sama5d3_devices.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright (C) 2012-2013 Atmel Corporation
  3. * Bo Shen <voice.shen@atmel.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <asm/arch/sama5d3.h>
  25. #include <asm/arch/at91_common.h>
  26. #include <asm/arch/at91_pmc.h>
  27. #include <asm/arch/clk.h>
  28. #include <asm/arch/gpio.h>
  29. #include <asm/io.h>
  30. unsigned int has_emac()
  31. {
  32. return cpu_is_sama5d31() || cpu_is_sama5d35();
  33. }
  34. unsigned int has_gmac()
  35. {
  36. return !cpu_is_sama5d31();
  37. }
  38. unsigned int has_lcdc()
  39. {
  40. return !cpu_is_sama5d35();
  41. }
  42. char *get_cpu_name()
  43. {
  44. unsigned int extension_id = get_extension_chip_id();
  45. if (cpu_is_sama5d3())
  46. switch (extension_id) {
  47. case ARCH_EXID_SAMA5D31:
  48. return "SAMA5D31";
  49. case ARCH_EXID_SAMA5D33:
  50. return "SAMA5D33";
  51. case ARCH_EXID_SAMA5D34:
  52. return "SAMA5D34";
  53. case ARCH_EXID_SAMA5D35:
  54. return "SAMA5D35";
  55. default:
  56. return "Unknown CPU type";
  57. }
  58. else
  59. return "Unknown CPU type";
  60. }
  61. void at91_serial0_hw_init(void)
  62. {
  63. at91_set_a_periph(AT91_PIO_PORTD, 18, 1); /* TXD0 */
  64. at91_set_a_periph(AT91_PIO_PORTD, 17, 0); /* RXD0 */
  65. /* Enable clock */
  66. at91_periph_clk_enable(ATMEL_ID_USART0);
  67. }
  68. void at91_serial1_hw_init(void)
  69. {
  70. at91_set_a_periph(AT91_PIO_PORTB, 29, 1); /* TXD1 */
  71. at91_set_a_periph(AT91_PIO_PORTB, 28, 0); /* RXD1 */
  72. /* Enable clock */
  73. at91_periph_clk_enable(ATMEL_ID_USART1);
  74. }
  75. void at91_serial2_hw_init(void)
  76. {
  77. at91_set_b_periph(AT91_PIO_PORTE, 26, 1); /* TXD2 */
  78. at91_set_b_periph(AT91_PIO_PORTE, 25, 0); /* RXD2 */
  79. /* Enable clock */
  80. at91_periph_clk_enable(ATMEL_ID_USART2);
  81. }
  82. void at91_seriald_hw_init(void)
  83. {
  84. at91_set_a_periph(AT91_PIO_PORTB, 31, 1); /* DTXD */
  85. at91_set_a_periph(AT91_PIO_PORTB, 30, 0); /* DRXD */
  86. /* Enable clock */
  87. at91_periph_clk_enable(ATMEL_ID_SYS);
  88. }
  89. #if defined(CONFIG_ATMEL_SPI)
  90. void at91_spi0_hw_init(unsigned long cs_mask)
  91. {
  92. at91_set_a_periph(AT91_PIO_PORTD, 10, 0); /* SPI0_MISO */
  93. at91_set_a_periph(AT91_PIO_PORTD, 11, 0); /* SPI0_MOSI */
  94. at91_set_a_periph(AT91_PIO_PORTD, 12, 0); /* SPI0_SPCK */
  95. if (cs_mask & (1 << 0))
  96. at91_set_pio_output(AT91_PIO_PORTD, 13, 1);
  97. if (cs_mask & (1 << 1))
  98. at91_set_pio_output(AT91_PIO_PORTD, 14, 1);
  99. if (cs_mask & (1 << 2))
  100. at91_set_pio_output(AT91_PIO_PORTD, 15, 1);
  101. if (cs_mask & (1 << 3))
  102. at91_set_pio_output(AT91_PIO_PORTD, 16, 1);
  103. /* Enable clock */
  104. at91_periph_clk_enable(ATMEL_ID_SPI0);
  105. }
  106. #endif
  107. #ifdef CONFIG_GENERIC_ATMEL_MCI
  108. void at91_mci_hw_init(void)
  109. {
  110. at91_set_a_periph(AT91_PIO_PORTD, 0, 0); /* MCI0 CMD */
  111. at91_set_a_periph(AT91_PIO_PORTD, 1, 0); /* MCI0 DA0 */
  112. at91_set_a_periph(AT91_PIO_PORTD, 2, 0); /* MCI0 DA1 */
  113. at91_set_a_periph(AT91_PIO_PORTD, 3, 0); /* MCI0 DA2 */
  114. at91_set_a_periph(AT91_PIO_PORTD, 4, 0); /* MCI0 DA3 */
  115. #ifdef CONFIG_ATMEL_MCI_8BIT
  116. at91_set_a_periph(AT91_PIO_PORTD, 5, 0); /* MCI0 DA4 */
  117. at91_set_a_periph(AT91_PIO_PORTD, 6, 0); /* MCI0 DA5 */
  118. at91_set_a_periph(AT91_PIO_PORTD, 7, 0); /* MCI0 DA6 */
  119. at91_set_a_periph(AT91_PIO_PORTD, 8, 0); /* MCI0 DA7 */
  120. #endif
  121. at91_set_a_periph(AT91_PIO_PORTD, 9, 0); /* MCI0 CLK */
  122. /* Enable clock */
  123. at91_periph_clk_enable(ATMEL_ID_MCI0);
  124. }
  125. #endif
  126. #ifdef CONFIG_MACB
  127. void at91_macb_hw_init(void)
  128. {
  129. at91_set_a_periph(AT91_PIO_PORTC, 7, 0); /* ETXCK_EREFCK */
  130. at91_set_a_periph(AT91_PIO_PORTC, 5, 0); /* ERXDV */
  131. at91_set_a_periph(AT91_PIO_PORTC, 2, 0); /* ERX0 */
  132. at91_set_a_periph(AT91_PIO_PORTC, 3, 0); /* ERX1 */
  133. at91_set_a_periph(AT91_PIO_PORTC, 6, 0); /* ERXER */
  134. at91_set_a_periph(AT91_PIO_PORTC, 4, 0); /* ETXEN */
  135. at91_set_a_periph(AT91_PIO_PORTC, 0, 0); /* ETX0 */
  136. at91_set_a_periph(AT91_PIO_PORTC, 1, 0); /* ETX1 */
  137. at91_set_a_periph(AT91_PIO_PORTC, 9, 0); /* EMDIO */
  138. at91_set_a_periph(AT91_PIO_PORTC, 8, 0); /* EMDC */
  139. /* Enable clock */
  140. at91_periph_clk_enable(ATMEL_ID_EMAC);
  141. }
  142. #endif
  143. #ifdef CONFIG_LCD
  144. void at91_lcd_hw_init(void)
  145. {
  146. at91_set_a_periph(AT91_PIO_PORTA, 24, 0); /* LCDPWM */
  147. at91_set_a_periph(AT91_PIO_PORTA, 25, 0); /* LCDDISP */
  148. at91_set_a_periph(AT91_PIO_PORTA, 26, 0); /* LCDVSYNC */
  149. at91_set_a_periph(AT91_PIO_PORTA, 27, 0); /* LCDHSYNC */
  150. at91_set_a_periph(AT91_PIO_PORTA, 28, 0); /* LCDDOTCK */
  151. at91_set_a_periph(AT91_PIO_PORTA, 29, 0); /* LCDDEN */
  152. /* The lower 16-bit of LCD only available on Port A */
  153. at91_set_a_periph(AT91_PIO_PORTA, 0, 0); /* LCDD0 */
  154. at91_set_a_periph(AT91_PIO_PORTA, 1, 0); /* LCDD1 */
  155. at91_set_a_periph(AT91_PIO_PORTA, 2, 0); /* LCDD2 */
  156. at91_set_a_periph(AT91_PIO_PORTA, 3, 0); /* LCDD3 */
  157. at91_set_a_periph(AT91_PIO_PORTA, 4, 0); /* LCDD4 */
  158. at91_set_a_periph(AT91_PIO_PORTA, 5, 0); /* LCDD5 */
  159. at91_set_a_periph(AT91_PIO_PORTA, 6, 0); /* LCDD6 */
  160. at91_set_a_periph(AT91_PIO_PORTA, 7, 0); /* LCDD7 */
  161. at91_set_a_periph(AT91_PIO_PORTA, 8, 0); /* LCDD8 */
  162. at91_set_a_periph(AT91_PIO_PORTA, 9, 0); /* LCDD9 */
  163. at91_set_a_periph(AT91_PIO_PORTA, 10, 0); /* LCDD10 */
  164. at91_set_a_periph(AT91_PIO_PORTA, 11, 0); /* LCDD11 */
  165. at91_set_a_periph(AT91_PIO_PORTA, 12, 0); /* LCDD12 */
  166. at91_set_a_periph(AT91_PIO_PORTA, 13, 0); /* LCDD13 */
  167. at91_set_a_periph(AT91_PIO_PORTA, 14, 0); /* LCDD14 */
  168. at91_set_a_periph(AT91_PIO_PORTA, 15, 0); /* LCDD15 */
  169. /* Enable clock */
  170. at91_periph_clk_enable(ATMEL_ID_LCDC);
  171. }
  172. #endif