/* * power up s3c-udc power & enable otg clock */ void s3c_udc_power_up(void) { struct s3c_udc *dev = the_controller; #ifdef CONFIG_CPU_FREQ set_dvfs_level(0); #endif /* CONFIG_CPU_FREQ */ if(dev->udc_state == USB_STATE_NOTATTACHED) { DEBUG_PM("[%s] \n", __func__); S3C_UDC_POWER_UP: fsa9480_s3c_udc_on(); if(!dev->clocked) { if(clk_enable(otg_clock) != 0) { DEBUG_ERROR("\n[%s] clk_enable(otg_clock) failed.\n", __func__); } else { dev->clocked = 1; DEBUG_PM("\n[%s] clk_enable(otg_clock) OK.\n", __func__); } } else DEBUG_PM("\n[%s] already clk_enabled.\n", __func__); if(s3c_udc_enable(dev) != 0 || !dev->clocked) { /* Just in case */ DEBUG_ERROR("\n[%s] FAIL TO s3c_udc_enable()\n", __func__); DEBUG_ERROR("\n[%s] Power UP again.\n", __func__); goto S3C_UDC_POWER_UP; } else DEBUG_PM("\n[%s] POWER-UP OK!.\n", __func__); } else { DEBUG_PM("[%s] skipped , already powered up\n", __func__); if(!readl(S3C_UDC_OTG_GINTMSK) || !dev->clocked) { /* Just in case */ DEBUG_ERROR("\n[%s] !readl(S3C_UDC_OTG_GINTMSK) || !dev->clocked\n", __func__); DEBUG_ERROR("\n[%s] Power UP again.\n", __func__); goto S3C_UDC_POWER_UP; } } dev->powered = 1; }
/* * usb_gadget_register_driver * Register entry point for the peripheral controller driver. */ int usb_gadget_register_driver(struct usb_gadget_driver *driver) { struct s3c_udc *dev = the_controller; int retval; DEBUG_SETUP("%s: %s\n", __func__, driver->driver.name); #if 1 /* adb composite fail to !driver->unbind in composite.c as below static struct usb_gadget_driver composite_driver = { .speed = USB_SPEED_HIGH, .bind = composite_bind, .unbind = __exit_p(composite_unbind), */ if (!driver || (driver->speed < USB_SPEED_FULL) || !driver->bind || !driver->disconnect || !driver->setup) return -EINVAL; #else if (!driver || (driver->speed != USB_SPEED_FULL && driver->speed != USB_SPEED_HIGH) || !driver->bind || !driver->unbind || !driver->disconnect || !driver->setup) return -EINVAL; #endif if (!dev) return -ENODEV; if (dev->driver) return -EBUSY; /* first hook up the driver ... */ dev->devstatus = 1 << USB_DEVICE_SELF_POWERED; dev->driver = driver; dev->gadget.dev.driver = &driver->driver; retval = device_add(&dev->gadget.dev); if(retval) { /* TODO */ DEBUG_ERROR("target device_add failed, error %d\n", retval); return retval; } retval = driver->bind(&dev->gadget); if (retval) { DEBUG_ERROR("%s: bind to driver %s --> error %d\n", dev->gadget.name, driver->driver.name, retval); device_del(&dev->gadget.dev); dev->driver = 0; dev->gadget.dev.driver = 0; return retval; } enable_irq(IRQ_OTG); DEBUG_SETUP("Registered gadget driver '%s'\n", driver->driver.name); #ifndef CONFIG_PM s3c_udc_enable(dev); #endif /* in case of rndis, will be chaned at the time of SET_CONFIGURATION */ if (strcmp(driver->driver.name, "g_ether") == 0) dev->config_gadget_driver = ETHER_CDC; else if (strcmp(driver->driver.name, "android_adb") == 0) dev->config_gadget_driver = ANDROID_ADB; else if (strcmp(driver->driver.name, "android_usb") == 0) dev->config_gadget_driver = ANDROID_ADB_UMS; else if (strcmp(driver->driver.name, "android_adb_ums_acm") == 0) dev->config_gadget_driver = ANDROID_ADB_UMS_ACM; else if (strcmp(driver->driver.name, "g_serial") == 0) dev->config_gadget_driver = SERIAL; else if (strcmp(driver->driver.name, "g_cdc") == 0) dev->config_gadget_driver = CDC2; else if (strcmp(driver->driver.name, "g_file_storage") == 0) dev->config_gadget_driver = FILE_STORAGE; else DEBUG_ERROR("Not recognized driver's name '%s'\n", driver->driver.name); return 0; }