Changeset bfc5c9dd in mainline for uspace/drv/bus/usb/ohci/ohci_regs.h
- Timestamp:
- 2012-02-23T20:42:30Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 815b244a
- Parents:
- ffcc5776
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/ohci_regs.h
rffcc5776 rbfc5c9dd 42 42 #define ohci_reg2host(value) uint32_t_le2host(value) 43 43 44 #define OHCI_WR(reg, val) reg = host2uint32_t_le(val) 45 #define OHCI_RD(reg) uint32_t_le2host(reg) 46 #define OHCI_SET(reg, val) reg |= host2uint32_t_le(val) 47 #define OHCI_CLR(reg, val) reg &= host2uint32_t_le(val) 48 49 44 50 #define LEGACY_REGS_OFFSET 0x100 45 51 … … 47 53 typedef struct ohci_regs { 48 54 const ioport32_t revision; 49 #define R_REVISION_ (reg) (ohci_reg2host(reg) &0x3f)50 #define R_LEGACY_FLAG host2ohci_reg(0x80)55 #define R_REVISION_MASK (0x3f) 56 #define R_LEGACY_FLAG (0x80) 51 57 52 58 ioport32_t control; … … 56 62 #define C_CBSR_1_3 (0x2) 57 63 #define C_CBSR_1_4 (0x3) 58 #define C_CBSR_GET(reg) (ohci_reg2host(reg) & 0x3) 59 #define C_CBSR_SET(reg, value) \ 60 do { \ 61 reg = (reg & host2ohci_reg(~0x3) | host2ohci_reg(value & 0x3)) \ 62 } while (0) 63 64 #define C_PLE host2ohci_reg(1 << 2) /* Periodic list enable */ 65 #define C_IE host2ohci_reg(1 << 3) /* Isochronous enable */ 66 #define C_CLE host2ohci_reg(1 << 4) /* Control list enable */ 67 #define C_BLE host2ohci_reg(1 << 5) /* Bulk list enable */ 64 #define C_CBSR_MASK (0x3) 65 #define C_CBSR_SHIFT 0 66 67 #define C_PLE (1 << 2) /* Periodic list enable */ 68 #define C_IE (1 << 3) /* Isochronous enable */ 69 #define C_CLE (1 << 4) /* Control list enable */ 70 #define C_BLE (1 << 5) /* Bulk list enable */ 68 71 69 72 /* Host controller functional state */ … … 72 75 #define C_HCFS_OPERATIONAL (0x2) 73 76 #define C_HCFS_SUSPEND (0x3) 74 #define C_HCFS_GET(reg) (( ohci_reg2host(reg) >> 6) & 0x3)77 #define C_HCFS_GET(reg) ((OHCI_RD(reg) >> 6) & 0x3) 75 78 #define C_HCFS_SET(reg, value) \ 76 79 do { \ 77 reg = (reg & host2ohci_reg(~(0x3 << 6))) \ 78 | host2ohci_reg((value & 0x3) << 6); \ 80 uint32_t r = OHCI_RD(reg); \ 81 r &= ~(0x3 << 6); \ 82 r |= (value & 0x3) << 6; \ 83 OHCI_WR(reg, r); \ 79 84 } while (0) 80 85 81 #define C_IR host2ohci_reg(1 << 8) /* Interrupt routing, make sure it's 0 */82 #define C_RWC host2ohci_reg(1 << 9) /* Remote wakeup connected, host specific */83 #define C_RWE host2ohci_reg(1 << 10) /* Remote wakeup enable */86 #define C_IR (1 << 8) /* Interrupt routing, make sure it's 0 */ 87 #define C_RWC (1 << 9) /* Remote wakeup connected, host specific */ 88 #define C_RWE (1 << 10) /* Remote wakeup enable */ 84 89 85 90 ioport32_t command_status; 86 #define CS_HCR host2ohci_reg(1 << 0) /* Host controller reset */87 #define CS_CLF host2ohci_reg(1 << 1) /* Control list filled */88 #define CS_BLF host2ohci_reg(1 << 2) /* Bulk list filled */89 #define CS_OCR host2ohci_reg(1 << 3) /* Ownership change request */91 #define CS_HCR (1 << 0) /* Host controller reset */ 92 #define CS_CLF (1 << 1) /* Control list filled */ 93 #define CS_BLF (1 << 2) /* Bulk list filled */ 94 #define CS_OCR (1 << 3) /* Ownership change request */ 90 95 #if 0 91 96 #define CS_SOC_MASK (0x3) /* Scheduling overrun count */ … … 100 105 ioport32_t interrupt_enable; 101 106 ioport32_t interrupt_disable; 102 #define I_SO host2ohci_reg(1 << 0) /* Scheduling overrun */103 #define I_WDH host2ohci_reg(1 << 1) /* Done head write-back */104 #define I_SF host2ohci_reg(1 << 2) /* Start of frame */105 #define I_RD host2ohci_reg(1 << 3) /* Resume detect */106 #define I_UE host2ohci_reg(1 << 4) /* Unrecoverable error */107 #define I_FNO host2ohci_reg(1 << 5) /* Frame number overflow */108 #define I_RHSC host2ohci_reg(1 << 6) /* Root hub status change */109 #define I_OC host2ohci_reg(1 << 30) /* Ownership change */110 #define I_MI host2ohci_reg(1 << 31) /* Master interrupt (any/all) */107 #define I_SO (1 << 0) /* Scheduling overrun */ 108 #define I_WDH (1 << 1) /* Done head write-back */ 109 #define I_SF (1 << 2) /* Start of frame */ 110 #define I_RD (1 << 3) /* Resume detect */ 111 #define I_UE (1 << 4) /* Unrecoverable error */ 112 #define I_FNO (1 << 5) /* Frame number overflow */ 113 #define I_RHSC (1 << 6) /* Root hub status change */ 114 #define I_OC (1 << 30) /* Ownership change */ 115 #define I_MI (1 << 31) /* Master interrupt (any/all) */ 111 116 112 117 /** HCCA pointer (see hw_struct hcca.h) */ … … 134 139 /** Frame time and max packet size for all transfers */ 135 140 ioport32_t fm_interval; 136 #define FMI_FL_GET(reg) (ohci_reg2host(reg) & 0x3fff)137 #if 0138 141 #define FMI_FI_MASK (0x3fff) /* Frame interval in bit times (should be 11999)*/ 139 142 #define FMI_FI_SHIFT (0) … … 141 144 #define FMI_FSMPS_SHIFT (16) 142 145 #define FMI_TOGGLE_FLAG (1 << 31) 143 #endif144 146 145 147 /** Bit times remaining in current frame */ 146 148 const ioport32_t fm_remaining; 147 #define FMR_R_GET(reg) (ohci_reg2host(reg) & 0x3fff)148 #if 0149 149 #define FMR_FR_MASK FMI_FI_MASK 150 150 #define FMR_FR_SHIFT FMI_FI_SHIFT 151 151 #define FMR_TOGGLE_FLAG FMI_TOGGLE_FLAG 152 #endif 152 153 153 /** Frame number */ 154 154 const ioport32_t fm_number; 155 #if 0156 155 #define FMN_NUMBER_MASK (0xffff) 157 #endif 156 158 157 /** Remaining bit time in frame to start periodic transfers */ 159 158 ioport32_t periodic_start; 160 #define PS_GET(reg) (ohci_reg2host(reg) & 0x3fff) 161 #define PS_SET(reg, value) \ 162 do { \ 163 reg = (reg & host2ohci_reg(~0x3fff)) | host2ohci_reg(value & 0x3fff); \ 164 } while (0) 159 #define PS_MASK 0x3fff 160 #define PS_SHIFT 0 165 161 166 162 /** Threshold for starting LS transaction */ 167 163 ioport32_t ls_threshold; 168 //#define LST_LST_MASK (0x7fff)164 #define LST_LST_MASK (0x7fff) 169 165 170 166 /** The first root hub control register */ 171 167 ioport32_t rh_desc_a; 172 168 /** Number of downstream ports, max 15 */ 173 #define RHDA_NDS (reg) (ohci_reg2host(reg) &0xff)169 #define RHDA_NDS_MASK (0xff) 174 170 /** Power switching mode: 0-global, 1-per port*/ 175 #define RHDA_PSM_FLAG host2ohci_reg(1 << 8)171 #define RHDA_PSM_FLAG (1 << 8) 176 172 /** No power switch: 1-power on, 0-use PSM*/ 177 #define RHDA_NPS_FLAG host2ohci_reg(1 << 9)173 #define RHDA_NPS_FLAG (1 << 9) 178 174 /** 1-Compound device, must be 0 */ 179 #define RHDA_DT_FLAG host2ohci_reg(1 << 10)175 #define RHDA_DT_FLAG (1 << 10) 180 176 /** Over-current mode: 0-global, 1-per port */ 181 #define RHDA_OCPM_FLAG host2ohci_reg(1 << 11)177 #define RHDA_OCPM_FLAG (1 << 11) 182 178 /** OC control: 0-use OCPM, 1-OC off */ 183 #define RHDA_NOCP_FLAG host2ohci_reg(1 << 12)179 #define RHDA_NOCP_FLAG (1 << 12) 184 180 /** Power on to power good time */ 185 #define RHDA_POTPGT (reg) (ohci_reg2host(reg) >> 24)181 #define RHDA_POTPGT_SHIFT 24 186 182 187 183 /** The other root hub control register */ 188 184 ioport32_t rh_desc_b; 189 185 /** Device removable mask */ 190 #define RHDB_DR_ READ(reg) (ohci_reg2host(reg) & 0xffff)191 #define RHDB_DR_ WRITE(val) host2ohci_reg(val & 0xffff)186 #define RHDB_DR_SHIFT 0 187 #define RHDB_DR_MASK 0xffff 192 188 /** Power control mask */ 193 #define RHDB_PCC_READ(reg) (ohci_reg2host(reg) >> 16) 194 #define RHDB_PCC_WRITE(val) host2ohci_reg(val << 16) 195 /* Port device removable status */ 196 #define RHDB_DR_FLAG(port) \ 197 host2ohci_reg(((1 << port) & RHDB_DR_MASK) << RHDB_DR_SHIFT) 198 /* Port power control status: 1-per port power control, 0-global power switch */ 199 #define RHDB_PPC_FLAG(port) \ 200 host2ohci_reg(((1 << port) & RHDB_DR_MASK) << RHDB_DR_SHIFT) 189 #define RHDB_PCC_MASK (0xffff) 190 #define RHDB_PCC_SHIFT 16 201 191 202 192 /** Root hub status register */ … … 207 197 * specified in PPCM(RHDB), or all ports, 208 198 * if power is set globally */ 209 #define RHS_LPS_FLAG host2ohci_reg(1 << 0)199 #define RHS_LPS_FLAG (1 << 0) 210 200 #define RHS_CLEAR_GLOBAL_POWER RHS_LPS_FLAG /* synonym for the above */ 211 201 /** Over-current indicator, if per-port: 0 */ 212 #define RHS_OCI_FLAG host2ohci_reg(1 << 1)202 #define RHS_OCI_FLAG (1 << 1) 213 203 214 204 /* read: 0-connect status change does not wake HC 215 205 * 1-connect status change wakes HC 216 206 * write: 1-set DRWE, 0-no effect */ 217 #define RHS_DRWE_FLAG host2ohci_reg(1 << 15)207 #define RHS_DRWE_FLAG (1 << 15) 218 208 #define RHS_SET_DRWE RHS_DRWE_FLAG 219 209 /* read: 0, … … 222 212 * specified in PPCM(RHDB), or all ports, 223 213 * if power is set globally */ 224 #define RHS_LPSC_FLAG host2ohci_reg(1 << 16)214 #define RHS_LPSC_FLAG (1 << 16) 225 215 #define RHS_SET_GLOBAL_POWER RHS_LPSC_FLAG /* synonym for the above */ 226 216 /** Over-current change indicator*/ 227 #define RHS_OCIC_FLAG host2ohci_reg(1 << 17)228 #define RHS_CLEAR_DRWE host2ohci_reg(1 << 31)217 #define RHS_OCIC_FLAG (1 << 17) 218 #define RHS_CLEAR_DRWE (1 << 31) 229 219 230 220 /** Root hub per port status */ 231 221 ioport32_t rh_port_status[]; 232 #define RHPS_CCS_FLAG host2ohci_reg(1 << 0) /* r: current connect status,222 #define RHPS_CCS_FLAG (1 << 0) /* r: current connect status, 233 223 * w: 1-clear port enable, 0-N/S*/ 234 224 #define RHPS_CLEAR_PORT_ENABLE RHPS_CCS_FLAG 235 #define RHPS_PES_FLAG host2ohci_reg(1 << 1) /* r: port enable status225 #define RHPS_PES_FLAG (1 << 1) /* r: port enable status 236 226 * w: 1-set port enable, 0-N/S */ 237 227 #define RHPS_SET_PORT_ENABLE RHPS_PES_FLAG 238 #define RHPS_PSS_FLAG host2ohci_reg(1 << 2) /* r: port suspend status228 #define RHPS_PSS_FLAG (1 << 2) /* r: port suspend status 239 229 * w: 1-set port suspend, 0-N/S */ 240 230 #define RHPS_SET_PORT_SUSPEND RHPS_PSS_FLAG 241 #define RHPS_POCI_FLAG host2ohci_reg(1 << 3) /* r: port over-current231 #define RHPS_POCI_FLAG (1 << 3) /* r: port over-current 242 232 * (if reports are per-port 243 233 * w: 1-clear port suspend … … 245 235 * 0-nothing */ 246 236 #define RHPS_CLEAR_PORT_SUSPEND RHPS_POCI_FLAG 247 #define RHPS_PRS_FLAG host2ohci_reg(1 << 4) /* r: port reset status237 #define RHPS_PRS_FLAG (1 << 4) /* r: port reset status 248 238 * w: 1-set port reset, 0-N/S */ 249 239 #define RHPS_SET_PORT_RESET RHPS_PRS_FLAG 250 #define RHPS_PPS_FLAG host2ohci_reg(1 << 8) /* r: port power status240 #define RHPS_PPS_FLAG (1 << 8) /* r: port power status 251 241 * w: 1-set port power, 0-N/S */ 252 242 #define RHPS_SET_PORT_POWER RHPS_PPS_FLAG 253 #define RHPS_LSDA_FLAG host2ohci_reg(1 << 9) /* r: low speed device attached243 #define RHPS_LSDA_FLAG (1 << 9) /* r: low speed device attached 254 244 * w: 1-clear port power, 0-N/S*/ 255 245 #define RHPS_CLEAR_PORT_POWER RHPS_LSDA_FLAG 256 #define RHPS_CSC_FLAG host2ohci_reg(1 << 16) /* connect status change WC */ 257 #define RHPS_PESC_FLAG host2ohci_reg(1 << 17) /* port enable status change WC */ 258 #define RHPS_PSSC_FLAG host2ohci_reg(1 << 18) /* port suspend status change WC */ 259 #define RHPS_OCIC_FLAG host2ohci_reg(1 << 19) /* port over-current change WC */ 260 #define RHPS_PRSC_FLAG host2ohci_reg(1 << 20) /* port reset status change WC */ 261 #define RHPS_CHANGE_WC_MASK host2ohci_reg(0x1f0000) 262 /** OHCI designers were kind enough to make bits correspond to feature # */ 263 #define RHPS_FEATURE_BIT(feature) host2ohci_reg(1 << feature) 246 #define RHPS_CSC_FLAG (1 << 16) /* connect status change WC */ 247 #define RHPS_PESC_FLAG (1 << 17) /* port enable status change WC */ 248 #define RHPS_PSSC_FLAG (1 << 18) /* port suspend status change WC */ 249 #define RHPS_OCIC_FLAG (1 << 19) /* port over-current change WC */ 250 #define RHPS_PRSC_FLAG (1 << 20) /* port reset status change WC */ 251 #define RHPS_CHANGE_WC_MASK (0x1f0000) 264 252 } __attribute__((packed)) ohci_regs_t; 265 253 #endif
Note:
See TracChangeset
for help on using the changeset viewer.