Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1207849
  • 博文数量: 322
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 3276
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-17 09:21
文章分类

全部博文(322)

文章存档

2010年(155)

2009年(167)

我的朋友

分类: 嵌入式

2010-03-09 11:54:50

S3C2410 USB的驱动
代码修改——修改arch/arm/mach-s3c2410/mach-smdk2410.c
+#include
+#include
+#include
+#include


static struct s3c2410_hcd_info usb_sbc2410_info = {
    .port[0]        = {

            .flags  = S3C_HCDFLG_USED
     }
};

int usb_sbc2410_init(void)
{
unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03);
printk("USB Control, (c) 2006 sbc2410\n");
s3c_device_usb.dev.platform_data = &usb_sbc2410_info;
while(upllvalue!=__raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue,S3C2410_UPLLCON);
mdelay(1);
}
return 0;
}

static void __init smdk2410_map_io(void)
{
s3c24xx_init_io(smdk2410_iodesc, ARRAY_SIZE(smdk2410_iodesc));
s3c24xx_init_clocks(0);
s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
s3c24xx_set_board(&smdk2410_board);
usb_sbc2410_init();
}

3.
内核配置
>
让内核支持热插拔

General setup  --->  Support for hot-pluggable devices

>USB
驱动设置

Device Drivers  --->Generic Driver Options  

                                       ---> Hotplug firmware loading support  

                                Block devices  

                                       --->  Low Performance USB Block driver  

                                SCSI device support  

                                       --->  SCSI generic support  

                                              Probe all LUNs on each SCSI device

                                USB support  

                                       --->Support for Host-side USB    

                                USB device filesystem

                                        ---> USB Mass Storage support

                                              USB Monitor

>
加入MSDOS FSVFAT FS支持

File systems  ---> DOS/FAT/NT Filesystems  

                                     --->  MSDOS fs support

                                             VFAT (Windows-95) fs support

                                             (936) Default codepage for FAT

                                             (cp936) Default iocharset for FAT

做完这些后,插入u盘后,内核应该可以识别到u盘,出现:
usb 1-1: new full speed USB device using s3c2410-ohci and address 3
ub(1.3): GetMaxLUN returned 0, using 1 LUNs

但是,还有下面一句出错提示:
/dev/ub/a: unknown partition table

>
使能(DOS分区)CONFIG_MSDOS_PARTITION

File systems  ---> Partition Types  

                                ---> PC BIOS (MSDOS partition tables) support

以下是我的内核插入u盘后的提示信息:
usb 1-1: new full speed USB device using s3c2410-ohci and 2
ub(1.2): GetMaxLUN returned 0, using 1 LUNs
/dev/ub/a: p1
表示usb设备已经挂载到/dev/ub/a/part1目录下

>
加入中文字体库

Native Language Support  

                               ---> Simplified Chinese charset (CP936, GB2312)  

                                      NLS UTF8

以下是挂载usb设备后的显示:
[root@Emux /]# mount -t vfat -o iocharset=cp936 /dev/ub/a/part1 /mnt
[root@Emux /]# ls /mnt



4.
移植小结

>
如果想知道内核有没有识别出u盘的话可以执行命令:cat /proc/partitions ,看看插入USB前后分区信息有什么不同就知道了  

>
另外,如果想让内核把它当成SCSI设备来处理的话

Device Drivers  ---> Block devices  

                                      --->  Low Performance USB Block driver    
去掉

Device Drivers  --->SCSI device support

                                      --->  SCSI disk support                                  
添加

个人觉得使用usb设备的话Low Performance USB Block driverSCSI disk要好

>
一般都会新建一个/dev/sda1的链接指向usb设备的挂载点的,可以在启动文件中使用命令ln -s xxx xxx来建立这个链接
阅读(1044) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~