HALhwio.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. /*
  2. * Copyright (c) 2019, 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. #ifndef HAL_HWIO_H
  17. #define HAL_HWIO_H
  18. /*===========================================================================
  19. *
  20. * HWIO REGISTER INPUT/OUTPUT HEADER FILE
  21. *
  22. * DESCRIPTION
  23. * This interface is a replacement for that represented by
  24. * msm<ASIC>reg.h, msm<ASIC>io.h and msm<ASIC>redefs.h. For further background
  25. * and documentation on this interface, please see word docs and ppt docs at
  26. *
  27. * This file, together with msmhwioreg.h, provides a portable interface
  28. * from the perspective of chip address file coupling to DMSS register
  29. * I/O software. The interface defined by msmhwio.h and msmhwioreg.h
  30. * encapsulates register name, size, type and access method.
  31. *
  32. * msmhwioreg.h is an auto-generated file that may be subsequently edited
  33. * by hand to handle arbitrary register and bit field name changes, and
  34. * register type and size changes. When hand editing, one does not directly
  35. * hand edit msmhwioreg.h or msm<ASIC>reg.h except to cut/paste registers
  36. * or bitmasks from msm<ASIC>reg.h to msm<ASIC>reg_port.h or from msmhwioreg.h
  37. * to msmhwioreg_port.h. One edits an msmreg.pl input file, possibly named
  38. * something like msmreg_port.dat, to add patterns which msmreg.pl matches
  39. * during chip address file parsing. If a pattern from input the port.dat input
  40. * file is matched, that register or bitmask is not ouput to the register
  41. * header files, but is output to the *_port.h versions of the register header
  42. * files. This mechanism allows hand edit of register header file without loss
  43. * of hand edits on each successive re-parse of chip address file. See msmreg.pl
  44. * header comments for more information.
  45. *
  46. * msmhwioreg.h also handles register access method changes by allowing users
  47. * to change a registers I/O functions on a per register basis. By default,
  48. * when auto-generated, all register I/O functions are selected from the
  49. * inline functions listed below.
  50. *
  51. * (Note that currently inline functions are not used. This is because
  52. * rex_int_lock/rex_int_free are not inline and there the masked IO functions
  53. * would not inline since the compiler will not inline a function that calls
  54. * a function. The task of figuring out how to inline rex_int_lock has been
  55. * deferred. So, for the time being, the functions described below are
  56. * implemented as #define marcos.)
  57. *
  58. * To customize register I/O for a single register, one follows the porting
  59. * mechanism mentioned above and changes the input/output function for the
  60. * desired register.
  61. *
  62. * Direct, un-encapsulated, use of register addresses or register header file
  63. * components is discouraged. To that end, the interface described here fully
  64. * encapsulates all the CAF components including register address, bit field mask,
  65. * and bit field shift values in addition to register input and output.
  66. *
  67. * INLINE byte in_byte(dword addr)
  68. * INLINE byte in_byte_masked(dword addr, dword mask)
  69. * INLINE void out_byte(dword addr, byte val)
  70. * INLINE void out_byte_masked(dword io, dword mask, byte val)
  71. *
  72. * INLINE word in_word(dword addr)
  73. * INLINE word in_word_masked(dword addr, dword mask)
  74. * INLINE void out_word(dword addr, word val)
  75. * INLINE void out_word_masked(dword io, dword mask, word val)
  76. *
  77. * INLINE dword in_dword(dword addr)
  78. * INLINE dword in_dword_masked(dword addr, dword mask)
  79. * INLINE void out_dword(dword addr, dword val)
  80. * INLINE void out_dword_masked(dword io, dword mask, dword val)
  81. *
  82. * Initially, then there is a one-to-one correspondance between the inline
  83. * functions above and the macro interface below with the inline functions
  84. * intended as implementation detail of the macro interface. Register access
  85. * method changes of arbitrary complexity are handled by writing the
  86. * appropriate new I/O function and replacing the existing one for the
  87. * register under consideration.
  88. *
  89. * The interface described below takes chip address file (CAF) symbols as input.
  90. * Wherever hwiosym, hsio_regsym, or hwio_fldsym appears below, that is
  91. * a CAF register or bit field name.
  92. *
  93. *
  94. * #define HWIO_IN(hwiosym)
  95. * Perform input on register hwiosym. Replaces MSM_IN, MSM_INH and MSM_INW.
  96. *
  97. * #define HWIO_INM(hwiosym, m)
  98. * Perform masked input on register hwiosym applying mask m.
  99. * Replaces MSM_INM, MSM_INHM, and MSM_INWM.
  100. *
  101. * #define HWIO_INF(hwio_regsym, hwio_fldsym)
  102. * Read the value from the given field in the given register.
  103. *
  104. * #define HWIO_OUT(hwiosym, val)
  105. * Write input val on register hwiosym. Replaces MSM_OUT, MSM_OUTH, and
  106. * MSM_OUTW.
  107. *
  108. * #define HWIO_OUTM(hwiosym, mask, val)
  109. * Write input val on register hwiosym. Input mask is applied to shadow
  110. * memory and val such that only bits in mask are updated on register hwiosym
  111. * and shadow memory. Replaces MSM_OUTM, MSM_OUTHM, and MSM_OUTWM.
  112. *
  113. * #define HWIO_OUTF(hwio_regsym, hwio_fldsym, val)
  114. * Set the given field in the given register to the given value.
  115. *
  116. * #define HWIO_ADDR(hwiosym)
  117. * Get the register address of hwiosym. Replaces the unencapulsated use of
  118. * of numeric literal HEX constants for register address.
  119. *
  120. * #define HWIO_RMSK(hwiosym)
  121. * Get the mask describing valid bits in register hwiosym. Replaces direct,
  122. * unencapsulated use of mask symbol from register header file.
  123. *
  124. * #define HWIO_RSHFT(hwiosym)
  125. * Get the shift value of the least significant bit in register hwiosym.a
  126. * Replaces SHIFT_FROM_MASK.
  127. *
  128. * #define HWIO_FMSK(hwio_regsym, hwio_fldsym)
  129. * Get the bit field mask for bit field hwio_fldsym in register hwio_regsym.
  130. * Replaces the direct, unencapsulated use of bit field masks from register
  131. * header file.
  132. *
  133. * #define HWIO_SHFT(hwio_regsym, hwio_fldsym)
  134. * Get the shift value of the least significant bit of bit field hwio_fldsym
  135. * in register hwio_regsym. Replaces SHIFT_FROM_MASK.
  136. *
  137. *===========================================================================*/
  138. /*===========================================================================
  139. *
  140. * EDIT HISTORY FOR FILE
  141. *
  142. * This section contains comments describing changes made to this file.
  143. * Notice that changes are listed in reverse chronological order.
  144. *
  145. * when who what, where, why
  146. * -------- --- ----------------------------------------------------------
  147. * 02/01/08 gfr Wrap passed in mask with parenthesis.
  148. * 12/06/07 gfr More depreciated MSM macros.
  149. * 11/19/07 gfr Added MSM_R macro.
  150. * 11/19/07 gfr Removed obselete hwio_interrupts_locked_by_user.
  151. * 10/26/07 gfr Fix MSM_SET macro.
  152. * 10/10/07 gfr Added mappings for MSM_R_MASKED and some others.
  153. * 09/21/07 gfr Added mapping for MSM_W_MASKED_i.
  154. * 09/21/07 gfr Merged in changes for WinCE and 7k.
  155. * 04/24/07 gfr Support for HWIO_INTLOCK/INTFREE to remove lint warnings.
  156. * 04/09/07 gfr Cleanup, compile support for HWIO_INTLOCK/HWIO_INTFREE.
  157. * 09/19/06 eav Added HWIO_PHYS, HWIO_PHYSI, HWIO_PHYSI2
  158. * 08/28/06 gfr Added HWIO_RMSKI, HWIO_SHDW, HWIO_SHDWI
  159. * 06/23/06 gfr Added HWIO_INF, HWIO_INFI, HWIO_OUTF and HWIO_OUTFI
  160. * 06/16/05 eav Changed __msmhwio_addri to call HWIO_##hwiosym##_ADDRI
  161. * 10/10/02 aks Map MSM_OUTSH() used by the MSM6200, to the equivalent
  162. * macro in the MSM6300.
  163. * 4/29/02 cr initial revision
  164. *===========================================================================*/
  165. /*===========================================================================
  166. *
  167. * INCLUDE FILES
  168. *
  169. *===========================================================================*/
  170. #ifdef FEATURE_WINCE_OAL
  171. #include <windows.h>
  172. #include <nkintr.h>
  173. #endif
  174. #ifndef _ARM_ASM_
  175. #include "HALcomdef.h"
  176. #endif
  177. /*===========================================================================
  178. *
  179. * EXTERNAL DECLARATIONS
  180. *
  181. *===========================================================================*/
  182. #ifdef __cplusplus
  183. extern "C" {
  184. #endif
  185. #ifndef _ARM_ASM_
  186. extern uint32 rex_int_lock(void);
  187. extern uint32 rex_int_free(void);
  188. uint32 pti_inpdw(uint32 * port);
  189. void pti_outpdw(uint32 * port, uint32 val);
  190. #endif
  191. #ifdef __cplusplus
  192. }
  193. #endif
  194. /* -----------------------------------------------------------------------
  195. ** Macros
  196. ** ----------------------------------------------------------------------- */
  197. /**
  198. @addtogroup macros
  199. @{
  200. */
  201. /**
  202. * Map a base name to the pointer to access the base.
  203. *
  204. * This macro maps a base name to the pointer to access the base.
  205. * This is generally just used internally.
  206. *
  207. */
  208. #define HWIO_BASE_PTR(base) base##_BASE_PTR
  209. /**
  210. * Declare a HWIO base pointer.
  211. *
  212. * This macro will declare a HWIO base pointer data structure. The pointer
  213. * will always be declared as a weak symbol so multiple declarations will
  214. * resolve correctly to the same data at link-time.
  215. */
  216. #ifdef __ARMCC_VERSION
  217. #define DECLARE_HWIO_BASE_PTR(base) __weak uint8 *HWIO_BASE_PTR(base)
  218. #else
  219. #define DECLARE_HWIO_BASE_PTR(base) uint8 *HWIO_BASE_PTR(base)
  220. #endif
  221. /**
  222. @}
  223. */
  224. /**
  225. @addtogroup hwio_macros
  226. @{
  227. */
  228. /**
  229. * @name Address Macros
  230. *
  231. * Macros for getting register addresses.
  232. * These macros are used for retrieving the address of a register.
  233. * HWIO_ADDR* will return the directly accessible address (virtual or physical based
  234. * on environment), HWIO_PHYS* will always return the physical address.
  235. * The offset from the base region can be retrieved using HWIO_OFFS*.
  236. * The "X" extension is used for explicit addressing where the base address of
  237. * the module in question is provided as an argument to the macro.
  238. *
  239. * @{
  240. */
  241. #define HWIO_ADDR(hwiosym) __msmhwio_addr(hwiosym)
  242. #define HWIO_ADDRI(hwiosym, index) __msmhwio_addri(hwiosym, index)
  243. #define HWIO_ADDRI2(hwiosym, index1, index2) __msmhwio_addri2(hwiosym, index1, index2)
  244. #define HWIO_ADDRI3(hwiosym, index1, index2, index3) __msmhwio_addri3(hwiosym, index1, index2, index3)
  245. #define HWIO_ADDRX(base, hwiosym) __msmhwio_addrx(base, hwiosym)
  246. #define HWIO_ADDRXI(base, hwiosym, index) __msmhwio_addrxi(base, hwiosym, index)
  247. #define HWIO_ADDRXI2(base, hwiosym, index1, index2) __msmhwio_addrxi2(base, hwiosym, index1, index2)
  248. #define HWIO_ADDRXI3(base, hwiosym, index1, index2, index3) __msmhwio_addrxi3(base, hwiosym, index1, index2, index3)
  249. #define HWIO_PHYS(hwiosym) __msmhwio_phys(hwiosym)
  250. #define HWIO_PHYSI(hwiosym, index) __msmhwio_physi(hwiosym, index)
  251. #define HWIO_PHYSI2(hwiosym, index1, index2) __msmhwio_physi2(hwiosym, index1, index2)
  252. #define HWIO_PHYSI3(hwiosym, index1, index2, index3) __msmhwio_physi3(hwiosym, index1, index2, index3)
  253. #define HWIO_PHYSX(base, hwiosym) __msmhwio_physx(base, hwiosym)
  254. #define HWIO_PHYSXI(base, hwiosym, index) __msmhwio_physxi(base, hwiosym, index)
  255. #define HWIO_PHYSXI2(base, hwiosym, index1, index2) __msmhwio_physxi2(base, hwiosym, index1, index2)
  256. #define HWIO_PHYSXI3(base, hwiosym, index1, index2, index3) __msmhwio_physxi3(base, hwiosym, index1, index2, index3)
  257. #define HWIO_OFFS(hwiosym) __msmhwio_offs(hwiosym)
  258. #define HWIO_OFFSI(hwiosym, index) __msmhwio_offsi(hwiosym, index)
  259. #define HWIO_OFFSI2(hwiosym, index1, index2) __msmhwio_offsi2(hwiosym, index1, index2)
  260. #define HWIO_OFFSI3(hwiosym, index1, index2, index3) __msmhwio_offsi3(hwiosym, index1, index2, index3)
  261. /** @} */
  262. /*===========================================================================
  263. *
  264. * MACRO DECLARATIONS
  265. *
  266. *===========================================================================*/
  267. #define HWIO_POR(io) HWIO_##io##_POR
  268. /**
  269. * @name Input Macros
  270. *
  271. * These macros are used for reading from a named hardware register. Register
  272. * arrays ("indexed") use the macros with the "I" suffix. The "M" suffix
  273. * indicates that the input will be masked with the supplied mask. The HWIO_INF*
  274. * macros take a field name and will do the appropriate masking and shifting
  275. * to return just the value of that field.
  276. * The "X" extension is used for explicit addressing where the base address of
  277. * the module in question is provided as an argument to the macro.
  278. *
  279. * Generally you want to use either HWIO_IN or HWIO_INF (with required indexing).
  280. *
  281. * @{
  282. */
  283. #define HWIO_IN(hwiosym) __msmhwio_in(hwiosym)
  284. #define HWIO_INI(hwiosym, index) __msmhwio_ini(hwiosym, index)
  285. #define HWIO_INI2(hwiosym, index1, index2) __msmhwio_ini2(hwiosym, index1, index2)
  286. #define HWIO_INI3(hwiosym, index1, index2, index3) __msmhwio_ini3(hwiosym, index1, index2, index3)
  287. #define HWIO_INM(hwiosym, mask) __msmhwio_inm(hwiosym, mask)
  288. #define HWIO_INMI(hwiosym, index, mask) __msmhwio_inmi(hwiosym, index, mask)
  289. #define HWIO_INMI2(hwiosym, index1, index2, mask) __msmhwio_inmi2(hwiosym, index1, index2, mask)
  290. #define HWIO_INMI3(hwiosym, index1, index2, index3, mask) __msmhwio_inmi3(hwiosym, index1, index2, index3, mask)
  291. #define HWIO_INF(io, field) (HWIO_INM(io, HWIO_FMSK(io, field)) >> HWIO_SHFT(io, field))
  292. #define HWIO_INFI(io, index, field) (HWIO_INMI(io, index, HWIO_FMSK(io, field)) >> HWIO_SHFT(io, field))
  293. #define HWIO_INFI2(io, index1, index2, field) (HWIO_INMI2(io, index1, index2, HWIO_FMSK(io, field)) >> HWIO_SHFT(io, field))
  294. #define HWIO_INFI3(io, index1, index2, index3, field) (HWIO_INMI3(io, index1, index2, index3, HWIO_FMSK(io, field)) >> HWIO_SHFT(io, field))
  295. #define HWIO_INX(base, hwiosym) __msmhwio_inx(base, hwiosym)
  296. #define HWIO_INXI(base, hwiosym, index) __msmhwio_inxi(base, hwiosym, index)
  297. #define HWIO_INXI2(base, hwiosym, index1, index2) __msmhwio_inxi2(base, hwiosym, index1, index2)
  298. #define HWIO_INXI3(base, hwiosym, index1, index2, index3) __msmhwio_inxi3(base, hwiosym, index1, index2, index3)
  299. #define HWIO_INXM(base, hwiosym, mask) __msmhwio_inxm(base, hwiosym, mask)
  300. #define HWIO_INXMI(base, hwiosym, index, mask) __msmhwio_inxmi(base, hwiosym, index, mask)
  301. #define HWIO_INXMI2(base, hwiosym, index1, index2, mask) __msmhwio_inxmi2(base, hwiosym, index1, index2, mask)
  302. #define HWIO_INXMI3(base, hwiosym, index1, index2, index3, mask) __msmhwio_inxmi3(base, hwiosym, index1, index2, index3, mask)
  303. #define HWIO_INXF(base, io, field) (HWIO_INXM(base, io, HWIO_FMSK(io, field)) >> HWIO_SHFT(io, field))
  304. #define HWIO_INXFI(base, io, index, field) (HWIO_INXMI(base, io, index, HWIO_FMSK(io, field)) >> HWIO_SHFT(io, field))
  305. #define HWIO_INXFI2(base, io, index1, index2, field) (HWIO_INXMI2(base, io, index1, index2, HWIO_FMSK(io, field)) >> HWIO_SHFT(io, field))
  306. #define HWIO_INXFI3(base, io, index1, index2, index3, field) (HWIO_INXMI3(base, io, index1, index2, index3, HWIO_FMSK(io, field)) >> HWIO_SHFT(io, field))
  307. /** @} */
  308. /**
  309. * @name Output Macros
  310. *
  311. * These macros are used for writing to a named hardware register. Register
  312. * arrays ("indexed") use the macros with the "I" suffix. The "M" suffix
  313. * indicates that the output will be masked with the supplied mask (meaning these
  314. * macros do a read first, mask in the supplied data, then write it back).
  315. * The "X" extension is used for explicit addressing where the base address of
  316. * the module in question is provided as an argument to the macro.
  317. * The HWIO_OUTF* macros take a field name and will do the appropriate masking
  318. * and shifting to output just the value of that field.
  319. * HWIO_OUTV* registers take a named value instead of a numeric value and
  320. * do the same masking/shifting as HWIO_OUTF.
  321. *
  322. * Generally you want to use either HWIO_OUT or HWIO_OUTF (with required indexing).
  323. *
  324. * @{
  325. */
  326. #define HWIO_OUT(hwiosym, val) __msmhwio_out(hwiosym, val)
  327. #define HWIO_OUTI(hwiosym, index, val) __msmhwio_outi(hwiosym, index, val)
  328. #define HWIO_OUTI2(hwiosym, index1, index2, val) __msmhwio_outi2(hwiosym, index1, index2, val)
  329. #define HWIO_OUTI3(hwiosym, index1, index2, index3, val) __msmhwio_outi3(hwiosym, index1, index2, index3, val)
  330. #define HWIO_OUTM(hwiosym, mask, val) __msmhwio_outm(hwiosym, mask, val)
  331. #define HWIO_OUTMI(hwiosym, index, mask, val) __msmhwio_outmi(hwiosym, index, mask, val)
  332. #define HWIO_OUTMI2(hwiosym, index1, index2, mask, val) __msmhwio_outmi2(hwiosym, index1, index2, mask, val)
  333. #define HWIO_OUTMI3(hwiosym, index1, index2, index3, mask, val) __msmhwio_outmi3(hwiosym, index1, index2, index3, mask, val)
  334. #define HWIO_OUTF(io, field, val) HWIO_OUTM(io, HWIO_FMSK(io, field), (uint32)(val) << HWIO_SHFT(io, field))
  335. #define HWIO_OUTFI(io, index, field, val) HWIO_OUTMI(io, index, HWIO_FMSK(io, field), (uint32)(val) << HWIO_SHFT(io, field))
  336. #define HWIO_OUTFI2(io, index1, index2, field, val) HWIO_OUTMI2(io, index1, index2, HWIO_FMSK(io, field), (uint32)(val) << HWIO_SHFT(io, field))
  337. #define HWIO_OUTFI3(io, index1, index2, index3, field, val) HWIO_OUTMI3(io, index1, index2, index3, HWIO_FMSK(io, field), (uint32)(val) << HWIO_SHFT(io, field))
  338. //----------------------------------------------------------------------------------------------
  339. //<DVICP> added for Waverider
  340. #define HWIO_OUTF2(io, field2, field1, val2, val1) HWIO_OUTM(io, (HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  341. ( (val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  342. #define HWIO_OUTF3(io, field3, field2, field1, val3, val2, val1) HWIO_OUTM(io, (HWIO_FMSK(io, field3)|HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  343. ( (val3<<HWIO_SHFT(io, field3))|(val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  344. #define HWIO_OUTF4(io, field4, field3, field2, field1, val4, val3, val2, val1) HWIO_OUTM(io, (HWIO_FMSK(io, field4) |HWIO_FMSK(io, field3)|HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  345. ( (val4<<HWIO_SHFT(io, field4))|(val3<<HWIO_SHFT(io, field3))|(val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  346. #define HWIO_OUTF5(io, field5, field4, field3, field2, field1, val5, val4, val3, val2, val1) HWIO_OUTM(io, (HWIO_FMSK(io, field5)|HWIO_FMSK(io, field4)|HWIO_FMSK(io, field3)|HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  347. ( (val5<<HWIO_SHFT(io, field5))|(val4<<HWIO_SHFT(io, field4))|(val3<<HWIO_SHFT(io, field3))|(val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  348. #define HWIO_OUTF6(io, field6, field5, field4, field3, field2, field1, val6, val5, val4, val3, val2, val1) HWIO_OUTM(io, (HWIO_FMSK(io, field6)|HWIO_FMSK(io, field5)|HWIO_FMSK(io, field4)|HWIO_FMSK(io, field3)|HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  349. ( (val6<<HWIO_SHFT(io, field6))|(val5<<HWIO_SHFT(io, field5))|(val4<<HWIO_SHFT(io, field4))|(val3<<HWIO_SHFT(io, field3))|(val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  350. #define HWIO_OUTF2I(io, idx, field2, field1, val2, val1) HWIO_OUTMI(io, idx, (HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  351. ( (val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  352. #define HWIO_OUTF3I(io, idx, field3, field2, field1, val3, val2, val1) HWIO_OUTMI(io, idx, (HWIO_FMSK(io, field3)|HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  353. ( (val3<<HWIO_SHFT(io, field3))|(val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  354. #define HWIO_OUTF4I(io, idx, field4, field3, field2, field1, val4, val3, val2, val1) HWIO_OUTMI(io, idx, (HWIO_FMSK(io, field4)|HWIO_FMSK(io, field3)|HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  355. ( (val4<<HWIO_SHFT(io, field4))|(val3<<HWIO_SHFT(io, field3))|(val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  356. #define HWIO_OUTF5I(io, idx, field5, field4, field3, field2, field1, val5, val4, val3, val2, val1) HWIO_OUTMI(io, idx, (HWIO_FMSK(io, field5)|HWIO_FMSK(io, field4)|HWIO_FMSK(io, field3)|HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  357. ( (val5<<HWIO_SHFT(io, field5))|(val4<<HWIO_SHFT(io, field4))|(val3<<HWIO_SHFT(io, field3))|(val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  358. #define HWIO_OUTF6I(io, idx, field6, field5, field4, field3, field2, field1, val6, val5, val4, val3, val2, val1) HWIO_OUTMI(io, idx, (HWIO_FMSK(io, field6)|HWIO_FMSK(io, field5)|HWIO_FMSK(io, field4)|HWIO_FMSK(io, field3)|HWIO_FMSK(io, field2)|HWIO_FMSK(io, field1)), \
  359. ( (val6<<HWIO_SHFT(io, field6))|(val5<<HWIO_SHFT(io, field5))|(val4<<HWIO_SHFT(io, field4))|(val3<<HWIO_SHFT(io, field3))|(val2<<HWIO_SHFT(io, field2))|(val1<<HWIO_SHFT(io, field1))) )
  360. // ----------------------------------------------------------------------------------------------
  361. #define HWIO_OUTV(io, field, val) HWIO_OUTM(io, HWIO_FMSK(io, field), (uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field))
  362. #define HWIO_OUTVI(io, index, field, val) HWIO_OUTMI(io, index, HWIO_FMSK(io, field), (uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field))
  363. #define HWIO_OUTVI2(io, index1, index2, field, val) HWIO_OUTMI2(io, index1, index2, HWIO_FMSK(io, field), (uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field))
  364. #define HWIO_OUTVI3(io, index1, index2, index3, field, val) HWIO_OUTMI3(io, index1, index2, index3, HWIO_FMSK(io, field), (uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field))
  365. #define HWIO_OUTX(base, hwiosym, val) __msmhwio_outx(base, hwiosym, val)
  366. #define HWIO_OUTXI(base, hwiosym, index, val) __msmhwio_outxi(base, hwiosym, index, val)
  367. #define HWIO_OUTXI2(base, hwiosym, index1, index2, val) __msmhwio_outxi2(base, hwiosym, index1, index2, val)
  368. #define HWIO_OUTXI3(base, hwiosym, index1, index2, index3, val) __msmhwio_outxi3(base, hwiosym, index1, index2, index3, val)
  369. #define HWIO_OUTXM(base, hwiosym, mask, val) __msmhwio_outxm(base, hwiosym, mask, val)
  370. #define HWIO_OUTXM2(base, hwiosym, mask1, mask2, val1, val2) __msmhwio_outxm2(base, hwiosym, mask1, mask2, val1, val2)
  371. #define HWIO_OUTXM3(base, hwiosym, mask1, mask2, mask3, val1, val2, val3) __msmhwio_outxm3(base, hwiosym, mask1, mask2, mask3, val1, val2, val3)
  372. #define HWIO_OUTXM4(base, hwiosym, mask1, mask2, mask3, mask4, val1, val2, val3, val4) __msmhwio_outxm4(base, hwiosym, mask1, mask2, mask3, mask4, val1, val2, val3, val4)
  373. #define HWIO_OUTXMI(base, hwiosym, index, mask, val) __msmhwio_outxmi(base, hwiosym, index, mask, val)
  374. #define HWIO_OUTXMI2(base, hwiosym, index1, index2, mask, val) __msmhwio_outxmi2(base, hwiosym, index1, index2, mask, val)
  375. #define HWIO_OUTXMI3(base, hwiosym, index1, index2, index3, mask, val) __msmhwio_outxmi3(base, hwiosym, index1, index2, index3, mask, val)
  376. #define HWIO_OUTXF(base, io, field, val) HWIO_OUTXM(base, io, HWIO_FMSK(io, field), (uint32)(val) << HWIO_SHFT(io, field))
  377. #define HWIO_OUTX2F(base, io, field1, field2, val1, val2) HWIO_OUTXM2(base, io, HWIO_FMSK(io, field1), HWIO_FMSK(io, field2), (uint32)(val1) << HWIO_SHFT(io, field1), (uint32)(val2) << HWIO_SHFT(io, field2))
  378. #define HWIO_OUTX3F(base, io, field1, field2, field3, val1, val2, val3) HWIO_OUTXM3(base, io, HWIO_FMSK(io, field1), HWIO_FMSK(io, field2), HWIO_FMSK(io, field3),(uint32)(val1) << HWIO_SHFT(io, field1), (uint32)(val2) << HWIO_SHFT(io, field2), (uint32)(val3) << HWIO_SHFT(io, field3) )
  379. #define HWIO_OUTX4F(base, io, field1, field2, field3, field4, val1, val2, val3, val4) HWIO_OUTXM4(base, io, HWIO_FMSK(io, field1), HWIO_FMSK(io, field2), HWIO_FMSK(io, field3), HWIO_FMSK(io, field4), (uint32)(val1) << HWIO_SHFT(io, field1) , (uint32)(val2) << HWIO_SHFT(io, field2), (uint32)(val3) << HWIO_SHFT(io, field3), (uint32)(val4) << HWIO_SHFT(io, field4) )
  380. #define HWIO_OUTXFI(base, io, index, field, val) HWIO_OUTXMI(base, io, index, HWIO_FMSK(io, field), (uint32)(val) << HWIO_SHFT(io, field))
  381. #define HWIO_OUTXFI2(base, io, index1, index2, field, val) HWIO_OUTXMI2(base, io, index1, index2, HWIO_FMSK(io, field), (uint32)(val) << HWIO_SHFT(io, field))
  382. #define HWIO_OUTXFI3(base, io, index1, index2, index3, field, val) HWIO_OUTXMI3(base, io, index1, index2, index3, HWIO_FMSK(io, field), (uint32)(val) << HWIO_SHFT(io, field))
  383. #define HWIO_OUTXV(base, io, field, val) HWIO_OUTXM(base, io, HWIO_FMSK(io, field), (uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field))
  384. #define HWIO_OUTXVI(base, io, index, field, val) HWIO_OUTXMI(base, io, index, HWIO_FMSK(io, field), (uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field))
  385. #define HWIO_OUTXVI2(base, io, index1, index2, field, val) HWIO_OUTXMI2(base, io, index1, index2, HWIO_FMSK(io, field), (uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field))
  386. #define HWIO_OUTXVI3(base, io, index1, index2, index3, field, val) HWIO_OUTXMI3(base, io, index1, index2, index3, HWIO_FMSK(io, field), (uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field))
  387. /** @} */
  388. /**
  389. * @name Shift and Mask Macros
  390. *
  391. * Macros for getting shift and mask values for fields and registers.
  392. * HWIO_RMSK: The mask value for accessing an entire register. For example:
  393. * @code
  394. * HWIO_RMSK(REG) -> 0xFFFFFFFF
  395. * @endcode
  396. * HWIO_RSHFT: The right-shift value for an entire register (rarely necessary).\n
  397. * HWIO_SHFT: The right-shift value for accessing a field in a register. For example:
  398. * @code
  399. * HWIO_SHFT(REG, FLD) -> 8
  400. * @endcode
  401. * HWIO_FMSK: The mask value for accessing a field in a register. For example:
  402. * @code
  403. * HWIO_FMSK(REG, FLD) -> 0xFF00
  404. * @endcode
  405. * HWIO_VAL: The value for a field in a register. For example:
  406. * @code
  407. * HWIO_VAL(REG, FLD, ON) -> 0x1
  408. * @endcode
  409. * HWIO_FVAL: This macro takes a numerical value and will shift and mask it into
  410. * the given field position. For example:
  411. * @code
  412. * HWIO_FVAL(REG, FLD, 0x1) -> 0x100
  413. * @endcode
  414. * HWIO_FVALV: This macro takes a logical (named) value and will shift and mask it
  415. * into the given field position. For example:
  416. * @code
  417. * HWIO_FVALV(REG, FLD, ON) -> 0x100
  418. * @endcode
  419. *
  420. * @{
  421. */
  422. #define HWIO_RMSK(hwiosym) __msmhwio_rmsk(hwiosym)
  423. #define HWIO_RMSKI(hwiosym, index) __msmhwio_rmski(hwiosym, index)
  424. #define HWIO_RSHFT(hwiosym) __msmhwio_rshft(hwiosym)
  425. #define HWIO_SHFT(hwio_regsym, hwio_fldsym) __msmhwio_shft(hwio_regsym, hwio_fldsym)
  426. #define HWIO_FMSK(hwio_regsym, hwio_fldsym) __msmhwio_fmsk(hwio_regsym, hwio_fldsym)
  427. #define HWIO_VAL(io, field, val) __msmhwio_val(io, field, val)
  428. #define HWIO_FVAL(io, field, val) (((uint32)(val) << HWIO_SHFT(io, field)) & HWIO_FMSK(io, field))
  429. #define HWIO_FVALV(io, field, val) (((uint32)(HWIO_VAL(io, field, val)) << HWIO_SHFT(io, field)) & HWIO_FMSK(io, field))
  430. /** @} */
  431. /**
  432. * @name Shadow Register Macros
  433. *
  434. * These macros are used for directly reading the value stored in a
  435. * shadow register.
  436. * Shadow registers are defined for write-only registers. Generally these
  437. * macros should not be necessary as HWIO_OUTM* macros will automatically use
  438. * the shadow values internally.
  439. *
  440. * @{
  441. */
  442. #define HWIO_SHDW(hwiosym) __msmhwio_shdw(hwiosym)
  443. #define HWIO_SHDWI(hwiosym, index) __msmhwio_shdwi(hwiosym, index)
  444. /** @} */
  445. /**
  446. @}
  447. */ /* end_group */
  448. #define __msmhwio_in(hwiosym) HWIO_##hwiosym##_IN
  449. #define __msmhwio_ini(hwiosym, index) HWIO_##hwiosym##_INI(index)
  450. #define __msmhwio_ini2(hwiosym, index1, index2) HWIO_##hwiosym##_INI2(index1, index2)
  451. #define __msmhwio_ini3(hwiosym, index1, index2, index3) HWIO_##hwiosym##_INI3(index1, index2, index3)
  452. #define __msmhwio_inm(hwiosym, mask) HWIO_##hwiosym##_INM(mask)
  453. #define __msmhwio_inmi(hwiosym, index, mask) HWIO_##hwiosym##_INMI(index, mask)
  454. #define __msmhwio_inmi2(hwiosym, index1, index2, mask) HWIO_##hwiosym##_INMI2(index1, index2, mask)
  455. #define __msmhwio_inmi3(hwiosym, index1, index2, index3, mask) HWIO_##hwiosym##_INMI3(index1, index2, index3, mask)
  456. #define __msmhwio_out(hwiosym, val) HWIO_##hwiosym##_OUT(val)
  457. #define __msmhwio_outi(hwiosym, index, val) HWIO_##hwiosym##_OUTI(index,val)
  458. #define __msmhwio_outi2(hwiosym, index1, index2, val) HWIO_##hwiosym##_OUTI2(index1, index2, val)
  459. #define __msmhwio_outi3(hwiosym, index1, index2, index3, val) HWIO_##hwiosym##_OUTI2(index1, index2, index3, val)
  460. #define __msmhwio_outm(hwiosym, mask, val) HWIO_##hwiosym##_OUTM(mask, val)
  461. #define __msmhwio_outmi(hwiosym, index, mask, val) HWIO_##hwiosym##_OUTMI(index, mask, val)
  462. #define __msmhwio_outmi2(hwiosym, idx1, idx2, mask, val) HWIO_##hwiosym##_OUTMI2(idx1, idx2, mask, val)
  463. #define __msmhwio_outmi3(hwiosym, idx1, idx2, idx3, mask, val) HWIO_##hwiosym##_OUTMI3(idx1, idx2, idx3, mask, val)
  464. #define __msmhwio_addr(hwiosym) HWIO_##hwiosym##_ADDR
  465. #define __msmhwio_addri(hwiosym, index) HWIO_##hwiosym##_ADDR(index)
  466. #define __msmhwio_addri2(hwiosym, idx1, idx2) HWIO_##hwiosym##_ADDR(idx1, idx2)
  467. #define __msmhwio_addri3(hwiosym, idx1, idx2, idx3) HWIO_##hwiosym##_ADDR(idx1, idx2, idx3)
  468. #define __msmhwio_phys(hwiosym) HWIO_##hwiosym##_PHYS
  469. #define __msmhwio_physi(hwiosym, index) HWIO_##hwiosym##_PHYS(index)
  470. #define __msmhwio_physi2(hwiosym, idx1, idx2) HWIO_##hwiosym##_PHYS(idx1, idx2)
  471. #define __msmhwio_physi3(hwiosym, idx1, idx2, idx3) HWIO_##hwiosym##_PHYS(idx1, idx2, idx3)
  472. #define __msmhwio_offs(hwiosym) HWIO_##hwiosym##_OFFS
  473. #define __msmhwio_offsi(hwiosym, index) HWIO_##hwiosym##_OFFS(index)
  474. #define __msmhwio_offsi2(hwiosym, idx1, idx2) HWIO_##hwiosym##_OFFS(idx1, idx2)
  475. #define __msmhwio_offsi3(hwiosym, idx1, idx2, idx3) HWIO_##hwiosym##_OFFS(idx1, idx2, idx3)
  476. #define __msmhwio_rmsk(hwiosym) HWIO_##hwiosym##_RMSK
  477. #define __msmhwio_rmski(hwiosym, index) HWIO_##hwiosym##_RMSK(index)
  478. #define __msmhwio_fmsk(hwiosym, hwiofldsym) HWIO_##hwiosym##_##hwiofldsym##_BMSK
  479. #define __msmhwio_rshft(hwiosym) HWIO_##hwiosym##_SHFT
  480. #define __msmhwio_shft(hwiosym, hwiofldsym) HWIO_##hwiosym##_##hwiofldsym##_SHFT
  481. #define __msmhwio_shdw(hwiosym) HWIO_##hwiosym##_shadow
  482. #define __msmhwio_shdwi(hwiosym, index) HWIO_##hwiosym##_SHDW(index)
  483. #define __msmhwio_val(hwiosym, hwiofld, hwioval) HWIO_##hwiosym##_##hwiofld##_##hwioval##_FVAL
  484. #define __msmhwio_inx(base, hwiosym) HWIO_##hwiosym##_IN(base)
  485. #define __msmhwio_inxi(base, hwiosym, index) HWIO_##hwiosym##_INI(base, index)
  486. #define __msmhwio_inxi2(base, hwiosym, index1, index2) HWIO_##hwiosym##_INI2(base, index1, index2)
  487. #define __msmhwio_inxi3(base, hwiosym, index1, index2, index3) HWIO_##hwiosym##_INI3(base, index1, index2, index3)
  488. #define __msmhwio_inxm(base, hwiosym, mask) HWIO_##hwiosym##_INM(base, mask)
  489. #define __msmhwio_inxmi(base, hwiosym, index, mask) HWIO_##hwiosym##_INMI(base, index, mask)
  490. #define __msmhwio_inxmi2(base, hwiosym, index1, index2, mask) HWIO_##hwiosym##_INMI2(base, index1, index2, mask)
  491. #define __msmhwio_inxmi3(base, hwiosym, index1, index2, index3, mask) HWIO_##hwiosym##_INMI3(base, index1, index2, index3, mask)
  492. #define __msmhwio_outx(base, hwiosym, val) HWIO_##hwiosym##_OUT(base, val)
  493. #define __msmhwio_outxi(base, hwiosym, index, val) HWIO_##hwiosym##_OUTI(base, index,val)
  494. #define __msmhwio_outxi2(base, hwiosym, index1, index2, val) HWIO_##hwiosym##_OUTI2(base, index1, index2, val)
  495. #define __msmhwio_outxi3(base, hwiosym, index1, index2, index3, val) HWIO_##hwiosym##_OUTI3(base, index1, index2, index3, val)
  496. #define __msmhwio_outxm(base, hwiosym, mask, val) HWIO_##hwiosym##_OUTM(base, mask, val)
  497. #define __msmhwio_outxm2(base, hwiosym, mask1, mask2, val1, val2) { \
  498. HWIO_##hwiosym##_OUTM(base, mask1, val1); \
  499. HWIO_##hwiosym##_OUTM(base, mask2, val2); \
  500. }
  501. #define __msmhwio_outxm3(base, hwiosym, mask1, mask2, mask3, val1, val2, val3) { \
  502. HWIO_##hwiosym##_OUTM(base, mask1, val1); \
  503. HWIO_##hwiosym##_OUTM(base, mask2, val2); \
  504. HWIO_##hwiosym##_OUTM(base, mask3, val3); \
  505. }
  506. #define __msmhwio_outxm4(base, hwiosym, mask1, mask2, mask3, mask4, val1, val2, val3, val4) { \
  507. HWIO_##hwiosym##_OUTM(base, mask1, val1); \
  508. HWIO_##hwiosym##_OUTM(base, mask2, val2); \
  509. HWIO_##hwiosym##_OUTM(base, mask3, val3); \
  510. HWIO_##hwiosym##_OUTM(base, mask4, val4); \
  511. }
  512. #define __msmhwio_outxmi(base, hwiosym, index, mask, val) HWIO_##hwiosym##_OUTMI(base, index, mask, val)
  513. #define __msmhwio_outxmi2(base, hwiosym, idx1, idx2, mask, val) HWIO_##hwiosym##_OUTMI2(base, idx1, idx2, mask, val)
  514. #define __msmhwio_outxmi3(base, hwiosym, idx1, idx2, idx3, mask, val) HWIO_##hwiosym##_OUTMI3(base, idx1, idx2, idx3, mask, val)
  515. #define __msmhwio_addrx(base, hwiosym) HWIO_##hwiosym##_ADDR(base)
  516. #define __msmhwio_addrxi(base, hwiosym, index) HWIO_##hwiosym##_ADDR(base, index)
  517. #define __msmhwio_addrxi2(base, hwiosym, idx1, idx2) HWIO_##hwiosym##_ADDR(base, idx1, idx2)
  518. #define __msmhwio_addrxi3(base, hwiosym, idx1, idx2, idx3) HWIO_##hwiosym##_ADDR(base, idx1, idx2, idx3)
  519. #define __msmhwio_physx(base, hwiosym) HWIO_##hwiosym##_PHYS(base)
  520. #define __msmhwio_physxi(base, hwiosym, index) HWIO_##hwiosym##_PHYS(base, index)
  521. #define __msmhwio_physxi2(base, hwiosym, idx1, idx2) HWIO_##hwiosym##_PHYS(base, idx1, idx2)
  522. #define __msmhwio_physxi3(base, hwiosym, idx1, idx2, idx3) HWIO_##hwiosym##_PHYS(base, idx1, idx2, idx3)
  523. /*
  524. * MSM_x (depreciated)
  525. *
  526. * These macros should be replaced with the relevant HWIO equivalent.
  527. */
  528. #define MSM_OUT(io, val) HWIO_OUT(io, val)
  529. #define MSM_IN(io) HWIO_IN(io)
  530. #define MSM_OUTM(io, mask, val) HWIO_OUTM(io, mask, val)
  531. #define MSM_INM(io, mask) HWIO_INM(io, mask)
  532. #define MSM_INF(io, field) HWIO_INF(io, field)
  533. #define MSM_FIELD(field, val) (((val) << field##_SHFT) & (field##_BMSK))
  534. #define MSM_OUTSH(io, mask, val) HWIO_OUTM(io, mask, val)
  535. #define MSM_FOUTSH(io, field, val) HWIO_OUTM(io, mask, val)
  536. #define MSM_SET(io, field) HWIO_OUTM(io, HWIO_FMSK(io, field), HWIO_FMSK(io, field))
  537. #define MSM_SET_BIT(io, bit) HWIO_OUTM(io, (1<<bit), (1<<bit))
  538. #define MSM_SET_i(io, field, index) HWIO_OUTMI(io, index, HWIO_FMSK(io,field), HWIO_FMSK(io,field))
  539. #define MSM_SET_ij(io, field, index1, index2) HWIO_OUTMI2(io, index1, index2, HWIO_FMSK(io,field), HWIO_FMSK(io,field))
  540. #define MSM_CLEAR(io, field) HWIO_OUTM(io, HWIO_FMSK(io, field), 0)
  541. #define MSM_CLEAR_BIT(io, bit) HWIO_OUTM(io, (1<<bit), 0)
  542. #define MSM_CLEAR_i(io, field, n) HWIO_OUTMI(io, n, HWIO_FMSK(io,field), 0)
  543. #define MSM_CLEAR_ij(io, field, m, n) HWIO_OUTMI2(io, m, n, HWIO_FMSK(io,field), 0)
  544. #define MSM_SET_MASK(io, mask) HWIO_OUTM(io, mask, mask)
  545. #define MSM_CLEAR_MASK(io, mask) HWIO_OUTM(io, mask, 0)
  546. #define MSM_PULSE(io, field) HWIO_OUTF(io, field, 1); HWIO_OUTF(io, field, 0)
  547. #define MSM_GET(io, field) HWIO_INF(io, field)
  548. #define MSM_W(io, val) HWIO_OUT(io, val)
  549. #define MSM_W_i(io, val, index) HWIO_OUTI(io, index, val)
  550. #define MSM_W_ij(io, val, index1, index2) HWIO_OUTI2(io, index1, index2, val )
  551. #define MSM_W_MASKED(io, field, val) HWIO_OUTF(io, field, val)
  552. #define MSM_W_MASKED_i(io, field, val, index) HWIO_OUTFI(io, index, field, val)
  553. #define MSM_W_MASKED_ij(io, field, val, index1, index2) HWIO_OUTFI2(io, index1, index2, field, val)
  554. #define MSM_R(io) HWIO_IN(io)
  555. #define MSM_R_MASKED(base, field) HWIO_INF(base, field)
  556. #define MSM_R_MASKED_i(base, field, n) HWIO_INFI(base, n, field)
  557. #define MSM_R_MASKED_ij(base, field, index1, index2) HWIO_INFI2(base, index1, index2, field)
  558. #define MSM_GET_BIT(io, bit) (HWIO_INM(io, (1<<bit) ) >> bit)
  559. #define MSM_NOT_USED( i ) if(i) {}
  560. /*
  561. * MSM_LOCK / MSM_UNLOCK (depreciated)
  562. *
  563. * These macros are intended to be used if a client will be issuing a
  564. * series of HWIO writes to avoid the multiple locking/freeing of interrupts
  565. * that will otherwise occur.
  566. * They should be replaced with HWIO_LOCK / HWIO_UNLOCK
  567. */
  568. #define MSM_LOCK_REQUIRED \
  569. /*lint -save -e548 else expected*/ \
  570. MSM_LOCK_required = MSM_LOCK_required; \
  571. /*lint -restore */
  572. #define MSM_LOCK( ) \
  573. { \
  574. boolean MSM_LOCK_required = TRUE; \
  575. uint32 msm_sav; \
  576. INTLOCK_SAV(msm_sav)
  577. #define MSM_UNLOCK( ) \
  578. MSM_LOCK_REQUIRED \
  579. INTFREE_SAV(msm_sav); \
  580. }
  581. #define MSM_UNLOCK_AND_LOCK( ) \
  582. MSM_LOCK_REQUIRED \
  583. INTFREE_SAV( msm_sav ), \
  584. INTLOCK_SAV( msm_sav )
  585. /*
  586. * INPxx / OUTPxx (depreciated)
  587. *
  588. */
  589. #define INP32(addr) in_dword(addr)
  590. #define INP32M(addr, mask) in_dword_masked(addr,mask)
  591. #define OUTP32(addr, val) out_dword(addr, val)
  592. #define OUTP32M(addr, mask, val) \
  593. HWIO_INTLOCK(); \
  594. out_dword_masked_ns(addr, mask, val, INP32(addr)); \
  595. HWIO_INTFREE()
  596. /*
  597. * HWIO_LOCK / HWIO_UNLOCK
  598. *
  599. * These macros are intended to be used if a client will be issuing a
  600. * series of HWIO writes to avoid the multiple locking/freeing of interrupts
  601. * that will otherwise occur.
  602. */
  603. #define HWIO_LOCK() \
  604. { \
  605. uint16 hwio_sav; \
  606. INTLOCK_SAV(hwio_sav)
  607. #define HWIO_UNLOCK() \
  608. INTFREE_SAV(hwio_sav); \
  609. }
  610. #if defined(FEATURE_WINCE_BOOTLOADER)
  611. #define HWIO_INTLOCK()
  612. #define HWIO_INTFREE()
  613. #elif defined(FEATURE_WINCE_OAL)
  614. #define HWIO_INTLOCK() \
  615. { \
  616. uint32 ints_already_enabled = INTERRUPTS_ENABLE(FALSE)
  617. #define HWIO_INTFREE() \
  618. if (ints_already_enabled) INTERRUPTS_ENABLE(TRUE); \
  619. }
  620. #else
  621. #define HWIO_INTLOCK() \
  622. { \
  623. uint32 intlock_sav; \
  624. INTLOCK_SAV(intlock_sav)
  625. #define HWIO_INTFREE() \
  626. INTFREE_SAV(intlock_sav); \
  627. }
  628. #endif
  629. #if defined (PTI_PRINTF_EN) || defined(PTI_MEMORY_EN) || defined(PTI_STM_EN)
  630. #define __inp(port) (*((volatile uint8 *) (port)))
  631. #define __inpw(port) (*((volatile uint16 *) (port)))
  632. // #define __inpdw(port) (*((volatile uint32 *) (port)))
  633. #define __inpdw(port) pti_inpdw((uint32 *) (port))
  634. #define __outp(port, val) (*((volatile uint8 *) (port)) = ((uint8) (val)))
  635. #define __outpw(port, val) (*((volatile uint16 *) (port)) = ((uint16) (val)))
  636. // #define __outpdw(port, val) (*((volatile uint32 *) (port)) = ((uint32) (val)))
  637. #define __outpdw(port, val) pti_outpdw((uint32 *) (port), (val))
  638. #elif defined(__FWV) || defined(__KERNEL__) || defined(__SHARED_CODE) || defined(QURT_UFW_BUILD) || defined (_WIN)
  639. extern uint32_t registerRead(unsigned long addr);
  640. extern void registerWrite(unsigned long addr, uint32_t value);
  641. #define __inp(port) registerRead(port)
  642. #define __inpw(port) registerRead(port)
  643. #define __inpdw(port) registerRead(port)
  644. #define __outp(port, val) registerWrite(port, val)
  645. #define __outpw(port, val) registerWrite(port, val)
  646. #define __outpdw(port, val) registerWrite(port, val)
  647. #else
  648. #ifdef CDVI_SVTB_VERBOSE
  649. #define __inp(port) ((printf("CDVI_SVTB_VERBOSE: Calling bus_read from %s:%0d\n", __FILE__,__LINE__)&0) + bus_read(port))
  650. #else
  651. #define __inp(port) bus_read(port)
  652. #endif
  653. #define __inpw(port) __inp(port)
  654. #define __inpdw(port) __inp(port)
  655. #ifdef CDVI_SVTB_VERBOSE
  656. #define __outp(port, val) ((printf("CDVI_SVTB_VERBOSE: Calling bus_write from %s:%0d\n",__FILE__,__LINE__)&0) + bus_write (port, val))
  657. #else
  658. #define __outp(port, val) bus_write (port, val)
  659. #endif
  660. #define __outpw(port, val) __outp (port, val)
  661. #define __outpdw(port, val) __outp (port, val)
  662. #endif
  663. #define in_byte(addr) (__inp(addr))
  664. #define in_byte_masked(addr, mask) (__inp(addr) & (mask))
  665. #define out_byte(addr, val) __outp(addr,val)
  666. #define out_byte_masked(io, mask, val, shadow) \
  667. HWIO_INTLOCK(); \
  668. (void) out_byte( io, shadow); \
  669. shadow = (shadow & (uint16)(~(mask))) | ((uint16)((val) & (mask))); \
  670. HWIO_INTFREE()
  671. #define out_byte_masked_ns(io, mask, val, current_reg_content) \
  672. (void) out_byte( io, ((current_reg_content & (uint16)(~(mask))) | \
  673. ((uint16)((val) & (mask)))) )
  674. #define in_word(addr) (__inpw(addr))
  675. #define in_word_masked(addr, mask) (__inpw(addr) & (mask))
  676. #define out_word(addr, val) __outpw(addr,val)
  677. #define out_word_masked(io, mask, val, shadow) \
  678. HWIO_INTLOCK( ); \
  679. shadow = (shadow & (uint16)(~(mask))) | ((uint16)((val) & (mask))); \
  680. (void) out_word( io, shadow); \
  681. HWIO_INTFREE( )
  682. #define out_word_masked_ns(io, mask, val, current_reg_content) \
  683. (void) out_word( io, ((current_reg_content & (uint16)(~(mask))) | \
  684. ((uint16)((val) & (mask)))) )
  685. #define in_dword(addr) (__inpdw(addr))
  686. #define in_dword_masked(addr, mask) (__inpdw(addr) & (mask))
  687. #define out_dword(addr, val) __outpdw(addr,val)
  688. #define out_dword_masked(io, mask, val, shadow) \
  689. HWIO_INTLOCK( ); \
  690. shadow = (shadow & (uint32)(~(mask))) | ((uint32)((val) & (mask))); \
  691. (void) out_dword( io, shadow); \
  692. HWIO_INTFREE( )
  693. #define out_dword_masked_ns(io, mask, val, current_reg_content) \
  694. (void) out_dword( io, ((current_reg_content & (uint32)(~(mask))) | ((uint32)((val) & (mask)))) )
  695. /*
  696. * Base 64-bit quad-word accessing macros.
  697. */
  698. #define in_qword(addr) (__inpqw(addr))
  699. #define in_qword_masked(addr, mask) (__inpqw(addr) & (mask))
  700. #define out_qword(addr, val) __outpqw(addr,val)
  701. #define out_qword_masked(io, mask, val, shadow) \
  702. HWIO_INTLOCK(); \
  703. shadow = (shadow & (uint64)(~(mask))) | ((uint64)((val) & (mask))); \
  704. out_qword( io, shadow); \
  705. HWIO_INTFREE()
  706. #define out_qword_masked_ns(io, mask, val, current_reg_content) \
  707. out_qword( io, ((current_reg_content & (uint64)(~(mask))) | \
  708. ((uint64)((val) & (mask)))) )
  709. #define OUTP64(addr, val) out_qword(addr, val)
  710. #define __outpqw(port, val) (*((volatile uint64 *) (port)) = ((uint64) (val)))
  711. #define INP64(addr) in_qword(addr)
  712. #define __inpqw(port) (*((volatile uint64 *) (port)))
  713. #endif