微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 2440/2410上将usb device改成usb host

2440/2410上将usb device改成usb host

时间:11-09 来源:互联网 点击:
之前的开发,要在2440上使用两个usb host口,一个接摄像头,一个接无线网卡。但友善之臂mini2440板子只有一个usb host口,曾想通过外接一个usb hub来解决,无线网卡接hub没有问题,但是摄像头插到hub上总是有错误:

usb 1-1: reset full speed USB device using s3c2410-ohci and address 3
usb 1-1.2: new full speed USB device using s3c2410-ohci and address 4
usb 1-1.2: device descriptor read/64, error -62
usb 1-1.2: device descriptor read/64, error -62
usb 1-1.2: new full speed USB device using s3c2410-ohci and address 5
usb 1-1.2: device descriptor read/64, error -62
usb 1-1.2: device descriptor read/64, error -62
usb 1-1.2: new full speed USB device using s3c2410-ohci and address 6
usb 1-1.2: device not accepting address 6, error -62
usb 1-1.2: new full speed USB device using s3c2410-ohci and address 7
usb 1-1.2: device not accepting address 7, error -62
hub 1-1:1.0: unable to enumerate USB device on port 2

本来想试着修改内核中关于hub.c和ohci-s3c2410中的代码,看看能不能好使,但后来在PC机上的hub下使用摄像头也不好使,看来是我使用的zc301摄像头对hub不支持吧。(估计一般的摄像头都对hub不支持,我又试了另一款也是这样的)。

所以放弃了在usb hub上使用摄像头的想法。记得以前看过关于s3c2410的手册,它应该是支持2个usb host通道的啊,2440应该也是如此。所以仔细看了下s3c2440的手册,发现第二个usb hos通道的管脚和usb device的管脚是复用的。所以感觉将usb device改成host应该是可行的,深入研究研究。(好像一些板子已经设计出来可以跳线选择,友善之臂的没这么设计)

要将usb device改成host,不只是硬件上需要改动,软件驱动上肯定也需要改动,所以分为硬件和软件两个部分。

硬件上:仔细看了mini2440的手册中的关于usb电路图,其实硬件电路上host和device没什么本质区别,一些外拉电阻不一样,VBUS的提供者不一样。将device改成host感觉外拉电阻不一样应该也不会影响使用,所以就没有改变,避免在板子上做手脚。其它的就是要给VBUS一个5v的电源,而不是像device一样电脑供电了。其它的就没什么改动了。自己动手做了一个usb host口。

软件上:本质就是对寄存器MISCCR的设置改变一下,为了以后改动方便,我参考了网上的一些《关于阳初2440 超值版只能使用一个 USB Host 问题的解决》的方法。以下主要参照了一些关于这个方法的帖子博客之类的。(转载一些)

第一篇:

修改linux-2.6.20.3/drivers/usb/host/Kconfig,添加:

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

修改/linux-2.6.20.3/drivers/usb/host/ohci-s3c2410.c

static int usb_hcd_s3c2410_probe (const struct hc_driver *driver,

struct platform_device *dev)

{

struct usb_hcd *hcd = NULL;

int retval;

//add by hiboy

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);

......

修改/linux-2.6.20.3/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 = "cant allocate hub irq buffer";

ret =

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top