Skip to contentSkip to conversation

musb_hdrc: Host and OTG updates

PATCH In review Tony Lindgren 3 participants 18 messages Oct 11, 2007 – Oct 12, 2007

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover musb_hdrc: Host and OTG updates

Hi all,

Attached patch series updates musb code for host PM (mostly on tusb6010), and otg HNP stuff. Please comment and test.

Tested on tusb, compile tested on 2430sdp.

Regards,

Tony

#1 lore raw

PATCH 1/12 musb_hdrc: Allow tusb3.0 and greater to use multichannel DMA

Allow tusb3.0 and greater to use multichannel DMA

drivers/usb/musb/tusb6010.c +1 -1
index fbb402c..5026f2b 100644
@@ -34,7 +34,7 @@ static void tusb_source_power(struct musb *musb, int is_on);
  * Checks the revision. We need to use the DMA register as 3.0 does not
  * have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV.
  */
-static u8 tusb_get_revision(struct musb *musb)
+u8 tusb_get_revision(struct musb *musb)
 {
 	void __iomem	*tbase = musb->ctrl_base;
 	u32		die_id;
drivers/usb/musb/tusb6010.h +2 -0
index 16a311a..7ef6abf 100644
@@ -13,6 +13,8 @@
 #ifndef __TUSB6010_H__
 #define __TUSB6010_H__
 
+extern u8 tusb_get_revision(struct musb *musb);
+
 #ifdef CONFIG_USB_TUSB6010
 #define musb_in_tusb()			1
 #else
drivers/usb/musb/tusb6010_omap.c +10 -26
index 42c6a6b..09a6a3c 100644
@@ -20,18 +20,6 @@
 
 #include "musb_core.h"
 
-/*
- * REVISIT: With TUSB2.0 only one dmareq line can be used at a time.
- * This should get fixed in hardware at some point.
- */
-#define BROKEN_DMAREQ
-
-#ifdef BROKEN_DMAREQ
-#define dmareq_works()		0
-#else
-#define dmareq_works()		1
-#endif
-
 #define to_chdat(c)		(struct tusb_omap_dma_ch *)(c)->private_data
 
 #define MAX_DMAREQ		5	/* REVISIT: Really 6, but req5 not OK */
@@ -67,6 +55,7 @@ struct tusb_omap_dma {
 	int				ch;
 	s8				dmareq;
 	s8				sync_dev;
+	unsigned			multichannel:1;
 };
 
 static int tusb_omap_dma_start(struct dma_controller *c)
@@ -91,8 +80,6 @@ static int tusb_omap_dma_stop(struct dma_controller *c)
 	return 0;
 }
 
-#ifdef BROKEN_DMAREQ
-
 /*
  * Allocate dmareq0 to the current channel unless it's already taken
  */
@@ -128,11 +115,6 @@ static inline void tusb_omap_free_shared_dmareq(struct tusb_omap_dma_ch *chdat)
 	musb_writel(chdat->tbase, TUSB_DMA_EP_MAP, 0);
 }
 
-#else
-#define tusb_omap_use_shared_dmareq(x, y)	do {} while (0)
-#define tusb_omap_free_shared_dmareq(x, y)	do {} while (0)
-#endif
-
 /*
  * See also musb_dma_completion in plat_uds.c and musb_g_[tx|rx]() in
  * musb_gadget.c.
@@ -151,7 +133,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 
 	spin_lock_irqsave(&musb->lock, flags);
 
-	if (dmareq_works())
+	if (tusb_dma->multichannel)
 		ch = chdat->ch;
 	else
 		ch = tusb_dma->ch;
@@ -201,7 +183,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 		channel->actual_len += pio;
 	}
 
-	if (!dmareq_works())
+	if (!tusb_dma->multichannel)
 		tusb_omap_free_shared_dmareq(chdat);
 
 	channel->status = MUSB_DMA_STATUS_FREE;
@@ -283,7 +265,6 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 		return false;
 	}
 
-
 	chdat->transfer_len = len & ~0x1f;
 
 	if (len < packet_sz)
@@ -291,7 +272,7 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 	else
 		chdat->transfer_packet_sz = packet_sz;
 
-	if (dmareq_works()) {
+	if (tusb_dma->multichannel) {
 		ch = chdat->ch;
 		dmareq = chdat->dmareq;
 		sync_dev = chdat->sync_dev;
@@ -441,7 +422,7 @@ static int tusb_omap_dma_abort(struct dma_channel *channel)
 	struct tusb_omap_dma_ch	*chdat = to_chdat(channel);
 	struct tusb_omap_dma	*tusb_dma = chdat->tusb_dma;
 
-	if (!dmareq_works()) {
+	if (!tusb_dma->multichannel) {
 		if (tusb_dma->ch >= 0) {
 			omap_stop_dma(tusb_dma->ch);
 			omap_free_dma(tusb_dma->ch);
@@ -574,7 +555,7 @@ tusb_omap_dma_allocate(struct dma_controller *c,
 	channel->desired_mode = 0;
 	channel->actual_len = 0;
 
-	if (dmareq_works()) {
+	if (tusb_dma->multichannel) {
 		ret = tusb_omap_dma_allocate_dmareq(chdat);
 		if (ret != 0)
 			goto free_dmareq;
@@ -668,7 +649,7 @@ void dma_controller_destroy(struct dma_controller *c)
 		}
 	}
 
-	if (!dmareq_works() && tusb_dma && tusb_dma->ch >= 0)
+	if (!tusb_dma->multichannel && tusb_dma && tusb_dma->ch >= 0)
 		omap_free_dma(tusb_dma->ch);
 
 	kfree(tusb_dma);
@@ -710,6 +691,9 @@ dma_controller_create(struct musb *musb, void __iomem *base)
 	tusb_dma->controller.channel_abort = tusb_omap_dma_abort;
 	tusb_dma->controller.private_data = tusb_dma;
 
+	if (tusb_get_revision(musb) >= TUSB_REV_30)
+		tusb_dma->multichannel = 1;
+
 	for (i = 0; i < MAX_DMAREQ; i++) {
 		struct dma_channel	*ch;
 		struct tusb_omap_dma_ch	*chdat;
Signature · 1 line
1.5.2.5
#2 lore raw

PATCH 2/12 musb_hdrc: Add more sysfs notify events

Notify on all musb_stage0_irq events. For musb_stage2_irq events, add notify on suspend. Do not notify on SOF.

drivers/usb/musb/musb_core.c +2 -1
index 3093bda..f7dc22c 100644
@@ -652,11 +652,11 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 				DBG(1, "Unhandled BUS RESET as %s\n",
 					otg_state_string(musb));
 			}
-			schedule_work(&musb->irq_work);
 		}
 
 		handled = IRQ_HANDLED;
 	}
+	schedule_work(&musb->irq_work);
 
 	return handled;
 }
@@ -811,6 +811,7 @@ static irqreturn_t musb_stage2_irq(struct musb * musb, u8 int_usb,
 			musb->is_active = 0;
 			break;
 		}
+		schedule_work(&musb->irq_work);
 	}
 
 
Signature · 1 line
1.5.2.5
#3 lore raw

PATCH 3/12 musb_hdrc: Remove old sysfs entry cable, use mode instead

Cable was used earlier before OTG support for peripherals, however it does not really work for OTG. Sysfs entry mode shows the right OTG mode and should be used instead.

drivers/usb/musb/musb_core.c +0 -49
index f7dc22c..82bf57a 100644
@@ -1660,52 +1660,6 @@ musb_mode_store(struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store);
 
 static ssize_t
-musb_cable_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-	struct musb *musb = dev_to_musb(dev);
-	char *v1= "", *v2 = "?";
-	unsigned long flags;
-	int vbus;
-
-	spin_lock_irqsave(&musb->lock, flags);
-#if defined(CONFIG_USB_TUSB6010) && !defined(CONFIG_USB_MUSB_OTG)
-	/* REVISIT: connect-A != connect-B ... */
-	vbus = musb_platform_get_vbus_status(musb);
-	if (vbus)
-		v2 = "connected";
-	else
-		v2 = "disconnected";
-#else
-	/* NOTE: board-specific issues, like too-big capacitors keeping
-	 * VBUS high for a long time after power has been removed, can
-	 * cause temporary false indications of a connection.
-	 */
-	vbus = musb_readb(musb->mregs, MUSB_DEVCTL);
-	if (vbus & 0x10) {
-		/* REVISIT retest on real OTG hardware */
-		switch (musb->board_mode) {
-		case MUSB_HOST:
-			v2 = "A";
-			break;
-		case MUSB_PERIPHERAL:
-			v2 = "B";
-			break;
-		case MUSB_OTG:
-			v1 = "Mini-";
-			v2 = (vbus & MUSB_DEVCTL_BDEVICE) ? "B" : "A";
-			break;
-		}
-	} else	/* VBUS level below A-Valid */
-		v2 = "disconnected";
-#endif
-	musb_platform_try_idle(musb, 0);
-	spin_unlock_irqrestore(&musb->lock, flags);
-
-	return sprintf(buf, "%s%s\n", v1, v2);
-}
-static DEVICE_ATTR(cable, S_IRUGO, musb_cable_show, NULL);
-
-static ssize_t
 musb_vbus_store(struct device *dev, struct device_attribute *attr,
 		const char *buf, size_t n)
 {
@@ -1780,7 +1734,6 @@ static void musb_irq_work(struct work_struct *data)
 
 	if (musb->xceiv.state != old_state) {
 		old_state = musb->xceiv.state;
-		sysfs_notify(&musb->controller->kobj, NULL, "cable");
 		sysfs_notify(&musb->controller->kobj, NULL, "mode");
 	}
 }
@@ -1846,7 +1799,6 @@ static void musb_free(struct musb *musb)
 
 #ifdef CONFIG_SYSFS
 	device_remove_file(musb->controller, &dev_attr_mode);
-	device_remove_file(musb->controller, &dev_attr_cable);
 	device_remove_file(musb->controller, &dev_attr_vbus);
 #ifdef CONFIG_USB_MUSB_OTG
 	device_remove_file(musb->controller, &dev_attr_srp);
@@ -2082,7 +2034,6 @@ fail:
 
 #ifdef CONFIG_SYSFS
 	status = device_create_file(dev, &dev_attr_mode);
-	status = device_create_file(dev, &dev_attr_cable);
 	status = device_create_file(dev, &dev_attr_vbus);
 #ifdef CONFIG_USB_GADGET_MUSB_HDRC
 	status = device_create_file(dev, &dev_attr_srp);
Signature · 1 line
1.5.2.5
#4 lore raw

PATCH 4/12 musb_hdrc: Remove non-debug otg_state_string

The right state information via sys is good to know, don't try to optimize it away.

drivers/usb/musb/musb_core.c +20 -9
index 82bf57a..b438036 100644
@@ -121,15 +121,6 @@ module_param(debug, uint, 0);
 MODULE_PARM_DESC(debug, "initial debug message level");
 
 #define MUSB_VERSION_SUFFIX	"/dbg"
-#else
-
-const char *otg_state_string(struct musb *musb)
-{
-	static char buf[8];
-
-	snprintf(buf, sizeof buf, "otg-%d", musb->xceiv.state);
-	return buf;
-}
 #endif
 
 #define DRIVER_AUTHOR "Mentor Graphics, Texas Instruments, Nokia"
@@ -281,6 +272,26 @@ void musb_load_testpacket(struct musb *musb)
 
 /*-------------------------------------------------------------------------*/
 
+const char *otg_state_string(struct musb *musb)
+{
+	switch (musb->xceiv.state) {
+	case OTG_STATE_A_IDLE:		return "a_idle";
+	case OTG_STATE_A_WAIT_VRISE:	return "a_wait_vrise";
+	case OTG_STATE_A_WAIT_BCON:	return "a_wait_bcon";
+	case OTG_STATE_A_HOST:		return "a_host";
+	case OTG_STATE_A_SUSPEND:	return "a_suspend";
+	case OTG_STATE_A_PERIPHERAL:	return "a_peripheral";
+	case OTG_STATE_A_WAIT_VFALL:	return "a_wait_vfall";
+	case OTG_STATE_A_VBUS_ERR:	return "a_vbus_err";
+	case OTG_STATE_B_IDLE:		return "b_idle";
+	case OTG_STATE_B_SRP_INIT:	return "b_srp_init";
+	case OTG_STATE_B_PERIPHERAL:	return "b_peripheral";
+	case OTG_STATE_B_WAIT_ACON:	return "b_wait_acon";
+	case OTG_STATE_B_HOST:		return "b_host";
+	default:			return "UNDEFINED";
+	}
+}
+
 #ifdef	CONFIG_USB_MUSB_OTG
 
 /*
drivers/usb/musb/musb_procfs.c +0 -21
index ca53d13..bd282da 100644
@@ -42,27 +42,6 @@
 
 #include "davinci.h"
 
-
-const char *otg_state_string(struct musb *musb)
-{
-	switch (musb->xceiv.state) {
-	case OTG_STATE_A_IDLE:		return "a_idle";
-	case OTG_STATE_A_WAIT_VRISE:	return "a_wait_vrise";
-	case OTG_STATE_A_WAIT_BCON:	return "a_wait_bcon";
-	case OTG_STATE_A_HOST:		return "a_host";
-	case OTG_STATE_A_SUSPEND:	return "a_suspend";
-	case OTG_STATE_A_PERIPHERAL:	return "a_peripheral";
-	case OTG_STATE_A_WAIT_VFALL:	return "a_wait_vfall";
-	case OTG_STATE_A_VBUS_ERR:	return "a_vbus_err";
-	case OTG_STATE_B_IDLE:		return "b_idle";
-	case OTG_STATE_B_SRP_INIT:	return "b_srp_init";
-	case OTG_STATE_B_PERIPHERAL:	return "b_peripheral";
-	case OTG_STATE_B_WAIT_ACON:	return "b_wait_acon";
-	case OTG_STATE_B_HOST:		return "b_host";
-	default:			return "UNDEFINED";
-	}
-}
-
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
 
 static int dump_qh(struct musb_qh *qh, char *buf, unsigned max)
Signature · 1 line
1.5.2.5
#5 lore raw

PATCH 5/12 musb_hdrc: Fix host suspend handling, remove earlier hacks

If A-cable was connected and a gadget module was reloaded, root hub suspend would fail.

This the problem by managing musb inactive state better. The patch also adds more debug info for cases where suspend is attempted in active state.

drivers/usb/musb/musb_host.c +4 -2
index 79518ae..091ae8f 100644
@@ -2128,9 +2128,11 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
 {
 	struct musb	*musb = hcd_to_musb(hcd);
 
-	if (is_host_active(musb) && musb->is_active)
+	if (is_host_active(musb) && musb->is_active) {
+		WARN("trying to suspend as %s is_active=%i\n",
+			otg_state_string(musb), musb->is_active);
 		return -EBUSY;
-	else
+	} else
 		return 0;
 }
 
drivers/usb/musb/musb_virthub.c +1 -0
index b123d8e..22b1d5e 100644
@@ -190,6 +190,7 @@ void musb_root_disconnect(struct musb *musb)
 	case OTG_STATE_A_HOST:
 	case OTG_STATE_A_SUSPEND:
 		musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
+		musb->is_active = 0;
 		break;
 	case OTG_STATE_A_WAIT_VFALL:
 		musb->xceiv.state = OTG_STATE_B_IDLE;
drivers/usb/musb/tusb6010.c +3 -9
index 5026f2b..b3e745d 100644
@@ -430,7 +430,7 @@ static void musb_do_idle(unsigned long _musb)
 			DBG(4, "Nothing connected %s, turning off VBUS\n",
 					otg_state_string(musb));
 			tusb_source_power(musb, 0);
-			musb->xceiv.state = OTG_STATE_A_IDLE;
+			musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
 			musb->is_active = 0;
 		}
 		break;
@@ -551,16 +551,14 @@ static void tusb_source_power(struct musb *musb, int is_on)
 		if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
 			switch (musb->xceiv.state) {
 			case OTG_STATE_A_WAIT_VFALL:
-				musb->is_active = 1;
 				break;
 			case OTG_STATE_A_WAIT_VRISE:
-				musb->is_active = 1;
 				musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
 				break;
 			default:
-				musb->is_active = 0;
 				musb->xceiv.state = OTG_STATE_A_IDLE;
 			}
+			musb->is_active = 0;
 			musb->xceiv.default_a = 1;
 			MUSB_HST_MODE(musb);
 		} else {
@@ -778,11 +776,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
 					break;
 				}
 				musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
-				/* CONNECT can wake if a_wait_bcon is set */
-				if (musb->a_wait_bcon != 0)
-					musb->is_active = 0;
-				else
-					musb->is_active = 1;
+				musb->is_active = 0;
 				idle_timeout = jiffies
 					+ msecs_to_jiffies(musb->a_wait_bcon);
 			} else {
Signature · 1 line
1.5.2.5
#6 lore raw

PATCH 6/12 musb_hdrc: Improve tusb host state handling for a_idle

This patch makes the changes happen based on vbus change. This also seems to make enumeration work better.

drivers/usb/musb/tusb6010.c +8 -9
index b3e745d..16eaa48 100644
@@ -422,18 +422,15 @@ static void musb_do_idle(unsigned long _musb)
 
 	switch (musb->xceiv.state) {
 	case OTG_STATE_A_WAIT_BCON:
-	case OTG_STATE_A_WAIT_VRISE:
-	case OTG_STATE_A_IDLE:
 		if ((musb->a_wait_bcon != 0)
 			&& (musb->idle_timeout == 0
 				|| time_after(jiffies, musb->idle_timeout))) {
 			DBG(4, "Nothing connected %s, turning off VBUS\n",
 					otg_state_string(musb));
-			tusb_source_power(musb, 0);
-			musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
-			musb->is_active = 0;
 		}
-		break;
+		/* FALLTHROUGH */
+	case OTG_STATE_A_IDLE:
+		tusb_source_power(musb, 0);
 	default:
 		break;
 	}
@@ -533,7 +530,6 @@ static void tusb_source_power(struct musb *musb, int is_on)
 	if (is_on) {
 		if (musb->set_clock)
 			musb->set_clock(musb->clock, 1);
-		musb->is_active = 1;
 		timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE);
 		musb->xceiv.default_a = 1;
 		musb->xceiv.state = OTG_STATE_A_WAIT_VRISE;
@@ -550,11 +546,13 @@ static void tusb_source_power(struct musb *musb, int is_on)
 		otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT);
 		if (!(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) {
 			switch (musb->xceiv.state) {
-			case OTG_STATE_A_WAIT_VFALL:
-				break;
 			case OTG_STATE_A_WAIT_VRISE:
+			case OTG_STATE_A_WAIT_BCON:
 				musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
 				break;
+			case OTG_STATE_A_WAIT_VFALL:
+				musb->xceiv.state = OTG_STATE_A_IDLE;
+				break;
 			default:
 				musb->xceiv.state = OTG_STATE_A_IDLE;
 			}
@@ -798,6 +796,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
 			break;
 		}
 	}
+	schedule_work(&musb->irq_work);
 
 	return idle_timeout;
 }
Signature · 1 line
1.5.2.5
#7 lore raw

PATCH 7/12 musb_hdrc: Don't idle as host if VBUS timeout is 0

VBUS must be on all the time in this case.

drivers/usb/musb/tusb6010.c +3 -1
index 16eaa48..3008b6d 100644
@@ -482,7 +482,9 @@ void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
 	if (timeout == 0)
 		timeout = default_timeout;
 
-	if (musb->is_active) {
+	/* Never idle if active, or when VBUS timeout is not set as host */
+	if (musb->is_active || ((musb->a_wait_bcon == 0)
+			&& (musb->xceiv.state == OTG_STATE_A_WAIT_BCON))) {
 		DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
 		del_timer(&musb_idle_timer);
 		last_timer = jiffies;
Signature · 1 line
1.5.2.5
#8 lore raw

PATCH 8/12 musb_hdrc: Add timer for returning to host mode from HNP

This seems like the only way to deal with interrupted HNP if waiting as a_wait_bcon.

drivers/usb/musb/musb_core.c +16 -3
index b438036..efaa4fb 100644
@@ -309,11 +309,17 @@ void musb_otg_timer_func(unsigned long data)
 	unsigned long	flags;
 
 	spin_lock_irqsave(&musb->lock, flags);
-	if (musb->xceiv.state == OTG_STATE_B_WAIT_ACON) {
-		DBG(1, "HNP: B_WAIT_ACON timeout; back to B_PERIPHERAL\n");
+	switch (musb->xceiv.state) {
+	case OTG_STATE_B_WAIT_ACON:
+		DBG(1, "HNP: b_wait_acon timeout; back to b_peripheral\n");
 		musb_g_disconnect(musb);
 		musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
 		musb->is_active = 0;
+		break;
+	case OTG_STATE_A_WAIT_BCON:
+		DBG(1, "HNP: a_wait_bcon timeout; back to a_host\n");
+		musb_hnp_stop(musb);
+		break;
 	}
 	spin_unlock_irqrestore(&musb->lock, flags);
 }
@@ -649,10 +655,17 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 		} else if (is_peripheral_capable()) {
 			DBG(1, "BUS RESET as %s\n", otg_state_string(musb));
 			switch (musb->xceiv.state) {
-			case OTG_STATE_A_PERIPHERAL:
+#ifdef CONFIG_USB_OTG
 			case OTG_STATE_A_WAIT_BCON:	/* OPT TD.4.7-900ms */
+				DBG(1, "HNP: Setting timer as a_wait_bcon\n");
+				musb_otg_timer.data = (unsigned long)musb;
+				mod_timer(&musb_otg_timer, jiffies
+					+ msecs_to_jiffies(100));
+				break;
+			case OTG_STATE_A_PERIPHERAL:
 				musb_hnp_stop(musb);
 				break;
+#endif
 			case OTG_STATE_B_IDLE:
 				musb->xceiv.state = OTG_STATE_B_PERIPHERAL;
 				/* FALLTHROUGH */
Signature · 1 line
1.5.2.5
#9 lore raw

PATCH 9/12 musb_hdrc: Make HNP more reliable

Sometimes we get both SUSPEND and DISCONNECT the same time. In that case DISCONNECT must be ignored or else the HNP connection will break right away.

drivers/usb/musb/musb_core.c +7 -1
index efaa4fb..3d35a4e 100644
@@ -321,6 +321,7 @@ void musb_otg_timer_func(unsigned long data)
 		musb_hnp_stop(musb);
 		break;
 	}
+	musb->ignore_disconnect = 0;
 	spin_unlock_irqrestore(&musb->lock, flags);
 }
 
@@ -656,8 +657,13 @@ static irqreturn_t musb_stage0_irq(struct musb * musb, u8 int_usb,
 			DBG(1, "BUS RESET as %s\n", otg_state_string(musb));
 			switch (musb->xceiv.state) {
 #ifdef CONFIG_USB_OTG
+			case OTG_STATE_A_SUSPEND:
+				musb->ignore_disconnect = 1;
+				musb_g_reset(musb);
+				/* FALLTHROUGH */
 			case OTG_STATE_A_WAIT_BCON:	/* OPT TD.4.7-900ms */
-				DBG(1, "HNP: Setting timer as a_wait_bcon\n");
+				DBG(1, "HNP: Setting timer as %s\n",
+						otg_state_string(musb));
 				musb_otg_timer.data = (unsigned long)musb;
 				mod_timer(&musb_otg_timer, jiffies
 					+ msecs_to_jiffies(100));
Signature · 1 line
1.5.2.5
#10 lore raw

PATCH 10/12 musb_hdrc: Make vbus sysfs entry report current Vbus status

From: Felipe Balbi <[email protected]>

Getting the current status of Vbus is useful when running USB Compliance Tests.

drivers/usb/musb/musb_core.c +4 -1
index 3d35a4e..dc934dc 100644
@@ -1718,12 +1718,15 @@ musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
 	struct musb	*musb = dev_to_musb(dev);
 	unsigned long	flags;
 	unsigned long	val;
+	int		vbus;
 
 	spin_lock_irqsave(&musb->lock, flags);
 	val = musb->a_wait_bcon;
+	vbus = musb_platform_get_vbus_status(musb);
 	spin_unlock_irqrestore(&musb->lock, flags);
 
-	return sprintf(buf, "%lu\n", val);
+	return sprintf(buf, "Vbus %s, timeout %lu\n",
+			vbus ? "on" : "off", val);
 }
 static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store);
 
Signature · 1 line
1.5.2.5
#11 lore raw

PATCH 11/12 musb_hdrc: Allow suspend if host is already suspended

Allow suspend if host is already suspended

drivers/usb/musb/musb_host.c +3 -0
index 091ae8f..4eeff91 100644
@@ -2128,6 +2128,9 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
 {
 	struct musb	*musb = hcd_to_musb(hcd);
 
+	if (musb->xceiv.state == OTG_STATE_A_SUSPEND)
+		return 0;
+
 	if (is_host_active(musb) && musb->is_active) {
 		WARN("trying to suspend as %s is_active=%i\n",
 			otg_state_string(musb), musb->is_active);
Signature · 1 line
1.5.2.5
#12 lore raw

musb_hdrc: Fix compile if CONFIG_ARCH_OMAP_OTG is not set

Fix compile if CONFIG_ARCH_OMAP_OTG is not set

arch/arm/plat-omap/usb.c +1 -1
@@ -76,7 +76,7 @@
 
 /*-------------------------------------------------------------------------*/
 
-#ifdef	CONFIG_ARCH_OMAP_OTG
+#if	defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_USB_MUSB_OTG)
 
 static struct otg_transceiver *xceiv;
 
#13 lore raw

Re: [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended

In reply to Tony Lindgren

Hi,

Quoted 9 lines · Tony Lindgren

Allow suspend if host is already suspended

drivers/usb/musb/musb_host.c +0 -0
index 091ae8f..4eeff91 100644

drivers/usb/musb/musb_host.c static int musb_bus_suspend(struct usb_hcd *hcd) · line 2133

Quoted 6 lines
drivers/usb/musb/musb_host.c +3 -0
@@ -2128,6 +2128,9 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
 {
        struct musb     *musb = hcd_to_musb(hcd);
 
+       if (musb->xceiv.state == OTG_STATE_A_SUSPEND)
+               return 0;
+

Should we allow this ? If it's already suspended it doesn't make sense suspending again. And in OTG state machine there's no way to suspend a suspended device i.e. no loop going back to [ab]_suspend state.

In any case, if it works... ;-)

Quoted 11 lines
drivers/usb/musb/musb_host.c +0 -1
        if (is_host_active(musb) && musb->is_active) {
                WARN("trying to suspend as %s is_active=%i\n",
                        otg_state_string(musb), musb->is_active);
--

1.5.2.5

_______________________________________________
Linux-omap-open-source mailing list
[email protected]
http://linux.omap.com/mailman/listinfo/linux-omap-open-source

Signature · 4 lines
Best Regards,

Felipe Balbi
[email protected]
#14 lore raw

Re: [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended

Quoted 10 lines

drivers/usb/musb/musb_host.c static int musb_bus_suspend(struct usb_hcd *hcd) · line 2133

Quoted 7 lines
drivers/usb/musb/musb_host.c +3 -0
@@ -2128,6 +2128,9 @@ static int musb_bus_suspend(struct usb_hcd *hcd)
 {
        struct musb     *musb = hcd_to_musb(hcd);
 
+       if (musb->xceiv.state == OTG_STATE_A_SUSPEND)
+               return 0;
+

Should we allow this ? If it's already suspended it doesn't make sense suspending again.

Allow it. The invariant is that when the call returns, the bus has been suspended.

#15 lore raw

Re: [PATCH 11/12] musb_hdrc: Allow suspend if host is already suspended

On 10/11/07, David Brownell <[email protected]> wrote:

<snip>

Quoted 5 lines
Quoted 2 lines

Should we allow this ? If it's already suspended it doesn't make sense suspending again.

Allow it. The invariant is that when the call returns, the bus has been suspended.

K... thanks for clarification. ;-)

Signature · 4 lines
Best Regards,

Felipe Balbi
[email protected]
#17 lore raw
In reply to Tony Lindgren
Quoted 6 lines · Tony Lindgren

Hi all,

Attached patch series updates musb code for host PM (mostly on tusb6010), and otg HNP stuff. Please comment and test.

Tested on tusb, compile tested on 2430sdp.

Pushing this series today.

Tony