HALcomdef.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (c) 2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef HAL_COMDEF_H
  19. #define HAL_COMDEF_H
  20. /*
  21. ==============================================================================
  22. FILE: HALcomdef.h
  23. DESCRIPTION:
  24. ==============================================================================
  25. Edit History
  26. $Header: //depot/prj/qca/lithium/HWS/Q5_2p1/include/hwio/qca649x/E3R52/include/HALcomdef.h#1 $
  27. when who what, where, why
  28. -------- --- -----------------------------------------------------------
  29. 06/17/10 sc Included com_dtypes.h and cleaned up typedefs
  30. 05/15/08 gfr Added HAL_ENUM_32BITS macro.
  31. 02/14/08 gfr Added bool32 type.
  32. 11/13/07 gfr Removed dependency on comdef.h
  33. 01/08/07 hxw Created
  34. */
  35. /*
  36. * Assembly wrapper
  37. */
  38. #ifndef _ARM_ASM_
  39. /*
  40. * C++ wrapper
  41. */
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. #include "com_dtypes.h"
  46. /* -----------------------------------------------------------------------
  47. ** Types
  48. ** ----------------------------------------------------------------------- */
  49. /*
  50. * Standard integer types.
  51. *
  52. * bool32 - boolean, 32 bit (TRUE or FALSE)
  53. */
  54. #ifndef _BOOL32_DEFINED
  55. typedef unsigned long int bool32;
  56. #define _BOOL32_DEFINED
  57. #endif
  58. /*
  59. * Macro to allow forcing an enum to 32 bits. The argument should be
  60. * an identifier in the namespace of the enumeration in question, i.e.
  61. * for the clk HAL we might use HAL_ENUM_32BITS(CLK_xxx).
  62. */
  63. #define HAL_ENUM_32BITS(x) HAL_##x##_FORCE32BITS = 0x7FFFFFFF
  64. /*===========================================================================
  65. FUNCTION inp, outp, inpw, outpw, inpdw, outpdw
  66. DESCRIPTION
  67. IN/OUT port macros for byte and word ports, typically inlined by compilers
  68. which support these routines
  69. PARAMETERS
  70. inp( xx_addr )
  71. inpw( xx_addr )
  72. inpdw( xx_addr )
  73. outp( xx_addr, xx_byte_val )
  74. outpw( xx_addr, xx_word_val )
  75. outpdw( xx_addr, xx_dword_val )
  76. xx_addr - Address of port to read or write (may be memory mapped)
  77. xx_byte_val - 8 bit value to write
  78. xx_word_val - 16 bit value to write
  79. xx_dword_val - 32 bit value to write
  80. DEPENDENCIES
  81. None
  82. RETURN VALUE
  83. inp/inpw/inpdw: the byte, word or dword read from the given address
  84. outp/outpw/outpdw: the byte, word or dword written to the given address
  85. SIDE EFFECTS
  86. None.
  87. ===========================================================================*/
  88. /* ARM based targets use memory mapped i/o, so the inp/outp calls are
  89. ** macroized to access memory directly
  90. */
  91. #define inp(port) (*((volatile byte *) (port)))
  92. #define inpw(port) (*((volatile word *) (port)))
  93. #define inpdw(port) (*((volatile dword *)(port)))
  94. #define outp(port, val) (*((volatile byte *) (port)) = ((byte) (val)))
  95. #define outpw(port, val) (*((volatile word *) (port)) = ((word) (val)))
  96. #define outpdw(port, val) (*((volatile dword *) (port)) = ((dword) (val)))
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100. #endif /* !_ARM_ASM_ */
  101. #endif /* HAL_COMDEF_H */