mini6410 2.6.38移植 USB

 

  一、首先是U盘得支持。
1、vi arch/arm/mach-s3c64xx/mach-mini6410.c
124行增加
/* Initializes OTG Phy. to output 48M clock */
void s3c_otg_phy_config(int enable) {
u32 val;
if (enable) {
__raw_writel(0x0, S3C_PHYPWR); /* Power up */
val = __raw_readl(S3C_PHYCLK);
val &= ~S3C_PHYCLK_CLKSEL_MASK;
__raw_writel(val, S3C_PHYCLK);
__raw_writel(0x1, S3C_RSTCON);
udelay(5);
__raw_writel(0x0, S3C_RSTCON); /* Finish the reset */
udelay(5);
} else {
__raw_writel(0x19, S3C_PHYPWR); /* Power down */
}
}
2、vi drivers/usb/host/ohci-s3c2410.c
修改方法
@@ -25,10 +25,14 @@
#define valid_port(idx) ((idx) == 1 || (idx) == 2)
+#ifdef CONFIG_MACH_MINI6410
+extern void s3c_otg_phy_config(int enable);
+#endif
+
/* clock device associated with the hcd */
static struct clk *clk;
-static struct clk *usb_clk;
+static struct clk *otg_clk, *usb_clk;
/* forward definitions */
@@ -47,6 +51,11 @@
dev_dbg(&dev->dev, "s3c2410_start_hc:\n");
+ clk_enable(otg_clk);
+#ifdef CONFIG_MACH_MINI6410
+ s3c_otg_phy_config(1);
+#endif
+
clk_enable(usb_clk);
mdelay(2); /* let the bus clock stabilise */
@@ -79,6 +88,7 @@
clk_disable(clk);
clk_disable(usb_clk);
+ clk_disable(otg_clk);
}
/* ohci_s3c2410_hub_status_data
@@ -375,6 +385,13 @@
goto err_clk;
}
+ otg_clk = clk_get(&dev->dev, "otg");
+ if (IS_ERR(otg_clk)) {
+ dev_err(&dev->dev, "cannot get otg clock\n");
+ retval = -ENOENT;
+ goto err_otg;
+ }
+
s3c2410_start_hc(dev, hcd);
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
@@ -395,6 +412,10 @@
err_ioremap:
s3c2410_stop_hc(dev);
iounmap(hcd->regs);
+
+ clk_put(otg_clk);
+
+ err_otg:
clk_put(usb_clk);
err_clk:
3、make menuconfig
Device Drivers --->
SCSI device support --->
<*> SCSI device support
<*> SCSI disk support
<*> SCSI generic support
USB support
<*> Support for Host-side USB
[*] USB device filesystem (DEPRECATED)
<*> USB Monitor
<*> OHCI HCD support
<*> USB Mass Storage support
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盘显示
[root@FriendlyARM /]# usb 1-1.2: new full speed USB device using s3c2410-ohci and address 3
usb 1-1.2: New USB device found, idVendor=1043, idProduct=8012
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.2: Product: USB Flash Drive
usb 1-1.2: Manufacturer: Generic
uba: uba4
挂载 mount /dev/uba4 /mnt后即能看到u盘里的数据了
二、说说usb摄像头的和usb-wifi的支持吧,这两个东西得看你的设备是什么芯片,
先说usb摄像头吧,关于摄像头的驱动驱动配置比较简单,只是关于驱动接口有两种版本,分别
是V4L和V4L2,从2.6以后以后有了V4L2,我的linux2.6.38已经看不到关于v4l支持了,
在linux2.6.30.4的版本中我们还能看到

中有Video For linux API 1的支持,但38的版本却看不到了,所以 像gspcav1-20071224.tar.gz这样的v4l接口的驱动就加不进去了,
而很多V4l接口的usb测试程序也就用不了了,网上很少有V4l2的测试程序,所以友善也就没有开源的他的USB摄像头程序了(个人理解,不知是否正确)
既然这样我们就学友善的,按V4l2的来配置吧
我的摄像头芯片是sunplus凌阳的SPCA2000C的,支持UVC,支持UVC的就可以不用管是什么芯片了,选上一个就行
Device Drivers --->
<*> Multimedia support --->
<*> Video For Linux
[*] Video capture adapters --->
[*] V4L USB devices --->
<*> USB Video Class (UVC) 选上这个就行了
make zImage后启动,插上usb摄像头,显示
[root@FriendlyARM /]# usb 1-1.1: new full speed USB device using s3c2410-ohci and address 4
usb 1-1.1: New USB device found, idVendor=04fc, idProduct=2003
usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.1: Product: Sunplus Camera
usb 1-1.1: Manufacturer: Sunplus Camera
usb 1-1.1: SerialNumber: CN0316-MM00-OV03-VH-R61.01.00
uvcvideo: Found UVC 1.00 device Sunplus Camera (04fc:2003)
input: Sunplus Camera as /devices/platform/s3c2410-ohci/usb1/1-1/1-1.1/1-1.1:1.0/input/input1
在/dev/多了个video0,
测试的话用mjpg-streamer就能够测试了具体看友善光盘A中的 开发文档和教程 中的 专题04 通过Web远程浏览并控制Mini6410上的摄像头

此外,我还有个中星微的芯片是ZC0301的摄像头,它的配置是
Device Drivers --->
<*> Multimedia support --->
<*> Video For Linux
[*] Video capture adapters --->
<*> GSPCA based webcams --->
<*> ZC3XX USB Camera Driver
make zImage插上后显示
[root@FriendlyARM /]# usb 1-1.1: USB disconnect, address 4
usb 1-1.1: new full speed USB device using s3c2410-ohci and address 5
usb 1-1.1: New USB device found, idVendor=0ac8, idProduct=301b
usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.1: Product: PC Camera
usb 1-1.1: Manufacturer: Vimicro Corp.
gspca: probing 0ac8:301b
zc3xx: probe 2wr ov vga 0x0000
zc3xx: probe sensor -> 0011
zc3xx: Find Sensor HV7131R
input: zc3xx as /devices/platform/s3c2410-ohci/usb1/1-1/1-1.1/input/input2
gspca: video0 created
它采集到得数据直接是jpeg的,所以不能用mjpg-stream来测试,友善修改后mjpg-stream要求采集的数据是yuv货mjpg的,
我找了个基于v4l2的测试程序,看http://hi.baidu.com/aokikyon/blog/item/6e4e622c3e6f9be18b13993f.html,它将采集到数据直接存到了jpeg文件里面
见附件也行
三、说说usb-wifi的驱动
我的usb-wifi芯片是Ralink的RT2571WF,这个我是拆开看的,所以它的配置是
--- Wireless
<*> cfg80211 - wireless configuration API
<*> Generic IEEE 802.11 Networking Stack (mac80211)
[*] Wireless LAN --->
<*> Ralink driver support --->
<*> Ralink rt2501/rt73 (USB) support
然后make zImage后显示
[root@FriendlyARM /]# usb 1-1.2: new full speed USB device using s3c2410-ohci and address 3
usb 1-1.2: New USB device found, idVendor=148f, idProduct=2573
usb 1-1.2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
接着输入命令
0.ifconfig wlan0 up
1.列出区域内的无线网络
iwlist wlan0 scan
2.连接到网络
iwconfig wlan0 essid "MyHome" key s:12345
这个密码是无线路由的密码,如果没有就不用输入了。由于无线路由的密码形式有很多种,有wep和wpa什么的。
我们用的事wep,所以在输入key后加个s。
3.设置ip
ifconfig wlan0 10.10.86.91
3.启动网卡
ifconfig wlan0 up

这样就能够ping通了
总之,USB设备内核已经做的很多驱动,我们要做的是根据芯片选上对应的配置。
友善里面为USB做的驱动有两个,一个是usb转串口,一个是3g上网卡,这两个驱动是要自己加的,源码在
drivers/usb/serial/3g_devices.c
drivers/usb/serial/pl2303.c

原文地址:https://www.cnblogs.com/luxiaolai/p/2989403.html