Skip to contentSkip to conversation

RFC PATCH

PATCH New Felipe Balbi 4 participants 20 messages May 29, 2007 – Jun 5, 2007 1 message not in the archive

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

The following patch series is a work in progress and we have a lot to fix. But still, it fixes some issues and implement some nice features.

TODO:
SRP should be automatic
Vbus should be turned off if we're not using the bus.
mdelay() should be fixed
0008-*.diff shouldn't be applied is just a way to run the HSET tests from linux 0010-*.diff leave GPIO[7:6] pullups enabled as they're the default wake-up source for tusb6010
Without this patch we can't turn on Vbus if there's any load between Vbus and GND

I think that's all. Hope anyone can test/comment on this patch series.

[email protected]

#1 lore raw

PATCH 1/1 USB: Disable file_storage USB_CONFIG_ATT_WAKEUP

From: Tony Lindgren <[email protected]>

Disable file_storage USB_CONFIG_ATT_WAKEUP as it requires user interaction during Chapter 9 tests.

---

drivers/usb/gadget/file_storage.c +1 -2
index c6b6479..de85c8b 100644
@@ -3965,8 +3965,7 @@ static int __init fsg_bind(struct usb_gadget *gadget)
 #endif
 
 	if (gadget->is_otg) {
-		otg_desc.bmAttributes |= USB_OTG_HNP,
-		config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+		otg_desc.bmAttributes |= USB_OTG_HNP;
 	}
 
 	rc = -ENOMEM;
Signature · 1 line
1.5.2.rc3.39.gaf9b
#2 lore raw

PATCH 1/1 musb_hdrc: Implement workaround for tusb3.0 wbus bug rev2

From: Tony Lindgren <[email protected]>

Without this workaround tusb3.0 will wake-up spontaneously on USB suspend.

Patch also moves revision functions to the top of the file.

---

drivers/usb/musb/tusb6010.c +70 -25
Index: linux-omap-2.6/drivers/usb/musb/tusb6010.c
===================================================================
@@ -25,6 +25,67 @@
 
 #include "musbdefs.h"
 
+/*
+ * 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)
+{
+	void __iomem	*base = musb->ctrl_base;
+
+	return musb_readl(base, TUSB_DMA_CTRL_REV) & 0xff;
+}
+
+#define TUSB_REV_MAJOR(reg_val)		((reg_val >> 4) & 0xf)
+#define TUSB_REV_MINOR(reg_val)		(reg_val & 0xf)
+
+static int __init tusb_print_revision(struct musb *musb)
+{
+	void __iomem	*base = musb->ctrl_base;
+
+	pr_info("tusb: Revisions: %s%i.%i %s%i.%i %s%i.%i %s%i.%i\n",
+		"prcm",
+		TUSB_REV_MAJOR(musb_readl(base, TUSB_PRCM_REV)),
+		TUSB_REV_MINOR(musb_readl(base, TUSB_PRCM_REV)),
+		"int",
+		TUSB_REV_MAJOR(musb_readl(base, TUSB_INT_CTRL_REV)),
+		TUSB_REV_MINOR(musb_readl(base, TUSB_INT_CTRL_REV)),
+		"gpio",
+		TUSB_REV_MAJOR(musb_readl(base, TUSB_GPIO_REV)),
+		TUSB_REV_MINOR(musb_readl(base, TUSB_GPIO_REV)),
+		"dma",
+		TUSB_REV_MAJOR(musb_readl(base, TUSB_DMA_CTRL_REV)),
+		TUSB_REV_MINOR(musb_readl(base, TUSB_DMA_CTRL_REV)));
+
+	return TUSB_REV_MAJOR(musb_readl(base, TUSB_INT_CTRL_REV));
+}
+
+static void tusb_wbus_quirk(struct musb *musb, int enabled)
+{
+	void __iomem	*base = musb->ctrl_base;
+	static u32	phy_otg_ctrl = 0;
+
+	if (enabled) {
+		DBG(2, "Enabling tusb wbus quirk\n");
+		musb_writel(base, TUSB_PHY_OTG_CTRL_ENABLE,
+				TUSB_PHY_OTG_CTRL_WRPROTECT |
+				TUSB_PHY_OTG_CTRL_TESTM2 |
+				TUSB_PHY_OTG_CTRL_TESTM1 |
+				TUSB_PHY_OTG_CTRL_TESTM0);
+		phy_otg_ctrl = musb_readl(base, TUSB_PHY_OTG_CTRL);
+		musb_writel(base, TUSB_PHY_OTG_CTRL,
+				TUSB_PHY_OTG_CTRL_WRPROTECT |
+				TUSB_PHY_OTG_CTRL_TESTM2);
+	} else if (musb_readl(base, TUSB_PHY_OTG_CTRL_ENABLE)
+			& TUSB_PHY_OTG_CTRL_TESTM2) {
+		DBG(3, "Disabling tusb wbus quirk\n");
+		musb_writel(base, TUSB_PHY_OTG_CTRL,
+			TUSB_PHY_OTG_CTRL_WRPROTECT | phy_otg_ctrl);
+		musb_writel(base, TUSB_PHY_OTG_CTRL_ENABLE,
+			TUSB_PHY_OTG_CTRL_WRPROTECT);
+		phy_otg_ctrl = 0;
+	}
+}
 
 /*
  * TUSB 6010 may use a parallel bus that doesn't support byte ops;
@@ -253,6 +314,11 @@
 	void __iomem	*base = musb->ctrl_base;
 	u32		reg;
 
+	if ((wakeup_enables & TUSB_PRCM_WBUS)
+			&& musb_platform_get_vbus_status(musb)
+			&& (tusb_get_revision(musb) == TUSB_REV_30))
+		tusb_wbus_quirk(musb, 1);
+
 	tusb_set_clock_source(musb, 0);
 
 	wakeup_enables |= TUSB_PRCM_WNORCS;
@@ -302,7 +368,7 @@
 		musb_writel(base, TUSB_PRCM_MNGMT, prcm_mngmt);
 	}
 
-	if (otg_stat & TUSB_DEV_OTG_STAT_VBUS_SENSE)
+	if (otg_stat & TUSB_DEV_OTG_STAT_VBUS_VALID)
 		ret = 1;
 
 	return ret;
@@ -651,6 +717,9 @@
 		u32	reg;
 		u32	i;
 
+		if (tusb_get_revision(musb) == TUSB_REV_30)
+			tusb_wbus_quirk(musb, 0);
+
 		/* there are issues re-locking the PLL on wakeup ... */
 
 		/* work around issue 8 */
@@ -829,30 +898,6 @@
 	musb_writel(base, TUSB_WAIT_COUNT, 1);
 }
 
-#define TUSB_REV_MAJOR(reg_val)		((reg_val >> 4) & 0xf)
-#define TUSB_REV_MINOR(reg_val)		(reg_val & 0xf)
-
-static int __init tusb_print_revision(struct musb *musb)
-{
-	void __iomem	*base = musb->ctrl_base;
-
-	pr_info("tusb: Revisions: %s%i.%i %s%i.%i %s%i.%i %s%i.%i\n",
-		"prcm",
-		TUSB_REV_MAJOR(musb_readl(base, TUSB_PRCM_REV)),
-		TUSB_REV_MINOR(musb_readl(base, TUSB_PRCM_REV)),
-		"int",
-		TUSB_REV_MAJOR(musb_readl(base, TUSB_INT_CTRL_REV)),
-		TUSB_REV_MINOR(musb_readl(base, TUSB_INT_CTRL_REV)),
-		"gpio",
-		TUSB_REV_MAJOR(musb_readl(base, TUSB_GPIO_REV)),
-		TUSB_REV_MINOR(musb_readl(base, TUSB_GPIO_REV)),
-		"dma",
-		TUSB_REV_MAJOR(musb_readl(base, TUSB_DMA_CTRL_REV)),
-		TUSB_REV_MINOR(musb_readl(base, TUSB_DMA_CTRL_REV)));
-
-	return TUSB_REV_MAJOR(musb_readl(base, TUSB_INT_CTRL_REV));
-}
-
 static int __init tusb_start(struct musb *musb)
 {
 	void __iomem	*base = musb->ctrl_base;
drivers/usb/musb/tusb6010.h +4 -0
Index: linux-omap-2.6/drivers/usb/musb/tusb6010.h
===================================================================
@@ -216,6 +216,10 @@
 #define TUSB_PROD_TEST_RESET_VAL		0xa596
 #define TUSB_EP_FIFO(ep)			(TUSB_FIFO_BASE + (ep) * 0x20)
 
+#define TUSB_REV_1	0x10
+#define TUSB_REV_2	0x20
+#define TUSB_REV_30	0x30
+
 /*----------------------------------------------------------------------------*/
 
 #ifdef CONFIG_USB_TUSB6010
#3 lore raw

PATCH 1/1 musb_hdrc: Add SRP Interface and control it through sysfs

From: Felipe Balbi <[email protected]>

This patch adds a method to start SRP and a userspace interface to control it through sysfs.

---

drivers/usb/musb/musb_gadget.c +26 -0
Index: linux-omap-2.6/drivers/usb/musb/musb_gadget.c
===================================================================
@@ -2056,3 +2056,29 @@
 	(void) musb_gadget_vbus_draw(&musb->g,
 			is_otg_enabled(musb) ? 8 : 100);
 }
+
+/* called when we want to send a Session Request. Caller must hold the lock */
+void musb_g_srp(struct musb *musb)
+{
+	void __iomem	*base = musb->pRegs;
+	u8	devctl = musb_readb(base, MGC_O_HDRC_DEVCTL);
+
+	DBG(3, "Starting SRP\n");
+
+	musb_writeb(base, MGC_O_HDRC_DEVCTL, devctl | MGC_M_DEVCTL_BDEVICE);
+
+	/* In order to start SRP we need to ensure that Vbus is below the
+	 * Session Valid Threshold.
+	 * On MUSB this means that  MGC_M_DEVCTL_VBUS and MGC_S_DEVCTL_VBUS
+	 * are set to 00.
+	 */
+	devctl &= MGC_M_DEVCTL_VBUS & MGC_S_DEVCTL_VBUS;
+
+	if (!devctl) {
+		devctl = musb_readb(base, MGC_O_HDRC_DEVCTL);
+		devctl |= MGC_M_DEVCTL_SESSION | MGC_M_DEVCTL_BDEVICE;
+
+		musb_writeb(base, MGC_O_HDRC_DEVCTL, devctl);
+	} else
+		DBG(7, "Cannot Start SRP: devctl = %02x\n" , devctl);
+}
drivers/usb/musb/musbdefs.h +2 -0
Index: linux-omap-2.6/drivers/usb/musb/musbdefs.h
===================================================================
@@ -124,6 +124,7 @@
 extern void musb_g_reset(struct musb *);
 extern void musb_g_suspend(struct musb *);
 extern void musb_g_resume(struct musb *);
+extern void musb_g_srp(struct musb *);
 extern void musb_g_disconnect(struct musb *);
 
 #else
@@ -134,6 +135,7 @@
 static inline void musb_g_reset(struct musb *m) {}
 static inline void musb_g_suspend(struct musb *m) {}
 static inline void musb_g_resume(struct musb *m) {}
+static inline void musb_g_srp(struct musb *m) {}
 static inline void musb_g_disconnect(struct musb *m) {}
 
 #endif
drivers/usb/musb/plat_uds.c +32 -0
Index: linux-omap-2.6/drivers/usb/musb/plat_uds.c
===================================================================
@@ -1579,6 +1579,32 @@
 }
 static DEVICE_ATTR(cable, S_IRUGO, musb_cable_show, NULL);
 
+#ifdef CONFIG_USB_MUSB_OTG
+static ssize_t
+musb_srp_store(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t n)
+{
+	struct musb	*musb=dev_to_musb(dev);
+	unsigned long	flags;
+	unsigned short	srp;
+
+	if (sscanf(buf, "%hu", &srp) != 1
+			|| (srp != 1)) {
+		printk (KERN_ERR "SRP: Value must be 1\n");
+		return -EINVAL;
+	}
+
+	spin_lock_irqsave(&musb->Lock, flags);
+	if (srp == 1){
+		musb_g_srp(musb);
+	}
+	spin_unlock_irqrestore(&musb->Lock, flags);
+
+	return n;
+}
+static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store);
+#endif /* CONFIG_USB_MUSB_OTG */
+
 #endif
 
 /* Only used to provide cable state change events */
@@ -1648,6 +1674,9 @@
 #ifdef CONFIG_SYSFS
 	device_remove_file(musb->controller, &dev_attr_mode);
 	device_remove_file(musb->controller, &dev_attr_cable);
+#ifdef CONFIG_USB_MUSB_OTG
+	device_remove_file(musb->controller, &dev_attr_srp);
+#endif
 #endif
 
 #ifdef CONFIG_USB_GADGET_MUSB_HDRC
@@ -1876,6 +1905,9 @@
 #ifdef CONFIG_SYSFS
 	status = device_create_file(dev, &dev_attr_mode);
 	status = device_create_file(dev, &dev_attr_cable);
+#ifdef CONFIG_USB_MUSB_OTG
+	status = device_create_file(dev, &dev_attr_srp);
+#endif /* CONFIG_USB_MUSB_OTG */
 	status = 0;
 #endif
 
#4 lore raw

PATCH 1/1 Add Sysfs Interface to Control Vbus states

From: Felipe Balbi <[email protected]>

We need to control Vbus in order to save power and let us test SRP features.
This sysfs interface provides an easy way to control the Vbus states.

HowTo use it:
echo off > /sys/devices/platform/musb_hdrc/vbus
or
echo on > /sys/devices/platform/musb_hdrc/vbus

Later improvements:
* Check current Vbus state before setting new state.
* Implement MUSB PM features and shutdown Vbus whenever we're not using the Bus.

---

drivers/usb/musb/plat_uds.c +74 -0
Index: linux-omap-2.6/drivers/usb/musb/plat_uds.c
===================================================================
@@ -1579,6 +1579,78 @@
 }
 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)
+{
+	struct musb	*musb = dev_to_musb(dev);
+	unsigned long	flags;
+	u8		devctl;
+
+	/* REVISIT the correct way to do it would be checking if we're
+	 * the Standard A device. B devices do not provide Vbus.
+	 */
+	spin_lock_irqsave(&musb->Lock, flags);
+	devctl = musb_readb(musb->pRegs, MGC_O_HDRC_DEVCTL);
+	if (!strncmp(buf, "on", 2)) {
+		u8 power = musb_readb(musb->pRegs, MGC_O_HDRC_POWER);
+
+		musb->xceiv.default_a = 1;
+		devctl |= MGC_M_DEVCTL_SESSION;
+		musb_writeb(musb->pRegs, MGC_O_HDRC_DEVCTL, devctl);
+		musb_set_vbus(musb, 1);
+
+		/* After turning on Vbus we need to generate a reset signal
+		 * on the bus. The following code treats this
+		 */
+		power &= 0xf0;
+		musb_writeb(musb->pRegs, MGC_O_HDRC_POWER,
+				power | MGC_M_POWER_RESET);
+		musb->port1_status |= USB_PORT_STAT_RESET;
+		musb->port1_status &= ~USB_PORT_STAT_ENABLE;
+		musb->rh_timer = jiffies + msecs_to_jiffies(20);
+
+		/* REVISIT after sending the reset signal during 20msecs
+		 * we need to clear the RESET bit in the power register
+		 */
+		if (time_after(jiffies, musb->rh_timer))
+			musb_writeb(musb->pRegs, MGC_O_HDRC_POWER,
+					power & ~MGC_M_POWER_RESET);
+
+	}
+	if (!strncmp(buf, "off", 3)) {
+		devctl |= ~MGC_M_DEVCTL_SESSION;
+		musb_writeb(musb->pRegs, MGC_O_HDRC_DEVCTL, devctl);
+		musb_set_vbus(musb, 0);
+	}
+	/* REVIST when shutting down Vbus we should enter A_IDLE state and not
+	 * B_IDLE. Check tusb_source_power() definition
+	 */
+	spin_unlock_irqrestore(&musb->Lock, flags);
+
+	return n;
+}
+
+static ssize_t
+musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct musb	*musb = dev_to_musb(dev);
+	unsigned long	flags;
+	int		vbus;
+	char		*ret;
+
+	spin_lock_irqsave(&musb->Lock, flags);
+	vbus = musb_platform_get_vbus_status(musb);
+	if (vbus)
+		ret = "Vbus on";
+	else
+		ret = "Vbus off";
+	spin_unlock_irqrestore(&musb->Lock, flags);
+
+	return sprintf(buf, "%s\n", ret);
+}
+static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store);
+
 #ifdef CONFIG_USB_MUSB_OTG
 static ssize_t
 musb_srp_store(struct device *dev, struct device_attribute *attr,
@@ -1674,6 +1746,7 @@
 #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);
 #endif
@@ -1905,6 +1978,7 @@
 #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_MUSB_OTG
 	status = device_create_file(dev, &dev_attr_srp);
 #endif /* CONFIG_USB_MUSB_OTG */
#5 lore raw

PATCH 1/1 Add more Test Modes

From: Felipe Balbi <[email protected]>

This patch adds missing TestMode to MUSB driver. Needed to run USB Certification Tests.

---

drivers/usb/musb/virthub.c +5 -1
index 6a65f4f..b86f034 100644
@@ -362,7 +362,11 @@ int musb_hub_control(
 				temp = MGC_M_TEST_FORCE_HOST
 					| MGC_M_TEST_FORCE_HS;
 
-				/* FIXME and enable a session too */
+				musb_writeb(musb->pRegs, MGC_O_HDRC_DEVCTL, MGC_M_DEVCTL_SESSION);
+				break;
+			case 6:
+				pr_debug("TEST_FIFO_ACCESS\n");
+				temp = MGC_M_TEST_FIFO_ACCESS;
 				break;
 			default:
 				goto error;
Signature · 1 line
1.5.2.rc3.39.gaf9b
#6 lore raw

PATCH 1/1 musb_hdrc: Make HNP work

From: Tony Lindgren <[email protected]>

This patch makes Host Negotiation Protocol (HNP) mostly work. To enable HNP to turn B-device into B-host, do:

# echo 1 > /sys/devices/platform/musb_hdrc/hnp

To disable B-host:

# echo 0 > /sys/devices/platform/musb_hdrc/hnp

Currently you probably need to replug the B-device after stopping HNP to have it detected.

---

drivers/usb/musb/g_ep0.c +16 -10
Index: linux-omap-2.6/drivers/usb/musb/g_ep0.c
===================================================================
@@ -201,6 +201,21 @@
 }
 
 /*
+ * Tries to start B-device HNP negotiation if enabled via sysfs
+ */
+static inline void musb_try_b_hnp_enable(struct musb *musb)
+{
+	void __iomem	*pBase = musb->pRegs;
+	u8		devctl;
+
+	if (musb->is_hnp_enabled) {
+		DBG(1, "HNP: Setting HR\n");
+		devctl = musb_readb(pBase, MGC_O_HDRC_DEVCTL);
+		musb_writeb(pBase, MGC_O_HDRC_DEVCTL, devctl | MGC_M_DEVCTL_HR);
+	}
+}
+
+/*
  * Handle all control requests with no DATA stage, including standard
  * requests such as:
  * USB_REQ_SET_CONFIGURATION, USB_REQ_SET_INTERFACE, unrecognized
@@ -326,17 +341,8 @@
 				case USB_DEVICE_B_HNP_ENABLE:
 					if (!musb->g.is_otg)
 						goto stall;
-					{ u8 devctl;
 					musb->g.b_hnp_enable = 1;
-					devctl = musb_readb(pBase,
-							MGC_O_HDRC_DEVCTL);
-					/* NOTE:  at least DaVinci doesn't
-					 * like to set HR ...
-					 */
-					DBG(1, "set HR\n");
-					musb_writeb(pBase, MGC_O_HDRC_DEVCTL,
-						devctl | MGC_M_DEVCTL_HR);
-					}
+					musb_try_b_hnp_enable(musb);
 					break;
 				case USB_DEVICE_A_HNP_SUPPORT:
 					if (!musb->g.is_otg)
drivers/usb/musb/musb_gadget.c +8 -0
Index: linux-omap-2.6/drivers/usb/musb/musb_gadget.c
===================================================================
@@ -1872,6 +1872,11 @@
 	 */
 
 	spin_lock_irqsave(&musb->Lock, flags);
+
+#ifdef	CONFIG_USB_MUSB_OTG
+	musb_hnp_stop(musb);
+#endif
+
 	if (musb->pGadgetDriver == driver) {
 		musb->xceiv.state = OTG_STATE_UNDEFINED;
 		stop_activity(musb, driver);
@@ -1984,6 +1989,9 @@
 #ifdef	CONFIG_USB_MUSB_OTG
 		musb->xceiv.state = OTG_STATE_A_IDLE;
 		break;
+	case OTG_STATE_A_PERIPHERAL:
+		musb->xceiv.state = OTG_STATE_A_WAIT_VFALL;
+		break;
 	case OTG_STATE_B_WAIT_ACON:
 	case OTG_STATE_B_HOST:
 #endif
drivers/usb/musb/musbdefs.h +4 -0
Index: linux-omap-2.6/drivers/usb/musb/musbdefs.h
===================================================================
@@ -469,6 +469,8 @@
 #ifdef CONFIG_USB_MUSB_OTG
 	/* FIXME this can't be OTG-specific ... ? */
 	u8 bDelayPortPowerOff;
+
+	unsigned		is_hnp_enabled:1;
 #endif
 
 #ifdef MUSB_CONFIG_PROC_FS
@@ -508,6 +510,8 @@
 extern void musb_platform_enable(struct musb *musb);
 extern void musb_platform_disable(struct musb *musb);
 
+extern void musb_hnp_stop(struct musb *musb);
+
 #ifdef CONFIG_USB_TUSB6010
 extern void musb_platform_try_idle(struct musb *musb);
 extern int musb_platform_get_vbus_status(struct musb *musb);
drivers/usb/musb/plat_uds.c +141 -14

227 lines not on this page · raw message

#7 lore raw

PATCH 1/1 USB: Fix OTG HNP for hub.c

From: Tony Lindgren <[email protected]>

This patch makes makes OTG Host Negotiation Protocol (HNP) to behave.

---

drivers/usb/core/hub.c +77 -57
Index: linux-omap-2.6/drivers/usb/core/hub.c
===================================================================
@@ -1252,6 +1252,81 @@
 #ifdef	CONFIG_USB_OTG
 #include "otg_whitelist.h"
 static int __usb_port_suspend(struct usb_device *, int port1);
+
+/*
+ * OTG-aware devices on OTG-capable root hubs may be able to use SRP,
+ * to wake us after we've powered off VBUS; and HNP, switching roles
+ * "host" to "peripheral".  The OTG descriptor helps figure this out.
+ */
+static int usb_new_device_offer_hnp(struct usb_device *udev)
+{
+	struct usb_bus			*bus = udev->bus;
+	unsigned			port1 = udev->portnum;
+	struct usb_otg_descriptor	*desc = 0;
+	int				err;
+
+	if (udev->bus->is_b_host || !udev->config
+			|| udev->parent != udev->bus->root_hub)
+		return 0;
+
+	/* Descriptor may appear anywhere in config */
+	err = __usb_get_extra_descriptor(udev->rawdescriptors[0],
+				le16_to_cpu(udev->config[0].desc.wTotalLength),
+				USB_DT_OTG, (void **) &desc);
+	if (err < 0)
+		return 0;
+
+	if (!(desc->bmAttributes & USB_OTG_HNP))
+		return 0;
+
+	dev_info(&udev->dev, "Dual-Role OTG device on %sHNP port\n",
+				(port1 == bus->otg_port) ? "" : "non-");
+
+	/* Tell B-device if we support HNP */
+	if (port1 == bus->otg_port)
+		bus->b_hnp_enable = 1;
+	err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+			USB_REQ_SET_FEATURE, 0,
+			bus->b_hnp_enable ? USB_DEVICE_B_HNP_ENABLE
+			: USB_DEVICE_A_ALT_HNP_SUPPORT,
+			0, NULL, 0, USB_CTRL_SET_TIMEOUT);
+	if (err < 0) {
+		/*
+		 * OTG MESSAGE: report errors here, customize to match your
+		 * product.
+		 */
+		dev_err(&udev->dev, "can't set HNP mode; %d\n", err);
+		bus->b_hnp_enable = 0;
+		return 0;
+	}
+
+	/* If B-device wants to do HNP, it will do it after we suspend */
+	if (bus->b_hnp_enable) {
+		dev_err(&udev->dev, "trying HNP, suspending bus\n");
+		err = __usb_port_suspend(udev, udev->bus->otg_port);
+		if (err < 0) {
+			dev_err(&udev->dev, "suspend for HNP failed\n");
+			return -ENODEV;
+		}
+
+		/* TB_ASE0_BRST, minimum 3.125 ms */
+		mdelay(4);
+
+		/* Failed resume means B-device took over the bus with HNP */
+		err = usb_port_resume(udev);
+		if (err < 0) {
+			dev_err(&udev->dev, "HNP success\n");
+			return -ENODEV;
+		}
+	}
+
+	/* HNP failed. Reject B-devices not in our whitelist */
+	if (!is_targeted(udev))
+		return -ENODEV;
+
+	return 0;
+}
+
 #endif
 
 /**
@@ -1305,63 +1380,8 @@
 	show_string(udev, "SerialNumber", udev->serial);
 
 #ifdef	CONFIG_USB_OTG
-	/*
-	 * OTG-aware devices on OTG-capable root hubs may be able to use SRP,
-	 * to wake us after we've powered off VBUS; and HNP, switching roles
-	 * "host" to "peripheral".  The OTG descriptor helps figure this out.
-	 */
-	if (!udev->bus->is_b_host
-			&& udev->config
-			&& udev->parent == udev->bus->root_hub) {
-		struct usb_otg_descriptor	*desc = 0;
-		struct usb_bus			*bus = udev->bus;
-
-		/* descriptor may appear anywhere in config */
-		if (__usb_get_extra_descriptor (udev->rawdescriptors[0],
-					le16_to_cpu(udev->config[0].desc.wTotalLength),
-					USB_DT_OTG, (void **) &desc) == 0) {
-			if (desc->bmAttributes & USB_OTG_HNP) {
-				unsigned		port1 = udev->portnum;
-
-				dev_info(&udev->dev,
-					"Dual-Role OTG device on %sHNP port\n",
-					(port1 == bus->otg_port)
-						? "" : "non-");
-
-				/* enable HNP before suspend, it's simpler */
-				if (port1 == bus->otg_port)
-					bus->b_hnp_enable = 1;
-				err = usb_control_msg(udev,
-					usb_sndctrlpipe(udev, 0),
-					USB_REQ_SET_FEATURE, 0,
-					bus->b_hnp_enable
-						? USB_DEVICE_B_HNP_ENABLE
-						: USB_DEVICE_A_ALT_HNP_SUPPORT,
-					0, NULL, 0, USB_CTRL_SET_TIMEOUT);
-				if (err < 0) {
-					/* OTG MESSAGE: report errors here,
-					 * customize to match your product.
-					 */
-					dev_info(&udev->dev,
-						"can't set HNP mode; %d\n",
-						err);
-					bus->b_hnp_enable = 0;
-				}
-			}
-		}
-	}
-
-	if (!is_targeted(udev)) {
-
-		/* Maybe it can talk to us, though we can't talk to it.
-		 * (Includes HNP test device.)
-		 */
-		if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
-			err = __usb_port_suspend(udev, udev->bus->otg_port);
-			if (err < 0)
-				dev_dbg(&udev->dev, "HNP fail, %d\n", err);
-		}
-		err = -ENODEV;
+	err = usb_new_device_offer_hnp(udev);
+	if (err < 0) {
 		goto fail;
 	}
 #endif
#8 lore raw

PATCH 1/1 HSET tool for the MUSB Controler

From: Vikram Pandita <[email protected]>

This patch was took from linux-usb-devel mailing list.

It will help us until I finish developing a userspace application such as USBHSET.exe tool from usb.org/developer/tools.

We need to provide such tool for the USB Certification Lab.

---

drivers/usb/musb/Makefile +1 -1
Index: linux-omap-2.6/drivers/usb/musb/Makefile
===================================================================
@@ -23,7 +23,7 @@
 endif
 
 ifeq ($(CONFIG_USB_MUSB_HDRC_HCD),y)
-	musb_hdrc-objs		+= virthub.o musb_host.o
+	musb_hdrc-objs		+= virthub.o musb_host.o musb_hset.o
 endif
 
 # the kconfig must guarantee that only one of the
drivers/usb/musb/musb_hset.c new file +597 -0

597 lines not on this page · raw message

drivers/usb/musb/musbdefs.h +18 -1
Index: linux-omap-2.6/drivers/usb/musb/musbdefs.h
===================================================================
@@ -489,6 +489,16 @@
 }
 #endif
 
+/* for high speed test mode; see USB 2.0 spec */
+static const u8 musb_test_packet[53] = {
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+	0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+	0xaa, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
+	0xee, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xbf, 0xdf,
+	0xef, 0xf7, 0xfb, 0xfd, 0xfc, 0x7e, 0xbf, 0xdf,
+	0xef, 0xf7, 0xfb, 0xfd, 0x7e
+};
 
 /***************************** Glue it together *****************************/
 
@@ -532,7 +542,8 @@
 extern struct proc_dir_entry *musb_debug_create(char *name,
 						    struct musb *data);
 extern void musb_debug_delete(char *name, struct musb *data);
-
+extern void musb_init_hset(char *name, struct musb *musb);
+extern void musb_exit_hset(char *name, struct musb *musb);
 #else
 static inline struct proc_dir_entry *musb_debug_create(char *name,
 							   struct musb *data)
@@ -542,6 +553,12 @@
 static inline void musb_debug_delete(char *name, struct musb *data)
 {
 }
+static inline void musb_init_hset(char *name, struct musb *musb)
+{
+}
+static inline void musb_exit_hset(char *name, struct musb *musb)
+{
+}
 #endif
 
 #endif	/* __MUSB_MUSBDEFS_H__ */
drivers/usb/musb/plat_uds.c +7 -22
Index: linux-omap-2.6/drivers/usb/musb/plat_uds.c
===================================================================
@@ -248,27 +248,6 @@
 
 
 /*-------------------------------------------------------------------------*/
-
-/* for high speed test mode; see USB 2.0 spec 7.1.20 */
-static const u8 musb_test_packet[53] = {
-	/* implicit SYNC then DATA0 to start */
-
-	/* JKJKJKJK x9 */
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	/* JJKKJJKK x8 */
-	0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
-	/* JJJJKKKK x8 */
-	0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee, 0xee,
-	/* JJJJJJJKKKKKKK x8 */
-	0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-	/* JJJJJJJK x8 */
-	0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd,
-	/* JKKKKKKK x10, JK */
-	0xfc, 0x7e, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0x7e
-
-	/* implicit CRC16 then EOP to end */
-};
-
 void musb_load_testpacket(struct musb *musb)
 {
 	void __iomem	*regs = musb->aLocalEnd[0].regs;
@@ -2084,8 +2063,13 @@
 
 	}
 
-	if (status == 0)
+	if (status == 0) {
 		musb_debug_create("driver/musb_hdrc", pThis);
+#ifdef CONFIG_USB_MUSB_HDRC_HCD
+		musb_init_hset("driver/musb_HSET", pThis);
+#endif
+
+	}
 	else {
 fail:
 		if (pThis->clock)
@@ -2162,6 +2146,7 @@
 	musb_shutdown(pdev);
 	musb_debug_delete("driver/musb_hdrc", musb);
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
+	musb_exit_hset("driver/musb_HSET", musb);
 	if (musb->board_mode == MUSB_HOST)
 		usb_remove_hcd(musb_to_hcd(musb));
 #endif
#9 lore raw

PATCH 1/1 Leave GPIO[7:6] pullups enabled.

From: Felipe Balbi <[email protected]>

GPIO7 and GPIO6 are configured as default wake-up sources for tusb6010.

without this patch MUSB is not able to enumerate
any device that draw power from it.

After applying this patch, we're passing in almost all OTG Electrical Tests.

---

drivers/usb/musb/tusb6010.c +5 -2
Index: linux-omap-2.6/drivers/usb/musb/tusb6010.c
===================================================================
@@ -879,8 +879,11 @@
 {
 	void __iomem	*base = musb->ctrl_base;
 
-	/* Disable GPIO[7:0] pullups (used as output DMA requests) */
-	musb_writel(base, TUSB_PULLUP_1_CTRL, 0x000000FF);
+	/* GPIO[7:6] are the default wake-up sources for tusb6010.
+	 * We cannot disable their pullups.
+	 *
+	 * Disable GPIO[5:0] pullups (used as output DMA requests) */
+	musb_writel(base, TUSB_PULLUP_1_CTRL, 0x0000003F);
 	/* Disable all pullups on NOR IF, DMAREQ0 and DMAREQ1 */
 	musb_writel(base, TUSB_PULLUP_2_CTRL, 0x01FFFFFF);
 

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw

Re: [PATCH] Leave GPIO[7:6] pullups enabled.

In reply to Felipe Balbi
Quoted 22 lines · Felipe Balbi

From: Felipe Balbi <[email protected]>

GPIO7 and GPIO6 are configured as default wake-up sources for tusb6010.

without this patch MUSB is not able to enumerate
any device that draw power from it.

After applying this patch, we're passing in almost all OTG Electrical Tests.

---

Index: linux-omap-2.6/drivers/usb/musb/tusb6010.c
===================================================================

drivers/usb/musb/tusb6010.c +0 -0
@@ -879,8 +879,11 @@
 {
 	void __iomem	*base = musb->ctrl_base;
 

drivers/usb/musb/tusb6010.c line 889

Quoted 10 lines
drivers/usb/musb/tusb6010.c +5 -2
-	/* Disable GPIO[7:0] pullups (used as output DMA requests) */
-	musb_writel(base, TUSB_PULLUP_1_CTRL, 0x000000FF);
+	/* GPIO[7:6] are the default wake-up sources for tusb6010.
+	 * We cannot disable their pullups.
+	 *
+	 * Disable GPIO[5:0] pullups (used as output DMA requests) */
+	musb_writel(base, TUSB_PULLUP_1_CTRL, 0x0000003F);
 	/* Disable all pullups on NOR IF, DMAREQ0 and DMAREQ1 */
 	musb_writel(base, TUSB_PULLUP_2_CTRL, 0x01FFFFFF);
 

Pushing this one today, I edited the comments a bit.

Tony

#14 lore raw

Re: [PATCH] USB: Fix OTG HNP for hub.c

In reply to Felipe Balbi
Quoted 4 lines · Felipe Balbi

From: Tony Lindgren <[email protected]>

This patch makes makes OTG Host Negotiation Protocol (HNP) to behave.

Not really. It makes it strongly *MIS* behave in fact, since it always kicks off HNP ... even when it should not do so, because the device is in the whitelist. (Called the "Targeted Peripherals List", TPL, in jargonese.)

The two blocks of code are in the wrong order ...

A more limited patch would help. Specifically, just fixing whatever bug was seen in the original code, rather than abstracting it into a new subroutine and changing the logic while doing so.

- Dave

Quoted 24 lines
drivers/usb/core/hub.c +24 -0
+	/* If B-device wants to do HNP, it will do it after we suspend */
+	if (bus->b_hnp_enable) {
+		dev_err(&udev->dev, "trying HNP, suspending bus\n");
+		err = __usb_port_suspend(udev, udev->bus->otg_port);
+		if (err < 0) {
+			dev_err(&udev->dev, "suspend for HNP failed\n");
+			return -ENODEV;
+		}
+
+		/* TB_ASE0_BRST, minimum 3.125 ms */
+		mdelay(4);
+
+		/* Failed resume means B-device took over the bus with HNP */
+		err = usb_port_resume(udev);
+		if (err < 0) {
+			dev_err(&udev->dev, "HNP success\n");
+			return -ENODEV;
+		}
+	}
+
+	/* HNP failed. Reject B-devices not in our whitelist */
+	if (!is_targeted(udev))
+		return -ENODEV;
+
#15 lore raw

Re: [PATCH] USB: Fix OTG HNP for hub.c

Hi,

Quoted 11 lines · David Brownell
Quoted 4 lines · Felipe Balbi

From: Tony Lindgren <[email protected]>

This patch makes makes OTG Host Negotiation Protocol (HNP) to behave.

Not really. It makes it strongly *MIS* behave in fact, since it always kicks off HNP ... even when it should not do so, because the device is in the whitelist. (Called the "Targeted Peripherals List", TPL, in jargonese.)

Quoted 7 lines

The two blocks of code are in the wrong order ...

A more limited patch would help. Specifically, just fixing whatever bug was seen in the original code, rather than abstracting it into a new subroutine and changing the logic while doing so.

Tony do you have any comments?
Do you mind if I try to re-work you patch?

Quoted 30 lines

- Dave

Quoted 24 lines
drivers/usb/core/hub.c +24 -0
+     /* If B-device wants to do HNP, it will do it after we suspend */
+     if (bus->b_hnp_enable) {
+             dev_err(&udev->dev, "trying HNP, suspending bus\n");
+             err = __usb_port_suspend(udev, udev->bus->otg_port);
+             if (err < 0) {
+                     dev_err(&udev->dev, "suspend for HNP failed\n");
+                     return -ENODEV;
+             }
+
+             /* TB_ASE0_BRST, minimum 3.125 ms */
+             mdelay(4);
+
+             /* Failed resume means B-device took over the bus with HNP */
+             err = usb_port_resume(udev);
+             if (err < 0) {
+                     dev_err(&udev->dev, "HNP success\n");
+                     return -ENODEV;
+             }
+     }
+
+     /* HNP failed. Reject B-devices not in our whitelist */
+     if (!is_targeted(udev))
+             return -ENODEV;
+
Signature · 4 lines
Best Regards,

Felipe Balbi
[email protected]
#16 lore raw

Re: [PATCH] USB: Fix OTG HNP for hub.c

Quoted 15 lines · Felipe Balbi

Hi,

Quoted 12 lines · David Brownell
Quoted 4 lines · Felipe Balbi

From: Tony Lindgren <[email protected]>

This patch makes makes OTG Host Negotiation Protocol (HNP) to behave.

Not really. It makes it strongly *MIS* behave in fact, since it always kicks off HNP ... even when it should not do so, because the device is in the whitelist. (Called the "Targeted Peripherals List", TPL, in jargonese.)

The two blocks of code are in the wrong order ...

Hmm, are you sure about that? My patch is based on USB_TG_1-3.pdf and playing with usbcv13.exe and two N800s.

I'm under the impression that if the peripheral supports HNP, the host must offer HNP at least once during the session.

And as I understand, the whitelist is for peripherals the host supports, with HNP or no HNP.

With my patch, we offer to do HNP right in the beginning of the session. Then the peripheral can use it or not use depending if HNP is enabled on peripheral.

Quoted 4 lines
Quoted 4 lines

A more limited patch would help. Specifically, just fixing whatever bug was seen in the original code, rather than abstracting it into a new subroutine and changing the logic while doing so.

Dave, did you ever get HNP working with any device and test it with usbcv13.exe and OPT?

Quoted 2 lines

Tony do you have any comments?
Do you mind if I try to re-work you patch?

Felipe I guess you're the only one with OPT right now, and that's really what we should use for doing the HNP. So go ahead!

Regards,

Tony

#17 lore raw

Re: [PATCH] USB: Fix OTG HNP for hub.c

Quoted 15 lines · Tony Lindgren
Quoted 14 lines · Felipe Balbi

Hi,

Quoted 11 lines · David Brownell
Quoted 4 lines · Felipe Balbi

From: Tony Lindgren <[email protected]>

This patch makes makes OTG Host Negotiation Protocol (HNP) to behave.

Not really. It makes it strongly *MIS* behave in fact, since it always kicks off HNP ... even when it should not do so, because the device is in the whitelist. (Called the "Targeted Peripherals List", TPL, in jargonese.)

Quoted 7 lines
Quoted 1 line
Quoted 1 line

The two blocks of code are in the wrong order ...

Hmm, are you sure about that? My patch is based on USB_TG_1-3.pdf and playing with usbcv13.exe and two N800s.

I'm under the impression that if the peripheral supports HNP, the host must offer HNP at least once during the session.

See section 6.8.1.4 of the OTG 1.2 spec which says that the A-device first sets up communication with the B-device, when it's on the TPL.

You might be thinking about the later part of 6.8.1.4 which says that "before ending the session" the A-device gives the B-device an opportunity to be the master. That may be a "new" requirement, added by OTG 1.2 and not in OTG 1.0a. But in any case, that's after having done normal "work" (if any).

The mechanism for that is to enter the A_SUSPEND state after enabling HNP. Right now I'd expect autosuspend to make that happen ... that's a new mechanism, we may need to re-evaluate stting B_HNP_ENABLE that early.

Quoted 2 lines

And as I understand, the whitelist is for peripherals the host supports, with HNP or no HNP.

Yes ... and see 6.8.1.4 too. Devices NOT on the whitelist get the A_BUS_REQ = FALSE treatment, triggering HNP or disconnect.

But ones on the whitelist keep A_BUS_REQ = TRUE until they're done getting work done.

Quoted 3 lines

With my patch, we offer to do HNP right in the beginning of the session. Then the peripheral can use it or not use depending if HNP is enabled on peripheral.

There are two requirements. For HNP the only requirement is to try it by the end of the session. But for devices that have not been blacklisted, there's another requirement: first, set up normal communication with that peripheral.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

A more limited patch would help. Specifically, just fixing whatever bug was seen in the original code, rather than abstracting it into a new subroutine and changing the logic while doing so.

Dave, did you ever get HNP working with any device and test it with usbcv13.exe and OPT?

HNP was certainly working on H2 back around 2.6.10/11 using the original OPT ... that's before usbcv13.exe or the very latest (mucho expensivo, high speed capable) OPT hardware.

I believe the OMAP tree has code changes in isp1301_omap (from TI) which allegedly made it work on H3, but broke it on H2. (The OMAP1 OTG core changed a bit between OMAP 1611 and 1710.) Those changes have not yet gone upstream, on the grounds that they'd be a regression.

I may take that H2 out of storage and see how it behaves on current kernels ... it's possible that usbcore changes have broken that support.

- Dave

Quoted 10 lines
Quoted 2 lines

Tony do you have any comments?
Do you mind if I try to re-work you patch?

Felipe I guess you're the only one with OPT right now, and that's really what we should use for doing the HNP. So go ahead!

Regards,

Tony

#18 lore raw

Re: [PATCH] USB: Fix OTG HNP for hub.c

Quoted 24 lines · David Brownell
Quoted 15 lines · Tony Lindgren
Quoted 14 lines · Felipe Balbi

Hi,

Quoted 11 lines · David Brownell
Quoted 4 lines · Felipe Balbi

From: Tony Lindgren <[email protected]>

This patch makes makes OTG Host Negotiation Protocol (HNP) to behave.

Not really. It makes it strongly *MIS* behave in fact, since it always kicks off HNP ... even when it should not do so, because the device is in the whitelist. (Called the "Targeted Peripherals List", TPL, in jargonese.)

Quoted 7 lines
Quoted 1 line
Quoted 1 line

The two blocks of code are in the wrong order ...

Hmm, are you sure about that? My patch is based on USB_TG_1-3.pdf and playing with usbcv13.exe and two N800s.

I'm under the impression that if the peripheral supports HNP, the host must offer HNP at least once during the session.

Quoted 8 lines

See section 6.8.1.4 of the OTG 1.2 spec which says that the A-device first sets up communication with the B-device, when it's on the TPL.

You might be thinking about the later part of 6.8.1.4 which says that "before ending the session" the A-device gives the B-device an opportunity to be the master. That may be a "new" requirement, added by OTG 1.2 and not in OTG 1.0a. But in any case, that's after having done normal "work" (if any).

But HNP can also be offered early in addition to autosuspend (which I have missed). Does "sets up communications with b-device" really mean use it as a peripheral? Or does it mean set up communications to configure b-device?

If the b-device has b_host mode enabled, it does not want to be a peripheral at that point.

Quoted 6 lines

The mechanism for that is to enter the A_SUSPEND state after enabling HNP. Right now I'd expect autosuspend to make that happen ... that's a new mechanism, we may need to re-evaluate stting B_HNP_ENABLE that early.

Quoted 8 lines
Quoted 2 lines

And as I understand, the whitelist is for peripherals the host supports, with HNP or no HNP.

Yes ... and see 6.8.1.4 too. Devices NOT on the whitelist get the A_BUS_REQ = FALSE treatment, triggering HNP or disconnect.

But ones on the whitelist keep A_BUS_REQ = TRUE until they're done getting work done.

Yes, I still don't see a conflict with my patch and 6.8.1.4, if we assume communcations with b-device means just configure it.

Quoted 8 lines
Quoted 3 lines

With my patch, we offer to do HNP right in the beginning of the session. Then the peripheral can use it or not use depending if HNP is enabled on peripheral.

There are two requirements. For HNP the only requirement is to try it by the end of the session. But for devices that have not been blacklisted, there's another requirement: first, set up normal communication with that peripheral.

Hmmm, I ended up doing it this way to get usbcv13.exe OTG tests to pass. I guess it boils down what "sets up communication with b-device" means.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

A more limited patch would help. Specifically, just fixing whatever bug was seen in the original code, rather than abstracting it into a new subroutine and changing the logic while doing so.

Dave, did you ever get HNP working with any device and test it with usbcv13.exe and OPT?

HNP was certainly working on H2 back around 2.6.10/11 using the original OPT ... that's before usbcv13.exe or the very latest (mucho expensivo, high speed capable) OPT hardware.

OK, that's good to hear.

Quoted 9 lines

I believe the OMAP tree has code changes in isp1301_omap (from TI) which allegedly made it work on H3, but broke it on H2. (The OMAP1 OTG core changed a bit between OMAP 1611 and 1710.) Those changes have not yet gone upstream, on the grounds that they'd be a regression.

I may take that H2 out of storage and see how it behaves on current kernels ... it's possible that usbcore changes have broken that support.

Yeh, I suspect it will fail at least usbcv13.exe OTG tests.

Regards,

Tony

#19 lore raw

Re: [PATCH] Add more Test Modes

In reply to Felipe Balbi

drivers/usb/musb/virthub.c int musb_hub_control( · line 369

Quoted 12 lines · Felipe Balbi
drivers/usb/musb/virthub.c +5 -1
@@ -362,7 +362,11 @@ int musb_hub_control(
 				temp = MGC_M_TEST_FORCE_HOST
 					| MGC_M_TEST_FORCE_HS;
 
-				/* FIXME and enable a session too */
+				musb_writeb(musb->pRegs, MGC_O_HDRC_DEVCTL, MGC_M_DEVCTL_SESSION);
+				break;
+			case 6:
+				pr_debug("TEST_FIFO_ACCESS\n");
+				temp = MGC_M_TEST_FIFO_ACCESS;

I don't see this defined in the USB 2.0 specification. Table 11-24 shows values 1-5 only ... where is "6" defined?

FIFO access doesn't make sense as a portable test in any case. If it's needed for some musb-specific thing, this should go into the vendor-specific range (0xc0 and up).

- Dave

Quoted 11 lines
drivers/usb/musb/virthub.c +0 -0
 				break;
 			default:
 				goto error;
Signature · 6 lines
1.5.2.rc3.39.gaf9b

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

Re: [PATCH] musb_hdrc: Add SRP Interface and control it through sysfs

In reply to Felipe Balbi

drivers/usb/musb/musb_gadget.c line 2061

Quoted 9 lines · Felipe Balbi
drivers/usb/musb/musb_gadget.c +3 -0
@@ -2056,3 +2056,29 @@
 	(void) musb_gadget_vbus_draw(&musb->g,
 			is_otg_enabled(musb) ? 8 : 100);
 }
+
+/* called when we want to send a Session Request. Caller must hold the lock */
+void musb_g_srp(struct musb *musb)

This method should not be needed. When you
invoke usb_gadget_wakeup(), that's supposed
to trigger SRP when there's no existing
power session.

Note also that SRP is *NOT* an OTG-only
capability ... so it's incorrect to wrap
calls to such a routine in an OTG #ifdef.
Any peripheral is allowed to issue SRP.

Quoted 10 lines
drivers/usb/musb/plat_uds.c +4 -0
@@ -1579,6 +1579,32 @@
 }
 static DEVICE_ATTR(cable, S_IRUGO, musb_cable_show, NULL);
 
+#ifdef CONFIG_USB_MUSB_OTG
+static ssize_t
+musb_srp_store(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t n)

drivers/usb/musb/plat_uds.c line 1595

Quoted 10 lines
drivers/usb/musb/plat_uds.c +10 -0
+{
+	struct musb	*musb=dev_to_musb(dev);
+	unsigned long	flags;
+	unsigned short	srp;
+
+	if (sscanf(buf, "%hu", &srp) != 1
+			|| (srp != 1)) {
+		printk (KERN_ERR "SRP: Value must be 1\n");
+		return -EINVAL;
+	}

I see no point to such input validation. Why even bother?

drivers/usb/musb/plat_uds.c line 1599

Quoted 4 lines
drivers/usb/musb/plat_uds.c +4 -0
+
+	spin_lock_irqsave(&musb->Lock, flags);
+	if (srp == 1){
+		musb_g_srp(musb);

Call the "resume" method, not a special SRP-only one.

Quoted 12 lines
drivers/usb/musb/plat_uds.c +8 -0
+	}
+	spin_unlock_irqrestore(&musb->Lock, flags);
+
+	return n;
+}
+static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store);
+#endif /* CONFIG_USB_MUSB_OTG */
+
 #endif
 
 /* Only used to provide cable state change events */

drivers/usb/musb/plat_uds.c line 1677

Quoted 4 lines
drivers/usb/musb/plat_uds.c +1 -0
@@ -1648,6 +1674,9 @@
 #ifdef CONFIG_SYSFS
 	device_remove_file(musb->controller, &dev_attr_mode);
 	device_remove_file(musb->controller, &dev_attr_cable);
+#ifdef CONFIG_USB_MUSB_OTG

This, and its sibling later, and the code above, should all be #ifdeffed CONFIG_USB_GADGET_MUSB_HDRC ... since any peripheral may issue SRP, not only OTG-capable ones.

Quoted 20 lines
drivers/usb/musb/plat_uds.c +5 -0
+	device_remove_file(musb->controller, &dev_attr_srp);
+#endif
 #endif
 
 #ifdef CONFIG_USB_GADGET_MUSB_HDRC
@@ -1876,6 +1905,9 @@
 #ifdef CONFIG_SYSFS
 	status = device_create_file(dev, &dev_attr_mode);
 	status = device_create_file(dev, &dev_attr_cable);
+#ifdef CONFIG_USB_MUSB_OTG
+	status = device_create_file(dev, &dev_attr_srp);
+#endif /* CONFIG_USB_MUSB_OTG */
 	status = 0;
 #endif
 

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