sv_addr_ag.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*!**************************************************************************
  2. *!
  3. *! MACROS:
  4. *! IO_MASK(reg,field)
  5. *! IO_STATE(reg,field,state)
  6. *! IO_EXTRACT(reg,field,val)
  7. *! IO_STATE_VALUE(reg,field,state)
  8. *! IO_BITNR(reg,field)
  9. *! IO_WIDTH(reg,field)
  10. *! IO_FIELD(reg,field,val)
  11. *! IO_RD(reg)
  12. *! All moderegister addresses and fields of these.
  13. *!
  14. *!**************************************************************************/
  15. #ifndef __sv_addr_ag_h__
  16. #define __sv_addr_ag_h__
  17. #define __test_sv_addr__ 0
  18. /*------------------------------------------------------------
  19. !* General macros to manipulate moderegisters.
  20. !*-----------------------------------------------------------*/
  21. /* IO_MASK returns a mask for a specified bitfield in a register.
  22. Note that this macro doesn't work when field width is 32 bits. */
  23. #define IO_MASK(reg, field) IO_MASK_ (reg##_, field##_)
  24. #define IO_MASK_(reg_, field_) \
  25. ( ( ( 1 << reg_##_##field_##_WIDTH ) - 1 ) << reg_##_##field_##_BITNR )
  26. /* IO_STATE returns a constant corresponding to a one of the symbolic
  27. states that the bitfield can have. (Shifted to correct position) */
  28. #define IO_STATE(reg, field, state) IO_STATE_ (reg##_, field##_, _##state)
  29. #define IO_STATE_(reg_, field_, _state) \
  30. ( reg_##_##field_##_state << reg_##_##field_##_BITNR )
  31. /* IO_EXTRACT returns the masked and shifted value corresponding to the
  32. bitfield can have. */
  33. #define IO_EXTRACT(reg, field, val) IO_EXTRACT_ (reg##_, field##_, val)
  34. #define IO_EXTRACT_(reg_, field_, val) ( (( ( ( 1 << reg_##_##field_##_WIDTH ) \
  35. - 1 ) << reg_##_##field_##_BITNR ) & (val)) >> reg_##_##field_##_BITNR )
  36. /* IO_STATE_VALUE returns a constant corresponding to a one of the symbolic
  37. states that the bitfield can have. (Not shifted) */
  38. #define IO_STATE_VALUE(reg, field, state) \
  39. IO_STATE_VALUE_ (reg##_, field##_, _##state)
  40. #define IO_STATE_VALUE_(reg_, field_, _state) ( reg_##_##field_##_state )
  41. /* IO_FIELD shifts the val parameter to be aligned with the bitfield
  42. specified. */
  43. #define IO_FIELD(reg, field, val) IO_FIELD_ (reg##_, field##_, val)
  44. #define IO_FIELD_(reg_, field_, val) ((val) << reg_##_##field_##_BITNR)
  45. /* IO_BITNR returns the starting bitnumber of a bitfield. Bit 0 is
  46. LSB and the returned bitnumber is LSB of the field. */
  47. #define IO_BITNR(reg, field) IO_BITNR_ (reg##_, field##_)
  48. #define IO_BITNR_(reg_, field_) (reg_##_##field_##_BITNR)
  49. /* IO_WIDTH returns the width, in bits, of a bitfield. */
  50. #define IO_WIDTH(reg, field) IO_WIDTH_ (reg##_, field##_)
  51. #define IO_WIDTH_(reg_, field_) (reg_##_##field_##_WIDTH)
  52. /*--- Obsolete. Kept for backw compatibility. ---*/
  53. /* Reads (or writes) a byte/uword/udword from the specified mode
  54. register. */
  55. #define IO_RD(reg) (*(volatile u32*)(reg))
  56. #define IO_RD_B(reg) (*(volatile u8*)(reg))
  57. #define IO_RD_W(reg) (*(volatile u16*)(reg))
  58. #define IO_RD_D(reg) (*(volatile u32*)(reg))
  59. /*------------------------------------------------------------
  60. !* Start addresses of the different memory areas.
  61. !*-----------------------------------------------------------*/
  62. #define MEM_CSE0_START (0x00000000)
  63. #define MEM_CSE0_SIZE (0x04000000)
  64. #define MEM_CSE1_START (0x04000000)
  65. #define MEM_CSE1_SIZE (0x04000000)
  66. #define MEM_CSR0_START (0x08000000)
  67. #define MEM_CSR1_START (0x0c000000)
  68. #define MEM_CSP0_START (0x10000000)
  69. #define MEM_CSP1_START (0x14000000)
  70. #define MEM_CSP2_START (0x18000000)
  71. #define MEM_CSP3_START (0x1c000000)
  72. #define MEM_CSP4_START (0x20000000)
  73. #define MEM_CSP5_START (0x24000000)
  74. #define MEM_CSP6_START (0x28000000)
  75. #define MEM_CSP7_START (0x2c000000)
  76. #define MEM_DRAM_START (0x40000000)
  77. #define MEM_NON_CACHEABLE (0x80000000)
  78. /*------------------------------------------------------------
  79. !* Type casts used in mode register macros, making pointer
  80. !* dereferencing possible. Empty in assembler.
  81. !*-----------------------------------------------------------*/
  82. #ifndef __ASSEMBLER__
  83. # define IO_TYPECAST_UDWORD (volatile u32*)
  84. # define IO_TYPECAST_RO_UDWORD (const volatile u32*)
  85. # define IO_TYPECAST_UWORD (volatile u16*)
  86. # define IO_TYPECAST_RO_UWORD (const volatile u16*)
  87. # define IO_TYPECAST_BYTE (volatile u8*)
  88. # define IO_TYPECAST_RO_BYTE (const volatile u8*)
  89. #else
  90. # define IO_TYPECAST_UDWORD
  91. # define IO_TYPECAST_RO_UDWORD
  92. # define IO_TYPECAST_UWORD
  93. # define IO_TYPECAST_RO_UWORD
  94. # define IO_TYPECAST_BYTE
  95. # define IO_TYPECAST_RO_BYTE
  96. #endif
  97. /*------------------------------------------------------------*/
  98. #include "sv_addr.agh"
  99. #if __test_sv_addr__
  100. /* IO_MASK( R_BUS_CONFIG , CE ) */
  101. IO_MASK( R_WAITSTATES , SRAM_WS )
  102. IO_MASK( R_TEST , W32 )
  103. IO_STATE( R_BUS_CONFIG, CE, DISABLE )
  104. IO_STATE( R_BUS_CONFIG, CE, ENABLE )
  105. IO_STATE( R_DRAM_TIMING, REF, IVAL2 )
  106. IO_MASK( R_DRAM_TIMING, REF )
  107. IO_MASK( R_EXT_DMA_0_STAT, TFR_COUNT ) >> IO_BITNR( R_EXT_DMA_0_STAT, TFR_COUNT )
  108. IO_RD(R_EXT_DMA_0_STAT) & IO_MASK( R_EXT_DMA_0_STAT, S )
  109. == IO_STATE( R_EXT_DMA_0_STAT, S, STARTED )
  110. #endif
  111. #endif /* ifndef __sv_addr_ag_h__ */