at91sam9rlek.c 4.9 KB

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