pio.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Atmel PIO2 Port Multiplexer support
  3. *
  4. * Copyright (C) 2004-2006 Atmel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __ARCH_AVR32_AT32AP_PIO_H__
  11. #define __ARCH_AVR32_AT32AP_PIO_H__
  12. /* PIO register offsets */
  13. #define PIO_PER 0x0000
  14. #define PIO_PDR 0x0004
  15. #define PIO_PSR 0x0008
  16. #define PIO_OER 0x0010
  17. #define PIO_ODR 0x0014
  18. #define PIO_OSR 0x0018
  19. #define PIO_IFER 0x0020
  20. #define PIO_IFDR 0x0024
  21. #define PIO_IFSR 0x0028
  22. #define PIO_SODR 0x0030
  23. #define PIO_CODR 0x0034
  24. #define PIO_ODSR 0x0038
  25. #define PIO_PDSR 0x003c
  26. #define PIO_IER 0x0040
  27. #define PIO_IDR 0x0044
  28. #define PIO_IMR 0x0048
  29. #define PIO_ISR 0x004c
  30. #define PIO_MDER 0x0050
  31. #define PIO_MDDR 0x0054
  32. #define PIO_MDSR 0x0058
  33. #define PIO_PUDR 0x0060
  34. #define PIO_PUER 0x0064
  35. #define PIO_PUSR 0x0068
  36. #define PIO_ASR 0x0070
  37. #define PIO_BSR 0x0074
  38. #define PIO_ABSR 0x0078
  39. #define PIO_OWER 0x00a0
  40. #define PIO_OWDR 0x00a4
  41. #define PIO_OWSR 0x00a8
  42. /* Bitfields in PER */
  43. /* Bitfields in PDR */
  44. /* Bitfields in PSR */
  45. /* Bitfields in OER */
  46. /* Bitfields in ODR */
  47. /* Bitfields in OSR */
  48. /* Bitfields in IFER */
  49. /* Bitfields in IFDR */
  50. /* Bitfields in IFSR */
  51. /* Bitfields in SODR */
  52. /* Bitfields in CODR */
  53. /* Bitfields in ODSR */
  54. /* Bitfields in PDSR */
  55. /* Bitfields in IER */
  56. /* Bitfields in IDR */
  57. /* Bitfields in IMR */
  58. /* Bitfields in ISR */
  59. /* Bitfields in MDER */
  60. /* Bitfields in MDDR */
  61. /* Bitfields in MDSR */
  62. /* Bitfields in PUDR */
  63. /* Bitfields in PUER */
  64. /* Bitfields in PUSR */
  65. /* Bitfields in ASR */
  66. /* Bitfields in BSR */
  67. /* Bitfields in ABSR */
  68. #define PIO_P0_OFFSET 0
  69. #define PIO_P0_SIZE 1
  70. #define PIO_P1_OFFSET 1
  71. #define PIO_P1_SIZE 1
  72. #define PIO_P2_OFFSET 2
  73. #define PIO_P2_SIZE 1
  74. #define PIO_P3_OFFSET 3
  75. #define PIO_P3_SIZE 1
  76. #define PIO_P4_OFFSET 4
  77. #define PIO_P4_SIZE 1
  78. #define PIO_P5_OFFSET 5
  79. #define PIO_P5_SIZE 1
  80. #define PIO_P6_OFFSET 6
  81. #define PIO_P6_SIZE 1
  82. #define PIO_P7_OFFSET 7
  83. #define PIO_P7_SIZE 1
  84. #define PIO_P8_OFFSET 8
  85. #define PIO_P8_SIZE 1
  86. #define PIO_P9_OFFSET 9
  87. #define PIO_P9_SIZE 1
  88. #define PIO_P10_OFFSET 10
  89. #define PIO_P10_SIZE 1
  90. #define PIO_P11_OFFSET 11
  91. #define PIO_P11_SIZE 1
  92. #define PIO_P12_OFFSET 12
  93. #define PIO_P12_SIZE 1
  94. #define PIO_P13_OFFSET 13
  95. #define PIO_P13_SIZE 1
  96. #define PIO_P14_OFFSET 14
  97. #define PIO_P14_SIZE 1
  98. #define PIO_P15_OFFSET 15
  99. #define PIO_P15_SIZE 1
  100. #define PIO_P16_OFFSET 16
  101. #define PIO_P16_SIZE 1
  102. #define PIO_P17_OFFSET 17
  103. #define PIO_P17_SIZE 1
  104. #define PIO_P18_OFFSET 18
  105. #define PIO_P18_SIZE 1
  106. #define PIO_P19_OFFSET 19
  107. #define PIO_P19_SIZE 1
  108. #define PIO_P20_OFFSET 20
  109. #define PIO_P20_SIZE 1
  110. #define PIO_P21_OFFSET 21
  111. #define PIO_P21_SIZE 1
  112. #define PIO_P22_OFFSET 22
  113. #define PIO_P22_SIZE 1
  114. #define PIO_P23_OFFSET 23
  115. #define PIO_P23_SIZE 1
  116. #define PIO_P24_OFFSET 24
  117. #define PIO_P24_SIZE 1
  118. #define PIO_P25_OFFSET 25
  119. #define PIO_P25_SIZE 1
  120. #define PIO_P26_OFFSET 26
  121. #define PIO_P26_SIZE 1
  122. #define PIO_P27_OFFSET 27
  123. #define PIO_P27_SIZE 1
  124. #define PIO_P28_OFFSET 28
  125. #define PIO_P28_SIZE 1
  126. #define PIO_P29_OFFSET 29
  127. #define PIO_P29_SIZE 1
  128. #define PIO_P30_OFFSET 30
  129. #define PIO_P30_SIZE 1
  130. #define PIO_P31_OFFSET 31
  131. #define PIO_P31_SIZE 1
  132. /* Bitfields in OWER */
  133. /* Bitfields in OWDR */
  134. /* Bitfields in OWSR */
  135. /* Bit manipulation macros */
  136. #define PIO_BIT(name) (1 << PIO_##name##_OFFSET)
  137. #define PIO_BF(name,value) (((value) & ((1 << PIO_##name##_SIZE) - 1)) << PIO_##name##_OFFSET)
  138. #define PIO_BFEXT(name,value) (((value) >> PIO_##name##_OFFSET) & ((1 << PIO_##name##_SIZE) - 1))
  139. #define PIO_BFINS(name,value,old) (((old) & ~(((1 << PIO_##name##_SIZE) - 1) << PIO_##name##_OFFSET)) | PIO_BF(name,value))
  140. /* Register access macros */
  141. #define pio_readl(port,reg) \
  142. __raw_readl((port)->regs + PIO_##reg)
  143. #define pio_writel(port,reg,value) \
  144. __raw_writel((value), (port)->regs + PIO_##reg)
  145. void at32_init_pio(struct platform_device *pdev);
  146. #endif /* __ARCH_AVR32_AT32AP_PIO_H__ */