USB设备问题
LINUX内核版本2.6.21,使用我的两块板子(cpu均为s3c2416),一块作为USB HOST,一块作为USB DEVICE。现在情况是将DEVICE设备连到HOST上出错,错误消息如下:# usb 1-1.1: new full speed USB device using s3c2410-ohci and address 3
usb 1-1.1: device descriptor read/64, error -62
usb 1-1.1: device descriptor read/64, error -62
usb 1-1.1: new full speed USB device using s3c2410-ohci and address 4
usb 1-1.1: device descriptor read/64, error -62
usb 1-1.1: device descriptor read/64, error -62
usb 1-1.1: new full speed USB device using s3c2410-ohci and address 5
usb 1-1.1: device not accepting address 5, error -62
usb 1-1.1: new full speed USB device using s3c2410-ohci and address 6
usb 1-1.1: device not accepting address 6, error -62
可确定HOST侧是好的(因为我连上U盘可正常识别),看来问题应该在DEVICE这边。
HOST和DEVICE侧的驱动都是移植的友坚开发板自带的驱动。
由上述消息大概问题出在哪,我现在都没有方向了。请指教。 USB的时钟有问题 一种方法是在uboot中改,也可以在加载驱动时加一下,
我把ret = platform_add_devices(s3c2440_devices, 1);中的usb加载,没有放在启动,而是用insmod加载
加载时初始化upll
static u64 samsung_device_dma_mask = DMA_BIT_MASK(32);
static struct resource s3c_usb_resource[] = {
= DEFINE_RES_MEM(S3C_PA_USBHOST, SZ_256),
= DEFINE_RES_IRQ(IRQ_USBH),
};
struct platform_device s3c_device_ohci = {
.name = "s3c2440-ohci",
.id = -1,
.num_resources= ARRAY_SIZE(s3c_usb_resource),
.resource = s3c_usb_resource,
.dev = {
.dma_mask = &samsung_device_dma_mask,
.coherent_dma_mask = DMA_BIT_MASK(32),
}
};
static struct platform_device *s3c2440_devices[] __initdata =
{
&s3c_device_ohci,
};
static void usb_s3c2440_init_pll(void)
{
u32 upll_value;
upll_value = ((0x38 << 12) | (0x02 << 4) | (0x02 << 0));
do {
printk(KERN_INFO "UPLLCON = %x, wxl add\n", upll_value);
writel(upll_value, S3C2410_UPLLCON);
mdelay(1);
}while(upll_value != readl(S3C2410_UPLLCON));
}
static int __init s3c2440_usb_init(void)
int ret;
usb_s3c2440_init_pll();
ret = platform_add_devices(s3c2440_devices, 1);
return ret;
}
static void __exit s3c2440_usb_exit(void)
{
//platform_device_put(&s3c2440_uart_device);
}
MODULE_LICENSE("GPL");
module_init(s3c2440_usb_init);
module_exit(s3c2440_usb_exit);
你好,感谢回复。
请问以上代码是添加到哪个文件?
另外以上配置为2440,2416也是一样的吗? 在mach-smdk2416.c
中有platform_add_devices(smdk2416_devices, ARRAY_SIZE(smdk2416_devices));
static struct platform_device *smdk2416_devices[] __initdata = {
&s3c_device_fb,
&s3c_device_wdt,
&s3c_device_ohci,
ohci的加载
2440类似
这是系统初始化时就加载了
我把&s3c_device_ohci,去掉
单独写了一个模块,动态加载。就你看到的。你应该没去掉吧
upll初始化主要是
static void usb_s3c2440_init_pll(void)
{
u32 upll_value;
upll_value = ((0x38 << 12) | (0x02 << 4) | (0x02 << 0));
do {
printk(KERN_INFO "UPLLCON = %x, wxl add\n", upll_value);
writel(upll_value, S3C2410_UPLLCON);
mdelay(1);
}while(upll_value != readl(S3C2410_UPLLCON));
}
s3c2416的寄存器和s3c2440应该差不多
主要是upll_value的值,要么自己算,要么查一下uboot中的值。
还有usb_s3c2440_init_pll放那里,你没有把platform_add_devices单独,
你可以做一个简单的模块,init只做usb_s3c2440_init_pll,加载它。
也可以在ochi中的probe加载。
回复 4# thzhr2009
我按照你的指点,在/arch/arm/mach-s3c2416/mach-smdk2416.c中增加上述代码:
static void usb_s3c2416_init_pull(void)
{
u32 upll_value;
upll_value=((0x38<<12)|(0x02<<4)|(0x02<<0));
do
{
printk(KERN_INFO "upllcon=%x,wxl add\n",upll_value);
writel(upll_value,S3C2410_UPLLCON);
printk(KERN_INFO "read S3C2410_UPLLCON=%x\n",readl(S3C2410_UPLLCON));
mdelay(1);
}
while(upll_value!=readl(S3C2410_UPLLCON));
}
将此函数增加到smdk2416_machine_init()中:
static void __init smdk2416_machine_init(void)
{
/* SROM init for NFS */
printk("^^^^smdk2416_machine_init()^^zhr^^^^^^\n");
smdk2416_cs89x0_set();
hsspi_set_gpio();
usb_s3c2416_init_pull();
smdk_machine_init();
s3c_device_spi0.dev.platform_data= &s3c2416_spi0_platdata;
spi_register_board_info(s3c2416_spi0_board, ARRAY_SIZE(s3c2416_spi0_board));
}
但目前出现上电后出现usb_s3c2416_init_pull()函数中do while死循环:
read S3C2410_UPLLCON=8022
upllcon=38022,wxl add
read S3C2410_UPLLCON=8022
upllcon=38022,wxl add
read S3C2410_UPLLCON=8022
看来upllcon就没有写入S3C2410_UPLLCON寄存器中,这是怎么回事? 好的,我测试下。
另外我有些不明白的是ohci不是host端的吗,现在问题是在device侧? 是你的主机的upll不对回复 7# thzhr2009
本帖最后由 wwxxxxll 于 2013-07-26 10:50 编辑
你没看到打印是写进去和读出来不对
这确实有点奇怪,写寄存器不成功!
回复 6# thzhr2009
对
应该是寄存器不一样,我查下手册。
页:
[1]