aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/omap2430.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/musb/omap2430.c')
-rw-r--r--drivers/usb/musb/omap2430.c52
1 files changed, 21 insertions, 31 deletions
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index d369bf1f3936..763649eb4987 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -65,15 +65,15 @@ static void musb_do_idle(unsigned long _musb)
65 65
66 spin_lock_irqsave(&musb->lock, flags); 66 spin_lock_irqsave(&musb->lock, flags);
67 67
68 switch (musb->xceiv->state) { 68 switch (musb->xceiv->otg->state) {
69 case OTG_STATE_A_WAIT_BCON: 69 case OTG_STATE_A_WAIT_BCON:
70 70
71 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 71 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
72 if (devctl & MUSB_DEVCTL_BDEVICE) { 72 if (devctl & MUSB_DEVCTL_BDEVICE) {
73 musb->xceiv->state = OTG_STATE_B_IDLE; 73 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
74 MUSB_DEV_MODE(musb); 74 MUSB_DEV_MODE(musb);
75 } else { 75 } else {
76 musb->xceiv->state = OTG_STATE_A_IDLE; 76 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
77 MUSB_HST_MODE(musb); 77 MUSB_HST_MODE(musb);
78 } 78 }
79 break; 79 break;
@@ -90,15 +90,15 @@ static void musb_do_idle(unsigned long _musb)
90 musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16; 90 musb->port1_status |= USB_PORT_STAT_C_SUSPEND << 16;
91 usb_hcd_poll_rh_status(musb->hcd); 91 usb_hcd_poll_rh_status(musb->hcd);
92 /* NOTE: it might really be A_WAIT_BCON ... */ 92 /* NOTE: it might really be A_WAIT_BCON ... */
93 musb->xceiv->state = OTG_STATE_A_HOST; 93 musb->xceiv->otg->state = OTG_STATE_A_HOST;
94 } 94 }
95 break; 95 break;
96 case OTG_STATE_A_HOST: 96 case OTG_STATE_A_HOST:
97 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 97 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
98 if (devctl & MUSB_DEVCTL_BDEVICE) 98 if (devctl & MUSB_DEVCTL_BDEVICE)
99 musb->xceiv->state = OTG_STATE_B_IDLE; 99 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
100 else 100 else
101 musb->xceiv->state = OTG_STATE_A_WAIT_BCON; 101 musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
102 default: 102 default:
103 break; 103 break;
104 } 104 }
@@ -116,9 +116,9 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
116 116
117 /* Never idle if active, or when VBUS timeout is not set as host */ 117 /* Never idle if active, or when VBUS timeout is not set as host */
118 if (musb->is_active || ((musb->a_wait_bcon == 0) 118 if (musb->is_active || ((musb->a_wait_bcon == 0)
119 && (musb->xceiv->state == OTG_STATE_A_WAIT_BCON))) { 119 && (musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON))) {
120 dev_dbg(musb->controller, "%s active, deleting timer\n", 120 dev_dbg(musb->controller, "%s active, deleting timer\n",
121 usb_otg_state_string(musb->xceiv->state)); 121 usb_otg_state_string(musb->xceiv->otg->state));
122 del_timer(&musb_idle_timer); 122 del_timer(&musb_idle_timer);
123 last_timer = jiffies; 123 last_timer = jiffies;
124 return; 124 return;
@@ -135,7 +135,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout)
135 last_timer = timeout; 135 last_timer = timeout;
136 136
137 dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n", 137 dev_dbg(musb->controller, "%s inactive, for idle timer for %lu ms\n",
138 usb_otg_state_string(musb->xceiv->state), 138 usb_otg_state_string(musb->xceiv->otg->state),
139 (unsigned long)jiffies_to_msecs(timeout - jiffies)); 139 (unsigned long)jiffies_to_msecs(timeout - jiffies));
140 mod_timer(&musb_idle_timer, timeout); 140 mod_timer(&musb_idle_timer, timeout);
141} 141}
@@ -153,7 +153,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
153 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 153 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
154 154
155 if (is_on) { 155 if (is_on) {
156 if (musb->xceiv->state == OTG_STATE_A_IDLE) { 156 if (musb->xceiv->otg->state == OTG_STATE_A_IDLE) {
157 int loops = 100; 157 int loops = 100;
158 /* start the session */ 158 /* start the session */
159 devctl |= MUSB_DEVCTL_SESSION; 159 devctl |= MUSB_DEVCTL_SESSION;
@@ -162,7 +162,8 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
162 * Wait for the musb to set as A device to enable the 162 * Wait for the musb to set as A device to enable the
163 * VBUS 163 * VBUS
164 */ 164 */
165 while (musb_readb(musb->mregs, MUSB_DEVCTL) & 0x80) { 165 while (musb_readb(musb->mregs, MUSB_DEVCTL) &
166 MUSB_DEVCTL_BDEVICE) {
166 167
167 mdelay(5); 168 mdelay(5);
168 cpu_relax(); 169 cpu_relax();
@@ -179,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
179 } else { 180 } else {
180 musb->is_active = 1; 181 musb->is_active = 1;
181 otg->default_a = 1; 182 otg->default_a = 1;
182 musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; 183 musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
183 devctl |= MUSB_DEVCTL_SESSION; 184 devctl |= MUSB_DEVCTL_SESSION;
184 MUSB_HST_MODE(musb); 185 MUSB_HST_MODE(musb);
185 } 186 }
@@ -191,7 +192,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
191 */ 192 */
192 193
193 otg->default_a = 0; 194 otg->default_a = 0;
194 musb->xceiv->state = OTG_STATE_B_IDLE; 195 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
195 devctl &= ~MUSB_DEVCTL_SESSION; 196 devctl &= ~MUSB_DEVCTL_SESSION;
196 197
197 MUSB_DEV_MODE(musb); 198 MUSB_DEV_MODE(musb);
@@ -200,7 +201,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on)
200 201
201 dev_dbg(musb->controller, "VBUS %s, devctl %02x " 202 dev_dbg(musb->controller, "VBUS %s, devctl %02x "
202 /* otg %3x conf %08x prcm %08x */ "\n", 203 /* otg %3x conf %08x prcm %08x */ "\n",
203 usb_otg_state_string(musb->xceiv->state), 204 usb_otg_state_string(musb->xceiv->otg->state),
204 musb_readb(musb->mregs, MUSB_DEVCTL)); 205 musb_readb(musb->mregs, MUSB_DEVCTL));
205} 206}
206 207
@@ -265,7 +266,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
265 dev_dbg(dev, "ID GND\n"); 266 dev_dbg(dev, "ID GND\n");
266 267
267 otg->default_a = true; 268 otg->default_a = true;
268 musb->xceiv->state = OTG_STATE_A_IDLE; 269 musb->xceiv->otg->state = OTG_STATE_A_IDLE;
269 musb->xceiv->last_event = USB_EVENT_ID; 270 musb->xceiv->last_event = USB_EVENT_ID;
270 if (musb->gadget_driver) { 271 if (musb->gadget_driver) {
271 pm_runtime_get_sync(dev); 272 pm_runtime_get_sync(dev);
@@ -279,7 +280,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
279 dev_dbg(dev, "VBUS Connect\n"); 280 dev_dbg(dev, "VBUS Connect\n");
280 281
281 otg->default_a = false; 282 otg->default_a = false;
282 musb->xceiv->state = OTG_STATE_B_IDLE; 283 musb->xceiv->otg->state = OTG_STATE_B_IDLE;
283 musb->xceiv->last_event = USB_EVENT_VBUS; 284 musb->xceiv->last_event = USB_EVENT_VBUS;
284 if (musb->gadget_driver) 285 if (musb->gadget_driver)
285 pm_runtime_get_sync(dev); 286 pm_runtime_get_sync(dev);
@@ -518,10 +519,8 @@ static int omap2430_probe(struct platform_device *pdev)
518 int ret = -ENOMEM; 519 int ret = -ENOMEM;
519 520
520 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); 521 glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
521 if (!glue) { 522 if (!glue)
522 dev_err(&pdev->dev, "failed to allocate glue context\n");
523 goto err0; 523 goto err0;
524 }
525 524
526 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); 525 musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
527 if (!musb) { 526 if (!musb) {
@@ -543,25 +542,16 @@ static int omap2430_probe(struct platform_device *pdev)
543 struct platform_device *control_pdev; 542 struct platform_device *control_pdev;
544 543
545 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 544 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
546 if (!pdata) { 545 if (!pdata)
547 dev_err(&pdev->dev,
548 "failed to allocate musb platform data\n");
549 goto err2; 546 goto err2;
550 }
551 547
552 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); 548 data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
553 if (!data) { 549 if (!data)
554 dev_err(&pdev->dev,
555 "failed to allocate musb board data\n");
556 goto err2; 550 goto err2;
557 }
558 551
559 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); 552 config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
560 if (!config) { 553 if (!config)
561 dev_err(&pdev->dev,
562 "failed to allocate musb hdrc config\n");
563 goto err2; 554 goto err2;
564 }
565 555
566 of_property_read_u32(np, "mode", (u32 *)&pdata->mode); 556 of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
567 of_property_read_u32(np, "interface-type", 557 of_property_read_u32(np, "interface-type",