hmatrix-common.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (C) 2008 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __ASM_AVR32_HMATRIX_COMMON_H__
  23. #define __ASM_AVR32_HMATRIX_COMMON_H__
  24. /* HMATRIX register offsets */
  25. struct hmatrix_regs {
  26. u32 MCFG[16];
  27. u32 SCFG[16];
  28. struct {
  29. u32 A;
  30. u32 B;
  31. } PRS[16];
  32. u32 MRCR;
  33. u32 __reserved[3];
  34. u32 SFR[16];
  35. };
  36. /* Bitfields in MCFG */
  37. #define HMATRIX_ULBT_OFFSET 0
  38. #define HMATRIX_ULBT_SIZE 3
  39. /* Bitfields in SCFG */
  40. #define HMATRIX_SLOT_CYCLE_OFFSET 0
  41. #define HMATRIX_SLOT_CYCLE_SIZE 8
  42. #define HMATRIX_DEFMSTR_TYPE_OFFSET 16
  43. #define HMATRIX_DEFMSTR_TYPE_SIZE 2
  44. #define HMATRIX_FIXED_DEFMSTR_OFFSET 18
  45. #define HMATRIX_FIXED_DEFMSTR_SIZE 4
  46. #define HMATRIX_ARBT_OFFSET 24
  47. #define HMATRIX_ARBT_SIZE 1
  48. /* Bitfields in PRS.A */
  49. #define HMATRIX_M0PR_OFFSET 0
  50. #define HMATRIX_M0PR_SIZE 4
  51. #define HMATRIX_M1PR_OFFSET 4
  52. #define HMATRIX_M1PR_SIZE 4
  53. #define HMATRIX_M2PR_OFFSET 8
  54. #define HMATRIX_M2PR_SIZE 4
  55. #define HMATRIX_M3PR_OFFSET 12
  56. #define HMATRIX_M3PR_SIZE 4
  57. #define HMATRIX_M4PR_OFFSET 16
  58. #define HMATRIX_M4PR_SIZE 4
  59. #define HMATRIX_M5PR_OFFSET 20
  60. #define HMATRIX_M5PR_SIZE 4
  61. #define HMATRIX_M6PR_OFFSET 24
  62. #define HMATRIX_M6PR_SIZE 4
  63. #define HMATRIX_M7PR_OFFSET 28
  64. #define HMATRIX_M7PR_SIZE 4
  65. /* Bitfields in PRS.B */
  66. #define HMATRIX_M8PR_OFFSET 0
  67. #define HMATRIX_M8PR_SIZE 4
  68. #define HMATRIX_M9PR_OFFSET 4
  69. #define HMATRIX_M9PR_SIZE 4
  70. #define HMATRIX_M10PR_OFFSET 8
  71. #define HMATRIX_M10PR_SIZE 4
  72. #define HMATRIX_M11PR_OFFSET 12
  73. #define HMATRIX_M11PR_SIZE 4
  74. #define HMATRIX_M12PR_OFFSET 16
  75. #define HMATRIX_M12PR_SIZE 4
  76. #define HMATRIX_M13PR_OFFSET 20
  77. #define HMATRIX_M13PR_SIZE 4
  78. #define HMATRIX_M14PR_OFFSET 24
  79. #define HMATRIX_M14PR_SIZE 4
  80. #define HMATRIX_M15PR_OFFSET 28
  81. #define HMATRIX_M15PR_SIZE 4
  82. /* Constants for ULBT */
  83. #define HMATRIX_ULBT_INFINITE 0
  84. #define HMATRIX_ULBT_SINGLE 1
  85. #define HMATRIX_ULBT_FOUR_BEAT 2
  86. #define HMATRIX_ULBT_EIGHT_BEAT 3
  87. #define HMATRIX_ULBT_SIXTEEN_BEAT 4
  88. /* Constants for DEFMSTR_TYPE */
  89. #define HMATRIX_DEFMSTR_TYPE_NO_DEFAULT 0
  90. #define HMATRIX_DEFMSTR_TYPE_LAST_DEFAULT 1
  91. #define HMATRIX_DEFMSTR_TYPE_FIXED_DEFAULT 2
  92. /* Constants for ARBT */
  93. #define HMATRIX_ARBT_ROUND_ROBIN 0
  94. #define HMATRIX_ARBT_FIXED_PRIORITY 1
  95. /* Bit manipulation macros */
  96. #define HMATRIX_BIT(name) \
  97. (1 << HMATRIX_##name##_OFFSET)
  98. #define HMATRIX_BF(name,value) \
  99. (((value) & ((1 << HMATRIX_##name##_SIZE) - 1)) \
  100. << HMATRIX_##name##_OFFSET)
  101. #define HMATRIX_BFEXT(name,value) \
  102. (((value) >> HMATRIX_##name##_OFFSET) \
  103. & ((1 << HMATRIX_##name##_SIZE) - 1))
  104. #define HMATRIX_BFINS(name,value,old) \
  105. (((old) & ~(((1 << HMATRIX_##name##_SIZE) - 1) \
  106. << HMATRIX_##name##_OFFSET)) \
  107. | HMATRIX_BF(name,value))
  108. /* Register access macros */
  109. #define __hmatrix_reg(reg) \
  110. (((volatile struct hmatrix_regs *)HMATRIX_BASE)->reg)
  111. #define hmatrix_read(reg) \
  112. (__hmatrix_reg(reg))
  113. #define hmatrix_write(reg, value) \
  114. do { __hmatrix_reg(reg) = (value); } while (0)
  115. #define hmatrix_slave_read(slave, reg) \
  116. hmatrix_read(reg[HMATRIX_SLAVE_##slave])
  117. #define hmatrix_slave_write(slave, reg, value) \
  118. hmatrix_write(reg[HMATRIX_SLAVE_##slave], value)
  119. #endif /* __ASM_AVR32_HMATRIX_COMMON_H__ */