Patchwork [U-Boot,v3,01/10] usb: Move 'bmRequestType' USB device request macros from EHCI header

login
register
mail settings
Submitter Vivek Gautam
Date Sept. 14, 2013, 8:32 a.m.
Message ID <1379147573-21897-2-git-send-email-gautam.vivek@samsung.com>
Download mbox | patch
Permalink /patch/274900/
State Awaiting Upstream
Delegated to: Marek Vasut
Headers show

Comments

Vivek Gautam - Sept. 14, 2013, 8:32 a.m.
Macros defining bmRequestType field of USB device request,
given in table 9.2 USB 2.0 spec, are rather generic macros
which can be further used by other Host controller stacks.
So moving them to usb_defs header.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Cc: Julius Werner <jwerner@chromium.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Minkyu Kang <mk7.kang@samsung.com>
Cc: Dan Murphy <dmurphy@ti.com>
Cc: Marek Vasut <marex@denx.de>
---

Changes since v2:
 - This patch is newly added in this version of the series.

 drivers/usb/host/ehci.h |   16 ----------------
 include/usb_defs.h      |   19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 16 deletions(-)
Marek Vasut - Sept. 17, 2013, 3:02 a.m.
Dear Vivek Gautam,

> Macros defining bmRequestType field of USB device request,
> given in table 9.2 USB 2.0 spec, are rather generic macros
> which can be further used by other Host controller stacks.
> So moving them to usb_defs header.
> 
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> Cc: Julius Werner <jwerner@chromium.org>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Minkyu Kang <mk7.kang@samsung.com>
> Cc: Dan Murphy <dmurphy@ti.com>
> Cc: Marek Vasut <marex@denx.de>

Why not just use include/usb.h ?

Best regards,
Marek Vasut
Vivek Gautam - Sept. 17, 2013, 3:21 a.m.
Hi Marek,


On Tue, Sep 17, 2013 at 8:32 AM, Marek Vasut <marex@denx.de> wrote:
> Dear Vivek Gautam,
>
>> Macros defining bmRequestType field of USB device request,
>> given in table 9.2 USB 2.0 spec, are rather generic macros
>> which can be further used by other Host controller stacks.
>> So moving them to usb_defs header.
>>
>> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
>> Cc: Julius Werner <jwerner@chromium.org>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: Minkyu Kang <mk7.kang@samsung.com>
>> Cc: Dan Murphy <dmurphy@ti.com>
>> Cc: Marek Vasut <marex@denx.de>
>
> Why not just use include/usb.h ?

The bit field definitions for usb-types usb-recipient, and directions
are itself defined in usb_defs.h;
so i thought of keeping their combination just below it, so that it
would not be difficult to reference.

Please let me know if you want me to move them to include/usb.h

>
> Best regards,
> Marek Vasut
Marek Vasut - Sept. 17, 2013, 3:23 p.m.
Dear Vivek Gautam,

> Hi Marek,
> 
> On Tue, Sep 17, 2013 at 8:32 AM, Marek Vasut <marex@denx.de> wrote:
> > Dear Vivek Gautam,
> > 
> >> Macros defining bmRequestType field of USB device request,
> >> given in table 9.2 USB 2.0 spec, are rather generic macros
> >> which can be further used by other Host controller stacks.
> >> So moving them to usb_defs header.
> >> 
> >> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> >> Cc: Julius Werner <jwerner@chromium.org>
> >> Cc: Simon Glass <sjg@chromium.org>
> >> Cc: Minkyu Kang <mk7.kang@samsung.com>
> >> Cc: Dan Murphy <dmurphy@ti.com>
> >> Cc: Marek Vasut <marex@denx.de>
> > 
> > Why not just use include/usb.h ?
> 
> The bit field definitions for usb-types usb-recipient, and directions
> are itself defined in usb_defs.h;
> so i thought of keeping their combination just below it, so that it
> would not be difficult to reference.
> 
> Please let me know if you want me to move them to include/usb.h

Ah, we already have usb_defs.h , then this is OK. The headers are mess and will 
eventually need cleanup too, not in this patchset of course.

Best regards,
Marek Vasut

Patch

diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index bd52afe..3e1c312 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -28,22 +28,6 @@ 
 #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS	2
 #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_defs.h b/include/usb_defs.h
index 0cf5f2d..236a5ec 100644
--- a/include/usb_defs.h
+++ b/include/usb_defs.h
@@ -63,6 +63,25 @@ 
 #define USB_DIR_OUT           0
 #define USB_DIR_IN            0x80
 
+/*
+ * bmRequestType: USB Device Requests, table 9.2 USB 2.0 spec.
+ * (shifted) direction/type/recipient.
+ */
+#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)
+
 /* Descriptor types */
 #define USB_DT_DEVICE        0x01
 #define USB_DT_CONFIG        0x02