11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/sched.h>
15 #include <linux/list.h>
21 #include <linux/prefetch.h>
24 #include <asm/cacheflush.h>
34 #define glue_to_musb(g) platform_get_drvdata(g->musb)
48 musb_writew(epio, MUSB_TXCOUNT, len);
51 hw_ep->
epnum, fifo, len, src, epio);
59 (
unsigned long)(src + len));
66 dma_reg = (
u32)src >> 16;
94 if (
unlikely((
unsigned long)src & 0x01))
95 outsw_8((
unsigned long)fifo, src, (len + 1) >> 1);
97 outsw((
unsigned long)fifo, src, (len + 1) >> 1);
113 (
unsigned long)(dst + len));
120 dma_reg = (
u32)dst >> 16;
151 *dst = (
u8)
inw((
unsigned long)fifo + 4);
153 if (
unlikely((
unsigned long)dst & 0x01))
154 insw_8((
unsigned long)fifo,
dst, len >> 1);
156 insw((
unsigned long)fifo, dst, len >> 1);
159 *(dst + len - 1) = (
u8)
inw((
unsigned long)fifo + 4);
163 'R', hw_ep->
epnum, fifo, len, dst);
168 static irqreturn_t blackfin_interrupt(
int irq,
void *__hci)
195 spin_unlock_irqrestore(&musb->
lock, flags);
200 static void musb_conn_timer_handler(
unsigned long _musb)
202 struct musb *musb = (
void *)_musb;
208 switch (musb->
xceiv->state) {
246 if (!(val & MUSB_DEVCTL_BDEVICE)) {
286 spin_unlock_irqrestore(&musb->
lock, flags);
292 static void bfin_musb_enable(
struct musb *musb)
297 static void bfin_musb_disable(
struct musb *musb)
301 static void bfin_musb_set_vbus(
struct musb *musb,
int is_on)
314 static int bfin_musb_set_power(
struct usb_phy *
x,
unsigned mA)
319 static int bfin_musb_vbus_status(
struct musb *musb)
324 static int bfin_musb_set_mode(
struct musb *musb,
u8 musb_mode)
343 if (musb_channel->
transmit && *mode == 1)
344 *len = *len - (*len % packet_sz);
350 static void bfin_musb_reg_init(
struct musb *musb)
364 ((480/musb->
config->clkin) << 1));
388 static int bfin_musb_init(
struct musb *musb)
400 musb->
config->gpio_vrsel);
407 if (IS_ERR_OR_NULL(musb->
xceiv)) {
412 bfin_musb_reg_init(musb);
414 setup_timer(&musb_conn_timer, musb_conn_timer_handler,
415 (
unsigned long) musb);
417 musb->
xceiv->set_power = bfin_musb_set_power;
419 musb->
isr = blackfin_interrupt;
425 static int bfin_musb_exit(
struct musb *musb)
435 .init = bfin_musb_init,
436 .exit = bfin_musb_exit,
438 .enable = bfin_musb_enable,
439 .disable = bfin_musb_disable,
441 .set_mode = bfin_musb_set_mode,
443 .vbus_status = bfin_musb_vbus_status,
444 .set_vbus = bfin_musb_set_vbus,
446 .adjust_channel_params = bfin_musb_adjust_channel_params,
462 dev_err(&pdev->
dev,
"failed to allocate glue context\n");
469 dev_err(&pdev->
dev,
"failed to allocate musb id\n");
476 dev_err(&pdev->
dev,
"failed to allocate musb device\n");
481 musb->
dev.parent = &pdev->
dev;
482 musb->
dev.dma_mask = &bfin_dmamask;
483 musb->
dev.coherent_dma_mask = bfin_dmamask;
490 platform_set_drvdata(pdev, glue);
495 dev_err(&pdev->
dev,
"failed to add resources\n");
501 dev_err(&pdev->
dev,
"failed to add platform_data\n");
507 dev_err(&pdev->
dev,
"failed to register musb device\n");
528 struct bfin_glue *glue = platform_get_drvdata(pdev);
539 static int bfin_suspend(
struct device *
dev)
556 static int bfin_resume(
struct device *dev)
561 bfin_musb_reg_init(musb);
568 .resume = bfin_resume,
571 #define DEV_PM_OPS &bfin_pm_ops
573 #define DEV_PM_OPS NULL
580 .name =
"musb-blackfin",
589 static int __init bfin_init(
void)
595 static void __exit bfin_exit(
void)