mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/10] More USB cleanup and fixes
@ 2014-07-23 13:51 Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 01/10] USB: import ch11.h from Linux Sebastian Hesselbarth
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

Sascha,

I have assembled a bunch of additional imports, cleanup, and fixes
before actually rebasing xHCI HCD on top of your latest USB changes.

Patches 1-3 import ch11.h from Linux and prepare it for use in
Barebox.

Patch 4 fixes a copy-and-paste error in usb_hub_configure().

Patches 5-8 clean up ehci-hcd and make it use ch9.h defines.

Patch 9 installs ch11.h and removes the duplicates from usb.h.

Patch 10 finally removes now redundant defines from usb_defs.h.

I have only compile-tested this as far as I could, so at least a
Tested-by on any EHCI driver would be good.

Sebastian

Sebastian Hesselbarth (10):
  USB: import ch11.h from Linux
  USB: reduce USB_MAXCHILDREN on imported ch11.h
  USB: fixup usb_hub_descriptor length name
  USB: fix PowerPowerCtrlMask assignment
  USB: Move FooRequest defines and add class requests
  USB: EHCI: reuse ch9.h config and interface descriptors
  USB: EHCI: make use of defines for descriptors
  USB: EHCI: use descriptor length fields
  USB: Use descriptors from ch11.h
  USB: remove redundant defines from usb_defs.h

 drivers/usb/core/hub.c      |  10 +-
 drivers/usb/host/ehci-hcd.c | 114 +++++++++---------
 drivers/usb/host/ehci.h     |  41 -------
 include/usb/ch11.h          | 279 ++++++++++++++++++++++++++++++++++++++++++++
 include/usb/usb.h           |  27 +----
 include/usb/usb_defs.h      | 135 ++++-----------------
 6 files changed, 364 insertions(+), 242 deletions(-)
 create mode 100644 include/usb/ch11.h

---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 01/10] USB: import ch11.h from Linux
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 02/10] USB: reduce USB_MAXCHILDREN on imported ch11.h Sebastian Hesselbarth
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

Linux has an extra include for chapter 11 (Hub Specification) of USB 2.0
spec. We already have a ch9.h, so import the one from Linux.

Barebox specific changes will be patched up later.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 include/usb/ch11.h | 277 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 277 insertions(+)
 create mode 100644 include/usb/ch11.h

diff --git a/include/usb/ch11.h b/include/usb/ch11.h
new file mode 100644
index 000000000000..331499d597fa
--- /dev/null
+++ b/include/usb/ch11.h
@@ -0,0 +1,277 @@
+/*
+ * This file holds Hub protocol constants and data structures that are
+ * defined in chapter 11 (Hub Specification) of the USB 2.0 specification.
+ *
+ * It is used/shared between the USB core, the HCDs and couple of other USB
+ * drivers.
+ */
+
+#ifndef __LINUX_CH11_H
+#define __LINUX_CH11_H
+
+#include <linux/types.h>	/* __u8 etc */
+
+/* This is arbitrary.
+ * From USB 2.0 spec Table 11-13, offset 7, a hub can
+ * have up to 255 ports. The most yet reported is 10.
+ *
+ * Current Wireless USB host hardware (Intel i1480 for example) allows
+ * up to 22 devices to connect. Upcoming hardware might raise that
+ * limit. Because the arrays need to add a bit for hub status data, we
+ * use 31, so plus one evens out to four bytes.
+ */
+#define USB_MAXCHILDREN		31
+
+/*
+ * Hub request types
+ */
+
+#define USB_RT_HUB	(USB_TYPE_CLASS | USB_RECIP_DEVICE)
+#define USB_RT_PORT	(USB_TYPE_CLASS | USB_RECIP_OTHER)
+
+/*
+ * Hub class requests
+ * See USB 2.0 spec Table 11-16
+ */
+#define HUB_CLEAR_TT_BUFFER	8
+#define HUB_RESET_TT		9
+#define HUB_GET_TT_STATE	10
+#define HUB_STOP_TT		11
+
+/*
+ * Hub class additional requests defined by USB 3.0 spec
+ * See USB 3.0 spec Table 10-6
+ */
+#define HUB_SET_DEPTH		12
+#define HUB_GET_PORT_ERR_COUNT	13
+
+/*
+ * Hub Class feature numbers
+ * See USB 2.0 spec Table 11-17
+ */
+#define C_HUB_LOCAL_POWER	0
+#define C_HUB_OVER_CURRENT	1
+
+/*
+ * Port feature numbers
+ * See USB 2.0 spec Table 11-17
+ */
+#define USB_PORT_FEAT_CONNECTION	0
+#define USB_PORT_FEAT_ENABLE		1
+#define USB_PORT_FEAT_SUSPEND		2	/* L2 suspend */
+#define USB_PORT_FEAT_OVER_CURRENT	3
+#define USB_PORT_FEAT_RESET		4
+#define USB_PORT_FEAT_L1		5	/* L1 suspend */
+#define USB_PORT_FEAT_POWER		8
+#define USB_PORT_FEAT_LOWSPEED		9	/* Should never be used */
+#define USB_PORT_FEAT_C_CONNECTION	16
+#define USB_PORT_FEAT_C_ENABLE		17
+#define USB_PORT_FEAT_C_SUSPEND		18
+#define USB_PORT_FEAT_C_OVER_CURRENT	19
+#define USB_PORT_FEAT_C_RESET		20
+#define USB_PORT_FEAT_TEST              21
+#define USB_PORT_FEAT_INDICATOR         22
+#define USB_PORT_FEAT_C_PORT_L1         23
+
+/*
+ * Port feature selectors added by USB 3.0 spec.
+ * See USB 3.0 spec Table 10-7
+ */
+#define USB_PORT_FEAT_LINK_STATE		5
+#define USB_PORT_FEAT_U1_TIMEOUT		23
+#define USB_PORT_FEAT_U2_TIMEOUT		24
+#define USB_PORT_FEAT_C_PORT_LINK_STATE		25
+#define USB_PORT_FEAT_C_PORT_CONFIG_ERROR	26
+#define USB_PORT_FEAT_REMOTE_WAKE_MASK		27
+#define USB_PORT_FEAT_BH_PORT_RESET		28
+#define USB_PORT_FEAT_C_BH_PORT_RESET		29
+#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT	30
+
+#define USB_PORT_LPM_TIMEOUT(p)			(((p) & 0xff) << 8)
+
+/* USB 3.0 hub remote wake mask bits, see table 10-14 */
+#define USB_PORT_FEAT_REMOTE_WAKE_CONNECT	(1 << 8)
+#define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT	(1 << 9)
+#define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT	(1 << 10)
+
+/*
+ * Hub Status and Hub Change results
+ * See USB 2.0 spec Table 11-19 and Table 11-20
+ */
+struct usb_port_status {
+	__le16 wPortStatus;
+	__le16 wPortChange;
+} __attribute__ ((packed));
+
+/*
+ * wPortStatus bit field
+ * See USB 2.0 spec Table 11-21
+ */
+#define USB_PORT_STAT_CONNECTION	0x0001
+#define USB_PORT_STAT_ENABLE		0x0002
+#define USB_PORT_STAT_SUSPEND		0x0004
+#define USB_PORT_STAT_OVERCURRENT	0x0008
+#define USB_PORT_STAT_RESET		0x0010
+#define USB_PORT_STAT_L1		0x0020
+/* bits 6 to 7 are reserved */
+#define USB_PORT_STAT_POWER		0x0100
+#define USB_PORT_STAT_LOW_SPEED		0x0200
+#define USB_PORT_STAT_HIGH_SPEED        0x0400
+#define USB_PORT_STAT_TEST              0x0800
+#define USB_PORT_STAT_INDICATOR         0x1000
+/* bits 13 to 15 are reserved */
+
+/*
+ * Additions to wPortStatus bit field from USB 3.0
+ * See USB 3.0 spec Table 10-10
+ */
+#define USB_PORT_STAT_LINK_STATE	0x01e0
+#define USB_SS_PORT_STAT_POWER		0x0200
+#define USB_SS_PORT_STAT_SPEED		0x1c00
+#define USB_PORT_STAT_SPEED_5GBPS	0x0000
+/* Valid only if port is enabled */
+/* Bits that are the same from USB 2.0 */
+#define USB_SS_PORT_STAT_MASK (USB_PORT_STAT_CONNECTION |	    \
+				USB_PORT_STAT_ENABLE |	    \
+				USB_PORT_STAT_OVERCURRENT | \
+				USB_PORT_STAT_RESET)
+
+/*
+ * Definitions for PORT_LINK_STATE values
+ * (bits 5-8) in wPortStatus
+ */
+#define USB_SS_PORT_LS_U0		0x0000
+#define USB_SS_PORT_LS_U1		0x0020
+#define USB_SS_PORT_LS_U2		0x0040
+#define USB_SS_PORT_LS_U3		0x0060
+#define USB_SS_PORT_LS_SS_DISABLED	0x0080
+#define USB_SS_PORT_LS_RX_DETECT	0x00a0
+#define USB_SS_PORT_LS_SS_INACTIVE	0x00c0
+#define USB_SS_PORT_LS_POLLING		0x00e0
+#define USB_SS_PORT_LS_RECOVERY		0x0100
+#define USB_SS_PORT_LS_HOT_RESET	0x0120
+#define USB_SS_PORT_LS_COMP_MOD		0x0140
+#define USB_SS_PORT_LS_LOOPBACK		0x0160
+
+/*
+ * wPortChange bit field
+ * See USB 2.0 spec Table 11-22 and USB 2.0 LPM ECN Table-4.10
+ * Bits 0 to 5 shown, bits 6 to 15 are reserved
+ */
+#define USB_PORT_STAT_C_CONNECTION	0x0001
+#define USB_PORT_STAT_C_ENABLE		0x0002
+#define USB_PORT_STAT_C_SUSPEND		0x0004
+#define USB_PORT_STAT_C_OVERCURRENT	0x0008
+#define USB_PORT_STAT_C_RESET		0x0010
+#define USB_PORT_STAT_C_L1		0x0020
+/*
+ * USB 3.0 wPortChange bit fields
+ * See USB 3.0 spec Table 10-11
+ */
+#define USB_PORT_STAT_C_BH_RESET	0x0020
+#define USB_PORT_STAT_C_LINK_STATE	0x0040
+#define USB_PORT_STAT_C_CONFIG_ERROR	0x0080
+
+/*
+ * wHubCharacteristics (masks)
+ * See USB 2.0 spec Table 11-13, offset 3
+ */
+#define HUB_CHAR_LPSM		0x0003 /* Logical Power Switching Mode mask */
+#define HUB_CHAR_COMMON_LPSM	0x0000 /* All ports power control at once */
+#define HUB_CHAR_INDV_PORT_LPSM	0x0001 /* per-port power control */
+#define HUB_CHAR_NO_LPSM	0x0002 /* no power switching */
+
+#define HUB_CHAR_COMPOUND	0x0004 /* hub is part of a compound device */
+
+#define HUB_CHAR_OCPM		0x0018 /* Over-Current Protection Mode mask */
+#define HUB_CHAR_COMMON_OCPM	0x0000 /* All ports Over-Current reporting */
+#define HUB_CHAR_INDV_PORT_OCPM	0x0008 /* per-port Over-current reporting */
+#define HUB_CHAR_NO_OCPM	0x0010 /* No Over-current Protection support */
+
+#define HUB_CHAR_TTTT		0x0060 /* TT Think Time mask */
+#define HUB_CHAR_PORTIND	0x0080 /* per-port indicators (LEDs) */
+
+struct usb_hub_status {
+	__le16 wHubStatus;
+	__le16 wHubChange;
+} __attribute__ ((packed));
+
+/*
+ * Hub Status & Hub Change bit masks
+ * See USB 2.0 spec Table 11-19 and Table 11-20
+ * Bits 0 and 1 for wHubStatus and wHubChange
+ * Bits 2 to 15 are reserved for both
+ */
+#define HUB_STATUS_LOCAL_POWER	0x0001
+#define HUB_STATUS_OVERCURRENT	0x0002
+#define HUB_CHANGE_LOCAL_POWER	0x0001
+#define HUB_CHANGE_OVERCURRENT	0x0002
+
+
+/*
+ * Hub descriptor
+ * See USB 2.0 spec Table 11-13
+ */
+
+#define USB_DT_HUB			(USB_TYPE_CLASS | 0x09)
+#define USB_DT_SS_HUB			(USB_TYPE_CLASS | 0x0a)
+#define USB_DT_HUB_NONVAR_SIZE		7
+#define USB_DT_SS_HUB_SIZE              12
+
+/*
+ * Hub Device descriptor
+ * USB Hub class device protocols
+ */
+
+#define USB_HUB_PR_FS		0 /* Full speed hub */
+#define USB_HUB_PR_HS_NO_TT	0 /* Hi-speed hub without TT */
+#define USB_HUB_PR_HS_SINGLE_TT	1 /* Hi-speed hub with single TT */
+#define USB_HUB_PR_HS_MULTI_TT	2 /* Hi-speed hub with multiple TT */
+#define USB_HUB_PR_SS		3 /* Super speed hub */
+
+struct usb_hub_descriptor {
+	__u8  bDescLength;
+	__u8  bDescriptorType;
+	__u8  bNbrPorts;
+	__le16 wHubCharacteristics;
+	__u8  bPwrOn2PwrGood;
+	__u8  bHubContrCurrent;
+
+	/* 2.0 and 3.0 hubs differ here */
+	union {
+		struct {
+			/* add 1 bit for hub status change; round to bytes */
+			__u8  DeviceRemovable[(USB_MAXCHILDREN + 1 + 7) / 8];
+			__u8  PortPwrCtrlMask[(USB_MAXCHILDREN + 1 + 7) / 8];
+		}  __attribute__ ((packed)) hs;
+
+		struct {
+			__u8 bHubHdrDecLat;
+			__le16 wHubDelay;
+			__le16 DeviceRemovable;
+		}  __attribute__ ((packed)) ss;
+	} u;
+} __attribute__ ((packed));
+
+/* port indicator status selectors, tables 11-7 and 11-25 */
+#define HUB_LED_AUTO	0
+#define HUB_LED_AMBER	1
+#define HUB_LED_GREEN	2
+#define HUB_LED_OFF	3
+
+enum hub_led_mode {
+	INDICATOR_AUTO = 0,
+	INDICATOR_CYCLE,
+	/* software blinks for attention:  software, hardware, reserved */
+	INDICATOR_GREEN_BLINK, INDICATOR_GREEN_BLINK_OFF,
+	INDICATOR_AMBER_BLINK, INDICATOR_AMBER_BLINK_OFF,
+	INDICATOR_ALT_BLINK, INDICATOR_ALT_BLINK_OFF
+} __attribute__ ((packed));
+
+/* Transaction Translator Think Times, in bits */
+#define HUB_TTTT_8_BITS		0x00
+#define HUB_TTTT_16_BITS	0x20
+#define HUB_TTTT_24_BITS	0x40
+#define HUB_TTTT_32_BITS	0x60
+
+#endif /* __LINUX_CH11_H */
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 02/10] USB: reduce USB_MAXCHILDREN on imported ch11.h
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 01/10] USB: import ch11.h from Linux Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 03/10] USB: fixup usb_hub_descriptor length name Sebastian Hesselbarth
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

Barebox supports up to 8 USB devices attached on a Hub, Linux does 31.
Reduce the USB_MAXCHILDREN define in ch11.h to the Barebox one and
put a comment above.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 include/usb/ch11.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/usb/ch11.h b/include/usb/ch11.h
index 331499d597fa..924a9ea64c5e 100644
--- a/include/usb/ch11.h
+++ b/include/usb/ch11.h
@@ -19,8 +19,10 @@
  * up to 22 devices to connect. Upcoming hardware might raise that
  * limit. Because the arrays need to add a bit for hub status data, we
  * use 31, so plus one evens out to four bytes.
+ *
+ * Reduced to 8 max children for Barebox.
  */
-#define USB_MAXCHILDREN		31
+#define USB_MAXCHILDREN		8
 
 /*
  * Hub request types
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 03/10] USB: fixup usb_hub_descriptor length name
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 01/10] USB: import ch11.h from Linux Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 02/10] USB: reduce USB_MAXCHILDREN on imported ch11.h Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 04/10] USB: fix PowerPowerCtrlMask assignment Sebastian Hesselbarth
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

All other descriptors have their length field named bLength, except
imported usb_hub_descriptor from Linux uses bDescLength. Adjust the
name to match the others.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 include/usb/ch11.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/usb/ch11.h b/include/usb/ch11.h
index 924a9ea64c5e..93f891aea753 100644
--- a/include/usb/ch11.h
+++ b/include/usb/ch11.h
@@ -232,7 +232,7 @@ struct usb_hub_status {
 #define USB_HUB_PR_SS		3 /* Super speed hub */
 
 struct usb_hub_descriptor {
-	__u8  bDescLength;
+	__u8  bLength;
 	__u8  bDescriptorType;
 	__u8  bNbrPorts;
 	__le16 wHubCharacteristics;
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 04/10] USB: fix PowerPowerCtrlMask assignment
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
                   ` (2 preceding siblings ...)
  2014-07-23 13:51 ` [PATCH 03/10] USB: fixup usb_hub_descriptor length name Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 05/10] USB: Move FooRequest defines and add class requests Sebastian Hesselbarth
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

usb_hub_configure() gets the hub descriptor and copies its values
over to a local descriptor.

While copying PortPowerCtrlMask it erroneously overwrites
DeviceRemovable due to a copy-and-paste error. Fix it up.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 drivers/usb/core/hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index f90a927eef66..7553bcdd5ef3 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -342,7 +342,7 @@ static int usb_hub_configure(struct usb_device *dev)
 		hub->desc.DeviceRemovable[i] = descriptor->DeviceRemovable[i];
 
 	for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
-		hub->desc.DeviceRemovable[i] = descriptor->PortPowerCtrlMask[i];
+		hub->desc.PortPowerCtrlMask[i] = descriptor->PortPowerCtrlMask[i];
 
 	dev->maxchild = descriptor->bNbrPorts;
 	dev_dbg(&dev->dev, "%d ports detected\n", dev->maxchild);
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 05/10] USB: Move FooRequest defines and add class requests
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
                   ` (3 preceding siblings ...)
  2014-07-23 13:51 ` [PATCH 04/10] USB: fix PowerPowerCtrlMask assignment Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 06/10] USB: EHCI: reuse ch9.h config and interface descriptors Sebastian Hesselbarth
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

{Device,Interface,Endpoint}Requests are currently defined in private
ehci.h but are also useful for other drivers than ehci-hcd. Move them
to usb/usb_defs.h and also add some more class requests.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 drivers/usb/host/ehci.h | 16 ----------------
 include/usb/usb_defs.h  | 26 ++++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 5d899cc2ec08..b1e768b49304 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -22,22 +22,6 @@
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS	16
 #endif
 
-/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
-#define DeviceRequest \
-	((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
-
-#define DeviceOutRequest \
-	((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
-
-#define InterfaceRequest \
-	((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
-
-#define EndpointRequest \
-	((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
-
-#define EndpointOutRequest \
-	((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
-
 /*
  * Register Space.
  */
diff --git a/include/usb/usb_defs.h b/include/usb/usb_defs.h
index ace20e430d14..461f7dbf4e96 100644
--- a/include/usb/usb_defs.h
+++ b/include/usb/usb_defs.h
@@ -238,4 +238,30 @@
 #define HUB_CHANGE_LOCAL_POWER	0x0001
 #define HUB_CHANGE_OVERCURRENT	0x0002
 
+/* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
+#define DeviceRequest \
+	((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
+
+#define DeviceOutRequest \
+	((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
+
+#define InterfaceRequest \
+	((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
+
+#define EndpointRequest \
+	((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
+
+#define EndpointOutRequest \
+	((USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_INTERFACE) << 8)
+
+/* class requests from the USB 2.0 hub spec, table 11-15 */
+/* GetBusState and SetHubDescriptor are optional, omitted */
+#define ClearHubFeature		(0x2000 | USB_REQ_CLEAR_FEATURE)
+#define ClearPortFeature	(0x2300 | USB_REQ_CLEAR_FEATURE)
+#define GetHubDescriptor	(0xa000 | USB_REQ_GET_DESCRIPTOR)
+#define GetHubStatus		(0xa000 | USB_REQ_GET_STATUS)
+#define GetPortStatus		(0xa300 | USB_REQ_GET_STATUS)
+#define SetHubFeature		(0x2000 | USB_REQ_SET_FEATURE)
+#define SetPortFeature		(0x2300 | USB_REQ_SET_FEATURE)
+
 #endif /*_USB_DEFS_H_ */
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 06/10] USB: EHCI: reuse ch9.h config and interface descriptors
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
                   ` (4 preceding siblings ...)
  2014-07-23 13:51 ` [PATCH 05/10] USB: Move FooRequest defines and add class requests Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 07/10] USB: EHCI: make use of defines for descriptors Sebastian Hesselbarth
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

Now that usb_config_descriptor and usb_interface_descriptor are clean
of any additional fields, drop the duplication in EHCI code and use
the default ones.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 drivers/usb/host/ehci-hcd.c |  4 ++--
 drivers/usb/host/ehci.h     | 25 -------------------------
 2 files changed, 2 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 9e30deb419cc..7857576738d7 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -57,8 +57,8 @@ struct ehci_priv {
 static struct descriptor {
 	struct usb_hub_descriptor hub;
 	struct usb_device_descriptor device;
-	struct usb_linux_config_descriptor config;
-	struct usb_linux_interface_descriptor interface;
+	struct usb_config_descriptor config;
+	struct usb_interface_descriptor interface;
 	struct usb_endpoint_descriptor endpoint;
 }  __attribute__ ((packed)) descriptor = {
 	{
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index b1e768b49304..8cc477aa4ffe 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -68,31 +68,6 @@ struct ehci_hcor {
 #define USBMODE_CM_HC	(3 << 0)	/* host controller mode */
 #define USBMODE_CM_IDLE	(0 << 0)	/* idle state */
 
-/* Interface descriptor */
-struct usb_linux_interface_descriptor {
-	unsigned char	bLength;
-	unsigned char	bDescriptorType;
-	unsigned char	bInterfaceNumber;
-	unsigned char	bAlternateSetting;
-	unsigned char	bNumEndpoints;
-	unsigned char	bInterfaceClass;
-	unsigned char	bInterfaceSubClass;
-	unsigned char	bInterfaceProtocol;
-	unsigned char	iInterface;
-} __attribute__ ((packed));
-
-/* Configuration descriptor information.. */
-struct usb_linux_config_descriptor {
-	unsigned char	bLength;
-	unsigned char	bDescriptorType;
-	unsigned short	wTotalLength;
-	unsigned char	bNumInterfaces;
-	unsigned char	bConfigurationValue;
-	unsigned char	iConfiguration;
-	unsigned char	bmAttributes;
-	unsigned char	MaxPower;
-} __attribute__ ((packed));
-
 #if defined CONFIG_EHCI_DESC_BIG_ENDIAN
 #define	ehci_readl(x)		(*((volatile u32 *)(x)))
 #define ehci_writel(a, b)	(*((volatile u32 *)(a)) = ((volatile u32)b))
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 07/10] USB: EHCI: make use of defines for descriptors
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
                   ` (5 preceding siblings ...)
  2014-07-23 13:51 ` [PATCH 06/10] USB: EHCI: reuse ch9.h config and interface descriptors Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 08/10] USB: EHCI: use descriptor length fields Sebastian Hesselbarth
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

Now that we have a full set of defines for each descriptor field,
make use of it for the EHCI HCD descriptors.

This fixes endianess issues for .device.bcdUSB, .device.bcdDevice,
.config.wTotalLength, and .endpoint.wMaxPacketSize.

Also, .endpoint.bInterval was set to 0 instead of 255 due to a
copy-and-paste error while assigning u8[] to usb_endpoint_descriptor.

This also is a preparation for including ch11.h later, which has
a modified usb_hub_descriptor for USB 3.0.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 drivers/usb/host/ehci-hcd.c | 104 ++++++++++++++++++++++----------------------
 1 file changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 7857576738d7..a3063f988da0 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -61,62 +61,62 @@ static struct descriptor {
 	struct usb_interface_descriptor interface;
 	struct usb_endpoint_descriptor endpoint;
 }  __attribute__ ((packed)) descriptor = {
-	{
-		0x8,		/* bDescLength */
-		0x29,		/* bDescriptorType: hub descriptor */
-		2,		/* bNrPorts -- runtime modified */
-		0,		/* wHubCharacteristics */
-		10,		/* bPwrOn2PwrGood */
-		0,		/* bHubCntrCurrent */
-		{},		/* Device removable */
-		{}		/* at most 7 ports! XXX */
+	.hub = {
+		.bLength		= USB_DT_HUB_NONVAR_SIZE +
+					  ((USB_MAXCHILDREN + 1 + 7) / 8),
+		.bDescriptorType	= USB_DT_HUB,
+		.bNbrPorts		= 2,	/* runtime modified */
+		.wHubCharacteristics	= 0,
+		.bPwrOn2PwrGood		= 10,
+		.bHubContrCurrent	= 0,
+		.DeviceRemovable	= {},
+		.PortPowerCtrlMask	= {}
 	},
-	{
-		0x12,		/* bLength */
-		1,		/* bDescriptorType: UDESC_DEVICE */
-		0x0002,		/* bcdUSB: v2.0 */
-		9,		/* bDeviceClass: UDCLASS_HUB */
-		0,		/* bDeviceSubClass: UDSUBCLASS_HUB */
-		1,		/* bDeviceProtocol: UDPROTO_HSHUBSTT */
-		64,		/* bMaxPacketSize: 64 bytes */
-		0x0000,		/* idVendor */
-		0x0000,		/* idProduct */
-		0x0001,		/* bcdDevice */
-		1,		/* iManufacturer */
-		2,		/* iProduct */
-		0,		/* iSerialNumber */
-		1		/* bNumConfigurations: 1 */
+	.device = {
+		.bLength		= USB_DT_DEVICE_SIZE,
+		.bDescriptorType	= USB_DT_DEVICE,
+		.bcdUSB			= __constant_cpu_to_le16(0x0002), /* v2.0 */
+		.bDeviceClass		= USB_CLASS_HUB,
+		.bDeviceSubClass	= 0,
+		.bDeviceProtocol	= 1,	/* bDeviceProtocol: UDPROTO_HSHUBSTT */
+		.bMaxPacketSize0	= 64,
+		.idVendor		= 0x0000,
+		.idProduct		= 0x0000,
+		.bcdDevice		= __constant_cpu_to_le16(0x0001),
+		.iManufacturer		= 1,
+		.iProduct		= 2,
+		.iSerialNumber		= 0,
+		.bNumConfigurations	= 1
 	},
-	{
-		0x9,
-		2,		/* bDescriptorType: UDESC_CONFIG */
-		cpu_to_le16(0x19),
-		1,		/* bNumInterface */
-		1,		/* bConfigurationValue */
-		0,		/* iConfiguration */
-		0x40,		/* bmAttributes: UC_SELF_POWER */
-		0		/* bMaxPower */
+	.config = {
+		.bLength		= USB_DT_CONFIG_SIZE,
+		.bDescriptorType	= USB_DT_CONFIG,
+		.wTotalLength		= __constant_cpu_to_le16(USB_DT_CONFIG_SIZE +
+					 USB_DT_INTERFACE_SIZE + USB_DT_ENDPOINT_SIZE),
+		.bNumInterfaces		= 1,
+		.bConfigurationValue	= 1,
+		.iConfiguration		= 0,
+		.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
+		.bMaxPower		= 0
 	},
-	{
-		0x9,		/* bLength */
-		4,		/* bDescriptorType: UDESC_INTERFACE */
-		0,		/* bInterfaceNumber */
-		0,		/* bAlternateSetting */
-		1,		/* bNumEndpoints */
-		9,		/* bInterfaceClass: UICLASS_HUB */
-		0,		/* bInterfaceSubClass: UISUBCLASS_HUB */
-		0,		/* bInterfaceProtocol: UIPROTO_HSHUBSTT */
-		0		/* iInterface */
+	.interface = {
+		.bLength		= USB_DT_INTERFACE_SIZE,
+		.bDescriptorType	= USB_DT_INTERFACE,
+		.bInterfaceNumber	= 0,
+		.bAlternateSetting	= 0,
+		.bNumEndpoints		= 1,
+		.bInterfaceClass	= USB_CLASS_HUB,
+		.bInterfaceSubClass	= 0,
+		.bInterfaceProtocol	= 0,	/* bInterfaceProtocol: UIPROTO_HSHUBSTT */
+		.iInterface		= 0
 	},
-	{
-		0x7,		/* bLength */
-		5,		/* bDescriptorType: UDESC_ENDPOINT */
-		0x81,		/* bEndpointAddress:
-				 * UE_DIR_IN | EHCI_INTR_ENDPT
-				 */
-		3,		/* bmAttributes: UE_INTERRUPT */
-		8, 0,		/* wMaxPacketSize */
-		255		/* bInterval */
+	.endpoint = {
+		.bLength		= USB_DT_ENDPOINT_SIZE,
+		.bDescriptorType	= USB_DT_ENDPOINT,
+		.bEndpointAddress	= 0x81,	/* UE_DIR_IN | EHCI_INTR_ENDPT */
+		.bmAttributes		= USB_ENDPOINT_XFER_INT,
+		.wMaxPacketSize		= __constant_cpu_to_le16((USB_MAXCHILDREN + 1 + 7) / 8),
+		.bInterval		= 255
 	},
 };
 
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 08/10] USB: EHCI: use descriptor length fields
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
                   ` (6 preceding siblings ...)
  2014-07-23 13:51 ` [PATCH 07/10] USB: EHCI: make use of defines for descriptors Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 09/10] USB: Use descriptors from ch11.h Sebastian Hesselbarth
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

Instead of hard-coding descriptor length, pick it from the
corresponding descriptor.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 drivers/usb/host/ehci-hcd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index a3063f988da0..ab1bc0331ba1 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -503,12 +503,12 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 		case USB_DT_DEVICE:
 			dev_dbg(ehci->dev, "USB_DT_DEVICE request\n");
 			srcptr = &descriptor.device;
-			srclen = 0x12;
+			srclen = descriptor.device.bLength;
 			break;
 		case USB_DT_CONFIG:
 			dev_dbg(ehci->dev, "USB_DT_CONFIG config\n");
 			srcptr = &descriptor.config;
-			srclen = 0x19;
+			srclen = le16_to_cpu(descriptor.config.wTotalLength);
 			break;
 		case USB_DT_STRING:
 			dev_dbg(ehci->dev, "USB_DT_STRING config\n");
@@ -543,7 +543,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
 		case USB_DT_HUB:
 			dev_dbg(ehci->dev, "USB_DT_HUB config\n");
 			srcptr = &descriptor.hub;
-			srclen = 0x8;
+			srclen = descriptor.hub.bLength;
 			break;
 		default:
 			dev_dbg(ehci->dev, "unknown value %x\n", le16_to_cpu(req->value));
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 09/10] USB: Use descriptors from ch11.h
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
                   ` (7 preceding siblings ...)
  2014-07-23 13:51 ` [PATCH 08/10] USB: EHCI: use descriptor length fields Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-23 13:51 ` [PATCH 10/10] USB: remove redundant defines from usb_defs.h Sebastian Hesselbarth
  2014-07-24  7:05 ` [PATCH 00/10] More USB cleanup and fixes Sascha Hauer
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

Use the descriptors from ch11.h instead of duplicating them
in usb.h. usb_hub_descriptor now contains a union .u to differentiate
HS hub descriptor from SS hub descriptor.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 drivers/usb/core/hub.c      | 10 +++++-----
 drivers/usb/host/ehci-hcd.c |  4 ++--
 include/usb/usb.h           | 27 +--------------------------
 3 files changed, 8 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 7553bcdd5ef3..c1f743cbed12 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -332,17 +332,17 @@ static int usb_hub_configure(struct usb_device *dev)
 	hub->desc.wHubCharacteristics =
 				le16_to_cpu(descriptor->wHubCharacteristics);
 	/* set the bitmap */
-	bitmap = (unsigned char *)&hub->desc.DeviceRemovable[0];
+	bitmap = (unsigned char *)&hub->desc.u.hs.DeviceRemovable[0];
 	/* devices not removable by default */
 	memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8);
-	bitmap = (unsigned char *)&hub->desc.PortPowerCtrlMask[0];
+	bitmap = (unsigned char *)&hub->desc.u.hs.PortPwrCtrlMask[0];
 	memset(bitmap, 0xff, (USB_MAXCHILDREN+1+7)/8); /* PowerMask = 1B */
 
 	for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
-		hub->desc.DeviceRemovable[i] = descriptor->DeviceRemovable[i];
+		hub->desc.u.hs.DeviceRemovable[i] = descriptor->u.hs.DeviceRemovable[i];
 
 	for (i = 0; i < ((hub->desc.bNbrPorts + 1 + 7)/8); i++)
-		hub->desc.PortPowerCtrlMask[i] = descriptor->PortPowerCtrlMask[i];
+		hub->desc.u.hs.PortPwrCtrlMask[i] = descriptor->u.hs.PortPwrCtrlMask[i];
 
 	dev->maxchild = descriptor->bNbrPorts;
 	dev_dbg(&dev->dev, "%d ports detected\n", dev->maxchild);
@@ -385,7 +385,7 @@ static int usb_hub_configure(struct usb_device *dev)
 
 	for (i = 0; i < dev->maxchild; i++)
 		dev_dbg(&dev->dev, "port %d is%s removable\n", i + 1,
-			hub->desc.DeviceRemovable[(i + 1) / 8] & \
+			hub->desc.u.hs.DeviceRemovable[(i + 1) / 8] & \
 					   (1 << ((i + 1) % 8)) ? " not" : "");
 
 	if (sizeof(struct usb_hub_status) > USB_BUFSIZ) {
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index ab1bc0331ba1..a76e06bd565f 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -69,8 +69,8 @@ static struct descriptor {
 		.wHubCharacteristics	= 0,
 		.bPwrOn2PwrGood		= 10,
 		.bHubContrCurrent	= 0,
-		.DeviceRemovable	= {},
-		.PortPowerCtrlMask	= {}
+		.u.hs.DeviceRemovable	= {},
+		.u.hs.PortPwrCtrlMask	= {}
 	},
 	.device = {
 		.bLength		= USB_DT_DEVICE_SIZE,
diff --git a/include/usb/usb.h b/include/usb/usb.h
index 41f92c2df0ce..82acf20b1298 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -24,6 +24,7 @@
 
 #include <driver.h>
 #include <usb/ch9.h>
+#include <usb/ch11.h>
 #include <usb/usb_defs.h>
 #include <asm/byteorder.h>
 
@@ -311,32 +312,6 @@ void usb_rescan(void);
 /*************************************************************************
  * Hub Stuff
  */
-struct usb_port_status {
-	unsigned short wPortStatus;
-	unsigned short wPortChange;
-} __attribute__ ((packed));
-
-struct usb_hub_status {
-	unsigned short wHubStatus;
-	unsigned short wHubChange;
-} __attribute__ ((packed));
-
-
-/* Hub descriptor */
-struct usb_hub_descriptor {
-	unsigned char  bLength;
-	unsigned char  bDescriptorType;
-	unsigned char  bNbrPorts;
-	unsigned short wHubCharacteristics;
-	unsigned char  bPwrOn2PwrGood;
-	unsigned char  bHubContrCurrent;
-	unsigned char  DeviceRemovable[(USB_MAXCHILDREN+1+7)/8];
-	unsigned char  PortPowerCtrlMask[(USB_MAXCHILDREN+1+7)/8];
-	/* DeviceRemovable and PortPwrCtrlMask want to be variable-length
-	   bitmaps that hold max 255 entries. (bit0 is ignored) */
-} __attribute__ ((packed));
-
-
 struct usb_hub_device {
 	struct usb_device *pusb_dev;
 	struct usb_hub_descriptor desc;
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 10/10] USB: remove redundant defines from usb_defs.h
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
                   ` (8 preceding siblings ...)
  2014-07-23 13:51 ` [PATCH 09/10] USB: Use descriptors from ch11.h Sebastian Hesselbarth
@ 2014-07-23 13:51 ` Sebastian Hesselbarth
  2014-07-24  7:05 ` [PATCH 00/10] More USB cleanup and fixes Sascha Hauer
  10 siblings, 0 replies; 12+ messages in thread
From: Sebastian Hesselbarth @ 2014-07-23 13:51 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Sascha Hauer; +Cc: barebox

We imported a bunch of defines with ch9.h and ch11.h that are now
duplicated in usb_defs.h. Get rid of each duplicate in usb_defs.h
and prefer the ones from ch9.h and ch11.h.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
---
 include/usb/usb_defs.h | 117 -------------------------------------------------
 1 file changed, 117 deletions(-)

diff --git a/include/usb/usb_defs.h b/include/usb/usb_defs.h
index 461f7dbf4e96..8e32379c63cd 100644
--- a/include/usb/usb_defs.h
+++ b/include/usb/usb_defs.h
@@ -24,17 +24,6 @@
 
 /* USB constants */
 
-/* Device and/or Interface Class codes */
-#define USB_CLASS_PER_INTERFACE  0	/* for DeviceClass */
-#define USB_CLASS_AUDIO          1
-#define USB_CLASS_COMM           2
-#define USB_CLASS_HID            3
-#define USB_CLASS_PRINTER	       7
-#define USB_CLASS_MASS_STORAGE   8
-#define USB_CLASS_HUB            9
-#define USB_CLASS_DATA           10
-#define USB_CLASS_VENDOR_SPEC    0xff
-
 /* some HID sub classes */
 #define USB_SUB_HID_NONE        0
 #define USB_SUB_HID_BOOT        1
@@ -60,53 +49,14 @@
 #define US_PR_CBI              0		/* Control/Bulk/Interrupt */
 #define US_PR_BULK             0x50		/* bulk only */
 
-/* USB types */
-#define USB_TYPE_STANDARD   (0x00 << 5)
-#define USB_TYPE_CLASS      (0x01 << 5)
-#define USB_TYPE_VENDOR     (0x02 << 5)
-#define USB_TYPE_RESERVED   (0x03 << 5)
-
-/* USB recipients */
-#define USB_RECIP_DEVICE      0x00
-#define USB_RECIP_INTERFACE   0x01
-#define USB_RECIP_ENDPOINT    0x02
-#define USB_RECIP_OTHER       0x03
-
-/* USB directions */
-#define USB_DIR_OUT           0
-#define USB_DIR_IN            0x80
-
 /* Descriptor types */
-#define USB_DT_DEVICE        0x01
-#define USB_DT_CONFIG        0x02
-#define USB_DT_STRING        0x03
-#define USB_DT_INTERFACE     0x04
-#define USB_DT_ENDPOINT      0x05
-
 #define USB_DT_HID          (USB_TYPE_CLASS | 0x01)
 #define USB_DT_REPORT       (USB_TYPE_CLASS | 0x02)
 #define USB_DT_PHYSICAL     (USB_TYPE_CLASS | 0x03)
-#define USB_DT_HUB          (USB_TYPE_CLASS | 0x09)
 
 /* Descriptor sizes per descriptor type */
-#define USB_DT_DEVICE_SIZE      18
-#define USB_DT_CONFIG_SIZE      9
-#define USB_DT_INTERFACE_SIZE   9
-#define USB_DT_ENDPOINT_SIZE    7
-#define USB_DT_ENDPOINT_AUDIO_SIZE  9	/* Audio extension */
-#define USB_DT_HUB_NONVAR_SIZE  7
 #define USB_DT_HID_SIZE         9
 
-/* Endpoints */
-#define USB_ENDPOINT_NUMBER_MASK  0x0f	/* in bEndpointAddress */
-#define USB_ENDPOINT_DIR_MASK     0x80
-
-#define USB_ENDPOINT_XFERTYPE_MASK 0x03	/* in bmAttributes */
-#define USB_ENDPOINT_XFER_CONTROL  0
-#define USB_ENDPOINT_XFER_ISOC     1
-#define USB_ENDPOINT_XFER_BULK     2
-#define USB_ENDPOINT_XFER_INT      3
-
 /* USB Packet IDs (PIDs) */
 #define USB_PID_UNDEF_0             0xf0
 #define USB_PID_OUT                 0xe1
@@ -125,19 +75,6 @@
 #define USB_PID_STALL               0x1e
 #define USB_PID_UNDEF_F             0x0f
 
-/* Standard requests */
-#define USB_REQ_GET_STATUS          0x00
-#define USB_REQ_CLEAR_FEATURE       0x01
-#define USB_REQ_SET_FEATURE         0x03
-#define USB_REQ_SET_ADDRESS         0x05
-#define USB_REQ_GET_DESCRIPTOR      0x06
-#define USB_REQ_SET_DESCRIPTOR      0x07
-#define USB_REQ_GET_CONFIGURATION   0x08
-#define USB_REQ_SET_CONFIGURATION   0x09
-#define USB_REQ_GET_INTERFACE       0x0A
-#define USB_REQ_SET_INTERFACE       0x0B
-#define USB_REQ_SYNCH_FRAME         0x0C
-
 /* HID requests */
 #define USB_REQ_GET_REPORT          0x01
 #define USB_REQ_GET_IDLE            0x02
@@ -176,68 +113,14 @@
  */
 
 /*
- * Hub request types
- */
-
-#define USB_RT_HUB	(USB_TYPE_CLASS | USB_RECIP_DEVICE)
-#define USB_RT_PORT	(USB_TYPE_CLASS | USB_RECIP_OTHER)
-
-/*
- * Hub Class feature numbers
- */
-#define C_HUB_LOCAL_POWER   0
-#define C_HUB_OVER_CURRENT  1
-
-/*
  * Port feature numbers
  */
-#define USB_PORT_FEAT_CONNECTION     0
-#define USB_PORT_FEAT_ENABLE         1
-#define USB_PORT_FEAT_SUSPEND        2
-#define USB_PORT_FEAT_OVER_CURRENT   3
-#define USB_PORT_FEAT_RESET          4
-#define USB_PORT_FEAT_POWER          8
-#define USB_PORT_FEAT_LOWSPEED       9
 #define USB_PORT_FEAT_HIGHSPEED      10
-#define USB_PORT_FEAT_C_CONNECTION   16
-#define USB_PORT_FEAT_C_ENABLE       17
-#define USB_PORT_FEAT_C_SUSPEND      18
-#define USB_PORT_FEAT_C_OVER_CURRENT 19
-#define USB_PORT_FEAT_C_RESET        20
 
 /* wPortStatus bits */
-#define USB_PORT_STAT_CONNECTION    0x0001
-#define USB_PORT_STAT_ENABLE        0x0002
-#define USB_PORT_STAT_SUSPEND       0x0004
-#define USB_PORT_STAT_OVERCURRENT   0x0008
-#define USB_PORT_STAT_RESET         0x0010
-#define USB_PORT_STAT_POWER         0x0100
-#define USB_PORT_STAT_LOW_SPEED     0x0200
-#define USB_PORT_STAT_HIGH_SPEED    0x0400	/* support for EHCI */
 #define USB_PORT_STAT_SPEED	\
 	(USB_PORT_STAT_LOW_SPEED | USB_PORT_STAT_HIGH_SPEED)
 
-/* wPortChange bits */
-#define USB_PORT_STAT_C_CONNECTION  0x0001
-#define USB_PORT_STAT_C_ENABLE      0x0002
-#define USB_PORT_STAT_C_SUSPEND     0x0004
-#define USB_PORT_STAT_C_OVERCURRENT 0x0008
-#define USB_PORT_STAT_C_RESET       0x0010
-
-/* wHubCharacteristics (masks) */
-#define HUB_CHAR_LPSM               0x0003
-#define HUB_CHAR_COMPOUND           0x0004
-#define HUB_CHAR_OCPM               0x0018
-
-/*
- *Hub Status & Hub Change bit masks
- */
-#define HUB_STATUS_LOCAL_POWER	0x0001
-#define HUB_STATUS_OVERCURRENT	0x0002
-
-#define HUB_CHANGE_LOCAL_POWER	0x0001
-#define HUB_CHANGE_OVERCURRENT	0x0002
-
 /* (shifted) direction/type/recipient from the USB 2.0 spec, table 9.2 */
 #define DeviceRequest \
 	((USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE) << 8)
-- 
2.0.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 00/10] More USB cleanup and fixes
  2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
                   ` (9 preceding siblings ...)
  2014-07-23 13:51 ` [PATCH 10/10] USB: remove redundant defines from usb_defs.h Sebastian Hesselbarth
@ 2014-07-24  7:05 ` Sascha Hauer
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2014-07-24  7:05 UTC (permalink / raw)
  To: Sebastian Hesselbarth; +Cc: barebox

On Wed, Jul 23, 2014 at 03:51:41PM +0200, Sebastian Hesselbarth wrote:
> Sascha,
> 
> I have assembled a bunch of additional imports, cleanup, and fixes
> before actually rebasing xHCI HCD on top of your latest USB changes.
> 
> Patches 1-3 import ch11.h from Linux and prepare it for use in
> Barebox.
> 
> Patch 4 fixes a copy-and-paste error in usb_hub_configure().
> 
> Patches 5-8 clean up ehci-hcd and make it use ch9.h defines.
> 
> Patch 9 installs ch11.h and removes the duplicates from usb.h.
> 
> Patch 10 finally removes now redundant defines from usb_defs.h.
> 
> I have only compile-tested this as far as I could, so at least a
> Tested-by on any EHCI driver would be good.

Nice cleanups! I gave it a quick test on an i.MX53 and all devices
are still detected, an ethernet dongle is still working.

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-07-24  7:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23 13:51 [PATCH 00/10] More USB cleanup and fixes Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 01/10] USB: import ch11.h from Linux Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 02/10] USB: reduce USB_MAXCHILDREN on imported ch11.h Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 03/10] USB: fixup usb_hub_descriptor length name Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 04/10] USB: fix PowerPowerCtrlMask assignment Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 05/10] USB: Move FooRequest defines and add class requests Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 06/10] USB: EHCI: reuse ch9.h config and interface descriptors Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 07/10] USB: EHCI: make use of defines for descriptors Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 08/10] USB: EHCI: use descriptor length fields Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 09/10] USB: Use descriptors from ch11.h Sebastian Hesselbarth
2014-07-23 13:51 ` [PATCH 10/10] USB: remove redundant defines from usb_defs.h Sebastian Hesselbarth
2014-07-24  7:05 ` [PATCH 00/10] More USB cleanup and fixes Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox