Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / seabios / src / hw / usb-ohci.h
1 #ifndef __USB_OHCI_H
2 #define __USB_OHCI_H
3
4 // usb-ohci.c
5 void ohci_setup(void);
6 struct usbdevice_s;
7 struct usb_endpoint_descriptor;
8 struct usb_pipe;
9 struct usb_pipe *ohci_realloc_pipe(struct usbdevice_s *usbdev
10                                    , struct usb_pipe *upipe
11                                    , struct usb_endpoint_descriptor *epdesc);
12 int ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
13                    , void *data, int datasize);
14 int ohci_poll_intr(struct usb_pipe *p, void *data);
15
16
17 /****************************************************************
18  * ohci structs and flags
19  ****************************************************************/
20
21 struct ohci_ed {
22     u32 hwINFO;
23     u32 hwTailP;
24     u32 hwHeadP;
25     u32 hwNextED;
26 } PACKED;
27
28 #define ED_ISO          (1 << 15)
29 #define ED_SKIP         (1 << 14)
30 #define ED_LOWSPEED     (1 << 13)
31 #define ED_OUT          (0x01 << 11)
32 #define ED_IN           (0x02 << 11)
33
34 #define ED_C            (0x02)
35 #define ED_H            (0x01)
36
37 struct ohci_td {
38     u32 hwINFO;
39     u32 hwCBP;
40     u32 hwNextTD;
41     u32 hwBE;
42 } PACKED;
43
44 #define TD_CC       0xf0000000
45 #define TD_CC_GET(td_p) ((td_p >>28) & 0x0f)
46 #define TD_DI       0x00E00000
47
48 #define TD_DONE     0x00020000
49 #define TD_ISO      0x00010000
50
51 #define TD_EC       0x0C000000
52 #define TD_T        0x03000000
53 #define TD_T_DATA0  0x02000000
54 #define TD_T_DATA1  0x03000000
55 #define TD_T_TOGGLE 0x00000000
56 #define TD_DP       0x00180000
57 #define TD_DP_SETUP 0x00000000
58 #define TD_DP_IN    0x00100000
59 #define TD_DP_OUT   0x00080000
60
61 #define TD_R        0x00040000
62
63 struct ohci_hcca {
64     u32  int_table[32];
65     u32  frame_no;
66     u32  done_head;
67     u8   reserved[120];
68 } PACKED;
69
70 struct ohci_regs {
71     u32  revision;
72     u32  control;
73     u32  cmdstatus;
74     u32  intrstatus;
75     u32  intrenable;
76     u32  intrdisable;
77
78     u32  hcca;
79     u32  ed_periodcurrent;
80     u32  ed_controlhead;
81     u32  ed_controlcurrent;
82     u32  ed_bulkhead;
83     u32  ed_bulkcurrent;
84     u32  donehead;
85
86     u32  fminterval;
87     u32  fmremaining;
88     u32  fmnumber;
89     u32  periodicstart;
90     u32  lsthresh;
91
92     u32  roothub_a;
93     u32  roothub_b;
94     u32  roothub_status;
95     u32  roothub_portstatus[15];
96 } PACKED;
97
98 #define OHCI_CTRL_CBSR  (3 << 0)
99 #define OHCI_CTRL_PLE   (1 << 2)
100 #define OHCI_CTRL_CLE   (1 << 4)
101 #define OHCI_CTRL_BLE   (1 << 5)
102 #define OHCI_CTRL_HCFS  (3 << 6)
103 #       define OHCI_USB_RESET   (0 << 6)
104 #       define OHCI_USB_OPER    (2 << 6)
105 #define OHCI_CTRL_RWC   (1 << 9)
106
107 #define OHCI_HCR        (1 << 0)
108 #define OHCI_CLF        (1 << 1)
109 #define OHCI_BLF        (1 << 2)
110
111 #define OHCI_INTR_MIE   (1 << 31)
112
113 #define RH_PS_CCS            0x00000001
114 #define RH_PS_PES            0x00000002
115 #define RH_PS_PSS            0x00000004
116 #define RH_PS_POCI           0x00000008
117 #define RH_PS_PRS            0x00000010
118 #define RH_PS_PPS            0x00000100
119 #define RH_PS_LSDA           0x00000200
120 #define RH_PS_CSC            0x00010000
121 #define RH_PS_PESC           0x00020000
122 #define RH_PS_PSSC           0x00040000
123 #define RH_PS_OCIC           0x00080000
124 #define RH_PS_PRSC           0x00100000
125
126 #define RH_HS_LPS            0x00000001
127 #define RH_HS_OCI            0x00000002
128 #define RH_HS_DRWE           0x00008000
129 #define RH_HS_LPSC           0x00010000
130 #define RH_HS_OCIC           0x00020000
131 #define RH_HS_CRWE           0x80000000
132
133 #define RH_B_DR         0x0000ffff
134 #define RH_B_PPCM       0xffff0000
135
136 #define RH_A_NDP        (0xff << 0)
137 #define RH_A_PSM        (1 << 8)
138 #define RH_A_NPS        (1 << 9)
139 #define RH_A_DT         (1 << 10)
140 #define RH_A_OCPM       (1 << 11)
141 #define RH_A_NOCP       (1 << 12)
142 #define RH_A_POTPGT     (0xff << 24)
143
144 #endif // usb-ohci.h