2 * This file is part of the libpayload project.
4 * Copyright (C) 2008 coresystems GmbH
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 unsigned long terminate:1;
39 unsigned long queue_head:1;
41 unsigned long ptr_part:28;
44 } __attribute__ ((packed)) flistp_t;
49 unsigned long terminate:1;
50 unsigned long queue_head:1;
51 unsigned long depth_first:1;
53 } __attribute__ ((packed));
55 } __attribute__ ((packed));
57 volatile unsigned long actlen:11;
58 volatile unsigned long:5;
61 unsigned long:1; // bit 0
62 unsigned long status_bitstuff_err:1;
63 unsigned long status_crc_err:1;
64 unsigned long status_nakrcvd:1;
65 unsigned long status_babble:1;
66 unsigned long status_databuf_err:1;
67 unsigned long status_stalled:1;
68 unsigned long status_active:1; // bit 7
69 } __attribute__ ((packed));
71 } __attribute__ ((packed));
72 volatile unsigned long ioc:1; /* interrupt on complete */
73 volatile unsigned long isochronous:1;
74 volatile unsigned long lowspeed:1;
75 volatile unsigned long counter:2;
76 volatile unsigned long shortpck:1;
77 volatile unsigned long:2;
80 unsigned long dev_addr:7;
82 unsigned long data_toggle:1;
84 unsigned long maxlen:11;
88 } __attribute__ ((packed))
93 volatile flistp_t elementlinkptr;
94 } __attribute__ ((packed))
97 typedef enum { USBCMD = 0, USBSTS = 2, USBINTR = 4, FRNUM =
98 6, FLBASEADD = 8, SOFMOD = 0xc, PORTSC1 = 0x10, PORTSC2 =
102 void uhci_reg_write32 (hci_t *ctrl, usbreg reg, u32 value);
103 u32 uhci_reg_read32 (hci_t *ctrl, usbreg reg);
104 void uhci_reg_write16 (hci_t *ctrl, usbreg reg, u16 value);
105 u16 uhci_reg_read16 (hci_t *ctrl, usbreg reg);
106 void uhci_reg_write8 (hci_t *ctrl, usbreg reg, u8 value);
107 u8 uhci_reg_read8 (hci_t *ctrl, usbreg reg);
108 void uhci_reg_mask32 (hci_t *ctrl, usbreg reg, u32 andmask, u32 ormask);
109 void uhci_reg_mask16 (hci_t *ctrl, usbreg reg, u16 andmask, u16 ormask);
110 void uhci_reg_mask8 (hci_t *ctrl, usbreg reg, u8 andmask, u8 ormask);
112 typedef struct uhci {
113 flistp_t *framelistptr;
114 qh_t *qh_intr, *qh_data, *qh_last;
118 #define UHCI_INST(controller) ((uhci_t*)((controller)->instance))
120 hci_t *uhci_init (pcidev_t addr);
122 void uhci_rh_init (usbdev_t *dev);