at91_pio.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. */
  16. #ifndef AT91_PIO_H
  17. #define AT91_PIO_H
  18. #define AT91_ASM_PIO_RANGE 0x200
  19. #define AT91_ASM_PIOC_ASR \
  20. (AT91_PIO_BASE + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x70)
  21. #define AT91_ASM_PIOC_BSR \
  22. (AT91_PIO_BASE + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x74)
  23. #define AT91_ASM_PIOC_PDR \
  24. (AT91_PIO_BASE + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x04)
  25. #define AT91_ASM_PIOC_PUDR \
  26. (AT91_PIO_BASE + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x60)
  27. #define AT91_ASM_PIOD_PDR \
  28. (AT91_PIO_BASE + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x04)
  29. #define AT91_ASM_PIOD_PUDR \
  30. (AT91_PIO_BASE + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x60)
  31. #define AT91_ASM_PIOD_ASR \
  32. (AT91_PIO_BASE + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x70)
  33. #ifndef __ASSEMBLY__
  34. typedef struct at91_port {
  35. u32 per; /* 0x00 PIO Enable Register */
  36. u32 pdr; /* 0x04 PIO Disable Register */
  37. u32 psr; /* 0x08 PIO Status Register */
  38. u32 reserved0;
  39. u32 oer; /* 0x10 Output Enable Register */
  40. u32 odr; /* 0x14 Output Disable Registerr */
  41. u32 osr; /* 0x18 Output Status Register */
  42. u32 reserved1;
  43. u32 ifer; /* 0x20 Input Filter Enable Register */
  44. u32 ifdr; /* 0x24 Input Filter Disable Register */
  45. u32 ifsr; /* 0x28 Input Filter Status Register */
  46. u32 reserved2;
  47. u32 sodr; /* 0x30 Set Output Data Register */
  48. u32 codr; /* 0x34 Clear Output Data Register */
  49. u32 odsr; /* 0x38 Output Data Status Register */
  50. u32 pdsr; /* 0x3C Pin Data Status Register */
  51. u32 ier; /* 0x40 Interrupt Enable Register */
  52. u32 idr; /* 0x44 Interrupt Disable Register */
  53. u32 imr; /* 0x48 Interrupt Mask Register */
  54. u32 isr; /* 0x4C Interrupt Status Register */
  55. u32 mder; /* 0x50 Multi-driver Enable Register */
  56. u32 mddr; /* 0x54 Multi-driver Disable Register */
  57. u32 mdsr; /* 0x58 Multi-driver Status Register */
  58. u32 reserved3;
  59. u32 pudr; /* 0x60 Pull-up Disable Register */
  60. u32 puer; /* 0x64 Pull-up Enable Register */
  61. u32 pusr; /* 0x68 Pad Pull-up Status Register */
  62. u32 reserved4;
  63. u32 asr; /* 0x70 Select A Register */
  64. u32 bsr; /* 0x74 Select B Register */
  65. u32 absr; /* 0x78 AB Select Status Register */
  66. u32 reserved5[9]; /* */
  67. u32 ower; /* 0xA0 Output Write Enable Register */
  68. u32 owdr; /* 0xA4 Output Write Disable Register */
  69. u32 owsr; /* OxA8 utput Write Status Register */
  70. u32 reserved6[85];
  71. } at91_port_t;
  72. #if defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9261) || \
  73. defined(CONFIG_AT91SAM9G10) || defined(CONFIG_AT91SAM9G20)
  74. #define AT91_PIO_PORTS 3
  75. #elif defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G45) || \
  76. defined(CONFIG_AT91SAM9M10G45)
  77. #define AT91_PIO_PORTS 5
  78. #elif defined(CONFIG_AT91RM9200) || defined(CONFIG_AT91CAP9) || \
  79. defined(CONFIG_AT91SAM9RL)
  80. #define AT91_PIO_PORTS 4
  81. #else
  82. #error "Unsupported cpu. Please update at91_pio.h"
  83. #endif
  84. typedef union at91_pio {
  85. struct {
  86. at91_port_t pioa;
  87. at91_port_t piob;
  88. at91_port_t pioc;
  89. #if (AT91_PIO_PORTS > 3)
  90. at91_port_t piod;
  91. #endif
  92. #if (AT91_PIO_PORTS > 4)
  93. at91_port_t pioe;
  94. #endif
  95. } ;
  96. at91_port_t port[AT91_PIO_PORTS];
  97. } at91_pio_t;
  98. #ifdef CONFIG_AT91_GPIO
  99. int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup);
  100. int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup);
  101. int at91_set_pio_input(unsigned port, unsigned pin, int use_pullup);
  102. int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on);
  103. int at91_set_pio_output(unsigned port, unsigned pin, int value);
  104. int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup);
  105. int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup);
  106. int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on);
  107. int at91_set_pio_value(unsigned port, unsigned pin, int value);
  108. int at91_get_pio_value(unsigned port, unsigned pin);
  109. #endif
  110. #endif
  111. #define AT91_PIO_PORTA 0x0
  112. #define AT91_PIO_PORTB 0x1
  113. #define AT91_PIO_PORTC 0x2
  114. #define AT91_PIO_PORTD 0x3
  115. #define AT91_PIO_PORTE 0x4
  116. #ifdef CONFIG_AT91_LEGACY
  117. #define PIO_PER 0x00 /* Enable Register */
  118. #define PIO_PDR 0x04 /* Disable Register */
  119. #define PIO_PSR 0x08 /* Status Register */
  120. #define PIO_OER 0x10 /* Output Enable Register */
  121. #define PIO_ODR 0x14 /* Output Disable Register */
  122. #define PIO_OSR 0x18 /* Output Status Register */
  123. #define PIO_IFER 0x20 /* Glitch Input Filter Enable */
  124. #define PIO_IFDR 0x24 /* Glitch Input Filter Disable */
  125. #define PIO_IFSR 0x28 /* Glitch Input Filter Status */
  126. #define PIO_SODR 0x30 /* Set Output Data Register */
  127. #define PIO_CODR 0x34 /* Clear Output Data Register */
  128. #define PIO_ODSR 0x38 /* Output Data Status Register */
  129. #define PIO_PDSR 0x3c /* Pin Data Status Register */
  130. #define PIO_IER 0x40 /* Interrupt Enable Register */
  131. #define PIO_IDR 0x44 /* Interrupt Disable Register */
  132. #define PIO_IMR 0x48 /* Interrupt Mask Register */
  133. #define PIO_ISR 0x4c /* Interrupt Status Register */
  134. #define PIO_MDER 0x50 /* Multi-driver Enable Register */
  135. #define PIO_MDDR 0x54 /* Multi-driver Disable Register */
  136. #define PIO_MDSR 0x58 /* Multi-driver Status Register */
  137. #define PIO_PUDR 0x60 /* Pull-up Disable Register */
  138. #define PIO_PUER 0x64 /* Pull-up Enable Register */
  139. #define PIO_PUSR 0x68 /* Pull-up Status Register */
  140. #define PIO_ASR 0x70 /* Peripheral A Select Register */
  141. #define PIO_BSR 0x74 /* Peripheral B Select Register */
  142. #define PIO_ABSR 0x78 /* AB Status Register */
  143. #define PIO_OWER 0xa0 /* Output Write Enable Register */
  144. #define PIO_OWDR 0xa4 /* Output Write Disable Register */
  145. #define PIO_OWSR 0xa8 /* Output Write Status Register */
  146. #endif
  147. #endif