提交 743411b3 编写于 作者: F Felipe Balbi

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: NFelipe Balbi <balbi@ti.com>
上级 3ca8abb8
...@@ -122,9 +122,9 @@ static inline void phy_off(void) ...@@ -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; void __iomem *reg_base = musb->ctrl_base;
u32 epmask; u32 epmask;
...@@ -143,9 +143,9 @@ void musb_platform_enable(struct musb *musb) ...@@ -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; void __iomem *reg_base = musb->ctrl_base;
...@@ -162,7 +162,7 @@ void musb_platform_disable(struct musb *musb) ...@@ -162,7 +162,7 @@ void musb_platform_disable(struct musb *musb)
#define portstate(stmt) #define portstate(stmt)
#endif #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)); WARN_ON(is_on && is_peripheral_active(musb));
} }
...@@ -221,7 +221,7 @@ static void otg_timer(unsigned long _musb) ...@@ -221,7 +221,7 @@ static void otg_timer(unsigned long _musb)
spin_unlock_irqrestore(&musb->lock, flags); 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; static unsigned long last_timer;
...@@ -251,7 +251,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) ...@@ -251,7 +251,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
mod_timer(&otg_workaround, 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; struct musb *musb = hci;
void __iomem *reg_base = musb->ctrl_base; void __iomem *reg_base = musb->ctrl_base;
...@@ -362,7 +362,7 @@ static irqreturn_t am35x_interrupt(int irq, void *hci) ...@@ -362,7 +362,7 @@ static irqreturn_t am35x_interrupt(int irq, void *hci)
return ret; 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); u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
...@@ -391,7 +391,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) ...@@ -391,7 +391,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
return 0; 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; void __iomem *reg_base = musb->ctrl_base;
u32 rev, lvl_intr, sw_reset; u32 rev, lvl_intr, sw_reset;
...@@ -427,7 +427,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) ...@@ -427,7 +427,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
if (is_host_enabled(musb)) if (is_host_enabled(musb))
setup_timer(&otg_workaround, otg_timer, (unsigned long) 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 */ /* Global reset */
sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_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) ...@@ -446,7 +446,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
msleep(5); msleep(5);
musb->isr = am35x_interrupt; musb->isr = am35x_musb_interrupt;
/* clear level interrupt */ /* clear level interrupt */
lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
...@@ -461,7 +461,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) ...@@ -461,7 +461,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
return status; return status;
} }
int musb_platform_exit(struct musb *musb) static int am35x_musb_exit(struct musb *musb)
{ {
if (is_host_enabled(musb)) if (is_host_enabled(musb))
del_timer_sync(&otg_workaround); del_timer_sync(&otg_workaround);
...@@ -522,3 +522,16 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) ...@@ -522,3 +522,16 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
memcpy(dst, &val, len); 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,
};
...@@ -277,7 +277,7 @@ static void musb_conn_timer_handler(unsigned long _musb) ...@@ -277,7 +277,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
DBG(4, "state is %s\n", otg_state_string(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)) { if (!is_otg_enabled(musb) && is_host_enabled(musb)) {
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
...@@ -285,11 +285,11 @@ void musb_platform_enable(struct musb *musb) ...@@ -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; int value = musb->config->gpio_vrsel_active;
if (!is_on) if (!is_on)
...@@ -302,51 +302,29 @@ static void bfin_set_vbus(struct musb *musb, int is_on) ...@@ -302,51 +302,29 @@ static void bfin_set_vbus(struct musb *musb, int is_on)
musb_readb(musb->mregs, MUSB_DEVCTL)); 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; 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)) if (!is_otg_enabled(musb) && is_host_enabled(musb))
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); 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; 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; 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) { if (ANOMALY_05000346) {
bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value); bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value);
SSYNC(); SSYNC();
...@@ -380,21 +358,69 @@ int __init musb_platform_init(struct musb *musb) ...@@ -380,21 +358,69 @@ int __init musb_platform_init(struct musb *musb)
EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA | EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA |
EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA); EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA);
SSYNC(); 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)) { 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, setup_timer(&musb_conn_timer,
musb_conn_timer_handler, (unsigned long) musb); musb_conn_timer_handler, (unsigned long) musb);
} }
if (is_peripheral_enabled(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; musb->isr = blackfin_interrupt;
return 0; 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); gpio_free(musb->config->gpio_vrsel);
...@@ -402,3 +428,17 @@ int musb_platform_exit(struct musb *musb) ...@@ -402,3 +428,17 @@ int musb_platform_exit(struct musb *musb)
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; 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,
};
...@@ -131,9 +131,9 @@ static inline void phy_off(void) ...@@ -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; void __iomem *reg_base = musb->ctrl_base;
u32 mask; u32 mask;
...@@ -151,9 +151,9 @@ void musb_platform_enable(struct musb *musb) ...@@ -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; void __iomem *reg_base = musb->ctrl_base;
...@@ -170,7 +170,7 @@ void musb_platform_disable(struct musb *musb) ...@@ -170,7 +170,7 @@ void musb_platform_disable(struct musb *musb)
#define portstate(stmt) #define portstate(stmt)
#endif #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)); WARN_ON(is_on && is_peripheral_active(musb));
} }
...@@ -252,7 +252,7 @@ static void otg_timer(unsigned long _musb) ...@@ -252,7 +252,7 @@ static void otg_timer(unsigned long _musb)
spin_unlock_irqrestore(&musb->lock, flags); 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; static unsigned long last_timer;
...@@ -282,7 +282,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) ...@@ -282,7 +282,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
mod_timer(&otg_workaround, 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; struct musb *musb = hci;
void __iomem *reg_base = musb->ctrl_base; void __iomem *reg_base = musb->ctrl_base;
...@@ -380,7 +380,7 @@ static irqreturn_t da8xx_interrupt(int irq, void *hci) ...@@ -380,7 +380,7 @@ static irqreturn_t da8xx_interrupt(int irq, void *hci)
return ret; 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); u32 cfgchip2 = __raw_readl(CFGCHIP2);
...@@ -409,7 +409,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) ...@@ -409,7 +409,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
return 0; 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; void __iomem *reg_base = musb->ctrl_base;
u32 rev; u32 rev;
...@@ -431,7 +431,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data) ...@@ -431,7 +431,7 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
if (is_host_enabled(musb)) if (is_host_enabled(musb))
setup_timer(&otg_workaround, otg_timer, (unsigned long)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 */ /* Reset the controller */
musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK); 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) ...@@ -446,14 +446,14 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
rev, __raw_readl(CFGCHIP2), rev, __raw_readl(CFGCHIP2),
musb_readb(reg_base, DA8XX_USB_CTRL_REG)); musb_readb(reg_base, DA8XX_USB_CTRL_REG));
musb->isr = da8xx_interrupt; musb->isr = da8xx_musb_interrupt;
return 0; return 0;
fail: fail:
clk_disable(musb->clock); clk_disable(musb->clock);
return -ENODEV; return -ENODEV;
} }
int musb_platform_exit(struct musb *musb) static int da8xx_musb_exit(struct musb *musb)
{ {
if (is_host_enabled(musb)) if (is_host_enabled(musb))
del_timer_sync(&otg_workaround); del_timer_sync(&otg_workaround);
...@@ -467,3 +467,16 @@ int musb_platform_exit(struct musb *musb) ...@@ -467,3 +467,16 @@ int musb_platform_exit(struct musb *musb)
return 0; 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,
};
...@@ -83,7 +83,7 @@ static inline void phy_off(void) ...@@ -83,7 +83,7 @@ static inline void phy_off(void)
static int dma_off = 1; static int dma_off = 1;
void musb_platform_enable(struct musb *musb) static void davinci_musb_enable(struct musb *musb)
{ {
u32 tmp, old, val; u32 tmp, old, val;
...@@ -116,7 +116,7 @@ void musb_platform_enable(struct musb *musb) ...@@ -116,7 +116,7 @@ void musb_platform_enable(struct musb *musb)
/* /*
* Disable the HDRC and flush interrupts * 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: /* because we don't set CTRLR.UINT, "important" to:
* - not read/write INTRUSB/INTRUSBE * - not read/write INTRUSB/INTRUSBE
...@@ -167,7 +167,7 @@ static void evm_deferred_drvvbus(struct work_struct *ignored) ...@@ -167,7 +167,7 @@ static void evm_deferred_drvvbus(struct work_struct *ignored)
#endif /* EVM */ #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 #ifdef CONFIG_MACH_DAVINCI_EVM
if (is_on) if (is_on)
...@@ -190,10 +190,10 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate) ...@@ -190,10 +190,10 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate)
#endif #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)); 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) ...@@ -259,7 +259,7 @@ static void otg_timer(unsigned long _musb)
spin_unlock_irqrestore(&musb->lock, flags); 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; unsigned long flags;
irqreturn_t retval = IRQ_NONE; irqreturn_t retval = IRQ_NONE;
...@@ -345,7 +345,7 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci) ...@@ -345,7 +345,7 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
/* NOTE: this must complete poweron within 100 msec /* NOTE: this must complete poweron within 100 msec
* (OTG_TIME_A_WAIT_VRISE) but we don't check for that. * (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", DBG(2, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off", drvvbus ? "on" : "off",
otg_state_string(musb), otg_state_string(musb),
...@@ -370,13 +370,13 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci) ...@@ -370,13 +370,13 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
return retval; 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?) */ /* EVM can't do this (right?) */
return -EIO; return -EIO;
} }
int __init musb_platform_init(struct musb *musb) static int davinci_musb_init(struct musb *musb)
{ {
void __iomem *tibase = musb->ctrl_base; void __iomem *tibase = musb->ctrl_base;
u32 revision; u32 revision;
...@@ -398,8 +398,8 @@ int __init musb_platform_init(struct musb *musb) ...@@ -398,8 +398,8 @@ int __init musb_platform_init(struct musb *musb)
if (is_host_enabled(musb)) if (is_host_enabled(musb))
setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
musb->board_set_vbus = davinci_set_vbus; musb->board_set_vbus = davinci_musb_set_vbus;
davinci_source_power(musb, 0, 1); davinci_musb_source_power(musb, 0, 1);
/* dm355 EVM swaps D+/D- for signal integrity, and /* dm355 EVM swaps D+/D- for signal integrity, and
* is clocked from the main 24 MHz crystal. * is clocked from the main 24 MHz crystal.
...@@ -440,7 +440,7 @@ int __init musb_platform_init(struct musb *musb) ...@@ -440,7 +440,7 @@ int __init musb_platform_init(struct musb *musb)
revision, __raw_readl(USB_PHY_CTRL), revision, __raw_readl(USB_PHY_CTRL),
musb_readb(tibase, DAVINCI_USB_CTRL_REG)); musb_readb(tibase, DAVINCI_USB_CTRL_REG));
musb->isr = davinci_interrupt; musb->isr = davinci_musb_interrupt;
return 0; return 0;
fail: fail:
...@@ -451,7 +451,7 @@ int __init musb_platform_init(struct musb *musb) ...@@ -451,7 +451,7 @@ int __init musb_platform_init(struct musb *musb)
return -ENODEV; return -ENODEV;
} }
int musb_platform_exit(struct musb *musb) static int davinci_musb_exit(struct musb *musb)
{ {
if (is_host_enabled(musb)) if (is_host_enabled(musb))
del_timer_sync(&otg_workaround); del_timer_sync(&otg_workaround);
...@@ -465,7 +465,7 @@ int musb_platform_exit(struct musb *musb) ...@@ -465,7 +465,7 @@ int musb_platform_exit(struct musb *musb)
__raw_writel(deepsleep, DM355_DEEPSLEEP); __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 */ /* delay, to avoid problems with module reload */
if (is_host_enabled(musb) && musb->xceiv->default_a) { if (is_host_enabled(musb) && musb->xceiv->default_a) {
...@@ -502,3 +502,15 @@ int musb_platform_exit(struct musb *musb) ...@@ -502,3 +502,15 @@ int musb_platform_exit(struct musb *musb)
return 0; 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,
};
...@@ -390,7 +390,7 @@ void musb_otg_timer_func(unsigned long data) ...@@ -390,7 +390,7 @@ void musb_otg_timer_func(unsigned long data)
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
DBG(1, "HNP: %s timeout\n", otg_state_string(musb)); 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; musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
break; break;
default: default:
...@@ -570,7 +570,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -570,7 +570,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
musb->ep0_stage = MUSB_EP0_START; musb->ep0_stage = MUSB_EP0_START;
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb_set_vbus(musb, 1); musb_platform_set_vbus(musb, 1);
handled = IRQ_HANDLED; handled = IRQ_HANDLED;
} }
...@@ -641,7 +641,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ...@@ -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 */ /* go through A_WAIT_VFALL then start a new session */
if (!ignore) if (!ignore)
musb_set_vbus(musb, 0); musb_platform_set_vbus(musb, 0);
handled = IRQ_HANDLED; handled = IRQ_HANDLED;
} }
...@@ -1898,6 +1898,8 @@ allocate_instance(struct device *dev, ...@@ -1898,6 +1898,8 @@ allocate_instance(struct device *dev,
} }
musb->controller = dev; musb->controller = dev;
musb->ops = &musb_ops;
return musb; return musb;
} }
......
...@@ -281,6 +281,8 @@ struct musb_platform_ops { ...@@ -281,6 +281,8 @@ struct musb_platform_ops {
void (*set_vbus)(struct musb *musb, int on); void (*set_vbus)(struct musb *musb, int on);
}; };
extern const struct musb_platform_ops musb_ops;
/* /*
* struct musb_hw_ep - endpoint hardware (bidirectional) * struct musb_hw_ep - endpoint hardware (bidirectional)
* *
...@@ -359,6 +361,9 @@ struct musb { ...@@ -359,6 +361,9 @@ struct musb {
spinlock_t lock; spinlock_t lock;
struct clk *clock; struct clk *clock;
struct clk *phy_clock; struct clk *phy_clock;
const struct musb_platform_ops *ops;
irqreturn_t (*isr)(int, void *); irqreturn_t (*isr)(int, void *);
struct work_struct irq_work; struct work_struct irq_work;
u16 hwvers; u16 hwvers;
...@@ -486,52 +491,6 @@ struct musb { ...@@ -486,52 +491,6 @@ struct musb {
#endif #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 #ifdef CONFIG_USB_GADGET_MUSB_HDRC
static inline struct musb *gadget_to_musb(struct usb_gadget *g) static inline struct musb *gadget_to_musb(struct usb_gadget *g)
{ {
...@@ -620,29 +579,120 @@ extern void musb_load_testpacket(struct musb *); ...@@ -620,29 +579,120 @@ extern void musb_load_testpacket(struct musb *);
extern irqreturn_t musb_interrupt(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 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) || \ struct musb_context_registers {
defined(CONFIG_ARCH_DAVINCI_DA8XX) || \
defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \ #if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
defined(CONFIG_ARCH_OMAP4) defined(CONFIG_ARCH_OMAP4)
extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout); u32 otg_sysconfig, otg_forcestandby;
#else
#define musb_platform_try_idle(x, y) do {} while (0)
#endif #endif
u8 power;
u16 intrtxe, intrrxe;
u8 intrusbe;
u16 frame;
u8 index, testmode;
#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) u8 devctl, busctl, misc;
extern int musb_platform_get_vbus_status(struct musb *musb);
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 #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 #endif
extern int __init musb_platform_init(struct musb *musb); #endif
extern int musb_platform_exit(struct musb *musb);
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__ */ #endif /* __MUSB_CORE_H__ */
...@@ -276,7 +276,7 @@ int musb_hub_control( ...@@ -276,7 +276,7 @@ int musb_hub_control(
break; break;
case USB_PORT_FEAT_POWER: case USB_PORT_FEAT_POWER:
if (!(is_otg_enabled(musb) && hcd->self.is_b_host)) if (!(is_otg_enabled(musb) && hcd->self.is_b_host))
musb_set_vbus(musb, 0); musb_platform_set_vbus(musb, 0);
break; break;
case USB_PORT_FEAT_C_CONNECTION: case USB_PORT_FEAT_C_CONNECTION:
case USB_PORT_FEAT_C_ENABLE: case USB_PORT_FEAT_C_ENABLE:
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "musb_core.h" #include "musb_core.h"
#include "omap2430.h" #include "omap2430.h"
static struct timer_list musb_idle_timer; static struct timer_list musb_idle_timer;
static void musb_do_idle(unsigned long _musb) static void musb_do_idle(unsigned long _musb)
...@@ -98,7 +97,7 @@ 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); unsigned long default_timeout = jiffies + msecs_to_jiffies(3);
static unsigned long last_timer; static unsigned long last_timer;
...@@ -131,13 +130,15 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) ...@@ -131,13 +130,15 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
mod_timer(&musb_idle_timer, 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; u8 devctl;
/* HDRC controls CPEN, but beware current surges during device /* HDRC controls CPEN, but beware current surges during device
...@@ -175,9 +176,9 @@ static void omap_set_vbus(struct musb *musb, int is_on) ...@@ -175,9 +176,9 @@ static void omap_set_vbus(struct musb *musb, int is_on)
musb_readb(musb->mregs, MUSB_DEVCTL)); 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); u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
...@@ -187,7 +188,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) ...@@ -187,7 +188,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
return 0; return 0;
} }
int __init musb_platform_init(struct musb *musb) static int omap2430_musb_init(struct musb *musb)
{ {
u32 l; u32 l;
struct device *dev = musb->controller; struct device *dev = musb->controller;
...@@ -204,7 +205,7 @@ int __init musb_platform_init(struct musb *musb) ...@@ -204,7 +205,7 @@ int __init musb_platform_init(struct musb *musb)
return -ENODEV; return -ENODEV;
} }
musb_platform_resume(musb); omap2430_musb_resume(musb);
l = musb_readl(musb->mregs, OTG_SYSCONFIG); l = musb_readl(musb->mregs, OTG_SYSCONFIG);
l &= ~ENABLEWAKEUP; /* disable wakeup */ l &= ~ENABLEWAKEUP; /* disable wakeup */
...@@ -242,7 +243,7 @@ int __init musb_platform_init(struct musb *musb) ...@@ -242,7 +243,7 @@ int __init musb_platform_init(struct musb *musb)
musb_readl(musb->mregs, OTG_SIMENABLE)); musb_readl(musb->mregs, OTG_SIMENABLE));
if (is_host_enabled(musb)) 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); setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
...@@ -265,7 +266,7 @@ void musb_platform_restore_context(struct musb *musb, ...@@ -265,7 +266,7 @@ void musb_platform_restore_context(struct musb *musb,
} }
#endif #endif
static int musb_platform_suspend(struct musb *musb) static int omap2430_musb_suspend(struct musb *musb)
{ {
u32 l; u32 l;
...@@ -291,7 +292,7 @@ static int musb_platform_suspend(struct musb *musb) ...@@ -291,7 +292,7 @@ static int musb_platform_suspend(struct musb *musb)
return 0; return 0;
} }
static int musb_platform_resume(struct musb *musb) static int omap2430_musb_resume(struct musb *musb)
{ {
u32 l; u32 l;
...@@ -316,12 +317,27 @@ static int musb_platform_resume(struct musb *musb) ...@@ -316,12 +317,27 @@ static int musb_platform_resume(struct musb *musb)
return 0; return 0;
} }
static int omap2430_musb_exit(struct musb *musb)
int musb_platform_exit(struct musb *musb)
{ {
musb_platform_suspend(musb); omap2430_musb_suspend(musb);
otg_put_transceiver(musb->xceiv); otg_put_transceiver(musb->xceiv);
return 0; 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,
};
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "musb_core.h" #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_MAJOR(reg_val) ((reg_val >> 4) & 0xf)
#define TUSB_REV_MINOR(reg_val) (reg_val & 0xf) #define TUSB_REV_MINOR(reg_val) (reg_val & 0xf)
...@@ -50,7 +50,7 @@ u8 tusb_get_revision(struct musb *musb) ...@@ -50,7 +50,7 @@ u8 tusb_get_revision(struct musb *musb)
return rev; 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; void __iomem *tbase = musb->ctrl_base;
u8 rev; u8 rev;
...@@ -348,7 +348,7 @@ static void tusb_set_clock_source(struct musb *musb, unsigned mode) ...@@ -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 * USB link is not suspended ... and tells us the relevant wakeup
* events. SW_EN for voltage is handled separately. * 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; void __iomem *tbase = musb->ctrl_base;
u32 reg; u32 reg;
...@@ -385,7 +385,7 @@ void tusb_allow_idle(struct musb *musb, u32 wakeup_enables) ...@@ -385,7 +385,7 @@ void tusb_allow_idle(struct musb *musb, u32 wakeup_enables)
/* /*
* Updates cable VBUS status. Caller must take care of locking. * 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; void __iomem *tbase = musb->ctrl_base;
u32 otg_stat, prcm_mngmt; u32 otg_stat, prcm_mngmt;
...@@ -431,7 +431,7 @@ static void musb_do_idle(unsigned long _musb) ...@@ -431,7 +431,7 @@ static void musb_do_idle(unsigned long _musb)
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
tusb_source_power(musb, 0); tusb_musb_set_vbus(musb, 0);
default: default:
break; break;
} }
...@@ -475,7 +475,7 @@ static void musb_do_idle(unsigned long _musb) ...@@ -475,7 +475,7 @@ static void musb_do_idle(unsigned long _musb)
* we don't want to treat that full speed J as a wakeup event. * we don't want to treat that full speed J as a wakeup event.
* ... peripherals must draw only suspend current after 10 msec. * ... 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); unsigned long default_timeout = jiffies + msecs_to_jiffies(3);
static unsigned long last_timer; static unsigned long last_timer;
...@@ -515,7 +515,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout) ...@@ -515,7 +515,7 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
| TUSB_DEV_OTG_TIMER_ENABLE) \ | TUSB_DEV_OTG_TIMER_ENABLE) \
: 0) : 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; void __iomem *tbase = musb->ctrl_base;
u32 conf, prcm, timer; u32 conf, prcm, timer;
...@@ -599,7 +599,7 @@ static void tusb_source_power(struct musb *musb, int is_on) ...@@ -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 peripheral modes in non-OTG configurations by reconfiguring hardware
* and then setting musb->board_mode. For now, only support OTG mode. * 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; void __iomem *tbase = musb->ctrl_base;
u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; 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) ...@@ -677,7 +677,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
default_a = is_host_enabled(musb); default_a = is_host_enabled(musb);
DBG(2, "Default-%c\n", default_a ? 'A' : 'B'); DBG(2, "Default-%c\n", default_a ? 'A' : 'B');
musb->xceiv->default_a = default_a; musb->xceiv->default_a = default_a;
tusb_source_power(musb, default_a); tusb_musb_set_vbus(musb, default_a);
/* Don't allow idling immediately */ /* Don't allow idling immediately */
if (default_a) if (default_a)
...@@ -722,7 +722,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -722,7 +722,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
switch (musb->xceiv->state) { switch (musb->xceiv->state) {
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
DBG(2, "Got SRP, turning on VBUS\n"); 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 */ /* CONNECT can wake if a_wait_bcon is set */
if (musb->a_wait_bcon != 0) if (musb->a_wait_bcon != 0)
...@@ -748,11 +748,11 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -748,11 +748,11 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
*/ */
if (musb->vbuserr_retry) { if (musb->vbuserr_retry) {
musb->vbuserr_retry--; musb->vbuserr_retry--;
tusb_source_power(musb, 1); tusb_musb_set_vbus(musb, 1);
} else { } else {
musb->vbuserr_retry musb->vbuserr_retry
= VBUSERR_RETRY_COUNT; = VBUSERR_RETRY_COUNT;
tusb_source_power(musb, 0); tusb_musb_set_vbus(musb, 0);
} }
break; break;
default: default:
...@@ -786,7 +786,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -786,7 +786,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
} else { } else {
/* REVISIT report overcurrent to hub? */ /* REVISIT report overcurrent to hub? */
ERR("vbus too slow, devctl %02x\n", devctl); ERR("vbus too slow, devctl %02x\n", devctl);
tusb_source_power(musb, 0); tusb_musb_set_vbus(musb, 0);
} }
break; break;
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
...@@ -807,7 +807,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -807,7 +807,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
return idle_timeout; 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; struct musb *musb = __hci;
void __iomem *tbase = musb->ctrl_base; void __iomem *tbase = musb->ctrl_base;
...@@ -911,7 +911,7 @@ static irqreturn_t tusb_interrupt(int irq, void *__hci) ...@@ -911,7 +911,7 @@ static irqreturn_t tusb_interrupt(int irq, void *__hci)
musb_writel(tbase, TUSB_INT_SRC_CLEAR, musb_writel(tbase, TUSB_INT_SRC_CLEAR,
int_src & ~TUSB_INT_MASK_RESERVED_BITS); 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); musb_writel(tbase, TUSB_INT_MASK, int_mask);
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
...@@ -926,7 +926,7 @@ static int dma_off; ...@@ -926,7 +926,7 @@ static int dma_off;
* REVISIT: * REVISIT:
* - Check what is unnecessary in MGC_HdrcStart() * - 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; void __iomem *tbase = musb->ctrl_base;
...@@ -970,7 +970,7 @@ void musb_platform_enable(struct musb *musb) ...@@ -970,7 +970,7 @@ void musb_platform_enable(struct musb *musb)
/* /*
* Disables TUSB6010. Caller must take care of locking. * 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; void __iomem *tbase = musb->ctrl_base;
...@@ -995,7 +995,7 @@ void musb_platform_disable(struct musb *musb) ...@@ -995,7 +995,7 @@ void musb_platform_disable(struct musb *musb)
* Sets up TUSB6010 CPU interface specific signals and registers * Sets up TUSB6010 CPU interface specific signals and registers
* Note: Settings optimized for OMAP24xx * 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; void __iomem *tbase = musb->ctrl_base;
...@@ -1022,7 +1022,7 @@ static void __init tusb_setup_cpu_interface(struct musb *musb) ...@@ -1022,7 +1022,7 @@ static void __init tusb_setup_cpu_interface(struct musb *musb)
musb_writel(tbase, TUSB_WAIT_COUNT, 1); 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; void __iomem *tbase = musb->ctrl_base;
int ret = 0; int ret = 0;
...@@ -1091,7 +1091,7 @@ static int __init tusb_start(struct musb *musb) ...@@ -1091,7 +1091,7 @@ static int __init tusb_start(struct musb *musb)
return -ENODEV; return -ENODEV;
} }
int __init musb_platform_init(struct musb *musb) static int tusb_musb_init(struct musb *musb)
{ {
struct platform_device *pdev; struct platform_device *pdev;
struct resource *mem; struct resource *mem;
...@@ -1131,16 +1131,14 @@ int __init musb_platform_init(struct musb *musb) ...@@ -1131,16 +1131,14 @@ int __init musb_platform_init(struct musb *musb)
*/ */
musb->mregs += TUSB_BASE_OFFSET; musb->mregs += TUSB_BASE_OFFSET;
ret = tusb_start(musb); ret = tusb_musb_start(musb);
if (ret) { if (ret) {
printk(KERN_ERR "Could not start tusb6010 (%d)\n", printk(KERN_ERR "Could not start tusb6010 (%d)\n",
ret); ret);
goto done; 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)) { if (is_peripheral_enabled(musb)) {
musb->xceiv->set_power = tusb_draw_power; musb->xceiv->set_power = tusb_draw_power;
the_musb = musb; the_musb = musb;
...@@ -1159,7 +1157,7 @@ int __init musb_platform_init(struct musb *musb) ...@@ -1159,7 +1157,7 @@ int __init musb_platform_init(struct musb *musb)
return ret; return ret;
} }
int musb_platform_exit(struct musb *musb) static int tusb_musb_exit(struct musb *musb)
{ {
del_timer_sync(&musb_idle_timer); del_timer_sync(&musb_idle_timer);
the_musb = NULL; the_musb = NULL;
...@@ -1173,3 +1171,17 @@ int musb_platform_exit(struct musb *musb) ...@@ -1173,3 +1171,17 @@ int musb_platform_exit(struct musb *musb)
usb_nop_xceiv_unregister(); usb_nop_xceiv_unregister();
return 0; 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,
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册