From de2e1b0c988c901989713869a8bea3b3d02bb9ce Mon Sep 17 00:00:00 2001 From: Maulik Mankad Date: Fri, 12 Mar 2010 10:29:07 +0200 Subject: usb: musb: Set transceiver interface type Program the OTG_INTERFSEL register based on transcevier type passed from board file. Adapt signature of musb_platform_init() function for davinci, blackfin and tusb6010. Signed-off-by: Maulik Mankad Cc: David Brownell Cc: Sergei Shtylyov Cc: Olof Johansson Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/blackfin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/usb/musb/blackfin.c') diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index ec8d324237f6..7c71eb422a9c 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -270,7 +270,7 @@ int musb_platform_set_mode(struct musb *musb, u8 musb_mode) return -EIO; } -int __init musb_platform_init(struct musb *musb) +int __init musb_platform_init(struct musb *musb, void *board_data) { /* -- cgit v1.2.2 From 6ddc6dae4ab559b648bc348e3a48e113e92ab4a2 Mon Sep 17 00:00:00 2001 From: Cliff Cai Date: Fri, 12 Mar 2010 10:29:10 +0200 Subject: USB: musb: allow the Blackfin vrsel gpio to be active low Rather than hardcoding the gpio levels for vrsel, allow the platform resources to handle this so boards can be active high or low. Signed-off-by: Cliff Cai Signed-off-by: Mike Frysinger Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/blackfin.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/usb/musb/blackfin.c') diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 7c71eb422a9c..eb4392f904e4 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -238,10 +238,10 @@ static void bfin_vbus_power(struct musb *musb, int is_on, int sleeping) static void bfin_set_vbus(struct musb *musb, int is_on) { - if (is_on) - gpio_set_value(musb->config->gpio_vrsel, 1); - else - gpio_set_value(musb->config->gpio_vrsel, 0); + int value = musb->config->gpio_vrsel_active; + if (!is_on) + value = !value; + gpio_set_value(musb->config->gpio_vrsel, value); DBG(1, "VBUS %s, devctl %02x " /* otg %3x conf %08x prcm %08x */ "\n", -- cgit v1.2.2 From ff927addd62d33ab95cd83208e7db3ff37fdac18 Mon Sep 17 00:00:00 2001 From: Cliff Cai Date: Thu, 25 Mar 2010 13:25:19 +0200 Subject: USB: musb: support host/gadget role switching on Blackfin parts Signed-off-by: Cliff Cai Signed-off-by: Mike Frysinger Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/blackfin.c | 69 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 6 deletions(-) (limited to 'drivers/usb/musb/blackfin.c') diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index eb4392f904e4..8052e7659ac8 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -170,6 +170,13 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci) retval = musb_interrupt(musb); } + /* Start sampling ID pin, when plug is removed from MUSB */ + if (is_otg_enabled(musb) && (musb->xceiv->state == OTG_STATE_B_IDLE + || musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) { + mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); + musb->a_wait_bcon = TIMER_DELAY; + } + spin_unlock_irqrestore(&musb->lock, flags); return retval; @@ -180,6 +187,7 @@ static void musb_conn_timer_handler(unsigned long _musb) struct musb *musb = (void *)_musb; unsigned long flags; u16 val; + static u8 toggle; spin_lock_irqsave(&musb->lock, flags); switch (musb->xceiv->state) { @@ -187,10 +195,44 @@ static void musb_conn_timer_handler(unsigned long _musb) case OTG_STATE_A_WAIT_BCON: /* Start a new session */ val = musb_readw(musb->mregs, MUSB_DEVCTL); + val &= ~MUSB_DEVCTL_SESSION; + musb_writew(musb->mregs, MUSB_DEVCTL, val); val |= MUSB_DEVCTL_SESSION; musb_writew(musb->mregs, MUSB_DEVCTL, val); + /* Check if musb is host or peripheral. */ + val = musb_readw(musb->mregs, MUSB_DEVCTL); + + if (!(val & MUSB_DEVCTL_BDEVICE)) { + gpio_set_value(musb->config->gpio_vrsel, 1); + musb->xceiv->state = OTG_STATE_A_WAIT_BCON; + } else { + gpio_set_value(musb->config->gpio_vrsel, 0); + /* Ignore VBUSERROR and SUSPEND IRQ */ + val = musb_readb(musb->mregs, MUSB_INTRUSBE); + val &= ~MUSB_INTR_VBUSERROR; + musb_writeb(musb->mregs, MUSB_INTRUSBE, val); + val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR; + musb_writeb(musb->mregs, MUSB_INTRUSB, val); + if (is_otg_enabled(musb)) + musb->xceiv->state = OTG_STATE_B_IDLE; + else + musb_writeb(musb->mregs, MUSB_POWER, MUSB_POWER_HSENAB); + } + mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); + break; + case OTG_STATE_B_IDLE: + + if (!is_peripheral_enabled(musb)) + break; + /* Start a new session. It seems that MUSB needs taking + * some time to recognize the type of the plug inserted? + */ val = musb_readw(musb->mregs, MUSB_DEVCTL); + val |= MUSB_DEVCTL_SESSION; + musb_writew(musb->mregs, MUSB_DEVCTL, val); + val = musb_readw(musb->mregs, MUSB_DEVCTL); + if (!(val & MUSB_DEVCTL_BDEVICE)) { gpio_set_value(musb->config->gpio_vrsel, 1); musb->xceiv->state = OTG_STATE_A_WAIT_BCON; @@ -205,12 +247,27 @@ static void musb_conn_timer_handler(unsigned long _musb) val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR; musb_writeb(musb->mregs, MUSB_INTRUSB, val); - val = MUSB_POWER_HSENAB; - musb_writeb(musb->mregs, MUSB_POWER, val); + /* Toggle the Soft Conn bit, so that we can response to + * the inserting of either A-plug or B-plug. + */ + if (toggle) { + val = musb_readb(musb->mregs, MUSB_POWER); + val &= ~MUSB_POWER_SOFTCONN; + musb_writeb(musb->mregs, MUSB_POWER, val); + toggle = 0; + } else { + val = musb_readb(musb->mregs, MUSB_POWER); + val |= MUSB_POWER_SOFTCONN; + musb_writeb(musb->mregs, MUSB_POWER, val); + toggle = 1; + } + /* The delay time is set to 1/4 second by default, + * shortening it, if accelerating A-plug detection + * is needed in OTG mode. + */ + mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY / 4); } - mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); break; - default: DBG(1, "%s state not handled\n", otg_state_string(musb)); break; @@ -222,7 +279,7 @@ static void musb_conn_timer_handler(unsigned long _musb) void musb_platform_enable(struct musb *musb) { - if (is_host_enabled(musb)) { + if (!is_otg_enabled(musb) && is_host_enabled(musb)) { mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); musb->a_wait_bcon = TIMER_DELAY; } @@ -256,7 +313,7 @@ static int bfin_set_power(struct otg_transceiver *x, unsigned mA) void musb_platform_try_idle(struct musb *musb, unsigned long timeout) { - if (is_host_enabled(musb)) + if (!is_otg_enabled(musb) && is_host_enabled(musb)) mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); } -- cgit v1.2.2 From 69b2cd7200a32956581cab24b2a4ecf8353cd6f8 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Thu, 25 Mar 2010 13:25:21 +0200 Subject: MUSB: Blackfin: remove bfin_vbus_power() This function does nothing... Signed-off-by: Sergei Shtylyov Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/blackfin.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/usb/musb/blackfin.c') diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 8052e7659ac8..903b465c4c68 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -289,10 +289,6 @@ void musb_platform_disable(struct musb *musb) { } -static void bfin_vbus_power(struct musb *musb, int is_on, int sleeping) -{ -} - static void bfin_set_vbus(struct musb *musb, int is_on) { int value = musb->config->gpio_vrsel_active; @@ -410,7 +406,6 @@ int musb_platform_resume(struct musb *musb) int musb_platform_exit(struct musb *musb) { - bfin_vbus_power(musb, 0 /*off*/, 1); gpio_free(musb->config->gpio_vrsel); musb_platform_suspend(musb); -- cgit v1.2.2 From d55d221a93c62a769f2bcf9cd5853425addb5c9f Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Thu, 25 Mar 2010 13:25:23 +0200 Subject: MUSB: Blackfin: remove musb_platform_{suspend|resume}() These functions do nothing and also are both unnecessarily 'extern'; actually, musb_platform_resume() in not even called... Signed-off-by: Sergei Shtylyov Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/blackfin.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'drivers/usb/musb/blackfin.c') diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 903b465c4c68..b611420a8050 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -392,22 +392,10 @@ int __init musb_platform_init(struct musb *musb, void *board_data) return 0; } -int musb_platform_suspend(struct musb *musb) -{ - return 0; -} - -int musb_platform_resume(struct musb *musb) -{ - return 0; -} - - int musb_platform_exit(struct musb *musb) { gpio_free(musb->config->gpio_vrsel); - musb_platform_suspend(musb); return 0; } -- cgit v1.2.2