at91sam9n12_devices.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * (C) Copyright 2013 Atmel Corporation
  3. * Josh Wu <josh.wu@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/io.h>
  25. #include <asm/arch/at91_common.h>
  26. #include <asm/arch/at91_pmc.h>
  27. #include <asm/arch/at91_pio.h>
  28. unsigned int has_lcdc()
  29. {
  30. return 1;
  31. }
  32. void at91_serial0_hw_init(void)
  33. {
  34. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  35. at91_set_a_periph(AT91_PIO_PORTA, 0, 1); /* TXD0 */
  36. at91_set_a_periph(AT91_PIO_PORTA, 1, 0); /* RXD0 */
  37. writel(1 << ATMEL_ID_USART0, &pmc->pcer);
  38. }
  39. void at91_serial1_hw_init(void)
  40. {
  41. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  42. at91_set_a_periph(AT91_PIO_PORTA, 5, 1); /* TXD1 */
  43. at91_set_a_periph(AT91_PIO_PORTA, 6, 0); /* RXD1 */
  44. writel(1 << ATMEL_ID_USART1, &pmc->pcer);
  45. }
  46. void at91_serial2_hw_init(void)
  47. {
  48. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  49. at91_set_a_periph(AT91_PIO_PORTA, 7, 1); /* TXD2 */
  50. at91_set_a_periph(AT91_PIO_PORTA, 8, 0); /* RXD2 */
  51. writel(1 << ATMEL_ID_USART2, &pmc->pcer);
  52. }
  53. void at91_serial3_hw_init(void)
  54. {
  55. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  56. at91_set_b_periph(AT91_PIO_PORTC, 22, 1); /* TXD3 */
  57. at91_set_b_periph(AT91_PIO_PORTC, 23, 0); /* RXD3 */
  58. writel(1 << ATMEL_ID_USART3, &pmc->pcer);
  59. }
  60. void at91_seriald_hw_init(void)
  61. {
  62. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  63. at91_set_a_periph(AT91_PIO_PORTA, 10, 1); /* DTXD */
  64. at91_set_a_periph(AT91_PIO_PORTA, 9, 0); /* DRXD */
  65. writel(1 << ATMEL_ID_SYS, &pmc->pcer);
  66. }
  67. #ifdef CONFIG_ATMEL_SPI
  68. void at91_spi0_hw_init(unsigned long cs_mask)
  69. {
  70. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  71. at91_set_a_periph(AT91_PIO_PORTA, 11, 0); /* SPI0_MISO */
  72. at91_set_a_periph(AT91_PIO_PORTA, 12, 0); /* SPI0_MOSI */
  73. at91_set_a_periph(AT91_PIO_PORTA, 13, 0); /* SPI0_SPCK */
  74. /* Enable clock */
  75. writel(1 << ATMEL_ID_SPI0, &pmc->pcer);
  76. if (cs_mask & (1 << 0))
  77. at91_set_pio_output(AT91_PIO_PORTA, 14, 1);
  78. if (cs_mask & (1 << 1))
  79. at91_set_pio_output(AT91_PIO_PORTA, 7, 1);
  80. if (cs_mask & (1 << 2))
  81. at91_set_pio_output(AT91_PIO_PORTA, 1, 1);
  82. if (cs_mask & (1 << 3))
  83. at91_set_pio_output(AT91_PIO_PORTB, 3, 1);
  84. }
  85. void at91_spi1_hw_init(unsigned long cs_mask)
  86. {
  87. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  88. at91_set_b_periph(AT91_PIO_PORTA, 21, 0); /* SPI1_MISO */
  89. at91_set_b_periph(AT91_PIO_PORTA, 22, 0); /* SPI1_MOSI */
  90. at91_set_b_periph(AT91_PIO_PORTA, 23, 0); /* SPI1_SPCK */
  91. /* Enable clock */
  92. writel(1 << ATMEL_ID_SPI1, &pmc->pcer);
  93. if (cs_mask & (1 << 0))
  94. at91_set_pio_output(AT91_PIO_PORTA, 8, 1);
  95. if (cs_mask & (1 << 1))
  96. at91_set_pio_output(AT91_PIO_PORTA, 0, 1);
  97. if (cs_mask & (1 << 2))
  98. at91_set_pio_output(AT91_PIO_PORTA, 31, 1);
  99. if (cs_mask & (1 << 3))
  100. at91_set_pio_output(AT91_PIO_PORTA, 30, 1);
  101. }
  102. #endif
  103. void at91_mci_hw_init(void)
  104. {
  105. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  106. at91_set_a_periph(AT91_PIO_PORTA, 17, 0); /* MCCK */
  107. at91_set_a_periph(AT91_PIO_PORTA, 16, 0); /* MCCDA */
  108. at91_set_a_periph(AT91_PIO_PORTA, 15, 0); /* MCDA0 */
  109. at91_set_a_periph(AT91_PIO_PORTA, 18, 0); /* MCDA1 */
  110. at91_set_a_periph(AT91_PIO_PORTA, 19, 0); /* MCDA2 */
  111. at91_set_a_periph(AT91_PIO_PORTA, 20, 0); /* MCDA3 */
  112. writel(1 << ATMEL_ID_HSMCI0, &pmc->pcer);
  113. }
  114. #ifdef CONFIG_LCD
  115. void at91_lcd_hw_init(void)
  116. {
  117. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  118. at91_set_a_periph(AT91_PIO_PORTC, 24, 0); /* LCDDPWR */
  119. at91_set_a_periph(AT91_PIO_PORTC, 26, 0); /* LCDVSYNC */
  120. at91_set_a_periph(AT91_PIO_PORTC, 27, 0); /* LCDHSYNC */
  121. at91_set_a_periph(AT91_PIO_PORTC, 28, 0); /* LCDDOTCK */
  122. at91_set_a_periph(AT91_PIO_PORTC, 29, 0); /* LCDDEN */
  123. at91_set_a_periph(AT91_PIO_PORTC, 30, 0); /* LCDDOTCK */
  124. at91_set_a_periph(AT91_PIO_PORTC, 0, 0); /* LCDD0 */
  125. at91_set_a_periph(AT91_PIO_PORTC, 1, 0); /* LCDD1 */
  126. at91_set_a_periph(AT91_PIO_PORTC, 2, 0); /* LCDD2 */
  127. at91_set_a_periph(AT91_PIO_PORTC, 3, 0); /* LCDD3 */
  128. at91_set_a_periph(AT91_PIO_PORTC, 4, 0); /* LCDD4 */
  129. at91_set_a_periph(AT91_PIO_PORTC, 5, 0); /* LCDD5 */
  130. at91_set_a_periph(AT91_PIO_PORTC, 6, 0); /* LCDD6 */
  131. at91_set_a_periph(AT91_PIO_PORTC, 7, 0); /* LCDD7 */
  132. at91_set_a_periph(AT91_PIO_PORTC, 8, 0); /* LCDD8 */
  133. at91_set_a_periph(AT91_PIO_PORTC, 9, 0); /* LCDD9 */
  134. at91_set_a_periph(AT91_PIO_PORTC, 10, 0); /* LCDD10 */
  135. at91_set_a_periph(AT91_PIO_PORTC, 11, 0); /* LCDD11 */
  136. at91_set_a_periph(AT91_PIO_PORTC, 12, 0); /* LCDD12 */
  137. at91_set_a_periph(AT91_PIO_PORTC, 13, 0); /* LCDD13 */
  138. at91_set_a_periph(AT91_PIO_PORTC, 14, 0); /* LCDD14 */
  139. at91_set_a_periph(AT91_PIO_PORTC, 15, 0); /* LCDD15 */
  140. at91_set_a_periph(AT91_PIO_PORTC, 16, 0); /* LCDD16 */
  141. at91_set_a_periph(AT91_PIO_PORTC, 17, 0); /* LCDD17 */
  142. at91_set_a_periph(AT91_PIO_PORTC, 18, 0); /* LCDD18 */
  143. at91_set_a_periph(AT91_PIO_PORTC, 19, 0); /* LCDD19 */
  144. at91_set_a_periph(AT91_PIO_PORTC, 20, 0); /* LCDD20 */
  145. at91_set_a_periph(AT91_PIO_PORTC, 21, 0); /* LCDD21 */
  146. at91_set_a_periph(AT91_PIO_PORTC, 22, 0); /* LCDD22 */
  147. at91_set_a_periph(AT91_PIO_PORTC, 23, 0); /* LCDD23 */
  148. writel(1 << ATMEL_ID_LCDC, &pmc->pcer);
  149. }
  150. #endif