void print_usb_msg(struct usb_msg_center_info * center_info) { DMSG_DBG_MANAGER("hw_insmod_host = %d\n", center_info->msg.hw_insmod_host); DMSG_DBG_MANAGER("hw_rmmod_host = %d\n", center_info->msg.hw_rmmod_host); DMSG_DBG_MANAGER("hw_insmod_device = %d\n", center_info->msg.hw_insmod_device); DMSG_DBG_MANAGER("hw_rmmod_device = %d\n", center_info->msg.hw_rmmod_device); }
/* ******************************************************************************* * usb_msg_center * * Description: * void * * Parameters: * void * * Return value: * void * * note: * void * ******************************************************************************* */ void usb_msg_center(struct usb_cfg *cfg) { enum usb_role role = USB_ROLE_NULL; struct usb_msg_center_info * center_info = &g_center_info; /* receive massage */ print_usb_msg(center_info); modify_msg(¢er_info->msg); /* execute cmd */ role = get_usb_role(); DMSG_DBG_MANAGER("role=%d\n", get_usb_role()); switch(role){ case USB_ROLE_NULL: do_usb_role_null(center_info); break; case USB_ROLE_HOST: do_usb_role_host(center_info); break; case USB_ROLE_DEVICE: do_usb_role_device(center_info); break; default: DMSG_PANIC("ERR: unkown role(%x)\n", role); } return; }
/* ******************************************************************************* * usb_manager_exit * * Description: * void * * Parameters: * void * * Return value: * void * * note: * void * ******************************************************************************* */ static void __exit usb_manager_exit(void) { bsp_usbc_t usbc; DMSG_DBG_MANAGER("[sw usb]: usb_manager_exit\n"); #if defined(CONFIG_USB_SW_SUN3I_USB0_DEVICE_ONLY) DMSG_INFO("CONFIG_USB_SW_SUN3I_USB0_DEVICE_ONLY\n"); #elif defined(CONFIG_USB_SW_SUN3I_USB0_HOST_ONLY) DMSG_INFO("CONFIG_USB_SW_SUN3I_USB0_HOST_ONLY\n"); #elif defined(CONFIG_USB_SW_SUN3I_USB0_OTG) DMSG_INFO("CONFIG_USB_SW_SUN3I_USB0_OTG\n"); #else DMSG_INFO("CONFIG_USB_SW_SUN3I_USB0_NULL\n"); return; #endif memset(&usbc, 0, sizeof(bsp_usbc_t)); USBC_exit(&usbc); #ifdef CONFIG_USB_SW_SUN3I_USB0_OTG thread_run_flag = 0; while(!thread_stopped_flag){ DMSG_INFO("waitting for usb_hardware_scan_thread stop\n"); } usb_hw_scan_exit(&g_usb_cfg); #endif usbc0_platform_device_exit(); usbc1_platform_device_exit(); usbc2_platform_device_exit(); return; }
static int usb_hardware_scan_thread(void * pArg) { struct usb_cfg *cfg = pArg; while(thread_run_flag){ DMSG_DBG_MANAGER("\n\n"); usb_hw_scan(cfg); usb_msg_center(cfg); DMSG_DBG_MANAGER("\n\n"); msleep(1000); /* 1s */ } thread_stopped_flag = 1; return 0; }
static void print_gpio_set(user_gpio_set_t *gpio_set) { DMSG_DBG_MANAGER("gpio_name = %s\n", gpio_set->gpio_name); DMSG_DBG_MANAGER("port = %x\n", gpio_set->port); DMSG_DBG_MANAGER("port_num = %x\n", gpio_set->port_num); DMSG_DBG_MANAGER("mul_sel = %x\n", gpio_set->mul_sel); DMSG_DBG_MANAGER("pull = %x\n", gpio_set->pull); DMSG_DBG_MANAGER("drv_level = %x\n", gpio_set->drv_level); DMSG_DBG_MANAGER("data = %x\n", gpio_set->data); }
/* ******************************************************************************* * 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_SUN3I_USB0_OTG struct task_struct *th = NULL; #endif DMSG_DBG_MANAGER("[sw usb]: usb_manager_init\n"); #if defined(CONFIG_USB_SW_SUN3I_USB0_DEVICE_ONLY) DMSG_INFO("CONFIG_USB_SW_SUN3I_USB0_DEVICE_ONLY\n"); #elif defined(CONFIG_USB_SW_SUN3I_USB0_HOST_ONLY) DMSG_INFO("CONFIG_USB_SW_SUN3I_USB0_HOST_ONLY\n"); #elif defined(CONFIG_USB_SW_SUN3I_USB0_OTG) DMSG_INFO("CONFIG_USB_SW_SUN3I_USB0_OTG\n"); #else DMSG_INFO("CONFIG_USB_SW_SUN3I_USB0_NULL\n"); return 0; #endif memset(&g_usb_cfg, 0, sizeof(struct usb_cfg)); ret = get_usb_cfg(&g_usb_cfg); if(ret != 0){ DMSG_PANIC("ERR: get_usb_cfg failed\n"); return -1; } 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(); usbc1_platform_device_init(); usbc2_platform_device_init(); #ifdef CONFIG_USB_SW_SUN3I_USB0_OTG 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_DBG_MANAGER("[sw usb]: usb_manager_init end\n"); return 0; }
/* ******************************************************************************* * print_usb_cfg * * Description: * void * * Parameters: * void * * Return value: * void * * note: * void * ******************************************************************************* */ static void print_usb_cfg(struct usb_cfg *cfg) { u32 i = 0; DMSG_DBG_MANAGER("\n-----------usb config information--------------\n"); DMSG_DBG_MANAGER("controller number = %x\n", (u32)USBC_MAX_CTL_NUM); DMSG_DBG_MANAGER("usb_global_enable = %x\n", cfg->usb_global_enable); DMSG_DBG_MANAGER("usbc_num = %x\n", cfg->usbc_num); for(i = 0; i < USBC_MAX_CTL_NUM; i++){ DMSG_DBG_MANAGER("\n"); DMSG_DBG_MANAGER("port[%d]:\n", i); DMSG_DBG_MANAGER("enable = %x\n", cfg->port[i].enable); DMSG_DBG_MANAGER("port_no = %x\n", cfg->port[i].port_no); DMSG_DBG_MANAGER("port_type = %x\n", cfg->port[i].port_type); DMSG_DBG_MANAGER("detect_type = %x\n", cfg->port[i].detect_type); DMSG_DBG_MANAGER("id.valid = %x\n", cfg->port[i].id.valid); DMSG_DBG_MANAGER("id.group_type = %x\n", cfg->port[i].id.group_type); print_gpio_set(&cfg->port[i].id.gpio_set); DMSG_DBG_MANAGER("vbus.valid = %x\n", cfg->port[i].det_vbus.valid); DMSG_DBG_MANAGER("vbus.group_type = %x\n", cfg->port[i].det_vbus.group_type); print_gpio_set(&cfg->port[i].det_vbus.gpio_set); DMSG_DBG_MANAGER("drv_vbus.valid = %x\n", cfg->port[i].drv_vbus.valid); DMSG_DBG_MANAGER("drv_vbus.group_type = %x\n", cfg->port[i].drv_vbus.group_type); print_gpio_set(&cfg->port[i].drv_vbus.gpio_set); DMSG_DBG_MANAGER("\n"); } DMSG_DBG_MANAGER("-------------------------------------------------\n"); }