blob: f650c4a46867f067375f1829fd164164399f99e5 [file] [log] [blame]
Patrick Georgid78691d2010-06-07 13:58:17 +00001/*
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
33typedef enum { UHCI_SETUP = 0x2d, UHCI_IN = 0x69, UHCI_OUT = 0xe1 } uhci_pid_t;
34
Patrick Georgib0b4a522011-11-24 11:55:46 +010035typedef u32 flistp_t;
36#define FLISTP_TERMINATE 1
37#define FLISTP_QH 2
Patrick Georgid78691d2010-06-07 13:58:17 +000038
39typedef struct {
Patrick Georgib0b4a522011-11-24 11:55:46 +010040 u32 ptr;
41#define TD_TERMINATE 1
42#define TD_QH 2
43#define TD_DEPTH_FIRST 4
Patrick Georgid78691d2010-06-07 13:58:17 +000044
Patrick Georgib0b4a522011-11-24 11:55:46 +010045 u32 ctrlsts;
46#define TD_STATUS_MASK (0xff << 16)
47#define TD_STATUS_BITSTUFF_ERR (1 << 17)
48#define TD_STATUS_CRC_ERR (1 << 18)
49#define TD_STATUS_NAK_RCVD (1 << 19)
50#define TD_STATUS_BABBLE (1 << 20)
51#define TD_STATUS_DATABUF_ERR (1 << 21)
52#define TD_STATUS_STALLED (1 << 22)
53#define TD_STATUS_ACTIVE (1 << 23)
54#define TD_LOWSPEED (1 << 26)
55#define TD_COUNTER_SHIFT 27
Patrick Georgid78691d2010-06-07 13:58:17 +000056
Patrick Georgib0b4a522011-11-24 11:55:46 +010057 u32 token;
58#define TD_PID_MASK 0xff
59#define TD_DEVADDR_SHIFT 8
60#define TD_DEVADDR_MASK (((1<<7)-1) << TD_DEVADDR_SHIFT)
61#define TD_EP_SHIFT 15
62#define TD_EP_MASK (0xf << TD_EP_SHIFT)
63#define TD_TOGGLE_SHIFT 19
64#define TD_MAXLEN_SHIFT 21
65#define TD_TOGGLE_DATA0 0
66#define TD_TOGGLE_DATA1 (1 << TD_TOGGLE_SHIFT)
Patrick Georgid78691d2010-06-07 13:58:17 +000067
68 u32 bufptr;
69
70} __attribute__ ((packed))
71 td_t;
72
73 typedef struct {
74 flistp_t headlinkptr;
75 volatile flistp_t elementlinkptr;
76 } __attribute__ ((packed))
77 qh_t;
78
79 typedef enum { USBCMD = 0, USBSTS = 2, USBINTR = 4, FRNUM =
80 6, FLBASEADD = 8, SOFMOD = 0xc, PORTSC1 = 0x10, PORTSC2 =
81 0x12
82 } usbreg;
83
84 void uhci_reg_write32 (hci_t *ctrl, usbreg reg, u32 value);
85 u32 uhci_reg_read32 (hci_t *ctrl, usbreg reg);
86 void uhci_reg_write16 (hci_t *ctrl, usbreg reg, u16 value);
87 u16 uhci_reg_read16 (hci_t *ctrl, usbreg reg);
88 void uhci_reg_write8 (hci_t *ctrl, usbreg reg, u8 value);
89 u8 uhci_reg_read8 (hci_t *ctrl, usbreg reg);
Patrick Georgid78691d2010-06-07 13:58:17 +000090
91 typedef struct uhci {
92 flistp_t *framelistptr;
93 qh_t *qh_prei, *qh_intr, *qh_data, *qh_last;
94 usbdev_t *roothub;
95 } uhci_t;
96
97#define UHCI_INST(controller) ((uhci_t*)((controller)->instance))
98
99#endif