fl2440添加USB驱动

版权声明:转载请附带原博主的网址 https://blog.csdn.net/qq_43260665/article/details/89789136

最近在做fl2440网卡使用3G模块实现AP和STA模式上网。在此之前,必须添加USB驱动
1,修改linux内核的menuconfig

Device Drivers  --->
	Generic Driver Options  --->  
		(/sbin/hotplug) path to uevent helper
	[*] Block devices  --->	
		<*>   Low Performance USB Block driver
	SCSI device support  --->
		<*> SCSI device support
		[*] legacy /proc/scsi/ support
		<*> SCSI disk support
		<*> SCSI generic support
		[*] Probe all LUNs on each SCSI device
	[*] USB support  --->
		<*>  Support for Host-side USB
		[*]     USB device filesystem (DEPRECATED)
		[*]     USB device class-devices (DEPRECATED)
		<*>  USB Monitor
		<*>  OHCI HCD support
		<*>   USB Mass Storage support 
	[*] HID Devices  --->
		<*>   USB Human Interface Device (full HID) support 
		[*]   /dev/hiddev raw HID device support
File systems  --->
	DOS/FAT/NT Filesystems  --->
		<*> MSDOS fs support                                               
        <*> VFAT (Windows-95) fs support                                      
        (437) Default codepage for FAT                                      
        (iso8859-1) Default iocharset for FAT                                
        <*> NTFS file system support                                          
        [*]   NTFS debugging support                                        
        [*]   NTFS write support

2,修改内核源码

zhanghang@ubuntu:~/fl2440/linux/linux-3.0$ vim drivers/usb/serial/option.c

修改如下:
以下为我做的一个补丁文件:
vim option.patch

--- option.c    2019-05-03 01:17:06.087400313 -0700
+++ option_s.c  2019-05-01 23:31:19.000000000 -0700
@@ -49,6 +49,11 @@
                        const struct usb_device_id *id);
 static int option_send_setup(struct usb_serial_port *port);
 static void option_instat_callback(struct urb *urb);
+/*add for USB*/
+static int vendor=0;
+static int product=0;
+#define OPTION_VENDOR_RESERVED 0xFFFF
+#define OPTION_RESERVED_DEVICE 0xFFFF
 /* Vendor and product IDs */
 #define OPTION_VENDOR_ID                       0x0AF0
 #define OPTION_PRODUCT_COLT                    0x5000
@@ -444,8 +449,9 @@
        .ifaceinfo = zte_k3765_z_no_sendsetup,
        .reason = OPTION_BLACKLIST_SENDSETUP
 };
-
-static const struct usb_device_id option_ids[] = {
+/*delete const of this struct*/
+static struct usb_device_id option_ids[] = {
+    { USB_DEVICE(OPTION_VENDOR_RESERVED,OPTION_RESERVED_DEVICE) },//add for USB
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
        { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
@@ -1077,6 +1083,13 @@
 /* Functions used by new usb-serial code. */
 static int __init option_init(void)
 {
+    if ((vendor>0) && (product>0))
+    {
+        option_ids[0].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
+        option_ids[0].idVendor = vendor;
+        option_ids[0].idProduct = product;
+        printk("Register option drvier for modem vendor=0x%04x                  product=0x%04x\n", vendor, product);
+    }//add for USB
        int retval;
        retval = usb_serial_register(&option_1port_device);
        if (retval)
vim arch/arm/mach-s3c2440/mach-smdk2440.c

vim mach-smdk2440.patch

--- mach-smdk2440.c     2019-05-03 01:29:10.771422429 -0700
+++ ./fl2440/linux/linux-3.0/arch/arm/mach-s3c2440/mach-smdk2440.c      2019-05-03 01:34:15.003431713 -0700
@@ -23,6 +23,11 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/dm9000.h>
+#include <linux/gpio_keys.h>
+#include <linux/input.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
@@ -44,6 +49,11 @@
 #include <plat/clock.h>
 #include <plat/devs.h>
 #include <plat/cpu.h>
+#include <plat/ts.h>
+#include <mach/regs-clock.h>
+#include <linux/i2c.h>
+#include <linux/i2c/at24.h>
+#include <linux/delay.h>

 #include <plat/common-smdk.h>
 #define DM9000_BASE    (S3C2410_CS4 + 0x300)
@@ -187,12 +197,23 @@
        &s3c_device_iis,
        &s3c_device_dm9000,
 };
-
+int usb_s3c2440_init(void)
+{
+       /*  Input Frequency is 12.0000MHz, and MDEV=0x38 PDIV=2 SDIV=2, so output frequency 48.00MHz */
+       unsigned long upllvalue = (0x38<<12)|(0x02<<4)|(0x02); 
+       while (upllvalue != __raw_readl(S3C2410_UPLLCON))
+       {
+               __raw_writel(upllvalue, S3C2410_UPLLCON);
+               mdelay(1);
+       }
+       return 0;
+}
 static void __init smdk2440_map_io(void)
 {
        s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
        s3c24xx_init_clocks(12000000);
        s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
+       usb_s3c2440_init();
 }

 static void __init smdk2440_machine_init(void)

再次编译内核生成.bin文件移植到开发板:
显示:

...
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mousedev: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
...

此时插入U盘,将会有提示:

~ >: usb 1-1.1: new full speed USB device number 3 using s3c2410-ohci
...

拔出U盘:

~ >: usb 1-1.1: USB disconnect, device number 3

猜你喜欢

转载自blog.csdn.net/qq_43260665/article/details/89789136
今日推荐