免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3180 | 回复: 9
打印 上一主题 下一主题

USB设备问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-07-24 16:06 |只看该作者 |倒序浏览
LINUX内核版本2.6.21,使用我的两块板子(cpu均为s3c2416),一块作为USB HOST,一块作为USB DEVICE。现在情况是将DEVICE设备连到HOST上出错,错误消息如下:
[root@urbetter /]# 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侧的驱动都是移植的友坚开发板自带的驱动。
由上述消息大概问题出在哪,我现在都没有方向了。请指教。

论坛徽章:
0
2 [报告]
发表于 2013-07-24 16:52 |只看该作者
USB的时钟有问题

论坛徽章:
0
3 [报告]
发表于 2013-07-24 16:56 |只看该作者
一种方法是在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[] = {
        [0] = DEFINE_RES_MEM(S3C_PA_USBHOST, SZ_256),
        [1] = 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);

论坛徽章:
0
4 [报告]
发表于 2013-07-25 19:03 |只看该作者
你好,感谢回复。
请问以上代码是添加到哪个文件?
另外以上配置为2440,2416也是一样的吗?

论坛徽章:
0
5 [报告]
发表于 2013-07-26 09:56 |只看该作者
在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


   

论坛徽章:
0
6 [报告]
发表于 2013-07-26 10:28 |只看该作者
我按照你的指点,在/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寄存器中,这是怎么回事?

论坛徽章:
0
7 [报告]
发表于 2013-07-26 10:37 |只看该作者
好的,我测试下。
另外我有些不明白的是ohci不是host端的吗,现在问题是在device侧?

论坛徽章:
0
8 [报告]
发表于 2013-07-26 10:41 |只看该作者
是你的主机的upll不对回复 7# thzhr2009


   

论坛徽章:
0
9 [报告]
发表于 2013-07-26 10:45 |只看该作者
本帖最后由 wwxxxxll 于 2013-07-26 10:50 编辑

你没看到打印是写进去和读出来不对
这确实有点奇怪,写寄存器不成功!
回复 6# thzhr2009


   

论坛徽章:
0
10 [报告]
发表于 2013-07-26 10:57 |只看该作者

应该是寄存器不一样,我查下手册。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP