]> git.sur5r.net Git - u-boot/blobdiff - arch/sparc/cpu/leon3/usb_uhci.c
Fix spelling of "transferred".
[u-boot] / arch / sparc / cpu / leon3 / usb_uhci.c
index b1269d26002a10fd22638dc98fd4d93d6c14520a..67bd1241bd27844cf87dcc4402efafbea664c363 100644 (file)
  *
  * Adapted for U-Boot:
  * (C) Copyright 2001 Denis Peter, MPL AG Switzerland
- * (C) Copyright 2008, Daniel Hellström, daniel@gaisler.com
+ * (C) Copyright 2008, Daniel Hellström, daniel@gaisler.com
  *     Added AMBA Plug&Play detection of GRUSB, modified interrupt handler.
  *     Added cache flushes where needed.
  *
- * 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+
  */
 
 /**********************************************************************
@@ -73,7 +55,7 @@
  * For Interrupt transfers USB_MAX_TEMP_INT_TD Transfer descriptor are available. They
  * will be inserted after the appropriate (depending the interval setting) skeleton TD.
  * If an interrupt has been detected the dev->irqhandler is called. The status and number
- * of transfered bytes is stored in dev->irq_status resp. dev->irq_act_len. If the
+ * of transferred bytes is stored in dev->irq_status resp. dev->irq_act_len. If the
  * dev->irqhandler returns 0, the interrupt TD is removed and disabled. If an 1 is returned,
  * the interrupt TD will be reactivated.
  *
 #include <usb.h>
 #include "usb_uhci.h"
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define USB_MAX_TEMP_TD      128       /* number of temporary TDs for bulk and control transfers */
 #define USB_MAX_TEMP_INT_TD  32        /* number of temporary TDs for Interrupt transfers */
 
-extern int leon3_snooping_avail;
 /*
 #define out16r(address,data) (*(unsigned short *)(address) = \
  (unsigned short)( \
@@ -246,7 +229,7 @@ unsigned long usb_uhci_td_stat(unsigned long status)
        return result;
 }
 
-/* get the status and the transfered len of a td chain.
+/* get the status and the transferred len of a td chain.
  * called from the completion handler
  */
 int usb_get_td_status(uhci_td_t * td, struct usb_device *dev)
@@ -264,7 +247,7 @@ int usb_get_td_status(uhci_td_t * td, struct usb_device *dev)
                stat = usb_uhci_td_stat(temp);
                info = swap_32((unsigned long)READ32(&mytd->info));
                if (((info & 0xff) != USB_PID_SETUP) && (((info >> 21) & 0x7ff) != 0x7ff) && (temp & 0x7FF) != 0x7ff) { /* if not setup and not null data pack */
-                       dev->act_len += (temp & 0x7FF) + 1;     /* the transfered len is act_len + 1 */
+                       dev->act_len += (temp & 0x7FF) + 1;     /* the transferred len is act_len + 1 */
                }
                if (stat) {     /* status no ok */
                        dev->status = stat;
@@ -515,9 +498,9 @@ void reset_hc(void)
        out16r(usb_base_addr + USBCMD, USBCMD_GRESET | USBCMD_RS);
        /* Turn off all interrupts */
        out16r(usb_base_addr + USBINTR, 0);
-       wait_ms(50);
+       mdelay(50);
        out16r(usb_base_addr + USBCMD, 0);
-       wait_ms(10);
+       mdelay(10);
 }
 
 void start_hc(void)
@@ -591,7 +574,7 @@ void usb_check_skel(void)
        if (qh_cntrl.dev_ptr != 0) {    /* it's a device assigned check if this caused IRQ */
                dev = (struct usb_device *)qh_cntrl.dev_ptr;
                /* Flush cache now that hardware updated DATA and TDs/QHs */
-               if (!leon3_snooping_avail)
+               if (!gd->arch.snooping_avail)
                        sparc_dcache_flush_all();
                usb_get_td_status(&tmp_td[0], dev);     /* update status */
                if (!(dev->status & USB_ST_NOT_PROC)) { /* is not active anymore, disconnect devices */
@@ -602,7 +585,7 @@ void usb_check_skel(void)
        if (qh_bulk.dev_ptr != 0) {     /* it's a device assigned check if this caused IRQ */
                dev = (struct usb_device *)qh_bulk.dev_ptr;
                /* Flush cache now that hardware updated DATA and TDs/QHs */
-               if (!leon3_snooping_avail)
+               if (!gd->arch.snooping_avail)
                        sparc_dcache_flush_all();
                usb_get_td_status(&tmp_td[0], dev);     /* update status */
                if (!(dev->status & USB_ST_NOT_PROC)) { /* is not active anymore, disconnect devices */
@@ -638,7 +621,7 @@ void usb_check_int_chain(void)
                        if ((td->dev_ptr != 0L) && !(status & TD_CTRL_ACTIVE)) {
                                /* td is not active and a device is assigned -> call irqhandler */
                                dev = (struct usb_device *)td->dev_ptr;
-                               dev->irq_act_len = ((status & 0x7FF) == 0x7FF) ? 0 : (status & 0x7FF) + 1;      /* transfered length */
+                               dev->irq_act_len = ((status & 0x7FF) == 0x7FF) ? 0 : (status & 0x7FF) + 1;      /* transferred length */
                                dev->irq_status = usb_uhci_td_stat(status);     /* get status */
                                res = dev->irq_handle(dev);     /* call irqhandler */
                                if (res == 1) {
@@ -706,13 +689,13 @@ void handle_usb_interrupt(void)
 
 /* init uhci
  */
-int usb_lowlevel_init(void)
+int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
 {
-       unsigned char temp;
        ambapp_ahbdev ahbdev;
 
        /* Find GRUSB core using AMBA Plug&Play information */
-       if (ambapp_ahbslv_first(VENDOR_GAISLER, GAISLER_UHCI, &ahbdev) != 1) {
+       if (ambapp_ahbslv_find(&ambapp_plb, VENDOR_GAISLER, GAISLER_UHCI,
+               CONFIG_SYS_GRLIB_GRUSB_INDEX, &ahbdev) != 1) {
                printf("USB UHCI: Failed to find GRUSB controller\n");
                return -1;
        }
@@ -745,7 +728,7 @@ int usb_lowlevel_init(void)
 
 /* stop uhci
  */
-int usb_lowlevel_stop(void)
+int usb_lowlevel_stop(int index)
 {
        if (grusb_irq == -1)
                return 1;
@@ -775,110 +758,9 @@ static void usb_display_Req(unsigned short req)
 }
 #endif
 
-static unsigned char root_hub_dev_des[] = {
-       0x12,                   /*  __u8  bLength; */
-       0x01,                   /*  __u8  bDescriptorType; Device */
-       0x00,                   /*  __u16 bcdUSB; v1.0 */
-       0x01,
-       0x09,                   /*  __u8  bDeviceClass; HUB_CLASSCODE */
-       0x00,                   /*  __u8  bDeviceSubClass; */
-       0x00,                   /*  __u8  bDeviceProtocol; */
-       0x08,                   /*  __u8  bMaxPacketSize0; 8 Bytes */
-       0x00,                   /*  __u16 idVendor; */
-       0x00,
-       0x00,                   /*  __u16 idProduct; */
-       0x00,
-       0x00,                   /*  __u16 bcdDevice; */
-       0x00,
-       0x01,                   /*  __u8  iManufacturer; */
-       0x00,                   /*  __u8  iProduct; */
-       0x00,                   /*  __u8  iSerialNumber; */
-       0x01                    /*  __u8  bNumConfigurations; */
-};
-
-/* Configuration descriptor */
-static unsigned char root_hub_config_des[] = {
-       0x09,                   /*  __u8  bLength; */
-       0x02,                   /*  __u8  bDescriptorType; Configuration */
-       0x19,                   /*  __u16 wTotalLength; */
-       0x00,
-       0x01,                   /*  __u8  bNumInterfaces; */
-       0x01,                   /*  __u8  bConfigurationValue; */
-       0x00,                   /*  __u8  iConfiguration; */
-       0x40,                   /*  __u8  bmAttributes;
-                                  Bit 7: Bus-powered, 6: Self-powered, 5 Remote-wakwup, 4..0: resvd */
-       0x00,                   /*  __u8  MaxPower; */
-
-       /* interface */
-       0x09,                   /*  __u8  if_bLength; */
-       0x04,                   /*  __u8  if_bDescriptorType; Interface */
-       0x00,                   /*  __u8  if_bInterfaceNumber; */
-       0x00,                   /*  __u8  if_bAlternateSetting; */
-       0x01,                   /*  __u8  if_bNumEndpoints; */
-       0x09,                   /*  __u8  if_bInterfaceClass; HUB_CLASSCODE */
-       0x00,                   /*  __u8  if_bInterfaceSubClass; */
-       0x00,                   /*  __u8  if_bInterfaceProtocol; */
-       0x00,                   /*  __u8  if_iInterface; */
-
-       /* endpoint */
-       0x07,                   /*  __u8  ep_bLength; */
-       0x05,                   /*  __u8  ep_bDescriptorType; Endpoint */
-       0x81,                   /*  __u8  ep_bEndpointAddress; IN Endpoint 1 */
-       0x03,                   /*  __u8  ep_bmAttributes; Interrupt */
-       0x08,                   /*  __u16 ep_wMaxPacketSize; 8 Bytes */
-       0x00,
-       0xff                    /*  __u8  ep_bInterval; 255 ms */
-};
-
-static unsigned char root_hub_hub_des[] = {
-       0x09,                   /*  __u8  bLength; */
-       0x29,                   /*  __u8  bDescriptorType; Hub-descriptor */
-       0x02,                   /*  __u8  bNbrPorts; */
-       0x00,                   /* __u16  wHubCharacteristics; */
-       0x00,
-       0x01,                   /*  __u8  bPwrOn2pwrGood; 2ms */
-       0x00,                   /*  __u8  bHubContrCurrent; 0 mA */
-       0x00,                   /*  __u8  DeviceRemovable; *** 7 Ports max *** */
-       0xff                    /*  __u8  PortPwrCtrlMask; *** 7 ports max *** */
-};
-
-static unsigned char root_hub_str_index0[] = {
-       0x04,                   /*  __u8  bLength; */
-       0x03,                   /*  __u8  bDescriptorType; String-descriptor */
-       0x09,                   /*  __u8  lang ID */
-       0x04,                   /*  __u8  lang ID */
-};
-
-static unsigned char root_hub_str_index1[] = {
-       28,                     /*  __u8  bLength; */
-       0x03,                   /*  __u8  bDescriptorType; String-descriptor */
-       'U',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'H',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'C',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'I',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       ' ',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'R',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'o',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'o',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       't',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       ' ',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'H',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'u',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-       'b',                    /*  __u8  Unicode */
-       0,                      /*  __u8  Unicode */
-};
+#define WANT_USB_ROOT_HUB_HUB_DES
+#include <usbroothubdes.h>
+#undef WANT_USB_ROOT_HUB_HUB_DES
 
 /*
  * Root Hub Control Pipe (interrupt Pipes are not supported)
@@ -1044,7 +926,7 @@ int uhci_submit_rh_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
                        status = (status & 0xfff5) | USBPORTSC_PR;
                        out16r(usb_base_addr + USBPORTSC1 + 2 * (wIndex - 1),
                               status);
-                       wait_ms(10);
+                       mdelay(10);
                        status = (status & 0xfff5) & ~USBPORTSC_PR;
                        out16r(usb_base_addr + USBPORTSC1 + 2 * (wIndex - 1),
                               status);
@@ -1052,7 +934,7 @@ int uhci_submit_rh_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
                        status = (status & 0xfff5) | USBPORTSC_PE;
                        out16r(usb_base_addr + USBPORTSC1 + 2 * (wIndex - 1),
                               status);
-                       wait_ms(10);
+                       mdelay(10);
                        status = (status & 0xfff5) | 0xa;
                        out16r(usb_base_addr + USBPORTSC1 + 2 * (wIndex - 1),
                               status);