usb: move the OTG state from the USB PHY to the OTG structure
[pandora-kernel.git] / drivers / usb / musb / musb_core.c
index e46e295..df9c5fa 100644 (file)
@@ -360,23 +360,23 @@ static void musb_otg_timer_func(unsigned long data)
        unsigned long   flags;
 
        spin_lock_irqsave(&musb->lock, flags);
-       switch (musb->xceiv->state) {
+       switch (musb->xceiv->otg->state) {
        case OTG_STATE_B_WAIT_ACON:
                dev_dbg(musb->controller, "HNP: b_wait_acon timeout; back to b_peripheral\n");
                musb_g_disconnect(musb);
-               musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+               musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
                musb->is_active = 0;
                break;
        case OTG_STATE_A_SUSPEND:
        case OTG_STATE_A_WAIT_BCON:
                dev_dbg(musb->controller, "HNP: %s timeout\n",
-                       usb_otg_state_string(musb->xceiv->state));
+                       usb_otg_state_string(musb->xceiv->otg->state));
                musb_platform_set_vbus(musb, 0);
-               musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+               musb->xceiv->otg->state = OTG_STATE_A_WAIT_VFALL;
                break;
        default:
                dev_dbg(musb->controller, "HNP: Unhandled mode %s\n",
-                       usb_otg_state_string(musb->xceiv->state));
+                       usb_otg_state_string(musb->xceiv->otg->state));
        }
        spin_unlock_irqrestore(&musb->lock, flags);
 }
@@ -391,19 +391,19 @@ void musb_hnp_stop(struct musb *musb)
        u8      reg;
 
        dev_dbg(musb->controller, "HNP: stop from %s\n",
-                       usb_otg_state_string(musb->xceiv->state));
+                       usb_otg_state_string(musb->xceiv->otg->state));
 
-       switch (musb->xceiv->state) {
+       switch (musb->xceiv->otg->state) {
        case OTG_STATE_A_PERIPHERAL:
                musb_g_disconnect(musb);
                dev_dbg(musb->controller, "HNP: back to %s\n",
-                       usb_otg_state_string(musb->xceiv->state));
+                       usb_otg_state_string(musb->xceiv->otg->state));
                break;
        case OTG_STATE_B_HOST:
                dev_dbg(musb->controller, "HNP: Disabling HR\n");
                if (hcd)
                        hcd->self.is_b_host = 0;
-               musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+               musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
                MUSB_DEV_MODE(musb);
                reg = musb_readb(mbase, MUSB_POWER);
                reg |= MUSB_POWER_SUSPENDM;
@@ -412,7 +412,7 @@ void musb_hnp_stop(struct musb *musb)
                break;
        default:
                dev_dbg(musb->controller, "HNP: Stopping in unknown state %s\n",
-                       usb_otg_state_string(musb->xceiv->state));
+                       usb_otg_state_string(musb->xceiv->otg->state));
        }
 
        /*
@@ -449,13 +449,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
         */
        if (int_usb & MUSB_INTR_RESUME) {
                handled = IRQ_HANDLED;
-               dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->state));
+               dev_dbg(musb->controller, "RESUME (%s)\n", usb_otg_state_string(musb->xceiv->otg->state));
 
                if (devctl & MUSB_DEVCTL_HM) {
                        void __iomem *mbase = musb->mregs;
                        u8 power;
 
-                       switch (musb->xceiv->state) {
+                       switch (musb->xceiv->otg->state) {
                        case OTG_STATE_A_SUSPEND:
                                /* remote wakeup?  later, GetPortStatus
                                 * will stop RESUME signaling
@@ -482,25 +482,25 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                                        &musb->finish_resume_work,
                                        msecs_to_jiffies(20));
 
-                               musb->xceiv->state = OTG_STATE_A_HOST;
+                               musb->xceiv->otg->state = OTG_STATE_A_HOST;
                                musb->is_active = 1;
                                musb_host_resume_root_hub(musb);
                                break;
                        case OTG_STATE_B_WAIT_ACON:
-                               musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+                               musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
                                musb->is_active = 1;
                                MUSB_DEV_MODE(musb);
                                break;
                        default:
                                WARNING("bogus %s RESUME (%s)\n",
                                        "host",
-                                       usb_otg_state_string(musb->xceiv->state));
+                                       usb_otg_state_string(musb->xceiv->otg->state));
                        }
                } else {
-                       switch (musb->xceiv->state) {
+                       switch (musb->xceiv->otg->state) {
                        case OTG_STATE_A_SUSPEND:
                                /* possibly DISCONNECT is upcoming */
-                               musb->xceiv->state = OTG_STATE_A_HOST;
+                               musb->xceiv->otg->state = OTG_STATE_A_HOST;
                                musb_host_resume_root_hub(musb);
                                break;
                        case OTG_STATE_B_WAIT_ACON:
@@ -523,7 +523,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                        default:
                                WARNING("bogus %s RESUME (%s)\n",
                                        "peripheral",
-                                       usb_otg_state_string(musb->xceiv->state));
+                                       usb_otg_state_string(musb->xceiv->otg->state));
                        }
                }
        }
@@ -539,7 +539,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                }
 
                dev_dbg(musb->controller, "SESSION_REQUEST (%s)\n",
-                       usb_otg_state_string(musb->xceiv->state));
+                       usb_otg_state_string(musb->xceiv->otg->state));
 
                /* IRQ arrives from ID pin sense or (later, if VBUS power
                 * is removed) SRP.  responses are time critical:
@@ -550,7 +550,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                 */
                musb_writeb(mbase, MUSB_DEVCTL, MUSB_DEVCTL_SESSION);
                musb->ep0_stage = MUSB_EP0_START;
-               musb->xceiv->state = OTG_STATE_A_IDLE;
+               musb->xceiv->otg->state = OTG_STATE_A_IDLE;
                MUSB_HST_MODE(musb);
                musb_platform_set_vbus(musb, 1);
 
@@ -576,7 +576,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                 * REVISIT:  do delays from lots of DEBUG_KERNEL checks
                 * make trouble here, keeping VBUS < 4.4V ?
                 */
-               switch (musb->xceiv->state) {
+               switch (musb->xceiv->otg->state) {
                case OTG_STATE_A_HOST:
                        /* recovery is dicey once we've gotten past the
                         * initial stages of enumeration, but if VBUS
@@ -605,7 +605,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
 
                dev_printk(ignore ? KERN_DEBUG : KERN_ERR, musb->controller,
                                "VBUS_ERROR in %s (%02x, %s), retry #%d, port1 %08x\n",
-                               usb_otg_state_string(musb->xceiv->state),
+                               usb_otg_state_string(musb->xceiv->otg->state),
                                devctl,
                                ({ char *s;
                                switch (devctl & MUSB_DEVCTL_VBUS) {
@@ -630,10 +630,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
 
        if (int_usb & MUSB_INTR_SUSPEND) {
                dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n",
-                       usb_otg_state_string(musb->xceiv->state), devctl);
+                       usb_otg_state_string(musb->xceiv->otg->state), devctl);
                handled = IRQ_HANDLED;
 
-               switch (musb->xceiv->state) {
+               switch (musb->xceiv->otg->state) {
                case OTG_STATE_A_PERIPHERAL:
                        /* We also come here if the cable is removed, since
                         * this silicon doesn't report ID-no-longer-grounded.
@@ -657,7 +657,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                        musb_g_suspend(musb);
                        musb->is_active = musb->g.b_hnp_enable;
                        if (musb->is_active) {
-                               musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
+                               musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
                                dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n");
                                mod_timer(&musb->otg_timer, jiffies
                                        + msecs_to_jiffies(
@@ -670,7 +670,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                                        + msecs_to_jiffies(musb->a_wait_bcon));
                        break;
                case OTG_STATE_A_HOST:
-                       musb->xceiv->state = OTG_STATE_A_SUSPEND;
+                       musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
                        musb->is_active = musb->hcd->self.b_hnp_enable;
                        break;
                case OTG_STATE_B_HOST:
@@ -713,7 +713,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                        musb->port1_status |= USB_PORT_STAT_LOW_SPEED;
 
                /* indicate new connection to OTG machine */
-               switch (musb->xceiv->state) {
+               switch (musb->xceiv->otg->state) {
                case OTG_STATE_B_PERIPHERAL:
                        if (int_usb & MUSB_INTR_SUSPEND) {
                                dev_dbg(musb->controller, "HNP: SUSPEND+CONNECT, now b_host\n");
@@ -725,7 +725,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
                case OTG_STATE_B_WAIT_ACON:
                        dev_dbg(musb->controller, "HNP: CONNECT, now b_host\n");
 b_host:
-                       musb->xceiv->state = OTG_STATE_B_HOST;
+                       musb->xceiv->otg->state = OTG_STATE_B_HOST;
                        if (musb->hcd)
                                musb->hcd->self.is_b_host = 1;
                        del_timer(&musb->otg_timer);
@@ -733,7 +733,7 @@ b_host:
                default:
                        if ((devctl & MUSB_DEVCTL_VBUS)
                                        == (3 << MUSB_DEVCTL_VBUS_SHIFT)) {
-                               musb->xceiv->state = OTG_STATE_A_HOST;
+                               musb->xceiv->otg->state = OTG_STATE_A_HOST;
                                if (hcd)
                                        hcd->self.is_b_host = 0;
                        }
@@ -743,16 +743,16 @@ b_host:
                musb_host_poke_root_hub(musb);
 
                dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n",
-                               usb_otg_state_string(musb->xceiv->state), devctl);
+                               usb_otg_state_string(musb->xceiv->otg->state), devctl);
        }
 
        if (int_usb & MUSB_INTR_DISCONNECT) {
                dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n",
-                               usb_otg_state_string(musb->xceiv->state),
+                               usb_otg_state_string(musb->xceiv->otg->state),
                                MUSB_MODE(musb), devctl);
                handled = IRQ_HANDLED;
 
-               switch (musb->xceiv->state) {
+               switch (musb->xceiv->otg->state) {
                case OTG_STATE_A_HOST:
                case OTG_STATE_A_SUSPEND:
                        musb_host_resume_root_hub(musb);
@@ -770,7 +770,7 @@ b_host:
                        musb_root_disconnect(musb);
                        if (musb->hcd)
                                musb->hcd->self.is_b_host = 0;
-                       musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+                       musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
                        MUSB_DEV_MODE(musb);
                        musb_g_disconnect(musb);
                        break;
@@ -786,7 +786,7 @@ b_host:
                        break;
                default:
                        WARNING("unhandled DISCONNECT transition (%s)\n",
-                               usb_otg_state_string(musb->xceiv->state));
+                               usb_otg_state_string(musb->xceiv->otg->state));
                        break;
                }
        }
@@ -812,15 +812,15 @@ b_host:
                        }
                } else {
                        dev_dbg(musb->controller, "BUS RESET as %s\n",
-                               usb_otg_state_string(musb->xceiv->state));
-                       switch (musb->xceiv->state) {
+                               usb_otg_state_string(musb->xceiv->otg->state));
+                       switch (musb->xceiv->otg->state) {
                        case OTG_STATE_A_SUSPEND:
                                musb_g_reset(musb);
                                /* FALLTHROUGH */
                        case OTG_STATE_A_WAIT_BCON:     /* OPT TD.4.7-900ms */
                                /* never use invalid T(a_wait_bcon) */
                                dev_dbg(musb->controller, "HNP: in %s, %d msec timeout\n",
-                                       usb_otg_state_string(musb->xceiv->state),
+                                       usb_otg_state_string(musb->xceiv->otg->state),
                                        TA_WAIT_BCON(musb));
                                mod_timer(&musb->otg_timer, jiffies
                                        + msecs_to_jiffies(TA_WAIT_BCON(musb)));
@@ -831,19 +831,19 @@ b_host:
                                break;
                        case OTG_STATE_B_WAIT_ACON:
                                dev_dbg(musb->controller, "HNP: RESET (%s), to b_peripheral\n",
-                                       usb_otg_state_string(musb->xceiv->state));
-                               musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+                                       usb_otg_state_string(musb->xceiv->otg->state));
+                               musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
                                musb_g_reset(musb);
                                break;
                        case OTG_STATE_B_IDLE:
-                               musb->xceiv->state = OTG_STATE_B_PERIPHERAL;
+                               musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
                                /* FALLTHROUGH */
                        case OTG_STATE_B_PERIPHERAL:
                                musb_g_reset(musb);
                                break;
                        default:
                                dev_dbg(musb->controller, "Unhandled BUS RESET as %s\n",
-                                       usb_otg_state_string(musb->xceiv->state));
+                                       usb_otg_state_string(musb->xceiv->otg->state));
                        }
                }
        }
@@ -1630,7 +1630,7 @@ musb_mode_show(struct device *dev, struct device_attribute *attr, char *buf)
        int ret = -EINVAL;
 
        spin_lock_irqsave(&musb->lock, flags);
-       ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->state));
+       ret = sprintf(buf, "%s\n", usb_otg_state_string(musb->xceiv->otg->state));
        spin_unlock_irqrestore(&musb->lock, flags);
 
        return ret;
@@ -1675,7 +1675,7 @@ musb_vbus_store(struct device *dev, struct device_attribute *attr,
        spin_lock_irqsave(&musb->lock, flags);
        /* force T(a_wait_bcon) to be zero/unlimited *OR* valid */
        musb->a_wait_bcon = val ? max_t(int, val, OTG_TIME_A_WAIT_BCON) : 0 ;
-       if (musb->xceiv->state == OTG_STATE_A_WAIT_BCON)
+       if (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON)
                musb->is_active = 0;
        musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(val));
        spin_unlock_irqrestore(&musb->lock, flags);
@@ -1743,8 +1743,8 @@ static void musb_irq_work(struct work_struct *data)
 {
        struct musb *musb = container_of(data, struct musb, irq_work);
 
-       if (musb->xceiv->state != musb->xceiv_old_state) {
-               musb->xceiv_old_state = musb->xceiv->state;
+       if (musb->xceiv->otg->state != musb->xceiv_old_state) {
+               musb->xceiv_old_state = musb->xceiv->otg->state;
                sysfs_notify(&musb->controller->kobj, NULL, "mode");
        }
 }
@@ -1983,10 +1983,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
 
        if (musb->xceiv->otg->default_a) {
                MUSB_HST_MODE(musb);
-               musb->xceiv->state = OTG_STATE_A_IDLE;
+               musb->xceiv->otg->state = OTG_STATE_A_IDLE;
        } else {
                MUSB_DEV_MODE(musb);
-               musb->xceiv->state = OTG_STATE_B_IDLE;
+               musb->xceiv->otg->state = OTG_STATE_B_IDLE;
        }
 
        switch (musb->port_mode) {