From 3ca8abb84522f4b773678726db6ebd6fc277bc96 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 21 Oct 2010 13:56:40 +0300 Subject: usb: musb: introduce struct musb_platform_ops This will be passed to musb_core by platform glue layer in order to make it easier to compile support for several HW glue layers. Later patches will come using this structure and also moving HW glue layers to its own platform driver; the idea is to be able to handle platform peculiarities in a manner which doesn't affect one another. Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 6ad72f395e28..59928a235dc5 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -253,6 +253,34 @@ enum musb_g_ep0_state { /******************************** TYPES *************************************/ +/** + * struct musb_platform_ops - Operations passed to musb_core by HW glue layer + * @init: turns on clocks, sets up platform-specific registers, etc + * @exit: undoes @init + * @suspend: platform-specific suspend, e.g. context save + * @resume: platform-specific resume, e.g. context restore + * @set_mode: forcefully changes operating mode + * @try_ilde: tries to idle the IP + * @vbus_status: returns vbus status if possible + * @set_vbus: forces vbus status + */ +struct musb_platform_ops { + int (*init)(struct musb *musb); + int (*exit)(struct musb *musb); + + int (*suspend)(struct musb *musb); + int (*resume)(struct musb *musb); + + void (*enable)(struct musb *musb); + void (*disable)(struct musb *musb); + + int (*set_mode)(struct musb *musb, u8 mode); + void (*try_idle)(struct musb *musb, unsigned long timeout); + + int (*vbus_status)(struct musb *musb); + void (*set_vbus)(struct musb *musb, int on); +}; + /* * struct musb_hw_ep - endpoint hardware (bidirectional) * -- cgit v1.2.2 From 743411b3f3e96e8ac4cae73551a0a95392fed1ea Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 1 Dec 2010 13:22:05 +0200 Subject: usb: musb: make all glue layer export struct musb_platform_ops preparing to a big refactor on musb code. We need to be able to compile in all glue layers (or at least all ARM-based ones) together and have a working binary. While preparing for that, we move every glue layer to export only one symbol, which is a struct musb_platform_ops, and make all other functions static. Later patches will come to allow for compiling all glue layers together and have a working binary. Signed-off-by: Felipe Balbi --- drivers/usb/musb/am35x.c | 37 ++++++--- drivers/usb/musb/blackfin.c | 106 ++++++++++++++++-------- drivers/usb/musb/da8xx.c | 37 ++++++--- drivers/usb/musb/davinci.c | 40 +++++---- drivers/usb/musb/musb_core.c | 8 +- drivers/usb/musb/musb_core.h | 174 ++++++++++++++++++++++++++-------------- drivers/usb/musb/musb_virthub.c | 2 +- drivers/usb/musb/omap2430.c | 46 +++++++---- drivers/usb/musb/tusb6010.c | 62 ++++++++------ 9 files changed, 335 insertions(+), 177 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index b0aabf3a606f..be17610d7fc2 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -122,9 +122,9 @@ static inline void phy_off(void) } /* - * musb_platform_enable - enable interrupts + * am35x_musb_enable - enable interrupts */ -void musb_platform_enable(struct musb *musb) +static void am35x_musb_enable(struct musb *musb) { void __iomem *reg_base = musb->ctrl_base; u32 epmask; @@ -143,9 +143,9 @@ void musb_platform_enable(struct musb *musb) } /* - * musb_platform_disable - disable HDRC and flush interrupts + * am35x_musb_disable - disable HDRC and flush interrupts */ -void musb_platform_disable(struct musb *musb) +static void am35x_musb_disable(struct musb *musb) { void __iomem *reg_base = musb->ctrl_base; @@ -162,7 +162,7 @@ void musb_platform_disable(struct musb *musb) #define portstate(stmt) #endif -static void am35x_set_vbus(struct musb *musb, int is_on) +static void am35x_musb_set_vbus(struct musb *musb, int is_on) { WARN_ON(is_on && is_peripheral_active(musb)); } @@ -221,7 +221,7 @@ static void otg_timer(unsigned long _musb) spin_unlock_irqrestore(&musb->lock, flags); } -void musb_platform_try_idle(struct musb *musb, unsigned long timeout) +static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout) { static unsigned long last_timer; @@ -251,7 +251,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) mod_timer(&otg_workaround, timeout); } -static irqreturn_t am35x_interrupt(int irq, void *hci) +static irqreturn_t am35x_musb_interrupt(int irq, void *hci) { struct musb *musb = hci; void __iomem *reg_base = musb->ctrl_base; @@ -362,7 +362,7 @@ eoi: return ret; } -int musb_platform_set_mode(struct musb *musb, u8 musb_mode) +static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode) { u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); @@ -391,7 +391,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) return 0; } -int __init musb_platform_init(struct musb *musb, void *board_data) +static int am35x_musb_init(struct musb *musb) { void __iomem *reg_base = musb->ctrl_base; u32 rev, lvl_intr, sw_reset; @@ -427,7 +427,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) if (is_host_enabled(musb)) setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); - musb->board_set_vbus = am35x_set_vbus; + musb->board_set_vbus = am35x_musb_set_vbus; /* Global reset */ sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); @@ -446,7 +446,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) msleep(5); - musb->isr = am35x_interrupt; + musb->isr = am35x_musb_interrupt; /* clear level interrupt */ lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); @@ -461,7 +461,7 @@ exit0: return status; } -int musb_platform_exit(struct musb *musb) +static int am35x_musb_exit(struct musb *musb) { if (is_host_enabled(musb)) del_timer_sync(&otg_workaround); @@ -522,3 +522,16 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) memcpy(dst, &val, len); } } + +const struct musb_platform_ops musb_ops = { + .init = am35x_musb_init, + .exit = am35x_musb_exit, + + .enable = am35x_musb_enable, + .disable = am35x_musb_disable, + + .set_mode = am35x_musb_set_mode, + .try_idle = am35x_musb_try_idle, + + .set_vbus = am35x_musb_set_vbus, +}; diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index e8cbcc59c419..9874501d6429 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -277,7 +277,7 @@ static void musb_conn_timer_handler(unsigned long _musb) DBG(4, "state is %s\n", otg_state_string(musb)); } -void musb_platform_enable(struct musb *musb) +static void bfin_musb_enable(struct musb *musb) { if (!is_otg_enabled(musb) && is_host_enabled(musb)) { mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); @@ -285,11 +285,11 @@ void musb_platform_enable(struct musb *musb) } } -void musb_platform_disable(struct musb *musb) +static void bfin_musb_disable(struct musb *musb) { } -static void bfin_set_vbus(struct musb *musb, int is_on) +static void bfin_musb_set_vbus(struct musb *musb, int is_on) { int value = musb->config->gpio_vrsel_active; if (!is_on) @@ -302,51 +302,29 @@ static void bfin_set_vbus(struct musb *musb, int is_on) musb_readb(musb->mregs, MUSB_DEVCTL)); } -static int bfin_set_power(struct otg_transceiver *x, unsigned mA) +static int bfin_musb_set_power(struct otg_transceiver *x, unsigned mA) { return 0; } -void musb_platform_try_idle(struct musb *musb, unsigned long timeout) +static void bfin_musb_try_idle(struct musb *musb, unsigned long timeout) { if (!is_otg_enabled(musb) && is_host_enabled(musb)) mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); } -int musb_platform_get_vbus_status(struct musb *musb) +static int bfin_musb_get_vbus_status(struct musb *musb) { return 0; } -int musb_platform_set_mode(struct musb *musb, u8 musb_mode) +static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode) { return -EIO; } -int __init musb_platform_init(struct musb *musb) +static void bfin_musb_reg_init(struct musb *musb) { - - /* - * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE - * and OTG HOST modes, while rev 1.1 and greater require PE7 to - * be low for DEVICE mode and high for HOST mode. We set it high - * here because we are in host mode - */ - - if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) { - printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d \n", - musb->config->gpio_vrsel); - return -ENODEV; - } - gpio_direction_output(musb->config->gpio_vrsel, 0); - - usb_nop_xceiv_register(); - musb->xceiv = otg_get_transceiver(); - if (!musb->xceiv) { - gpio_free(musb->config->gpio_vrsel); - return -ENODEV; - } - if (ANOMALY_05000346) { bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value); SSYNC(); @@ -380,21 +358,69 @@ int __init musb_platform_init(struct musb *musb) EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA | EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA); SSYNC(); +} + +static int bfin_musb_init(struct musb *musb) +{ + + /* + * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE + * and OTG HOST modes, while rev 1.1 and greater require PE7 to + * be low for DEVICE mode and high for HOST mode. We set it high + * here because we are in host mode + */ + + if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) { + printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d\n", + musb->config->gpio_vrsel); + return -ENODEV; + } + gpio_direction_output(musb->config->gpio_vrsel, 0); + + usb_nop_xceiv_register(); + musb->xceiv = otg_get_transceiver(); + if (!musb->xceiv) { + gpio_free(musb->config->gpio_vrsel); + return -ENODEV; + } + + bfin_musb_reg_init(musb); if (is_host_enabled(musb)) { - musb->board_set_vbus = bfin_set_vbus; + musb->board_set_vbus = bfin_musb_set_vbus; setup_timer(&musb_conn_timer, musb_conn_timer_handler, (unsigned long) musb); } if (is_peripheral_enabled(musb)) - musb->xceiv->set_power = bfin_set_power; + musb->xceiv->set_power = bfin_musb_set_power; musb->isr = blackfin_interrupt; return 0; } -int musb_platform_exit(struct musb *musb) +#ifdef CONFIG_PM +void musb_platform_save_context(struct musb *musb, + struct musb_context_registers *musb_context) +{ + if (is_host_active(musb)) + /* + * During hibernate gpio_vrsel will change from high to low + * low which will generate wakeup event resume the system + * immediately. Set it to 0 before hibernate to avoid this + * wakeup event. + */ + gpio_set_value(musb->config->gpio_vrsel, 0); +} + +void musb_platform_restore_context(struct musb *musb, + struct musb_context_registers *musb_context) +{ + bfin_musb_reg_init(musb); +} +#endif + +static int bfin_musb_exit(struct musb *musb) { gpio_free(musb->config->gpio_vrsel); @@ -402,3 +428,17 @@ int musb_platform_exit(struct musb *musb) usb_nop_xceiv_unregister(); return 0; } + +const struct musb_platform_ops musb_ops = { + .init = bfin_musb_init, + .exit = bfin_musb_exit, + + .enable = bfin_musb_enable, + .disable = bfin_musb_disable, + + .set_mode = bfin_musb_set_mode, + .try_idle = bfin_musb_try_idle, + + .vbus_status = bfin_musb_vbus_status, + .set_vbus = bfin_musb_set_vbus, +}; diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 84427bebbf62..6161fc50d049 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -131,9 +131,9 @@ static inline void phy_off(void) */ /** - * musb_platform_enable - enable interrupts + * da8xx_musb_enable - enable interrupts */ -void musb_platform_enable(struct musb *musb) +static void da8xx_musb_enable(struct musb *musb) { void __iomem *reg_base = musb->ctrl_base; u32 mask; @@ -151,9 +151,9 @@ void musb_platform_enable(struct musb *musb) } /** - * musb_platform_disable - disable HDRC and flush interrupts + * da8xx_musb_disable - disable HDRC and flush interrupts */ -void musb_platform_disable(struct musb *musb) +static void da8xx_musb_disable(struct musb *musb) { void __iomem *reg_base = musb->ctrl_base; @@ -170,7 +170,7 @@ void musb_platform_disable(struct musb *musb) #define portstate(stmt) #endif -static void da8xx_set_vbus(struct musb *musb, int is_on) +static void da8xx_musb_set_vbus(struct musb *musb, int is_on) { WARN_ON(is_on && is_peripheral_active(musb)); } @@ -252,7 +252,7 @@ static void otg_timer(unsigned long _musb) spin_unlock_irqrestore(&musb->lock, flags); } -void musb_platform_try_idle(struct musb *musb, unsigned long timeout) +static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout) { static unsigned long last_timer; @@ -282,7 +282,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) mod_timer(&otg_workaround, timeout); } -static irqreturn_t da8xx_interrupt(int irq, void *hci) +static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) { struct musb *musb = hci; void __iomem *reg_base = musb->ctrl_base; @@ -380,7 +380,7 @@ static irqreturn_t da8xx_interrupt(int irq, void *hci) return ret; } -int musb_platform_set_mode(struct musb *musb, u8 musb_mode) +static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode) { u32 cfgchip2 = __raw_readl(CFGCHIP2); @@ -409,7 +409,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) return 0; } -int __init musb_platform_init(struct musb *musb, void *board_data) +static int da8xx_musb_init(struct musb *musb) { void __iomem *reg_base = musb->ctrl_base; u32 rev; @@ -431,7 +431,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) if (is_host_enabled(musb)) setup_timer(&otg_workaround, otg_timer, (unsigned long)musb); - musb->board_set_vbus = da8xx_set_vbus; + musb->board_set_vbus = da8xx_musb_set_vbus; /* Reset the controller */ musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); @@ -446,14 +446,14 @@ int __init musb_platform_init(struct musb *musb, void *board_data) rev, __raw_readl(CFGCHIP2), musb_readb(reg_base, DA8XX_USB_CTRL_REG)); - musb->isr = da8xx_interrupt; + musb->isr = da8xx_musb_interrupt; return 0; fail: clk_disable(musb->clock); return -ENODEV; } -int musb_platform_exit(struct musb *musb) +static int da8xx_musb_exit(struct musb *musb) { if (is_host_enabled(musb)) del_timer_sync(&otg_workaround); @@ -467,3 +467,16 @@ int musb_platform_exit(struct musb *musb) return 0; } + +const struct musb_platform_ops musb_ops = { + .init = da8xx_musb_init, + .exit = da8xx_musb_exit, + + .enable = da8xx_musb_enable, + .disable = da8xx_musb_disable, + + .set_mode = da8xx_musb_set_mode, + .try_idle = da8xx_musb_try_idle, + + .set_vbus = da8xx_musb_set_vbus, +}; diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 051e2bf1897a..e283b5af8de0 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -83,7 +83,7 @@ static inline void phy_off(void) static int dma_off = 1; -void musb_platform_enable(struct musb *musb) +static void davinci_musb_enable(struct musb *musb) { u32 tmp, old, val; @@ -116,7 +116,7 @@ void musb_platform_enable(struct musb *musb) /* * Disable the HDRC and flush interrupts */ -void musb_platform_disable(struct musb *musb) +static void davinci_musb_disable(struct musb *musb) { /* because we don't set CTRLR.UINT, "important" to: * - not read/write INTRUSB/INTRUSBE @@ -167,7 +167,7 @@ static void evm_deferred_drvvbus(struct work_struct *ignored) #endif /* EVM */ -static void davinci_source_power(struct musb *musb, int is_on, int immediate) +static void davinci_musb_source_power(struct musb *musb, int is_on, int immediate) { #ifdef CONFIG_MACH_DAVINCI_EVM if (is_on) @@ -190,10 +190,10 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate) #endif } -static void davinci_set_vbus(struct musb *musb, int is_on) +static void davinci_musb_set_vbus(struct musb *musb, int is_on) { WARN_ON(is_on && is_peripheral_active(musb)); - davinci_source_power(musb, is_on, 0); + davinci_musb_source_power(musb, is_on, 0); } @@ -259,7 +259,7 @@ static void otg_timer(unsigned long _musb) spin_unlock_irqrestore(&musb->lock, flags); } -static irqreturn_t davinci_interrupt(int irq, void *__hci) +static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) { unsigned long flags; irqreturn_t retval = IRQ_NONE; @@ -345,7 +345,7 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci) /* NOTE: this must complete poweron within 100 msec * (OTG_TIME_A_WAIT_VRISE) but we don't check for that. */ - davinci_source_power(musb, drvvbus, 0); + davinci_musb_source_power(musb, drvvbus, 0); DBG(2, "VBUS %s (%s)%s, devctl %02x\n", drvvbus ? "on" : "off", otg_state_string(musb), @@ -370,13 +370,13 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci) return retval; } -int musb_platform_set_mode(struct musb *musb, u8 mode) +static int davinci_musb_set_mode(struct musb *musb, u8 mode) { /* EVM can't do this (right?) */ return -EIO; } -int __init musb_platform_init(struct musb *musb) +static int davinci_musb_init(struct musb *musb) { void __iomem *tibase = musb->ctrl_base; u32 revision; @@ -398,8 +398,8 @@ int __init musb_platform_init(struct musb *musb) if (is_host_enabled(musb)) setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); - musb->board_set_vbus = davinci_set_vbus; - davinci_source_power(musb, 0, 1); + musb->board_set_vbus = davinci_musb_set_vbus; + davinci_musb_source_power(musb, 0, 1); /* dm355 EVM swaps D+/D- for signal integrity, and * is clocked from the main 24 MHz crystal. @@ -440,7 +440,7 @@ int __init musb_platform_init(struct musb *musb) revision, __raw_readl(USB_PHY_CTRL), musb_readb(tibase, DAVINCI_USB_CTRL_REG)); - musb->isr = davinci_interrupt; + musb->isr = davinci_musb_interrupt; return 0; fail: @@ -451,7 +451,7 @@ fail: return -ENODEV; } -int musb_platform_exit(struct musb *musb) +static int davinci_musb_exit(struct musb *musb) { if (is_host_enabled(musb)) del_timer_sync(&otg_workaround); @@ -465,7 +465,7 @@ int musb_platform_exit(struct musb *musb) __raw_writel(deepsleep, DM355_DEEPSLEEP); } - davinci_source_power(musb, 0 /*off*/, 1); + davinci_musb_source_power(musb, 0 /*off*/, 1); /* delay, to avoid problems with module reload */ if (is_host_enabled(musb) && musb->xceiv->default_a) { @@ -502,3 +502,15 @@ int musb_platform_exit(struct musb *musb) return 0; } + +const struct musb_platform_ops musb_ops = { + .init = davinci_musb_init, + .exit = davinci_musb_exit, + + .enable = davinci_musb_enable, + .disable = davinci_musb_disable, + + .set_mode = davinci_musb_set_mode, + + .set_vbus = davinci_musb_set_vbus, +}; diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index a5ceddfe57d6..516c68c6fa50 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -390,7 +390,7 @@ void musb_otg_timer_func(unsigned long data) case OTG_STATE_A_SUSPEND: case OTG_STATE_A_WAIT_BCON: DBG(1, "HNP: %s timeout\n", otg_state_string(musb)); - musb_set_vbus(musb, 0); + musb_platform_set_vbus(musb, 0); musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; break; default: @@ -570,7 +570,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb->ep0_stage = MUSB_EP0_START; musb->xceiv->state = OTG_STATE_A_IDLE; MUSB_HST_MODE(musb); - musb_set_vbus(musb, 1); + musb_platform_set_vbus(musb, 1); handled = IRQ_HANDLED; } @@ -641,7 +641,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, /* go through A_WAIT_VFALL then start a new session */ if (!ignore) - musb_set_vbus(musb, 0); + musb_platform_set_vbus(musb, 0); handled = IRQ_HANDLED; } @@ -1898,6 +1898,8 @@ allocate_instance(struct device *dev, } musb->controller = dev; + musb->ops = &musb_ops; + return musb; } diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 59928a235dc5..68fc76f5e316 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -281,6 +281,8 @@ struct musb_platform_ops { void (*set_vbus)(struct musb *musb, int on); }; +extern const struct musb_platform_ops musb_ops; + /* * struct musb_hw_ep - endpoint hardware (bidirectional) * @@ -359,6 +361,9 @@ struct musb { spinlock_t lock; struct clk *clock; struct clk *phy_clock; + + const struct musb_platform_ops *ops; + irqreturn_t (*isr)(int, void *); struct work_struct irq_work; u16 hwvers; @@ -486,52 +491,6 @@ struct musb { #endif }; -#ifdef CONFIG_PM -struct musb_csr_regs { - /* FIFO registers */ - u16 txmaxp, txcsr, rxmaxp, rxcsr; - u16 rxfifoadd, txfifoadd; - u8 txtype, txinterval, rxtype, rxinterval; - u8 rxfifosz, txfifosz; - u8 txfunaddr, txhubaddr, txhubport; - u8 rxfunaddr, rxhubaddr, rxhubport; -}; - -struct musb_context_registers { - -#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ - defined(CONFIG_ARCH_OMAP4) - u32 otg_sysconfig, otg_forcestandby; -#endif - u8 power; - u16 intrtxe, intrrxe; - u8 intrusbe; - u16 frame; - u8 index, testmode; - - u8 devctl, busctl, misc; - - struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; -}; - -#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ - defined(CONFIG_ARCH_OMAP4) -extern void musb_platform_save_context(struct musb *musb, - struct musb_context_registers *musb_context); -extern void musb_platform_restore_context(struct musb *musb, - struct musb_context_registers *musb_context); -#else -#define musb_platform_save_context(m, x) do {} while (0) -#define musb_platform_restore_context(m, x) do {} while (0) -#endif - -#endif - -static inline void musb_set_vbus(struct musb *musb, int is_on) -{ - musb->board_set_vbus(musb, is_on); -} - #ifdef CONFIG_USB_GADGET_MUSB_HDRC static inline struct musb *gadget_to_musb(struct usb_gadget *g) { @@ -620,29 +579,120 @@ extern void musb_load_testpacket(struct musb *); extern irqreturn_t musb_interrupt(struct musb *); -extern void musb_platform_enable(struct musb *musb); -extern void musb_platform_disable(struct musb *musb); - extern void musb_hnp_stop(struct musb *musb); -extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode); +#ifdef CONFIG_PM +struct musb_csr_regs { + /* FIFO registers */ + u16 txmaxp, txcsr, rxmaxp, rxcsr; + u16 rxfifoadd, txfifoadd; + u8 txtype, txinterval, rxtype, rxinterval; + u8 rxfifosz, txfifosz; + u8 txfunaddr, txhubaddr, txhubport; + u8 rxfunaddr, rxhubaddr, rxhubport; +}; -#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \ - defined(CONFIG_ARCH_DAVINCI_DA8XX) || \ - defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ - defined(CONFIG_ARCH_OMAP4) -extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout); -#else -#define musb_platform_try_idle(x, y) do {} while (0) +struct musb_context_registers { + +#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ + defined(CONFIG_ARCH_OMAP4) + u32 otg_sysconfig, otg_forcestandby; #endif + u8 power; + u16 intrtxe, intrrxe; + u8 intrusbe; + u16 frame; + u8 index, testmode; -#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) -extern int musb_platform_get_vbus_status(struct musb *musb); + u8 devctl, busctl, misc; + + struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; +}; + +#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ + defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_BLACKFIN) +extern void musb_platform_save_context(struct musb *musb, + struct musb_context_registers *musb_context); +extern void musb_platform_restore_context(struct musb *musb, + struct musb_context_registers *musb_context); #else -#define musb_platform_get_vbus_status(x) 0 +#define musb_platform_save_context(m, x) do {} while (0) +#define musb_platform_restore_context(m, x) do {} while (0) #endif -extern int __init musb_platform_init(struct musb *musb); -extern int musb_platform_exit(struct musb *musb); +#endif + +static inline void musb_platform_set_vbus(struct musb *musb, int is_on) +{ + if (musb->ops->set_vbus) + musb->ops->set_vbus(musb, is_on); +} + +static inline void musb_platform_enable(struct musb *musb) +{ + if (musb->ops->enable) + musb->ops->enable(musb); +} + +static inline void musb_platform_disable(struct musb *musb) +{ + if (musb->ops->disable) + musb->ops->disable(musb); +} + +static inline int musb_platform_set_mode(struct musb *musb, u8 mode) +{ + if (!musb->ops->set_mode) + return 0; + + return musb->ops->set_mode(musb, mode); +} + +static inline void musb_platform_try_idle(struct musb *musb, + unsigned long timeout) +{ + if (musb->ops->try_idle) + musb->ops->try_idle(musb, timeout); +} + +static inline int musb_platform_get_vbus_status(struct musb *musb) +{ + if (!musb->ops->vbus_status) + return 0; + + return musb->ops->vbus_status(musb); +} + +static inline int musb_platform_init(struct musb *musb) +{ + if (!musb->ops->init) + return -EINVAL; + + return musb->ops->init(musb); +} + +static inline int musb_platform_exit(struct musb *musb) +{ + if (!musb->ops->exit) + return -EINVAL; + + return musb->ops->exit(musb); +} + +static inline int musb_platform_suspend(struct musb *musb) +{ + if (!musb->ops->suspend) + return 0; + + return musb->ops->suspend(musb); +} + +static inline int musb_platform_resume(struct musb *musb) +{ + if (!musb->ops->resume) + return 0; + + return musb->ops->resume(musb); +} #endif /* __MUSB_CORE_H__ */ diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 43233c397b6e..b46d1877e28e 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -276,7 +276,7 @@ int musb_hub_control( break; case USB_PORT_FEAT_POWER: if (!(is_otg_enabled(musb) && hcd->self.is_b_host)) - musb_set_vbus(musb, 0); + musb_platform_set_vbus(musb, 0); break; case USB_PORT_FEAT_C_CONNECTION: case USB_PORT_FEAT_C_ENABLE: diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 27dabcf0a868..5f0d0f105989 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -35,7 +35,6 @@ #include "musb_core.h" #include "omap2430.h" - static struct timer_list musb_idle_timer; static void musb_do_idle(unsigned long _musb) @@ -98,7 +97,7 @@ static void musb_do_idle(unsigned long _musb) } -void musb_platform_try_idle(struct musb *musb, unsigned long timeout) +static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) { unsigned long default_timeout = jiffies + msecs_to_jiffies(3); static unsigned long last_timer; @@ -131,13 +130,15 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) mod_timer(&musb_idle_timer, timeout); } -void musb_platform_enable(struct musb *musb) +static void omap2430_musb_enable(struct musb *musb) { } -void musb_platform_disable(struct musb *musb) + +static void omap2430_musb_disable(struct musb *musb) { } -static void omap_set_vbus(struct musb *musb, int is_on) + +static void omap2430_musb_set_vbus(struct musb *musb, int is_on) { u8 devctl; /* HDRC controls CPEN, but beware current surges during device @@ -175,9 +176,9 @@ static void omap_set_vbus(struct musb *musb, int is_on) musb_readb(musb->mregs, MUSB_DEVCTL)); } -static int musb_platform_resume(struct musb *musb); +static int omap2430_musb_resume(struct musb *musb); -int musb_platform_set_mode(struct musb *musb, u8 musb_mode) +static int omap2430_musb_set_mode(struct musb *musb, u8 musb_mode) { u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); @@ -187,7 +188,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) return 0; } -int __init musb_platform_init(struct musb *musb) +static int omap2430_musb_init(struct musb *musb) { u32 l; struct device *dev = musb->controller; @@ -204,7 +205,7 @@ int __init musb_platform_init(struct musb *musb) return -ENODEV; } - musb_platform_resume(musb); + omap2430_musb_resume(musb); l = musb_readl(musb->mregs, OTG_SYSCONFIG); l &= ~ENABLEWAKEUP; /* disable wakeup */ @@ -242,7 +243,7 @@ int __init musb_platform_init(struct musb *musb) musb_readl(musb->mregs, OTG_SIMENABLE)); if (is_host_enabled(musb)) - musb->board_set_vbus = omap_set_vbus; + musb->board_set_vbus = omap2430_musb_set_vbus; setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); @@ -265,7 +266,7 @@ void musb_platform_restore_context(struct musb *musb, } #endif -static int musb_platform_suspend(struct musb *musb) +static int omap2430_musb_suspend(struct musb *musb) { u32 l; @@ -291,7 +292,7 @@ static int musb_platform_suspend(struct musb *musb) return 0; } -static int musb_platform_resume(struct musb *musb) +static int omap2430_musb_resume(struct musb *musb) { u32 l; @@ -316,12 +317,27 @@ static int musb_platform_resume(struct musb *musb) return 0; } - -int musb_platform_exit(struct musb *musb) +static int omap2430_musb_exit(struct musb *musb) { - musb_platform_suspend(musb); + omap2430_musb_suspend(musb); otg_put_transceiver(musb->xceiv); return 0; } + +const struct musb_platform_ops musb_ops = { + .init = omap2430_musb_init, + .exit = omap2430_musb_exit, + + .suspend = omap2430_musb_suspend, + .resume = omap2430_musb_resume, + + .enable = omap2430_musb_enable, + .disable = omap2430_musb_disable, + + .set_mode = omap2430_musb_set_mode, + .try_idle = omap2430_musb_try_idle, + + .set_vbus = omap2430_musb_set_vbus, +}; diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 41b04b906ce1..60abd52b2c51 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -24,7 +24,7 @@ #include "musb_core.h" -static void tusb_source_power(struct musb *musb, int is_on); +static void tusb_musb_set_vbus(struct musb *musb, int is_on); #define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) #define TUSB_REV_MINOR(reg_val) (reg_val & 0xf) @@ -50,7 +50,7 @@ u8 tusb_get_revision(struct musb *musb) return rev; } -static int __init tusb_print_revision(struct musb *musb) +static int tusb_print_revision(struct musb *musb) { void __iomem *tbase = musb->ctrl_base; u8 rev; @@ -348,7 +348,7 @@ static void tusb_set_clock_source(struct musb *musb, unsigned mode) * USB link is not suspended ... and tells us the relevant wakeup * events. SW_EN for voltage is handled separately. */ -void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) +static void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) { void __iomem *tbase = musb->ctrl_base; u32 reg; @@ -385,7 +385,7 @@ void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) /* * Updates cable VBUS status. Caller must take care of locking. */ -int musb_platform_get_vbus_status(struct musb *musb) +static int tusb_musb_vbus_status(struct musb *musb) { void __iomem *tbase = musb->ctrl_base; u32 otg_stat, prcm_mngmt; @@ -431,7 +431,7 @@ static void musb_do_idle(unsigned long _musb) } /* FALLTHROUGH */ case OTG_STATE_A_IDLE: - tusb_source_power(musb, 0); + tusb_musb_set_vbus(musb, 0); default: break; } @@ -475,7 +475,7 @@ done: * we don't want to treat that full speed J as a wakeup event. * ... peripherals must draw only suspend current after 10 msec. */ -void musb_platform_try_idle(struct musb *musb, unsigned long timeout) +static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout) { unsigned long default_timeout = jiffies + msecs_to_jiffies(3); static unsigned long last_timer; @@ -515,7 +515,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) | TUSB_DEV_OTG_TIMER_ENABLE) \ : 0) -static void tusb_source_power(struct musb *musb, int is_on) +static void tusb_musb_set_vbus(struct musb *musb, int is_on) { void __iomem *tbase = musb->ctrl_base; u32 conf, prcm, timer; @@ -599,7 +599,7 @@ static void tusb_source_power(struct musb *musb, int is_on) * and peripheral modes in non-OTG configurations by reconfiguring hardware * and then setting musb->board_mode. For now, only support OTG mode. */ -int musb_platform_set_mode(struct musb *musb, u8 musb_mode) +static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) { void __iomem *tbase = musb->ctrl_base; u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; @@ -677,7 +677,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) default_a = is_host_enabled(musb); DBG(2, "Default-%c\n", default_a ? 'A' : 'B'); musb->xceiv->default_a = default_a; - tusb_source_power(musb, default_a); + tusb_musb_set_vbus(musb, default_a); /* Don't allow idling immediately */ if (default_a) @@ -722,7 +722,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) switch (musb->xceiv->state) { case OTG_STATE_A_IDLE: DBG(2, "Got SRP, turning on VBUS\n"); - musb_set_vbus(musb, 1); + musb_platform_set_vbus(musb, 1); /* CONNECT can wake if a_wait_bcon is set */ if (musb->a_wait_bcon != 0) @@ -748,11 +748,11 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) */ if (musb->vbuserr_retry) { musb->vbuserr_retry--; - tusb_source_power(musb, 1); + tusb_musb_set_vbus(musb, 1); } else { musb->vbuserr_retry = VBUSERR_RETRY_COUNT; - tusb_source_power(musb, 0); + tusb_musb_set_vbus(musb, 0); } break; default: @@ -786,7 +786,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) } else { /* REVISIT report overcurrent to hub? */ ERR("vbus too slow, devctl %02x\n", devctl); - tusb_source_power(musb, 0); + tusb_musb_set_vbus(musb, 0); } break; case OTG_STATE_A_WAIT_BCON: @@ -807,7 +807,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) return idle_timeout; } -static irqreturn_t tusb_interrupt(int irq, void *__hci) +static irqreturn_t tusb_musb_interrupt(int irq, void *__hci) { struct musb *musb = __hci; void __iomem *tbase = musb->ctrl_base; @@ -911,7 +911,7 @@ static irqreturn_t tusb_interrupt(int irq, void *__hci) musb_writel(tbase, TUSB_INT_SRC_CLEAR, int_src & ~TUSB_INT_MASK_RESERVED_BITS); - musb_platform_try_idle(musb, idle_timeout); + tusb_musb_try_idle(musb, idle_timeout); musb_writel(tbase, TUSB_INT_MASK, int_mask); spin_unlock_irqrestore(&musb->lock, flags); @@ -926,7 +926,7 @@ static int dma_off; * REVISIT: * - Check what is unnecessary in MGC_HdrcStart() */ -void musb_platform_enable(struct musb *musb) +static void tusb_musb_enable(struct musb *musb) { void __iomem *tbase = musb->ctrl_base; @@ -970,7 +970,7 @@ void musb_platform_enable(struct musb *musb) /* * Disables TUSB6010. Caller must take care of locking. */ -void musb_platform_disable(struct musb *musb) +static void tusb_musb_disable(struct musb *musb) { void __iomem *tbase = musb->ctrl_base; @@ -995,7 +995,7 @@ void musb_platform_disable(struct musb *musb) * Sets up TUSB6010 CPU interface specific signals and registers * Note: Settings optimized for OMAP24xx */ -static void __init tusb_setup_cpu_interface(struct musb *musb) +static void tusb_setup_cpu_interface(struct musb *musb) { void __iomem *tbase = musb->ctrl_base; @@ -1022,7 +1022,7 @@ static void __init tusb_setup_cpu_interface(struct musb *musb) musb_writel(tbase, TUSB_WAIT_COUNT, 1); } -static int __init tusb_start(struct musb *musb) +static int tusb_musb_start(struct musb *musb) { void __iomem *tbase = musb->ctrl_base; int ret = 0; @@ -1091,7 +1091,7 @@ err: return -ENODEV; } -int __init musb_platform_init(struct musb *musb) +static int tusb_musb_init(struct musb *musb) { struct platform_device *pdev; struct resource *mem; @@ -1131,16 +1131,14 @@ int __init musb_platform_init(struct musb *musb) */ musb->mregs += TUSB_BASE_OFFSET; - ret = tusb_start(musb); + ret = tusb_musb_start(musb); if (ret) { printk(KERN_ERR "Could not start tusb6010 (%d)\n", ret); goto done; } - musb->isr = tusb_interrupt; + musb->isr = tusb_musb_interrupt; - if (is_host_enabled(musb)) - musb->board_set_vbus = tusb_source_power; if (is_peripheral_enabled(musb)) { musb->xceiv->set_power = tusb_draw_power; the_musb = musb; @@ -1159,7 +1157,7 @@ done: return ret; } -int musb_platform_exit(struct musb *musb) +static int tusb_musb_exit(struct musb *musb) { del_timer_sync(&musb_idle_timer); the_musb = NULL; @@ -1173,3 +1171,17 @@ int musb_platform_exit(struct musb *musb) usb_nop_xceiv_unregister(); return 0; } + +const struct musb_platform_ops musb_ops = { + .init = tusb_musb_init, + .exit = tusb_musb_exit, + + .enable = tusb_musb_enable, + .disable = tusb_musb_disable, + + .set_mode = tusb_musb_set_mode, + .try_idle = tusb_musb_try_idle, + + .vbus_status = tusb_musb_vbus_status, + .set_vbus = tusb_musb_set_vbus, +}; -- cgit v1.2.2 From 7421107b293cace2fc081731306d447ecd8517ab Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 1 Dec 2010 13:53:27 +0200 Subject: usb: musb: hold context on musb structure when we start splitting HW glue layer, it's gonna make it easier to re-use that structure. Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.c | 112 +++++++++++++++++++++---------------------- drivers/usb/musb/musb_core.h | 55 ++++++++++----------- 2 files changed, 83 insertions(+), 84 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 516c68c6fa50..5abcfe6ab2ee 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2265,8 +2265,6 @@ static int __exit musb_remove(struct platform_device *pdev) #ifdef CONFIG_PM -static struct musb_context_registers musb_context; - void musb_save_context(struct musb *musb) { int i; @@ -2274,65 +2272,65 @@ void musb_save_context(struct musb *musb) void __iomem *epio; if (is_host_enabled(musb)) { - musb_context.frame = musb_readw(musb_base, MUSB_FRAME); - musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE); - musb_context.busctl = musb_read_ulpi_buscontrol(musb->mregs); + musb->context.frame = musb_readw(musb_base, MUSB_FRAME); + musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE); + musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs); } - musb_context.power = musb_readb(musb_base, MUSB_POWER); - musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE); - musb_context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE); - musb_context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE); - musb_context.index = musb_readb(musb_base, MUSB_INDEX); - musb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL); + musb->context.power = musb_readb(musb_base, MUSB_POWER); + musb->context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE); + musb->context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE); + musb->context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE); + musb->context.index = musb_readb(musb_base, MUSB_INDEX); + musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL); for (i = 0; i < musb->config->num_eps; ++i) { epio = musb->endpoints[i].regs; - musb_context.index_regs[i].txmaxp = + musb->context.index_regs[i].txmaxp = musb_readw(epio, MUSB_TXMAXP); - musb_context.index_regs[i].txcsr = + musb->context.index_regs[i].txcsr = musb_readw(epio, MUSB_TXCSR); - musb_context.index_regs[i].rxmaxp = + musb->context.index_regs[i].rxmaxp = musb_readw(epio, MUSB_RXMAXP); - musb_context.index_regs[i].rxcsr = + musb->context.index_regs[i].rxcsr = musb_readw(epio, MUSB_RXCSR); if (musb->dyn_fifo) { - musb_context.index_regs[i].txfifoadd = + musb->context.index_regs[i].txfifoadd = musb_read_txfifoadd(musb_base); - musb_context.index_regs[i].rxfifoadd = + musb->context.index_regs[i].rxfifoadd = musb_read_rxfifoadd(musb_base); - musb_context.index_regs[i].txfifosz = + musb->context.index_regs[i].txfifosz = musb_read_txfifosz(musb_base); - musb_context.index_regs[i].rxfifosz = + musb->context.index_regs[i].rxfifosz = musb_read_rxfifosz(musb_base); } if (is_host_enabled(musb)) { - musb_context.index_regs[i].txtype = + musb->context.index_regs[i].txtype = musb_readb(epio, MUSB_TXTYPE); - musb_context.index_regs[i].txinterval = + musb->context.index_regs[i].txinterval = musb_readb(epio, MUSB_TXINTERVAL); - musb_context.index_regs[i].rxtype = + musb->context.index_regs[i].rxtype = musb_readb(epio, MUSB_RXTYPE); - musb_context.index_regs[i].rxinterval = + musb->context.index_regs[i].rxinterval = musb_readb(epio, MUSB_RXINTERVAL); - musb_context.index_regs[i].txfunaddr = + musb->context.index_regs[i].txfunaddr = musb_read_txfunaddr(musb_base, i); - musb_context.index_regs[i].txhubaddr = + musb->context.index_regs[i].txhubaddr = musb_read_txhubaddr(musb_base, i); - musb_context.index_regs[i].txhubport = + musb->context.index_regs[i].txhubport = musb_read_txhubport(musb_base, i); - musb_context.index_regs[i].rxfunaddr = + musb->context.index_regs[i].rxfunaddr = musb_read_rxfunaddr(musb_base, i); - musb_context.index_regs[i].rxhubaddr = + musb->context.index_regs[i].rxhubaddr = musb_read_rxhubaddr(musb_base, i); - musb_context.index_regs[i].rxhubport = + musb->context.index_regs[i].rxhubport = musb_read_rxhubport(musb_base, i); } } - musb_platform_save_context(musb, &musb_context); + musb_platform_save_context(musb, &musb->context); } void musb_restore_context(struct musb *musb) @@ -2342,67 +2340,67 @@ void musb_restore_context(struct musb *musb) void __iomem *ep_target_regs; void __iomem *epio; - musb_platform_restore_context(musb, &musb_context); + musb_platform_restore_context(musb, &musb->context); if (is_host_enabled(musb)) { - musb_writew(musb_base, MUSB_FRAME, musb_context.frame); - musb_writeb(musb_base, MUSB_TESTMODE, musb_context.testmode); - musb_write_ulpi_buscontrol(musb->mregs, musb_context.busctl); + musb_writew(musb_base, MUSB_FRAME, musb->context.frame); + musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); + musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); } - musb_writeb(musb_base, MUSB_POWER, musb_context.power); - musb_writew(musb_base, MUSB_INTRTXE, musb_context.intrtxe); - musb_writew(musb_base, MUSB_INTRRXE, musb_context.intrrxe); - musb_writeb(musb_base, MUSB_INTRUSBE, musb_context.intrusbe); - musb_writeb(musb_base, MUSB_DEVCTL, musb_context.devctl); + musb_writeb(musb_base, MUSB_POWER, musb->context.power); + musb_writew(musb_base, MUSB_INTRTXE, musb->context.intrtxe); + musb_writew(musb_base, MUSB_INTRRXE, musb->context.intrrxe); + musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe); + musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); for (i = 0; i < musb->config->num_eps; ++i) { epio = musb->endpoints[i].regs; musb_writew(epio, MUSB_TXMAXP, - musb_context.index_regs[i].txmaxp); + musb->context.index_regs[i].txmaxp); musb_writew(epio, MUSB_TXCSR, - musb_context.index_regs[i].txcsr); + musb->context.index_regs[i].txcsr); musb_writew(epio, MUSB_RXMAXP, - musb_context.index_regs[i].rxmaxp); + musb->context.index_regs[i].rxmaxp); musb_writew(epio, MUSB_RXCSR, - musb_context.index_regs[i].rxcsr); + musb->context.index_regs[i].rxcsr); if (musb->dyn_fifo) { musb_write_txfifosz(musb_base, - musb_context.index_regs[i].txfifosz); + musb->context.index_regs[i].txfifosz); musb_write_rxfifosz(musb_base, - musb_context.index_regs[i].rxfifosz); + musb->context.index_regs[i].rxfifosz); musb_write_txfifoadd(musb_base, - musb_context.index_regs[i].txfifoadd); + musb->context.index_regs[i].txfifoadd); musb_write_rxfifoadd(musb_base, - musb_context.index_regs[i].rxfifoadd); + musb->context.index_regs[i].rxfifoadd); } if (is_host_enabled(musb)) { musb_writeb(epio, MUSB_TXTYPE, - musb_context.index_regs[i].txtype); + musb->context.index_regs[i].txtype); musb_writeb(epio, MUSB_TXINTERVAL, - musb_context.index_regs[i].txinterval); + musb->context.index_regs[i].txinterval); musb_writeb(epio, MUSB_RXTYPE, - musb_context.index_regs[i].rxtype); + musb->context.index_regs[i].rxtype); musb_writeb(epio, MUSB_RXINTERVAL, - musb_context.index_regs[i].rxinterval); + musb->context.index_regs[i].rxinterval); musb_write_txfunaddr(musb_base, i, - musb_context.index_regs[i].txfunaddr); + musb->context.index_regs[i].txfunaddr); musb_write_txhubaddr(musb_base, i, - musb_context.index_regs[i].txhubaddr); + musb->context.index_regs[i].txhubaddr); musb_write_txhubport(musb_base, i, - musb_context.index_regs[i].txhubport); + musb->context.index_regs[i].txhubport); ep_target_regs = musb_read_target_reg_base(i, musb_base); musb_write_rxfunaddr(ep_target_regs, - musb_context.index_regs[i].rxfunaddr); + musb->context.index_regs[i].rxfunaddr); musb_write_rxhubaddr(ep_target_regs, - musb_context.index_regs[i].rxhubaddr); + musb->context.index_regs[i].rxhubaddr); musb_write_rxhubport(ep_target_regs, - musb_context.index_regs[i].rxhubport); + musb->context.index_regs[i].rxhubport); } } } diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 68fc76f5e316..cb393e4a3722 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -353,6 +353,33 @@ static inline struct usb_request *next_out_request(struct musb_hw_ep *hw_ep) #endif } +struct musb_csr_regs { + /* FIFO registers */ + u16 txmaxp, txcsr, rxmaxp, rxcsr; + u16 rxfifoadd, txfifoadd; + u8 txtype, txinterval, rxtype, rxinterval; + u8 rxfifosz, txfifosz; + u8 txfunaddr, txhubaddr, txhubport; + u8 rxfunaddr, rxhubaddr, rxhubport; +}; + +struct musb_context_registers { + +#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ + defined(CONFIG_ARCH_OMAP4) + u32 otg_sysconfig, otg_forcestandby; +#endif + u8 power; + u16 intrtxe, intrrxe; + u8 intrusbe; + u16 frame; + u8 index, testmode; + + u8 devctl, busctl, misc; + + struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; +}; + /* * struct musb - Driver instance data. */ @@ -363,6 +390,7 @@ struct musb { struct clk *phy_clock; const struct musb_platform_ops *ops; + struct musb_context_registers context; irqreturn_t (*isr)(int, void *); struct work_struct irq_work; @@ -582,33 +610,6 @@ extern irqreturn_t musb_interrupt(struct musb *); extern void musb_hnp_stop(struct musb *musb); #ifdef CONFIG_PM -struct musb_csr_regs { - /* FIFO registers */ - u16 txmaxp, txcsr, rxmaxp, rxcsr; - u16 rxfifoadd, txfifoadd; - u8 txtype, txinterval, rxtype, rxinterval; - u8 rxfifosz, txfifosz; - u8 txfunaddr, txhubaddr, txhubport; - u8 rxfunaddr, rxhubaddr, rxhubport; -}; - -struct musb_context_registers { - -#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ - defined(CONFIG_ARCH_OMAP4) - u32 otg_sysconfig, otg_forcestandby; -#endif - u8 power; - u16 intrtxe, intrrxe; - u8 intrusbe; - u16 frame; - u8 index, testmode; - - u8 devctl, busctl, misc; - - struct musb_csr_regs index_regs[MUSB_C_NUM_EPS]; -}; - #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_BLACKFIN) extern void musb_platform_save_context(struct musb *musb, -- cgit v1.2.2 From 7c925546427a0428b84bc5ba1f28b3698e492072 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 1 Dec 2010 14:23:48 +0200 Subject: usb: musb: add Kconfig options for each glue layer This will make things simpler when choosing which glue layer to compile. It avoids a lot of magic around the "default" Kconfig option and lets the user choose what exactly s/he wants to compile. Signed-off-by: Felipe Balbi --- drivers/usb/musb/Kconfig | 70 ++++++++++++++++---------------------------- drivers/usb/musb/Makefile | 21 ++++++------- drivers/usb/musb/musb_core.c | 9 +++--- drivers/usb/musb/musb_core.h | 8 ++--- drivers/usb/musb/musb_io.h | 4 +-- drivers/usb/musb/musb_regs.h | 4 +-- 6 files changed, 46 insertions(+), 70 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 341a37a469bd..7119d900a479 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -32,55 +32,35 @@ config USB_MUSB_HDRC To compile this driver as a module, choose M here; the module will be called "musb_hdrc". -config USB_MUSB_SOC - boolean +choice + prompt "Platform Glue Layer" depends on USB_MUSB_HDRC - default y if ARCH_DAVINCI - default y if ARCH_OMAP2430 - default y if ARCH_OMAP3 - default y if ARCH_OMAP4 - default y if (BF54x && !BF544) - default y if (BF52x && !BF522 && !BF523) -comment "DaVinci 35x and 644x USB support" - depends on USB_MUSB_HDRC && ARCH_DAVINCI_DMx +config USB_MUSB_DAVINCI + bool "DaVinci" + depends on ARCH_DAVINCI_DMx -comment "DA8xx/OMAP-L1x USB support" - depends on USB_MUSB_HDRC && ARCH_DAVINCI_DA8XX +config USB_MUSB_DA8XX + bool "DA8xx/OMAP-L1x" + depends on ARCH_DAVINCI_DA8XX -comment "OMAP 243x high speed USB support" - depends on USB_MUSB_HDRC && ARCH_OMAP2430 +config USB_MUSB_TUSB6010 + bool "TUSB6010" + depends on ARCH_OMAP -comment "OMAP 343x high speed USB support" - depends on USB_MUSB_HDRC && ARCH_OMAP3 +config USB_MUSB_OMAP2PLUS + bool "OMAP2430 and onwards" + depends on ARCH_OMAP2PLUS -comment "OMAP 44xx high speed USB support" - depends on USB_MUSB_HDRC && ARCH_OMAP4 +config USB_MUSB_AM35X + bool "AM35x" + depends on ARCH_OMAP -comment "Blackfin high speed USB Support" - depends on USB_MUSB_HDRC && ((BF54x && !BF544) || (BF52x && !BF522 && !BF523)) +config USB_MUSB_BLACKFIN + bool "Blackfin" + depends on (BF54x && !BF544) || (BF52x && ! BF522 && !BF523) -config USB_MUSB_AM35X - bool - depends on USB_MUSB_HDRC && !ARCH_OMAP2430 && !ARCH_OMAP4 - select NOP_USB_XCEIV - default MACH_OMAP3517EVM - help - Select this option if your platform is based on AM35x. As - AM35x has an updated MUSB with CPPI4.1 DMA so this config - is introduced to differentiate musb ip between OMAP3x and - AM35x platforms. - -config USB_TUSB6010 - boolean "TUSB 6010 support" - depends on USB_MUSB_HDRC && !USB_MUSB_SOC - select NOP_USB_XCEIV - default y - help - The TUSB 6010 chip, from Texas Instruments, connects a discrete - HDRC core using a 16-bit parallel bus (NOR flash style) or VLYNQ - (a high speed serial link). It can use system-specific external - DMA controllers. +endchoice choice prompt "Driver Mode" @@ -158,7 +138,7 @@ config USB_MUSB_HDRC_HCD config MUSB_PIO_ONLY bool 'Disable DMA (always use PIO)' depends on USB_MUSB_HDRC - default USB_TUSB6010 || ARCH_DAVINCI_DA8XX || USB_MUSB_AM35X + default USB_MUSB_TUSB6010 || USB_MUSB_DA8XX || USB_MUSB_AM35X help All data is copied between memory and FIFO by the CPU. DMA controllers are ignored. @@ -171,21 +151,21 @@ config MUSB_PIO_ONLY config USB_INVENTRA_DMA bool depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY - default ARCH_OMAP2430 || ARCH_OMAP3 || BLACKFIN || ARCH_OMAP4 + default USB_MUSB_OMAP2PLUS || USB_MUSB_BLACKFIN help Enable DMA transfers using Mentor's engine. config USB_TI_CPPI_DMA bool depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY - default ARCH_DAVINCI + default USB_MUSB_DAVINCI help Enable DMA transfers when TI CPPI DMA is available. config USB_TUSB_OMAP_DMA bool depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY - depends on USB_TUSB6010 + depends on USB_MUSB_TUSB6010 depends on ARCH_OMAP default y help diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index ce164e8998d8..52d18dbefcfa 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -8,22 +8,19 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o musb_hdrc-y := musb_core.o -musb_hdrc-$(CONFIG_ARCH_DAVINCI_DMx) += davinci.o -musb_hdrc-$(CONFIG_ARCH_DAVINCI_DA8XX) += da8xx.o -musb_hdrc-$(CONFIG_USB_TUSB6010) += tusb6010.o -musb_hdrc-$(CONFIG_ARCH_OMAP2430) += omap2430.o -ifeq ($(CONFIG_USB_MUSB_AM35X),y) - musb_hdrc-$(CONFIG_ARCH_OMAP3430) += am35x.o -else - musb_hdrc-$(CONFIG_ARCH_OMAP3430) += omap2430.o -endif -musb_hdrc-$(CONFIG_ARCH_OMAP4) += omap2430.o -musb_hdrc-$(CONFIG_BF54x) += blackfin.o -musb_hdrc-$(CONFIG_BF52x) += blackfin.o musb_hdrc-$(CONFIG_USB_GADGET_MUSB_HDRC) += musb_gadget_ep0.o musb_gadget.o musb_hdrc-$(CONFIG_USB_MUSB_HDRC_HCD) += musb_virthub.o musb_host.o musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o +# Hardware Glue Layer + +musb_hdrc-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o +musb_hdrc-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o +musb_hdrc-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o +musb_hdrc-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o +musb_hdrc-$(CONFIG_USB_MUSB_AM35X) += am35x.o +musb_hdrc-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o + # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... # PIO only, or DMA (several potential schemes). diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 5abcfe6ab2ee..8df1c583f19d 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -230,7 +230,7 @@ static struct otg_io_access_ops musb_ulpi_access = { /*-------------------------------------------------------------------------*/ -#if !defined(CONFIG_USB_TUSB6010) && !defined(CONFIG_BLACKFIN) +#if !defined(CONFIG_USB_MUSB_TUSB6010) && !defined(CONFIG_USB_MUSB_BLACKFIN) /* * Load an endpoint's FIFO @@ -1068,9 +1068,8 @@ static void musb_shutdown(struct platform_device *pdev) * We don't currently use dynamic fifo setup capability to do anything * more than selecting one of a bunch of predefined configurations. */ -#if defined(CONFIG_USB_TUSB6010) || \ - defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) \ - || defined(CONFIG_ARCH_OMAP4) +#if defined(CONFIG_USB_MUSB_TUSB6010) || defined(CONFIG_USB_MUSB_OMAP2PLUS) \ + || defined(CONFIG_USB_MUSB_AM35X) static ushort __initdata fifo_mode = 4; #else static ushort __initdata fifo_mode = 2; @@ -1495,7 +1494,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) struct musb_hw_ep *hw_ep = musb->endpoints + i; hw_ep->fifo = MUSB_FIFO_OFFSET(i) + mbase; -#ifdef CONFIG_USB_TUSB6010 +#ifdef CONFIG_USB_MUSB_TUSB6010 hw_ep->fifo_async = musb->async + 0x400 + MUSB_FIFO_OFFSET(i); hw_ep->fifo_sync = musb->sync + 0x400 + MUSB_FIFO_OFFSET(i); hw_ep->fifo_sync_va = diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index cb393e4a3722..9594b9d1d27b 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -222,7 +222,7 @@ enum musb_g_ep0_state { #endif /* TUSB mapping: "flat" plus ep0 special cases */ -#if defined(CONFIG_USB_TUSB6010) +#if defined(CONFIG_USB_MUSB_TUSB6010) #define musb_ep_select(_mbase, _epnum) \ musb_writeb((_mbase), MUSB_INDEX, (_epnum)) #define MUSB_EP_OFFSET MUSB_TUSB_OFFSET @@ -293,7 +293,7 @@ struct musb_hw_ep { void __iomem *fifo; void __iomem *regs; -#ifdef CONFIG_USB_TUSB6010 +#ifdef CONFIG_USB_MUSB_TUSB6010 void __iomem *conf; #endif @@ -310,7 +310,7 @@ struct musb_hw_ep { struct dma_channel *tx_channel; struct dma_channel *rx_channel; -#ifdef CONFIG_USB_TUSB6010 +#ifdef CONFIG_USB_MUSB_TUSB6010 /* TUSB has "asynchronous" and "synchronous" dma modes */ dma_addr_t fifo_async; dma_addr_t fifo_sync; @@ -432,7 +432,7 @@ struct musb { void __iomem *ctrl_base; void __iomem *mregs; -#ifdef CONFIG_USB_TUSB6010 +#ifdef CONFIG_USB_MUSB_TUSB6010 dma_addr_t async; dma_addr_t sync; void __iomem *sync_va; diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h index b06e9ef00cfc..03c6ccdbb3be 100644 --- a/drivers/usb/musb/musb_io.h +++ b/drivers/usb/musb/musb_io.h @@ -74,7 +74,7 @@ static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data) { __raw_writel(data, addr + offset); } -#ifdef CONFIG_USB_TUSB6010 +#ifdef CONFIG_USB_MUSB_TUSB6010 /* * TUSB6010 doesn't allow 8-bit access; 16-bit access is the minimum. @@ -114,7 +114,7 @@ static inline u8 musb_readb(const void __iomem *addr, unsigned offset) static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data) { __raw_writeb(data, addr + offset); } -#endif /* CONFIG_USB_TUSB6010 */ +#endif /* CONFIG_USB_MUSB_TUSB6010 */ #else diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h index 244267527a60..9cb5fe044438 100644 --- a/drivers/usb/musb/musb_regs.h +++ b/drivers/usb/musb/musb_regs.h @@ -234,7 +234,7 @@ #define MUSB_TESTMODE 0x0F /* 8 bit */ /* Get offset for a given FIFO from musb->mregs */ -#ifdef CONFIG_USB_TUSB6010 +#ifdef CONFIG_USB_MUSB_TUSB6010 #define MUSB_FIFO_OFFSET(epnum) (0x200 + ((epnum) * 0x20)) #else #define MUSB_FIFO_OFFSET(epnum) (0x20 + ((epnum) * 4)) @@ -295,7 +295,7 @@ #define MUSB_FLAT_OFFSET(_epnum, _offset) \ (0x100 + (0x10*(_epnum)) + (_offset)) -#ifdef CONFIG_USB_TUSB6010 +#ifdef CONFIG_USB_MUSB_TUSB6010 /* TUSB6010 EP0 configuration register is special */ #define MUSB_TUSB_OFFSET(_epnum, _offset) \ (0x10 + _offset) -- cgit v1.2.2 From 05ac10dd6862a3fcce33d2203fbb2ef285e3ca87 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 08:49:26 +0200 Subject: usb: musb: trivial search and replace patch change all ocurrences of musb_hdrc to musb-hdrc. We will call glue layer drivers musb-, so in order to keep things somewhat standard, let's change the underscore into a dash. Signed-off-by: Felipe Balbi --- drivers/usb/gadget/gadget_chips.h | 2 +- drivers/usb/musb/Kconfig | 2 +- drivers/usb/musb/musb_core.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index d7b3bbe56808..aeb109bd317d 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h @@ -96,7 +96,7 @@ /* Mentor high speed "dual role" controller, in peripheral role */ #ifdef CONFIG_USB_GADGET_MUSB_HDRC -#define gadget_is_musbhdrc(g) !strcmp("musb_hdrc", (g)->name) +#define gadget_is_musbhdrc(g) !strcmp("musb-hdrc", (g)->name) #else #define gadget_is_musbhdrc(g) 0 #endif diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 7119d900a479..03a42901922c 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -30,7 +30,7 @@ config USB_MUSB_HDRC If you do not know what this is, please say N. To compile this driver as a module, choose M here; the - module will be called "musb_hdrc". + module will be called "musb-hdrc". choice prompt "Platform Glue Layer" diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 8df1c583f19d..1ca14f90c994 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -126,7 +126,7 @@ MODULE_PARM_DESC(debug, "Debug message level. Default = 0"); #define DRIVER_INFO DRIVER_DESC ", v" MUSB_VERSION -#define MUSB_DRIVER_NAME "musb_hdrc" +#define MUSB_DRIVER_NAME "musb-hdrc" const char musb_driver_name[] = MUSB_DRIVER_NAME; MODULE_DESCRIPTION(DRIVER_INFO); -- cgit v1.2.2 From dc09886bfa781e2b442301116c18199519e36f0f Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 1 Dec 2010 15:01:11 +0200 Subject: usb: musb: split omap2430 to its own platform_driver Just adding its own platform_driver, not really using it yet. When all HW glue layers are converted, more patches will come to split power management code from musb_core and move it completely to HW glue layer. Signed-off-by: Felipe Balbi --- drivers/usb/musb/Makefile | 3 +- drivers/usb/musb/omap2430.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 52d18dbefcfa..4792001a3d06 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -17,10 +17,11 @@ musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o musb_hdrc-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o musb_hdrc-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o musb_hdrc-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o -musb_hdrc-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o musb_hdrc-$(CONFIG_USB_MUSB_AM35X) += am35x.o musb_hdrc-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o +obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o + # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... # PIO only, or DMA (several potential schemes). diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 5f0d0f105989..78bb1e5cb9f8 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "musb_core.h" #include "omap2430.h" @@ -341,3 +343,85 @@ const struct musb_platform_ops musb_ops = { .set_vbus = omap2430_musb_set_vbus, }; + +static u64 omap2430_dmamask = DMA_BIT_MASK(32); + +static int __init omap2430_probe(struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; + struct platform_device *musb; + + int ret = -ENOMEM; + + musb = platform_device_alloc("musb-hdrc", -1); + if (!musb) { + dev_err(&pdev->dev, "failed to allocate musb device\n"); + goto err0; + } + + musb->dev.parent = &pdev->dev; + musb->dev.dma_mask = &omap2430_dmamask; + musb->dev.coherent_dma_mask = omap2430_dmamask; + + platform_set_drvdata(pdev, musb); + + ret = platform_device_add_resources(musb, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, "failed to add resources\n"); + goto err1; + } + + ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); + if (ret) { + dev_err(&pdev->dev, "failed to add platform_data\n"); + goto err1; + } + + ret = platform_device_add(musb); + if (ret) { + dev_err(&pdev->dev, "failed to register musb device\n"); + goto err1; + } + + return 0; + +err1: + platform_device_put(musb); + +err0: + return ret; +} + +static int __exit omap2430_remove(struct platform_device *pdev) +{ + struct platform_device *musb = platform_get_drvdata(pdev); + + platform_device_del(musb); + platform_device_put(musb); + + return 0; +} + +static struct platform_driver omap2430_driver = { + .remove = __exit_p(omap2430_remove), + .driver = { + .name = "musb-omap2430", + }, +}; + +MODULE_DESCRIPTION("OMAP2PLUS MUSB Glue Layer"); +MODULE_AUTHOR("Felipe Balbi "); +MODULE_LICENSE("GPL v2"); + +static int __init omap2430_init(void) +{ + return platform_driver_probe(&omap2430_driver, omap2430_probe); +} +subsys_initcall(omap2430_init); + +static void __exit omap2430_exit(void) +{ + platform_driver_unregister(&omap2430_driver); +} +module_exit(omap2430_exit); -- cgit v1.2.2 From ce40c5767a0ea1e77ca5d0b73269cb86301a35cf Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:06:51 +0200 Subject: usb: musb: split am35x to its own platform_driver Just adding its own platform_driver, not really using it yet. When all HW glue layers are converted, more patches will come to split power management code from musb_core and move it completely to HW glue layer. Signed-off-by: Felipe Balbi --- drivers/usb/musb/Makefile | 2 +- drivers/usb/musb/am35x.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 4792001a3d06..a48c86d9b4d0 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -17,10 +17,10 @@ musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o musb_hdrc-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o musb_hdrc-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o musb_hdrc-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o -musb_hdrc-$(CONFIG_USB_MUSB_AM35X) += am35x.o musb_hdrc-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o +obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index be17610d7fc2..0ae01f57b3df 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include @@ -535,3 +537,85 @@ const struct musb_platform_ops musb_ops = { .set_vbus = am35x_musb_set_vbus, }; + +static u64 am35x_dmamask = DMA_BIT_MASK(32); + +static int __init am35x_probe(struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; + struct platform_device *musb; + + int ret = -ENOMEM; + + musb = platform_device_alloc("musb-hdrc", -1); + if (!musb) { + dev_err(&pdev->dev, "failed to allocate musb device\n"); + goto err0; + } + + musb->dev.parent = &pdev->dev; + musb->dev.dma_mask = &am35x_dmamask; + musb->dev.coherent_dma_mask = am35x_dmamask; + + platform_set_drvdata(pdev, musb); + + ret = platform_device_add_resources(musb, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, "failed to add resources\n"); + goto err1; + } + + ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); + if (ret) { + dev_err(&pdev->dev, "failed to add platform_data\n"); + goto err1; + } + + ret = platform_device_add(musb); + if (ret) { + dev_err(&pdev->dev, "failed to register musb device\n"); + goto err1; + } + + return 0; + +err1: + platform_device_put(musb); + +err0: + return ret; +} + +static int __exit am35x_remove(struct platform_device *pdev) +{ + struct platform_device *musb = platform_get_drvdata(pdev); + + platform_device_del(musb); + platform_device_put(musb); + + return 0; +} + +static struct platform_driver am35x_driver = { + .remove = __exit_p(am35x_remove), + .driver = { + .name = "musb-am35x", + }, +}; + +MODULE_DESCRIPTION("AM35x MUSB Glue Layer"); +MODULE_AUTHOR("Ajay Kumar Gupta "); +MODULE_LICENSE("GPL v2"); + +static int __init am35x_init(void) +{ + return platform_driver_probe(&am35x_driver, am35x_probe); +} +subsys_initcall(am35x_init); + +static void __exit am35x_exit(void) +{ + platform_driver_unregister(&am35x_driver); +} +module_exit(am35x_exit); -- cgit v1.2.2 From 18688fbeb09665725c842291bbadd88295a359e1 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:13:54 +0200 Subject: usb: musb: split tusb6010 to its own platform_driver Just adding its own platform_driver, not really using it yet. When all HW glue layers are converted, more patches will come to split power management code from musb_core and move it completely to HW glue layer. Signed-off-by: Felipe Balbi --- drivers/usb/musb/Makefile | 2 +- drivers/usb/musb/tusb6010.c | 83 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index a48c86d9b4d0..8e0c9ad85531 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -16,11 +16,11 @@ musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o musb_hdrc-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o musb_hdrc-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o -musb_hdrc-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o musb_hdrc-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o +obj-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 60abd52b2c51..a8e26a0f2ad4 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "musb_core.h" @@ -1185,3 +1186,85 @@ const struct musb_platform_ops musb_ops = { .vbus_status = tusb_musb_vbus_status, .set_vbus = tusb_musb_set_vbus, }; + +static u64 tusb_dmamask = DMA_BIT_MASK(32); + +static int __init tusb_probe(struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; + struct platform_device *musb; + + int ret = -ENOMEM; + + musb = platform_device_alloc("musb-hdrc", -1); + if (!musb) { + dev_err(&pdev->dev, "failed to allocate musb device\n"); + goto err0; + } + + musb->dev.parent = &pdev->dev; + musb->dev.dma_mask = &tusb_dmamask; + musb->dev.coherent_dma_mask = tusb_dmamask; + + platform_set_drvdata(pdev, musb); + + ret = platform_device_add_resources(musb, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, "failed to add resources\n"); + goto err1; + } + + ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); + if (ret) { + dev_err(&pdev->dev, "failed to add platform_data\n"); + goto err1; + } + + ret = platform_device_add(musb); + if (ret) { + dev_err(&pdev->dev, "failed to register musb device\n"); + goto err1; + } + + return 0; + +err1: + platform_device_put(musb); + +err0: + return ret; +} + +static int __exit tusb_remove(struct platform_device *pdev) +{ + struct platform_device *musb = platform_get_drvdata(pdev); + + platform_device_del(musb); + platform_device_put(musb); + + return 0; +} + +static struct platform_driver tusb_driver = { + .remove = __exit_p(tusb_remove), + .driver = { + .name = "musb-tusb", + }, +}; + +MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer"); +MODULE_AUTHOR("Felipe Balbi "); +MODULE_LICENSE("GPL v2"); + +static int __init tusb_init(void) +{ + return platform_driver_probe(&tusb_driver, tusb_probe); +} +subsys_initcall(tusb_init); + +static void __exit tusb_exit(void) +{ + platform_driver_unregister(&tusb_driver); +} +module_exit(tusb_exit); -- cgit v1.2.2 From 73b089b052a69020b953312a624a6e1eb5b81fab Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:16:55 +0200 Subject: usb: musb: split davinci to its own platform_driver Just adding its own platform_driver, not really using it yet. When all HW glue layers are converted, more patches will come to split power management code from musb_core and move it completely to HW glue layer. Signed-off-by: Felipe Balbi --- drivers/usb/musb/Makefile | 2 +- drivers/usb/musb/davinci.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 8e0c9ad85531..2692eeb2085f 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -14,13 +14,13 @@ musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o # Hardware Glue Layer -musb_hdrc-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o musb_hdrc-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o musb_hdrc-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o obj-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o +obj-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index e283b5af8de0..bdf1940d6fee 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -514,3 +516,85 @@ const struct musb_platform_ops musb_ops = { .set_vbus = davinci_musb_set_vbus, }; + +static u64 davinci_dmamask = DMA_BIT_MASK(32); + +static int __init davinci_probe(struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; + struct platform_device *musb; + + int ret = -ENOMEM; + + musb = platform_device_alloc("musb-hdrc", -1); + if (!musb) { + dev_err(&pdev->dev, "failed to allocate musb device\n"); + goto err0; + } + + musb->dev.parent = &pdev->dev; + musb->dev.dma_mask = &davinci_dmamask; + musb->dev.coherent_dma_mask = davinci_dmamask; + + platform_set_drvdata(pdev, musb); + + ret = platform_device_add_resources(musb, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, "failed to add resources\n"); + goto err1; + } + + ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); + if (ret) { + dev_err(&pdev->dev, "failed to add platform_data\n"); + goto err1; + } + + ret = platform_device_add(musb); + if (ret) { + dev_err(&pdev->dev, "failed to register musb device\n"); + goto err1; + } + + return 0; + +err1: + platform_device_put(musb); + +err0: + return ret; +} + +static int __exit davinci_remove(struct platform_device *pdev) +{ + struct platform_device *musb = platform_get_drvdata(pdev); + + platform_device_del(musb); + platform_device_put(musb); + + return 0; +} + +static struct platform_driver davinci_driver = { + .remove = __exit_p(davinci_remove), + .driver = { + .name = "musb-davinci", + }, +}; + +MODULE_DESCRIPTION("DaVinci MUSB Glue Layer"); +MODULE_AUTHOR("Felipe Balbi "); +MODULE_LICENSE("GPL v2"); + +static int __init davinci_init(void) +{ + return platform_driver_probe(&davinci_driver, davinci_probe); +} +subsys_initcall(davinci_init); + +static void __exit davinci_exit(void) +{ + platform_driver_unregister(&davinci_driver); +} +module_exit(davinci_exit); -- cgit v1.2.2 From 8ceae51ed5d1739d4ed5c4b947d12ff1d7df0e89 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:19:35 +0200 Subject: usb: musb: split da8xx to its own platform_driver Just adding its own platform_driver, not really using it yet. When all HW glue layers are converted, more patches will come to split power management code from musb_core and move it completely to HW glue layer. Signed-off-by: Felipe Balbi --- drivers/usb/musb/Makefile | 2 +- drivers/usb/musb/da8xx.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 2692eeb2085f..d2a012917887 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -14,13 +14,13 @@ musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o # Hardware Glue Layer -musb_hdrc-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o musb_hdrc-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o obj-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o obj-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o +obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 6161fc50d049..b80b7da44727 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include @@ -480,3 +482,85 @@ const struct musb_platform_ops musb_ops = { .set_vbus = da8xx_musb_set_vbus, }; + +static u64 da8xx_dmamask = DMA_BIT_MASK(32); + +static int __init da8xx_probe(struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; + struct platform_device *musb; + + int ret = -ENOMEM; + + musb = platform_device_alloc("musb-hdrc", -1); + if (!musb) { + dev_err(&pdev->dev, "failed to allocate musb device\n"); + goto err0; + } + + musb->dev.parent = &pdev->dev; + musb->dev.dma_mask = &da8xx_dmamask; + musb->dev.coherent_dma_mask = da8xx_dmamask; + + platform_set_drvdata(pdev, musb); + + ret = platform_device_add_resources(musb, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, "failed to add resources\n"); + goto err1; + } + + ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); + if (ret) { + dev_err(&pdev->dev, "failed to add platform_data\n"); + goto err1; + } + + ret = platform_device_add(musb); + if (ret) { + dev_err(&pdev->dev, "failed to register musb device\n"); + goto err1; + } + + return 0; + +err1: + platform_device_put(musb); + +err0: + return ret; +} + +static int __exit da8xx_remove(struct platform_device *pdev) +{ + struct platform_device *musb = platform_get_drvdata(pdev); + + platform_device_del(musb); + platform_device_put(musb); + + return 0; +} + +static struct platform_driver da8xx_driver = { + .remove = __exit_p(da8xx_remove), + .driver = { + .name = "musb-da8xx", + }, +}; + +MODULE_DESCRIPTION("DA8xx/OMAP-L1x MUSB Glue Layer"); +MODULE_AUTHOR("Sergei Shtylyov "); +MODULE_LICENSE("GPL v2"); + +static int __init da8xx_init(void) +{ + return platform_driver_probe(&da8xx_driver, da8xx_probe); +} +subsys_initcall(da8xx_init); + +static void __exit da8xx_exit(void) +{ + platform_driver_unregister(&da8xx_driver); +} +module_exit(da8xx_exit); -- cgit v1.2.2 From 9cb0308eec7a965136fe9fc6d1be3548c01a4a1e Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:21:05 +0200 Subject: usb: musb: split blackfin to its own platform_driver Just adding its own platform_driver, not really using it yet. Later patches will come to split power management code from musb_core and move it completely to HW glue layer. Signed-off-by: Felipe Balbi --- drivers/usb/musb/Makefile | 4 +-- drivers/usb/musb/blackfin.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 3 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index d2a012917887..61f46affcf7a 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -13,14 +13,12 @@ musb_hdrc-$(CONFIG_USB_MUSB_HDRC_HCD) += musb_virthub.o musb_host.o musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o # Hardware Glue Layer - -musb_hdrc-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o - obj-$(CONFIG_USB_MUSB_OMAP2PLUS) += omap2430.o obj-$(CONFIG_USB_MUSB_AM35X) += am35x.o obj-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o obj-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o +obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 9874501d6429..b0968201d849 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include @@ -442,3 +444,85 @@ const struct musb_platform_ops musb_ops = { .vbus_status = bfin_musb_vbus_status, .set_vbus = bfin_musb_set_vbus, }; + +static u64 bfin_dmamask = DMA_BIT_MASK(32); + +static int __init bfin_probe(struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; + struct platform_device *musb; + + int ret = -ENOMEM; + + musb = platform_device_alloc("musb-hdrc", -1); + if (!musb) { + dev_err(&pdev->dev, "failed to allocate musb device\n"); + goto err0; + } + + musb->dev.parent = &pdev->dev; + musb->dev.dma_mask = &bfin_dmamask; + musb->dev.coherent_dma_mask = bfin_dmamask; + + platform_set_drvdata(pdev, musb); + + ret = platform_device_add_resources(musb, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, "failed to add resources\n"); + goto err1; + } + + ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); + if (ret) { + dev_err(&pdev->dev, "failed to add platform_data\n"); + goto err1; + } + + ret = platform_device_add(musb); + if (ret) { + dev_err(&pdev->dev, "failed to register musb device\n"); + goto err1; + } + + return 0; + +err1: + platform_device_put(musb); + +err0: + return ret; +} + +static int __exit bfin_remove(struct platform_device *pdev) +{ + struct platform_device *musb = platform_get_drvdata(pdev); + + platform_device_del(musb); + platform_device_put(musb); + + return 0; +} + +static struct platform_driver bfin_driver = { + .remove = __exit_p(bfin_remove), + .driver = { + .name = "musb-bfin", + }, +}; + +MODULE_DESCRIPTION("Blackfin MUSB Glue Layer"); +MODULE_AUTHOR("Bryan Wy "); +MODULE_LICENSE("GPL v2"); + +static int __init bfin_init(void) +{ + return platform_driver_probe(&bfin_driver, bfin_probe); +} +subsys_initcall(bfin_init); + +static void __exit bfin_exit(void) +{ + platform_driver_unregister(&bfin_driver); +} +module_exit(bfin_exit); -- cgit v1.2.2 From a3cee12aa9129b576c5403a31e37d0e0113235b3 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:27:29 +0200 Subject: usb: musb: omap2430: give it a context structure that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi --- drivers/usb/musb/omap2430.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 78bb1e5cb9f8..bca9df7557a4 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -37,6 +37,11 @@ #include "musb_core.h" #include "omap2430.h" +struct omap2430_glue { + struct device *dev; + struct platform_device *musb; +}; + static struct timer_list musb_idle_timer; static void musb_do_idle(unsigned long _musb) @@ -350,55 +355,69 @@ static int __init omap2430_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; + struct omap2430_glue *glue; int ret = -ENOMEM; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + dev_err(&pdev->dev, "failed to allocate glue context\n"); + goto err0; + } + musb = platform_device_alloc("musb-hdrc", -1); if (!musb) { dev_err(&pdev->dev, "failed to allocate musb device\n"); - goto err0; + goto err1; } musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &omap2430_dmamask; musb->dev.coherent_dma_mask = omap2430_dmamask; - platform_set_drvdata(pdev, musb); + glue->dev = &pdev->dev; + glue->musb = musb; + + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err1; + goto err2; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err1; + goto err2; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err1; + goto err2; } return 0; -err1: +err2: platform_device_put(musb); +err1: + kfree(glue); + err0: return ret; } static int __exit omap2430_remove(struct platform_device *pdev) { - struct platform_device *musb = platform_get_drvdata(pdev); + struct omap2430_glue *glue = platform_get_drvdata(pdev); - platform_device_del(musb); - platform_device_put(musb); + platform_device_del(glue->musb); + platform_device_put(glue->musb); + kfree(glue); return 0; } -- cgit v1.2.2 From 0919dfc12a43d5ea21411e67984c268e84d05204 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:33:24 +0200 Subject: usb: musb: am35x: give it a context structure that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi --- drivers/usb/musb/am35x.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 0ae01f57b3df..355883c5ffed 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -82,6 +82,11 @@ #define USB_MENTOR_CORE_OFFSET 0x400 +struct am35x_glue { + struct device *dev; + struct platform_device *musb; +}; + static inline void phy_on(void) { unsigned long timeout = jiffies + msecs_to_jiffies(100); @@ -544,55 +549,69 @@ static int __init am35x_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; + struct am35x_glue *glue; int ret = -ENOMEM; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + dev_err(&pdev->dev, "failed to allocate glue context\n"); + goto err0; + } + musb = platform_device_alloc("musb-hdrc", -1); if (!musb) { dev_err(&pdev->dev, "failed to allocate musb device\n"); - goto err0; + goto err1; } musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &am35x_dmamask; musb->dev.coherent_dma_mask = am35x_dmamask; - platform_set_drvdata(pdev, musb); + glue->dev = &pdev->dev; + glue->musb = musb; + + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err1; + goto err2; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err1; + goto err2; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err1; + goto err2; } return 0; -err1: +err2: platform_device_put(musb); +err1: + kfree(glue); + err0: return ret; } static int __exit am35x_remove(struct platform_device *pdev) { - struct platform_device *musb = platform_get_drvdata(pdev); + struct am35x_glue *glue = platform_get_drvdata(pdev); - platform_device_del(musb); - platform_device_put(musb); + platform_device_del(glue->musb); + platform_device_put(glue->musb); + kfree(glue); return 0; } -- cgit v1.2.2 From 1add75d2bd1a44553e2c40e30db5f90a500dc1ab Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:35:58 +0200 Subject: usb: musb: tusb6010: give it a context structure that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi --- drivers/usb/musb/tusb6010.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index a8e26a0f2ad4..2ff78d6b2eff 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -25,6 +25,11 @@ #include "musb_core.h" +struct tusb6010_glue { + struct device *dev; + struct platform_device *musb; +}; + static void tusb_musb_set_vbus(struct musb *musb, int is_on); #define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) @@ -1193,32 +1198,42 @@ static int __init tusb_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; + struct tusb6010_glue *glue; int ret = -ENOMEM; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + dev_err(&pdev->dev, "failed to allocate glue context\n"); + goto err0; + } + musb = platform_device_alloc("musb-hdrc", -1); if (!musb) { dev_err(&pdev->dev, "failed to allocate musb device\n"); - goto err0; + goto err1; } musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &tusb_dmamask; musb->dev.coherent_dma_mask = tusb_dmamask; - platform_set_drvdata(pdev, musb); + glue->dev = &pdev->dev; + glue->musb = musb; + + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err1; + goto err2; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err1; + goto err2; } ret = platform_device_add(musb); @@ -1229,19 +1244,23 @@ static int __init tusb_probe(struct platform_device *pdev) return 0; -err1: +err2: platform_device_put(musb); +err1: + kfree(glue); + err0: return ret; } static int __exit tusb_remove(struct platform_device *pdev) { - struct platform_device *musb = platform_get_drvdata(pdev); + struct tusb6010_glue *glue = platform_get_drvdata(pdev); - platform_device_del(musb); - platform_device_put(musb); + platform_device_del(glue->musb); + platform_device_put(glue->musb); + kfree(glue); return 0; } -- cgit v1.2.2 From e110de4d5358f2e67c333d23d608cbabe26b6220 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:38:12 +0200 Subject: usb: musb: davinci: give it a context structure that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi --- drivers/usb/musb/davinci.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index bdf1940d6fee..661870a1cd4d 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -53,6 +53,11 @@ #define USB_PHY_CTRL IO_ADDRESS(USBPHY_CTL_PADDR) #define DM355_DEEPSLEEP IO_ADDRESS(DM355_DEEPSLEEP_PADDR) +struct davinci_glue { + struct device *dev; + struct platform_device *musb; +}; + /* REVISIT (PM) we should be able to keep the PHY in low power mode most * of the time (24 MHZ oscillator and PLL off, etc) by setting POWER.D0 * and, when in host mode, autosuspending idle root ports... PHYPLLON @@ -523,55 +528,69 @@ static int __init davinci_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; + struct davinci_glue *glue; int ret = -ENOMEM; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + dev_err(&pdev->dev, "failed to allocate glue context\n"); + goto err0; + } + musb = platform_device_alloc("musb-hdrc", -1); if (!musb) { dev_err(&pdev->dev, "failed to allocate musb device\n"); - goto err0; + goto err1; } musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &davinci_dmamask; musb->dev.coherent_dma_mask = davinci_dmamask; - platform_set_drvdata(pdev, musb); + glue->dev = &pdev->dev; + glue->musb = musb; + + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err1; + goto err2; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err1; + goto err2; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err1; + goto err2; } return 0; -err1: +err2: platform_device_put(musb); +err1: + kfree(glue); + err0: return ret; } static int __exit davinci_remove(struct platform_device *pdev) { - struct platform_device *musb = platform_get_drvdata(pdev); + struct davinci_glue *glue = platform_get_drvdata(pdev); - platform_device_del(musb); - platform_device_put(musb); + platform_device_del(glue->musb); + platform_device_put(glue->musb); + kfree(glue); return 0; } -- cgit v1.2.2 From e6480faa1067af91ab403fd3aaf6db2fe1134b13 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:40:34 +0200 Subject: usb: musb: da8xx: give it a context structure that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi --- drivers/usb/musb/da8xx.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index b80b7da44727..94ddfe01d673 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -80,6 +80,11 @@ #define CFGCHIP2 IO_ADDRESS(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG) +struct da8xx_glue { + struct device *dev; + struct platform_device *musb; +}; + /* * REVISIT (PM): we should be able to keep the PHY in low power mode most * of the time (24 MHz oscillator and PLL off, etc.) by setting POWER.D0 @@ -489,55 +494,69 @@ static int __init da8xx_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; + struct da8xx_glue *glue; int ret = -ENOMEM; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + dev_err(&pdev->dev, "failed to allocate glue context\n"); + goto err0; + } + musb = platform_device_alloc("musb-hdrc", -1); if (!musb) { dev_err(&pdev->dev, "failed to allocate musb device\n"); - goto err0; + goto err1; } musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &da8xx_dmamask; musb->dev.coherent_dma_mask = da8xx_dmamask; - platform_set_drvdata(pdev, musb); + glue->dev = &pdev->dev; + glue->musb = musb; + + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err1; + goto err2; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err1; + goto err2; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err1; + goto err2; } return 0; -err1: +err2: platform_device_put(musb); +err1: + kfree(glue); + err0: return ret; } static int __exit da8xx_remove(struct platform_device *pdev) { - struct platform_device *musb = platform_get_drvdata(pdev); + struct da8xx_glue *glue = platform_get_drvdata(pdev); - platform_device_del(musb); - platform_device_put(musb); + platform_device_del(glue->musb); + platform_device_put(glue->musb); + kfree(glue); return 0; } -- cgit v1.2.2 From a023c631f546ef95d58969385825a47652ab9039 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:42:50 +0200 Subject: usb: musb: blackfin: give it a context structure that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi --- drivers/usb/musb/blackfin.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index b0968201d849..02eded21d171 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -23,6 +23,11 @@ #include "musb_core.h" #include "blackfin.h" +struct bfin_glue { + struct device *dev; + struct platform_device *musb; +}; + /* * Load an endpoint's FIFO */ @@ -451,55 +456,69 @@ static int __init bfin_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; + struct bfin_glue *glue; int ret = -ENOMEM; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + dev_err(&pdev->dev, "failed to allocate glue context\n"); + goto err0; + } + musb = platform_device_alloc("musb-hdrc", -1); if (!musb) { dev_err(&pdev->dev, "failed to allocate musb device\n"); - goto err0; + goto err1; } musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &bfin_dmamask; musb->dev.coherent_dma_mask = bfin_dmamask; - platform_set_drvdata(pdev, musb); + glue->dev = &pdev->dev; + glue->musb = musb; + + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err1; + goto err2; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err1; + goto err2; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err1; + goto err2; } return 0; -err1: +err2: platform_device_put(musb); +err1: + kfree(glue); + err0: return ret; } static int __exit bfin_remove(struct platform_device *pdev) { - struct platform_device *musb = platform_get_drvdata(pdev); + struct bfin_glue *glue = platform_get_drvdata(pdev); - platform_device_del(musb); - platform_device_put(musb); + platform_device_del(glue->musb); + platform_device_put(glue->musb); + kfree(glue); return 0; } -- cgit v1.2.2 From f7ec94370f417fedad4db1054228ef958d48b926 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:48:58 +0200 Subject: usb: musb: pass platform_ops via platform_data ... then we don't need to export any symbols from glue layer to musb_core. Signed-off-by: Felipe Balbi --- drivers/usb/musb/am35x.c | 4 +++- drivers/usb/musb/blackfin.c | 4 +++- drivers/usb/musb/da8xx.c | 4 +++- drivers/usb/musb/davinci.c | 4 +++- drivers/usb/musb/musb_core.c | 2 +- drivers/usb/musb/musb_core.h | 2 -- drivers/usb/musb/omap2430.c | 4 +++- drivers/usb/musb/tusb6010.c | 4 +++- 8 files changed, 19 insertions(+), 9 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 355883c5ffed..e372c87f37e2 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -530,7 +530,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) } } -const struct musb_platform_ops musb_ops = { +static const struct musb_platform_ops am35x_ops = { .init = am35x_musb_init, .exit = am35x_musb_exit, @@ -572,6 +572,8 @@ static int __init am35x_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; + pdata->platform_ops = &am35x_ops; + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 02eded21d171..03cb001c0e19 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -436,7 +436,7 @@ static int bfin_musb_exit(struct musb *musb) return 0; } -const struct musb_platform_ops musb_ops = { +static const struct musb_platform_ops bfin_ops = { .init = bfin_musb_init, .exit = bfin_musb_exit, @@ -479,6 +479,8 @@ static int __init bfin_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; + pdata->platform_ops = &bfin_ops; + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 94ddfe01d673..45ccac3aad9d 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -475,7 +475,7 @@ static int da8xx_musb_exit(struct musb *musb) return 0; } -const struct musb_platform_ops musb_ops = { +static const struct musb_platform_ops da8xx_ops = { .init = da8xx_musb_init, .exit = da8xx_musb_exit, @@ -517,6 +517,8 @@ static int __init da8xx_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; + pdata->platform_ops = &da8xx_ops; + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 661870a1cd4d..831a04dd5a53 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -510,7 +510,7 @@ static int davinci_musb_exit(struct musb *musb) return 0; } -const struct musb_platform_ops musb_ops = { +static const struct musb_platform_ops davinci_ops = { .init = davinci_musb_init, .exit = davinci_musb_exit, @@ -551,6 +551,8 @@ static int __init davinci_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; + pdata->platform_ops = &davinci_ops; + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 1ca14f90c994..dcc77ef6cfff 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1897,7 +1897,6 @@ allocate_instance(struct device *dev, } musb->controller = dev; - musb->ops = &musb_ops; return musb; } @@ -1997,6 +1996,7 @@ bad_config: musb->board_set_power = plat->set_power; musb->set_clock = plat->set_clock; musb->min_power = plat->min_power; + musb->ops = plat->platform_ops; /* Clock usage is chip-specific ... functional clock (DaVinci, * OMAP2430), or PHY ref (some TUSB6010 boards). All this core diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 9594b9d1d27b..fac1eab3c59f 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -281,8 +281,6 @@ struct musb_platform_ops { void (*set_vbus)(struct musb *musb, int on); }; -extern const struct musb_platform_ops musb_ops; - /* * struct musb_hw_ep - endpoint hardware (bidirectional) * diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index bca9df7557a4..2eea1703e630 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -333,7 +333,7 @@ static int omap2430_musb_exit(struct musb *musb) return 0; } -const struct musb_platform_ops musb_ops = { +static const struct musb_platform_ops omap2430_ops = { .init = omap2430_musb_init, .exit = omap2430_musb_exit, @@ -378,6 +378,8 @@ static int __init omap2430_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; + pdata->platform_ops = &omap2430_ops; + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 2ff78d6b2eff..d6b832641c53 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -1178,7 +1178,7 @@ static int tusb_musb_exit(struct musb *musb) return 0; } -const struct musb_platform_ops musb_ops = { +static const struct musb_platform_ops tusb_ops = { .init = tusb_musb_init, .exit = tusb_musb_exit, @@ -1221,6 +1221,8 @@ static int __init tusb_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->musb = musb; + pdata->platform_ops = &tusb_ops; + platform_set_drvdata(pdev, glue); ret = platform_device_add_resources(musb, pdev->resource, -- cgit v1.2.2 From 0349176120aa3024e96ae4fd7dc0e0181dc55f52 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 09:57:08 +0200 Subject: usb: musb: move clock handling to glue layer 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. Signed-off-by: Felipe Balbi --- drivers/usb/musb/am35x.c | 91 +++++++++++++++++++++++++++----------------- drivers/usb/musb/da8xx.c | 36 ++++++++++++++---- drivers/usb/musb/davinci.c | 36 +++++++++++++----- drivers/usb/musb/musb_core.c | 39 +------------------ drivers/usb/musb/musb_core.h | 2 - drivers/usb/musb/omap2430.c | 46 +++++++++++++--------- drivers/usb/musb/tusb6010.c | 15 -------- 7 files changed, 140 insertions(+), 125 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index e372c87f37e2..e4e571bf9ba7 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -85,6 +85,8 @@ struct am35x_glue { struct device *dev; struct platform_device *musb; + struct clk *phy_clk; + struct clk *clk; }; static inline void phy_on(void) @@ -402,34 +404,18 @@ static int am35x_musb_init(struct musb *musb) { void __iomem *reg_base = musb->ctrl_base; u32 rev, lvl_intr, sw_reset; - int status; musb->mregs += USB_MENTOR_CORE_OFFSET; - clk_enable(musb->clock); - DBG(2, "musb->clock=%lud\n", clk_get_rate(musb->clock)); - - musb->phy_clock = clk_get(musb->controller, "fck"); - if (IS_ERR(musb->phy_clock)) { - status = PTR_ERR(musb->phy_clock); - goto exit0; - } - clk_enable(musb->phy_clock); - DBG(2, "musb->phy_clock=%lud\n", clk_get_rate(musb->phy_clock)); - /* Returns zero if e.g. not clocked */ rev = musb_readl(reg_base, USB_REVISION_REG); - if (!rev) { - status = -ENODEV; - goto exit1; - } + if (!rev) + return -ENODEV; usb_nop_xceiv_register(); musb->xceiv = otg_get_transceiver(); - if (!musb->xceiv) { - status = -ENODEV; - goto exit1; - } + if (!musb->xceiv) + return -ENODEV; if (is_host_enabled(musb)) setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); @@ -459,13 +445,8 @@ static int am35x_musb_init(struct musb *musb) lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); lvl_intr |= AM35XX_USBOTGSS_INT_CLR; omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR); + return 0; -exit1: - clk_disable(musb->phy_clock); - clk_put(musb->phy_clock); -exit0: - clk_disable(musb->clock); - return status; } static int am35x_musb_exit(struct musb *musb) @@ -478,11 +459,6 @@ static int am35x_musb_exit(struct musb *musb) otg_put_transceiver(musb->xceiv); usb_nop_xceiv_unregister(); - clk_disable(musb->clock); - - clk_disable(musb->phy_clock); - clk_put(musb->phy_clock); - return 0; } @@ -551,6 +527,9 @@ static int __init am35x_probe(struct platform_device *pdev) struct platform_device *musb; struct am35x_glue *glue; + struct clk *phy_clk; + struct clk *clk; + int ret = -ENOMEM; glue = kzalloc(sizeof(*glue), GFP_KERNEL); @@ -565,12 +544,40 @@ static int __init am35x_probe(struct platform_device *pdev) goto err1; } + phy_clk = clk_get(&pdev->dev, "fck"); + if (IS_ERR(phy_clk)) { + dev_err(&pdev->dev, "failed to get PHY clock\n"); + ret = PTR_ERR(phy_clk); + goto err2; + } + + clk = clk_get(&pdev->dev, "ick"); + if (IS_ERR(clk)) { + dev_err(&pdev->dev, "failed to get clock\n"); + ret = PTR_ERR(clk); + goto err3; + } + + ret = clk_enable(phy_clk); + if (ret) { + dev_err(&pdev->dev, "failed to enable PHY clock\n"); + goto err4; + } + + ret = clk_enable(clk); + if (ret) { + dev_err(&pdev->dev, "failed to enable clock\n"); + goto err5; + } + musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &am35x_dmamask; musb->dev.coherent_dma_mask = am35x_dmamask; glue->dev = &pdev->dev; glue->musb = musb; + glue->phy_clk = phy_clk; + glue->clk = clk; pdata->platform_ops = &am35x_ops; @@ -580,23 +587,35 @@ static int __init am35x_probe(struct platform_device *pdev) pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err2; + goto err6; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err2; + goto err6; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err2; + goto err6; } return 0; +err6: + clk_disable(clk); + +err5: + clk_disable(phy_clk); + +err4: + clk_put(clk); + +err3: + clk_put(phy_clk); + err2: platform_device_put(musb); @@ -613,6 +632,10 @@ static int __exit am35x_remove(struct platform_device *pdev) platform_device_del(glue->musb); platform_device_put(glue->musb); + clk_disable(glue->clk); + clk_disable(glue->phy_clk); + clk_put(glue->clk); + clk_put(glue->phy_clk); kfree(glue); return 0; diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 45ccac3aad9d..387f4a75706f 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -83,6 +83,7 @@ struct da8xx_glue { struct device *dev; struct platform_device *musb; + struct clk *clk; }; /* @@ -423,8 +424,6 @@ static int da8xx_musb_init(struct musb *musb) musb->mregs += DA8XX_MENTOR_CORE_OFFSET; - clk_enable(musb->clock); - /* Returns zero if e.g. not clocked */ rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG); if (!rev) @@ -456,7 +455,6 @@ static int da8xx_musb_init(struct musb *musb) musb->isr = da8xx_musb_interrupt; return 0; fail: - clk_disable(musb->clock); return -ENODEV; } @@ -470,8 +468,6 @@ static int da8xx_musb_exit(struct musb *musb) otg_put_transceiver(musb->xceiv); usb_nop_xceiv_unregister(); - clk_disable(musb->clock); - return 0; } @@ -496,6 +492,8 @@ static int __init da8xx_probe(struct platform_device *pdev) struct platform_device *musb; struct da8xx_glue *glue; + struct clk *clk; + int ret = -ENOMEM; glue = kzalloc(sizeof(*glue), GFP_KERNEL); @@ -510,12 +508,26 @@ static int __init da8xx_probe(struct platform_device *pdev) goto err1; } + clk = clk_get(&pdev->dev, "usb20"); + if (IS_ERR(clk)) { + dev_err(&pdev->dev, "failed to get clock\n"); + ret = PTR_ERR(clk); + goto err2; + } + + ret = clk_enable(clk); + if (ret) { + dev_err(&pdev->dev, "failed to enable clock\n"); + goto err3; + } + musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &da8xx_dmamask; musb->dev.coherent_dma_mask = da8xx_dmamask; glue->dev = &pdev->dev; glue->musb = musb; + glue->clk = clk; pdata->platform_ops = &da8xx_ops; @@ -525,23 +537,29 @@ static int __init da8xx_probe(struct platform_device *pdev) pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err2; + goto err4; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err2; + goto err4; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err2; + goto err4; } return 0; +err4: + clk_disable(clk); + +err3: + clk_put(clk); + err2: platform_device_put(musb); @@ -558,6 +576,8 @@ static int __exit da8xx_remove(struct platform_device *pdev) platform_device_del(glue->musb); platform_device_put(glue->musb); + clk_disable(glue->clk); + clk_put(glue->clk); kfree(glue); return 0; diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 831a04dd5a53..de67480d4f19 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -56,6 +56,7 @@ struct davinci_glue { struct device *dev; struct platform_device *musb; + struct clk *clk; }; /* REVISIT (PM) we should be able to keep the PHY in low power mode most @@ -395,8 +396,6 @@ static int davinci_musb_init(struct musb *musb) musb->mregs += DAVINCI_BASE_OFFSET; - clk_enable(musb->clock); - /* returns zero if e.g. not clocked */ revision = musb_readl(tibase, DAVINCI_USB_VERSION_REG); if (revision == 0) @@ -451,8 +450,6 @@ static int davinci_musb_init(struct musb *musb) return 0; fail: - clk_disable(musb->clock); - otg_put_transceiver(musb->xceiv); usb_nop_xceiv_unregister(); return -ENODEV; @@ -502,8 +499,6 @@ static int davinci_musb_exit(struct musb *musb) phy_off(); - clk_disable(musb->clock); - otg_put_transceiver(musb->xceiv); usb_nop_xceiv_unregister(); @@ -529,6 +524,7 @@ static int __init davinci_probe(struct platform_device *pdev) struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; struct davinci_glue *glue; + struct clk *clk; int ret = -ENOMEM; @@ -544,12 +540,26 @@ static int __init davinci_probe(struct platform_device *pdev) goto err1; } + clk = clk_get(&pdev->dev, "usb"); + if (IS_ERR(clk)) { + dev_err(&pdev->dev, "failed to get clock\n"); + ret = PTR_ERR(clk); + goto err2; + } + + ret = clk_enable(clk); + if (ret) { + dev_err(&pdev->dev, "failed to enable clock\n"); + goto err3; + } + musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &davinci_dmamask; musb->dev.coherent_dma_mask = davinci_dmamask; glue->dev = &pdev->dev; glue->musb = musb; + glue->clk = clk; pdata->platform_ops = &davinci_ops; @@ -559,23 +569,29 @@ static int __init davinci_probe(struct platform_device *pdev) pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err2; + goto err4; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err2; + goto err4; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err2; + goto err4; } return 0; +err4: + clk_disable(clk); + +err3: + clk_put(clk); + err2: platform_device_put(musb); @@ -592,6 +608,8 @@ static int __exit davinci_remove(struct platform_device *pdev) platform_device_del(glue->musb); platform_device_put(glue->musb); + clk_disable(glue->clk); + clk_put(glue->clk); kfree(glue); return 0; diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index dcc77ef6cfff..6078eece74c7 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1048,8 +1048,6 @@ static void musb_shutdown(struct platform_device *pdev) spin_lock_irqsave(&musb->lock, flags); musb_platform_disable(musb); musb_generic_disable(musb); - if (musb->clock) - clk_put(musb->clock); spin_unlock_irqrestore(&musb->lock, flags); /* FIXME power down */ @@ -1994,29 +1992,13 @@ bad_config: spin_lock_init(&musb->lock); musb->board_mode = plat->mode; musb->board_set_power = plat->set_power; - musb->set_clock = plat->set_clock; musb->min_power = plat->min_power; musb->ops = plat->platform_ops; - /* Clock usage is chip-specific ... functional clock (DaVinci, - * OMAP2430), or PHY ref (some TUSB6010 boards). All this core - * code does is make sure a clock handle is available; platform - * code manages it during start/stop and suspend/resume. - */ - if (plat->clock) { - musb->clock = clk_get(dev, plat->clock); - if (IS_ERR(musb->clock)) { - status = PTR_ERR(musb->clock); - musb->clock = NULL; - goto fail1; - } - } - /* The musb_platform_init() call: * - adjusts musb->mregs and musb->isr if needed, * - may initialize an integrated tranceiver * - initializes musb->xceiv, usually by otg_get_transceiver() - * - activates clocks. * - stops powering VBUS * - assigns musb->board_set_vbus if host mode is enabled * @@ -2028,7 +2010,7 @@ bad_config: musb->isr = generic_interrupt; status = musb_platform_init(musb); if (status < 0) - goto fail2; + goto fail1; if (!musb->isr) { status = -ENODEV; @@ -2178,10 +2160,6 @@ fail3: device_init_wakeup(dev, 0); musb_platform_exit(musb); -fail2: - if (musb->clock) - clk_put(musb->clock); - fail1: dev_err(musb->controller, "musb_init_controller failed with status %d\n", status); @@ -2410,9 +2388,6 @@ static int musb_suspend(struct device *dev) unsigned long flags; struct musb *musb = dev_to_musb(&pdev->dev); - if (!musb->clock) - return 0; - spin_lock_irqsave(&musb->lock, flags); if (is_peripheral_active(musb)) { @@ -2427,10 +2402,6 @@ static int musb_suspend(struct device *dev) musb_save_context(musb); - if (musb->set_clock) - musb->set_clock(musb->clock, 0); - else - clk_disable(musb->clock); spin_unlock_irqrestore(&musb->lock, flags); return 0; } @@ -2440,14 +2411,6 @@ static int musb_resume_noirq(struct device *dev) struct platform_device *pdev = to_platform_device(dev); struct musb *musb = dev_to_musb(&pdev->dev); - if (!musb->clock) - return 0; - - if (musb->set_clock) - musb->set_clock(musb->clock, 1); - else - clk_enable(musb->clock); - musb_restore_context(musb); /* for static cmos like DaVinci, register values were preserved diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index fac1eab3c59f..6c8e9630fb19 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -384,8 +384,6 @@ struct musb_context_registers { struct musb { /* device lock */ spinlock_t lock; - struct clk *clock; - struct clk *phy_clock; const struct musb_platform_ops *ops; struct musb_context_registers context; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 2eea1703e630..fa3154b03044 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -40,6 +40,7 @@ struct omap2430_glue { struct device *dev; struct platform_device *musb; + struct clk *clk; }; static struct timer_list musb_idle_timer; @@ -277,9 +278,6 @@ static int omap2430_musb_suspend(struct musb *musb) { u32 l; - if (!musb->clock) - return 0; - /* in any role */ l = musb_readl(musb->mregs, OTG_FORCESTDBY); l |= ENABLEFORCE; /* enable MSTANDBY */ @@ -291,11 +289,6 @@ static int omap2430_musb_suspend(struct musb *musb) otg_set_suspend(musb->xceiv, 1); - if (musb->set_clock) - musb->set_clock(musb->clock, 0); - else - clk_disable(musb->clock); - return 0; } @@ -303,16 +296,8 @@ static int omap2430_musb_resume(struct musb *musb) { u32 l; - if (!musb->clock) - return 0; - otg_set_suspend(musb->xceiv, 0); - if (musb->set_clock) - musb->set_clock(musb->clock, 1); - else - clk_enable(musb->clock); - l = musb_readl(musb->mregs, OTG_SYSCONFIG); l &= ~ENABLEWAKEUP; /* disable wakeup */ musb_writel(musb->mregs, OTG_SYSCONFIG, l); @@ -356,6 +341,7 @@ static int __init omap2430_probe(struct platform_device *pdev) struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct platform_device *musb; struct omap2430_glue *glue; + struct clk *clk; int ret = -ENOMEM; @@ -371,12 +357,26 @@ static int __init omap2430_probe(struct platform_device *pdev) goto err1; } + clk = clk_get(&pdev->dev, "ick"); + if (IS_ERR(clk)) { + dev_err(&pdev->dev, "failed to get clock\n"); + ret = PTR_ERR(clk); + goto err2; + } + + ret = clk_enable(clk); + if (ret) { + dev_err(&pdev->dev, "failed to enable clock\n"); + goto err3; + } + musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &omap2430_dmamask; musb->dev.coherent_dma_mask = omap2430_dmamask; glue->dev = &pdev->dev; glue->musb = musb; + glue->clk = clk; pdata->platform_ops = &omap2430_ops; @@ -386,23 +386,29 @@ static int __init omap2430_probe(struct platform_device *pdev) pdev->num_resources); if (ret) { dev_err(&pdev->dev, "failed to add resources\n"); - goto err2; + goto err4; } ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); if (ret) { dev_err(&pdev->dev, "failed to add platform_data\n"); - goto err2; + goto err4; } ret = platform_device_add(musb); if (ret) { dev_err(&pdev->dev, "failed to register musb device\n"); - goto err2; + goto err4; } return 0; +err4: + clk_disable(clk); + +err3: + clk_put(clk); + err2: platform_device_put(musb); @@ -419,6 +425,8 @@ static int __exit omap2430_remove(struct platform_device *pdev) platform_device_del(glue->musb); platform_device_put(glue->musb); + clk_disable(glue->clk); + clk_put(glue->clk); kfree(glue); return 0; diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index d6b832641c53..2ba3b070ed0b 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -281,17 +281,6 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA) void __iomem *tbase = musb->ctrl_base; u32 reg; - /* - * Keep clock active when enabled. Note that this is not tied to - * drawing VBUS, as with OTG mA can be less than musb->min_power. - */ - if (musb->set_clock) { - if (mA) - musb->set_clock(musb->clock, 1); - else - musb->set_clock(musb->clock, 0); - } - /* tps65030 seems to consume max 100mA, with maybe 60mA available * (measured on one board) for things other than tps and tusb. * @@ -537,8 +526,6 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) devctl = musb_readb(musb->mregs, MUSB_DEVCTL); if (is_on) { - if (musb->set_clock) - musb->set_clock(musb->clock, 1); timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE); musb->xceiv->default_a = 1; musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; @@ -577,8 +564,6 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) devctl &= ~MUSB_DEVCTL_SESSION; conf &= ~TUSB_DEV_CONF_USB_HOST_MODE; - if (musb->set_clock) - musb->set_clock(musb->clock, 0); } prcm &= ~(TUSB_PRCM_MNGMT_15_SW_EN | TUSB_PRCM_MNGMT_33_SW_EN); -- cgit v1.2.2 From fa56df915d101770a495569473b4c13b1904087b Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 10:55:29 +0200 Subject: usb: musb: drop the set_clock magic now that platform glue layer handles clock completely, that function is completely useless for us. Drop it. Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 6c8e9630fb19..1e538675ab86 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -455,8 +455,6 @@ struct musb { u8 board_mode; /* enum musb_mode */ int (*board_set_power)(int state); - int (*set_clock)(struct clk *clk, int is_active); - u8 min_power; /* vbus for periph, in mA/2 */ bool is_host; -- cgit v1.2.2 From 496351413a227a6c0ea1a704d3d4c775d413fd08 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 12:27:35 +0200 Subject: usb: musb: drop musb_platform_save/restore_context ... that can be easily folded into the musb_platform_suspend/resume calls. Signed-off-by: Felipe Balbi --- drivers/usb/musb/am35x.c | 15 +++++++++------ drivers/usb/musb/blackfin.c | 15 +++++++++------ drivers/usb/musb/musb_core.c | 4 ++-- drivers/usb/musb/musb_core.h | 14 -------------- drivers/usb/musb/omap2430.c | 20 ++++++++++---------- 5 files changed, 30 insertions(+), 38 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index e4e571bf9ba7..eacf1e09b495 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -462,19 +462,19 @@ static int am35x_musb_exit(struct musb *musb) return 0; } -#ifdef CONFIG_PM -void musb_platform_save_context(struct musb *musb, - struct musb_context_registers *musb_context) +static int am35x_musb_suspend(struct musb *musb) { phy_off(); + + return 0; } -void musb_platform_restore_context(struct musb *musb, - struct musb_context_registers *musb_context) +static int am35x_musb_resume(struct musb *musb) { phy_on(); + + return 0; } -#endif /* AM35x supports only 32bit read operation */ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) @@ -516,6 +516,9 @@ static const struct musb_platform_ops am35x_ops = { .set_mode = am35x_musb_set_mode, .try_idle = am35x_musb_try_idle, + .suspend = am35x_musb_suspend, + .resume = am35x_musb_resume, + .set_vbus = am35x_musb_set_vbus, }; diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 03cb001c0e19..8c9c5fc3a6ca 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -406,9 +406,7 @@ static int bfin_musb_init(struct musb *musb) return 0; } -#ifdef CONFIG_PM -void musb_platform_save_context(struct musb *musb, - struct musb_context_registers *musb_context) +static int bfin_musb_suspend(struct musb *musb) { if (is_host_active(musb)) /* @@ -418,14 +416,16 @@ void musb_platform_save_context(struct musb *musb, * wakeup event. */ gpio_set_value(musb->config->gpio_vrsel, 0); + + return 0; } -void musb_platform_restore_context(struct musb *musb, - struct musb_context_registers *musb_context) +static int bfin_musb_resume(struct musb *musb) { bfin_musb_reg_init(musb); + + return 0; } -#endif static int bfin_musb_exit(struct musb *musb) { @@ -446,6 +446,9 @@ static const struct musb_platform_ops bfin_ops = { .set_mode = bfin_musb_set_mode, .try_idle = bfin_musb_try_idle, + .suspend = bfin_musb_suspend, + .resume = bfin_musb_resume, + .vbus_status = bfin_musb_vbus_status, .set_vbus = bfin_musb_set_vbus, }; diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 6078eece74c7..4e048e3c3629 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2307,7 +2307,7 @@ void musb_save_context(struct musb *musb) } } - musb_platform_save_context(musb, &musb->context); + musb_platform_suspend(musb); } void musb_restore_context(struct musb *musb) @@ -2317,7 +2317,7 @@ void musb_restore_context(struct musb *musb) void __iomem *ep_target_regs; void __iomem *epio; - musb_platform_restore_context(musb, &musb->context); + musb_platform_resume(musb); if (is_host_enabled(musb)) { musb_writew(musb_base, MUSB_FRAME, musb->context.frame); diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 1e538675ab86..f8efd543c5f2 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -603,20 +603,6 @@ extern irqreturn_t musb_interrupt(struct musb *); extern void musb_hnp_stop(struct musb *musb); -#ifdef CONFIG_PM -#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ - defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_BLACKFIN) -extern void musb_platform_save_context(struct musb *musb, - struct musb_context_registers *musb_context); -extern void musb_platform_restore_context(struct musb *musb, - struct musb_context_registers *musb_context); -#else -#define musb_platform_save_context(m, x) do {} while (0) -#define musb_platform_restore_context(m, x) do {} while (0) -#endif - -#endif - static inline void musb_platform_set_vbus(struct musb *musb, int is_on) { if (musb->ops->set_vbus) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index fa3154b03044..2659667a1994 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -258,21 +258,17 @@ static int omap2430_musb_init(struct musb *musb) return 0; } -#ifdef CONFIG_PM -void musb_platform_save_context(struct musb *musb, - struct musb_context_registers *musb_context) +static void omap2430_save_context(struct musb *musb) { - musb_context->otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG); - musb_context->otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY); + musb->context.otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG); + musb->context.otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY); } -void musb_platform_restore_context(struct musb *musb, - struct musb_context_registers *musb_context) +static void omap2430_restore_context(struct musb *musb) { - musb_writel(musb->mregs, OTG_SYSCONFIG, musb_context->otg_sysconfig); - musb_writel(musb->mregs, OTG_FORCESTDBY, musb_context->otg_forcestandby); + musb_writel(musb->mregs, OTG_SYSCONFIG, musb->context.otg_sysconfig); + musb_writel(musb->mregs, OTG_FORCESTDBY, musb->context.otg_forcestandby); } -#endif static int omap2430_musb_suspend(struct musb *musb) { @@ -287,6 +283,8 @@ static int omap2430_musb_suspend(struct musb *musb) l |= ENABLEWAKEUP; /* enable wakeup */ musb_writel(musb->mregs, OTG_SYSCONFIG, l); + omap2430_save_context(musb); + otg_set_suspend(musb->xceiv, 1); return 0; @@ -298,6 +296,8 @@ static int omap2430_musb_resume(struct musb *musb) otg_set_suspend(musb->xceiv, 0); + omap2430_restore_context(musb); + l = musb_readl(musb->mregs, OTG_SYSCONFIG); l &= ~ENABLEWAKEUP; /* disable wakeup */ musb_writel(musb->mregs, OTG_SYSCONFIG, l); -- cgit v1.2.2 From 3c8a5fcc051c05cfdd8e3f0d37ba3c183d509cb9 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 12:28:39 +0200 Subject: usb: musb: mark musb_save/restore_context static those aren't used outside musb_core.c, so mark them as static. Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 4e048e3c3629..437a4c8c0128 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2242,7 +2242,7 @@ static int __exit musb_remove(struct platform_device *pdev) #ifdef CONFIG_PM -void musb_save_context(struct musb *musb) +static void musb_save_context(struct musb *musb) { int i; void __iomem *musb_base = musb->mregs; @@ -2310,7 +2310,7 @@ void musb_save_context(struct musb *musb) musb_platform_suspend(musb); } -void musb_restore_context(struct musb *musb) +static void musb_restore_context(struct musb *musb) { int i; void __iomem *musb_base = musb->mregs; -- cgit v1.2.2 From e6326358a43a9ac23f6df69ed1f4707c0d1ac473 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 12:35:59 +0200 Subject: usb: musb: omap2430: drop the nops we don't need those nops, so drop them. Signed-off-by: Felipe Balbi --- drivers/usb/musb/omap2430.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 2659667a1994..ef0f7fe92f13 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -138,14 +138,6 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) mod_timer(&musb_idle_timer, timeout); } -static void omap2430_musb_enable(struct musb *musb) -{ -} - -static void omap2430_musb_disable(struct musb *musb) -{ -} - static void omap2430_musb_set_vbus(struct musb *musb, int is_on) { u8 devctl; @@ -325,9 +317,6 @@ static const struct musb_platform_ops omap2430_ops = { .suspend = omap2430_musb_suspend, .resume = omap2430_musb_resume, - .enable = omap2430_musb_enable, - .disable = omap2430_musb_disable, - .set_mode = omap2430_musb_set_mode, .try_idle = omap2430_musb_try_idle, -- cgit v1.2.2 From c20aebb92796cf54ae8171ad7f53a8fa7c61d2d8 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 12:44:40 +0200 Subject: usb: musb: omap2430: use dev_pm_ops structure instead of using musb_platform_suspend/resume, we can use dev_pm_ops and let the platform_device core handle when to call musb_core's suspend and glue layer's suspend. Signed-off-by: Felipe Balbi --- drivers/usb/musb/omap2430.c | 146 ++++++++++++++++++++++++++------------------ 1 file changed, 87 insertions(+), 59 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index ef0f7fe92f13..5939823990c9 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -42,6 +42,7 @@ struct omap2430_glue { struct platform_device *musb; struct clk *clk; }; +#define glue_to_musb(g) platform_get_drvdata(g->musb) static struct timer_list musb_idle_timer; @@ -176,8 +177,6 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) musb_readb(musb->mregs, MUSB_DEVCTL)); } -static int omap2430_musb_resume(struct musb *musb); - static int omap2430_musb_set_mode(struct musb *musb, u8 musb_mode) { u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); @@ -188,6 +187,33 @@ static int omap2430_musb_set_mode(struct musb *musb, u8 musb_mode) return 0; } +static inline void omap2430_low_level_exit(struct musb *musb) +{ + u32 l; + + /* in any role */ + l = musb_readl(musb->mregs, OTG_FORCESTDBY); + l |= ENABLEFORCE; /* enable MSTANDBY */ + musb_writel(musb->mregs, OTG_FORCESTDBY, l); + + l = musb_readl(musb->mregs, OTG_SYSCONFIG); + l |= ENABLEWAKEUP; /* enable wakeup */ + musb_writel(musb->mregs, OTG_SYSCONFIG, l); +} + +static inline void omap2430_low_level_init(struct musb *musb) +{ + u32 l; + + l = musb_readl(musb->mregs, OTG_SYSCONFIG); + l &= ~ENABLEWAKEUP; /* disable wakeup */ + musb_writel(musb->mregs, OTG_SYSCONFIG, l); + + l = musb_readl(musb->mregs, OTG_FORCESTDBY); + l &= ~ENABLEFORCE; /* disable MSTANDBY */ + musb_writel(musb->mregs, OTG_FORCESTDBY, l); +} + static int omap2430_musb_init(struct musb *musb) { u32 l; @@ -205,7 +231,7 @@ static int omap2430_musb_init(struct musb *musb) return -ENODEV; } - omap2430_musb_resume(musb); + omap2430_low_level_init(musb); l = musb_readl(musb->mregs, OTG_SYSCONFIG); l &= ~ENABLEWAKEUP; /* disable wakeup */ @@ -250,63 +276,12 @@ static int omap2430_musb_init(struct musb *musb) return 0; } -static void omap2430_save_context(struct musb *musb) -{ - musb->context.otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG); - musb->context.otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY); -} - -static void omap2430_restore_context(struct musb *musb) -{ - musb_writel(musb->mregs, OTG_SYSCONFIG, musb->context.otg_sysconfig); - musb_writel(musb->mregs, OTG_FORCESTDBY, musb->context.otg_forcestandby); -} - -static int omap2430_musb_suspend(struct musb *musb) -{ - u32 l; - - /* in any role */ - l = musb_readl(musb->mregs, OTG_FORCESTDBY); - l |= ENABLEFORCE; /* enable MSTANDBY */ - musb_writel(musb->mregs, OTG_FORCESTDBY, l); - - l = musb_readl(musb->mregs, OTG_SYSCONFIG); - l |= ENABLEWAKEUP; /* enable wakeup */ - musb_writel(musb->mregs, OTG_SYSCONFIG, l); - - omap2430_save_context(musb); - - otg_set_suspend(musb->xceiv, 1); - - return 0; -} - -static int omap2430_musb_resume(struct musb *musb) -{ - u32 l; - - otg_set_suspend(musb->xceiv, 0); - - omap2430_restore_context(musb); - - l = musb_readl(musb->mregs, OTG_SYSCONFIG); - l &= ~ENABLEWAKEUP; /* disable wakeup */ - musb_writel(musb->mregs, OTG_SYSCONFIG, l); - - l = musb_readl(musb->mregs, OTG_FORCESTDBY); - l &= ~ENABLEFORCE; /* disable MSTANDBY */ - musb_writel(musb->mregs, OTG_FORCESTDBY, l); - - return 0; -} - static int omap2430_musb_exit(struct musb *musb) { - omap2430_musb_suspend(musb); - + omap2430_low_level_exit(musb); otg_put_transceiver(musb->xceiv); + return 0; } @@ -314,9 +289,6 @@ static const struct musb_platform_ops omap2430_ops = { .init = omap2430_musb_init, .exit = omap2430_musb_exit, - .suspend = omap2430_musb_suspend, - .resume = omap2430_musb_resume, - .set_mode = omap2430_musb_set_mode, .try_idle = omap2430_musb_try_idle, @@ -421,10 +393,66 @@ static int __exit omap2430_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static void omap2430_save_context(struct musb *musb) +{ + musb->context.otg_sysconfig = musb_readl(musb->mregs, OTG_SYSCONFIG); + musb->context.otg_forcestandby = musb_readl(musb->mregs, OTG_FORCESTDBY); +} + +static void omap2430_restore_context(struct musb *musb) +{ + musb_writel(musb->mregs, OTG_SYSCONFIG, musb->context.otg_sysconfig); + musb_writel(musb->mregs, OTG_FORCESTDBY, musb->context.otg_forcestandby); +} + +static int omap2430_suspend(struct device *dev) +{ + struct omap2430_glue *glue = dev_get_drvdata(dev); + struct musb *musb = glue_to_musb(glue); + + omap2430_low_level_exit(musb); + otg_set_suspend(musb->xceiv, 1); + omap2430_save_context(musb); + clk_disable(glue->clk); + + return 0; +} + +static int omap2430_resume(struct device *dev) +{ + struct omap2430_glue *glue = dev_get_drvdata(dev); + struct musb *musb = glue_to_musb(glue); + int ret; + + ret = clk_enable(glue->clk); + if (ret) { + dev_err(dev, "faled to enable clock\n"); + return ret; + } + + omap2430_low_level_init(musb); + omap2430_restore_context(musb); + otg_set_suspend(musb->xceiv, 0); + + return 0; +} + +static struct dev_pm_ops omap2430_pm_ops = { + .suspend = omap2430_suspend, + .resume = omap2430_resume, +}; + +#define DEV_PM_OPS (&omap2430_pm_ops) +#else +#define DEV_PM_OPS NULL +#endif + static struct platform_driver omap2430_driver = { .remove = __exit_p(omap2430_remove), .driver = { .name = "musb-omap2430", + .pm = DEV_PM_OPS, }, }; -- cgit v1.2.2 From 6f783e287c074afe1e9cf3f32ded9948e184b45e Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 12:53:22 +0200 Subject: usb: musb: am35x: usb dev_pm_ops structure instead of using musb_platform_suspend_resume, we can use dev_pm_ops and let platform_device core handle when to call musb_core's suspend and glue layer's suspend. Signed-off-by: Felipe Balbi --- drivers/usb/musb/am35x.c | 62 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 17 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index eacf1e09b495..fdc7c8878f8b 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -88,6 +88,7 @@ struct am35x_glue { struct clk *phy_clk; struct clk *clk; }; +#define glue_to_musb(g) platform_get_drvdata(g->musb) static inline void phy_on(void) { @@ -462,20 +463,6 @@ static int am35x_musb_exit(struct musb *musb) return 0; } -static int am35x_musb_suspend(struct musb *musb) -{ - phy_off(); - - return 0; -} - -static int am35x_musb_resume(struct musb *musb) -{ - phy_on(); - - return 0; -} - /* AM35x supports only 32bit read operation */ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) { @@ -516,9 +503,6 @@ static const struct musb_platform_ops am35x_ops = { .set_mode = am35x_musb_set_mode, .try_idle = am35x_musb_try_idle, - .suspend = am35x_musb_suspend, - .resume = am35x_musb_resume, - .set_vbus = am35x_musb_set_vbus, }; @@ -644,10 +628,54 @@ static int __exit am35x_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int am35x_suspend(struct device *dev) +{ + struct am35x_glue *glue = dev_get_drvdata(dev); + + phy_off(); + clk_disable(glue->phy_clk); + clk_disable(glue->clk); + + return 0; +} + +static int am35x_resume(struct device *dev) +{ + struct am35x_glue *glue = dev_get_drvdata(dev); + int ret; + + phy_on(); + ret = clk_enable(glue->phy_clk); + if (ret) { + dev_err(dev, "failed to enable PHY clock\n"); + return ret; + } + + ret = clk_enable(glue->clk); + if (ret) { + dev_err(dev, "failed to enable clock\n"); + return ret; + } + + return 0; +} + +static struct dev_pm_ops am35x_pm_ops = { + .suspend = am35x_suspend, + .resume = am35x_resume, +}; + +#define DEV_PM_OPS &am35x_pm_ops +#else +#define DEV_PM_OPS NULL +#endif + static struct platform_driver am35x_driver = { .remove = __exit_p(am35x_remove), .driver = { .name = "musb-am35x", + .pm = DEV_PM_OPS, }, }; -- cgit v1.2.2 From fcd22e3b1f12e026dfefca20c97ff550a0e11b2b Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 13:13:09 +0200 Subject: usb: musb: blackfin: usb dev_pm_ops structure instead of using musb_platform_suspend_resume, we can use dev_pm_ops and let platform_device core handle when to call musb_core's suspend and glue layer's suspend. Signed-off-by: Felipe Balbi --- drivers/usb/musb/blackfin.c | 64 ++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 24 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 8c9c5fc3a6ca..df0e906b1850 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -27,6 +27,7 @@ struct bfin_glue { struct device *dev; struct platform_device *musb; }; +#define glue_to_musb(g) platform_get_drvdata(g->musb) /* * Load an endpoint's FIFO @@ -406,27 +407,6 @@ static int bfin_musb_init(struct musb *musb) return 0; } -static int bfin_musb_suspend(struct musb *musb) -{ - if (is_host_active(musb)) - /* - * During hibernate gpio_vrsel will change from high to low - * low which will generate wakeup event resume the system - * immediately. Set it to 0 before hibernate to avoid this - * wakeup event. - */ - gpio_set_value(musb->config->gpio_vrsel, 0); - - return 0; -} - -static int bfin_musb_resume(struct musb *musb) -{ - bfin_musb_reg_init(musb); - - return 0; -} - static int bfin_musb_exit(struct musb *musb) { gpio_free(musb->config->gpio_vrsel); @@ -446,9 +426,6 @@ static const struct musb_platform_ops bfin_ops = { .set_mode = bfin_musb_set_mode, .try_idle = bfin_musb_try_idle, - .suspend = bfin_musb_suspend, - .resume = bfin_musb_resume, - .vbus_status = bfin_musb_vbus_status, .set_vbus = bfin_musb_set_vbus, }; @@ -528,10 +505,49 @@ static int __exit bfin_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int bfin_suspend(struct device *dev) +{ + struct bfin_glue *glue = dev_get_drvdata(dev); + struct musb *musb = glue_to_musb(glue); + + if (is_host_active(musb)) + /* + * During hibernate gpio_vrsel will change from high to low + * low which will generate wakeup event resume the system + * immediately. Set it to 0 before hibernate to avoid this + * wakeup event. + */ + gpio_set_value(musb->config->gpio_vrsel, 0); + + return 0; +} + +static int bfin_resume(struct device *dev) +{ + struct bfin_glue *glue = dev_get_drvdata(dev); + struct musb *musb = glue_to_musb(glue); + + bfin_musb_reg_init(musb); + + return 0; +} + +static struct dev_pm_ops bfin_pm_ops = { + .suspend = bfin_suspend, + .resume = bfin_resume, +}; + +#define DEV_PM_OPS &bfin_pm_op, +#else +#define DEV_PM_OPS NULL +#endif + static struct platform_driver bfin_driver = { .remove = __exit_p(bfin_remove), .driver = { .name = "musb-bfin", + .pm = DEV_PM_OPS, }, }; -- cgit v1.2.2 From 784173723e2fd23332af948a90612950964cd140 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 13:17:53 +0200 Subject: usb: musb: drop musb_platform_suspend/resume all glue layers are now fully moved to the new setup. We are now using dev_pm_ops to implement suspend/resume functionality and thus, musb_platform_suspend/resume has become deprecated and useless. This patch drops those function pointers and its uses. Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.c | 4 ---- drivers/usb/musb/musb_core.h | 21 --------------------- 2 files changed, 25 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 437a4c8c0128..e24bb41df1dc 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2306,8 +2306,6 @@ static void musb_save_context(struct musb *musb) musb_read_rxhubport(musb_base, i); } } - - musb_platform_suspend(musb); } static void musb_restore_context(struct musb *musb) @@ -2317,8 +2315,6 @@ static void musb_restore_context(struct musb *musb) void __iomem *ep_target_regs; void __iomem *epio; - musb_platform_resume(musb); - if (is_host_enabled(musb)) { musb_writew(musb_base, MUSB_FRAME, musb->context.frame); musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index f8efd543c5f2..9a3c71fce2b4 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -257,8 +257,6 @@ enum musb_g_ep0_state { * struct musb_platform_ops - Operations passed to musb_core by HW glue layer * @init: turns on clocks, sets up platform-specific registers, etc * @exit: undoes @init - * @suspend: platform-specific suspend, e.g. context save - * @resume: platform-specific resume, e.g. context restore * @set_mode: forcefully changes operating mode * @try_ilde: tries to idle the IP * @vbus_status: returns vbus status if possible @@ -268,9 +266,6 @@ struct musb_platform_ops { int (*init)(struct musb *musb); int (*exit)(struct musb *musb); - int (*suspend)(struct musb *musb); - int (*resume)(struct musb *musb); - void (*enable)(struct musb *musb); void (*disable)(struct musb *musb); @@ -660,20 +655,4 @@ static inline int musb_platform_exit(struct musb *musb) return musb->ops->exit(musb); } -static inline int musb_platform_suspend(struct musb *musb) -{ - if (!musb->ops->suspend) - return 0; - - return musb->ops->suspend(musb); -} - -static inline int musb_platform_resume(struct musb *musb) -{ - if (!musb->ops->resume) - return 0; - - return musb->ops->resume(musb); -} - #endif /* __MUSB_CORE_H__ */ -- cgit v1.2.2 From 92b48df24eec49ed1eb0ec9c5f6165d8282153ea Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 2 Dec 2010 14:30:06 +0200 Subject: usb: musb: drop board_set_vbus that's not used anymore. So let's drop it. Signed-off-by: Felipe Balbi --- drivers/usb/musb/am35x.c | 2 -- drivers/usb/musb/blackfin.c | 1 - drivers/usb/musb/da8xx.c | 2 -- drivers/usb/musb/davinci.c | 1 - drivers/usb/musb/musb_core.c | 1 - drivers/usb/musb/musb_core.h | 5 ----- drivers/usb/musb/omap2430.c | 3 --- 7 files changed, 15 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index fdc7c8878f8b..62e65f0a7284 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -421,8 +421,6 @@ static int am35x_musb_init(struct musb *musb) if (is_host_enabled(musb)) setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); - musb->board_set_vbus = am35x_musb_set_vbus; - /* Global reset */ sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index df0e906b1850..e72f762d214d 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -395,7 +395,6 @@ static int bfin_musb_init(struct musb *musb) bfin_musb_reg_init(musb); if (is_host_enabled(musb)) { - musb->board_set_vbus = bfin_musb_set_vbus; setup_timer(&musb_conn_timer, musb_conn_timer_handler, (unsigned long) musb); } diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 387f4a75706f..69a0da3c8f09 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -437,8 +437,6 @@ static int da8xx_musb_init(struct musb *musb) if (is_host_enabled(musb)) setup_timer(&otg_workaround, otg_timer, (unsigned long)musb); - musb->board_set_vbus = da8xx_musb_set_vbus; - /* Reset the controller */ musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index de67480d4f19..e6de097fb7e8 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -404,7 +404,6 @@ static int davinci_musb_init(struct musb *musb) if (is_host_enabled(musb)) setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); - musb->board_set_vbus = davinci_musb_set_vbus; davinci_musb_source_power(musb, 0, 1); /* dm355 EVM swaps D+/D- for signal integrity, and diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index e24bb41df1dc..325d7acafdf9 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2000,7 +2000,6 @@ bad_config: * - may initialize an integrated tranceiver * - initializes musb->xceiv, usually by otg_get_transceiver() * - stops powering VBUS - * - assigns musb->board_set_vbus if host mode is enabled * * There are various transciever configurations. Blackfin, * DaVinci, TUSB60x0, and others integrate them. OMAP3 uses diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 9a3c71fce2b4..b9ea563d1c8e 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -412,11 +412,6 @@ struct musb { struct timer_list otg_timer; #endif - /* called with IRQs blocked; ON/nonzero implies starting a session, - * and waiting at least a_wait_vrise_tmout. - */ - void (*board_set_vbus)(struct musb *, int is_on); - struct dma_controller *dma_controller; struct device *controller; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 5939823990c9..0a7e6824eae8 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -268,9 +268,6 @@ static int omap2430_musb_init(struct musb *musb) musb_readl(musb->mregs, OTG_INTERFSEL), musb_readl(musb->mregs, OTG_SIMENABLE)); - if (is_host_enabled(musb)) - musb->board_set_vbus = omap2430_musb_set_vbus; - setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); return 0; -- cgit v1.2.2 From a9c037832e9624e240c5019d0e01e9352e8f638d Mon Sep 17 00:00:00 2001 From: Ajay Kumar Gupta Date: Tue, 7 Dec 2010 18:57:45 +0530 Subject: musb: am35x: fix compile error due to control apis commit 4814ced5116e3b73dc4f63eec84999739fc8ed11 (OMAP: control: move plat-omap/control.h to mach-omap2/control.h) moved to another location, preventing drivers from accessing it, so we need to pass function pointers from arch code to be able to talk to internal PHY on AM35x. Signed-off-by: Ajay Kumar Gupta Signed-off-by: Felipe Balbi --- drivers/usb/musb/am35x.c | 130 ++++++++++++++++------------------------------- 1 file changed, 45 insertions(+), 85 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 62e65f0a7284..d5a3da37c90c 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -32,7 +32,6 @@ #include #include -#include #include #include "musb_core.h" @@ -90,47 +89,6 @@ struct am35x_glue { }; #define glue_to_musb(g) platform_get_drvdata(g->musb) -static inline void phy_on(void) -{ - unsigned long timeout = jiffies + msecs_to_jiffies(100); - u32 devconf2; - - /* - * Start the on-chip PHY and its PLL. - */ - devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); - - devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN); - devconf2 |= CONF2_PHY_PLLON; - - omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); - - DBG(1, "Waiting for PHY clock good...\n"); - while (!(omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2) - & CONF2_PHYCLKGD)) { - cpu_relax(); - - if (time_after(jiffies, timeout)) { - DBG(1, "musb PHY clock good timed out\n"); - break; - } - } -} - -static inline void phy_off(void) -{ - u32 devconf2; - - /* - * Power down the on-chip PHY. - */ - devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); - - devconf2 &= ~CONF2_PHY_PLLON; - devconf2 |= CONF2_PHYPWRDN | CONF2_OTGPWRDN; - omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); -} - /* * am35x_musb_enable - enable interrupts */ @@ -265,9 +223,12 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) { struct musb *musb = hci; void __iomem *reg_base = musb->ctrl_base; + struct device *dev = musb->controller; + struct musb_hdrc_platform_data *plat = dev->platform_data; + struct omap_musb_board_data *data = plat->board_data; unsigned long flags; irqreturn_t ret = IRQ_NONE; - u32 epintr, usbintr, lvl_intr; + u32 epintr, usbintr; spin_lock_irqsave(&musb->lock, flags); @@ -356,9 +317,8 @@ eoi: /* EOI needs to be written for the IRQ to be re-asserted. */ if (ret == IRQ_HANDLED || epintr || usbintr) { /* clear level interrupt */ - lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); - lvl_intr |= AM35XX_USBOTGSS_INT_CLR; - omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR); + if (data->clear_irq) + data->clear_irq(); /* write EOI */ musb_writel(reg_base, USB_END_OF_INTR_REG, 0); } @@ -374,37 +334,26 @@ eoi: static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode) { - u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2); + struct device *dev = musb->controller; + struct musb_hdrc_platform_data *plat = dev->platform_data; + struct omap_musb_board_data *data = plat->board_data; + int retval = 0; - devconf2 &= ~CONF2_OTGMODE; - switch (musb_mode) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD - case MUSB_HOST: /* Force VBUS valid, ID = 0 */ - devconf2 |= CONF2_FORCE_HOST; - break; -#endif -#ifdef CONFIG_USB_GADGET_MUSB_HDRC - case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */ - devconf2 |= CONF2_FORCE_DEVICE; - break; -#endif -#ifdef CONFIG_USB_MUSB_OTG - case MUSB_OTG: /* Don't override the VBUS/ID comparators */ - devconf2 |= CONF2_NO_OVERRIDE; - break; -#endif - default: - DBG(2, "Trying to set unsupported mode %u\n", musb_mode); - } + if (data->set_mode) + data->set_mode(musb_mode); + else + retval = -EIO; - omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); - return 0; + return retval; } static int am35x_musb_init(struct musb *musb) { + struct device *dev = musb->controller; + struct musb_hdrc_platform_data *plat = dev->platform_data; + struct omap_musb_board_data *data = plat->board_data; void __iomem *reg_base = musb->ctrl_base; - u32 rev, lvl_intr, sw_reset; + u32 rev; musb->mregs += USB_MENTOR_CORE_OFFSET; @@ -421,39 +370,40 @@ static int am35x_musb_init(struct musb *musb) if (is_host_enabled(musb)) setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); - /* Global reset */ - sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); - - sw_reset |= AM35XX_USBOTGSS_SW_RST; - omap_ctrl_writel(sw_reset, AM35XX_CONTROL_IP_SW_RESET); - - sw_reset &= ~AM35XX_USBOTGSS_SW_RST; - omap_ctrl_writel(sw_reset, AM35XX_CONTROL_IP_SW_RESET); + /* Reset the musb */ + if (data->reset) + data->reset(); /* Reset the controller */ musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK); /* Start the on-chip PHY and its PLL. */ - phy_on(); + if (data->set_phy_power) + data->set_phy_power(1); msleep(5); musb->isr = am35x_musb_interrupt; /* clear level interrupt */ - lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); - lvl_intr |= AM35XX_USBOTGSS_INT_CLR; - omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR); + if (data->clear_irq) + data->clear_irq(); return 0; } static int am35x_musb_exit(struct musb *musb) { + struct device *dev = musb->controller; + struct musb_hdrc_platform_data *plat = dev->platform_data; + struct omap_musb_board_data *data = plat->board_data; + if (is_host_enabled(musb)) del_timer_sync(&otg_workaround); - phy_off(); + /* Shutdown the on-chip PHY and its PLL. */ + if (data->set_phy_power) + data->set_phy_power(0); otg_put_transceiver(musb->xceiv); usb_nop_xceiv_unregister(); @@ -630,8 +580,13 @@ static int __exit am35x_remove(struct platform_device *pdev) static int am35x_suspend(struct device *dev) { struct am35x_glue *glue = dev_get_drvdata(dev); + struct musb_hdrc_platform_data *plat = dev->platform_data; + struct omap_musb_board_data *data = plat->board_data; + + /* Shutdown the on-chip PHY and its PLL. */ + if (data->set_phy_power) + data->set_phy_power(0); - phy_off(); clk_disable(glue->phy_clk); clk_disable(glue->clk); @@ -641,9 +596,14 @@ static int am35x_suspend(struct device *dev) static int am35x_resume(struct device *dev) { struct am35x_glue *glue = dev_get_drvdata(dev); + struct musb_hdrc_platform_data *plat = dev->platform_data; + struct omap_musb_board_data *data = plat->board_data; int ret; - phy_on(); + /* Start the on-chip PHY and its PLL. */ + if (data->set_phy_power) + data->set_phy_power(1); + ret = clk_enable(glue->phy_clk); if (ret) { dev_err(dev, "failed to enable PHY clock\n"); -- cgit v1.2.2 From 4bc36fd31b07054bdf7378cca7162c10598f3eff Mon Sep 17 00:00:00 2001 From: Mian Yousaf Kaukab Date: Thu, 9 Dec 2010 13:05:01 +0100 Subject: usb: musb: add support for ux500 platform Initial support for u8500 and u5500 platform. Signed-off-by: Mian Yousaf Kaukab Acked-by: Linus Walleij Signed-off-by: Felipe Balbi --- drivers/usb/musb/Kconfig | 4 + drivers/usb/musb/Makefile | 1 + drivers/usb/musb/musb_core.c | 5 +- drivers/usb/musb/ux500.c | 216 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/musb/ux500.c (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 03a42901922c..19145f6166fe 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -60,6 +60,10 @@ config USB_MUSB_BLACKFIN bool "Blackfin" depends on (BF54x && !BF544) || (BF52x && ! BF522 && !BF523) +config USB_MUSB_UX500 + bool "U8500 and U5500" + depends on (ARCH_U8500 && AB8500_USB) || (ARCH_U5500) + endchoice choice diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index 61f46affcf7a..74df5284894f 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_USB_MUSB_TUSB6010) += tusb6010.o obj-$(CONFIG_USB_MUSB_DAVINCI) += davinci.o obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o +obj-$(CONFIG_USB_MUSB_UX500) += ux500.o # the kconfig must guarantee that only one of the # possible I/O schemes will be enabled at a time ... diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 325d7acafdf9..a4e3f872c730 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1069,6 +1069,8 @@ static void musb_shutdown(struct platform_device *pdev) #if defined(CONFIG_USB_MUSB_TUSB6010) || defined(CONFIG_USB_MUSB_OMAP2PLUS) \ || defined(CONFIG_USB_MUSB_AM35X) static ushort __initdata fifo_mode = 4; +#elif defined(CONFIG_USB_MUSB_UX500) +static ushort __initdata fifo_mode = 5; #else static ushort __initdata fifo_mode = 2; #endif @@ -1539,7 +1541,8 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) /*-------------------------------------------------------------------------*/ #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430) || \ - defined(CONFIG_ARCH_OMAP4) + defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_U8500) || \ + defined(CONFIG_ARCH_U5500) static irqreturn_t generic_interrupt(int irq, void *__hci) { diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c new file mode 100644 index 000000000000..d6384e4aeef9 --- /dev/null +++ b/drivers/usb/musb/ux500.c @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2010 ST-Ericsson AB + * Mian Yousaf Kaukab + * + * Based on omap2430.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include "musb_core.h" + +struct ux500_glue { + struct device *dev; + struct platform_device *musb; + struct clk *clk; +}; +#define glue_to_musb(g) platform_get_drvdata(g->musb) + +static int ux500_musb_init(struct musb *musb) +{ + musb->xceiv = otg_get_transceiver(); + if (!musb->xceiv) { + pr_err("HS USB OTG: no transceiver configured\n"); + return -ENODEV; + } + + return 0; +} + +static int ux500_musb_exit(struct musb *musb) +{ + otg_put_transceiver(musb->xceiv); + + return 0; +} + +static const struct musb_platform_ops ux500_ops = { + .init = ux500_musb_init, + .exit = ux500_musb_exit, +}; + +static int __init ux500_probe(struct platform_device *pdev) +{ + struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; + struct platform_device *musb; + struct ux500_glue *glue; + struct clk *clk; + + int ret = -ENOMEM; + + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + dev_err(&pdev->dev, "failed to allocate glue context\n"); + goto err0; + } + + musb = platform_device_alloc("musb-hdrc", -1); + if (!musb) { + dev_err(&pdev->dev, "failed to allocate musb device\n"); + goto err1; + } + + clk = clk_get(&pdev->dev, "usb"); + if (IS_ERR(clk)) { + dev_err(&pdev->dev, "failed to get clock\n"); + ret = PTR_ERR(clk); + goto err2; + } + + ret = clk_enable(clk); + if (ret) { + dev_err(&pdev->dev, "failed to enable clock\n"); + goto err3; + } + + musb->dev.parent = &pdev->dev; + + glue->dev = &pdev->dev; + glue->musb = musb; + glue->clk = clk; + + pdata->platform_ops = &ux500_ops; + + platform_set_drvdata(pdev, glue); + + ret = platform_device_add_resources(musb, pdev->resource, + pdev->num_resources); + if (ret) { + dev_err(&pdev->dev, "failed to add resources\n"); + goto err4; + } + + ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); + if (ret) { + dev_err(&pdev->dev, "failed to add platform_data\n"); + goto err4; + } + + ret = platform_device_add(musb); + if (ret) { + dev_err(&pdev->dev, "failed to register musb device\n"); + goto err4; + } + + return 0; + +err4: + clk_disable(clk); + +err3: + clk_put(clk); + +err2: + platform_device_put(musb); + +err1: + kfree(glue); + +err0: + return ret; +} + +static int __exit ux500_remove(struct platform_device *pdev) +{ + struct ux500_glue *glue = platform_get_drvdata(pdev); + + platform_device_del(glue->musb); + platform_device_put(glue->musb); + clk_disable(glue->clk); + clk_put(glue->clk); + kfree(glue); + + return 0; +} + +#ifdef CONFIG_PM +static int ux500_suspend(struct device *dev) +{ + struct ux500_glue *glue = dev_get_drvdata(dev); + struct musb *musb = glue_to_musb(glue); + + otg_set_suspend(musb->xceiv, 1); + clk_disable(glue->clk); + + return 0; +} + +static int ux500_resume(struct device *dev) +{ + struct ux500_glue *glue = dev_get_drvdata(dev); + struct musb *musb = glue_to_musb(glue); + int ret; + + ret = clk_enable(glue->clk); + if (ret) { + dev_err(dev, "failed to enable clock\n"); + return ret; + } + + otg_set_suspend(musb->xceiv, 0); + + return 0; +} + +static const struct dev_pm_ops ux500_pm_ops = { + .suspend = ux500_suspend, + .resume = ux500_resume, +}; + +#define DEV_PM_OPS (&ux500_pm_ops) +#else +#define DEV_PM_OPS NULL +#endif + +static struct platform_driver ux500_driver = { + .remove = __exit_p(ux500_remove), + .driver = { + .name = "musb-ux500", + .pm = DEV_PM_OPS, + }, +}; + +MODULE_DESCRIPTION("UX500 MUSB Glue Layer"); +MODULE_AUTHOR("Mian Yousaf Kaukab "); +MODULE_LICENSE("GPL v2"); + +static int __init ux500_init(void) +{ + return platform_driver_probe(&ux500_driver, ux500_probe); +} +subsys_initcall(ux500_init); + +static void __exit ux500_exit(void) +{ + platform_driver_unregister(&ux500_driver); +} +module_exit(ux500_exit); -- cgit v1.2.2 From c33fad0c37481c4ba5c8b98cb62de3f4d95a44da Mon Sep 17 00:00:00 2001 From: Hema HK Date: Fri, 10 Dec 2010 17:58:20 +0530 Subject: usb: otg: Adding twl6030-usb transceiver driver for OMAP4430 Adding the twl6030-usb transceiver support for OMAP4 musb driver. OMAP4 supports 2 types of transceiver interface. 1. UTMI: The PHY is embedded within OMAP4. The transceiver functionality is split between the twl6030 PMIC chip and OMAP4430. The VBUS, ID pin sensing and OTG SRP generation part is integrated in TWL6030 and UTMI PHY functionality is embedded within the OMAP4430. There is no direct interactions between the MUSB controller and TWL6030 chip to communicate the session-valid, session-end and ID-GND events. It has to be done through a software by setting/resetting bits in one of the control module register of OMAP4430 which in turn toggles the appropriate signals to MUSB controller. The internal transceiver has functional clocks and powerdown bits to powerdown the PHY for power saving. Since there is no option available for having 2 transceiver drivers for one USB controller, internal PHY specific APIs are passed through plaform_data function pointers to use in the twl6030-usb transceiver driver. 2. ULPI interface is provided for off-chip transceivers. Signed-off-by: Hema HK Cc: Tony Lindgren Cc: David Brownell Signed-off-by: Felipe Balbi --- drivers/usb/otg/twl6030-usb.c | 493 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 493 insertions(+) create mode 100644 drivers/usb/otg/twl6030-usb.c (limited to 'drivers/usb') diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c new file mode 100644 index 000000000000..28f770103640 --- /dev/null +++ b/drivers/usb/otg/twl6030-usb.c @@ -0,0 +1,493 @@ +/* + * twl6030_usb - TWL6030 USB transceiver, talking to OMAP OTG driver. + * + * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Author: Hema HK + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* usb register definitions */ +#define USB_VENDOR_ID_LSB 0x00 +#define USB_VENDOR_ID_MSB 0x01 +#define USB_PRODUCT_ID_LSB 0x02 +#define USB_PRODUCT_ID_MSB 0x03 +#define USB_VBUS_CTRL_SET 0x04 +#define USB_VBUS_CTRL_CLR 0x05 +#define USB_ID_CTRL_SET 0x06 +#define USB_ID_CTRL_CLR 0x07 +#define USB_VBUS_INT_SRC 0x08 +#define USB_VBUS_INT_LATCH_SET 0x09 +#define USB_VBUS_INT_LATCH_CLR 0x0A +#define USB_VBUS_INT_EN_LO_SET 0x0B +#define USB_VBUS_INT_EN_LO_CLR 0x0C +#define USB_VBUS_INT_EN_HI_SET 0x0D +#define USB_VBUS_INT_EN_HI_CLR 0x0E +#define USB_ID_INT_SRC 0x0F +#define USB_ID_INT_LATCH_SET 0x10 +#define USB_ID_INT_LATCH_CLR 0x11 + +#define USB_ID_INT_EN_LO_SET 0x12 +#define USB_ID_INT_EN_LO_CLR 0x13 +#define USB_ID_INT_EN_HI_SET 0x14 +#define USB_ID_INT_EN_HI_CLR 0x15 +#define USB_OTG_ADP_CTRL 0x16 +#define USB_OTG_ADP_HIGH 0x17 +#define USB_OTG_ADP_LOW 0x18 +#define USB_OTG_ADP_RISE 0x19 +#define USB_OTG_REVISION 0x1A + +/* to be moved to LDO */ +#define TWL6030_MISC2 0xE5 +#define TWL6030_CFG_LDO_PD2 0xF5 +#define TWL6030_BACKUP_REG 0xFA + +#define STS_HW_CONDITIONS 0x21 + +/* In module TWL6030_MODULE_PM_MASTER */ +#define STS_HW_CONDITIONS 0x21 +#define STS_USB_ID BIT(2) + +/* In module TWL6030_MODULE_PM_RECEIVER */ +#define VUSB_CFG_TRANS 0x71 +#define VUSB_CFG_STATE 0x72 +#define VUSB_CFG_VOLTAGE 0x73 + +/* in module TWL6030_MODULE_MAIN_CHARGE */ + +#define CHARGERUSB_CTRL1 0x8 + +#define CONTROLLER_STAT1 0x03 +#define VBUS_DET BIT(2) + +struct twl6030_usb { + struct otg_transceiver otg; + struct device *dev; + + /* for vbus reporting with irqs disabled */ + spinlock_t lock; + + struct regulator *usb3v3; + + int irq1; + int irq2; + u8 linkstat; + u8 asleep; + bool irq_enabled; +}; + +#define xceiv_to_twl(x) container_of((x), struct twl6030_usb, otg); + +/*-------------------------------------------------------------------------*/ + +static inline int twl6030_writeb(struct twl6030_usb *twl, u8 module, + u8 data, u8 address) +{ + int ret = 0; + + ret = twl_i2c_write_u8(module, data, address); + if (ret < 0) + dev_err(twl->dev, + "Write[0x%x] Error %d\n", address, ret); + return ret; +} + +static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address) +{ + u8 data, ret = 0; + + ret = twl_i2c_read_u8(module, &data, address); + if (ret >= 0) + ret = data; + else + dev_err(twl->dev, + "readb[0x%x,0x%x] Error %d\n", + module, address, ret); + return ret; +} + +/*-------------------------------------------------------------------------*/ +static int twl6030_set_phy_clk(struct otg_transceiver *x, int on) +{ + struct twl6030_usb *twl; + struct device *dev; + struct twl4030_usb_data *pdata; + + twl = xceiv_to_twl(x); + dev = twl->dev; + pdata = dev->platform_data; + + pdata->phy_set_clock(twl->dev, on); + + return 0; +} + +static int twl6030_phy_init(struct otg_transceiver *x) +{ + u8 hw_state; + struct twl6030_usb *twl; + struct device *dev; + struct twl4030_usb_data *pdata; + + twl = xceiv_to_twl(x); + dev = twl->dev; + pdata = dev->platform_data; + + regulator_enable(twl->usb3v3); + + hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); + + if (hw_state & STS_USB_ID) + pdata->phy_power(twl->dev, 1, 1); + else + pdata->phy_power(twl->dev, 0, 1); + + return 0; +} + +static void twl6030_phy_shutdown(struct otg_transceiver *x) +{ + struct twl6030_usb *twl; + struct device *dev; + struct twl4030_usb_data *pdata; + + twl = xceiv_to_twl(x); + dev = twl->dev; + pdata = dev->platform_data; + pdata->phy_power(twl->dev, 0, 0); + regulator_disable(twl->usb3v3); +} + +static int twl6030_usb_ldo_init(struct twl6030_usb *twl) +{ + + /* Set to OTG_REV 1.3 and turn on the ID_WAKEUP_COMP */ + twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_BACKUP_REG); + + /* Program CFG_LDO_PD2 register and set VUSB bit */ + twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x1, TWL6030_CFG_LDO_PD2); + + /* Program MISC2 register and set bit VUSB_IN_VBAT */ + twl6030_writeb(twl, TWL6030_MODULE_ID0 , 0x10, TWL6030_MISC2); + + twl->usb3v3 = regulator_get(twl->dev, "vusb"); + if (IS_ERR(twl->usb3v3)) + return -ENODEV; + + regulator_enable(twl->usb3v3); + + /* Program the VUSB_CFG_TRANS for ACTIVE state. */ + twl6030_writeb(twl, TWL_MODULE_PM_RECEIVER, 0x3F, + VUSB_CFG_TRANS); + + /* Program the VUSB_CFG_STATE register to ON on all groups. */ + twl6030_writeb(twl, TWL_MODULE_PM_RECEIVER, 0xE1, + VUSB_CFG_STATE); + + /* Program the USB_VBUS_CTRL_SET and set VBUS_ACT_COMP bit */ + twl6030_writeb(twl, TWL_MODULE_USB, 0x4, USB_VBUS_CTRL_SET); + + /* + * Program the USB_ID_CTRL_SET register to enable GND drive + * and the ID comparators + */ + twl6030_writeb(twl, TWL_MODULE_USB, 0x14, USB_ID_CTRL_SET); + + return 0; +} + +static ssize_t twl6030_usb_vbus_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct twl6030_usb *twl = dev_get_drvdata(dev); + unsigned long flags; + int ret = -EINVAL; + + spin_lock_irqsave(&twl->lock, flags); + + switch (twl->linkstat) { + case USB_EVENT_VBUS: + ret = snprintf(buf, PAGE_SIZE, "vbus\n"); + break; + case USB_EVENT_ID: + ret = snprintf(buf, PAGE_SIZE, "id\n"); + break; + case USB_EVENT_NONE: + ret = snprintf(buf, PAGE_SIZE, "none\n"); + break; + default: + ret = snprintf(buf, PAGE_SIZE, "UNKNOWN\n"); + } + spin_unlock_irqrestore(&twl->lock, flags); + + return ret; +} +static DEVICE_ATTR(vbus, 0444, twl6030_usb_vbus_show, NULL); + +static irqreturn_t twl6030_usb_irq(int irq, void *_twl) +{ + struct twl6030_usb *twl = _twl; + int status; + u8 vbus_state, hw_state; + + hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); + + vbus_state = twl6030_readb(twl, TWL_MODULE_MAIN_CHARGE, + CONTROLLER_STAT1); + if (!(hw_state & STS_USB_ID)) { + if (vbus_state & VBUS_DET) { + status = USB_EVENT_VBUS; + twl->otg.default_a = false; + twl->otg.state = OTG_STATE_B_IDLE; + } else { + status = USB_EVENT_NONE; + } + if (status >= 0) { + twl->linkstat = status; + blocking_notifier_call_chain(&twl->otg.notifier, + status, twl->otg.gadget); + } + } + sysfs_notify(&twl->dev->kobj, NULL, "vbus"); + + return IRQ_HANDLED; +} + +static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl) +{ + struct twl6030_usb *twl = _twl; + int status = USB_EVENT_NONE; + u8 hw_state; + + hw_state = twl6030_readb(twl, TWL6030_MODULE_ID0, STS_HW_CONDITIONS); + + if (hw_state & STS_USB_ID) { + + twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, 0x1); + twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, + 0x10); + status = USB_EVENT_ID; + twl->otg.default_a = true; + twl->otg.state = OTG_STATE_A_IDLE; + blocking_notifier_call_chain(&twl->otg.notifier, status, + twl->otg.gadget); + } else { + twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, + 0x10); + twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, + 0x1); + } + twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_LATCH_CLR, status); + twl->linkstat = status; + + return IRQ_HANDLED; +} + +static int twl6030_set_peripheral(struct otg_transceiver *x, + struct usb_gadget *gadget) +{ + struct twl6030_usb *twl; + + if (!x) + return -ENODEV; + + twl = xceiv_to_twl(x); + twl->otg.gadget = gadget; + if (!gadget) + twl->otg.state = OTG_STATE_UNDEFINED; + + return 0; +} + +static int twl6030_enable_irq(struct otg_transceiver *x) +{ + struct twl6030_usb *twl = xceiv_to_twl(x); + + twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, 0x1); + twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C); + twl6030_interrupt_unmask(0x05, REG_INT_MSK_STS_C); + + twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK, + REG_INT_MSK_LINE_C); + twl6030_interrupt_unmask(TWL6030_CHARGER_CTRL_INT_MASK, + REG_INT_MSK_STS_C); + twl6030_usb_irq(twl->irq2, twl); + twl6030_usbotg_irq(twl->irq1, twl); + + return 0; +} + +static int twl6030_set_vbus(struct otg_transceiver *x, bool enabled) +{ + struct twl6030_usb *twl = xceiv_to_twl(x); + + /* + * Start driving VBUS. Set OPA_MODE bit in CHARGERUSB_CTRL1 + * register. This enables boost mode. + */ + if (enabled) + twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x40, + CHARGERUSB_CTRL1); + else + twl6030_writeb(twl, TWL_MODULE_MAIN_CHARGE , 0x00, + CHARGERUSB_CTRL1); + return 0; +} + +static int twl6030_set_host(struct otg_transceiver *x, struct usb_bus *host) +{ + struct twl6030_usb *twl; + + if (!x) + return -ENODEV; + + twl = xceiv_to_twl(x); + twl->otg.host = host; + if (!host) + twl->otg.state = OTG_STATE_UNDEFINED; + return 0; +} + +static int __devinit twl6030_usb_probe(struct platform_device *pdev) +{ + struct twl6030_usb *twl; + int status, err; + struct twl4030_usb_data *pdata; + struct device *dev = &pdev->dev; + pdata = dev->platform_data; + + twl = kzalloc(sizeof *twl, GFP_KERNEL); + if (!twl) + return -ENOMEM; + + twl->dev = &pdev->dev; + twl->irq1 = platform_get_irq(pdev, 0); + twl->irq2 = platform_get_irq(pdev, 1); + twl->otg.dev = twl->dev; + twl->otg.label = "twl6030"; + twl->otg.set_host = twl6030_set_host; + twl->otg.set_peripheral = twl6030_set_peripheral; + twl->otg.set_vbus = twl6030_set_vbus; + twl->otg.init = twl6030_phy_init; + twl->otg.shutdown = twl6030_phy_shutdown; + + /* init spinlock for workqueue */ + spin_lock_init(&twl->lock); + + err = twl6030_usb_ldo_init(twl); + if (err) { + dev_err(&pdev->dev, "ldo init failed\n"); + kfree(twl); + return err; + } + otg_set_transceiver(&twl->otg); + + platform_set_drvdata(pdev, twl); + if (device_create_file(&pdev->dev, &dev_attr_vbus)) + dev_warn(&pdev->dev, "could not create sysfs file\n"); + + BLOCKING_INIT_NOTIFIER_HEAD(&twl->otg.notifier); + + twl->irq_enabled = true; + status = request_threaded_irq(twl->irq1, NULL, twl6030_usbotg_irq, + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, + "twl6030_usb", twl); + if (status < 0) { + dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", + twl->irq1, status); + device_remove_file(twl->dev, &dev_attr_vbus); + kfree(twl); + return status; + } + + status = request_threaded_irq(twl->irq2, NULL, twl6030_usb_irq, + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, + "twl6030_usb", twl); + if (status < 0) { + dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", + twl->irq2, status); + free_irq(twl->irq1, twl); + device_remove_file(twl->dev, &dev_attr_vbus); + kfree(twl); + return status; + } + + pdata->phy_init(dev); + twl6030_enable_irq(&twl->otg); + dev_info(&pdev->dev, "Initialized TWL6030 USB module\n"); + + return 0; +} + +static int __exit twl6030_usb_remove(struct platform_device *pdev) +{ + struct twl6030_usb *twl = platform_get_drvdata(pdev); + + struct twl4030_usb_data *pdata; + struct device *dev = &pdev->dev; + pdata = dev->platform_data; + + twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, + REG_INT_MSK_LINE_C); + twl6030_interrupt_mask(TWL6030_USBOTG_INT_MASK, + REG_INT_MSK_STS_C); + free_irq(twl->irq1, twl); + free_irq(twl->irq2, twl); + regulator_put(twl->usb3v3); + pdata->phy_exit(twl->dev); + device_remove_file(twl->dev, &dev_attr_vbus); + kfree(twl); + + return 0; +} + +static struct platform_driver twl6030_usb_driver = { + .probe = twl6030_usb_probe, + .remove = __exit_p(twl6030_usb_remove), + .driver = { + .name = "twl6030_usb", + .owner = THIS_MODULE, + }, +}; + +static int __init twl6030_usb_init(void) +{ + return platform_driver_register(&twl6030_usb_driver); +} +subsys_initcall(twl6030_usb_init); + +static void __exit twl6030_usb_exit(void) +{ + platform_driver_unregister(&twl6030_usb_driver); +} +module_exit(twl6030_usb_exit); + +MODULE_ALIAS("platform:twl6030_usb"); +MODULE_AUTHOR("Hema HK "); +MODULE_DESCRIPTION("TWL6030 USB transceiver driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.2 From 6b296123cc1d958fe5045114f7ae0c1e19cbb29a Mon Sep 17 00:00:00 2001 From: Hema HK Date: Fri, 10 Dec 2010 18:08:48 +0530 Subject: usb: otg: Kconfig: Add Kconfig option for TWL6030 transceiver. Added the TWL6030-usb transceiver option in the Kconfig Signed-off-by: Hema HK Cc: David Brownell Signed-off-by: Felipe Balbi --- drivers/usb/otg/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index 5ce07528cd0c..e3ecc211fe5f 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig @@ -59,6 +59,18 @@ config TWL4030_USB This transceiver supports high and full speed devices plus, in host mode, low speed. +config TWL6030_USB + tristate "TWL6030 USB Transceiver Driver" + depends on TWL4030_CORE + select USB_OTG_UTILS + help + Enable this to support the USB OTG transceiver on TWL6030 + family chips. This TWL6030 transceiver has the VBUS and ID GND + and OTG SRP events capabilities. For all other transceiver functionality + UTMI PHY is embedded in OMAP4430. The internal PHY configurations APIs + are hooked to this driver through platform_data structure. + The definition of internal PHY APIs are in the mach-omap2 layer. + config NOP_USB_XCEIV tristate "NOP USB Transceiver Driver" select USB_OTG_UTILS -- cgit v1.2.2 From 4c42fbc99fc8656efc7d2b5e92be0d430ccefdc6 Mon Sep 17 00:00:00 2001 From: Hema HK Date: Fri, 10 Dec 2010 18:09:35 +0530 Subject: usb: musb: TWL6030: Selecting TWL6030_USB transceiver Selecting the twl6030-usb for OMAP4430SDP and OMAP4PANDA boards and adding OMAP4 internal phy code for compilation Signed-off-by: Hema HK Cc: Tony Lindgren Signed-off-by: Felipe Balbi --- drivers/usb/musb/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 19145f6166fe..4cbb7e4b368d 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -12,6 +12,7 @@ config USB_MUSB_HDRC depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)) select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) select TWL4030_USB if MACH_OMAP_3430SDP + select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA select USB_OTG_UTILS tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)' help -- cgit v1.2.2 From 221946d04aa9bd3cffd93e4876bcb2e616941df9 Mon Sep 17 00:00:00 2001 From: Hema HK Date: Fri, 10 Dec 2010 18:10:37 +0530 Subject: usb: otg: TWL6030: Add twl6030_usb file for compilation Add the twl6030_usb transceiver file for compilation. Signed-off-by: Hema HK Signed-off-by: Felipe Balbi --- drivers/usb/otg/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/usb') diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile index 66f1b83e4fa7..ff01f5fe0bd5 100644 --- a/drivers/usb/otg/Makefile +++ b/drivers/usb/otg/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_USB_OTG_UTILS) += otg.o obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o +obj-$(CONFIG_TWL6030_USB) += twl6030-usb.o obj-$(CONFIG_USB_LANGWELL_OTG) += langwell_otg.o obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o obj-$(CONFIG_USB_ULPI) += ulpi.o -- cgit v1.2.2 From 594632efbb9a4ac323cbf8dbf37c608d418ca8c1 Mon Sep 17 00:00:00 2001 From: Hema HK Date: Fri, 10 Dec 2010 18:10:51 +0530 Subject: usb: musb: Adding musb support for OMAP4430 OMAP4430 supports UTMI and ULPI types of transceiver interface. In UTMI mode: The PHY is embedded within OMAP4430. The transceiver functionality is split between the twl6030 PMIC chip and OMAP4430. The VBUS, ID pin sensing and OTG SRP generation part is integrated in TWL6030 and UTMI PHY functionality is embedded within the OMAP4430. There is no direct interactions between the MUSB controller and TWL6030 chip to communicate the session-valid, session-end and ID-GND events. It has to be done through a software by setting/resetting bits in one of the control module register of OMAP4430 which in turn toggles the appropriate signals to MUSB controller. musb driver is register for blocking notifications from the transceiver driver to get the event notifications for connect/disconnect and ID-GND. Based on these events call the transceiver init/shutdown function to configure the transceiver to toggle the VBUS valid, session end and ID_GND signals to musb and power on/off the internal PHY. For ID_GND event notifications, toggle the ID_GND signal and then wait for musb to be configured as "A" device, and then call the transceiver function to set the VBUS. In OTG mode and musb as a host, When the Micro A connector used, VBUS is turned on and session bit set. When the device is connected, enumeration goes through. When the device disconnected from the other end of the connector(ID is still grounded), link will detect the disconnect and end the session. When the device is connected back, there are no events generated in the TWL6030-usb, and link is already down. So the device is not detected. Removed the session bit disable code which will recognize the connect of the device. Limitation: In OTG host mode, if device is connected during boot, it does not get detected. If disconnect and connect it back or connect after boot only it works. Fix for this, I will submit seperate patch later. Signed-off-by: Hema HK Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.h | 1 + drivers/usb/musb/omap2430.c | 109 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 99 insertions(+), 11 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index b9ea563d1c8e..d0c236f8e191 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -411,6 +411,7 @@ struct musb { struct timer_list otg_timer; #endif + struct notifier_block nb; struct dma_controller *dma_controller; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 0a7e6824eae8..a3f12333fc41 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -57,12 +57,8 @@ static void musb_do_idle(unsigned long _musb) spin_lock_irqsave(&musb->lock, flags); - devctl = musb_readb(musb->mregs, MUSB_DEVCTL); - switch (musb->xceiv->state) { case OTG_STATE_A_WAIT_BCON: - devctl &= ~MUSB_DEVCTL_SESSION; - musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); devctl = musb_readb(musb->mregs, MUSB_DEVCTL); if (devctl & MUSB_DEVCTL_BDEVICE) { @@ -142,6 +138,8 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) static void omap2430_musb_set_vbus(struct musb *musb, int is_on) { u8 devctl; + unsigned long timeout = jiffies + msecs_to_jiffies(1000); + int ret = 1; /* HDRC controls CPEN, but beware current surges during device * connect. They can trigger transient overcurrent conditions * that must be ignored. @@ -150,12 +148,35 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) devctl = musb_readb(musb->mregs, MUSB_DEVCTL); if (is_on) { - musb->is_active = 1; - musb->xceiv->default_a = 1; - musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; - devctl |= MUSB_DEVCTL_SESSION; - - MUSB_HST_MODE(musb); + if (musb->xceiv->state == OTG_STATE_A_IDLE) { + /* start the session */ + devctl |= MUSB_DEVCTL_SESSION; + musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); + /* + * Wait for the musb to set as A device to enable the + * VBUS + */ + while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) { + + cpu_relax(); + + if (time_after(jiffies, timeout)) { + dev_err(musb->controller, + "configured as A device timeout"); + ret = -EINVAL; + break; + } + } + + if (ret && musb->xceiv->set_vbus) + otg_set_vbus(musb->xceiv, 1); + } else { + musb->is_active = 1; + musb->xceiv->default_a = 1; + musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; + devctl |= MUSB_DEVCTL_SESSION; + MUSB_HST_MODE(musb); + } } else { musb->is_active = 0; @@ -214,9 +235,64 @@ static inline void omap2430_low_level_init(struct musb *musb) musb_writel(musb->mregs, OTG_FORCESTDBY, l); } +/* blocking notifier support */ +static int musb_otg_notifications(struct notifier_block *nb, + unsigned long event, void *unused) +{ + struct musb *musb = container_of(nb, struct musb, nb); + struct device *dev = musb->controller; + struct musb_hdrc_platform_data *pdata = dev->platform_data; + struct omap_musb_board_data *data = pdata->board_data; + + switch (event) { + case USB_EVENT_ID: + DBG(4, "ID GND\n"); + + if (is_otg_enabled(musb)) { +#ifdef CONFIG_USB_GADGET_MUSB_HDRC + if (musb->gadget_driver) { + otg_init(musb->xceiv); + + if (data->interface_type == + MUSB_INTERFACE_UTMI) + omap2430_musb_set_vbus(musb, 1); + + } +#endif + } else { + otg_init(musb->xceiv); + if (data->interface_type == + MUSB_INTERFACE_UTMI) + omap2430_musb_set_vbus(musb, 1); + } + break; + + case USB_EVENT_VBUS: + DBG(4, "VBUS Connect\n"); + + otg_init(musb->xceiv); + break; + + case USB_EVENT_NONE: + DBG(4, "VBUS Disconnect\n"); + + if (data->interface_type == MUSB_INTERFACE_UTMI) { + if (musb->xceiv->set_vbus) + otg_set_vbus(musb->xceiv, 0); + } + otg_shutdown(musb->xceiv); + break; + default: + DBG(4, "ID float\n"); + return NOTIFY_DONE; + } + + return NOTIFY_OK; +} + static int omap2430_musb_init(struct musb *musb) { - u32 l; + u32 l, status = 0; struct device *dev = musb->controller; struct musb_hdrc_platform_data *plat = dev->platform_data; struct omap_musb_board_data *data = plat->board_data; @@ -268,6 +344,17 @@ static int omap2430_musb_init(struct musb *musb) musb_readl(musb->mregs, OTG_INTERFSEL), musb_readl(musb->mregs, OTG_SIMENABLE)); + musb->nb.notifier_call = musb_otg_notifications; + status = otg_register_notifier(musb->xceiv, &musb->nb); + + if (status) + DBG(1, "notification register failed\n"); + + /* check whether cable is already connected */ + if (musb->xceiv->state ==OTG_STATE_B_IDLE) + musb_otg_notifications(&musb->nb, 1, + musb->xceiv->gadget); + setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); return 0; -- cgit v1.2.2 From e4a2b3565fc7ac2d70361a36337be57a59d783da Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Fri, 10 Dec 2010 22:48:28 +0300 Subject: usb: musb: core: kill unneeded #include's musb_core.c #include's a bunch of ARM and DaVinci specific headers, goodness knows why -- it happily compiles without them... Signed-off-by: Sergei Shtylyov Signed-off-by: Felipe Balbi --- drivers/usb/musb/musb_core.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'drivers/usb') diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index a4e3f872c730..7816c0180430 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -99,19 +99,8 @@ #include #include -#ifdef CONFIG_ARM -#include -#include -#include -#endif - #include "musb_core.h" - -#ifdef CONFIG_ARCH_DAVINCI -#include "davinci.h" -#endif - #define TA_WAIT_BCON(m) max_t(int, (m)->a_wait_bcon, OTG_TIME_A_WAIT_BCON) -- cgit v1.2.2