musb core doesn't need to know about platform specific details. So start moving clock handling to platform glue layer and make musb core agnostic about that.
···4040struct omap2430_glue {4141 struct device *dev;4242 struct platform_device *musb;4343+ struct clk *clk;4344};44454546static struct timer_list musb_idle_timer;···278277{279278 u32 l;280279281281- if (!musb->clock)282282- return 0;283283-284280 /* in any role */285281 l = musb_readl(musb->mregs, OTG_FORCESTDBY);286282 l |= ENABLEFORCE; /* enable MSTANDBY */···289291290292 otg_set_suspend(musb->xceiv, 1);291293292292- if (musb->set_clock)293293- musb->set_clock(musb->clock, 0);294294- else295295- clk_disable(musb->clock);296296-297294 return 0;298295}299296···296303{297304 u32 l;298305299299- if (!musb->clock)300300- return 0;301301-302306 otg_set_suspend(musb->xceiv, 0);303303-304304- if (musb->set_clock)305305- musb->set_clock(musb->clock, 1);306306- else307307- clk_enable(musb->clock);308307309308 l = musb_readl(musb->mregs, OTG_SYSCONFIG);310309 l &= ~ENABLEWAKEUP; /* disable wakeup */···341356 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;342357 struct platform_device *musb;343358 struct omap2430_glue *glue;359359+ struct clk *clk;344360345361 int ret = -ENOMEM;346362···357371 goto err1;358372 }359373374374+ clk = clk_get(&pdev->dev, "ick");375375+ if (IS_ERR(clk)) {376376+ dev_err(&pdev->dev, "failed to get clock\n");377377+ ret = PTR_ERR(clk);378378+ goto err2;379379+ }380380+381381+ ret = clk_enable(clk);382382+ if (ret) {383383+ dev_err(&pdev->dev, "failed to enable clock\n");384384+ goto err3;385385+ }386386+360387 musb->dev.parent = &pdev->dev;361388 musb->dev.dma_mask = &omap2430_dmamask;362389 musb->dev.coherent_dma_mask = omap2430_dmamask;363390364391 glue->dev = &pdev->dev;365392 glue->musb = musb;393393+ glue->clk = clk;366394367395 pdata->platform_ops = &omap2430_ops;368396···386386 pdev->num_resources);387387 if (ret) {388388 dev_err(&pdev->dev, "failed to add resources\n");389389- goto err2;389389+ goto err4;390390 }391391392392 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));393393 if (ret) {394394 dev_err(&pdev->dev, "failed to add platform_data\n");395395- goto err2;395395+ goto err4;396396 }397397398398 ret = platform_device_add(musb);399399 if (ret) {400400 dev_err(&pdev->dev, "failed to register musb device\n");401401- goto err2;401401+ goto err4;402402 }403403404404 return 0;405405+406406+err4:407407+ clk_disable(clk);408408+409409+err3:410410+ clk_put(clk);405411406412err2:407413 platform_device_put(musb);···425419426420 platform_device_del(glue->musb);427421 platform_device_put(glue->musb);422422+ clk_disable(glue->clk);423423+ clk_put(glue->clk);428424 kfree(glue);429425430426 return 0;
-15
drivers/usb/musb/tusb6010.c
···281281 void __iomem *tbase = musb->ctrl_base;282282 u32 reg;283283284284- /*285285- * Keep clock active when enabled. Note that this is not tied to286286- * drawing VBUS, as with OTG mA can be less than musb->min_power.287287- */288288- if (musb->set_clock) {289289- if (mA)290290- musb->set_clock(musb->clock, 1);291291- else292292- musb->set_clock(musb->clock, 0);293293- }294294-295284 /* tps65030 seems to consume max 100mA, with maybe 60mA available296285 * (measured on one board) for things other than tps and tusb.297286 *···526537 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);527538528539 if (is_on) {529529- if (musb->set_clock)530530- musb->set_clock(musb->clock, 1);531540 timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);532541 musb->xceiv->default_a = 1;533542 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;···564577565578 devctl &= ~MUSB_DEVCTL_SESSION;566579 conf &= ~TUSB_DEV_CONF_USB_HOST_MODE;567567- if (musb->set_clock)568568- musb->set_clock(musb->clock, 0);569580 }570581 prcm &= ~(TUSB_PRCM_MNGMT_15_SW_EN | TUSB_PRCM_MNGMT_33_SW_EN);571582