aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_core.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-10-11 04:38:13 -0400
committerFelipe Balbi <balbi@ti.com>2013-10-11 11:39:35 -0400
commit001dd84a92a25f8f2bad7d26df8bdb0362302c07 (patch)
tree8343ad761d519da0919817295ab2dc8a29694da2 /drivers/usb/musb/musb_core.c
parentb377216bd2d313b393ddd4b04c71f700842d104b (diff)
usb: musb: start musb on the udc side, too
I have am335x-evm with one port running in OTG mode. Since commit fe4cb09 ("usb: musb: gadget: remove hcd initialization") the loaded gadget does non pop up on the host. All I see is |usb 4-5: new high-speed USB device number 52 using ehci-pci |usb 4-5: device descriptor read/64, error -110 Since a later commit 2cc65fe ("usb: musb: add musb_host_setup() and musb_host_cleanup()) the gadget shows up on the host again but only in OTG mode (because we have the host init code running). It does not work in device only mode. If running in OTG mode and the gadget is removed and added back (rmmod followed by modprobe of a gadget) then the same error is pops up on the host side. This patch ensures that the gadget side also executes musb_start() which puts the chip in "connect accept" mode. With this change the device works in OTG & device mode and the gadget can be added & removed multiple times. A device (if musb is in OTG mode acting as a host) is only recognized if it is attached during module load (musb_hdrc module). After the device unplugged and plugged again the host does not recognize it. We get a buch of errors if musb running in OTG mode, attached to a host and no gadget is loaded. Bah. This is one step forward. Host & device only mode should work. I will look at OTG later. I looked at this before commit fe4cb09 and OTG wasn't working there perfectly so I am not sure that it is a regression :) Cc: <stable@vger.kernel.org> # v3.11 Cc: Daniel Mack <zonque@gmail.com> Cc: Peter Korsgaard <jacmet@sunsite.dk> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/musb_core.c')
-rw-r--r--drivers/usb/musb/musb_core.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 18e877ffe7b7..cd70cc886171 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -922,6 +922,52 @@ static void musb_generic_disable(struct musb *musb)
922} 922}
923 923
924/* 924/*
925 * Program the HDRC to start (enable interrupts, dma, etc.).
926 */
927void musb_start(struct musb *musb)
928{
929 void __iomem *regs = musb->mregs;
930 u8 devctl = musb_readb(regs, MUSB_DEVCTL);
931
932 dev_dbg(musb->controller, "<== devctl %02x\n", devctl);
933
934 /* Set INT enable registers, enable interrupts */
935 musb->intrtxe = musb->epmask;
936 musb_writew(regs, MUSB_INTRTXE, musb->intrtxe);
937 musb->intrrxe = musb->epmask & 0xfffe;
938 musb_writew(regs, MUSB_INTRRXE, musb->intrrxe);
939 musb_writeb(regs, MUSB_INTRUSBE, 0xf7);
940
941 musb_writeb(regs, MUSB_TESTMODE, 0);
942
943 /* put into basic highspeed mode and start session */
944 musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
945 | MUSB_POWER_HSENAB
946 /* ENSUSPEND wedges tusb */
947 /* | MUSB_POWER_ENSUSPEND */
948 );
949
950 musb->is_active = 0;
951 devctl = musb_readb(regs, MUSB_DEVCTL);
952 devctl &= ~MUSB_DEVCTL_SESSION;
953
954 /* session started after:
955 * (a) ID-grounded irq, host mode;
956 * (b) vbus present/connect IRQ, peripheral mode;
957 * (c) peripheral initiates, using SRP
958 */
959 if (musb->port_mode != MUSB_PORT_MODE_HOST &&
960 (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) {
961 musb->is_active = 1;
962 } else {
963 devctl |= MUSB_DEVCTL_SESSION;
964 }
965
966 musb_platform_enable(musb);
967 musb_writeb(regs, MUSB_DEVCTL, devctl);
968}
969
970/*
925 * Make the HDRC stop (disable interrupts, etc.); 971 * Make the HDRC stop (disable interrupts, etc.);
926 * reversible by musb_start 972 * reversible by musb_start
927 * called on gadget driver unregister 973 * called on gadget driver unregister