at91sam9rlek.c 5.2 KB

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