__s32 usbc0_platform_device_init(struct usb_port_info *port_info) { /* device */ #ifndef CONFIG_ARCH_SUN9IW1 #if defined (CONFIG_ARCH_SUN8IW6) || defined (CONFIG_ARCH_SUN8IW7) || defined (CONFIG_ARCH_SUN8IW8) sunxi_udc_cfg.port_info = port_info; sunxi_udc_cfg.usbc_base = (unsigned int __force)SUNXI_USB_OTG_VBASE; /* host */ sunxi_hcd_config.port_info = port_info; platform_device_register(&sunxi_udc_device); #if !defined (CONFIG_ARCH_SUN8IW8) && !defined (CONFIG_ARCH_SUN8IW7) platform_device_register(&sunxi_hcd_device); #endif device_create_file(&sunxi_udc_device.dev, &dev_attr_hw_scan_debug); { int ret = 0; int i = 0; for (i = 0; i < ARRAY_SIZE(chose_attrs); i++) { ret = device_create_file(&sunxi_udc_device.dev, &chose_attrs[i]); if (ret) DMSG_INFO_MANAGER("create_device_attrs_file fail\n"); } } #else sunxi_udc_cfg.port_info = port_info; sunxi_udc_cfg.usbc_base = (unsigned int __force)SUNXI_USB_OTG_VBASE; /* host */ sunxi_hcd_config.port_info = port_info; switch(port_info->port_type) { case USB_PORT_TYPE_DEVICE: platform_device_register(&sunxi_udc_device); break; case USB_PORT_TYPE_HOST: platform_device_register(&sunxi_hcd_device); break; case USB_PORT_TYPE_OTG: platform_device_register(&sunxi_udc_device); platform_device_register(&sunxi_hcd_device); device_create_file(&sunxi_udc_device.dev, &dev_attr_hw_scan_debug); { int ret = 0; int i = 0; for (i = 0; i < ARRAY_SIZE(chose_attrs); i++) { ret = device_create_file(&sunxi_udc_device.dev, &chose_attrs[i]); if (ret) DMSG_INFO_MANAGER("create_host_attrs_file fail\n"); } } break; default: DMSG_PANIC("ERR: unkown port_type(%d)\n", port_info->port_type); } #endif #else bsp_usb300_init(); sunxi_otg.resource[0].start = sunxi_otgc_base(); sunxi_otg.resource[0].end = sunxi_otgc_base() + 0xfffff; platform_device_register(&sunxi_otg); device_create_file(&sunxi_otg.dev, &dev_attr_hw_scan_debug); { int ret = 0; int i = 0; for (i = 0; i < ARRAY_SIZE(chose_attrs); i++) { ret = device_create_file(&sunxi_otg.dev, &chose_attrs[i]); if (ret) DMSG_INFO_MANAGER("create_host_attrs_file fail\n"); } } #endif return 0; }
/* ******************************************************************************* * usb_manager_init * * Description: * void * * Parameters: * void * * Return value: * void * * note: * void * ******************************************************************************* */ static int __init usb_manager_init(void) { __s32 ret = 0; bsp_usbc_t usbc; u32 i = 0; #ifdef CONFIG_USB_SW_SUN4I_USB0_OTG struct task_struct *th = NULL; #endif DMSG_MANAGER_DEBUG("[sw usb]: usb_manager_init\n"); #if defined(CONFIG_USB_SW_SUN4I_USB0_DEVICE_ONLY) DMSG_INFO_MANAGER("CONFIG_USB_SW_SUN4I_USB0_DEVICE_ONLY\n"); #elif defined(CONFIG_USB_SW_SUN4I_USB0_HOST_ONLY) DMSG_INFO_MANAGER("CONFIG_USB_SW_SUN4I_USB0_HOST_ONLY\n"); #elif defined(CONFIG_USB_SW_SUN4I_USB0_OTG) DMSG_INFO_MANAGER("CONFIG_USB_SW_SUN4I_USB0_OTG\n"); #else DMSG_INFO_MANAGER("CONFIG_USB_SW_SUN4I_USB0_NULL\n"); return 0; #endif memset(&g_usb_cfg, 0, sizeof(struct usb_cfg)); g_usb_cfg.usb_global_enable = 1; g_usb_cfg.usbc_num = 3; ret = get_usb_cfg(&g_usb_cfg); if(ret != 0){ DMSG_PANIC("ERR: get_usb_cfg failed\n"); return -1; } if(g_usb_cfg.port[0].enable == 0){ DMSG_PANIC("wrn: usb0 is disable\n"); return 0; } memset(&usbc, 0, sizeof(bsp_usbc_t)); for(i = 0; i < USBC_MAX_CTL_NUM; i++){ usbc.usbc_info[i].num = i; switch(i){ case 0: usbc.usbc_info[i].base = SW_VA_USB0_IO_BASE; break; case 1: usbc.usbc_info[i].base = SW_VA_USB1_IO_BASE; break; case 2: usbc.usbc_info[i].base = SW_VA_USB2_IO_BASE; break; default: DMSG_PANIC("ERR: unkown cnt(%d)\n", i); usbc.usbc_info[i].base = 0; } } usbc.sram_base = SW_VA_SRAM_IO_BASE; USBC_init(&usbc); usbc0_platform_device_init(&g_usb_cfg.port[0]); #ifdef CONFIG_USB_SW_SUN4I_USB0_OTG if(g_usb_cfg.port[0].port_type == USB_PORT_TYPE_OTG && g_usb_cfg.port[0].detect_type == USB_DETECT_TYPE_VBUS_ID){ usb_hw_scan_init(&g_usb_cfg); thread_run_flag = 1; thread_stopped_flag = 0; th = kthread_create(usb_hardware_scan_thread, &g_usb_cfg, "usb-hardware-scan"); if(IS_ERR(th)){ DMSG_PANIC("ERR: kthread_create failed\n"); return -1; } wake_up_process(th); } #endif DMSG_MANAGER_DEBUG("[sw usb]: usb_manager_init end\n"); return 0; }