at91sam9rlek.c 5.0 KB

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