[U-Boot] [PATCH 05/17] drivers: usb: musb: adopt musb backend driver to driver model
Mugunthan V N
mugunthanvnm at ti.com
Mon Feb 29 04:44:08 CET 2016
Currently all backend driver ops uses hard coded physical
address, so to adopt the driver to DM, add device pointer to ops
call backs so that drivers that drivers can get physical
addresses from the usb driver priv/plat data.
Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
---
arch/arm/include/asm/omap_musb.h | 7 +++++++
drivers/usb/musb-new/am35x.c | 35 +++++++++++++++++++++++++++++++++++
drivers/usb/musb-new/musb_dsps.c | 20 ++++++++++++++++++++
3 files changed, 62 insertions(+)
diff --git a/arch/arm/include/asm/omap_musb.h b/arch/arm/include/asm/omap_musb.h
index 8b9cb0e..d358148 100644
--- a/arch/arm/include/asm/omap_musb.h
+++ b/arch/arm/include/asm/omap_musb.h
@@ -15,9 +15,16 @@ extern const struct musb_platform_ops omap2430_ops;
struct omap_musb_board_data {
u8 interface_type;
+#ifndef CONFIG_DM_USB
void (*set_phy_power)(u8 on);
void (*clear_irq)(void);
void (*reset)(void);
+#else
+ struct udevice *dev;
+ void (*set_phy_power)(struct udevice *dev, u8 on);
+ void (*clear_irq)(struct udevice *dev);
+ void (*reset)(struct udevice *dev);
+#endif
};
enum musb_interface {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI};
diff --git a/drivers/usb/musb-new/am35x.c b/drivers/usb/musb-new/am35x.c
index b8791dd..60c8275 100644
--- a/drivers/usb/musb-new/am35x.c
+++ b/drivers/usb/musb-new/am35x.c
@@ -335,8 +335,13 @@ eoi:
/* EOI needs to be written for the IRQ to be re-asserted. */
if (ret == IRQ_HANDLED || epintr || usbintr) {
/* clear level interrupt */
+#ifndef CONFIG_DM_USB
if (data->clear_irq)
data->clear_irq();
+#else
+ if (data->clear_irq)
+ data->clear_irq(data->dev);
+#endif
/* write EOI */
musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
}
@@ -400,23 +405,38 @@ static int am35x_musb_init(struct musb *musb)
#endif
/* Reset the musb */
+#ifndef CONFIG_DM_USB
if (data->reset)
data->reset();
+#else
+ if (data->reset)
+ data->reset(data->dev);
+#endif
/* Reset the controller */
musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK);
/* Start the on-chip PHY and its PLL. */
+#ifndef CONFIG_DM_USB
if (data->set_phy_power)
data->set_phy_power(1);
+#else
+ if (data->set_phy_power)
+ data->set_phy_power(data->dev, 1);
+#endif
msleep(5);
musb->isr = am35x_musb_interrupt;
/* clear level interrupt */
+#ifndef CONFIG_DM_USB
if (data->clear_irq)
data->clear_irq();
+#else
+ if (data->clear_irq)
+ data->clear_irq(data->dev);
+#endif
return 0;
}
@@ -437,9 +457,14 @@ static int am35x_musb_exit(struct musb *musb)
del_timer_sync(&otg_workaround);
#endif
+#ifndef CONFIG_DM_USB
/* Shutdown the on-chip PHY and its PLL. */
if (data->set_phy_power)
data->set_phy_power(0);
+#else
+ if (data->set_phy_power)
+ data->set_phy_power(data->dev, 0);
+#endif
#ifndef __UBOOT__
usb_put_phy(musb->xceiv);
@@ -628,9 +653,14 @@ static int am35x_suspend(struct device *dev)
struct musb_hdrc_platform_data *plat = dev->platform_data;
struct omap_musb_board_data *data = plat->board_data;
+#ifndef CONFIG_DM_USB
/* Shutdown the on-chip PHY and its PLL. */
if (data->set_phy_power)
data->set_phy_power(0);
+#else
+ if (data->set_phy_power)
+ data->set_phy_power(data->dev, 0);
+#endif
clk_disable(glue->phy_clk);
clk_disable(glue->clk);
@@ -645,9 +675,14 @@ static int am35x_resume(struct device *dev)
struct omap_musb_board_data *data = plat->board_data;
int ret;
+#ifndef CONFIG_DM_USB
/* Start the on-chip PHY and its PLL. */
if (data->set_phy_power)
data->set_phy_power(1);
+#else
+ if (data->set_phy_power)
+ data->set_phy_power(data->dev, 1);
+#endif
ret = clk_enable(glue->phy_clk);
if (ret) {
diff --git a/drivers/usb/musb-new/musb_dsps.c b/drivers/usb/musb-new/musb_dsps.c
index bb7c952..69d2dd8 100644
--- a/drivers/usb/musb-new/musb_dsps.c
+++ b/drivers/usb/musb-new/musb_dsps.c
@@ -451,8 +451,13 @@ static int dsps_musb_init(struct musb *musb)
dsps_writel(reg_base, wrp->control, (1 << wrp->reset));
/* Start the on-chip PHY and its PLL. */
+#ifndef CONFIG_DM_USB
if (data->set_phy_power)
data->set_phy_power(1);
+#else
+ if (data->set_phy_power)
+ data->set_phy_power(data->dev, 1);
+#endif
musb->isr = dsps_interrupt;
@@ -492,8 +497,13 @@ static int dsps_musb_exit(struct musb *musb)
#endif
/* Shutdown the on-chip PHY and its PLL. */
+#ifndef CONFIG_DM_USB
if (data->set_phy_power)
data->set_phy_power(0);
+#else
+ if (data->set_phy_power)
+ data->set_phy_power(data->dev, 0);
+#endif
#ifndef __UBOOT__
/* NOP driver needs change if supporting dual instance */
@@ -692,8 +702,13 @@ static int dsps_suspend(struct device *dev)
struct omap_musb_board_data *data = plat->board_data;
/* Shutdown the on-chip PHY and its PLL. */
+#ifndef CONFIG_DM_USB
if (data->set_phy_power)
data->set_phy_power(0);
+#else
+ if (data->set_phy_power)
+ data->set_phy_power(data->dev, 0);
+#endif
return 0;
}
@@ -704,8 +719,13 @@ static int dsps_resume(struct device *dev)
struct omap_musb_board_data *data = plat->board_data;
/* Start the on-chip PHY and its PLL. */
+#ifndef CONFIG_DM_USB
if (data->set_phy_power)
data->set_phy_power(1);
+#else
+ if (data->set_phy_power)
+ data->set_phy_power(data->dev, 1);
+#endif
return 0;
}
--
2.7.2.333.g70bd996
More information about the U-Boot
mailing list