【目标】
1、使插在开发板上的U盘或者sdcard可被PC自动识别,并且通过USB线可被挂载到PC上。类似智能手机连接PC时,存储设备可被PC存取。
2、研究USBNET,使通过USB线就可以与PC进行网络通讯。
目前进度:
USB gadget配置项:
以下配置项待测试(<M>USB Gadget Support选项主要是编译出s3c2410_udc.ko,经过测试使用如下配置项也可,此时只编译出g_file_storage.ko。值得注意的是,insmod g_file_storage.ko file=/dev/sda1 removable=1是以发现到usb分区为基础的,因而启动结束后,仍然需要sleep几秒等待找到usb分区后,再安装驱动。):
<*> USB Gadget Support --->
USB Peripheral Controller (S3C2410 USB Device Controller) --->
S3C2410 USB Device Controller
[*] S3C2410 udc debug messages
<M> USB Gadget Drivers
<M> File-backed Storage Gadget
以下为移植USB gadget驱动和rtc驱动的patch
--- linux-2.6.32.6.orig/arch/arm/mach-s3c2410/include/mach/regs-gpio.h 2010-01-25 13:50:10.000000000 -0500
+++ linux-2.6.32.6/arch/arm/mach-s3c2410/include/mach/regs-gpio.h 2010-09-17 18:42:44.000000000 -0400
@@ -199,6 +199,9 @@
#define S3C2400_GPB11_OUTP (0x01 << 22)
#define S3C2400_GPB11_DATA27 (0x02 << 22)
+//san 20100914 start
+#define S3C2410_GPG12 S3C2410_GPIONO(S3C2410_GPIO_BANKG, 12)
+//san 20100914 end
#define S3C2400_GPB12_INP (0x00 << 24)
#define S3C2400_GPB12_OUTP (0x01 << 24)
#define S3C2400_GPB12_DATA28 (0x02 << 24)
--- linux-2.6.32.6.orig/drivers/usb/gadget/r8a66597-udc.c 2010-01-25 13:50:10.000000000 -0500
+++ linux-2.6.32.6/drivers/usb/gadget/r8a66597-udc.c 2010-09-14 19:06:39.000000000 -0400
@@ -32,6 +32,10 @@
#include "r8a66597-udc.h"
+//san 20100914 start
+#include <linux/err.h>
+//san 20100914 end
+
#define DRIVER_VERSION "2009-08-18"
static const char udc_name[] = "r8a66597_udc";
--- linux-2.6.32.6.orig/drivers/watchdog/s3c2410_wdt.c 2010-01-25 13:50:10.000000000 -0500
+++ linux-2.6.32.6/drivers/watchdog/s3c2410_wdt.c 2010-09-16 19:02:30.000000000 -0400
@@ -46,9 +46,13 @@
#define PFX "s3c2410-wdt: "
-#define CONFIG_S3C2410_WATCHDOG_ATBOOT (0)
-#define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME (15)
-
+//san 20100916 start
+//#define CONFIG_S3C2410_WATCHDOG_ATBOOT (0)
+//#define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME (15)
+
+#define CONFIG_S3C2410_WATCHDOG_ATBOOT (1)
+#define CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME (30)
+//san 20100916 end
static int nowayout = WATCHDOG_NOWAYOUT;
static int tmr_margin = CONFIG_S3C2410_WATCHDOG_DEFAULT_TIME;
static int tmr_atboot = CONFIG_S3C2410_WATCHDOG_ATBOOT;
--- linux-2.6.32.6.orig/arch/arm/mach-s3c2440/mach-smdk2440.c 2010-01-25 13:50:10.000000000 -0500
+++ linux-2.6.32.6/arch/arm/mach-s3c2440/mach-smdk2440.c 2010-09-17 19:04:03.000000000 -0400
@@ -47,6 +47,11 @@
#include <plat/common-smdk.h>
+//san start
+#include <plat/udc.h>
+#include <mach/gpio-fns.h>
+//san end
+
static struct map_desc smdk2440_iodesc[] __initdata = {
/* ISA IO Space map (memory space selected by A24) */
@@ -149,18 +154,49 @@
.lpcsel = ((0xCE6) & ~7) | 1<<4,
};
+//san start
+#if 1
+static void EmbedSky_udc_pullup(enum s3c2410_udc_cmd_e cmd)
+{
+ printk(KERN_DEBUG "EmbedSKy udc: pullup(%d)/n", cmd);
+ switch(cmd)
+ {
+ case S3C2410_UDC_P_ENABLE:
+ s3c2410_gpio_setpin(S3C2410_GPG12, 1);
+ break;
+ case S3C2410_UDC_P_DISABLE:
+ s3c2410_gpio_setpin(S3C2410_GPG12, 0);
+ break;
+ case S3C2410_UDC_P_RESET:
+ break;
+ default:
+ break;
+ }
+}
+
+static struct s3c2410_udc_mach_info EmbedSky_udc_cfg = {
+ .udc_command = EmbedSky_udc_pullup,
+};
+#endif
+//san end
+
static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
+ //san start
+ &s3c_device_rtc,
+ &s3c_device_usbgadget,
+ //san end
};
static void __init smdk2440_map_io(void)
{
s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
- s3c24xx_init_clocks(16934400);
+ //s3c24xx_init_clocks(16934400);
+ s3c24xx_init_clocks(12000000);
s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
}
@@ -171,6 +207,11 @@
platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));
smdk_machine_init();
+ //san start
+ s3c2410_gpio_setpin(S3C2410_GPG12, 0);
+ s3c2410_gpio_cfgpin(S3C2410_GPG12, S3C2410_GPIO_OUTPUT);
+ s3c24xx_udc_set_platdata(&EmbedSky_udc_cfg);
+ //san end
}
MACHINE_START(S3C2440, "SMDK2440")
编译
make modules SUBDIRS=drivers/usb/gadget
安装驱动
insmod s3c2410_udc.ko
sleep 2(usleep ??)
insmod g_file_storage.ko file=/dev/sda1 removable=1