at91sam9263_devices.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2007-2008
  4. * Stelian Pop <stelian@popies.net>
  5. * Lead Tech Design <www.leadtechdesign.com>
  6. *
  7. * (C) Copyright 2009-2011
  8. * Daniel Gorsulowski <daniel.gorsulowski@esd.eu>
  9. * esd electronic system design gmbh <www.esd.eu>
  10. */
  11. #include <common.h>
  12. #include <asm/io.h>
  13. #include <asm/arch/at91_common.h>
  14. #include <asm/arch/clk.h>
  15. #include <asm/arch/gpio.h>
  16. /*
  17. * if CONFIG_AT91_GPIO_PULLUP ist set, keep pullups on on all
  18. * peripheral pins. Good to have if hardware is soldered optionally
  19. * or in case of SPI no slave is selected. Avoid lines to float
  20. * needlessly. Use a short local PUP define.
  21. *
  22. * Due to errata "TXD floats when CTS is inactive" pullups are always
  23. * on for TXD pins.
  24. */
  25. #ifdef CONFIG_AT91_GPIO_PULLUP
  26. # define PUP CONFIG_AT91_GPIO_PULLUP
  27. #else
  28. # define PUP 0
  29. #endif
  30. void at91_serial0_hw_init(void)
  31. {
  32. at91_set_a_periph(AT91_PIO_PORTA, 26, 1); /* TXD0 */
  33. at91_set_a_periph(AT91_PIO_PORTA, 27, PUP); /* RXD0 */
  34. at91_periph_clk_enable(ATMEL_ID_USART0);
  35. }
  36. void at91_serial1_hw_init(void)
  37. {
  38. at91_set_a_periph(AT91_PIO_PORTD, 0, 1); /* TXD1 */
  39. at91_set_a_periph(AT91_PIO_PORTD, 1, PUP); /* RXD1 */
  40. at91_periph_clk_enable(ATMEL_ID_USART1);
  41. }
  42. void at91_serial2_hw_init(void)
  43. {
  44. at91_set_a_periph(AT91_PIO_PORTD, 2, 1); /* TXD2 */
  45. at91_set_a_periph(AT91_PIO_PORTD, 3, PUP); /* RXD2 */
  46. at91_periph_clk_enable(ATMEL_ID_USART2);
  47. }
  48. void at91_seriald_hw_init(void)
  49. {
  50. at91_set_a_periph(AT91_PIO_PORTC, 30, PUP); /* DRXD */
  51. at91_set_a_periph(AT91_PIO_PORTC, 31, 1); /* DTXD */
  52. at91_periph_clk_enable(ATMEL_ID_SYS);
  53. }
  54. #ifdef CONFIG_ATMEL_SPI
  55. void at91_spi0_hw_init(unsigned long cs_mask)
  56. {
  57. at91_set_b_periph(AT91_PIO_PORTA, 0, PUP); /* SPI0_MISO */
  58. at91_set_b_periph(AT91_PIO_PORTA, 1, PUP); /* SPI0_MOSI */
  59. at91_set_b_periph(AT91_PIO_PORTA, 2, PUP); /* SPI0_SPCK */
  60. at91_periph_clk_enable(ATMEL_ID_SPI0);
  61. if (cs_mask & (1 << 0)) {
  62. at91_set_b_periph(AT91_PIO_PORTA, 5, 1);
  63. }
  64. if (cs_mask & (1 << 1)) {
  65. at91_set_b_periph(AT91_PIO_PORTA, 3, 1);
  66. }
  67. if (cs_mask & (1 << 2)) {
  68. at91_set_b_periph(AT91_PIO_PORTA, 4, 1);
  69. }
  70. if (cs_mask & (1 << 3)) {
  71. at91_set_b_periph(AT91_PIO_PORTB, 11, 1);
  72. }
  73. if (cs_mask & (1 << 4)) {
  74. at91_set_pio_output(AT91_PIO_PORTA, 5, 1);
  75. }
  76. if (cs_mask & (1 << 5)) {
  77. at91_set_pio_output(AT91_PIO_PORTA, 3, 1);
  78. }
  79. if (cs_mask & (1 << 6)) {
  80. at91_set_pio_output(AT91_PIO_PORTA, 4, 1);
  81. }
  82. if (cs_mask & (1 << 7)) {
  83. at91_set_pio_output(AT91_PIO_PORTB, 11, 1);
  84. }
  85. }
  86. void at91_spi1_hw_init(unsigned long cs_mask)
  87. {
  88. at91_set_a_periph(AT91_PIO_PORTB, 12, PUP); /* SPI1_MISO */
  89. at91_set_a_periph(AT91_PIO_PORTB, 13, PUP); /* SPI1_MOSI */
  90. at91_set_a_periph(AT91_PIO_PORTB, 14, PUP); /* SPI1_SPCK */
  91. at91_periph_clk_enable(ATMEL_ID_SPI1);
  92. if (cs_mask & (1 << 0)) {
  93. at91_set_a_periph(AT91_PIO_PORTB, 15, 1);
  94. }
  95. if (cs_mask & (1 << 1)) {
  96. at91_set_a_periph(AT91_PIO_PORTB, 16, 1);
  97. }
  98. if (cs_mask & (1 << 2)) {
  99. at91_set_a_periph(AT91_PIO_PORTB, 17, 1);
  100. }
  101. if (cs_mask & (1 << 3)) {
  102. at91_set_a_periph(AT91_PIO_PORTB, 18, 1);
  103. }
  104. if (cs_mask & (1 << 4)) {
  105. at91_set_pio_output(AT91_PIO_PORTB, 15, 1);
  106. }
  107. if (cs_mask & (1 << 5)) {
  108. at91_set_pio_output(AT91_PIO_PORTB, 16, 1);
  109. }
  110. if (cs_mask & (1 << 6)) {
  111. at91_set_pio_output(AT91_PIO_PORTB, 17, 1);
  112. }
  113. if (cs_mask & (1 << 7)) {
  114. at91_set_pio_output(AT91_PIO_PORTB, 18, 1);
  115. }
  116. }
  117. #endif
  118. #if defined(CONFIG_GENERIC_ATMEL_MCI)
  119. void at91_mci_hw_init(void)
  120. {
  121. at91_periph_clk_enable(ATMEL_ID_MCI1);
  122. at91_set_a_periph(AT91_PIO_PORTA, 6, PUP); /* MCI1_CK */
  123. #if defined(CONFIG_ATMEL_MCI_PORTB)
  124. at91_set_a_periph(AT91_PIO_PORTA, 21, PUP); /* MCI1_CDB */
  125. at91_set_a_periph(AT91_PIO_PORTA, 22, PUP); /* MCI1_DB0 */
  126. at91_set_a_periph(AT91_PIO_PORTA, 23, PUP); /* MCI1_DB1 */
  127. at91_set_a_periph(AT91_PIO_PORTA, 24, PUP); /* MCI1_DB2 */
  128. at91_set_a_periph(AT91_PIO_PORTA, 25, PUP); /* MCI1_DB3 */
  129. #else
  130. at91_set_a_periph(AT91_PIO_PORTA, 7, PUP); /* MCI1_CDA */
  131. at91_set_a_periph(AT91_PIO_PORTA, 8, PUP); /* MCI1_DA0 */
  132. at91_set_a_periph(AT91_PIO_PORTA, 9, PUP); /* MCI1_DA1 */
  133. at91_set_a_periph(AT91_PIO_PORTA, 10, PUP); /* MCI1_DA2 */
  134. at91_set_a_periph(AT91_PIO_PORTA, 11, PUP); /* MCI1_DA3 */
  135. #endif
  136. }
  137. #endif
  138. #ifdef CONFIG_MACB
  139. void at91_macb_hw_init(void)
  140. {
  141. at91_set_a_periph(AT91_PIO_PORTE, 21, 0); /* ETXCK_EREFCK */
  142. at91_set_b_periph(AT91_PIO_PORTC, 25, 0); /* ERXDV */
  143. at91_set_a_periph(AT91_PIO_PORTE, 25, 0); /* ERX0 */
  144. at91_set_a_periph(AT91_PIO_PORTE, 26, 0); /* ERX1 */
  145. at91_set_a_periph(AT91_PIO_PORTE, 27, 0); /* ERXER */
  146. at91_set_a_periph(AT91_PIO_PORTE, 28, 0); /* ETXEN */
  147. at91_set_a_periph(AT91_PIO_PORTE, 23, 0); /* ETX0 */
  148. at91_set_a_periph(AT91_PIO_PORTE, 24, 0); /* ETX1 */
  149. at91_set_a_periph(AT91_PIO_PORTE, 30, 0); /* EMDIO */
  150. at91_set_a_periph(AT91_PIO_PORTE, 29, 0); /* EMDC */
  151. #ifndef CONFIG_RMII
  152. at91_set_a_periph(AT91_PIO_PORTE, 22, 0); /* ECRS */
  153. at91_set_b_periph(AT91_PIO_PORTC, 26, 0); /* ECOL */
  154. at91_set_b_periph(AT91_PIO_PORTC, 22, 0); /* ERX2 */
  155. at91_set_b_periph(AT91_PIO_PORTC, 23, 0); /* ERX3 */
  156. at91_set_b_periph(AT91_PIO_PORTC, 27, 0); /* ERXCK */
  157. at91_set_b_periph(AT91_PIO_PORTC, 20, 0); /* ETX2 */
  158. at91_set_b_periph(AT91_PIO_PORTC, 21, 0); /* ETX3 */
  159. at91_set_b_periph(AT91_PIO_PORTC, 24, 0); /* ETXER */
  160. #endif
  161. }
  162. #endif
  163. #ifdef CONFIG_USB_OHCI_NEW
  164. void at91_uhp_hw_init(void)
  165. {
  166. /* Enable VBus on UHP ports */
  167. at91_set_pio_output(AT91_PIO_PORTA, 21, 0);
  168. at91_set_pio_output(AT91_PIO_PORTA, 24, 0);
  169. }
  170. #endif
  171. #ifdef CONFIG_AT91_CAN
  172. void at91_can_hw_init(void)
  173. {
  174. at91_set_a_periph(AT91_PIO_PORTA, 13, 0); /* CAN_TX */
  175. at91_set_a_periph(AT91_PIO_PORTA, 14, 1); /* CAN_RX */
  176. at91_periph_clk_enable(ATMEL_ID_CAN);
  177. }
  178. #endif