mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/4] USB: Remove conflicting USB_SPEED_* definitions
Date: Fri, 18 Jul 2014 14:44:39 +0200	[thread overview]
Message-ID: <1405687479-3507-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1405687479-3507-1-git-send-email-s.hauer@pengutronix.de>

We have USB_SPEED_* definitions as macros in usb_defs.h and as an enum
in ch9.h. The defines in usb.h correspond to hardware bits in the
ehci controller. Get rid of them and keep the hardware independent
enums.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/host/ehci-hcd.c | 17 +++++++++++++++--
 drivers/usb/host/ohci-hcd.c |  2 +-
 include/usb/usb.h           |  2 --
 include/usb/usb_defs.h      |  6 ------
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 2da3edd..d30c3aa 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -229,16 +229,29 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
 
 	qh = &ehci->qh_list[1];
 	qh->qh_link = cpu_to_hc32((uint32_t)ehci->qh_list | QH_LINK_TYPE_QH);
-	c = (usb_pipespeed(pipe) != USB_SPEED_HIGH &&
+	c = (dev->speed != USB_SPEED_HIGH &&
 	     usb_pipeendpoint(pipe) == 0) ? 1 : 0;
 	endpt = (8 << 28) |
 	    (c << 27) |
 	    (usb_maxpacket(dev, pipe) << 16) |
 	    (0 << 15) |
 	    (1 << 14) |
-	    (usb_pipespeed(pipe) << 12) |
 	    (usb_pipeendpoint(pipe) << 8) |
 	    (0 << 7) | (usb_pipedevice(pipe) << 0);
+	switch (dev->speed) {
+	case USB_SPEED_FULL:
+		endpt |= 0 << 12;
+		break;
+	case USB_SPEED_LOW:
+		endpt |= 1 << 12;
+		break;
+	case USB_SPEED_HIGH:
+		endpt |= 2 << 12;
+		break;
+	default:
+		return -EINVAL;
+	}
+
 	qh->qh_endpt1 = cpu_to_hc32(endpt);
 	endpt = (1 << 30) |
 	    (dev->portnr << 23) |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 8bf20d0..3d18a73 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -794,7 +794,7 @@ static struct ed *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe,
 			| (usb_pipeisoc(pipe) ? 0x8000 : 0)
 			| (usb_pipecontrol(pipe) ? 0 : \
 					   (usb_pipeout(pipe) ? 0x800 : 0x1000))
-			| usb_pipeslow(pipe) << 13
+			| (usb_dev->speed == USB_SPEED_LOW) << 13
 			| usb_maxpacket(usb_dev, pipe) << 16);
 
 	if (ed->type == PIPE_INTERRUPT && ed->state == ED_UNLINK) {
diff --git a/include/usb/usb.h b/include/usb/usb.h
index a0bc1d2..ff5242b 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -301,8 +301,6 @@ void usb_rescan(int force);
 #define usb_pipe_endpdev(pipe)	(((pipe) >> 8) & 0x7ff)
 #define usb_pipeendpoint(pipe)	(((pipe) >> 15) & 0xf)
 #define usb_pipedata(pipe)	(((pipe) >> 19) & 1)
-#define usb_pipespeed(pipe)	(((pipe) >> 26) & 3)
-#define usb_pipeslow(pipe)	(usb_pipespeed(pipe) == USB_SPEED_LOW)
 #define usb_pipetype(pipe)	(((pipe) >> 30) & 3)
 #define usb_pipeisoc(pipe)	(usb_pipetype((pipe)) == PIPE_ISOCHRONOUS)
 #define usb_pipeint(pipe)	(usb_pipetype((pipe)) == PIPE_INTERRUPT)
diff --git a/include/usb/usb_defs.h b/include/usb/usb_defs.h
index 13eb330..ace20e4 100644
--- a/include/usb/usb_defs.h
+++ b/include/usb/usb_defs.h
@@ -76,12 +76,6 @@
 #define USB_DIR_OUT           0
 #define USB_DIR_IN            0x80
 
-/* USB device speeds */
-#define USB_SPEED_FULL		0x0	/* 12Mbps */
-#define USB_SPEED_LOW		0x1	/* 1.5Mbps */
-#define USB_SPEED_HIGH		0x2	/* 480Mbps */
-#define USB_SPEED_RESERVED	0x3
-
 /* Descriptor types */
 #define USB_DT_DEVICE        0x01
 #define USB_DT_CONFIG        0x02
-- 
2.0.1


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

      parent reply	other threads:[~2014-07-18 12:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 12:44 USB Cleanup patches Sascha Hauer
2014-07-18 12:44 ` [PATCH 1/4] USB: Kconfig: introduce USB_HOST symbol Sascha Hauer
2014-07-18 12:44 ` [PATCH 2/4] USB: introduce usb_interface/usb_configuration structs Sascha Hauer
2014-07-18 12:44 ` [PATCH 3/4] USB: Use descriptors from ch9.h Sascha Hauer
2014-07-18 12:44 ` Sascha Hauer [this message]

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=1405687479-3507-5-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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