fl2440 linux内核移植usb驱动
来源:互联网 发布:2013旧版qq软件 编辑:程序博客网 时间:2024/05/29 12:52
***********************************************************************************
开发板:fl2440
linux内核:linux-3.0
***********************************************************************************
1. 添加USB结构体变量,加厂商ID和设备ID
[zoulei@CentOS linux-3.0]$vim arch/arm/mach-s3c2440/mach-smdk2440.c
--- mach1-smdk2440.c 2017-04-15 06:12:36.061000246 -0700+++ mach2-smdk2440.c 2017-04-15 06:21:30.015999978 -0700@@ -13,6 +13,7 @@ * */ +#include <linux/dm9000.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/interrupt.h>@@ -22,6 +23,12 @@ #include <linux/serial_core.h> #include <linux/platform_device.h> #include <linux/io.h>+/* add by zoulei for norflash */ +#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>@@ -44,9 +51,45 @@ #include <plat/clock.h> #include <plat/devs.h> #include <plat/cpu.h>-+#include <plat/ts.h> /*Add by zoulei to support Touch screen, 2017.04.15*/ +#include <mach/regs-clock.h> /*Add by zoulei 2017.04.15, for usb_s3c2440_init() */ +#include <linux/i2c.h> /*Add by zoulei 2017.4.15, for AT24C512 driver */ +#include <linux/i2c/at24.h> /*Add by zoulei 2017.4.15, for AT24C512 driver */ +#include <linux/delay.h> #include <plat/common-smdk.h> +#define DM9000_BASE (S3C2410_CS4 + 0x300) +static struct resource s3c_dm9000_resource[] = { + [0] = { + .start = DM9000_BASE, + .end = DM9000_BASE + 3, + .flags = IORESOURCE_MEM + }, + [1] = { + .start = DM9000_BASE + 4, + .end = DM9000_BASE + 7, + .flags = IORESOURCE_MEM + }, + [2] = { + .start = IRQ_EINT7, + .end = IRQ_EINT7, + .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, + } +}; ++static struct dm9000_plat_data s3c_dm9000_pdata = { + .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM), +}; +static struct platform_device s3c_device_dm9000 = { + .name = "dm9000", + .id = -1, + .num_resources = ARRAY_SIZE(s3c_dm9000_resource), + .resource = s3c_dm9000_resource, + .dev = { + .platform_data = &s3c_dm9000_pdata, + }, +}; + static struct map_desc smdk2440_iodesc[] __initdata = { /* ISA IO Space map (memory space selected by A24) */ @@ -155,13 +198,30 @@ &s3c_device_wdt, &s3c_device_i2c0, &s3c_device_iis,+ &s3c_device_dm9000, }; +/* Add by zoulei 2017.04.15, fix device descriptor read/64, error -62 bug, value refer to datasheet P255 */ +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(16934400);+ s3c24xx_init_clocks(12000000); s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));+ usb_s3c2440_init(); /* Add by zoulei, 2017.04.15 */ } static void __init smdk2440_machine_init(void)
[zoulei@CentOS linux-3.0]$ vim drivers/usb/serial/option.c
--- option.c 2017-04-15 06:06:17.470001485 -0700+++ option1.c 2017-04-15 05:47:14.996001503 -0700@@ -50,7 +50,14 @@ static int option_send_setup(struct usb_serial_port *port); static void option_instat_callback(struct urb *urb); -/* Vendor and product IDs */+ /* Vendor and product IDs */ +static int vendor = 0; /* Add by zoulei */ +static int product = 0; /* Add by zoulei */ ++/* Vendor and product IDs */ +#define OPTION_VENDOR_RESERVED 0xFFFF /* Add by zoulei */ +#define OPTION_RESERVED_DEVICE 0xFFFF /* Add by zoulei */ + #define OPTION_VENDOR_ID 0x0AF0 #define OPTION_PRODUCT_COLT 0x5000 #define OPTION_PRODUCT_RICOLA 0x6000@@ -446,7 +453,8 @@ .reason = OPTION_BLACKLIST_SENDSETUP }; -static const struct usb_device_id option_ids[] = {+static struct usb_device_id option_ids[] = {+ { USB_DEVICE(OPTION_VENDOR_RESERVED, OPTION_RESERVED_DEVICE) }, { 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) },@@ -1079,6 +1087,15 @@ static int __init option_init(void) { int retval;+ + 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); + } + retval = usb_serial_register(&option_1port_device); if (retval) goto failed_1port_device_register;
2.添加U盘支持
[zoulei@CentOS linux-3.0]$ 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设备的支持
[*] legacy /proc/scsi/ support
<*> SCSI disk support //是对 USB 鼠标键盘的支持
<*> SCSI generic support //SCSI通用的支持
[*] Probe all LUNs on each SCSI device //所有在每个SCSI LUN探针装置
[*] HID Devices --->
<*> USB Human Interface Device (full HID) support //是对 USB 鼠标键盘的支持
[*] /dev/hiddev raw HID device support
[*] 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
(437) Default codepage for FAT //默认代码页
(iso8859-1) Default iocharset for FAT //默认字符集
-*- Native language support ---> //配置u盘的语言格式支持
--- Native language support
<*> Codepage 437 (United States, Canada)
<*> Simplified Chinese charset (CP936, GB2312)
<*> ASCII (United States)
<*> NLS UTF-8
3.自动挂载:
[zoulei@centos6 ~]$ cd /home/zoulei/opt/rootfs/etc
[zoulei@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)
******************************************************************************************************************************
注意:根文件树加了这个配置文件就可以自动挂载了,否则就需要手动挂载:mount /dev/sda /mnt/usb
如果你的U盘在板子上显示是sd,也可能有的设备是ub,这时候进入你的根文件树查看是否自动挂载
sd的设备后置a-z或者0-9都可以显示自动挂载 ub的设备后置从a-z可以显示自动挂载,如果你的ub设备显示数字,可将第三行改为
#ub[a-z][0-9] 0:0 0777 @(mount /dev/$MDEV /mnt/usb)
mmcblk的设备也是如此。
4.开发板上操作
当插上U盘后开发板上显示:
查看挂载到/mnt/usb目录,可以看到里面有我的u盘的内容,说明U盘移植成功了!
不过自己还是有个疑问:自己已经添加了中文支持。可是u盘还是显示不了中文,不知道为什么?
遇到的问题及解决方法:
- fl2440 linux内核移植usb驱动
- fl2440 usb驱动移植
- fl2440内核移植(五)——USB驱动移植
- ARM9开发板FL2440移植Linux-3.0内核————添加USB驱动
- FL2440移植Linux内核
- FL2440开发板Linux内核添加USB驱动
- 内核linux-3.0移植到fl2440-----添加DM9000网卡驱动
- fl2440内核linux-3.0移植-----添加led驱动
- 基于fl2440内核linux-3.0移植----添加按键驱动
- 基于fl2440内核linux-3.0移植----添加adc驱动
- fl2440——移植USB驱动、内核添加USB支持、U盘挂载
- Linux内核移植 part3:usb host驱动
- Arm9+linux fl2440 驱动移植之RTC(实时时钟)和USB host
- 关于fl2440开发板Linux内核添加USB驱动的问题
- FL2440移植内核Linux-3.0过程。
- fl2440内核移植过程Linux-3.0
- FL2440 Linux-3.0内核最小系统移植
- 内核linux-3.0移植到fl2440-----添加U盘,MMC和LCD驱动
- 51NOD1264 线段相交(计算几何)
- SPOJ QTREE Query on a tree
- 在园区网中实施VLAN
- L1-034. 点赞
- Item37 Make std::threads unjoinable on all paths
- fl2440 linux内核移植usb驱动
- Git版本管理工具的学习
- 【357】Count Numbers with Unique Digits
- NYOJ 小珂的烦恼
- 日常收集有用的网址:
- spring整合struts2和hibernate在删除关联数据的时候特别注意
- 【剑指offer之反转链表】九度OJ-1518-反转链表
- JAVA基本类型与包装类
- 【C++学习笔记】递增/递减运算符和指针