diff options
Diffstat (limited to 'drivers/usb/musb/blackfin.c')
-rw-r--r-- | drivers/usb/musb/blackfin.c | 74 |
1 files changed, 57 insertions, 17 deletions
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index ac4422b33dcd..a441a2de8619 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -33,10 +33,45 @@ struct bfin_glue { | |||
33 | }; | 33 | }; |
34 | #define glue_to_musb(g) platform_get_drvdata(g->musb) | 34 | #define glue_to_musb(g) platform_get_drvdata(g->musb) |
35 | 35 | ||
36 | static u32 bfin_fifo_offset(u8 epnum) | ||
37 | { | ||
38 | return USB_OFFSET(USB_EP0_FIFO) + (epnum * 8); | ||
39 | } | ||
40 | |||
41 | static u8 bfin_readb(const void __iomem *addr, unsigned offset) | ||
42 | { | ||
43 | return (u8)(bfin_read16(addr + offset)); | ||
44 | } | ||
45 | |||
46 | static u16 bfin_readw(const void __iomem *addr, unsigned offset) | ||
47 | { | ||
48 | return bfin_read16(addr + offset); | ||
49 | } | ||
50 | |||
51 | static u32 bfin_readl(const void __iomem *addr, unsigned offset) | ||
52 | { | ||
53 | return (u32)(bfin_read16(addr + offset)); | ||
54 | } | ||
55 | |||
56 | static void bfin_writeb(void __iomem *addr, unsigned offset, u8 data) | ||
57 | { | ||
58 | bfin_write16(addr + offset, (u16)data); | ||
59 | } | ||
60 | |||
61 | static void bfin_writew(void __iomem *addr, unsigned offset, u16 data) | ||
62 | { | ||
63 | bfin_write16(addr + offset, data); | ||
64 | } | ||
65 | |||
66 | static void binf_writel(void __iomem *addr, unsigned offset, u32 data) | ||
67 | { | ||
68 | bfin_write16(addr + offset, (u16)data); | ||
69 | } | ||
70 | |||
36 | /* | 71 | /* |
37 | * Load an endpoint's FIFO | 72 | * Load an endpoint's FIFO |
38 | */ | 73 | */ |
39 | void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) | 74 | static void bfin_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) |
40 | { | 75 | { |
41 | struct musb *musb = hw_ep->musb; | 76 | struct musb *musb = hw_ep->musb; |
42 | void __iomem *fifo = hw_ep->fifo; | 77 | void __iomem *fifo = hw_ep->fifo; |
@@ -100,7 +135,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) | |||
100 | /* | 135 | /* |
101 | * Unload an endpoint's FIFO | 136 | * Unload an endpoint's FIFO |
102 | */ | 137 | */ |
103 | void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) | 138 | static void bfin_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) |
104 | { | 139 | { |
105 | struct musb *musb = hw_ep->musb; | 140 | struct musb *musb = hw_ep->musb; |
106 | void __iomem *fifo = hw_ep->fifo; | 141 | void __iomem *fifo = hw_ep->fifo; |
@@ -185,8 +220,8 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci) | |||
185 | } | 220 | } |
186 | 221 | ||
187 | /* Start sampling ID pin, when plug is removed from MUSB */ | 222 | /* Start sampling ID pin, when plug is removed from MUSB */ |
188 | if ((musb->xceiv->state == OTG_STATE_B_IDLE | 223 | if ((musb->xceiv->otg->state == OTG_STATE_B_IDLE |
189 | || musb->xceiv->state == OTG_STATE_A_WAIT_BCON) || | 224 | || musb->xceiv->otg->state == OTG_STATE_A_WAIT_BCON) || |
190 | (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) { | 225 | (musb->int_usb & MUSB_INTR_DISCONNECT && is_host_active(musb))) { |
191 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); | 226 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); |
192 | musb->a_wait_bcon = TIMER_DELAY; | 227 | musb->a_wait_bcon = TIMER_DELAY; |
@@ -205,7 +240,7 @@ static void musb_conn_timer_handler(unsigned long _musb) | |||
205 | static u8 toggle; | 240 | static u8 toggle; |
206 | 241 | ||
207 | spin_lock_irqsave(&musb->lock, flags); | 242 | spin_lock_irqsave(&musb->lock, flags); |
208 | switch (musb->xceiv->state) { | 243 | switch (musb->xceiv->otg->state) { |
209 | case OTG_STATE_A_IDLE: | 244 | case OTG_STATE_A_IDLE: |
210 | case OTG_STATE_A_WAIT_BCON: | 245 | case OTG_STATE_A_WAIT_BCON: |
211 | /* Start a new session */ | 246 | /* Start a new session */ |
@@ -219,7 +254,7 @@ static void musb_conn_timer_handler(unsigned long _musb) | |||
219 | 254 | ||
220 | if (!(val & MUSB_DEVCTL_BDEVICE)) { | 255 | if (!(val & MUSB_DEVCTL_BDEVICE)) { |
221 | gpio_set_value(musb->config->gpio_vrsel, 1); | 256 | gpio_set_value(musb->config->gpio_vrsel, 1); |
222 | musb->xceiv->state = OTG_STATE_A_WAIT_BCON; | 257 | musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON; |
223 | } else { | 258 | } else { |
224 | gpio_set_value(musb->config->gpio_vrsel, 0); | 259 | gpio_set_value(musb->config->gpio_vrsel, 0); |
225 | /* Ignore VBUSERROR and SUSPEND IRQ */ | 260 | /* Ignore VBUSERROR and SUSPEND IRQ */ |
@@ -229,7 +264,7 @@ static void musb_conn_timer_handler(unsigned long _musb) | |||
229 | 264 | ||
230 | val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR; | 265 | val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR; |
231 | musb_writeb(musb->mregs, MUSB_INTRUSB, val); | 266 | musb_writeb(musb->mregs, MUSB_INTRUSB, val); |
232 | musb->xceiv->state = OTG_STATE_B_IDLE; | 267 | musb->xceiv->otg->state = OTG_STATE_B_IDLE; |
233 | } | 268 | } |
234 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); | 269 | mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); |
235 | break; | 270 | break; |
@@ -245,7 +280,7 @@ static void musb_conn_timer_handler(unsigned long _musb) | |||
245 | 280 | ||
246 | if (!(val & MUSB_DEVCTL_BDEVICE)) { | 281 | if (!(val & MUSB_DEVCTL_BDEVICE)) { |
247 | gpio_set_value(musb->config->gpio_vrsel, 1); | 282 | gpio_set_value(musb->config->gpio_vrsel, 1); |
248 | musb->xceiv->state = OTG_STATE_A_WAIT_BCON; | 283 | musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON; |
249 | } else { | 284 | } else { |
250 | gpio_set_value(musb->config->gpio_vrsel, 0); | 285 | gpio_set_value(musb->config->gpio_vrsel, 0); |
251 | 286 | ||
@@ -280,13 +315,13 @@ static void musb_conn_timer_handler(unsigned long _musb) | |||
280 | break; | 315 | break; |
281 | default: | 316 | default: |
282 | dev_dbg(musb->controller, "%s state not handled\n", | 317 | dev_dbg(musb->controller, "%s state not handled\n", |
283 | usb_otg_state_string(musb->xceiv->state)); | 318 | usb_otg_state_string(musb->xceiv->otg->state)); |
284 | break; | 319 | break; |
285 | } | 320 | } |
286 | spin_unlock_irqrestore(&musb->lock, flags); | 321 | spin_unlock_irqrestore(&musb->lock, flags); |
287 | 322 | ||
288 | dev_dbg(musb->controller, "state is %s\n", | 323 | dev_dbg(musb->controller, "state is %s\n", |
289 | usb_otg_state_string(musb->xceiv->state)); | 324 | usb_otg_state_string(musb->xceiv->otg->state)); |
290 | } | 325 | } |
291 | 326 | ||
292 | static void bfin_musb_enable(struct musb *musb) | 327 | static void bfin_musb_enable(struct musb *musb) |
@@ -307,7 +342,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on) | |||
307 | 342 | ||
308 | dev_dbg(musb->controller, "VBUS %s, devctl %02x " | 343 | dev_dbg(musb->controller, "VBUS %s, devctl %02x " |
309 | /* otg %3x conf %08x prcm %08x */ "\n", | 344 | /* otg %3x conf %08x prcm %08x */ "\n", |
310 | usb_otg_state_string(musb->xceiv->state), | 345 | usb_otg_state_string(musb->xceiv->otg->state), |
311 | musb_readb(musb->mregs, MUSB_DEVCTL)); | 346 | musb_readb(musb->mregs, MUSB_DEVCTL)); |
312 | } | 347 | } |
313 | 348 | ||
@@ -433,6 +468,15 @@ static const struct musb_platform_ops bfin_ops = { | |||
433 | .init = bfin_musb_init, | 468 | .init = bfin_musb_init, |
434 | .exit = bfin_musb_exit, | 469 | .exit = bfin_musb_exit, |
435 | 470 | ||
471 | .readb = bfin_readb, | ||
472 | .writeb = bfin_writeb, | ||
473 | .readw = bfin_readw, | ||
474 | .writew = bfin_writew, | ||
475 | .readl = bfin_readl, | ||
476 | .writel = bfin_writel, | ||
477 | .fifo_mode = 2, | ||
478 | .read_fifo = bfin_read_fifo, | ||
479 | .write_fifo = bfin_write_fifo, | ||
436 | .enable = bfin_musb_enable, | 480 | .enable = bfin_musb_enable, |
437 | .disable = bfin_musb_disable, | 481 | .disable = bfin_musb_disable, |
438 | 482 | ||
@@ -456,16 +500,12 @@ static int bfin_probe(struct platform_device *pdev) | |||
456 | int ret = -ENOMEM; | 500 | int ret = -ENOMEM; |
457 | 501 | ||
458 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); | 502 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); |
459 | if (!glue) { | 503 | if (!glue) |
460 | dev_err(&pdev->dev, "failed to allocate glue context\n"); | ||
461 | goto err0; | 504 | goto err0; |
462 | } | ||
463 | 505 | ||
464 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); | 506 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
465 | if (!musb) { | 507 | if (!musb) |
466 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | ||
467 | goto err0; | 508 | goto err0; |
468 | } | ||
469 | 509 | ||
470 | musb->dev.parent = &pdev->dev; | 510 | musb->dev.parent = &pdev->dev; |
471 | musb->dev.dma_mask = &bfin_dmamask; | 511 | musb->dev.dma_mask = &bfin_dmamask; |