1 /* 2 * Copyright (c) 2020, The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef HAL_HWIO_SPRUCE_H 18 #define HAL_HWIO_SPRUCE_H 19 /* 20 =========================================================================== 21 */ 22 /** 23 @file HALhwio.h 24 25 Public interface include file for accessing the HWIO HAL definitions. 26 27 The HALhwio.h file is the public API interface to the HW I/O (HWIO) 28 register access definitions. 29 */ 30 31 /*========================================================================= 32 Include Files 33 ==========================================================================*/ 34 35 36 /* 37 * Common types. 38 */ 39 #include "HALcomdef.h" 40 41 42 43 /* ----------------------------------------------------------------------- 44 ** Macros 45 ** ----------------------------------------------------------------------- */ 46 47 /** 48 @addtogroup macros 49 @{ 50 */ 51 52 /** 53 * Map a base name to the pointer to access the base. 54 * 55 * This macro maps a base name to the pointer to access the base. 56 * This is generally just used internally. 57 * 58 */ 59 #define HWIO_SPRUCE_BASE_PTR(base) base##_BASE_PTR 60 61 62 /** 63 * Declare a HWIO base pointer. 64 * 65 * This macro will declare a HWIO base pointer data structure. The pointer 66 * will always be declared as a weak symbol so multiple declarations will 67 * resolve correctly to the same data at link-time. 68 */ 69 #ifdef __ARMCC_VERSION 70 #define DECLARE_HWIO_SPRUCE_BASE_PTR(base) __weak uint8 *HWIO_SPRUCE_BASE_PTR(base) 71 #else 72 #define DECLARE_HWIO_SPRUCE_BASE_PTR(base) uint8 *HWIO_SPRUCE_BASE_PTR(base) 73 #endif 74 75 /** 76 @} 77 */ 78 79 80 /** 81 @addtogroup hwio_macros 82 @{ 83 */ 84 85 /** 86 * @name Address Macros 87 * 88 * Macros for getting register addresses. 89 * These macros are used for retrieving the address of a register. 90 * HWIO_SPRUCE_ADDR* will return the directly accessible address (virtual or physical based 91 * on environment), HWIO_SPRUCE_PHYS* will always return the physical address. 92 * The offset from the base region can be retrieved using HWIO_SPRUCE_OFFS*. 93 * The "X" extension is used for explicit addressing where the base address of 94 * the module in question is provided as an argument to the macro. 95 * 96 * @{ 97 */ 98 #define HWIO_SPRUCE_ADDR(hwiosym) __msmhwio_addr(hwiosym) 99 #define HWIO_SPRUCE_ADDRI(hwiosym, index) __msmhwio_addri(hwiosym, index) 100 #define HWIO_SPRUCE_ADDRI2(hwiosym, index1, index2) __msmhwio_addri2(hwiosym, index1, index2) 101 #define HWIO_SPRUCE_ADDRI3(hwiosym, index1, index2, index3) __msmhwio_addri3(hwiosym, index1, index2, index3) 102 103 #define HWIO_SPRUCE_ADDRX(base, hwiosym) __msmhwio_addrx(base, hwiosym) 104 #define HWIO_SPRUCE_ADDRXI(base, hwiosym, index) __msmhwio_addrxi(base, hwiosym, index) 105 #define HWIO_SPRUCE_ADDRXI2(base, hwiosym, index1, index2) __msmhwio_addrxi2(base, hwiosym, index1, index2) 106 #define HWIO_SPRUCE_ADDRXI3(base, hwiosym, index1, index2, index3) __msmhwio_addrxi3(base, hwiosym, index1, index2, index3) 107 108 #define HWIO_SPRUCE_PHYS(hwiosym) __msmhwio_phys(hwiosym) 109 #define HWIO_SPRUCE_PHYSI(hwiosym, index) __msmhwio_physi(hwiosym, index) 110 #define HWIO_SPRUCE_PHYSI2(hwiosym, index1, index2) __msmhwio_physi2(hwiosym, index1, index2) 111 #define HWIO_SPRUCE_PHYSI3(hwiosym, index1, index2, index3) __msmhwio_physi3(hwiosym, index1, index2, index3) 112 113 #define HWIO_SPRUCE_PHYSX(base, hwiosym) __msmhwio_physx(base, hwiosym) 114 #define HWIO_SPRUCE_PHYSXI(base, hwiosym, index) __msmhwio_physxi(base, hwiosym, index) 115 #define HWIO_SPRUCE_PHYSXI2(base, hwiosym, index1, index2) __msmhwio_physxi2(base, hwiosym, index1, index2) 116 #define HWIO_SPRUCE_PHYSXI3(base, hwiosym, index1, index2, index3) __msmhwio_physxi3(base, hwiosym, index1, index2, index3) 117 118 #define HWIO_SPRUCE_OFFS(hwiosym) __msmhwio_offs(hwiosym) 119 #define HWIO_SPRUCE_OFFSI(hwiosym, index) __msmhwio_offsi(hwiosym, index) 120 #define HWIO_SPRUCE_OFFSI2(hwiosym, index1, index2) __msmhwio_offsi2(hwiosym, index1, index2) 121 #define HWIO_SPRUCE_OFFSI3(hwiosym, index1, index2, index3) __msmhwio_offsi3(hwiosym, index1, index2, index3) 122 /** @} */ 123 124 /** 125 * @name Input Macros 126 * 127 * These macros are used for reading from a named hardware register. Register 128 * arrays ("indexed") use the macros with the "I" suffix. The "M" suffix 129 * indicates that the input will be masked with the supplied mask. The HWIO_SPRUCE_INF* 130 * macros take a field name and will do the appropriate masking and shifting 131 * to return just the value of that field. 132 * The "X" extension is used for explicit addressing where the base address of 133 * the module in question is provided as an argument to the macro. 134 * 135 * Generally you want to use either HWIO_SPRUCE_IN or HWIO_SPRUCE_INF (with required indexing). 136 * 137 * @{ 138 */ 139 #define HWIO_SPRUCE_IN(hwiosym) __msmhwio_in(hwiosym) 140 #define HWIO_SPRUCE_INI(hwiosym, index) __msmhwio_ini(hwiosym, index) 141 #define HWIO_SPRUCE_INI2(hwiosym, index1, index2) __msmhwio_ini2(hwiosym, index1, index2) 142 #define HWIO_SPRUCE_INI3(hwiosym, index1, index2, index3) __msmhwio_ini3(hwiosym, index1, index2, index3) 143 144 #define HWIO_SPRUCE_INM(hwiosym, mask) __msmhwio_inm(hwiosym, mask) 145 #define HWIO_SPRUCE_INMI(hwiosym, index, mask) __msmhwio_inmi(hwiosym, index, mask) 146 #define HWIO_SPRUCE_INMI2(hwiosym, index1, index2, mask) __msmhwio_inmi2(hwiosym, index1, index2, mask) 147 #define HWIO_SPRUCE_INMI3(hwiosym, index1, index2, index3, mask) __msmhwio_inmi3(hwiosym, index1, index2, index3, mask) 148 149 #define HWIO_SPRUCE_INF(io, field) (HWIO_SPRUCE_INM(io, HWIO_SPRUCE_FMSK(io, field)) >> HWIO_SPRUCE_SHFT(io, field)) 150 #define HWIO_SPRUCE_INFI(io, index, field) (HWIO_SPRUCE_INMI(io, index, HWIO_SPRUCE_FMSK(io, field)) >> HWIO_SPRUCE_SHFT(io, field)) 151 #define HWIO_SPRUCE_INFI2(io, index1, index2, field) (HWIO_SPRUCE_INMI2(io, index1, index2, HWIO_SPRUCE_FMSK(io, field)) >> HWIO_SPRUCE_SHFT(io, field)) 152 #define HWIO_SPRUCE_INFI3(io, index1, index2, index3, field) (HWIO_SPRUCE_INMI3(io, index1, index2, index3, HWIO_SPRUCE_FMSK(io, field)) >> HWIO_SPRUCE_SHFT(io, field)) 153 154 #define HWIO_SPRUCE_INX(base, hwiosym) __msmhwio_inx(base, hwiosym) 155 #define HWIO_SPRUCE_INXI(base, hwiosym, index) __msmhwio_inxi(base, hwiosym, index) 156 #define HWIO_SPRUCE_INXI2(base, hwiosym, index1, index2) __msmhwio_inxi2(base, hwiosym, index1, index2) 157 #define HWIO_SPRUCE_INXI3(base, hwiosym, index1, index2, index3) __msmhwio_inxi3(base, hwiosym, index1, index2, index3) 158 159 #define HWIO_SPRUCE_INXM(base, hwiosym, mask) __msmhwio_inxm(base, hwiosym, mask) 160 #define HWIO_SPRUCE_INXMI(base, hwiosym, index, mask) __msmhwio_inxmi(base, hwiosym, index, mask) 161 #define HWIO_SPRUCE_INXMI2(base, hwiosym, index1, index2, mask) __msmhwio_inxmi2(base, hwiosym, index1, index2, mask) 162 #define HWIO_SPRUCE_INXMI3(base, hwiosym, index1, index2, index3, mask) __msmhwio_inxmi3(base, hwiosym, index1, index2, index3, mask) 163 164 #define HWIO_SPRUCE_INXF(base, io, field) (HWIO_SPRUCE_INXM(base, io, HWIO_SPRUCE_FMSK(io, field)) >> HWIO_SPRUCE_SHFT(io, field)) 165 #define HWIO_SPRUCE_INXFI(base, io, index, field) (HWIO_SPRUCE_INXMI(base, io, index, HWIO_SPRUCE_FMSK(io, field)) >> HWIO_SPRUCE_SHFT(io, field)) 166 #define HWIO_SPRUCE_INXFI2(base, io, index1, index2, field) (HWIO_SPRUCE_INXMI2(base, io, index1, index2, HWIO_SPRUCE_FMSK(io, field)) >> HWIO_SPRUCE_SHFT(io, field)) 167 #define HWIO_SPRUCE_INXFI3(base, io, index1, index2, index3, field) (HWIO_SPRUCE_INXMI3(base, io, index1, index2, index3, HWIO_SPRUCE_FMSK(io, field)) >> HWIO_SPRUCE_SHFT(io, field)) 168 /** @} */ 169 170 /** 171 * @name Output Macros 172 * 173 * These macros are used for writing to a named hardware register. Register 174 * arrays ("indexed") use the macros with the "I" suffix. The "M" suffix 175 * indicates that the output will be masked with the supplied mask (meaning these 176 * macros do a read first, mask in the supplied data, then write it back). 177 * The "X" extension is used for explicit addressing where the base address of 178 * the module in question is provided as an argument to the macro. 179 * The HWIO_SPRUCE_OUTF* macros take a field name and will do the appropriate masking 180 * and shifting to output just the value of that field. 181 * HWIO_SPRUCE_OUTV* registers take a named value instead of a numeric value and 182 * do the same masking/shifting as HWIO_SPRUCE_OUTF. 183 * 184 * Generally you want to use either HWIO_SPRUCE_OUT or HWIO_SPRUCE_OUTF (with required indexing). 185 * 186 * @{ 187 */ 188 #define HWIO_SPRUCE_OUT(hwiosym, val) __msmhwio_out(hwiosym, val) 189 #define HWIO_SPRUCE_OUTI(hwiosym, index, val) __msmhwio_outi(hwiosym, index, val) 190 #define HWIO_SPRUCE_OUTI2(hwiosym, index1, index2, val) __msmhwio_outi2(hwiosym, index1, index2, val) 191 #define HWIO_SPRUCE_OUTI3(hwiosym, index1, index2, index3, val) __msmhwio_outi3(hwiosym, index1, index2, index3, val) 192 193 #define HWIO_SPRUCE_OUTM(hwiosym, mask, val) __msmhwio_outm(hwiosym, mask, val) 194 #define HWIO_SPRUCE_OUTMI(hwiosym, index, mask, val) __msmhwio_outmi(hwiosym, index, mask, val) 195 #define HWIO_SPRUCE_OUTMI2(hwiosym, index1, index2, mask, val) __msmhwio_outmi2(hwiosym, index1, index2, mask, val) 196 #define HWIO_SPRUCE_OUTMI3(hwiosym, index1, index2, index3, mask, val) __msmhwio_outmi3(hwiosym, index1, index2, index3, mask, val) 197 198 #define HWIO_SPRUCE_OUTF(io, field, val) HWIO_SPRUCE_OUTM(io, HWIO_SPRUCE_FMSK(io, field), (uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) 199 #define HWIO_SPRUCE_OUTFI(io, index, field, val) HWIO_SPRUCE_OUTMI(io, index, HWIO_SPRUCE_FMSK(io, field), (uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) 200 #define HWIO_SPRUCE_OUTFI2(io, index1, index2, field, val) HWIO_SPRUCE_OUTMI2(io, index1, index2, HWIO_SPRUCE_FMSK(io, field), (uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) 201 #define HWIO_SPRUCE_OUTFI3(io, index1, index2, index3, field, val) HWIO_SPRUCE_OUTMI3(io, index1, index2, index3, HWIO_SPRUCE_FMSK(io, field), (uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) 202 203 #define HWIO_SPRUCE_OUTV(io, field, val) HWIO_SPRUCE_OUTM(io, HWIO_SPRUCE_FMSK(io, field), (uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) 204 #define HWIO_SPRUCE_OUTVI(io, index, field, val) HWIO_SPRUCE_OUTMI(io, index, HWIO_SPRUCE_FMSK(io, field), (uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) 205 #define HWIO_SPRUCE_OUTVI2(io, index1, index2, field, val) HWIO_SPRUCE_OUTMI2(io, index1, index2, HWIO_SPRUCE_FMSK(io, field), (uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) 206 #define HWIO_SPRUCE_OUTVI3(io, index1, index2, index3, field, val) HWIO_SPRUCE_OUTMI3(io, index1, index2, index3, HWIO_SPRUCE_FMSK(io, field), (uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) 207 208 #define HWIO_SPRUCE_OUTX(base, hwiosym, val) __msmhwio_outx(base, hwiosym, val) 209 #define HWIO_SPRUCE_OUTXI(base, hwiosym, index, val) __msmhwio_outxi(base, hwiosym, index, val) 210 #define HWIO_SPRUCE_OUTXI2(base, hwiosym, index1, index2, val) __msmhwio_outxi2(base, hwiosym, index1, index2, val) 211 #define HWIO_SPRUCE_OUTXI3(base, hwiosym, index1, index2, index3, val) __msmhwio_outxi3(base, hwiosym, index1, index2, index3, val) 212 213 #define HWIO_SPRUCE_OUTXM(base, hwiosym, mask, val) __msmhwio_outxm(base, hwiosym, mask, val) 214 #define HWIO_SPRUCE_OUTXM2(base, hwiosym, mask1, mask2, val1, val2) __msmhwio_outxm2(base, hwiosym, mask1, mask2, val1, val2) 215 #define HWIO_SPRUCE_OUTXM3(base, hwiosym, mask1, mask2, mask3, val1, val2, val3) __msmhwio_outxm3(base, hwiosym, mask1, mask2, mask3, val1, val2, val3) 216 #define HWIO_SPRUCE_OUTXM4(base, hwiosym, mask1, mask2, mask3, mask4, val1, val2, val3, val4) __msmhwio_outxm4(base, hwiosym, mask1, mask2, mask3, mask4, val1, val2, val3, val4) 217 #define HWIO_SPRUCE_OUTXMI(base, hwiosym, index, mask, val) __msmhwio_outxmi(base, hwiosym, index, mask, val) 218 #define HWIO_SPRUCE_OUTXMI2(base, hwiosym, index1, index2, mask, val) __msmhwio_outxmi2(base, hwiosym, index1, index2, mask, val) 219 #define HWIO_SPRUCE_OUTXMI3(base, hwiosym, index1, index2, index3, mask, val) __msmhwio_outxmi3(base, hwiosym, index1, index2, index3, mask, val) 220 221 #define HWIO_SPRUCE_OUTXF(base, io, field, val) HWIO_SPRUCE_OUTXM(base, io, HWIO_SPRUCE_FMSK(io, field), (uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) 222 #define HWIO_SPRUCE_OUTX2F(base, io, field1, field2, val1, val2) HWIO_SPRUCE_OUTXM2(base, io, HWIO_SPRUCE_FMSK(io, field1), HWIO_SPRUCE_FMSK(io, field2), (uint32)(val1) << HWIO_SPRUCE_SHFT(io, field1), (uint32)(val2) << HWIO_SPRUCE_SHFT(io, field2)) 223 #define HWIO_SPRUCE_OUTX3F(base, io, field1, field2, field3, val1, val2, val3) HWIO_SPRUCE_OUTXM3(base, io, HWIO_SPRUCE_FMSK(io, field1), HWIO_SPRUCE_FMSK(io, field2), HWIO_SPRUCE_FMSK(io, field3),(uint32)(val1) << HWIO_SPRUCE_SHFT(io, field1), (uint32)(val2) << HWIO_SPRUCE_SHFT(io, field2), (uint32)(val3) << HWIO_SPRUCE_SHFT(io, field3) ) 224 #define HWIO_SPRUCE_OUTX4F(base, io, field1, field2, field3, field4, val1, val2, val3, val4) HWIO_SPRUCE_OUTXM4(base, io, HWIO_SPRUCE_FMSK(io, field1), HWIO_SPRUCE_FMSK(io, field2), HWIO_SPRUCE_FMSK(io, field3), HWIO_SPRUCE_FMSK(io, field4), (uint32)(val1) << HWIO_SPRUCE_SHFT(io, field1) , (uint32)(val2) << HWIO_SPRUCE_SHFT(io, field2), (uint32)(val3) << HWIO_SPRUCE_SHFT(io, field3), (uint32)(val4) << HWIO_SPRUCE_SHFT(io, field4) ) 225 226 #define HWIO_SPRUCE_OUTXFI(base, io, index, field, val) HWIO_SPRUCE_OUTXMI(base, io, index, HWIO_SPRUCE_FMSK(io, field), (uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) 227 #define HWIO_SPRUCE_OUTXFI2(base, io, index1, index2, field, val) HWIO_SPRUCE_OUTXMI2(base, io, index1, index2, HWIO_SPRUCE_FMSK(io, field), (uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) 228 #define HWIO_SPRUCE_OUTXFI3(base, io, index1, index2, index3, field, val) HWIO_SPRUCE_OUTXMI3(base, io, index1, index2, index3, HWIO_SPRUCE_FMSK(io, field), (uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) 229 230 #define HWIO_SPRUCE_OUTXV(base, io, field, val) HWIO_SPRUCE_OUTXM(base, io, HWIO_SPRUCE_FMSK(io, field), (uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) 231 #define HWIO_SPRUCE_OUTXVI(base, io, index, field, val) HWIO_SPRUCE_OUTXMI(base, io, index, HWIO_SPRUCE_FMSK(io, field), (uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) 232 #define HWIO_SPRUCE_OUTXVI2(base, io, index1, index2, field, val) HWIO_SPRUCE_OUTXMI2(base, io, index1, index2, HWIO_SPRUCE_FMSK(io, field), (uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) 233 #define HWIO_SPRUCE_OUTXVI3(base, io, index1, index2, index3, field, val) HWIO_SPRUCE_OUTXMI3(base, io, index1, index2, index3, HWIO_SPRUCE_FMSK(io, field), (uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) 234 /** @} */ 235 236 /** 237 * @name Shift and Mask Macros 238 * 239 * Macros for getting shift and mask values for fields and registers. 240 * HWIO_SPRUCE_RMSK: The mask value for accessing an entire register. For example: 241 * @code 242 * HWIO_SPRUCE_RMSK(REG) -> 0xFFFFFFFF 243 * @endcode 244 * HWIO_SPRUCE_RSHFT: The right-shift value for an entire register (rarely necessary).\n 245 * HWIO_SPRUCE_SHFT: The right-shift value for accessing a field in a register. For example: 246 * @code 247 * HWIO_SPRUCE_SHFT(REG, FLD) -> 8 248 * @endcode 249 * HWIO_SPRUCE_FMSK: The mask value for accessing a field in a register. For example: 250 * @code 251 * HWIO_SPRUCE_FMSK(REG, FLD) -> 0xFF00 252 * @endcode 253 * HWIO_SPRUCE_VAL: The value for a field in a register. For example: 254 * @code 255 * HWIO_SPRUCE_VAL(REG, FLD, ON) -> 0x1 256 * @endcode 257 * HWIO_SPRUCE_FVAL: This macro takes a numerical value and will shift and mask it into 258 * the given field position. For example: 259 * @code 260 * HWIO_SPRUCE_FVAL(REG, FLD, 0x1) -> 0x100 261 * @endcode 262 * HWIO_SPRUCE_FVALV: This macro takes a logical (named) value and will shift and mask it 263 * into the given field position. For example: 264 * @code 265 * HWIO_SPRUCE_FVALV(REG, FLD, ON) -> 0x100 266 * @endcode 267 * 268 * @{ 269 */ 270 #define HWIO_SPRUCE_RMSK(hwiosym) __msmhwio_rmsk(hwiosym) 271 #define HWIO_SPRUCE_RMSKI(hwiosym, index) __msmhwio_rmski(hwiosym, index) 272 #define HWIO_SPRUCE_RSHFT(hwiosym) __msmhwio_rshft(hwiosym) 273 #define HWIO_SPRUCE_SHFT(hwio_regsym, hwio_fldsym) __msmhwio_shft(hwio_regsym, hwio_fldsym) 274 #define HWIO_SPRUCE_FMSK(hwio_regsym, hwio_fldsym) __msmhwio_fmsk(hwio_regsym, hwio_fldsym) 275 #define HWIO_SPRUCE_VAL(io, field, val) __msmhwio_val(io, field, val) 276 #define HWIO_SPRUCE_FVAL(io, field, val) (((uint32)(val) << HWIO_SPRUCE_SHFT(io, field)) & HWIO_SPRUCE_FMSK(io, field)) 277 #define HWIO_SPRUCE_FVALV(io, field, val) (((uint32)(HWIO_SPRUCE_VAL(io, field, val)) << HWIO_SPRUCE_SHFT(io, field)) & HWIO_SPRUCE_FMSK(io, field)) 278 /** @} */ 279 280 /** 281 * @name Shadow Register Macros 282 * 283 * These macros are used for directly reading the value stored in a 284 * shadow register. 285 * Shadow registers are defined for write-only registers. Generally these 286 * macros should not be necessary as HWIO_SPRUCE_OUTM* macros will automatically use 287 * the shadow values internally. 288 * 289 * @{ 290 */ 291 #define HWIO_SPRUCE_SHDW(hwiosym) __msmhwio_shdw(hwiosym) 292 #define HWIO_SPRUCE_SHDWI(hwiosym, index) __msmhwio_shdwi(hwiosym, index) 293 /** @} */ 294 295 /** 296 @} 297 */ /* end_group */ 298 299 300 /** @cond */ 301 302 /* 303 * Map to final symbols. This remapping is done to allow register 304 * redefinitions. If we just define HWIO_SPRUCE_IN(xreg) as HWIO_SPRUCE_##xreg##_IN 305 * then remappings like "#define xreg xregnew" do not work as expected. 306 */ 307 #define __msmhwio_in(hwiosym) HWIO_SPRUCE_##hwiosym##_IN 308 #define __msmhwio_ini(hwiosym, index) HWIO_SPRUCE_##hwiosym##_INI(index) 309 #define __msmhwio_ini2(hwiosym, index1, index2) HWIO_SPRUCE_##hwiosym##_INI2(index1, index2) 310 #define __msmhwio_ini3(hwiosym, index1, index2, index3) HWIO_SPRUCE_##hwiosym##_INI3(index1, index2, index3) 311 #define __msmhwio_inm(hwiosym, mask) HWIO_SPRUCE_##hwiosym##_INM(mask) 312 #define __msmhwio_inmi(hwiosym, index, mask) HWIO_SPRUCE_##hwiosym##_INMI(index, mask) 313 #define __msmhwio_inmi2(hwiosym, index1, index2, mask) HWIO_SPRUCE_##hwiosym##_INMI2(index1, index2, mask) 314 #define __msmhwio_inmi3(hwiosym, index1, index2, index3, mask) HWIO_SPRUCE_##hwiosym##_INMI3(index1, index2, index3, mask) 315 #define __msmhwio_out(hwiosym, val) HWIO_SPRUCE_##hwiosym##_OUT(val) 316 #define __msmhwio_outi(hwiosym, index, val) HWIO_SPRUCE_##hwiosym##_OUTI(index,val) 317 #define __msmhwio_outi2(hwiosym, index1, index2, val) HWIO_SPRUCE_##hwiosym##_OUTI2(index1, index2, val) 318 #define __msmhwio_outi3(hwiosym, index1, index2, index3, val) HWIO_SPRUCE_##hwiosym##_OUTI2(index1, index2, index3, val) 319 #define __msmhwio_outm(hwiosym, mask, val) HWIO_SPRUCE_##hwiosym##_OUTM(mask, val) 320 #define __msmhwio_outmi(hwiosym, index, mask, val) HWIO_SPRUCE_##hwiosym##_OUTMI(index, mask, val) 321 #define __msmhwio_outmi2(hwiosym, idx1, idx2, mask, val) HWIO_SPRUCE_##hwiosym##_OUTMI2(idx1, idx2, mask, val) 322 #define __msmhwio_outmi3(hwiosym, idx1, idx2, idx3, mask, val) HWIO_SPRUCE_##hwiosym##_OUTMI3(idx1, idx2, idx3, mask, val) 323 #define __msmhwio_addr(hwiosym) HWIO_SPRUCE_##hwiosym##_ADDR 324 #define __msmhwio_addri(hwiosym, index) HWIO_SPRUCE_##hwiosym##_ADDR(index) 325 #define __msmhwio_addri2(hwiosym, idx1, idx2) HWIO_SPRUCE_##hwiosym##_ADDR(idx1, idx2) 326 #define __msmhwio_addri3(hwiosym, idx1, idx2, idx3) HWIO_SPRUCE_##hwiosym##_ADDR(idx1, idx2, idx3) 327 #define __msmhwio_phys(hwiosym) HWIO_SPRUCE_##hwiosym##_PHYS 328 #define __msmhwio_physi(hwiosym, index) HWIO_SPRUCE_##hwiosym##_PHYS(index) 329 #define __msmhwio_physi2(hwiosym, idx1, idx2) HWIO_SPRUCE_##hwiosym##_PHYS(idx1, idx2) 330 #define __msmhwio_physi3(hwiosym, idx1, idx2, idx3) HWIO_SPRUCE_##hwiosym##_PHYS(idx1, idx2, idx3) 331 #define __msmhwio_offs(hwiosym) HWIO_SPRUCE_##hwiosym##_OFFS 332 #define __msmhwio_offsi(hwiosym, index) HWIO_SPRUCE_##hwiosym##_OFFS(index) 333 #define __msmhwio_offsi2(hwiosym, idx1, idx2) HWIO_SPRUCE_##hwiosym##_OFFS(idx1, idx2) 334 #define __msmhwio_offsi3(hwiosym, idx1, idx2, idx3) HWIO_SPRUCE_##hwiosym##_OFFS(idx1, idx2, idx3) 335 #define __msmhwio_rmsk(hwiosym) HWIO_SPRUCE_##hwiosym##_RMSK 336 #define __msmhwio_rmski(hwiosym, index) HWIO_SPRUCE_##hwiosym##_RMSK(index) 337 #define __msmhwio_fmsk(hwiosym, hwiofldsym) HWIO_SPRUCE_##hwiosym##_##hwiofldsym##_BMSK 338 #define __msmhwio_rshft(hwiosym) HWIO_SPRUCE_##hwiosym##_SHFT 339 #define __msmhwio_shft(hwiosym, hwiofldsym) HWIO_SPRUCE_##hwiosym##_##hwiofldsym##_SHFT 340 #define __msmhwio_shdw(hwiosym) HWIO_SPRUCE_##hwiosym##_shadow 341 #define __msmhwio_shdwi(hwiosym, index) HWIO_SPRUCE_##hwiosym##_SHDW(index) 342 #define __msmhwio_val(hwiosym, hwiofld, hwioval) HWIO_SPRUCE_##hwiosym##_##hwiofld##_##hwioval##_FVAL 343 344 #define __msmhwio_inx(base, hwiosym) HWIO_SPRUCE_##hwiosym##_IN(base) 345 #define __msmhwio_inxi(base, hwiosym, index) HWIO_SPRUCE_##hwiosym##_INI(base, index) 346 #define __msmhwio_inxi2(base, hwiosym, index1, index2) HWIO_SPRUCE_##hwiosym##_INI2(base, index1, index2) 347 #define __msmhwio_inxi3(base, hwiosym, index1, index2, index3) HWIO_SPRUCE_##hwiosym##_INI3(base, index1, index2, index3) 348 #define __msmhwio_inxm(base, hwiosym, mask) HWIO_SPRUCE_##hwiosym##_INM(base, mask) 349 #define __msmhwio_inxmi(base, hwiosym, index, mask) HWIO_SPRUCE_##hwiosym##_INMI(base, index, mask) 350 #define __msmhwio_inxmi2(base, hwiosym, index1, index2, mask) HWIO_SPRUCE_##hwiosym##_INMI2(base, index1, index2, mask) 351 #define __msmhwio_inxmi3(base, hwiosym, index1, index2, index3, mask) HWIO_SPRUCE_##hwiosym##_INMI3(base, index1, index2, index3, mask) 352 #define __msmhwio_outx(base, hwiosym, val) HWIO_SPRUCE_##hwiosym##_OUT(base, val) 353 #define __msmhwio_outxi(base, hwiosym, index, val) HWIO_SPRUCE_##hwiosym##_OUTI(base, index,val) 354 #define __msmhwio_outxi2(base, hwiosym, index1, index2, val) HWIO_SPRUCE_##hwiosym##_OUTI2(base, index1, index2, val) 355 #define __msmhwio_outxi3(base, hwiosym, index1, index2, index3, val) HWIO_SPRUCE_##hwiosym##_OUTI2(base, index1, index2, index3, val) 356 #define __msmhwio_outxm(base, hwiosym, mask, val) HWIO_SPRUCE_##hwiosym##_OUTM(base, mask, val) 357 #define __msmhwio_outxm2(base, hwiosym, mask1, mask2, val1, val2) { \ 358 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask1, val1); \ 359 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask2, val2); \ 360 } 361 #define __msmhwio_outxm3(base, hwiosym, mask1, mask2, mask3, val1, val2, val3) { \ 362 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask1, val1); \ 363 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask2, val2); \ 364 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask3, val3); \ 365 } 366 #define __msmhwio_outxm4(base, hwiosym, mask1, mask2, mask3, mask4, val1, val2, val3, val4) { \ 367 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask1, val1); \ 368 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask2, val2); \ 369 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask3, val3); \ 370 HWIO_SPRUCE_##hwiosym##_OUTM(base, mask4, val4); \ 371 } 372 373 374 #define __msmhwio_outxmi(base, hwiosym, index, mask, val) HWIO_SPRUCE_##hwiosym##_OUTMI(base, index, mask, val) 375 #define __msmhwio_outxmi2(base, hwiosym, idx1, idx2, mask, val) HWIO_SPRUCE_##hwiosym##_OUTMI2(base, idx1, idx2, mask, val) 376 #define __msmhwio_outxmi3(base, hwiosym, idx1, idx2, idx3, mask, val) HWIO_SPRUCE_##hwiosym##_OUTMI3(base, idx1, idx2, idx3, mask, val) 377 #define __msmhwio_addrx(base, hwiosym) HWIO_SPRUCE_##hwiosym##_ADDR(base) 378 #define __msmhwio_addrxi(base, hwiosym, index) HWIO_SPRUCE_##hwiosym##_ADDR(base, index) 379 #define __msmhwio_addrxi2(base, hwiosym, idx1, idx2) HWIO_SPRUCE_##hwiosym##_ADDR(base, idx1, idx2) 380 #define __msmhwio_addrxi3(base, hwiosym, idx1, idx2, idx3) HWIO_SPRUCE_##hwiosym##_ADDR(base, idx1, idx2, idx3) 381 #define __msmhwio_physx(base, hwiosym) HWIO_SPRUCE_##hwiosym##_PHYS(base) 382 #define __msmhwio_physxi(base, hwiosym, index) HWIO_SPRUCE_##hwiosym##_PHYS(base, index) 383 #define __msmhwio_physxi2(base, hwiosym, idx1, idx2) HWIO_SPRUCE_##hwiosym##_PHYS(base, idx1, idx2) 384 #define __msmhwio_physxi3(base, hwiosym, idx1, idx2, idx3) HWIO_SPRUCE_##hwiosym##_PHYS(base, idx1, idx2, idx3) 385 386 387 /* 388 * HWIO_INTLOCK 389 * 390 * Macro used by autogenerated code for mutual exclusion around 391 * read-mask-write operations. This is not supported in HAL 392 * code but can be overridden by non-HAL code. 393 */ 394 #define HWIO_INTLOCK() 395 #define HWIO_INTFREE() 396 397 398 /* 399 * Input/output port macros for memory mapped IO. 400 */ 401 #define __inp(port) (*((volatile uint8 *) (port))) 402 #define __inpw(port) (*((volatile uint16 *) (port))) 403 #define __inpdw(port) (*((volatile uint32 *) (port))) 404 #define __outp(port, val) (*((volatile uint8 *) (port)) = ((uint8) (val))) 405 #define __outpw(port, val) (*((volatile uint16 *) (port)) = ((uint16) (val))) 406 #define __outpdw(port, val) (*((volatile uint32 *) (port)) = ((uint32) (val))) 407 408 409 #ifdef HAL_HWIO_SPRUCE_EXTERNAL 410 411 /* 412 * Replace macros with externally supplied functions. 413 */ 414 #undef __inp 415 #undef __inpw 416 #undef __inpdw 417 #undef __outp 418 #undef __outpw 419 #undef __outpdw 420 421 #define __inp(port) __inp_extern(port) 422 #define __inpw(port) __inpw_extern(port) 423 #define __inpdw(port) __inpdw_extern(port) 424 #define __outp(port, val) __outp_extern(port, val) 425 #define __outpw(port, val) __outpw_extern(port, val) 426 #define __outpdw(port, val) __outpdw_extern(port, val) 427 428 extern uint8 __inp_extern ( uint32 nAddr ); 429 extern uint16 __inpw_extern ( uint32 nAddr ); 430 extern uint32 __inpdw_extern ( uint32 nAddr ); 431 extern void __outp_extern ( uint32 nAddr, uint8 nData ); 432 extern void __outpw_extern ( uint32 nAddr, uint16 nData ); 433 extern void __outpdw_extern ( uint32 nAddr, uint32 nData ); 434 435 #endif /* HAL_HWIO_SPRUCE_EXTERNAL */ 436 437 438 /* 439 * Base 8-bit byte accessing macros. 440 */ 441 #define in_byte(addr) (__inp(addr)) 442 #define in_byte_masked(addr, mask) (__inp(addr) & (mask)) 443 #define out_byte(addr, val) __outp(addr,val) 444 #define out_byte_masked(io, mask, val, shadow) \ 445 HWIO_INTLOCK(); \ 446 out_byte( io, shadow); \ 447 shadow = (shadow & (uint16)(~(mask))) | ((uint16)((val) & (mask))); \ 448 HWIO_INTFREE() 449 #define out_byte_masked_ns(io, mask, val, current_reg_content) \ 450 out_byte( io, ((current_reg_content & (uint16)(~(mask))) | \ 451 ((uint16)((val) & (mask)))) ) 452 453 454 /* 455 * Base 16-bit word accessing macros. 456 */ 457 #define in_word(addr) (__inpw(addr)) 458 #define in_word_masked(addr, mask) (__inpw(addr) & (mask)) 459 #define out_word(addr, val) __outpw(addr,val) 460 #define out_word_masked(io, mask, val, shadow) \ 461 HWIO_INTLOCK( ); \ 462 shadow = (shadow & (uint16)(~(mask))) | ((uint16)((val) & (mask))); \ 463 out_word( io, shadow); \ 464 HWIO_INTFREE( ) 465 #define out_word_masked_ns(io, mask, val, current_reg_content) \ 466 out_word( io, ((current_reg_content & (uint16)(~(mask))) | \ 467 ((uint16)((val) & (mask)))) ) 468 469 470 /* 471 * Base 32-bit double-word accessing macros. 472 */ 473 #define in_dword(addr) (__inpdw(addr)) 474 #define in_dword_masked(addr, mask) (__inpdw(addr) & (mask)) 475 #define out_dword(addr, val) __outpdw(addr,val) 476 #define out_dword_masked(io, mask, val, shadow) \ 477 HWIO_INTLOCK(); \ 478 shadow = (shadow & (uint32)(~(mask))) | ((uint32)((val) & (mask))); \ 479 out_dword( io, shadow); \ 480 HWIO_INTFREE() 481 #define out_dword_masked_ns(io, mask, val, current_reg_content) \ 482 out_dword( io, ((current_reg_content & (uint32)(~(mask))) | \ 483 ((uint32)((val) & (mask)))) ) 484 485 /** @endcond */ 486 487 #endif /* HAL_HWIO_SPRUCE_H */ 488 489