]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - include/usb.h
arm: mx5: clock: add support for changing CPU clock via cmdline
[karo-tx-uboot.git] / include / usb.h
index 7c47098d8a432c1ca54f32001c2b05c19e3e4b7e..60db897cb22e282be528456bc447818bc5dc2ee0 100644 (file)
@@ -2,24 +2,7 @@
  * (C) Copyright 2001
  * Denis Peter, MPL AG Switzerland
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  * Note: Part of this code has been derived from linux
  *
  */
 #define _USB_H_
 
 #include <usb_defs.h>
+#include <linux/usb/ch9.h>
+
+/*
+ * The EHCI spec says that we must align to at least 32 bytes.  However,
+ * some platforms require larger alignment.
+ */
+#if ARCH_DMA_MINALIGN > 32
+#define USB_DMA_MINALIGN       ARCH_DMA_MINALIGN
+#else
+#define USB_DMA_MINALIGN       32
+#endif
 
 /* Everything is aribtrary */
 #define USB_ALTSETTINGALLOC            4
 
 #define USB_CNTL_TIMEOUT 100 /* 100ms timeout */
 
-/* String descriptor */
-struct usb_string_descriptor {
-       unsigned char   bLength;
-       unsigned char   bDescriptorType;
-       unsigned short  wData[1];
-} __attribute__ ((packed));
+/*
+ * This is the timeout to allow for submitting an urb in ms. We allow more
+ * time for a BULK device to react - some are slow.
+ */
+#define USB_TIMEOUT_MS(pipe) (usb_pipebulk(pipe) ? 5000 : 1000)
 
 /* device request (setup) */
 struct devrequest {
@@ -57,75 +50,29 @@ 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));
-
-/* Device descriptor */
-struct usb_device_descriptor {
-       unsigned char   bLength;
-       unsigned char   bDescriptorType;
-       unsigned short  bcdUSB;
-       unsigned char   bDeviceClass;
-       unsigned char   bDeviceSubClass;
-       unsigned char   bDeviceProtocol;
-       unsigned char   bMaxPacketSize0;
-       unsigned short  idVendor;
-       unsigned short  idProduct;
-       unsigned short  bcdDevice;
-       unsigned char   iManufacturer;
-       unsigned char   iProduct;
-       unsigned char   iSerialNumber;
-       unsigned char   bNumConfigurations;
-} __attribute__ ((packed));
-
-/* Endpoint descriptor */
-struct usb_endpoint_descriptor {
-       unsigned char   bLength;
-       unsigned char   bDescriptorType;
-       unsigned char   bEndpointAddress;
-       unsigned char   bmAttributes;
-       unsigned short  wMaxPacketSize;
-       unsigned char   bInterval;
-       unsigned char   bRefresh;
-       unsigned char   bSynchAddress;
-} __attribute__ ((packed)) __attribute__ ((aligned(2)));
-
-/* Interface descriptor */
-struct usb_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;
+/* Interface */
+struct usb_interface {
+       struct usb_interface_descriptor desc;
 
        unsigned char   no_of_ep;
        unsigned char   num_altsetting;
        unsigned char   act_altsetting;
 
        struct usb_endpoint_descriptor ep_desc[USB_MAXENDPOINTS];
+       /*
+        * Super Speed Device will have Super Speed Endpoint
+        * Companion Descriptor  (section 9.6.7 of usb 3.0 spec)
+        * Revision 1.0 June 6th 2011
+        */
+       struct usb_ss_ep_comp_descriptor ss_ep_comp_desc[USB_MAXENDPOINTS];
 } __attribute__ ((packed));
 
-
-/* Configuration descriptor information.. */
-struct usb_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;
+/* Configuration information.. */
+struct usb_config {
+       struct usb_config_descriptor desc;
 
        unsigned char   no_of_if;       /* number of interfaces */
-       struct usb_interface_descriptor if_desc[USB_MAXINTERFACES];
+       struct usb_interface if_desc[USB_MAXINTERFACES];
 } __attribute__ ((packed));
 
 enum {
@@ -155,8 +102,10 @@ struct usb_device {
        int epmaxpacketout[16];         /* OUTput endpoint specific maximums */
 
        int configno;                   /* selected config number */
-       struct usb_device_descriptor descriptor; /* Device Descriptor */
-       struct usb_config_descriptor config; /* config descriptor */
+       /* Device Descriptor */
+       struct usb_device_descriptor descriptor
+               __attribute__((aligned(ARCH_DMA_MINALIGN)));
+       struct usb_config config; /* config descriptor */
 
        int have_langid;                /* whether string_langid is valid yet */
        int string_langid;              /* language ID for strings */
@@ -174,6 +123,8 @@ struct usb_device {
        int portnr;
        struct usb_device *parent;
        struct usb_device *children[USB_MAXCHILDREN];
+
+       void *controller;               /* hardware controller private data */
 };
 
 /**********************************************************************
@@ -183,22 +134,37 @@ struct usb_device {
 #if defined(CONFIG_USB_UHCI) || defined(CONFIG_USB_OHCI) || \
        defined(CONFIG_USB_EHCI) || defined(CONFIG_USB_OHCI_NEW) || \
        defined(CONFIG_USB_SL811HS) || defined(CONFIG_USB_ISP116X_HCD) || \
-       defined(CONFIG_USB_R8A66597_HCD) || defined(CONFIG_USB_DAVINCI)
+       defined(CONFIG_USB_R8A66597_HCD) || defined(CONFIG_USB_DAVINCI) || \
+       defined(CONFIG_USB_OMAP3) || defined(CONFIG_USB_DA8XX) || \
+       defined(CONFIG_USB_BLACKFIN) || defined(CONFIG_USB_AM35X) || \
+       defined(CONFIG_USB_MUSB_DSPS) || defined(CONFIG_USB_MUSB_AM35X) || \
+       defined(CONFIG_USB_MUSB_OMAP2PLUS)
+
+int usb_lowlevel_init(int index, void **controller);
+int usb_lowlevel_stop(int index);
 
-int usb_lowlevel_init(void);
-int usb_lowlevel_stop(void);
 int submit_bulk_msg(struct usb_device *dev, unsigned long pipe,
                        void *buffer, int transfer_len);
 int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
                        int transfer_len, struct devrequest *setup);
 int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
                        int transfer_len, int interval);
-void usb_event_poll(void);
 
 /* Defines */
 #define USB_UHCI_VEND_ID       0x8086
 #define USB_UHCI_DEV_ID                0x7112
 
+/*
+ * PXA25x can only act as USB device. There are drivers
+ * which works with USB CDC gadgets implementations.
+ * Some of them have common routines which can be used
+ * in boards init functions e.g. udc_disconnect() used for
+ * forced device disconnection from host.
+ */
+#elif defined(CONFIG_USB_GADGET_PXA2XX)
+
+extern void udc_disconnect(void);
+
 #else
 #error USB Lowlevel not defined
 #endif
@@ -212,6 +178,13 @@ int usb_stor_info(void);
 
 #endif
 
+#ifdef CONFIG_USB_HOST_ETHER
+
+#define USB_MAX_ETH_DEV 5
+int usb_host_eth_scan(int mode);
+
+#endif
+
 #ifdef CONFIG_USB_KEYBOARD
 
 int drv_usb_kbd_init(void);
@@ -235,9 +208,8 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
                        void *data, int len, int *actual_length, int timeout);
 int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe,
                        void *buffer, int transfer_len, int interval);
-void usb_disable_asynch(int disable);
+int usb_disable_asynch(int disable);
 int usb_maxpacket(struct usb_device *dev, unsigned long pipe);
-inline void wait_ms(unsigned long ms);
 int usb_get_configuration_no(struct usb_device *dev, unsigned char *buffer,
                                int cfgno);
 int usb_get_report(struct usb_device *dev, int ifnum, unsigned char type,
@@ -298,7 +270,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)
  *
@@ -309,8 +280,8 @@ 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)->devnum << 8) | ((endpoint) << 15) | \
+               (dev)->maxpacketsize)
 #define default_pipe(dev) ((dev)->speed << 26)
 
 #define usb_sndctrlpipe(dev, endpoint) ((PIPE_CONTROL << 30) | \
@@ -361,8 +332,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)
@@ -404,4 +373,14 @@ struct usb_hub_device {
        struct usb_hub_descriptor desc;
 };
 
+int usb_hub_probe(struct usb_device *dev, int ifnum);
+void usb_hub_reset(void);
+int hub_port_reset(struct usb_device *dev, int port,
+                         unsigned short *portstat);
+
+struct usb_device *usb_alloc_new_device(void *controller);
+
+int usb_new_device(struct usb_device *dev);
+void usb_free_device(void);
+
 #endif /*_USB_H_ */