at91sam9rlek.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * (C) Copyright 2007-2008
  3. * Stelian Pop <stelian@popies.net>
  4. * Lead Tech Design <www.leadtechdesign.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <asm/io.h>
  10. #include <asm/arch/at91sam9rl.h>
  11. #include <asm/arch/at91sam9rl_matrix.h>
  12. #include <asm/arch/at91sam9_smc.h>
  13. #include <asm/arch/at91_common.h>
  14. #include <asm/arch/at91_pmc.h>
  15. #include <asm/arch/at91_rstc.h>
  16. #include <asm/arch/clk.h>
  17. #include <asm/arch/gpio.h>
  18. #include <lcd.h>
  19. #include <atmel_lcdc.h>
  20. #include <atmel_mci.h>
  21. #if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
  22. #include <net.h>
  23. #endif
  24. DECLARE_GLOBAL_DATA_PTR;
  25. /* ------------------------------------------------------------------------- */
  26. /*
  27. * Miscelaneous platform dependent initialisations
  28. */
  29. #ifdef CONFIG_CMD_NAND
  30. static void at91sam9rlek_nand_hw_init(void)
  31. {
  32. struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
  33. struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
  34. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  35. unsigned long csa;
  36. /* Enable CS3 */
  37. csa = readl(&matrix->ebicsa);
  38. csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
  39. writel(csa, &matrix->ebicsa);
  40. /* Configure SMC CS3 for NAND/SmartMedia */
  41. writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
  42. AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
  43. &smc->cs[3].setup);
  44. writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
  45. AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
  46. &smc->cs[3].pulse);
  47. writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
  48. &smc->cs[3].cycle);
  49. writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
  50. AT91_SMC_MODE_EXNW_DISABLE |
  51. #ifdef CONFIG_SYS_NAND_DBW_16
  52. AT91_SMC_MODE_DBW_16 |
  53. #else /* CONFIG_SYS_NAND_DBW_8 */
  54. AT91_SMC_MODE_DBW_8 |
  55. #endif
  56. AT91_SMC_MODE_TDF_CYCLE(2),
  57. &smc->cs[3].mode);
  58. writel(1 << ATMEL_ID_PIOD, &pmc->pcer);
  59. /* Configure RDY/BSY */
  60. at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
  61. /* Enable NandFlash */
  62. at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
  63. at91_set_A_periph(AT91_PIN_PB4, 0); /* NANDOE */
  64. at91_set_A_periph(AT91_PIN_PB5, 0); /* NANDWE */
  65. }
  66. #endif
  67. #ifdef CONFIG_LCD
  68. vidinfo_t panel_info = {
  69. .vl_col = 240,
  70. .vl_row = 320,
  71. .vl_clk = 4965000,
  72. .vl_sync = ATMEL_LCDC_INVLINE_INVERTED |
  73. ATMEL_LCDC_INVFRAME_INVERTED,
  74. .vl_bpix = 3,
  75. .vl_tft = 1,
  76. .vl_hsync_len = 5,
  77. .vl_left_margin = 1,
  78. .vl_right_margin = 33,
  79. .vl_vsync_len = 1,
  80. .vl_upper_margin = 1,
  81. .vl_lower_margin = 0,
  82. .mmio = ATMEL_BASE_LCDC,
  83. };
  84. void lcd_enable(void)
  85. {
  86. at91_set_gpio_value(AT91_PIN_PA30, 0); /* power up */
  87. }
  88. void lcd_disable(void)
  89. {
  90. at91_set_gpio_value(AT91_PIN_PA30, 1); /* power down */
  91. }
  92. static void at91sam9rlek_lcd_hw_init(void)
  93. {
  94. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  95. at91_set_B_periph(AT91_PIN_PC1, 0); /* LCDPWR */
  96. at91_set_A_periph(AT91_PIN_PC5, 0); /* LCDHSYNC */
  97. at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDDOTCK */
  98. at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDDEN */
  99. at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDCC */
  100. at91_set_B_periph(AT91_PIN_PC9, 0); /* LCDD3 */
  101. at91_set_B_periph(AT91_PIN_PC10, 0); /* LCDD4 */
  102. at91_set_B_periph(AT91_PIN_PC11, 0); /* LCDD5 */
  103. at91_set_B_periph(AT91_PIN_PC12, 0); /* LCDD6 */
  104. at91_set_B_periph(AT91_PIN_PC13, 0); /* LCDD7 */
  105. at91_set_B_periph(AT91_PIN_PC15, 0); /* LCDD11 */
  106. at91_set_B_periph(AT91_PIN_PC16, 0); /* LCDD12 */
  107. at91_set_B_periph(AT91_PIN_PC17, 0); /* LCDD13 */
  108. at91_set_B_periph(AT91_PIN_PC18, 0); /* LCDD14 */
  109. at91_set_B_periph(AT91_PIN_PC19, 0); /* LCDD15 */
  110. at91_set_B_periph(AT91_PIN_PC20, 0); /* LCDD18 */
  111. at91_set_B_periph(AT91_PIN_PC21, 0); /* LCDD19 */
  112. at91_set_B_periph(AT91_PIN_PC22, 0); /* LCDD20 */
  113. at91_set_B_periph(AT91_PIN_PC23, 0); /* LCDD21 */
  114. at91_set_B_periph(AT91_PIN_PC24, 0); /* LCDD22 */
  115. at91_set_B_periph(AT91_PIN_PC25, 0); /* LCDD23 */
  116. writel(1 << ATMEL_ID_LCDC, &pmc->pcer);
  117. }
  118. #ifdef CONFIG_LCD_INFO
  119. #include <nand.h>
  120. #include <version.h>
  121. void lcd_show_board_info(void)
  122. {
  123. ulong dram_size, nand_size;
  124. int i;
  125. char temp[32];
  126. lcd_printf ("%s\n", U_BOOT_VERSION);
  127. lcd_printf ("(C) 2008 ATMEL Corp\n");
  128. lcd_printf ("at91support@atmel.com\n");
  129. lcd_printf ("%s CPU at %s MHz\n",
  130. ATMEL_CPU_NAME,
  131. strmhz(temp, get_cpu_clk_rate()));
  132. dram_size = 0;
  133. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
  134. dram_size += gd->bd->bi_dram[i].size;
  135. nand_size = 0;
  136. for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
  137. nand_size += nand_info[i].size;
  138. lcd_printf (" %ld MB SDRAM, %ld MB NAND\n",
  139. dram_size >> 20,
  140. nand_size >> 20 );
  141. }
  142. #endif /* CONFIG_LCD_INFO */
  143. #endif
  144. #ifdef CONFIG_GENERIC_ATMEL_MCI
  145. int board_mmc_init(bd_t *bis)
  146. {
  147. at91_mci_hw_init();
  148. return atmel_mci_init((void *)ATMEL_BASE_MCI);
  149. }
  150. #endif
  151. int board_early_init_f(void)
  152. {
  153. struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
  154. /* Enable clocks for all PIOs */
  155. writel((1 << ATMEL_ID_PIOA) | (1 << ATMEL_ID_PIOB) |
  156. (1 << ATMEL_ID_PIOC) | (1 << ATMEL_ID_PIOD),
  157. &pmc->pcer);
  158. return 0;
  159. }
  160. int board_init(void)
  161. {
  162. /* arch number of AT91SAM9RLEK-Board */
  163. gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9RLEK;
  164. /* adress of boot parameters */
  165. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  166. at91_seriald_hw_init();
  167. #ifdef CONFIG_CMD_NAND
  168. at91sam9rlek_nand_hw_init();
  169. #endif
  170. #ifdef CONFIG_HAS_DATAFLASH
  171. at91_spi0_hw_init(1 << 0);
  172. #endif
  173. #ifdef CONFIG_LCD
  174. at91sam9rlek_lcd_hw_init();
  175. #endif
  176. return 0;
  177. }
  178. int dram_init(void)
  179. {
  180. gd->ram_size = get_ram_size(
  181. (void *)CONFIG_SYS_SDRAM_BASE,
  182. CONFIG_SYS_SDRAM_SIZE);
  183. return 0;
  184. }