mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Christoph Fritz <chf.fritz@googlemail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 13/18] usb: add musb support
Date: Fri, 13 Jun 2014 09:54:30 +0200	[thread overview]
Message-ID: <1402646075-22747-14-git-send-email-chf.fritz@googlemail.com> (raw)
In-Reply-To: <1402646075-22747-1-git-send-email-chf.fritz@googlemail.com>

---
 include/usb/usb.h |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/include/usb/usb.h b/include/usb/usb.h
index 1a369d2..6e204b4 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -27,6 +27,7 @@
 #include <driver.h>
 #include <usb/usb_defs.h>
 #include <asm/byteorder.h>
+#include <asm/unaligned.h>
 
 /* Everything is aribtrary */
 #define USB_ALTSETTINGALLOC		4
@@ -41,6 +42,31 @@
 
 #define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
 
+/**
+ * struct usb_ctrlrequest - SETUP data for a USB device control request
+ * @bRequestType: matches the USB bmRequestType field
+ * @bRequest: matches the USB bRequest field
+ * @wValue: matches the USB wValue field (le16 byte order)
+ * @wIndex: matches the USB wIndex field (le16 byte order)
+ * @wLength: matches the USB wLength field (le16 byte order)
+ *
+ * This structure is used to send control requests to a USB device.  It matches
+ * the different fields of the USB 2.0 Spec section 9.3, table 9-2.  See the
+ * USB spec for a fuller description of the different fields, and what they are
+ * used for.
+ *
+ * Note that the driver for any interface can issue control requests.
+ * For most devices, interfaces don't coordinate with each other, so
+ * such requests may be made at any time.
+ */
+struct usb_ctrlrequest {
+	__u8 bRequestType;
+	__u8 bRequest;
+	__le16 wValue;
+	__le16 wIndex;
+	__le16 wLength;
+} __attribute__ ((packed));
+
 /* String descriptor */
 struct usb_string_descriptor {
 	unsigned char	bLength;
@@ -539,4 +565,40 @@ enum usb_phy_interface {
 	USBPHY_INTERFACE_MODE_SERIAL,
 	USBPHY_INTERFACE_MODE_HSIC,
 };
+
+
+/**
+ * usb_endpoint_maxp - get endpoint's max packet size
+ * @epd: endpoint to be checked
+ *
+ * Returns @epd's max packet
+ */
+static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
+{
+	return __le16_to_cpu(get_unaligned(&epd->wMaxPacketSize));
+}
+
+/**
+ * usb_endpoint_type - get the endpoint's transfer type
+ * @epd: endpoint to be checked
+ *
+ * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
+ * to @epd's transfer type.
+ */
+static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
+{
+	return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+}
+
+/**
+ * usb_endpoint_num - get the endpoint's number
+ * @epd: endpoint to be checked
+ *
+ * Returns @epd's number: 0 to 15.
+ */
+static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
+{
+	return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
+}
+
 #endif /*_USB_H_ */
-- 
1.7.10.4


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

  parent reply	other threads:[~2014-06-13  7:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-13  7:54 [RFC][PATCH 00/18] am33x: add musb Christoph Fritz
2014-06-13  7:54 ` [PATCH 01/18] arm: am33xx: add USB clocks Christoph Fritz
2014-06-13  7:54 ` [PATCH 02/18] arm: am33xx: add pinmux config for USB Christoph Fritz
2014-06-13  7:54 ` [PATCH 03/18] linux wrapper: add more dummy spin_lock stubs Christoph Fritz
2014-06-13  7:54 ` [PATCH 05/18] musb: delete unused include files Christoph Fritz
2014-06-13  7:54 ` [PATCH 06/18] musb: move musb.h to path include/usb Christoph Fritz
2014-06-13  7:54 ` [PATCH 07/18] musb: drop gadget support - remove appropriate files Christoph Fritz
2014-06-13  7:54 ` [PATCH 08/18] musb: use __BAREBOX__ macro Christoph Fritz
2014-06-13  7:54 ` [PATCH 09/18] musb: adapt Kconfig and Makefiles Christoph Fritz
2014-06-13  7:54 ` [PATCH 10/18] arm: pcm051: enable musb in defconfig Christoph Fritz
2014-06-13  7:54 ` [PATCH 11/18] musb: adapt driver to work on barebox Christoph Fritz
2014-06-14 20:53   ` Michael Grzeschik
2014-06-17  9:55     ` Christoph Fritz
2014-06-13  7:54 ` [PATCH 12/18] musb: only support USB_SPEED_HIGH devices Christoph Fritz
2014-06-13  7:54 ` Christoph Fritz [this message]
2014-06-13  7:54 ` [PATCH 14/18] arm: am33xx: add usb base addresses Christoph Fritz
2014-06-13  7:54 ` [PATCH 15/18] arm: am33xx: add usb platform helper code Christoph Fritz
2014-06-13  7:54 ` [PATCH 16/18] musb: add barebox gluecode Christoph Fritz
2014-06-13  7:54 ` [PATCH 17/18] arm: pcm051: enable USB pinmux Christoph Fritz
2014-06-13  7:54 ` [PATCH 18/18] arm: pcm051: enable USB Christoph Fritz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402646075-22747-14-git-send-email-chf.fritz@googlemail.com \
    --to=chf.fritz@googlemail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox