usb: use linux/usb/ch9.h instead of usbdescriptors.h
authorIlya Yanok <ilya.yanok@cogentembedded.com>
Tue, 6 Nov 2012 13:48:20 +0000 (13:48 +0000)
committerChanho Park <chanho61.park@samsung.com>
Fri, 24 Jul 2015 07:29:54 +0000 (16:29 +0900)
Linux usb/ch9.h seems to have all the same information (and more)
as usbdescriptors.h so use the former instead of the later one.

As a consequense of this change USB_SPEED_* values don't correspond
directly to EHCI speed encoding anymore, I've added necessary
recoding in EHCI driver. Also there is no point to put speed into
pipe anymore so it's removed and a bunch of host drivers fixed to
look at usb_device->speed instead.

Old usbdescriptors.h included is not removed as it seems to be
used by old USB device code.

This makes usb.h and usbdevice.h incompatible. Fortunately the
only place that tries to include both are the old MUSB code and
it needs usb.h only for USB_DMA_MINALIGN used in aligned attribute
on musb_regs structure but this attribute seems to be unneeded
(old MUSB code doesn't support any DMA at all).

Signed-off-by: Ilya Yanok <ilya.yanok@cogentembedded.com>
Conflicts:
common/cmd_usb.c
drivers/usb/host/ehci-hcd.c

14 files changed:
arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c
arch/mips/cpu/mips32/au1x00/au1x00_usb_ohci.c
arch/powerpc/cpu/mpc5xxx/usb_ohci.c
arch/powerpc/cpu/ppc4xx/usb_ohci.c
common/cmd_usb.c
common/usb.c
drivers/usb/host/ehci-hcd.c
drivers/usb/host/isp116x-hcd.c
drivers/usb/host/ohci-hcd.c
drivers/usb/host/sl811-hcd.c
drivers/usb/musb/musb_core.h
drivers/usb/musb/musb_hcd.c
include/usb.h
include/usb_defs.h

index 944bb32f579520c6a62d966d78d0fbe44ffc1197..3bca66af3f259b69514f5228032c9b55fa9d6f98 100644 (file)
@@ -620,7 +620,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);
 
        return ed_ret;
index c747767e1e2c9469fa226c14d5557dacc6c7644e..b9b0998d48f199e74511e06f72733719f0771907 100644 (file)
@@ -615,7 +615,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
                        | usb_pipeendpoint (pipe) << 7
                        | (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);
 
        return ed_ret;
index 607034b7c652d673446d39c2f30376edc5f475a0..de07343d93fc9c45cd6e7a0f577cd3b019562ae7 100644 (file)
@@ -618,7 +618,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
                        | usb_pipeendpoint (pipe) << 7
                        | (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);
 
        return ed_ret;
index 4ce27262970624099119f267d602d8fca9d1afa6..f820c37a8f15d7d857b849b7637ddd776a5f423d 100644 (file)
@@ -621,7 +621,7 @@ static ed_t * ep_add_ed (struct usb_device *usb_dev, unsigned long pipe)
                        | usb_pipeendpoint (pipe) << 7
                        | (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);
 
        return ed_ret;
index c128455d747718c902ebc43436e6cc2f196db51f..cda4fac6e7361fd46c6e2d3a37d0d6cbe7570fcf 100644 (file)
@@ -192,8 +192,8 @@ void usb_display_desc(struct usb_device *dev)
 
 }
 
-void usb_display_conf_desc(struct usb_configuration_descriptor *config,
-                          struct usb_device *dev)
+static void usb_display_conf_desc(struct usb_config_descriptor *config,
+                                 struct usb_device *dev)
 {
        printf("   Configuration: %d\n", config->bConfigurationValue);
        printf("   - Interfaces: %d %s%s%dmA\n", config->bNumInterfaces,
index 50b81752ebca7300599da7580629614d84e0d696..ac9b4ca8d58bfe8dd3cd941c7fb094a4b9d819e7 100644 (file)
@@ -492,9 +492,9 @@ int usb_get_configuration_no(struct usb_device *dev,
 {
        int result;
        unsigned int tmp;
-       struct usb_configuration_descriptor *config;
+       struct usb_config_descriptor *config;
 
-       config = (struct usb_configuration_descriptor *)&buffer[0];
+       config = (struct usb_config_descriptor *)&buffer[0];
        result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 9);
        if (result < 9) {
                if (result < 0)
index 5d8714e688a38a4942f8f94868e17650c501ec9e..9cfacd78ef6d0b424db3c472fbac28f5826d88ac 100644 (file)
@@ -204,6 +204,18 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz)
        return 0;
 }
 
+static inline u8 ehci_encode_speed(enum usb_device_speed speed)
+{
+       #define QH_HIGH_SPEED   2
+       #define QH_FULL_SPEED   0
+       #define QH_LOW_SPEED    1
+       if (speed == USB_SPEED_HIGH)
+               return QH_HIGH_SPEED;
+       if (speed == USB_SPEED_LOW)
+               return QH_LOW_SPEED;
+       return QH_FULL_SPEED;
+}
+
 static int
 ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
                   int length, struct devrequest *req)
@@ -311,13 +323,13 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
         *   qh_overlay.qt_next ...... 13-10 H
         * - qh_overlay.qt_altnext
         */
-       qh->qh_link = cpu_to_hc32((uint32_t)qh_list | QH_LINK_TYPE_QH);
-       c = usb_pipespeed(pipe) != USB_SPEED_HIGH && !usb_pipeendpoint(pipe);
+       qh->qh_link = cpu_to_hc32((uint32_t)&ctrl->qh_list | QH_LINK_TYPE_QH);
+       c = (dev->speed != USB_SPEED_HIGH) && !usb_pipeendpoint(pipe);
        maxpacket = usb_maxpacket(dev, pipe);
        endpt = QH_ENDPT1_RL(8) | QH_ENDPT1_C(c) |
                QH_ENDPT1_MAXPKTLEN(maxpacket) | QH_ENDPT1_H(0) |
                QH_ENDPT1_DTC(QH_ENDPT1_DTC_DT_FROM_QTD) |
-               QH_ENDPT1_EPS(usb_pipespeed(pipe)) |
+               QH_ENDPT1_EPS(ehci_encode_speed(dev->speed)) |
                QH_ENDPT1_ENDPT(usb_pipeendpoint(pipe)) | QH_ENDPT1_I(0) |
                QH_ENDPT1_DEVADDR(usb_pipedevice(pipe));
        qh->qh_endpt1 = cpu_to_hc32(endpt);
index 19e16a4a804bbacf9efdee693ba9174f6ec6024b..289018c4f6aa3504f91311402720d95a52f74765 100644 (file)
@@ -617,7 +617,7 @@ static int isp116x_submit_job(struct usb_device *dev, unsigned long pipe,
        int epnum = usb_pipeendpoint(pipe);
        int max = usb_maxpacket(dev, pipe);
        int dir_out = usb_pipeout(pipe);
-       int speed_low = usb_pipeslow(pipe);
+       int speed_low = (dev->speed == USB_SPEED_LOW);
        int i, done = 0, stat, timeout, cc;
 
        /* 500 frames or 0.5s timeout when function is busy and NAKs transactions for a while */
index c5bf2cc660f377a9a44bf874ce6f6558a6935a1a..da95e1a4a5eeb7dd596c1361d22ecde6367a9879 100644 (file)
@@ -803,7 +803,7 @@ static ed_t *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) {
index 283061604693efa58e422f09ae95537ae4d52931..417f1a8aba1bf2e9833ee6b6e29267bd7b10b4cc 100644 (file)
@@ -234,7 +234,7 @@ static int sl811_send_packet(struct usb_device *dev, unsigned long pipe, __u8 *b
        __u16 status = 0;
        int err = 0, time_start = get_timer(0);
        int need_preamble = !(rh_status.wPortStatus & USB_PORT_STAT_LOW_SPEED) &&
-               usb_pipeslow(pipe);
+               (dev->speed == USB_SPEED_LOW);
 
        if (len > 239)
                return -1;
index e914369297047fcfcfa10ba0037fe30ab9820d83..ec8a038c74c10e08383b6854729ad72231049eaa 100644 (file)
@@ -34,7 +34,6 @@
 #ifndef __MUSB_HDRC_DEFS_H__
 #define __MUSB_HDRC_DEFS_H__
 
-#include <usb.h>
 #include <usb_defs.h>
 #include <asm/io.h>
 
@@ -145,7 +144,7 @@ struct musb_regs {
                struct musb_epN_regs epN;
        } ep[16];
 
-} __attribute__((packed, aligned(USB_DMA_MINALIGN)));
+} __attribute__((packed));
 #endif
 
 /*
index 5c8deca0918be6de70068432a8f30dec617aef2b..31a7a96683ea69569e9d85eb5c1103acbf329971 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <common.h>
+#include <usb.h>
 #include "musb_hcd.h"
 
 /* MSC control transfers */
@@ -485,8 +486,8 @@ static int ctrlreq_in_status_phase(struct usb_device *dev)
  */
 static u8 get_dev_speed(struct usb_device *dev)
 {
-       return (dev->speed & USB_SPEED_HIGH) ? MUSB_TYPE_SPEED_HIGH :
-               ((dev->speed & USB_SPEED_LOW) ? MUSB_TYPE_SPEED_LOW :
+       return (dev->speed == USB_SPEED_HIGH) ? MUSB_TYPE_SPEED_HIGH :
+               ((dev->speed == USB_SPEED_LOW) ? MUSB_TYPE_SPEED_LOW :
                                                MUSB_TYPE_SPEED_FULL);
 }
 
index 9dd879194752a829f93cb5b1cfadf4e9df55a2ab..4689db624db291d51cc0a6ad0fee3676ff8c1f98 100644 (file)
@@ -27,7 +27,7 @@
 #define _USB_H_
 
 #include <usb_defs.h>
-#include <usbdescriptors.h>
+#include <linux/usb/ch9.h>
 
 /*
  * The EHCI spec says that we must align to at least 32 bytes.  However,
@@ -67,12 +67,6 @@ struct devrequest {
        unsigned short  length;
 } __attribute__ ((packed));
 
-/* All standard descriptors have these 2 fields in common */
-struct usb_descriptor_header {
-       unsigned char   bLength;
-       unsigned char   bDescriptorType;
-} __attribute__ ((packed));
-
 /* Interface */
 struct usb_interface {
        struct usb_interface_descriptor desc;
@@ -86,7 +80,7 @@ struct usb_interface {
 
 /* Configuration information.. */
 struct usb_config {
-       struct usb_configuration_descriptor desc;
+       struct usb_config_descriptor desc;
 
        unsigned char   no_of_if;       /* number of interfaces */
        struct usb_interface if_desc[USB_MAXINTERFACES];
@@ -285,7 +279,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
  *  - device:          bits 8-14
  *  - endpoint:                bits 15-18
  *  - Data0/1:         bit 19
- *  - speed:           bit 26          (0 = Full, 1 = Low Speed, 2 = High)
  *  - pipe type:       bits 30-31      (00 = isochronous, 01 = interrupt,
  *                                      10 = control, 11 = bulk)
  *
@@ -297,7 +290,7 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
 /* Create various pipes... */
 #define create_pipe(dev,endpoint) \
                (((dev)->devnum << 8) | ((endpoint) << 15) | \
-               ((dev)->speed << 26) | (dev)->maxpacketsize)
+               (dev)->maxpacketsize)
 #define default_pipe(dev) ((dev)->speed << 26)
 
 #define usb_sndctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \
@@ -348,8 +341,6 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate);
 #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)
index 8032e5712524ee322842e3eebf16a438eb4d99a7..9502544b21bd1b41a034193de822f1345045acc7 100644 (file)
 #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