将arm板上的usb设备端改为主设备端:
修改linux-2.6.18.2/drivers/usb/host/Kconfig,末尾添加:
/********************add begin************************/
........
config MAX_ROOT_PORTS
int "Maximum port(s) of RootHub"
depends on USB_OHCI_HCD && ARCH_S3C2410
default 1
---help---
pls select usb host number,default one host and one device.so We select one normally
/********************add end************************/
修改/linux-2.6.18.2/drivers/usb/host/ohci-s3c2410.c
/********************add begin************************/
#include <asm/arch/regs-gpio.h>
static int usb_hcd_s3c2410_probe (const struct hc_driver *driver, struct platform_device *dev)
{
struct usb_hcd *hcd = NULL;
int retval;
//add by guo
unsigned long tmp;
#if CONFIG_MAX_ROOT_PORTS < 2
/* 1 host port, 1 slave port*/
tmp = __raw_readl(S3C2410_MISCCR);
tmp &= ~S3C2410_MISCCR_USBHOST;
__raw_writel(tmp, S3C2410_MISCCR);
s3c2410_usb_set_power(dev->dev.platform_data, 1, 1);
#else
/* 2 host port */
tmp = __raw_readl(S3C2410_MISCCR);
tmp |= S3C2410_MISCCR_USBHOST;
__raw_writel(tmp, S3C2410_MISCCR);
s3c2410_usb_set_power(dev->dev.platform_data, 1, 1);
s3c2410_usb_set_power(dev->dev.platform_data, 2, 1);
#endif
//s3c2410_usb_set_power(dev->dev.platform_data, 1, 1);
//s3c2410_usb_set_power(dev->dev.platform_data, 2, 1);
......
/********************add end************************/
修改/linux-2.6.18.2/drivers/usb/core/hub.c
static int hub_configure(struct usb_hub *hub,
struct usb_endpoint_descriptor *endpoint)
{
struct usb_device *hdev = hub->hdev;
struct device *hub_dev = hub->intfdev;
u16 hubstatus, hubchange;
u16 wHubCharacteristics;
unsigned int pipe;
int maxp, ret;
char *message;
hub->buffer = usb_buffer_alloc(hdev, sizeof(*hub->buffer), GFP_KERNEL,
&hub->buffer_dma);
if (!hub->buffer) {
message = "can't allocate hub irq buffer";
ret = -ENOMEM;
goto fail;
}
hub->status = kmalloc(sizeof(*hub->status), GFP_KERNEL);
if (!hub->status) {
message = "can't kmalloc hub status buffer";
ret = -ENOMEM;
goto fail;
}
mutex_init(&hub->status_mutex);
hub->descriptor = kmalloc(sizeof(*hub->descriptor), GFP_KERNEL);
if (!hub->descriptor) {
message = "can't kmalloc hub descriptor";
ret = -ENOMEM;
goto fail;
}
/* Request the entire hub descriptor.
* hub->descriptor can handle USB_MAXCHILDREN ports,
* but the hub can/will return fewer bytes here.
*/
ret = get_hub_descriptor(hdev, hub->descriptor,
sizeof(*hub->descriptor));
if (ret < 0) {
message = "can't read hub descriptor";
goto fail;
} else if (hub->descriptor->bNbrPorts > USB_MAXCHILDREN) {
message = "hub has too many ports!";
ret = -ENODEV;
goto fail;
}
/*********************add begin**********************/
/*add by guo */
#ifdef CONFIG_ARCH_S3C2410
if ((hdev->devnum == 1) // Root Hub
&& hub->descriptor->bNbrPorts > CONFIG_MAX_ROOT_PORTS) {
int j;
for (j=hub->descriptor->bNbrPorts-1; j>=0; j--) {
printk("port #%d ", j);
if (j > CONFIG_MAX_ROOT_PORTS-1) {
printk("suspened!/n");
} else {
printk("alived!/n");
}
}
hub->descriptor->bNbrPorts = CONFIG_MAX_ROOT_PORTS;
}
#endif
/********************add end*************************/
内核配置:
Device Drivers --->
USB support --->
<*> Support for Host-side USB
[*] USB device filesystem
<*> OHCI HCD support
<*> SL811HS HCD support
(2) Maximum port(s) of RootHub
本文来自CSDN博客:http://blog.csdn.net/guolihua/archive/2009/08/26/4487190.aspx
在开发板上有一个USB HOST接口,还有两个是USB HOST和USB DEVICE复用接口,现在需要把复用口改来作为USBHOST接口,让开发板上实现两个USB HOST接口功能。
步骤:
设置好交叉编译工具链,Linux内核是前面移植的2.6.32.8版本,在原来移植修改后的基础上进入下面操作。
通过s3c2440的datasheet可知,要实现USB Host功能,只需设置MISCCR寄存器的位3就可以。
1、修改drivers/usb/host/Kconfig文件,添加如下内容:
2、修改drivers/usb/host/ohci-s3c2410.c文件,添加如下内容:
#ifdefCONFIG_GEC2440_TWO_USB_HOST
#include<mach/regs-gpio.h>
#endif
在static intusb_hcd_s3c2410_probe (const struct hc_driver *driver,structplatform_device *dev)函数的int retval;后面添加如下代码:
3、重新配置内核
上面部分修改好后,把板上的J26和J27都短接到HOST边,然后在J34引脚处的USB口插入U盘,可以识别到,但拨出时并无释放提示,重插入U盘则识别不到,该问题待解决。(如果你有解决的方法,请发至guochongxin@qq.com,谢谢!)
解决方法:
DeviceDrivers --->
现在拔出仍无提示,不过再插上就可以识别。(有时要多插几次才能识别)
参考:http://www.armchina.cn/article.asp?id=41
天嵌的TQ2440用户手册
上面那部分转自:http://blog.sina.com.cn/s/blog_3e4774e30100i94q.html