On Mon, Jul 9, 2018 at 12:17 PM, Jagan Teki <ja...@amarulasolutions.com> wrote: > musb have platform ops to do proper graceful exit, > so add the exit call and move musb platform exit code > instead of keeping it in driver remove. > This make proper shutdown of musb where .remove will > call disable, exit serially via musb_stop. > > Signed-off-by: Jagan Teki <ja...@amarulasolutions.com> > --- > drivers/usb/musb-new/sunxi.c | 48 +++++++++++++++++++++--------------- > 1 file changed, 28 insertions(+), 20 deletions(-) > > diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c > index aa2880eeb9..9f71b84fd1 100644 > --- a/drivers/usb/musb-new/sunxi.c > +++ b/drivers/usb/musb-new/sunxi.c > @@ -326,6 +326,33 @@ static int sunxi_musb_init(struct musb *musb) > return 0; > } > > +static int sunxi_musb_exit(struct musb *musb) > +{ > + struct sunxi_glue *glue = to_sunxi_glue(musb->controller); > + int ret = 0; > + > + if (generic_phy_valid(&glue->phy)) { > + ret = generic_phy_exit(&glue->phy); > + if (ret) { > + dev_err(dev, "failed to power off usb phy\n"); > + return ret; > + } > + } > + > +#ifdef CONFIG_SUNXI_GEN_SUN6I
Same here, since you're refactoring this code, it would be appropriate to use compatibles and get rid of this ifdef. > + clrbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0)); > + if (glue->cfg->rst_bit) > + clrbits_le32(&glue->ccm->ahb_reset0_cfg, > + BIT(glue->cfg->rst_bit)); > +#endif > + clrbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0)); > + if (glue->cfg->clkgate_bit) > + clrbits_le32(&glue->ccm->ahb_gate0, > + BIT(glue->cfg->clkgate_bit)); > + > + return 0; > +} > + > static void sunxi_musb_pre_root_reset_end(struct musb *musb) > { > struct sunxi_glue *glue = to_sunxi_glue(musb->controller); > @@ -342,6 +369,7 @@ static void sunxi_musb_post_root_reset_end(struct musb > *musb) > > static const struct musb_platform_ops sunxi_musb_ops = { > .init = sunxi_musb_init, > + .exit = sunxi_musb_exit, > .enable = sunxi_musb_enable, > .disable = sunxi_musb_disable, > .pre_root_reset_end = sunxi_musb_pre_root_reset_end, > @@ -456,29 +484,9 @@ static int musb_usb_remove(struct udevice *dev) > { > struct sunxi_glue *glue = dev_get_priv(dev); > struct musb_host_data *host = &glue->mdata; > - int ret; > - > - if (generic_phy_valid(&glue->phy)) { > - ret = generic_phy_exit(&glue->phy); > - if (ret) { > - pr_err("failed to exit %s USB PHY\n", dev->name); > - return ret; > - } > - } > > musb_stop(host->host); > > -#ifdef CONFIG_SUNXI_GEN_SUN6I > - clrbits_le32(&glue->ccm->ahb_reset0_cfg, BIT(AHB_GATE_OFFSET_USB0)); > - if (glue->cfg->rst_bit) > - clrbits_le32(&glue->ccm->ahb_reset0_cfg, > - BIT(glue->cfg->rst_bit)); > -#endif > - clrbits_le32(&glue->ccm->ahb_gate0, BIT(AHB_GATE_OFFSET_USB0)); > - if (glue->cfg->clkgate_bit) > - clrbits_le32(&glue->ccm->ahb_gate0, > - BIT(glue->cfg->clkgate_bit)); > - > free(host->host); > host->host = NULL; > > -- > 2.17.1 > > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > https://lists.denx.de/listinfo/u-boot _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot