Commit e47d9254 authored by Antoine Tenart's avatar Antoine Tenart Committed by Felipe Balbi

usb: move the OTG state from the USB PHY to the OTG structure

Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.

[ balbi@ti.com : fix build regressions with phy-tahvo.c, musb_dsps.c,
		phy-isp1301-omap, and chipidea's debug.c ]
Acked-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
Acked-by: default avatarPeter Chen <peter.chen@freescale.com>
Signed-off-by: default avatarAntoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent a2655e4a
...@@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg) ...@@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg)
static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host) static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
{ {
struct usb_phy *phy = otg->phy;
otg->host = host; otg->host = host;
if (!host) if (!host)
phy->state = OTG_STATE_UNDEFINED; otg->state = OTG_STATE_UNDEFINED;
return 0; return 0;
} }
...@@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host) ...@@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host)
static int omap_usb_set_peripheral(struct usb_otg *otg, static int omap_usb_set_peripheral(struct usb_otg *otg,
struct usb_gadget *gadget) struct usb_gadget *gadget)
{ {
struct usb_phy *phy = otg->phy;
otg->gadget = gadget; otg->gadget = gadget;
if (!gadget) if (!gadget)
phy->state = OTG_STATE_UNDEFINED; otg->state = OTG_STATE_UNDEFINED;
return 0; return 0;
} }
......
...@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused) ...@@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused)
/* ------ State ----- */ /* ------ State ----- */
seq_printf(s, "OTG state: %s\n\n", seq_printf(s, "OTG state: %s\n\n",
usb_otg_state_string(ci->transceiver->state)); usb_otg_state_string(ci->transceiver->otg->state));
/* ------ State Machine Variables ----- */ /* ------ State Machine Variables ----- */
seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop); seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop);
......
...@@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator) ...@@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator)
set_tmout(ci, indicator); set_tmout(ci, indicator);
/* only vbus fall below B_sess_vld in b_idle state */ /* only vbus fall below B_sess_vld in b_idle state */
if (ci->transceiver->state == OTG_STATE_B_IDLE) if (ci->fsm.otg->state == OTG_STATE_B_IDLE)
ci_otg_queue_work(ci); ci_otg_queue_work(ci);
} }
...@@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci) ...@@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
* when there is no gadget class driver * when there is no gadget class driver
*/ */
if (ci->fsm.id && !(ci->driver) && if (ci->fsm.id && !(ci->driver) &&
ci->transceiver->state < OTG_STATE_A_IDLE) ci->fsm.otg->state < OTG_STATE_A_IDLE)
return 0; return 0;
if (otg_statemachine(&ci->fsm)) { if (otg_statemachine(&ci->fsm)) {
if (ci->transceiver->state == OTG_STATE_A_IDLE) { if (ci->fsm.otg->state == OTG_STATE_A_IDLE) {
/* /*
* Further state change for cases: * Further state change for cases:
* a_idle to b_idle; or * a_idle to b_idle; or
...@@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci) ...@@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
ci_otg_queue_work(ci); ci_otg_queue_work(ci);
if (ci->id_event) if (ci->id_event)
ci->id_event = false; ci->id_event = false;
} else if (ci->transceiver->state == OTG_STATE_B_IDLE) { } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) {
if (ci->fsm.b_sess_vld) { if (ci->fsm.b_sess_vld) {
ci->fsm.power_up = 0; ci->fsm.power_up = 0;
/* /*
...@@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci) ...@@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci)
otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV); otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV);
port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS); port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS);
switch (ci->transceiver->state) { switch (ci->fsm.otg->state) {
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
if (port_conn) { if (port_conn) {
fsm->b_conn = 1; fsm->b_conn = 1;
...@@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci) ...@@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci)
ci->transceiver->otg = ci->fsm.otg; ci->transceiver->otg = ci->fsm.otg;
ci->fsm.power_up = 1; ci->fsm.power_up = 1;
ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0; ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0;
ci->transceiver->state = OTG_STATE_UNDEFINED; ci->fsm.otg->state = OTG_STATE_UNDEFINED;
ci->fsm.ops = &ci_otg_ops; ci->fsm.ops = &ci_otg_ops;
mutex_init(&ci->fsm.lock); mutex_init(&ci->fsm.lock);
......
...@@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) ...@@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state)
static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
{ {
state_changed = 1; state_changed = 1;
if (fsm->otg->phy->state == new_state) if (fsm->otg->state == new_state)
return 0; return 0;
VDBG("Set state: %s\n", usb_otg_state_string(new_state)); VDBG("Set state: %s\n", usb_otg_state_string(new_state));
otg_leave_state(fsm, fsm->otg->phy->state); otg_leave_state(fsm, fsm->otg->state);
switch (new_state) { switch (new_state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
otg_drv_vbus(fsm, 0); otg_drv_vbus(fsm, 0);
...@@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) ...@@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state)
break; break;
} }
fsm->otg->phy->state = new_state; fsm->otg->state = new_state;
return 0; return 0;
} }
...@@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm) ...@@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm)
mutex_lock(&fsm->lock); mutex_lock(&fsm->lock);
state = fsm->otg->phy->state; state = fsm->otg->state;
state_changed = 0; state_changed = 0;
/* State machine state change judgement */ /* State machine state change judgement */
......
...@@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci) ...@@ -183,7 +183,7 @@ static void start_hnp(struct ohci_hcd *ohci)
otg_start_hnp(hcd->usb_phy->otg); otg_start_hnp(hcd->usb_phy->otg);
local_irq_save(flags); local_irq_save(flags);
hcd->usb_phy->state = OTG_STATE_A_SUSPEND; hcd->usb_phy->otg.state = OTG_STATE_A_SUSPEND;
writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]); writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]);
l = omap_readl(OTG_CTRL); l = omap_readl(OTG_CTRL);
l &= ~OTG_A_BUSREQ; l &= ~OTG_A_BUSREQ;
......
...@@ -149,25 +149,25 @@ static void otg_timer(unsigned long _musb) ...@@ -149,25 +149,25 @@ static void otg_timer(unsigned long _musb)
*/ */
devctl = musb_readb(mregs, MUSB_DEVCTL); devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION; devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) { if (devctl & MUSB_DEVCTL_BDEVICE) {
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
} else { } else {
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
} }
break; break;
case OTG_STATE_A_WAIT_VFALL: case OTG_STATE_A_WAIT_VFALL:
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG, musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT); MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
break; break;
...@@ -176,7 +176,7 @@ static void otg_timer(unsigned long _musb) ...@@ -176,7 +176,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE) if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else else
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break; break;
default: default:
break; break;
...@@ -193,9 +193,9 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -193,9 +193,9 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
/* Never idle if active, or when VBUS timeout is not set as host */ /* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 && if (musb->is_active || (musb->a_wait_bcon == 0 &&
musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n", dev_dbg(musb->controller, "%s active, deleting timer\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround); del_timer(&otg_workaround);
last_timer = jiffies; last_timer = jiffies;
return; return;
...@@ -208,7 +208,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -208,7 +208,7 @@ static void am35x_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout; last_timer = timeout;
dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies)); jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout); mod_timer(&otg_workaround, timeout);
} }
...@@ -278,27 +278,27 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) ...@@ -278,27 +278,27 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
* devctl. * devctl.
*/ */
musb->int_usb &= ~MUSB_INTR_VBUSERROR; musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n"); WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) { } else if (drvvbus) {
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
otg->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER); portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround); del_timer(&otg_workaround);
} else { } else {
musb->is_active = 0; musb->is_active = 0;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
otg->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
} }
/* NOTE: this must complete power-on within 100 ms. */ /* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off", drvvbus ? "on" : "off",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "", err ? " ERROR" : "",
devctl); devctl);
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
...@@ -324,7 +324,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) ...@@ -324,7 +324,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
} }
/* Poll for ID change */ /* Poll for ID change */
if (musb->xceiv->state == OTG_STATE_B_IDLE) if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
......
...@@ -185,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci) ...@@ -185,8 +185,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
} }
/* Start sampling ID pin, when plug is removed from MUSB */ /* Start sampling ID pin, when plug is removed from MUSB */
if ((musb->xceiv->state == OTG_STATE_B_IDLE if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE
|| musb->xceiv->state == OTG_STATE_A_WAIT_BCON) || || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) ||
(musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) { (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) {
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
musb->a_wait_bcon = TIMER_DELAY; musb->a_wait_bcon = TIMER_DELAY;
...@@ -205,7 +205,7 @@ static void musb_conn_timer_handler(unsigned long _musb) ...@@ -205,7 +205,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
static u8 toggle; static u8 toggle;
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
/* Start a new session */ /* Start a new session */
...@@ -219,7 +219,7 @@ static void musb_conn_timer_handler(unsigned long _musb) ...@@ -219,7 +219,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
if (!(val & MUSB_DEVCTL_BDEVICE)) { if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1); gpio_set_value(musb->config->gpio_vrsel, 1);
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else { } else {
gpio_set_value(musb->config->gpio_vrsel, 0); gpio_set_value(musb->config->gpio_vrsel, 0);
/* Ignore VBUSERROR and SUSPEND IRQ */ /* Ignore VBUSERROR and SUSPEND IRQ */
...@@ -229,7 +229,7 @@ static void musb_conn_timer_handler(unsigned long _musb) ...@@ -229,7 +229,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR; val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
musb_writeb(musb->mregs, MUSB_INTRUSB, val); musb_writeb(musb->mregs, MUSB_INTRUSB, val);
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
} }
mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
break; break;
...@@ -245,7 +245,7 @@ static void musb_conn_timer_handler(unsigned long _musb) ...@@ -245,7 +245,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
if (!(val & MUSB_DEVCTL_BDEVICE)) { if (!(val & MUSB_DEVCTL_BDEVICE)) {
gpio_set_value(musb->config->gpio_vrsel, 1); gpio_set_value(musb->config->gpio_vrsel, 1);
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
} else { } else {
gpio_set_value(musb->config->gpio_vrsel, 0); gpio_set_value(musb->config->gpio_vrsel, 0);
...@@ -280,13 +280,13 @@ static void musb_conn_timer_handler(unsigned long _musb) ...@@ -280,13 +280,13 @@ static void musb_conn_timer_handler(unsigned long _musb)
break; break;
default: default:
dev_dbg(musb->controller, "%s state not handled\n", dev_dbg(musb->controller, "%s state not handled\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
break; break;
} }
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
dev_dbg(musb->controller, "state is %s\n", dev_dbg(musb->controller, "state is %s\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
} }
static void bfin_musb_enable(struct musb *musb) static void bfin_musb_enable(struct musb *musb)
...@@ -307,7 +307,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on) ...@@ -307,7 +307,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on)
dev_dbg(musb->controller, "VBUS %s, devctl %02x " dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n", /* otg %3x conf %08x prcm %08x */ "\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL)); musb_readb(musb->mregs, MUSB_DEVCTL));
} }
......
...@@ -198,20 +198,20 @@ static void otg_timer(unsigned long _musb) ...@@ -198,20 +198,20 @@ static void otg_timer(unsigned long _musb)
*/ */
devctl = musb_readb(mregs, MUSB_DEVCTL); devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
devctl &= ~MUSB_DEVCTL_SESSION; devctl &= ~MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) { if (devctl & MUSB_DEVCTL_BDEVICE) {
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
} else { } else {
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
} }
break; break;
...@@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb) ...@@ -226,7 +226,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break; break;
} }
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG, musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT); MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
break; break;
...@@ -248,7 +248,7 @@ static void otg_timer(unsigned long _musb) ...@@ -248,7 +248,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE) if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else else
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break; break;
default: default:
break; break;
...@@ -265,9 +265,9 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -265,9 +265,9 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
/* Never idle if active, or when VBUS timeout is not set as host */ /* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 && if (musb->is_active || (musb->a_wait_bcon == 0 &&
musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n", dev_dbg(musb->controller, "%s active, deleting timer\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&otg_workaround); del_timer(&otg_workaround);
last_timer = jiffies; last_timer = jiffies;
return; return;
...@@ -280,7 +280,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -280,7 +280,7 @@ static void da8xx_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout; last_timer = timeout;
dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies)); jiffies_to_msecs(timeout - jiffies));
mod_timer(&otg_workaround, timeout); mod_timer(&otg_workaround, timeout);
} }
...@@ -341,26 +341,26 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) ...@@ -341,26 +341,26 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
* devctl. * devctl.
*/ */
musb->int_usb &= ~MUSB_INTR_VBUSERROR; musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n"); WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) { } else if (drvvbus) {
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
otg->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER); portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround); del_timer(&otg_workaround);
} else { } else {
musb->is_active = 0; musb->is_active = 0;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
otg->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
} }
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off", drvvbus ? "on" : "off",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "", err ? " ERROR" : "",
devctl); devctl);
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
...@@ -375,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) ...@@ -375,7 +375,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0); musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
/* Poll for ID change */ /* Poll for ID change */
if (musb->xceiv->state == OTG_STATE_B_IDLE) if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
......
...@@ -214,10 +214,10 @@ static void otg_timer(unsigned long _musb) ...@@ -214,10 +214,10 @@ static void otg_timer(unsigned long _musb)
*/ */
devctl = musb_readb(mregs, MUSB_DEVCTL); devctl = musb_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl, dev_dbg(musb->controller, "poll devctl %02x (%s)\n", devctl,
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VFALL: case OTG_STATE_A_WAIT_VFALL:
/* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL /* Wait till VBUS falls below SessionEnd (~0.2V); the 1.3 RTL
* seems to mis-handle session "start" otherwise (or in our * seems to mis-handle session "start" otherwise (or in our
...@@ -228,7 +228,7 @@ static void otg_timer(unsigned long _musb) ...@@ -228,7 +228,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
break; break;
} }
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG, musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG,
MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT); MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT);
break; break;
...@@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb) ...@@ -251,7 +251,7 @@ static void otg_timer(unsigned long _musb)
if (devctl & MUSB_DEVCTL_BDEVICE) if (devctl & MUSB_DEVCTL_BDEVICE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
else else
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break; break;
default: default:
break; break;
...@@ -325,20 +325,20 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) ...@@ -325,20 +325,20 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
* to stop registering in devctl. * to stop registering in devctl.
*/ */
musb->int_usb &= ~MUSB_INTR_VBUSERROR; musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
WARNING("VBUS error workaround (delay coming)\n"); WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) { } else if (drvvbus) {
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
otg->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
portstate(musb->port1_status |= USB_PORT_STAT_POWER); portstate(musb->port1_status |= USB_PORT_STAT_POWER);
del_timer(&otg_workaround); del_timer(&otg_workaround);
} else { } else {
musb->is_active = 0; musb->is_active = 0;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
otg->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
} }
...@@ -348,7 +348,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) ...@@ -348,7 +348,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
davinci_musb_source_power(musb, drvvbus, 0); davinci_musb_source_power(musb, drvvbus, 0);
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off", drvvbus ? "on" : "off",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "", err ? " ERROR" : "",
devctl); devctl);
retval = IRQ_HANDLED; retval = IRQ_HANDLED;
...@@ -361,7 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) ...@@ -361,7 +361,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
musb_writel(tibase, DAVINCI_USB_EOI_REG, 0); musb_writel(tibase, DAVINCI_USB_EOI_REG, 0);
/* poll for ID change */ /* poll for ID change */
if (musb->xceiv->state == OTG_STATE_B_IDLE) if (musb->xceiv->otg->state == OTG_STATE_B_IDLE)
mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
......
This diff is collapsed.
...@@ -179,9 +179,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -179,9 +179,9 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
/* Never idle if active, or when VBUS timeout is not set as host */ /* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || (musb->a_wait_bcon == 0 && if (musb->is_active || (musb->a_wait_bcon == 0 &&
musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)) {
dev_dbg(musb->controller, "%s active, deleting timer\n", dev_dbg(musb->controller, "%s active, deleting timer\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&glue->timer); del_timer(&glue->timer);
glue->last_timer = jiffies; glue->last_timer = jiffies;
return; return;
...@@ -201,7 +201,7 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -201,7 +201,7 @@ static void dsps_musb_try_idle(struct musb *musb, unsigned long timeout)
glue->last_timer = timeout; glue->last_timer = timeout;
dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n", dev_dbg(musb->controller, "%s inactive, starting idle timer for %u ms\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
jiffies_to_msecs(timeout - jiffies)); jiffies_to_msecs(timeout - jiffies));
mod_timer(&glue->timer, timeout); mod_timer(&glue->timer, timeout);
} }
...@@ -265,10 +265,10 @@ static void otg_timer(unsigned long _musb) ...@@ -265,10 +265,10 @@ static void otg_timer(unsigned long _musb)
*/ */
devctl = dsps_readb(mregs, MUSB_DEVCTL); devctl = dsps_readb(mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl, dev_dbg(musb->controller, "Poll devctl %02x (%s)\n", devctl,
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
dsps_writeb(musb->mregs, MUSB_DEVCTL, 0); dsps_writeb(musb->mregs, MUSB_DEVCTL, 0);
skip_session = 1; skip_session = 1;
...@@ -277,10 +277,10 @@ static void otg_timer(unsigned long _musb) ...@@ -277,10 +277,10 @@ static void otg_timer(unsigned long _musb)
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
if (devctl & MUSB_DEVCTL_BDEVICE) { if (devctl & MUSB_DEVCTL_BDEVICE) {
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
} else { } else {
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
} }
if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session) if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session)
...@@ -288,7 +288,7 @@ static void otg_timer(unsigned long _musb) ...@@ -288,7 +288,7 @@ static void otg_timer(unsigned long _musb)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
break; break;
case OTG_STATE_A_WAIT_VFALL: case OTG_STATE_A_WAIT_VFALL:
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
dsps_writel(musb->ctrl_base, wrp->coreintr_set, dsps_writel(musb->ctrl_base, wrp->coreintr_set,
MUSB_INTR_VBUSERROR << wrp->usb_shift); MUSB_INTR_VBUSERROR << wrp->usb_shift);
break; break;
...@@ -373,26 +373,26 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) ...@@ -373,26 +373,26 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
* devctl. * devctl.
*/ */
musb->int_usb &= ~MUSB_INTR_VBUSERROR; musb->int_usb &= ~MUSB_INTR_VBUSERROR;
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
mod_timer(&glue->timer, mod_timer(&glue->timer,
jiffies + wrp->poll_seconds * HZ); jiffies + wrp->poll_seconds * HZ);
WARNING("VBUS error workaround (delay coming)\n"); WARNING("VBUS error workaround (delay coming)\n");
} else if (drvvbus) { } else if (drvvbus) {
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1; musb->xceiv->otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
del_timer(&glue->timer); del_timer(&glue->timer);
} else { } else {
musb->is_active = 0; musb->is_active = 0;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0; musb->xceiv->otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
} }
/* NOTE: this must complete power-on within 100 ms. */ /* NOTE: this must complete power-on within 100 ms. */
dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n", dev_dbg(musb->controller, "VBUS %s (%s)%s, devctl %02x\n",
drvvbus ? "on" : "off", drvvbus ? "on" : "off",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
err ? " ERROR" : "", err ? " ERROR" : "",
devctl); devctl);
ret = IRQ_HANDLED; ret = IRQ_HANDLED;
...@@ -402,7 +402,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) ...@@ -402,7 +402,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci)
ret |= musb_interrupt(musb); ret |= musb_interrupt(musb);
/* Poll for ID change in OTG port mode */ /* Poll for ID change in OTG port mode */
if (musb->xceiv->state == OTG_STATE_B_IDLE && if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
out: out:
...@@ -900,7 +900,7 @@ static int dsps_resume(struct device *dev) ...@@ -900,7 +900,7 @@ static int dsps_resume(struct device *dev)
dsps_writel(mbase, wrp->mode, glue->context.mode); dsps_writel(mbase, wrp->mode, glue->context.mode);
dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode); dsps_writel(mbase, wrp->tx_mode, glue->context.tx_mode);
dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode); dsps_writel(mbase, wrp->rx_mode, glue->context.rx_mode);
if (musb->xceiv->state == OTG_STATE_B_IDLE && if (musb->xceiv->otg->state == OTG_STATE_B_IDLE &&
musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE)
mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ); mod_timer(&glue->timer, jiffies + wrp->poll_seconds * HZ);
......
...@@ -1546,7 +1546,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) ...@@ -1546,7 +1546,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
/* NOTE: OTG state machine doesn't include B_SUSPENDED; /* NOTE: OTG state machine doesn't include B_SUSPENDED;
* that's part of the standard usb 1.1 state machine, and * that's part of the standard usb 1.1 state machine, and
...@@ -1587,7 +1587,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) ...@@ -1587,7 +1587,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget)
goto done; goto done;
default: default:
dev_dbg(musb->controller, "Unhandled wake: %s\n", dev_dbg(musb->controller, "Unhandled wake: %s\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
goto done; goto done;
} }
...@@ -1791,7 +1791,7 @@ int musb_gadget_setup(struct musb *musb) ...@@ -1791,7 +1791,7 @@ int musb_gadget_setup(struct musb *musb)
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
musb->xceiv->otg->default_a = 0; musb->xceiv->otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
/* this "gadget" abstracts/virtualizes the controller */ /* this "gadget" abstracts/virtualizes the controller */
musb->g.name = musb_driver_name; musb->g.name = musb_driver_name;
...@@ -1857,7 +1857,7 @@ static int musb_gadget_start(struct usb_gadget *g, ...@@ -1857,7 +1857,7 @@ static int musb_gadget_start(struct usb_gadget *g,
musb->is_active = 1; musb->is_active = 1;
otg_set_peripheral(otg, &musb->g); otg_set_peripheral(otg, &musb->g);
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
musb_start(musb); musb_start(musb);
...@@ -1941,7 +1941,7 @@ static int musb_gadget_stop(struct usb_gadget *g) ...@@ -1941,7 +1941,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
(void) musb_gadget_vbus_draw(&musb->g, 0); (void) musb_gadget_vbus_draw(&musb->g, 0);
musb->xceiv->state = OTG_STATE_UNDEFINED; musb->xceiv->otg->state = OTG_STATE_UNDEFINED;
stop_activity(musb, NULL); stop_activity(musb, NULL);
otg_set_peripheral(musb->xceiv->otg, NULL); otg_set_peripheral(musb->xceiv->otg, NULL);
...@@ -1968,7 +1968,7 @@ static int musb_gadget_stop(struct usb_gadget *g) ...@@ -1968,7 +1968,7 @@ static int musb_gadget_stop(struct usb_gadget *g)
void musb_g_resume(struct musb *musb) void musb_g_resume(struct musb *musb)
{ {
musb->is_suspended = 0; musb->is_suspended = 0;
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
break; break;
case OTG_STATE_B_WAIT_ACON: case OTG_STATE_B_WAIT_ACON:
...@@ -1982,7 +1982,7 @@ void musb_g_resume(struct musb *musb) ...@@ -1982,7 +1982,7 @@ void musb_g_resume(struct musb *musb)
break; break;
default: default:
WARNING("unhandled RESUME transition (%s)\n", WARNING("unhandled RESUME transition (%s)\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
} }
} }
...@@ -1994,10 +1994,10 @@ void musb_g_suspend(struct musb *musb) ...@@ -1994,10 +1994,10 @@ void musb_g_suspend(struct musb *musb)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
dev_dbg(musb->controller, "devctl %02x\n", devctl); dev_dbg(musb->controller, "devctl %02x\n", devctl);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
musb->xceiv->state = OTG_STATE_B_PERIPHERAL; musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
break; break;
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
musb->is_suspended = 1; musb->is_suspended = 1;
...@@ -2012,7 +2012,7 @@ void musb_g_suspend(struct musb *musb) ...@@ -2012,7 +2012,7 @@ void musb_g_suspend(struct musb *musb)
* A_PERIPHERAL may need care too * A_PERIPHERAL may need care too
*/ */
WARNING("unhandled SUSPEND transition (%s)\n", WARNING("unhandled SUSPEND transition (%s)\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
} }
} }
...@@ -2043,22 +2043,22 @@ void musb_g_disconnect(struct musb *musb) ...@@ -2043,22 +2043,22 @@ void musb_g_disconnect(struct musb *musb)
spin_lock(&musb->lock); spin_lock(&musb->lock);
} }
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
default: default:
dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n", dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
break; break;
case OTG_STATE_A_PERIPHERAL: case OTG_STATE_A_PERIPHERAL:
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
break; break;
case OTG_STATE_B_WAIT_ACON: case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_HOST: case OTG_STATE_B_HOST:
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break; break;
case OTG_STATE_B_SRP_INIT: case OTG_STATE_B_SRP_INIT:
break; break;
...@@ -2118,13 +2118,13 @@ __acquires(musb->lock) ...@@ -2118,13 +2118,13 @@ __acquires(musb->lock)
* In that case, do not rely on devctl for setting * In that case, do not rely on devctl for setting
* peripheral mode. * peripheral mode.
*/ */
musb->xceiv->state = OTG_STATE_B_PERIPHERAL; musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0; musb->g.is_a_peripheral = 0;
} else if (devctl & MUSB_DEVCTL_BDEVICE) { } else if (devctl & MUSB_DEVCTL_BDEVICE) {
musb->xceiv->state = OTG_STATE_B_PERIPHERAL; musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
musb->g.is_a_peripheral = 0; musb->g.is_a_peripheral = 0;
} else { } else {
musb->xceiv->state = OTG_STATE_A_PERIPHERAL; musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1; musb->g.is_a_peripheral = 1;
} }
......
...@@ -2463,7 +2463,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd) ...@@ -2463,7 +2463,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
if (!is_host_active(musb)) if (!is_host_active(musb))
return 0; return 0;
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
return 0; return 0;
case OTG_STATE_A_WAIT_VRISE: case OTG_STATE_A_WAIT_VRISE:
...@@ -2473,7 +2473,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd) ...@@ -2473,7 +2473,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
*/ */
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS)
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
break; break;
default: default:
break; break;
...@@ -2481,7 +2481,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd) ...@@ -2481,7 +2481,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
if (musb->is_active) { if (musb->is_active) {
WARNING("trying to suspend as %s while active\n", WARNING("trying to suspend as %s while active\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
return -EBUSY; return -EBUSY;
} else } else
return 0; return 0;
...@@ -2678,7 +2678,7 @@ int musb_host_setup(struct musb *musb, int power_budget) ...@@ -2678,7 +2678,7 @@ int musb_host_setup(struct musb *musb, int power_budget)
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
musb->xceiv->otg->default_a = 1; musb->xceiv->otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
otg_set_host(musb->xceiv->otg, &hcd->self); otg_set_host(musb->xceiv->otg, &hcd->self);
hcd->self.otg_port = 1; hcd->self.otg_port = 1;
......
...@@ -69,7 +69,7 @@ void musb_host_finish_resume(struct work_struct *work) ...@@ -69,7 +69,7 @@ void musb_host_finish_resume(struct work_struct *work)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16; musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd); usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */ /* NOTE: it might really be A_WAIT_BCON ... */
musb->xceiv->state = OTG_STATE_A_HOST; musb->xceiv->otg->state = OTG_STATE_A_HOST;
spin_unlock_irqrestore(&musb->lock, flags); spin_unlock_irqrestore(&musb->lock, flags);
} }
...@@ -107,9 +107,9 @@ void musb_port_suspend(struct musb *musb, bool do_suspend) ...@@ -107,9 +107,9 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
dev_dbg(musb->controller, "Root port suspended, power %02x\n", power); dev_dbg(musb->controller, "Root port suspended, power %02x\n", power);
musb->port1_status |= USB_PORT_STAT_SUSPEND; musb->port1_status |= USB_PORT_STAT_SUSPEND;
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
musb->xceiv->state = OTG_STATE_A_SUSPEND; musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
musb->is_active = otg->host->b_hnp_enable; musb->is_active = otg->host->b_hnp_enable;
if (musb->is_active) if (musb->is_active)
mod_timer(&musb->otg_timer, jiffies mod_timer(&musb->otg_timer, jiffies
...@@ -118,13 +118,13 @@ void musb_port_suspend(struct musb *musb, bool do_suspend) ...@@ -118,13 +118,13 @@ void musb_port_suspend(struct musb *musb, bool do_suspend)
musb_platform_try_idle(musb, 0); musb_platform_try_idle(musb, 0);
break; break;
case OTG_STATE_B_HOST: case OTG_STATE_B_HOST:
musb->xceiv->state = OTG_STATE_B_WAIT_ACON; musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
musb->is_active = otg->host->b_hnp_enable; musb->is_active = otg->host->b_hnp_enable;
musb_platform_try_idle(musb, 0); musb_platform_try_idle(musb, 0);
break; break;
default: default:
dev_dbg(musb->controller, "bogus rh suspend? %s\n", dev_dbg(musb->controller, "bogus rh suspend? %s\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
} }
} else if (power & MUSB_POWER_SUSPENDM) { } else if (power & MUSB_POWER_SUSPENDM) {
power &= ~MUSB_POWER_SUSPENDM; power &= ~MUSB_POWER_SUSPENDM;
...@@ -145,7 +145,7 @@ void musb_port_reset(struct musb *musb, bool do_reset) ...@@ -145,7 +145,7 @@ void musb_port_reset(struct musb *musb, bool do_reset)
u8 power; u8 power;
void __iomem *mbase = musb->mregs; void __iomem *mbase = musb->mregs;
if (musb->xceiv->state == OTG_STATE_B_IDLE) { if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) {
dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n"); dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n");
musb->port1_status &= ~USB_PORT_STAT_RESET; musb->port1_status &= ~USB_PORT_STAT_RESET;
return; return;
...@@ -224,24 +224,24 @@ void musb_root_disconnect(struct musb *musb) ...@@ -224,24 +224,24 @@ void musb_root_disconnect(struct musb *musb)
usb_hcd_poll_rh_status(musb->hcd); usb_hcd_poll_rh_status(musb->hcd);
musb->is_active = 0; musb->is_active = 0;
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
if (otg->host->b_hnp_enable) { if (otg->host->b_hnp_enable) {
musb->xceiv->state = OTG_STATE_A_PERIPHERAL; musb->xceiv->otg->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1; musb->g.is_a_peripheral = 1;
break; break;
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0; musb->is_active = 0;
break; break;
case OTG_STATE_A_WAIT_VFALL: case OTG_STATE_A_WAIT_VFALL:
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break; break;
default: default:
dev_dbg(musb->controller, "host disconnect (%s)\n", dev_dbg(musb->controller, "host disconnect (%s)\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
} }
} }
......
...@@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb) ...@@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb)
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) { if (devctl & MUSB_DEVCTL_BDEVICE) {
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
} else { } else {
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
} }
break; break;
...@@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb) ...@@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb)
musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16; musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
usb_hcd_poll_rh_status(musb->hcd); usb_hcd_poll_rh_status(musb->hcd);
/* NOTE: it might really be A_WAIT_BCON ... */ /* NOTE: it might really be A_WAIT_BCON ... */
musb->xceiv->state = OTG_STATE_A_HOST; musb->xceiv->otg->state = OTG_STATE_A_HOST;
} }
break; break;
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) if (devctl & MUSB_DEVCTL_BDEVICE)
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
else else
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
default: default:
break; break;
} }
...@@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
/* Never idle if active, or when VBUS timeout is not set as host */ /* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0) if (musb->is_active || ((musb->a_wait_bcon == 0)
&& (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) { && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n", dev_dbg(musb->controller, "%s active, deleting timer\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer); del_timer(&musb_idle_timer);
last_timer = jiffies; last_timer = jiffies;
return; return;
...@@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout; last_timer = timeout;
dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n", dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies)); (unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout); mod_timer(&musb_idle_timer, timeout);
} }
...@@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) ...@@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (is_on) { if (is_on) {
if (musb->xceiv->state == OTG_STATE_A_IDLE) { if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
int loops = 100; int loops = 100;
/* start the session */ /* start the session */
devctl |= MUSB_DEVCTL_SESSION; devctl |= MUSB_DEVCTL_SESSION;
...@@ -180,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) ...@@ -180,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
} else { } else {
musb->is_active = 1; musb->is_active = 1;
otg->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION; devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
} }
...@@ -192,7 +192,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) ...@@ -192,7 +192,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
*/ */
otg->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
devctl &= ~MUSB_DEVCTL_SESSION; devctl &= ~MUSB_DEVCTL_SESSION;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
...@@ -201,7 +201,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) ...@@ -201,7 +201,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
dev_dbg(musb->controller, "VBUS %s, devctl %02x " dev_dbg(musb->controller, "VBUS %s, devctl %02x "
/* otg %3x conf %08x prcm %08x */ "\n", /* otg %3x conf %08x prcm %08x */ "\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL)); musb_readb(musb->mregs, MUSB_DEVCTL));
} }
...@@ -266,7 +266,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue) ...@@ -266,7 +266,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "ID GND\n"); dev_dbg(dev, "ID GND\n");
otg->default_a = true; otg->default_a = true;
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
musb->xceiv->last_event = USB_EVENT_ID; musb->xceiv->last_event = USB_EVENT_ID;
if (musb->gadget_driver) { if (musb->gadget_driver) {
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
...@@ -280,7 +280,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue) ...@@ -280,7 +280,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
dev_dbg(dev, "VBUS Connect\n"); dev_dbg(dev, "VBUS Connect\n");
otg->default_a = false; otg->default_a = false;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->xceiv->last_event = USB_EVENT_VBUS; musb->xceiv->last_event = USB_EVENT_VBUS;
if (musb->gadget_driver) if (musb->gadget_driver)
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
......
...@@ -415,13 +415,13 @@ static void musb_do_idle(unsigned long _musb) ...@@ -415,13 +415,13 @@ static void musb_do_idle(unsigned long _musb)
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
if ((musb->a_wait_bcon != 0) if ((musb->a_wait_bcon != 0)
&& (musb->idle_timeout == 0 && (musb->idle_timeout == 0
|| time_after(jiffies, musb->idle_timeout))) { || time_after(jiffies, musb->idle_timeout))) {
dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n", dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
...@@ -474,9 +474,9 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -474,9 +474,9 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
/* Never idle if active, or when VBUS timeout is not set as host */ /* Never idle if active, or when VBUS timeout is not set as host */
if (musb->is_active || ((musb->a_wait_bcon == 0) if (musb->is_active || ((musb->a_wait_bcon == 0)
&& (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) { && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
dev_dbg(musb->controller, "%s active, deleting timer\n", dev_dbg(musb->controller, "%s active, deleting timer\n",
usb_otg_state_string(musb->xceiv->state)); usb_otg_state_string(musb->xceiv->otg->state));
del_timer(&musb_idle_timer); del_timer(&musb_idle_timer);
last_timer = jiffies; last_timer = jiffies;
return; return;
...@@ -493,7 +493,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout) ...@@ -493,7 +493,7 @@ static void tusb_musb_try_idle(struct musb *musb, unsigned long timeout)
last_timer = timeout; last_timer = timeout;
dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n", dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
(unsigned long)jiffies_to_msecs(timeout - jiffies)); (unsigned long)jiffies_to_msecs(timeout - jiffies));
mod_timer(&musb_idle_timer, timeout); mod_timer(&musb_idle_timer, timeout);
} }
...@@ -524,7 +524,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) ...@@ -524,7 +524,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
if (is_on) { if (is_on) {
timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE); timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
otg->default_a = 1; otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION; devctl |= MUSB_DEVCTL_SESSION;
conf |= TUSB_DEV_CONF_USB_HOST_MODE; conf |= TUSB_DEV_CONF_USB_HOST_MODE;
...@@ -537,16 +537,16 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) ...@@ -537,16 +537,16 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
/* If ID pin is grounded, we want to be a_idle */ /* If ID pin is grounded, we want to be a_idle */
otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) { if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE: case OTG_STATE_A_WAIT_VRISE:
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
break; break;
case OTG_STATE_A_WAIT_VFALL: case OTG_STATE_A_WAIT_VFALL:
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
break; break;
default: default:
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->otg->state = OTG_STATE_A_IDLE;
} }
musb->is_active = 0; musb->is_active = 0;
otg->default_a = 1; otg->default_a = 1;
...@@ -554,7 +554,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) ...@@ -554,7 +554,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
} else { } else {
musb->is_active = 0; musb->is_active = 0;
otg->default_a = 0; otg->default_a = 0;
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
MUSB_DEV_MODE(musb); MUSB_DEV_MODE(musb);
} }
...@@ -569,7 +569,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) ...@@ -569,7 +569,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n", dev_dbg(musb->controller, "VBUS %s, devctl %02x otg %3x conf %08x prcm %08x\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL), musb_readb(musb->mregs, MUSB_DEVCTL),
musb_readl(tbase, TUSB_DEV_OTG_STAT), musb_readl(tbase, TUSB_DEV_OTG_STAT),
conf, prcm); conf, prcm);
...@@ -668,23 +668,23 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -668,23 +668,23 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) { if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n"); dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n");
if (musb->xceiv->state != OTG_STATE_B_IDLE) { if (musb->xceiv->otg->state != OTG_STATE_B_IDLE) {
/* INTR_DISCONNECT can hide... */ /* INTR_DISCONNECT can hide... */
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
musb->int_usb |= MUSB_INTR_DISCONNECT; musb->int_usb |= MUSB_INTR_DISCONNECT;
} }
musb->is_active = 0; musb->is_active = 0;
} }
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n", dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
usb_otg_state_string(musb->xceiv->state), otg_stat); usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
idle_timeout = jiffies + (1 * HZ); idle_timeout = jiffies + (1 * HZ);
schedule_work(&musb->irq_work); schedule_work(&musb->irq_work);
} else /* A-dev state machine */ { } else /* A-dev state machine */ {
dev_dbg(musb->controller, "vbus change, %s, otg %03x\n", dev_dbg(musb->controller, "vbus change, %s, otg %03x\n",
usb_otg_state_string(musb->xceiv->state), otg_stat); usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
dev_dbg(musb->controller, "Got SRP, turning on VBUS\n"); dev_dbg(musb->controller, "Got SRP, turning on VBUS\n");
musb_platform_set_vbus(musb, 1); musb_platform_set_vbus(musb, 1);
...@@ -731,9 +731,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -731,9 +731,9 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
u8 devctl; u8 devctl;
dev_dbg(musb->controller, "%s timer, %03x\n", dev_dbg(musb->controller, "%s timer, %03x\n",
usb_otg_state_string(musb->xceiv->state), otg_stat); usb_otg_state_string(musb->xceiv->otg->state), otg_stat);
switch (musb->xceiv->state) { switch (musb->xceiv->otg->state) {
case OTG_STATE_A_WAIT_VRISE: case OTG_STATE_A_WAIT_VRISE:
/* VBUS has probably been valid for a while now, /* VBUS has probably been valid for a while now,
* but may well have bounced out of range a bit * but may well have bounced out of range a bit
...@@ -745,7 +745,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -745,7 +745,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
dev_dbg(musb->controller, "devctl %02x\n", devctl); dev_dbg(musb->controller, "devctl %02x\n", devctl);
break; break;
} }
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
musb->is_active = 0; musb->is_active = 0;
idle_timeout = jiffies idle_timeout = jiffies
+ msecs_to_jiffies(musb->a_wait_bcon); + msecs_to_jiffies(musb->a_wait_bcon);
......
...@@ -56,7 +56,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on) ...@@ -56,7 +56,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (is_on) { if (is_on) {
if (musb->xceiv->state == OTG_STATE_A_IDLE) { if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
/* start the session */ /* start the session */
devctl |= MUSB_DEVCTL_SESSION; devctl |= MUSB_DEVCTL_SESSION;
musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
...@@ -76,7 +76,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on) ...@@ -76,7 +76,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
} else { } else {
musb->is_active = 1; musb->is_active = 1;
musb->xceiv->otg->default_a = 1; musb->xceiv->otg->default_a = 1;
musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
devctl |= MUSB_DEVCTL_SESSION; devctl |= MUSB_DEVCTL_SESSION;
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
} }
...@@ -102,7 +102,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on) ...@@ -102,7 +102,7 @@ static void ux500_musb_set_vbus(struct musb *musb, int is_on)
mdelay(200); mdelay(200);
dev_dbg(musb->controller, "VBUS %s, devctl %02x\n", dev_dbg(musb->controller, "VBUS %s, devctl %02x\n",
usb_otg_state_string(musb->xceiv->state), usb_otg_state_string(musb->xceiv->otg->state),
musb_readb(musb->mregs, MUSB_DEVCTL)); musb_readb(musb->mregs, MUSB_DEVCTL));
} }
...@@ -112,7 +112,7 @@ static int musb_otg_notifications(struct notifier_block *nb, ...@@ -112,7 +112,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
struct musb *musb = container_of(nb, struct musb, nb); struct musb *musb = container_of(nb, struct musb, nb);
dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n", dev_dbg(musb->controller, "musb_otg_notifications %ld %s\n",
event, usb_otg_state_string(musb->xceiv->state)); event, usb_otg_state_string(musb->xceiv->otg->state));
switch (event) { switch (event) {
case UX500_MUSB_ID: case UX500_MUSB_ID:
...@@ -127,7 +127,7 @@ static int musb_otg_notifications(struct notifier_block *nb, ...@@ -127,7 +127,7 @@ static int musb_otg_notifications(struct notifier_block *nb,
if (is_host_active(musb)) if (is_host_active(musb))
ux500_musb_set_vbus(musb, 0); ux500_musb_set_vbus(musb, 0);
else else
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->otg->state = OTG_STATE_B_IDLE;
break; break;
default: default:
dev_dbg(musb->controller, "ID float\n"); dev_dbg(musb->controller, "ID float\n");
......
...@@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, ...@@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB) if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE; event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected. */ /* Fallback to default B_IDLE as nothing is connected. */
ab->phy.state = OTG_STATE_B_IDLE; ab->phy.otg->state = OTG_STATE_B_IDLE;
break; break;
case USB_LINK_ACA_RID_C_NM_9540: case USB_LINK_ACA_RID_C_NM_9540:
...@@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, ...@@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing * Fallback to default B_IDLE as nothing
* is connected * is connected
*/ */
ab->phy.state = OTG_STATE_B_IDLE; ab->phy.otg->state = OTG_STATE_B_IDLE;
break; break;
case USB_LINK_ACA_RID_C_NM_8540: case USB_LINK_ACA_RID_C_NM_8540:
...@@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, ...@@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
* Fallback to default B_IDLE as nothing * Fallback to default B_IDLE as nothing
* is connected * is connected
*/ */
ab->phy.state = OTG_STATE_B_IDLE; ab->phy.otg->state = OTG_STATE_B_IDLE;
break; break;
case USB_LINK_ACA_RID_C_NM_8505: case USB_LINK_ACA_RID_C_NM_8505:
...@@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, ...@@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,
if (event != UX500_MUSB_RIDB) if (event != UX500_MUSB_RIDB)
event = UX500_MUSB_NONE; event = UX500_MUSB_NONE;
/* Fallback to default B_IDLE as nothing is connected */ /* Fallback to default B_IDLE as nothing is connected */
ab->phy.state = OTG_STATE_B_IDLE; ab->phy.otg->state = OTG_STATE_B_IDLE;
break; break;
case USB_LINK_ACA_RID_C_NM_8500: case USB_LINK_ACA_RID_C_NM_8500:
...@@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev) ...@@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
ab->phy.label = "ab8500"; ab->phy.label = "ab8500";
ab->phy.set_suspend = ab8500_usb_set_suspend; ab->phy.set_suspend = ab8500_usb_set_suspend;
ab->phy.set_power = ab8500_usb_set_power; ab->phy.set_power = ab8500_usb_set_power;
ab->phy.state = OTG_STATE_UNDEFINED; ab->phy.otg->state = OTG_STATE_UNDEFINED;
otg->phy = &ab->phy; otg->phy = &ab->phy;
otg->set_host = ab8500_usb_set_host; otg->set_host = ab8500_usb_set_host;
......
...@@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) ...@@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
/* Mini-A cable connected */ /* Mini-A cable connected */
struct otg_fsm *fsm = &otg_dev->fsm; struct otg_fsm *fsm = &otg_dev->fsm;
otg->phy->state = OTG_STATE_UNDEFINED; otg.state = OTG_STATE_UNDEFINED;
fsm->protocol = PROTO_UNDEF; fsm->protocol = PROTO_UNDEF;
} }
} }
...@@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA) ...@@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
{ {
if (!fsl_otg_dev) if (!fsl_otg_dev)
return -ENODEV; return -ENODEV;
if (phy->state == OTG_STATE_B_PERIPHERAL) if (phy->otg.state == OTG_STATE_B_PERIPHERAL)
pr_info("FSL OTG: Draw %d mA\n", mA); pr_info("FSL OTG: Draw %d mA\n", mA);
return 0; return 0;
...@@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg) ...@@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
{ {
struct fsl_otg *otg_dev; struct fsl_otg *otg_dev;
if (!otg || otg->phy->state != OTG_STATE_B_IDLE) if (!otg || otg.state != OTG_STATE_B_IDLE)
return -ENODEV; return -ENODEV;
otg_dev = container_of(otg->phy, struct fsl_otg, phy); otg_dev = container_of(otg->phy, struct fsl_otg, phy);
...@@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev) ...@@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev)
* Also: record initial state of ID pin * Also: record initial state of ID pin
*/ */
if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
p_otg->phy.state = OTG_STATE_UNDEFINED; p_otg->phy->otg.state = OTG_STATE_UNDEFINED;
p_otg->fsm.id = 1; p_otg->fsm.id = 1;
} else { } else {
p_otg->phy.state = OTG_STATE_A_IDLE; p_otg->phy->otg.state = OTG_STATE_A_IDLE;
p_otg->fsm.id = 0; p_otg->fsm.id = 0;
} }
......
...@@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) ...@@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
} }
otg->gadget = gadget; otg->gadget = gadget;
otg->phy->state = OTG_STATE_B_IDLE; otg->state = OTG_STATE_B_IDLE;
return 0; return 0;
} }
...@@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop, ...@@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
nop->phy.dev = nop->dev; nop->phy.dev = nop->dev;
nop->phy.label = "nop-xceiv"; nop->phy.label = "nop-xceiv";
nop->phy.set_suspend = nop_set_suspend; nop->phy.set_suspend = nop_set_suspend;
nop->phy.state = OTG_STATE_UNDEFINED;
nop->phy.type = type; nop->phy.type = type;
nop->phy.otg->state = OTG_STATE_UNDEFINED;
nop->phy.otg->phy = &nop->phy; nop->phy.otg->phy = &nop->phy;
nop->phy.otg->set_host = nop_set_host; nop->phy.otg->set_host = nop_set_host;
nop->phy.otg->set_peripheral = nop_set_peripheral; nop->phy.otg->set_peripheral = nop_set_peripheral;
......
...@@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work) ...@@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work)
if (vbus) { if (vbus) {
status = USB_EVENT_VBUS; status = USB_EVENT_VBUS;
gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL; gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL;
gpio_vbus->phy.last_event = status; gpio_vbus->phy.last_event = status;
usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);
...@@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work) ...@@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work)
usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
status = USB_EVENT_NONE; status = USB_EVENT_NONE;
gpio_vbus->phy.state = OTG_STATE_B_IDLE; gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE;
gpio_vbus->phy.last_event = status; gpio_vbus->phy.last_event = status;
atomic_notifier_call_chain(&gpio_vbus->phy.notifier, atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
...@@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg, ...@@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
set_vbus_draw(gpio_vbus, 0); set_vbus_draw(gpio_vbus, 0);
usb_gadget_vbus_disconnect(otg->gadget); usb_gadget_vbus_disconnect(otg->gadget);
otg->phy->state = OTG_STATE_UNDEFINED; otg->state = OTG_STATE_UNDEFINED;
otg->gadget = NULL; otg->gadget = NULL;
return 0; return 0;
...@@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA) ...@@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)
gpio_vbus = container_of(phy, struct gpio_vbus_data, phy); gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);
if (phy->state == OTG_STATE_B_PERIPHERAL) if (phy->otg->state == OTG_STATE_B_PERIPHERAL)
set_vbus_draw(gpio_vbus, mA); set_vbus_draw(gpio_vbus, mA);
return 0; return 0;
} }
...@@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev) ...@@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
gpio_vbus->phy.dev = gpio_vbus->dev; gpio_vbus->phy.dev = gpio_vbus->dev;
gpio_vbus->phy.set_power = gpio_vbus_set_power; gpio_vbus->phy.set_power = gpio_vbus_set_power;
gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend; gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
gpio_vbus->phy.state = OTG_STATE_UNDEFINED;
gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
gpio_vbus->phy.otg->phy = &gpio_vbus->phy; gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral; gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
......
This diff is collapsed.
...@@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) ...@@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
} }
if (!host) { if (!host) {
if (otg->phy->state == OTG_STATE_A_HOST) { if (otg->state == OTG_STATE_A_HOST) {
pm_runtime_get_sync(otg->phy->dev); pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_host(otg->phy, 0); msm_otg_start_host(otg->phy, 0);
otg->host = NULL; otg->host = NULL;
otg->phy->state = OTG_STATE_UNDEFINED; otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work); schedule_work(&motg->sm_work);
} else { } else {
otg->host = NULL; otg->host = NULL;
...@@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg, ...@@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
} }
if (!gadget) { if (!gadget) {
if (otg->phy->state == OTG_STATE_B_PERIPHERAL) { if (otg->state == OTG_STATE_B_PERIPHERAL) {
pm_runtime_get_sync(otg->phy->dev); pm_runtime_get_sync(otg->phy->dev);
msm_otg_start_peripheral(otg->phy, 0); msm_otg_start_peripheral(otg->phy, 0);
otg->gadget = NULL; otg->gadget = NULL;
otg->phy->state = OTG_STATE_UNDEFINED; otg->state = OTG_STATE_UNDEFINED;
schedule_work(&motg->sm_work); schedule_work(&motg->sm_work);
} else { } else {
otg->gadget = NULL; otg->gadget = NULL;
...@@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w) ...@@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w)
struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
struct usb_otg *otg = motg->phy.otg; struct usb_otg *otg = motg->phy.otg;
switch (otg->phy->state) { switch (otg->state) {
case OTG_STATE_UNDEFINED: case OTG_STATE_UNDEFINED:
dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n"); dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
msm_otg_reset(otg->phy); msm_otg_reset(otg->phy);
msm_otg_init_sm(motg); msm_otg_init_sm(motg);
otg->phy->state = OTG_STATE_B_IDLE; otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */ /* FALL THROUGH */
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n"); dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
...@@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w) ...@@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w)
/* disable BSV bit */ /* disable BSV bit */
writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
msm_otg_start_host(otg->phy, 1); msm_otg_start_host(otg->phy, 1);
otg->phy->state = OTG_STATE_A_HOST; otg->state = OTG_STATE_A_HOST;
} else if (test_bit(B_SESS_VLD, &motg->inputs)) { } else if (test_bit(B_SESS_VLD, &motg->inputs)) {
switch (motg->chg_state) { switch (motg->chg_state) {
case USB_CHG_STATE_UNDEFINED: case USB_CHG_STATE_UNDEFINED:
...@@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w) ...@@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_notify_charger(motg, msm_otg_notify_charger(motg,
IDEV_CHG_MAX); IDEV_CHG_MAX);
msm_otg_start_peripheral(otg->phy, 1); msm_otg_start_peripheral(otg->phy, 1);
otg->phy->state otg->state
= OTG_STATE_B_PERIPHERAL; = OTG_STATE_B_PERIPHERAL;
break; break;
case USB_SDP_CHARGER: case USB_SDP_CHARGER:
msm_otg_notify_charger(motg, IUNIT); msm_otg_notify_charger(motg, IUNIT);
msm_otg_start_peripheral(otg->phy, 1); msm_otg_start_peripheral(otg->phy, 1);
otg->phy->state otg->state
= OTG_STATE_B_PERIPHERAL; = OTG_STATE_B_PERIPHERAL;
break; break;
default: default:
...@@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w) ...@@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w)
motg->chg_type = USB_INVALID_CHARGER; motg->chg_type = USB_INVALID_CHARGER;
} }
if (otg->phy->state == OTG_STATE_B_IDLE) if (otg->state == OTG_STATE_B_IDLE)
pm_runtime_put_sync(otg->phy->dev); pm_runtime_put_sync(otg->phy->dev);
break; break;
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
...@@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w) ...@@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w)
msm_otg_start_peripheral(otg->phy, 0); msm_otg_start_peripheral(otg->phy, 0);
motg->chg_state = USB_CHG_STATE_UNDEFINED; motg->chg_state = USB_CHG_STATE_UNDEFINED;
motg->chg_type = USB_INVALID_CHARGER; motg->chg_type = USB_INVALID_CHARGER;
otg->phy->state = OTG_STATE_B_IDLE; otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy); msm_otg_reset(otg->phy);
schedule_work(w); schedule_work(w);
} }
...@@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w) ...@@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w)
dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n"); dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
if (test_bit(ID, &motg->inputs)) { if (test_bit(ID, &motg->inputs)) {
msm_otg_start_host(otg->phy, 0); msm_otg_start_host(otg->phy, 0);
otg->phy->state = OTG_STATE_B_IDLE; otg->state = OTG_STATE_B_IDLE;
msm_otg_reset(otg->phy); msm_otg_reset(otg->phy);
schedule_work(w); schedule_work(w);
} }
...@@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused) ...@@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
struct msm_otg *motg = s->private; struct msm_otg *motg = s->private;
struct usb_otg *otg = motg->phy.otg; struct usb_otg *otg = motg->phy.otg;
switch (otg->phy->state) { switch (otg->state) {
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
seq_puts(s, "host\n"); seq_puts(s, "host\n");
break; break;
...@@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, ...@@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
switch (req_mode) { switch (req_mode) {
case USB_DR_MODE_UNKNOWN: case USB_DR_MODE_UNKNOWN:
switch (otg->phy->state) { switch (otg->state) {
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
set_bit(ID, &motg->inputs); set_bit(ID, &motg->inputs);
...@@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, ...@@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
} }
break; break;
case USB_DR_MODE_PERIPHERAL: case USB_DR_MODE_PERIPHERAL:
switch (otg->phy->state) { switch (otg->state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
set_bit(ID, &motg->inputs); set_bit(ID, &motg->inputs);
...@@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, ...@@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
} }
break; break;
case USB_DR_MODE_HOST: case USB_DR_MODE_HOST:
switch (otg->phy->state) { switch (otg->state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
clear_bit(ID, &motg->inputs); clear_bit(ID, &motg->inputs);
...@@ -1769,7 +1769,7 @@ static int msm_otg_runtime_idle(struct device *dev) ...@@ -1769,7 +1769,7 @@ static int msm_otg_runtime_idle(struct device *dev)
* This 1 sec delay also prevents entering into LPM immediately * This 1 sec delay also prevents entering into LPM immediately
* after asynchronous interrupt. * after asynchronous interrupt.
*/ */
if (otg->phy->state != OTG_STATE_UNDEFINED) if (otg->state != OTG_STATE_UNDEFINED)
pm_schedule_suspend(dev, 1000); pm_schedule_suspend(dev, 1000);
return -EAGAIN; return -EAGAIN;
......
...@@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg) ...@@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
{ {
struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
struct usb_phy *phy = &mvotg->phy; struct usb_phy *phy = &mvotg->phy;
int old_state = phy->state; int old_state = mvotg->phy.otg->state;
switch (old_state) { switch (old_state) {
case OTG_STATE_UNDEFINED: case OTG_STATE_UNDEFINED:
phy->state = OTG_STATE_B_IDLE; mvotg->phy.otg->state = OTG_STATE_B_IDLE;
/* FALL THROUGH */ /* FALL THROUGH */
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
if (otg_ctrl->id == 0) if (otg_ctrl->id == 0)
phy->state = OTG_STATE_A_IDLE; mvotg->phy.otg->state = OTG_STATE_A_IDLE;
else if (otg_ctrl->b_sess_vld) else if (otg_ctrl->b_sess_vld)
phy->state = OTG_STATE_B_PERIPHERAL; mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break; break;
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
phy->state = OTG_STATE_B_IDLE; mvotg->phy.otg->state = OTG_STATE_B_IDLE;
break; break;
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
if (otg_ctrl->id) if (otg_ctrl->id)
phy->state = OTG_STATE_B_IDLE; mvotg->phy.otg->state = OTG_STATE_B_IDLE;
else if (!(otg_ctrl->a_bus_drop) && else if (!(otg_ctrl->a_bus_drop) &&
(otg_ctrl->a_bus_req || otg_ctrl->a_srp_det)) (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
phy->state = OTG_STATE_A_WAIT_VRISE; mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
break; break;
case OTG_STATE_A_WAIT_VRISE: case OTG_STATE_A_WAIT_VRISE:
if (otg_ctrl->a_vbus_vld) if (otg_ctrl->a_vbus_vld)
phy->state = OTG_STATE_A_WAIT_BCON; mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
break; break;
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
if (otg_ctrl->id || otg_ctrl->a_bus_drop if (otg_ctrl->id || otg_ctrl->a_bus_drop
|| otg_ctrl->a_wait_bcon_timeout) { || otg_ctrl->a_wait_bcon_timeout) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0; mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
phy->state = OTG_STATE_A_WAIT_VFALL; mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
otg_ctrl->a_bus_req = 0; otg_ctrl->a_bus_req = 0;
} else if (!otg_ctrl->a_vbus_vld) { } else if (!otg_ctrl->a_vbus_vld) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0; mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
phy->state = OTG_STATE_A_VBUS_ERR; mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
} else if (otg_ctrl->b_conn) { } else if (otg_ctrl->b_conn) {
mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
mvotg->otg_ctrl.a_wait_bcon_timeout = 0; mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
phy->state = OTG_STATE_A_HOST; mvotg->phy.otg->state = OTG_STATE_A_HOST;
} }
break; break;
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
if (otg_ctrl->id || !otg_ctrl->b_conn if (otg_ctrl->id || !otg_ctrl->b_conn
|| otg_ctrl->a_bus_drop) || otg_ctrl->a_bus_drop)
phy->state = OTG_STATE_A_WAIT_BCON; mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
else if (!otg_ctrl->a_vbus_vld) else if (!otg_ctrl->a_vbus_vld)
phy->state = OTG_STATE_A_VBUS_ERR; mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
break; break;
case OTG_STATE_A_WAIT_VFALL: case OTG_STATE_A_WAIT_VFALL:
if (otg_ctrl->id if (otg_ctrl->id
|| (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
|| otg_ctrl->a_bus_req) || otg_ctrl->a_bus_req)
phy->state = OTG_STATE_A_IDLE; mvotg->phy.otg->state = OTG_STATE_A_IDLE;
break; break;
case OTG_STATE_A_VBUS_ERR: case OTG_STATE_A_VBUS_ERR:
if (otg_ctrl->id || otg_ctrl->a_clr_err if (otg_ctrl->id || otg_ctrl->a_clr_err
|| otg_ctrl->a_bus_drop) { || otg_ctrl->a_bus_drop) {
otg_ctrl->a_clr_err = 0; otg_ctrl->a_clr_err = 0;
phy->state = OTG_STATE_A_WAIT_VFALL; mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
} }
break; break;
default: default:
...@@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work) ...@@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work)
run: run:
/* work queue is single thread, or we need spin_lock to protect */ /* work queue is single thread, or we need spin_lock to protect */
phy = &mvotg->phy; phy = &mvotg->phy;
otg = phy->otg; otg = mvotg->phy.otg;
old_state = phy->state; old_state = otg->state;
if (!mvotg->active) if (!mvotg->active)
return; return;
...@@ -429,12 +429,12 @@ static void mv_otg_work(struct work_struct *work) ...@@ -429,12 +429,12 @@ static void mv_otg_work(struct work_struct *work)
mv_otg_update_inputs(mvotg); mv_otg_update_inputs(mvotg);
mv_otg_update_state(mvotg); mv_otg_update_state(mvotg);
if (old_state != phy->state) { if (old_state != mvotg->phy.otg->state) {
dev_info(&mvotg->pdev->dev, "change from state %s to %s\n", dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
state_string[old_state], state_string[old_state],
state_string[phy->state]); state_string[mvotg->phy.otg->state]);
switch (phy->state) { switch (mvotg->phy.otg->state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
otg->default_a = 0; otg->default_a = 0;
if (old_state == OTG_STATE_B_PERIPHERAL) if (old_state == OTG_STATE_B_PERIPHERAL)
...@@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr, ...@@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
return -1; return -1;
/* We will use this interface to change to A device */ /* We will use this interface to change to A device */
if (mvotg->phy.state != OTG_STATE_B_IDLE if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
&& mvotg->phy.state != OTG_STATE_A_IDLE) && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
return -1; return -1;
/* The clock may disabled and we need to set irq for ID detected */ /* The clock may disabled and we need to set irq for ID detected */
...@@ -715,9 +715,9 @@ static int mv_otg_probe(struct platform_device *pdev) ...@@ -715,9 +715,9 @@ static int mv_otg_probe(struct platform_device *pdev)
mvotg->phy.dev = &pdev->dev; mvotg->phy.dev = &pdev->dev;
mvotg->phy.otg = otg; mvotg->phy.otg = otg;
mvotg->phy.label = driver_name; mvotg->phy.label = driver_name;
mvotg->phy.state = OTG_STATE_UNDEFINED;
otg->phy = &mvotg->phy; otg->phy = &mvotg->phy;
otg->state = OTG_STATE_UNDEFINED;
otg->set_host = mv_otg_set_host; otg->set_host = mv_otg_set_host;
otg->set_peripheral = mv_otg_set_peripheral; otg->set_peripheral = mv_otg_set_peripheral;
otg->set_vbus = mv_otg_set_vbus; otg->set_vbus = mv_otg_set_vbus;
......
...@@ -81,33 +81,33 @@ static void check_vbus_state(struct tahvo_usb *tu) ...@@ -81,33 +81,33 @@ static void check_vbus_state(struct tahvo_usb *tu)
reg = retu_read(rdev, TAHVO_REG_IDSR); reg = retu_read(rdev, TAHVO_REG_IDSR);
if (reg & TAHVO_STAT_VBUS) { if (reg & TAHVO_STAT_VBUS) {
switch (tu->phy.state) { switch (tu->phy.otg->state) {
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
/* Enable the gadget driver */ /* Enable the gadget driver */
if (tu->phy.otg->gadget) if (tu->phy.otg->gadget)
usb_gadget_vbus_connect(tu->phy.otg->gadget); usb_gadget_vbus_connect(tu->phy.otg->gadget);
tu->phy.state = OTG_STATE_B_PERIPHERAL; tu->phy.otg->state = OTG_STATE_B_PERIPHERAL;
break; break;
case OTG_STATE_A_IDLE: case OTG_STATE_A_IDLE:
/* /*
* Session is now valid assuming the USB hub is driving * Session is now valid assuming the USB hub is driving
* Vbus. * Vbus.
*/ */
tu->phy.state = OTG_STATE_A_HOST; tu->phy.otg->state = OTG_STATE_A_HOST;
break; break;
default: default:
break; break;
} }
dev_info(&tu->pt_dev->dev, "USB cable connected\n"); dev_info(&tu->pt_dev->dev, "USB cable connected\n");
} else { } else {
switch (tu->phy.state) { switch (tu->phy.otg->state) {
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
if (tu->phy.otg->gadget) if (tu->phy.otg->gadget)
usb_gadget_vbus_disconnect(tu->phy.otg->gadget); usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
tu->phy.state = OTG_STATE_B_IDLE; tu->phy.otg->state = OTG_STATE_B_IDLE;
break; break;
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
tu->phy.state = OTG_STATE_A_IDLE; tu->phy.otg->state = OTG_STATE_A_IDLE;
break; break;
default: default:
break; break;
...@@ -132,14 +132,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu) ...@@ -132,14 +132,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu)
/* Power up the transceiver in USB host mode */ /* Power up the transceiver in USB host mode */
retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
USBR_MASTER_SW2 | USBR_MASTER_SW1); USBR_MASTER_SW2 | USBR_MASTER_SW1);
tu->phy.state = OTG_STATE_A_IDLE; tu->phy.otg->state = OTG_STATE_A_IDLE;
check_vbus_state(tu); check_vbus_state(tu);
} }
static void tahvo_usb_stop_host(struct tahvo_usb *tu) static void tahvo_usb_stop_host(struct tahvo_usb *tu)
{ {
tu->phy.state = OTG_STATE_A_IDLE; tu->phy.otg->state = OTG_STATE_A_IDLE;
} }
static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
...@@ -151,7 +151,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) ...@@ -151,7 +151,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
/* Power up transceiver and set it in USB peripheral mode */ /* Power up transceiver and set it in USB peripheral mode */
retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT |
USBR_NSUSPEND | USBR_SLAVE_SW); USBR_NSUSPEND | USBR_SLAVE_SW);
tu->phy.state = OTG_STATE_B_IDLE; tu->phy.otg->state = OTG_STATE_B_IDLE;
check_vbus_state(tu); check_vbus_state(tu);
} }
...@@ -160,7 +160,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu) ...@@ -160,7 +160,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu)
{ {
if (tu->phy.otg->gadget) if (tu->phy.otg->gadget)
usb_gadget_vbus_disconnect(tu->phy.otg->gadget); usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
tu->phy.state = OTG_STATE_B_IDLE; tu->phy.otg->state = OTG_STATE_B_IDLE;
} }
static void tahvo_usb_power_off(struct tahvo_usb *tu) static void tahvo_usb_power_off(struct tahvo_usb *tu)
...@@ -173,7 +173,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu) ...@@ -173,7 +173,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu)
/* Power off transceiver */ /* Power off transceiver */
retu_write(rdev, TAHVO_REG_USBR, 0); retu_write(rdev, TAHVO_REG_USBR, 0);
tu->phy.state = OTG_STATE_UNDEFINED; tu->phy.otg->state = OTG_STATE_UNDEFINED;
} }
static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend)
...@@ -379,7 +379,7 @@ static int tahvo_usb_probe(struct platform_device *pdev) ...@@ -379,7 +379,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
/* Create OTG interface */ /* Create OTG interface */
tahvo_usb_power_off(tu); tahvo_usb_power_off(tu);
tu->phy.dev = &pdev->dev; tu->phy.dev = &pdev->dev;
tu->phy.state = OTG_STATE_UNDEFINED; tu->phy.otg->state = OTG_STATE_UNDEFINED;
tu->phy.label = DRIVER_NAME; tu->phy.label = DRIVER_NAME;
tu->phy.set_suspend = tahvo_usb_set_suspend; tu->phy.set_suspend = tahvo_usb_set_suspend;
......
...@@ -18,6 +18,8 @@ struct usb_otg { ...@@ -18,6 +18,8 @@ struct usb_otg {
struct usb_bus *host; struct usb_bus *host;
struct usb_gadget *gadget; struct usb_gadget *gadget;
enum usb_otg_state state;
/* bind/unbind the host controller */ /* bind/unbind the host controller */
int (*set_host)(struct usb_otg *otg, struct usb_bus *host); int (*set_host)(struct usb_otg *otg, struct usb_bus *host);
......
...@@ -77,7 +77,6 @@ struct usb_phy { ...@@ -77,7 +77,6 @@ struct usb_phy {
unsigned int flags; unsigned int flags;
enum usb_phy_type type; enum usb_phy_type type;
enum usb_otg_state state;
enum usb_phy_events last_event; enum usb_phy_events last_event;
struct usb_otg *otg; struct usb_otg *otg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment