Chinaunix首页 | 论坛 | 博客
  • 博客访问: 933120
  • 博文数量: 70
  • 博客积分: 1741
  • 博客等级: 上尉
  • 技术积分: 2476
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-05 14:46
个人简介

全志全系列芯片产品方案开发 A20/A33/A64/A40/A60/A83/A63/H3/H5/H6/H8

文章存档

2018年(1)

2012年(20)

2011年(49)

分类: LINUX

2011-11-26 09:16:16

在mach-xc2440.c中添加USB gadget驱动的支持:
加入必要的头文件:
#include

xc2440_devices[ ]结构体中加入:
&s3c_device_usbgadget,

构建USB gadget设备的平台数据结构:
  1. /* USB device UDC support */
  2. static void xc2440_udc_pullup(enum s3c2410_udc_cmd_e cmd)
  3. {
  4.     switch (cmd) {
  5.         case S3C2410_UDC_P_ENABLE :
  6.             gpio_set_value(S3C2410_GPG(12), 1);
  7.             break;
  8.         case S3C2410_UDC_P_DISABLE :
  9.             gpio_set_value(S3C2410_GPG(12), 0);
  10.             break;
  11.         case S3C2410_UDC_P_RESET :
  12.             break;
  13.         default:
  14.             break;
  15.     }
  16. }

static struct s3c2410_udc_mach_info xc2440_udc_cfg __initdata = {
.udc_command = xc2440_udc_pullup,
};

在xc2440_machine_init函数中加入:
s3c24xx_udc_set_platdata(&xc2440_udc_cfg);

配置内核,支持USB gadget驱动:
  1. Device Drivers --->
  2.     [*] USB support --->
  3.     <*> USB Gadget Support --->
  4.     USB Peripheral Controller (S3C2410 USB Device Controller) --->
  5. S3C2410 USB Device Controller
  6. USB Gadget Drivers
  7. File-backed Storage Gadget
  8. [*] File-backed Storage Gadget testing version
  9. Mass Storage Gadget

内核启动输出:
s3c2440-usbgadget s3c2440-usbgadget: S3C2440: increasing FIFO to 128 bytes

编译模块:
#make M=drivers/usb/gadget modules
在drivers/usb/gadget目录下生成:g_file_storage.kog_mass_storage.ko两个模块文件,将这两个文件下载到开发板的文件系统中,将文件放到:/lib/modules/2.6.37.4目录下
执行命令:#insmod /lib/modules/2.6.37.4/g_file_storage.ko file=/dev/sda1

[root@XC2440 /]# insmod /lib/modules/2.6.37.4/g_file_storage.ko file=/dev/sda1
g_file_storage gadget: No serial-number string provided!
g_file_storage gadget: File-backed Storage Gadget, version: 1 September 2010
g_file_storage gadget: Number of LUNs=1
g_file_storage gadget-lun0: ro=0, nofua=0, file: /dev/sda1
g_file_storage gadget: full speed config #1
g_file_storage gadget: full speed config #1



阅读(4877) | 评论(0) | 转发(5) |
给主人留下些什么吧!~~