ohci.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __OHCI_H__
00013 #define __OHCI_H__
00014
00015 #include <types.h>
00016
00017
00018
00019
00020
00021
00022
00023
00024 #define OHCI_CTRL_CBSR (3 << 0)
00025 #define OHCI_CTRL_PLE (1 << 2)
00026 #define OHCI_CTRL_IE (1 << 3)
00027 #define OHCI_CTRL_CLE (1 << 4)
00028 #define OHCI_CTRL_BLE (1 << 5)
00029 #define OHCI_CTRL_HCFS (3 << 6)
00030 #define OHCI_CTRL_IR (1 << 8)
00031 #define OHCI_CTRL_RWC (1 << 9)
00032 #define OHCI_CTRL_RWE (1 << 10)
00033
00034
00035 #define OHCI_USB_RESET (0 << 6)
00036 #define OHCI_USB_RESUME (1 << 6)
00037 #define OHCI_USB_OPER (2 << 6)
00038 #define OHCI_USB_SUSPEND (3 << 6)
00039
00040
00041
00042
00043 #define OHCI_HCR (1 << 0)
00044 #define OHCI_CLF (1 << 1)
00045 #define OHCI_BLF (1 << 2)
00046 #define OHCI_OCR (1 << 3)
00047 #define OHCI_SOC (3 << 16)
00048
00049
00050
00051
00052
00053
00054
00055 #define OHCI_INTR_SO (1 << 0)
00056 #define OHCI_INTR_WDH (1 << 1)
00057 #define OHCI_INTR_SF (1 << 2)
00058 #define OHCI_INTR_RD (1 << 3)
00059 #define OHCI_INTR_UE (1 << 4)
00060 #define OHCI_INTR_FNO (1 << 5)
00061 #define OHCI_INTR_RHSC (1 << 6)
00062 #define OHCI_INTR_OC (1 << 30)
00063 #define OHCI_INTR_MIE (1 << 31)
00064
00065
00066 #define OHCI_CONTROL_INIT (3 << 0)
00067 #define OHCI_INTR_INIT \
00068 (OHCI_INTR_MIE | OHCI_INTR_RHSC | OHCI_INTR_UE)
00069
00070
00071
00072
00073 #define RH_PS_CCS 0x00000001
00074 #define RH_PS_PES 0x00000002
00075 #define RH_PS_PSS 0x00000004
00076 #define RH_PS_POCI 0x00000008
00077 #define RH_PS_PRS 0x00000010
00078 #define RH_PS_PPS 0x00000100
00079 #define RH_PS_LSDA 0x00000200
00080 #define RH_PS_CSC 0x00010000
00081 #define RH_PS_PESC 0x00020000
00082 #define RH_PS_PSSC 0x00040000
00083 #define RH_PS_OCIC 0x00080000
00084 #define RH_PS_PRSC 0x00100000
00085
00086
00087 #define RH_HS_LPS 0x00000001
00088 #define RH_HS_OCI 0x00000002
00089 #define RH_HS_DRWE 0x00008000
00090 #define RH_HS_LPSC 0x00010000
00091 #define RH_HS_OCIC 0x00020000
00092 #define RH_HS_CRWE 0x80000000
00093
00094
00095 #define RH_B_DR 0x0000ffff
00096 #define RH_B_PPCM 0xffff0000
00097
00098
00099 #define RH_A_NDP (0xff << 0)
00100 #define RH_A_PSM (1 << 8)
00101 #define RH_A_NPS (1 << 9)
00102 #define RH_A_DT (1 << 10)
00103 #define RH_A_OCPM (1 << 11)
00104 #define RH_A_NOCP (1 << 12)
00105 #define RH_A_POTPGT (0xff << 24)
00106
00107 struct ohci_hcca {
00108 #define NUM_INITS 32
00109 u32 int_table[NUM_INITS];
00110
00111
00112
00113
00114
00115 u32 frame_no;
00116 u32 done_head;
00117 u8 reserved_for_hc [116];
00118 u8 what [4];
00119 } ALIGNED(256);
00120
00121 struct endpoint_descriptor {
00122
00123 u32 flags;
00124 u32 tailp;
00125 u32 headp;
00126 u32 nexted;
00127
00128
00129 u32 tdcount;
00130 u8 type;
00131 } ALIGNED(16);
00132
00133 #define OHCI_ENDPOINT_ADDRESS_MASK 0x0000007f
00134 #define OHCI_ENDPOINT_GET_DEVICE_ADDRESS(s) ((s) & 0x7f)
00135 #define OHCI_ENDPOINT_SET_DEVICE_ADDRESS(s) (s)
00136 #define OHCI_ENDPOINT_GET_ENDPOINT_NUMBER(s) (((s) >> 7) & 0xf)
00137 #define OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(s) ((s) << 7)
00138 #define OHCI_ENDPOINT_DIRECTION_MASK 0x00001800
00139 #define OHCI_ENDPOINT_DIRECTION_DESCRIPTOR 0x00000000
00140 #define OHCI_ENDPOINT_DIRECTION_OUT 0x00000800
00141 #define OHCI_ENDPOINT_DIRECTION_IN 0x00001000
00142 #define OHCI_ENDPOINT_LOW_SPEED 0x00002000
00143 #define OHCI_ENDPOINT_FULL_SPEED 0x00000000
00144 #define OHCI_ENDPOINT_SKIP 0x00004000
00145 #define OHCI_ENDPOINT_GENERAL_FORMAT 0x00000000
00146 #define OHCI_ENDPOINT_ISOCHRONOUS_FORMAT 0x00008000
00147 #define OHCI_ENDPOINT_MAX_PACKET_SIZE_MASK (0x7ff << 16)
00148 #define OHCI_ENDPOINT_GET_MAX_PACKET_SIZE(s) (((s) >> 16) & 0x07ff)
00149 #define OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(s) ((s) << 16)
00150 #define OHCI_ENDPOINT_HALTED 0x00000001
00151 #define OHCI_ENDPOINT_TOGGLE_CARRY 0x00000002
00152 #define OHCI_ENDPOINT_HEAD_MASK 0xfffffffc
00153
00154
00155 struct general_td {
00156
00157 u32 flags;
00158 u32 cbp;
00159 u32 nexttd;
00160 u32 be;
00161
00162
00163 u32 bufaddr;
00164 u32 buflen;
00165 u32 pad1;
00166 u32 pad2;
00167 } ALIGNED(16);
00168
00169 #define OHCI_TD_BUFFER_ROUNDING 0x00040000
00170 #define OHCI_TD_DIRECTION_PID_MASK 0x00180000
00171 #define OHCI_TD_DIRECTION_PID_SETUP 0x00000000
00172 #define OHCI_TD_DIRECTION_PID_OUT 0x00080000
00173 #define OHCI_TD_DIRECTION_PID_IN 0x00100000
00174 #define OHCI_TD_GET_DELAY_INTERRUPT(x) (((x) >> 21) & 7)
00175 #define OHCI_TD_SET_DELAY_INTERRUPT(x) ((x) << 21)
00176 #define OHCI_TD_INTERRUPT_MASK 0x00e00000
00177 #define OHCI_TD_TOGGLE_CARRY 0x00000000
00178 #define OHCI_TD_TOGGLE_0 0x02000000
00179 #define OHCI_TD_TOGGLE_1 0x03000000
00180 #define OHCI_TD_TOGGLE_MASK 0x03000000
00181 #define OHCI_TD_GET_ERROR_COUNT(x) (((x) >> 26) & 3)
00182 #define OHCI_TD_GET_CONDITION_CODE(x) ((x) >> 28)
00183 #define OHCI_TD_SET_CONDITION_CODE(x) ((x) << 28)
00184 #define OHCI_TD_CONDITION_CODE_MASK 0xf0000000
00185
00186 #define OHCI_TD_INTERRUPT_IMMEDIATE 0x00
00187 #define OHCI_TD_INTERRUPT_NONE 0x07
00188
00189 #define OHCI_TD_CONDITION_NO_ERROR 0x00
00190 #define OHCI_TD_CONDITION_CRC_ERROR 0x01
00191 #define OHCI_TD_CONDITION_BIT_STUFFING 0x02
00192 #define OHCI_TD_CONDITION_TOGGLE_MISMATCH 0x03
00193 #define OHCI_TD_CONDITION_STALL 0x04
00194 #define OHCI_TD_CONDITION_NO_RESPONSE 0x05
00195 #define OHCI_TD_CONDITION_PID_CHECK_FAILURE 0x06
00196 #define OHCI_TD_CONDITION_UNEXPECTED_PID 0x07
00197 #define OHCI_TD_CONDITION_DATA_OVERRUN 0x08
00198 #define OHCI_TD_CONDITION_DATA_UNDERRUN 0x09
00199 #define OHCI_TD_CONDITION_BUFFER_OVERRUN 0x0c
00200 #define OHCI_TD_CONDITION_BUFFER_UNDERRUN 0x0d
00201 #define OHCI_TD_CONDITION_NOT_ACCESSED 0x0f
00202
00203 #endif
00204