at91sam9rlek.c 5.2 KB

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