首页 > 系统相关 >FL2440开发板Linux内核添加USB驱动

FL2440开发板Linux内核添加USB驱动

时间:2022-10-18 17:06:44浏览次数:35  
标签:+# usb FL2440 开发板 guowenxue USB include OPTION


———————————————————————————————————————
主机操作系统:Centos 6.7 
交叉编译器环境:arm-linux-gcc-4.5.4 
开发板平台: FL2440 
Linux内核版本: linux-3.0 
开发模块: LINUX内核添加USB
邮箱:[email protected]
———————————————————————————————————————
、添加U盘支持   
     FL2440添加u盘的挂载比较简单,大部分的内容都是在内核里面做make menuconfig,配置内核
 Device Drivers  ---> 
     Generic Driver Options  --->
                  (/sbin/hotplug) path to uevent helper                  //配置u盘的热插拔
      [*] Block devices  --->
                   <*>   Low Performance USB Block driver     //低性能USB块设备驱动
     SCSI device support  ---> 
                  <*> SCSI device support   //SCSI设备的支持
                  <*> SCSI generic support   //SCSI通用的支持
                  [*] Probe all LUNs on each SCSI device           //所有在每个SCSI LUN探针装置
     [*] USB support  ---> 
                 <*>   Support for Host-side USB          //主机端USB支持
                 [*]     USB device filesystem (DEPRECATED)  //USB设备文件系统(不推荐使用)
                 [*]     USB device class-devices (DEPRECATED)   / /USB设备类设备(不推荐使用)
                 <*>   USB Monitor          //USB监控
                 <*>   OHCI HCD support //支持OHCI标准
                 <*>   USB Mass Storage support //支持USB海量存储
File systems  --->                                              //配置u盘的文件系统
       DOS/FAT/NT Filesystems  --->
                  <*> MSDOS fs support
                  <*> VFAT (Windows-95) fs support
                   (936) Default codepage for FAT //默认代码页
                   (cp936) Default iocharset for FAT //默认字符集
      -*- Native language support  --->                                      //配置u盘的语言格式支持,不过感觉着个配置没什么用,中文也支持不了,也许是因为linux对中文的支持并不好吧
                    <*>   Simplified Chinese charset (CP936, GB2312)
                     <*>   ASCII (United States) 
                     <*>   NLS UTF-8

添加USB结构体变量,加厂商ID和设备ID

[leiyuxing@centos6 linux-3.0]$vim drivers/usb/serial/option.c
2964 @@ -51,6 +51,13 @@
2965 static void option_instat_callback(struct urb *urb);
2966
2967 /* Vendor and product IDs */
2968 +static int vendor = 0; /* Add by guowenxue */
2969 +static int product = 0; /* Add by guowenxue */
2970 +
2971 +/* Vendor and product IDs */
2972 +#define OPTION_VENDOR_RESERVED 0xFFFF /* Add by guowenxue */
2973 +#define OPTION_RESERVED_DEVICE 0xFFFF /* Add by guowenxue */
2974 +
2975 #define OPTION_VENDOR_ID 0x0AF0
2976 #define OPTION_PRODUCT_COLT 0x5000
2977 #define OPTION_PRODUCT_RICOLA 0x6000
2978 @@ -446,7 +453,8 @@
2979 .reason = OPTION_BLACKLIST_SENDSETUP
2980 };
2981
2982-static const struct usb_device_id option_ids[] = {
2983 +static struct usb_device_id option_ids[] = {
2984 + { USB_DEVICE(OPTION_VENDOR_RESERVED, OPTION_RESERVED_DEVICE) }, /* Add by guowenxue */
2985 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
2986 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
2987 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
2988 @@ -1079,6 +1087,15 @@
2989 static int __init option_init(void)
2990 {
2991 int retval;
2992 +
2993 + if ((vendor>0) && (product>0))
2994 + {
2995 + option_ids[0].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
2996 + option_ids[0].idVendor = vendor;
2997 + option_ids[0].idProduct = product;
2998 + printk("Register option drvier for modem vendor=0x%04x product=0x%04x\n", vendor, product);
2999 + }
3000 +
[leiyuxing@centos6 linux-3.0]$ vim arch/arm/mach-s3c2440/mach-smdk2440.c
4 @@ -23,6 +23,13 @@
5 #include <linux/platform_device.h>
6 #include <linux/io.h>
7
8 +/* add by guowenxue for norflash */
9 +#include <linux/gpio_keys.h>
10 +#include <linux/input.h>
11 +#include <linux/mtd/physmap.h>
12 +#include <linux/mtd/mtd.h>
13 +#include <linux/mtd/partitions.h> 14 +
15 #include <asm/mach/arch.h>
16 #include <asm/mach/map.h>
17 #include <asm/mach/irq.h>
18 @@ -44,6 +51,11 @@
19 #include <plat/clock.h>
20 #include <plat/devs.h>
21#include <plat/cpu.h>
22 +#include <plat/ts.h> /*Add by guowenxue to support Touch screen, 2011.09.06*/
23 +#include <mach/regs-clock.h> /*Add by guowenxue 2012.07.15, for usb_s3c2440_init() */
24 +#include <linux/i2c.h> /*Add by guowenxue 2012.10.22, for AT24C512 driver */
25 +#include <linux/i2c/at24.h> /* Add by guowenxue 2012.10.22, for AT24C512 driver */
26 +#include <linux/delay.h>
27
28 #include <plat/common-smdk.h>
29
30@@ -102,6 +114,13 @@
31 }


224+/* Add by guowenxue 2012.07.15, fix device descriptor read/64, error -62 bug, value refer to datasheet P255 */
225 +int usb_s3c2440_init(void)
226 +{
227 + /* Input Frequency is 12.0000MHz, and MDEV=0x38 PDIV=2 SDIV=2, so output frequency 48.00MHz */
228 + unsigned long upllvalue = (0x38<<12)|(0x02<<4)|(0x02);
229 + while (upllvalue != __raw_readl(S3C2410_UPLLCON))
230 + {
231 + __raw_writel(upllvalue, S3C2410_UPLLCON);
232 + mdelay(1);
233 + }
234 +
235 + return 0;
236 +}
237 +
238 static void __init smdk2440_map_io(void)
239 {
240 s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
241 - s3c24xx_init_clocks(16934400);
242 + s3c24xx_init_clocks(12000000); /*Modify by guowenxue, 2011.08.30*/
243 s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
244 + usb_s3c2440_init(); /* Add by guowenxue, 2012.07.15 */
245 }
246

重新编译下内核,加载到开发板上,插入U盘会有如下显示

>: usb 1-1.1: new full speed USB device number 3 using s3c2410-ohci
scsi0 : usb-storage 1-1.1:1.0
scsi 0:0:0:0: Direct-Access SanDisk Ultra 1.00 PQ: 0 ANSI: 6
sd 0:0:0:0: [sda] 60062500 512-byte logical blocks: (30.7 GB/28.6 GiB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
sda: sda1
sd 0:0:0:0: [sda] Attached SCSI removable disk

U盘查看:

>: ls mnt/usb/
?????.docx
?????????.docx
System Volume Information
VMware-workstation-full-12.0.0-2985596.exe
scrt602_4768.exe
securecrt-kg.exe
~$?????.docx
~$???????.docx

有以上显示说明自动挂载成功。
还有一个关于自动挂载的问题,如果你的U盘在板子上显示是sd,也可能有的设备是ub,这时候进入你的根文件树查看是否自动挂载

[leiyuxing@centos6 ~]$ cd /home/leiyuxing/fl2440/rootfs/rootfs/etc
[leiyuxing@centos6 etc]$ vim mdev.conf
sd[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)
sd[a-z] 0:0 0777 $(umount /mnt/usb)
#ub[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)
#ub[a-z] 0:0 0777 $(umount /mnt/usb)
mmcblk[0-9]p[0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/sdc)
mmcblk[0-9] 0:0 0777 $(umount /mnt/sdc)

sd的设备后置a-z或者0-9都可以显示自动挂载
ub的设备后置从a-z可以显示自动挂载,如果你的ub设备显示数字,可将第三行改为
#ub[a-z][0-9]      0:0 0777        @(mount /dev/$MDEV /mnt/usb)
mmcblk的设备也是如此。

标签:+#,usb,FL2440,开发板,guowenxue,USB,include,OPTION
From: https://blog.51cto.com/u_15834920/5767599

相关文章