Skip to content

Commit

Permalink
usb: musb: drop useless board_mode usage
Browse files Browse the repository at this point in the history
we are compiling the driver always with full OTG
capabilities, so that board_mode trick becomes
useless.

Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Felipe Balbi committed Aug 9, 2012
1 parent 4f3e8d2 commit 032ec49
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 334 deletions.
24 changes: 7 additions & 17 deletions drivers/usb/musb/am35x.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ static void am35x_musb_enable(struct musb *musb)
musb_writel(reg_base, CORE_INTR_MASK_SET_REG, AM35X_INTR_USB_MASK);

/* Force the DRVVBUS IRQ so we can start polling for ID change. */
if (is_otg_enabled(musb))
musb_writel(reg_base, CORE_INTR_SRC_SET_REG,
AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT);
musb_writel(reg_base, CORE_INTR_SRC_SET_REG,
AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT);
}

/*
Expand Down Expand Up @@ -173,9 +172,6 @@ static void otg_timer(unsigned long _musb)
MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
break;
case OTG_STATE_B_IDLE:
if (!is_peripheral_enabled(musb))
break;

devctl = musb_readb(mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
Expand All @@ -192,9 +188,6 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
{
static unsigned long last_timer;

if (!is_otg_enabled(musb))
return;

if (timeout == 0)
timeout = jiffies + msecs_to_jiffies(3);

Expand Down Expand Up @@ -271,8 +264,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
int err;

err = is_host_enabled(musb) && (musb->int_usb &
MUSB_INTR_VBUSERROR);
err = musb->int_usb & MUSB_INTR_VBUSERROR;
if (err) {
/*
* The Mentor core doesn't debounce VBUS as needed
Expand All @@ -289,7 +281,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (is_host_enabled(musb) && drvvbus) {
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
Expand Down Expand Up @@ -326,7 +318,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
}

/* Poll for ID change */
if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE)
if (musb->xceiv->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
Expand Down Expand Up @@ -369,8 +361,7 @@ static int am35x_musb_init(struct musb *musb)
if (IS_ERR_OR_NULL(musb->xceiv))
return -ENODEV;

if (is_host_enabled(musb))
setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);

/* Reset the musb */
if (data->reset)
Expand Down Expand Up @@ -400,8 +391,7 @@ static int am35x_musb_exit(struct musb *musb)
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);
del_timer_sync(&otg_workaround);

/* Shutdown the on-chip PHY and its PLL. */
if (data->set_phy_power)
Expand Down
37 changes: 10 additions & 27 deletions drivers/usb/musb/blackfin.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
}

/* Start sampling ID pin, when plug is removed from MUSB */
if ((is_otg_enabled(musb) && (musb->xceiv->state == OTG_STATE_B_IDLE
|| musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) ||
if ((musb->xceiv->state == OTG_STATE_B_IDLE
|| musb->xceiv->state == OTG_STATE_A_WAIT_BCON) ||
(musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
musb->a_wait_bcon = TIMER_DELAY;
Expand Down Expand Up @@ -228,18 +228,13 @@ static void musb_conn_timer_handler(unsigned long _musb)

val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
musb_writeb(musb->mregs, MUSB_INTRUSB, val);
if (is_otg_enabled(musb))
musb->xceiv->state = OTG_STATE_B_IDLE;
else
musb_writeb(musb->mregs, MUSB_POWER, MUSB_POWER_HSENAB);
musb->xceiv->state = OTG_STATE_B_IDLE;
}
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
break;
case OTG_STATE_B_IDLE:

if (!is_peripheral_enabled(musb))
break;
/* Start a new session. It seems that MUSB needs taking
/*
* Start a new session. It seems that MUSB needs taking
* some time to recognize the type of the plug inserted?
*/
val = musb_readw(musb->mregs, MUSB_DEVCTL);
Expand Down Expand Up @@ -295,10 +290,7 @@ static void musb_conn_timer_handler(unsigned long _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);
musb->a_wait_bcon = TIMER_DELAY;
}
/* REVISIT is this really correct ? */
}

static void bfin_musb_disable(struct musb *musb)
Expand All @@ -323,12 +315,6 @@ static int bfin_musb_set_power(struct usb_phy *x, unsigned mA)
return 0;
}

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);
}

static int bfin_musb_vbus_status(struct musb *musb)
{
return 0;
Expand Down Expand Up @@ -424,12 +410,10 @@ static int bfin_musb_init(struct musb *musb)

bfin_musb_reg_init(musb);

if (is_host_enabled(musb)) {
setup_timer(&musb_conn_timer,
musb_conn_timer_handler, (unsigned long) musb);
}
if (is_peripheral_enabled(musb))
musb->xceiv->set_power = bfin_musb_set_power;
setup_timer(&musb_conn_timer, musb_conn_timer_handler,
(unsigned long) musb);

musb->xceiv->set_power = bfin_musb_set_power;

musb->isr = blackfin_interrupt;
musb->double_buffer_not_ok = true;
Expand All @@ -454,7 +438,6 @@ static const struct musb_platform_ops bfin_ops = {
.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,
Expand Down
24 changes: 7 additions & 17 deletions drivers/usb/musb/da8xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ static void da8xx_musb_enable(struct musb *musb)
musb_writel(reg_base, DA8XX_USB_INTR_MASK_SET_REG, mask);

/* Force the DRVVBUS IRQ so we can start polling for ID change. */
if (is_otg_enabled(musb))
musb_writel(reg_base, DA8XX_USB_INTR_SRC_SET_REG,
DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT);
musb_writel(reg_base, DA8XX_USB_INTR_SRC_SET_REG,
DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT);
}

/**
Expand Down Expand Up @@ -231,9 +230,6 @@ static void otg_timer(unsigned long _musb)
MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
break;
case OTG_STATE_B_IDLE:
if (!is_peripheral_enabled(musb))
break;

/*
* There's no ID-changed IRQ, so we have no good way to tell
* when to switch to the A-Default state machine (by setting
Expand Down Expand Up @@ -263,9 +259,6 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
{
static unsigned long last_timer;

if (!is_otg_enabled(musb))
return;

if (timeout == 0)
timeout = jiffies + msecs_to_jiffies(3);

Expand Down Expand Up @@ -333,8 +326,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
int err;

err = is_host_enabled(musb) && (musb->int_usb &
MUSB_INTR_VBUSERROR);
err = musb->int_usb & USB_INTR_VBUSERROR;
if (err) {
/*
* The Mentor core doesn't debounce VBUS as needed
Expand All @@ -351,7 +343,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (is_host_enabled(musb) && drvvbus) {
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
Expand Down Expand Up @@ -382,7 +374,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);

/* Poll for ID change */
if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE)
if (musb->xceiv->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
Expand Down Expand Up @@ -430,8 +422,7 @@ static int da8xx_musb_init(struct musb *musb)
if (IS_ERR_OR_NULL(musb->xceiv))
goto fail;

if (is_host_enabled(musb))
setup_timer(&otg_workaround, otg_timer, (unsigned long)musb);
setup_timer(&otg_workaround, otg_timer, (unsigned long)musb);

/* Reset the controller */
musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK);
Expand All @@ -454,8 +445,7 @@ static int da8xx_musb_init(struct musb *musb)

static int da8xx_musb_exit(struct musb *musb)
{
if (is_host_enabled(musb))
del_timer_sync(&otg_workaround);
del_timer_sync(&otg_workaround);

phy_off();

Expand Down
32 changes: 10 additions & 22 deletions drivers/usb/musb/davinci.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ static void davinci_musb_enable(struct musb *musb)
dma_off = 0;

/* force a DRVVBUS irq so we can start polling for ID change */
if (is_otg_enabled(musb))
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
DAVINCI_INTR_DRVVBUS << DAVINCI_USB_USBINT_SHIFT);
}

Expand Down Expand Up @@ -234,10 +233,8 @@ static void otg_timer(unsigned long _musb)
MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
break;
case OTG_STATE_B_IDLE:
if (!is_peripheral_enabled(musb))
break;

/* There's no ID-changed IRQ, so we have no good way to tell
/*
* There's no ID-changed IRQ, so we have no good way to tell
* when to switch to the A-Default state machine (by setting
* the DEVCTL.SESSION flag).
*
Expand Down Expand Up @@ -315,8 +312,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
int err = musb->int_usb & MUSB_INTR_VBUSERROR;

err = is_host_enabled(musb)
&& (musb->int_usb & MUSB_INTR_VBUSERROR);
err = musb->int_usb & MUSB_INTR_VBUSERROR;
if (err) {
/* The Mentor core doesn't debounce VBUS as needed
* to cope with device connect current spikes. This
Expand All @@ -332,7 +328,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n");
} else if (is_host_enabled(musb) && drvvbus) {
} else if (drvvbus) {
MUSB_HST_MODE(musb);
otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
Expand Down Expand Up @@ -365,8 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
musb_writel(tibase, DAVINCI_USB_EOI_REG, 0);

/* poll for ID change */
if (is_otg_enabled(musb)
&& musb->xceiv->state == OTG_STATE_B_IDLE)
if (musb->xceiv->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);

spin_unlock_irqrestore(&musb->lock, flags);
Expand Down Expand Up @@ -397,8 +392,7 @@ static int davinci_musb_init(struct musb *musb)
if (revision == 0)
goto fail;

if (is_host_enabled(musb))
setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);

davinci_musb_source_power(musb, 0, 1);

Expand All @@ -419,12 +413,7 @@ static int davinci_musb_init(struct musb *musb)
if (cpu_is_davinci_dm355()) {
u32 deepsleep = __raw_readl(DM355_DEEPSLEEP);

if (is_host_enabled(musb)) {
deepsleep &= ~DRVVBUS_OVERRIDE;
} else {
deepsleep &= ~DRVVBUS_FORCE;
deepsleep |= DRVVBUS_OVERRIDE;
}
deepsleep &= ~DRVVBUS_FORCE;
__raw_writel(deepsleep, DM355_DEEPSLEEP);
}

Expand Down Expand Up @@ -453,8 +442,7 @@ static int davinci_musb_init(struct musb *musb)

static int davinci_musb_exit(struct musb *musb)
{
if (is_host_enabled(musb))
del_timer_sync(&otg_workaround);
del_timer_sync(&otg_workaround);

/* force VBUS off */
if (cpu_is_davinci_dm355()) {
Expand All @@ -468,7 +456,7 @@ static int davinci_musb_exit(struct musb *musb)
davinci_musb_source_power(musb, 0 /*off*/, 1);

/* delay, to avoid problems with module reload */
if (is_host_enabled(musb) && musb->xceiv->otg->default_a) {
if (musb->xceiv->otg->default_a) {
int maxdelay = 30;
u8 devctl, warn = 0;

Expand Down
Loading

0 comments on commit 032ec49

Please sign in to comment.