libpayload: remove uhci_reg_maskX
[coreboot.git] / payloads / libpayload / drivers / usb / uhci_private.h
1 /*
2  * This file is part of the libpayload project.
3  *
4  * Copyright (C) 2008-2010 coresystems GmbH
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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.
16  *
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
27  * SUCH DAMAGE.
28  */
29
30 #ifndef __UHCI_PRIVATE_H
31 #define __UHCI_PRIVATE_H
32
33 typedef enum { UHCI_SETUP = 0x2d, UHCI_IN = 0x69, UHCI_OUT = 0xe1 } uhci_pid_t;
34
35 typedef union {
36         struct {
37                 unsigned long terminate:1;
38                 unsigned long queue_head:1;
39                 unsigned long:2;
40                 unsigned long ptr_part:28;
41         };
42         u32 ptr;
43 } __attribute__ ((packed)) flistp_t;
44
45 typedef struct {
46         union {
47                 struct {
48                         unsigned long terminate:1;
49                         unsigned long queue_head:1;
50                         unsigned long depth_first:1;
51                         unsigned long:29;
52                 } __attribute__ ((packed));
53                 u32 ptr;
54         } __attribute__ ((packed));
55
56         volatile unsigned long actlen:11;
57         volatile unsigned long:5;
58         union {
59                 struct {
60                         unsigned long:1;        // bit 0
61                         unsigned long status_bitstuff_err:1;
62                         unsigned long status_crc_err:1;
63                         unsigned long status_nakrcvd:1;
64                         unsigned long status_babble:1;
65                         unsigned long status_databuf_err:1;
66                         unsigned long status_stalled:1;
67                         unsigned long status_active:1;  // bit 7
68                 } __attribute__ ((packed));
69                 unsigned char status;
70         } __attribute__ ((packed));
71         volatile unsigned long ioc:1;   /* interrupt on complete */
72         volatile unsigned long isochronous:1;
73         volatile unsigned long lowspeed:1;
74         volatile unsigned long counter:2;
75         volatile unsigned long shortpck:1;
76         volatile unsigned long:2;
77
78         unsigned long pid:8;
79         unsigned long dev_addr:7;
80         unsigned long endp:4;
81         unsigned long data_toggle:1;
82         unsigned long:1;
83         unsigned long maxlen:11;
84
85         u32 bufptr;
86
87 } __attribute__ ((packed))
88      td_t;
89
90      typedef struct {
91              flistp_t headlinkptr;
92              volatile flistp_t elementlinkptr;
93      } __attribute__ ((packed))
94      qh_t;
95
96      typedef enum { USBCMD = 0, USBSTS = 2, USBINTR = 4, FRNUM =
97                      6, FLBASEADD = 8, SOFMOD = 0xc, PORTSC1 = 0x10, PORTSC2 =
98                      0x12
99      } usbreg;
100
101      void uhci_reg_write32 (hci_t *ctrl, usbreg reg, u32 value);
102      u32 uhci_reg_read32 (hci_t *ctrl, usbreg reg);
103      void uhci_reg_write16 (hci_t *ctrl, usbreg reg, u16 value);
104      u16 uhci_reg_read16 (hci_t *ctrl, usbreg reg);
105      void uhci_reg_write8 (hci_t *ctrl, usbreg reg, u8 value);
106      u8 uhci_reg_read8 (hci_t *ctrl, usbreg reg);
107
108      typedef struct uhci {
109              flistp_t *framelistptr;
110              qh_t *qh_prei, *qh_intr, *qh_data, *qh_last;
111              usbdev_t *roothub;
112      } uhci_t;
113
114 #define UHCI_INST(controller) ((uhci_t*)((controller)->instance))
115
116 #endif