at91_pio.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * [origin: Linux kernel include/asm-arm/arch-at91/at91_pio.h]
  3. *
  4. * Copyright (C) 2005 Ivan Kokshaysky
  5. * Copyright (C) SAN People
  6. * Copyright (C) 2009 Jens Scharsig (js_at_ng@scharsoft.de)
  7. *
  8. * Parallel I/O Controller (PIO) - System peripherals registers.
  9. * Based on AT91RM9200 datasheet revision E.
  10. *
  11. * SPDX-License-Identifier: GPL-2.0+
  12. */
  13. #ifndef AT91_PIO_H
  14. #define AT91_PIO_H
  15. #define AT91_ASM_PIO_RANGE 0x200
  16. #define AT91_ASM_PIOC_ASR \
  17. (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x70)
  18. #define AT91_ASM_PIOC_BSR \
  19. (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x74)
  20. #define AT91_ASM_PIOC_PDR \
  21. (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x04)
  22. #define AT91_ASM_PIOC_PUDR \
  23. (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x60)
  24. #define AT91_ASM_PIOD_PDR \
  25. (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x04)
  26. #define AT91_ASM_PIOD_PUDR \
  27. (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x60)
  28. #define AT91_ASM_PIOD_ASR \
  29. (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x70)
  30. #ifndef __ASSEMBLY__
  31. typedef struct at91_port {
  32. u32 per; /* 0x00 PIO Enable Register */
  33. u32 pdr; /* 0x04 PIO Disable Register */
  34. u32 psr; /* 0x08 PIO Status Register */
  35. u32 reserved0;
  36. u32 oer; /* 0x10 Output Enable Register */
  37. u32 odr; /* 0x14 Output Disable Registerr */
  38. u32 osr; /* 0x18 Output Status Register */
  39. u32 reserved1;
  40. u32 ifer; /* 0x20 Input Filter Enable Register */
  41. u32 ifdr; /* 0x24 Input Filter Disable Register */
  42. u32 ifsr; /* 0x28 Input Filter Status Register */
  43. u32 reserved2;
  44. u32 sodr; /* 0x30 Set Output Data Register */
  45. u32 codr; /* 0x34 Clear Output Data Register */
  46. u32 odsr; /* 0x38 Output Data Status Register */
  47. u32 pdsr; /* 0x3C Pin Data Status Register */
  48. u32 ier; /* 0x40 Interrupt Enable Register */
  49. u32 idr; /* 0x44 Interrupt Disable Register */
  50. u32 imr; /* 0x48 Interrupt Mask Register */
  51. u32 isr; /* 0x4C Interrupt Status Register */
  52. u32 mder; /* 0x50 Multi-driver Enable Register */
  53. u32 mddr; /* 0x54 Multi-driver Disable Register */
  54. u32 mdsr; /* 0x58 Multi-driver Status Register */
  55. u32 reserved3;
  56. u32 pudr; /* 0x60 Pull-up Disable Register */
  57. u32 puer; /* 0x64 Pull-up Enable Register */
  58. u32 pusr; /* 0x68 Pad Pull-up Status Register */
  59. u32 reserved4;
  60. #if defined(CPU_HAS_PIO3)
  61. u32 abcdsr1; /* 0x70 Peripheral ABCD Select Register 1 */
  62. u32 abcdsr2; /* 0x74 Peripheral ABCD Select Register 2 */
  63. u32 reserved5[2];
  64. u32 ifscdr; /* 0x80 Input Filter SCLK Disable Register */
  65. u32 ifscer; /* 0x84 Input Filter SCLK Enable Register */
  66. u32 ifscsr; /* 0x88 Input Filter SCLK Status Register */
  67. u32 scdr; /* 0x8C SCLK Divider Debouncing Register */
  68. u32 ppddr; /* 0x90 Pad Pull-down Disable Register */
  69. u32 ppder; /* 0x94 Pad Pull-down Enable Register */
  70. u32 ppdsr; /* 0x98 Pad Pull-down Status Register */
  71. u32 reserved6; /* */
  72. #else
  73. u32 asr; /* 0x70 Select A Register */
  74. u32 bsr; /* 0x74 Select B Register */
  75. u32 absr; /* 0x78 AB Select Status Register */
  76. u32 reserved5[9]; /* */
  77. #endif
  78. u32 ower; /* 0xA0 Output Write Enable Register */
  79. u32 owdr; /* 0xA4 Output Write Disable Register */
  80. u32 owsr; /* OxA8 Output Write Status Register */
  81. #if defined(CPU_HAS_PIO3)
  82. u32 reserved7; /* */
  83. u32 aimer; /* 0xB0 Additional INT Modes Enable Register */
  84. u32 aimdr; /* 0xB4 Additional INT Modes Disable Register */
  85. u32 aimmr; /* 0xB8 Additional INT Modes Mask Register */
  86. u32 reserved8; /* */
  87. u32 esr; /* 0xC0 Edge Select Register */
  88. u32 lsr; /* 0xC4 Level Select Register */
  89. u32 elsr; /* 0xC8 Edge/Level Status Register */
  90. u32 reserved9; /* 0xCC */
  91. u32 fellsr; /* 0xD0 Falling /Low Level Select Register */
  92. u32 rehlsr; /* 0xD4 Rising /High Level Select Register */
  93. u32 frlhsr; /* 0xD8 Fall/Rise - Low/High Status Register */
  94. u32 reserved10; /* */
  95. u32 locksr; /* 0xE0 Lock Status */
  96. u32 wpmr; /* 0xE4 Write Protect Mode Register */
  97. u32 wpsr; /* 0xE8 Write Protect Status Register */
  98. u32 reserved11[5]; /* */
  99. u32 schmitt; /* 0x100 Schmitt Trigger Register */
  100. u32 reserved12[63];
  101. #else
  102. u32 reserved6[85];
  103. #endif
  104. } at91_port_t;
  105. typedef union at91_pio {
  106. struct {
  107. at91_port_t pioa;
  108. at91_port_t piob;
  109. at91_port_t pioc;
  110. #if (ATMEL_PIO_PORTS > 3)
  111. at91_port_t piod;
  112. #endif
  113. #if (ATMEL_PIO_PORTS > 4)
  114. at91_port_t pioe;
  115. #endif
  116. } ;
  117. at91_port_t port[ATMEL_PIO_PORTS];
  118. } at91_pio_t;
  119. #ifdef CONFIG_AT91_GPIO
  120. int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup);
  121. int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup);
  122. #if defined(CPU_HAS_PIO3)
  123. int at91_set_c_periph(unsigned port, unsigned pin, int use_pullup);
  124. int at91_set_d_periph(unsigned port, unsigned pin, int use_pullup);
  125. int at91_set_pio_debounce(unsigned port, unsigned pin, int is_on, int div);
  126. int at91_set_pio_pulldown(unsigned port, unsigned pin, int is_on);
  127. int at91_set_pio_disable_schmitt_trig(unsigned port, unsigned pin);
  128. #endif
  129. int at91_set_pio_input(unsigned port, unsigned pin, int use_pullup);
  130. int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on);
  131. int at91_set_pio_output(unsigned port, unsigned pin, int value);
  132. int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup);
  133. int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup);
  134. int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on);
  135. int at91_set_pio_value(unsigned port, unsigned pin, int value);
  136. int at91_get_pio_value(unsigned port, unsigned pin);
  137. #endif
  138. #endif
  139. #define AT91_PIO_PORTA 0x0
  140. #define AT91_PIO_PORTB 0x1
  141. #define AT91_PIO_PORTC 0x2
  142. #define AT91_PIO_PORTD 0x3
  143. #define AT91_PIO_PORTE 0x4
  144. #endif