]> git.sur5r.net Git - u-boot/blobdiff - board/mpl/common/usb_uhci.c
usb: add enum usb_init_type parameter to usb_lowlevel_init
[u-boot] / board / mpl / common / usb_uhci.c
index 4a10b7969b780ef3888696fe900c92bdfb06951c..6bbb527dab5b3add30954b161e5a228c464a4d54 100644 (file)
@@ -1,27 +1,27 @@
 /*
- * (C) Copyright 2001
- * Denis Peter, MPL AG Switzerland
+ * Part of this code has been derived from linux:
+ * Universal Host Controller Interface driver for USB (take II).
  *
- * See file CREDITS for list of people who contributed to this
- * project.
+ * (c) 1999-2001 Georg Acher, acher@in.tum.de (executive slave) (base guitar)
+ *               Deti Fliegl, deti@fliegl.de (executive slave) (lead voice)
+ *               Thomas Sailer, sailer@ife.ee.ethz.ch (chief consultant) (cheer leader)
+ *               Roman Weissgaerber, weissg@vienna.at (virt root hub) (studio porter)
+ * (c) 2000      Yggdrasil Computing, Inc. (port of new PCI interface support
+ *               from usb-ohci.c by Adam Richter, adam@yggdrasil.com).
+ * (C) 2000      David Brownell, david-b@pacbell.net (usb-ohci.c)
  *
- * 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.
+ * HW-initalization based on material of
  *
- * 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.
+ * (C) Copyright 1999 Linus Torvalds
+ * (C) Copyright 1999 Johannes Erdfelt
+ * (C) Copyright 1999 Randy Dunlap
+ * (C) Copyright 1999 Gregory P. Smith
  *
- * 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
  *
- * Note: Part of this code has been derived from linux
+ * Adapted for U-Boot:
+ * (C) Copyright 2001 Denis Peter, MPL AG Switzerland
  *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /**********************************************************************
@@ -49,7 +49,7 @@
  *
  * Interrupt Transfers.
  * --------------------
- * For Interupt transfers USB_MAX_TEMP_INT_TD Transfer descriptor are available. They
+ * 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
@@ -417,9 +417,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)
@@ -518,11 +518,11 @@ void usb_check_int_chain(void)
        uhci_td_t *td,*prevtd;
 
        for(i=0;i<8;i++) {
-               prevtd=&td_int[i]; /* the first previous td is the skeleton td */
+               prevtd = &td_int[i]; /* the first previous td is the skeleton td */
                link=swap_32(td_int[i].link) & 0xfffffff0; /* next in chain */
                td=(uhci_td_t *)link; /* assign it */
                /* all interrupt TDs are finally linked to the td_int[0].
-                * so we process all until we find the td_int[0].
+                * so we process all until we find the td_int[0].
                 * if int0 chain points to a QH, we're also done
           */
                while(((i>0) && (link != (unsigned long)&td_int[0])) ||
@@ -584,7 +584,7 @@ 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;
        int     busdevfunc;
@@ -603,7 +603,7 @@ int usb_lowlevel_init(void)
        pci_read_config_dword(busdevfunc,PCI_BASE_ADDRESS_4,&usb_base_addr);
        USB_UHCI_PRINTF("IO Base Address = 0x%lx\n",usb_base_addr);
        usb_base_addr&=0xFFFFFFF0;
-       usb_base_addr+=CFG_ISA_IO_BASE_ADDRESS;
+       usb_base_addr+=CONFIG_SYS_ISA_IO_BASE_ADDRESS;
        rh.devnum = 0;
        usb_init_skel();
        reset_hc();
@@ -614,13 +614,13 @@ int usb_lowlevel_init(void)
 
 /* stop uhci
  */
-int usb_lowlevel_stop(void)
+int usb_lowlevel_stop(int index)
 {
        if(irqvec==-1)
                return 1;
        irq_free_handler(irqvec);
        reset_hc();
-       irqvec=-1;
+       irqvec = -1;
        return 0;
 }
 
@@ -774,7 +774,7 @@ int uhci_submit_rh_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
        unsigned short wIndex;
        unsigned short wLength;
 
-       if ((pipe & PIPE_INTERRUPT) == PIPE_INTERRUPT) {
+       if (usb_pipeint(pipe)) {
                printf("Root-Hub submit IRQ: NOT implemented\n");
 #if 0
                uhci->rh.urb = urb;
@@ -908,13 +908,13 @@ int uhci_submit_rh_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
                        status = in16r(usb_base_addr+USBPORTSC1+2*(wIndex-1));
                        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);
                        udelay(10);
                        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);
                        len=0;