blob: 3cae21ff26afee6dde34c1dc234c7ab88fa49588 [file] [log] [blame]
Kevin O'Connor59f02832009-10-12 10:09:15 -04001#ifndef __USB_OHCI_H
2#define __USB_OHCI_H
3
4// usb-ohci.c
Kevin O'Connorec443ff2013-12-05 18:43:20 -05005void ohci_setup(void);
Kevin O'Connor54bf2072012-03-09 07:52:33 -05006struct usbdevice_s;
7struct usb_endpoint_descriptor;
Kevin O'Connorc3d96c22012-03-10 09:03:25 -05008struct usb_pipe *ohci_alloc_pipe(struct usbdevice_s *usbdev
9 , struct usb_endpoint_descriptor *epdesc);
Kevin O'Connor357bdfa2010-02-26 08:57:13 -050010struct usb_pipe;
Kevin O'Connor357bdfa2010-02-26 08:57:13 -050011int ohci_control(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
Kevin O'Connor59f02832009-10-12 10:09:15 -040012 , void *data, int datasize);
Kevin O'Connor2f968002010-09-19 22:10:08 -040013int ohci_send_bulk(struct usb_pipe *p, int dir, void *data, int datasize);
Kevin O'Connor4547eb92010-02-28 02:17:28 -050014int ohci_poll_intr(struct usb_pipe *p, void *data);
Kevin O'Connor59f02832009-10-12 10:09:15 -040015
16
17/****************************************************************
18 * ohci structs and flags
19 ****************************************************************/
20
21struct 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
37struct 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
Kevin O'Connor59f02832009-10-12 10:09:15 -040047
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
63struct ohci_hcca {
64 u32 int_table[32];
65 u32 frame_no;
66 u32 done_head;
67 u8 reserved[120];
68} PACKED;
69
70struct 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
Kevin O'Connor1c46a542009-10-17 23:53:32 -040098#define OHCI_CTRL_CBSR (3 << 0)
99#define OHCI_CTRL_PLE (1 << 2)
100#define OHCI_CTRL_CLE (1 << 4)
Kevin O'Connor357bdfa2010-02-26 08:57:13 -0500101#define OHCI_CTRL_BLE (1 << 5)
Kevin O'Connor1c46a542009-10-17 23:53:32 -0400102#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
Kevin O'Connor59f02832009-10-12 10:09:15 -0400110#define OHCI_INTR_MIE (1 << 31)
111
Kevin O'Connor1c46a542009-10-17 23:53:32 -0400112#define RH_PS_CCS 0x00000001
113#define RH_PS_PES 0x00000002
114#define RH_PS_PSS 0x00000004
115#define RH_PS_POCI 0x00000008
116#define RH_PS_PRS 0x00000010
117#define RH_PS_PPS 0x00000100
118#define RH_PS_LSDA 0x00000200
119#define RH_PS_CSC 0x00010000
120#define RH_PS_PESC 0x00020000
121#define RH_PS_PSSC 0x00040000
122#define RH_PS_OCIC 0x00080000
123#define RH_PS_PRSC 0x00100000
124
125#define RH_HS_LPS 0x00000001
126#define RH_HS_OCI 0x00000002
127#define RH_HS_DRWE 0x00008000
128#define RH_HS_LPSC 0x00010000
129#define RH_HS_OCIC 0x00020000
130#define RH_HS_CRWE 0x80000000
131
132#define RH_B_DR 0x0000ffff
133#define RH_B_PPCM 0xffff0000
134
135#define RH_A_NDP (0xff << 0)
136#define RH_A_PSM (1 << 8)
137#define RH_A_NPS (1 << 9)
138#define RH_A_DT (1 << 10)
139#define RH_A_OCPM (1 << 11)
140#define RH_A_NOCP (1 << 12)
141#define RH_A_POTPGT (0xff << 24)
142
Kevin O'Connor59f02832009-10-12 10:09:15 -0400143#endif // usb-ohci.h