[42dbb26] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Jan Vesely
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - 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 | * - 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 ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
[c44a5f1] | 28 | /** @addtogroup drvusbohci
|
---|
[42dbb26] | 29 | * @{
|
---|
| 30 | */
|
---|
| 31 | /** @file
|
---|
| 32 | * @brief OHCI host controller register structure
|
---|
| 33 | */
|
---|
| 34 | #ifndef DRV_OHCI_OHCI_REGS_H
|
---|
| 35 | #define DRV_OHCI_OHCI_REGS_H
|
---|
[5d36062] | 36 | #include <sys/types.h>
|
---|
[ffcc5776] | 37 | #include <byteorder.h>
|
---|
| 38 |
|
---|
| 39 |
|
---|
| 40 | /* assume OHCI regs are le */
|
---|
| 41 | #define host2ohci_reg(value) host2uint32_t_le(value)
|
---|
| 42 | #define ohci_reg2host(value) uint32_t_le2host(value)
|
---|
[42dbb26] | 43 |
|
---|
[bfc5c9dd] | 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)
|
---|
[4e30369] | 47 | #define OHCI_CLR(reg, val) reg &= host2uint32_t_le(~val)
|
---|
[bfc5c9dd] | 48 |
|
---|
| 49 |
|
---|
[78ab6d4] | 50 | #define LEGACY_REGS_OFFSET 0x100
|
---|
| 51 |
|
---|
[02cacce] | 52 | /** OHCI memory mapped registers structure */
|
---|
| 53 | typedef struct ohci_regs {
|
---|
[5d36062] | 54 | const ioport32_t revision;
|
---|
[bfc5c9dd] | 55 | #define R_REVISION_MASK (0x3f)
|
---|
| 56 | #define R_LEGACY_FLAG (0x80)
|
---|
[78ab6d4] | 57 |
|
---|
[5d36062] | 58 | ioport32_t control;
|
---|
[ffcc5776] | 59 | /* Control-bulk service ratio */
|
---|
[01bbbb2] | 60 | #define C_CBSR_1_1 (0x0)
|
---|
| 61 | #define C_CBSR_1_2 (0x1)
|
---|
| 62 | #define C_CBSR_1_3 (0x2)
|
---|
| 63 | #define C_CBSR_1_4 (0x3)
|
---|
[bfc5c9dd] | 64 | #define C_CBSR_MASK (0x3)
|
---|
| 65 | #define C_CBSR_SHIFT 0
|
---|
[0c311d5] | 66 |
|
---|
[bfc5c9dd] | 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 */
|
---|
[0c311d5] | 71 |
|
---|
[ffcc5776] | 72 | /* Host controller functional state */
|
---|
[0c311d5] | 73 | #define C_HCFS_RESET (0x0)
|
---|
[5f7c846] | 74 | #define C_HCFS_RESUME (0x1)
|
---|
| 75 | #define C_HCFS_OPERATIONAL (0x2)
|
---|
[0c311d5] | 76 | #define C_HCFS_SUSPEND (0x3)
|
---|
[bfc5c9dd] | 77 | #define C_HCFS_GET(reg) ((OHCI_RD(reg) >> 6) & 0x3)
|
---|
[ffcc5776] | 78 | #define C_HCFS_SET(reg, value) \
|
---|
[78ab6d4] | 79 | do { \
|
---|
[bfc5c9dd] | 80 | uint32_t r = OHCI_RD(reg); \
|
---|
| 81 | r &= ~(0x3 << 6); \
|
---|
| 82 | r |= (value & 0x3) << 6; \
|
---|
| 83 | OHCI_WR(reg, r); \
|
---|
[78ab6d4] | 84 | } while (0)
|
---|
| 85 |
|
---|
[bfc5c9dd] | 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 */
|
---|
[2c617b0] | 89 |
|
---|
[5d36062] | 90 | ioport32_t command_status;
|
---|
[bfc5c9dd] | 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 */
|
---|
[ffcc5776] | 95 | #if 0
|
---|
[0c311d5] | 96 | #define CS_SOC_MASK (0x3) /* Scheduling overrun count */
|
---|
[2c617b0] | 97 | #define CS_SOC_SHIFT (16)
|
---|
[ffcc5776] | 98 | #endif
|
---|
[2c617b0] | 99 |
|
---|
[561112f] | 100 | /** Interupt enable/disable/status,
|
---|
| 101 | * reads give the same value,
|
---|
| 102 | * writing causes enable/disable,
|
---|
| 103 | * status is write-clean (writing 1 clears the bit*/
|
---|
[5d36062] | 104 | ioport32_t interrupt_status;
|
---|
| 105 | ioport32_t interrupt_enable;
|
---|
| 106 | ioport32_t interrupt_disable;
|
---|
[bfc5c9dd] | 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) */
|
---|
[0c311d5] | 116 |
|
---|
| 117 | /** HCCA pointer (see hw_struct hcca.h) */
|
---|
[5d36062] | 118 | ioport32_t hcca;
|
---|
[0c311d5] | 119 | #define HCCA_PTR_MASK 0xffffff00 /* HCCA is 256B aligned */
|
---|
| 120 |
|
---|
[aa9ccf7] | 121 | /** Currently executed periodic endpoint */
|
---|
[5d36062] | 122 | const ioport32_t periodic_current;
|
---|
[0c311d5] | 123 |
|
---|
| 124 | /** The first control endpoint */
|
---|
[5d36062] | 125 | ioport32_t control_head;
|
---|
[0c311d5] | 126 |
|
---|
| 127 | /** Currently executed control endpoint */
|
---|
[5d36062] | 128 | ioport32_t control_current;
|
---|
[0c311d5] | 129 |
|
---|
| 130 | /** The first bulk endpoint */
|
---|
[5d36062] | 131 | ioport32_t bulk_head;
|
---|
[0c311d5] | 132 |
|
---|
| 133 | /** Currently executed bulk endpoint */
|
---|
[5d36062] | 134 | ioport32_t bulk_current;
|
---|
[0c311d5] | 135 |
|
---|
| 136 | /** Done TD list, this value is periodically written to HCCA */
|
---|
[5d36062] | 137 | const ioport32_t done_head;
|
---|
[0c311d5] | 138 |
|
---|
| 139 | /** Frame time and max packet size for all transfers */
|
---|
[5d36062] | 140 | ioport32_t fm_interval;
|
---|
[112d159] | 141 | #define FMI_FI_MASK (0x3fff) /* Frame interval in bit times (should be 11999)*/
|
---|
[0c311d5] | 142 | #define FMI_FI_SHIFT (0)
|
---|
| 143 | #define FMI_FSMPS_MASK (0x7fff) /* Full speed max packet size */
|
---|
| 144 | #define FMI_FSMPS_SHIFT (16)
|
---|
| 145 | #define FMI_TOGGLE_FLAG (1 << 31)
|
---|
| 146 |
|
---|
| 147 | /** Bit times remaining in current frame */
|
---|
[5d36062] | 148 | const ioport32_t fm_remaining;
|
---|
[0c311d5] | 149 | #define FMR_FR_MASK FMI_FI_MASK
|
---|
| 150 | #define FMR_FR_SHIFT FMI_FI_SHIFT
|
---|
| 151 | #define FMR_TOGGLE_FLAG FMI_TOGGLE_FLAG
|
---|
[bfc5c9dd] | 152 |
|
---|
[0c311d5] | 153 | /** Frame number */
|
---|
[5d36062] | 154 | const ioport32_t fm_number;
|
---|
[0c311d5] | 155 | #define FMN_NUMBER_MASK (0xffff)
|
---|
[bfc5c9dd] | 156 |
|
---|
[0c311d5] | 157 | /** Remaining bit time in frame to start periodic transfers */
|
---|
[5d36062] | 158 | ioport32_t periodic_start;
|
---|
[bfc5c9dd] | 159 | #define PS_MASK 0x3fff
|
---|
| 160 | #define PS_SHIFT 0
|
---|
[0c311d5] | 161 |
|
---|
| 162 | /** Threshold for starting LS transaction */
|
---|
[5d36062] | 163 | ioport32_t ls_threshold;
|
---|
[bfc5c9dd] | 164 | #define LST_LST_MASK (0x7fff)
|
---|
[0c311d5] | 165 |
|
---|
| 166 | /** The first root hub control register */
|
---|
[5d36062] | 167 | ioport32_t rh_desc_a;
|
---|
[ffcc5776] | 168 | /** Number of downstream ports, max 15 */
|
---|
[bfc5c9dd] | 169 | #define RHDA_NDS_MASK (0xff)
|
---|
[ffcc5776] | 170 | /** Power switching mode: 0-global, 1-per port*/
|
---|
[bfc5c9dd] | 171 | #define RHDA_PSM_FLAG (1 << 8)
|
---|
[ffcc5776] | 172 | /** No power switch: 1-power on, 0-use PSM*/
|
---|
[bfc5c9dd] | 173 | #define RHDA_NPS_FLAG (1 << 9)
|
---|
[ffcc5776] | 174 | /** 1-Compound device, must be 0 */
|
---|
[bfc5c9dd] | 175 | #define RHDA_DT_FLAG (1 << 10)
|
---|
[ffcc5776] | 176 | /** Over-current mode: 0-global, 1-per port */
|
---|
[bfc5c9dd] | 177 | #define RHDA_OCPM_FLAG (1 << 11)
|
---|
[ffcc5776] | 178 | /** OC control: 0-use OCPM, 1-OC off */
|
---|
[bfc5c9dd] | 179 | #define RHDA_NOCP_FLAG (1 << 12)
|
---|
[ffcc5776] | 180 | /** Power on to power good time */
|
---|
[bfc5c9dd] | 181 | #define RHDA_POTPGT_SHIFT 24
|
---|
[0c311d5] | 182 |
|
---|
| 183 | /** The other root hub control register */
|
---|
[5d36062] | 184 | ioport32_t rh_desc_b;
|
---|
[ffcc5776] | 185 | /** Device removable mask */
|
---|
[bfc5c9dd] | 186 | #define RHDB_DR_SHIFT 0
|
---|
| 187 | #define RHDB_DR_MASK 0xffff
|
---|
[ffcc5776] | 188 | /** Power control mask */
|
---|
[bfc5c9dd] | 189 | #define RHDB_PCC_MASK (0xffff)
|
---|
| 190 | #define RHDB_PCC_SHIFT 16
|
---|
[0c311d5] | 191 |
|
---|
| 192 | /** Root hub status register */
|
---|
[5d36062] | 193 | ioport32_t rh_status;
|
---|
[ffcc5776] | 194 | /* read: 0,
|
---|
| 195 | * write: 0-no effect,
|
---|
| 196 | * 1-turn off port power for ports
|
---|
| 197 | * specified in PPCM(RHDB), or all ports,
|
---|
| 198 | * if power is set globally */
|
---|
[bfc5c9dd] | 199 | #define RHS_LPS_FLAG (1 << 0)
|
---|
[40c6cdf] | 200 | #define RHS_CLEAR_GLOBAL_POWER RHS_LPS_FLAG /* synonym for the above */
|
---|
[ffcc5776] | 201 | /** Over-current indicator, if per-port: 0 */
|
---|
[bfc5c9dd] | 202 | #define RHS_OCI_FLAG (1 << 1)
|
---|
[ffcc5776] | 203 |
|
---|
| 204 | /* read: 0-connect status change does not wake HC
|
---|
| 205 | * 1-connect status change wakes HC
|
---|
| 206 | * write: 1-set DRWE, 0-no effect */
|
---|
[bfc5c9dd] | 207 | #define RHS_DRWE_FLAG (1 << 15)
|
---|
[0c311d5] | 208 | #define RHS_SET_DRWE RHS_DRWE_FLAG
|
---|
[ffcc5776] | 209 | /* read: 0,
|
---|
| 210 | * write: 0-no effect
|
---|
| 211 | * 1-turn on port power for ports
|
---|
| 212 | * specified in PPCM(RHDB), or all ports,
|
---|
| 213 | * if power is set globally */
|
---|
[bfc5c9dd] | 214 | #define RHS_LPSC_FLAG (1 << 16)
|
---|
[735236a] | 215 | #define RHS_SET_GLOBAL_POWER RHS_LPSC_FLAG /* synonym for the above */
|
---|
[ffcc5776] | 216 | /** Over-current change indicator*/
|
---|
[bfc5c9dd] | 217 | #define RHS_OCIC_FLAG (1 << 17)
|
---|
| 218 | #define RHS_CLEAR_DRWE (1 << 31)
|
---|
[0c311d5] | 219 |
|
---|
| 220 | /** Root hub per port status */
|
---|
[5d36062] | 221 | ioport32_t rh_port_status[];
|
---|
[bfc5c9dd] | 222 | #define RHPS_CCS_FLAG (1 << 0) /* r: current connect status,
|
---|
[ffcc5776] | 223 | * w: 1-clear port enable, 0-N/S*/
|
---|
[0c311d5] | 224 | #define RHPS_CLEAR_PORT_ENABLE RHPS_CCS_FLAG
|
---|
[bfc5c9dd] | 225 | #define RHPS_PES_FLAG (1 << 1) /* r: port enable status
|
---|
[ffcc5776] | 226 | * w: 1-set port enable, 0-N/S */
|
---|
[0c311d5] | 227 | #define RHPS_SET_PORT_ENABLE RHPS_PES_FLAG
|
---|
[bfc5c9dd] | 228 | #define RHPS_PSS_FLAG (1 << 2) /* r: port suspend status
|
---|
[ffcc5776] | 229 | * w: 1-set port suspend, 0-N/S */
|
---|
[0c311d5] | 230 | #define RHPS_SET_PORT_SUSPEND RHPS_PSS_FLAG
|
---|
[bfc5c9dd] | 231 | #define RHPS_POCI_FLAG (1 << 3) /* r: port over-current
|
---|
[ffcc5776] | 232 | * (if reports are per-port
|
---|
| 233 | * w: 1-clear port suspend
|
---|
| 234 | * (start resume if suspened)
|
---|
| 235 | * 0-nothing */
|
---|
[0c311d5] | 236 | #define RHPS_CLEAR_PORT_SUSPEND RHPS_POCI_FLAG
|
---|
[bfc5c9dd] | 237 | #define RHPS_PRS_FLAG (1 << 4) /* r: port reset status
|
---|
[ffcc5776] | 238 | * w: 1-set port reset, 0-N/S */
|
---|
[0c311d5] | 239 | #define RHPS_SET_PORT_RESET RHPS_PRS_FLAG
|
---|
[bfc5c9dd] | 240 | #define RHPS_PPS_FLAG (1 << 8) /* r: port power status
|
---|
[ffcc5776] | 241 | * w: 1-set port power, 0-N/S */
|
---|
[0c311d5] | 242 | #define RHPS_SET_PORT_POWER RHPS_PPS_FLAG
|
---|
[bfc5c9dd] | 243 | #define RHPS_LSDA_FLAG (1 << 9) /* r: low speed device attached
|
---|
[ffcc5776] | 244 | * w: 1-clear port power, 0-N/S*/
|
---|
[0c311d5] | 245 | #define RHPS_CLEAR_PORT_POWER RHPS_LSDA_FLAG
|
---|
[bfc5c9dd] | 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)
|
---|
[e7bc999] | 252 | } __attribute__((packed)) ohci_regs_t;
|
---|
[42dbb26] | 253 | #endif
|
---|
| 254 | /**
|
---|
| 255 | * @}
|
---|
| 256 | */
|
---|