at91sam9263ek.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 <linux/sizes.h>
  10. #include <asm/arch/at91sam9263.h>
  11. #include <asm/arch/at91sam9_smc.h>
  12. #include <asm/arch/at91_common.h>
  13. #include <asm/arch/at91_matrix.h>
  14. #include <asm/arch/at91_pio.h>
  15. #include <asm/arch/clk.h>
  16. #include <asm/io.h>
  17. #include <asm/arch/gpio.h>
  18. #include <asm/arch/hardware.h>
  19. #include <lcd.h>
  20. #include <atmel_lcdc.h>
  21. #include <asm/mach-types.h>
  22. DECLARE_GLOBAL_DATA_PTR;
  23. /* ------------------------------------------------------------------------- */
  24. /*
  25. * Miscelaneous platform dependent initialisations
  26. */
  27. #ifdef CONFIG_CMD_NAND
  28. static void at91sam9263ek_nand_hw_init(void)
  29. {
  30. unsigned long csa;
  31. at91_smc_t *smc = (at91_smc_t *) ATMEL_BASE_SMC0;
  32. at91_matrix_t *matrix = (at91_matrix_t *) ATMEL_BASE_MATRIX;
  33. /* Enable CS3 */
  34. csa = readl(&matrix->csa[0]) | AT91_MATRIX_CSA_EBI_CS3A;
  35. writel(csa, &matrix->csa[0]);
  36. /* Enable CS3 */
  37. /* Configure SMC CS3 for NAND/SmartMedia */
  38. writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
  39. AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
  40. &smc->cs[3].setup);
  41. writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
  42. AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
  43. &smc->cs[3].pulse);
  44. writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
  45. &smc->cs[3].cycle);
  46. writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
  47. AT91_SMC_MODE_EXNW_DISABLE |
  48. #ifdef CONFIG_SYS_NAND_DBW_16
  49. AT91_SMC_MODE_DBW_16 |
  50. #else /* CONFIG_SYS_NAND_DBW_8 */
  51. AT91_SMC_MODE_DBW_8 |
  52. #endif
  53. AT91_SMC_MODE_TDF_CYCLE(2),
  54. &smc->cs[3].mode);
  55. at91_periph_clk_enable(ATMEL_ID_PIOA);
  56. at91_periph_clk_enable(ATMEL_ID_PIOCDE);
  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. }
  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_pio_value(AT91_PIO_PORTA, 30, 1); /* power up */
  83. }
  84. void lcd_disable(void)
  85. {
  86. at91_set_pio_value(AT91_PIO_PORTA, 30, 0); /* power down */
  87. }
  88. static void at91sam9263ek_lcd_hw_init(void)
  89. {
  90. at91_set_a_periph(AT91_PIO_PORTC, 1, 0); /* LCDHSYNC */
  91. at91_set_a_periph(AT91_PIO_PORTC, 2, 0); /* LCDDOTCK */
  92. at91_set_a_periph(AT91_PIO_PORTC, 3, 0); /* LCDDEN */
  93. at91_set_b_periph(AT91_PIO_PORTB, 9, 0); /* LCDCC */
  94. at91_set_a_periph(AT91_PIO_PORTC, 6, 0); /* LCDD2 */
  95. at91_set_a_periph(AT91_PIO_PORTC, 7, 0); /* LCDD3 */
  96. at91_set_a_periph(AT91_PIO_PORTC, 8, 0); /* LCDD4 */
  97. at91_set_a_periph(AT91_PIO_PORTC, 9, 0); /* LCDD5 */
  98. at91_set_a_periph(AT91_PIO_PORTC, 10, 0); /* LCDD6 */
  99. at91_set_a_periph(AT91_PIO_PORTC, 11, 0); /* LCDD7 */
  100. at91_set_a_periph(AT91_PIO_PORTC, 14, 0); /* LCDD10 */
  101. at91_set_a_periph(AT91_PIO_PORTC, 15, 0); /* LCDD11 */
  102. at91_set_a_periph(AT91_PIO_PORTC, 16, 0); /* LCDD12 */
  103. at91_set_b_periph(AT91_PIO_PORTC, 12, 0); /* LCDD13 */
  104. at91_set_a_periph(AT91_PIO_PORTC, 18, 0); /* LCDD14 */
  105. at91_set_a_periph(AT91_PIO_PORTC, 19, 0); /* LCDD15 */
  106. at91_set_a_periph(AT91_PIO_PORTC, 22, 0); /* LCDD18 */
  107. at91_set_a_periph(AT91_PIO_PORTC, 23, 0); /* LCDD19 */
  108. at91_set_a_periph(AT91_PIO_PORTC, 24, 0); /* LCDD20 */
  109. at91_set_b_periph(AT91_PIO_PORTC, 17, 0); /* LCDD21 */
  110. at91_set_a_periph(AT91_PIO_PORTC, 26, 0); /* LCDD22 */
  111. at91_set_a_periph(AT91_PIO_PORTC, 27, 0); /* LCDD23 */
  112. at91_periph_clk_enable(ATMEL_ID_LCDC);
  113. gd->fb_base = ATMEL_BASE_SRAM0;
  114. }
  115. #ifdef CONFIG_LCD_INFO
  116. #include <nand.h>
  117. #include <version.h>
  118. #ifdef CONFIG_MTD_NOR_FLASH
  119. extern flash_info_t flash_info[];
  120. #endif
  121. void lcd_show_board_info(void)
  122. {
  123. ulong dram_size, nand_size;
  124. #ifdef CONFIG_MTD_NOR_FLASH
  125. ulong flash_size;
  126. #endif
  127. int i;
  128. char temp[32];
  129. lcd_printf ("%s\n", U_BOOT_VERSION);
  130. lcd_printf ("(C) 2008 ATMEL Corp\n");
  131. lcd_printf ("at91support@atmel.com\n");
  132. lcd_printf ("%s CPU at %s MHz\n",
  133. ATMEL_CPU_NAME,
  134. strmhz(temp, get_cpu_clk_rate()));
  135. dram_size = 0;
  136. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
  137. dram_size += gd->bd->bi_dram[i].size;
  138. nand_size = 0;
  139. for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
  140. nand_size += get_nand_dev_by_index(i)->size;
  141. #ifdef CONFIG_MTD_NOR_FLASH
  142. flash_size = 0;
  143. for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++)
  144. flash_size += flash_info[i].size;
  145. #endif
  146. lcd_printf (" %ld MB SDRAM, %ld MB NAND",
  147. dram_size >> 20,
  148. nand_size >> 20 );
  149. #ifdef CONFIG_MTD_NOR_FLASH
  150. lcd_printf (",\n %ld MB NOR",
  151. flash_size >> 20);
  152. #endif
  153. lcd_puts ("\n");
  154. }
  155. #endif /* CONFIG_LCD_INFO */
  156. #endif
  157. #ifdef CONFIG_DEBUG_UART_BOARD_INIT
  158. void board_debug_uart_init(void)
  159. {
  160. at91_seriald_hw_init();
  161. }
  162. #endif
  163. #ifdef CONFIG_BOARD_EARLY_INIT_F
  164. int board_early_init_f(void)
  165. {
  166. #ifdef CONFIG_DEBUG_UART
  167. debug_uart_init();
  168. #endif
  169. return 0;
  170. }
  171. #endif
  172. int board_init(void)
  173. {
  174. /* arch number of AT91SAM9263EK-Board */
  175. gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9263EK;
  176. /* adress of boot parameters */
  177. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  178. #ifdef CONFIG_CMD_NAND
  179. at91sam9263ek_nand_hw_init();
  180. #endif
  181. #ifdef CONFIG_USB_OHCI_NEW
  182. at91_uhp_hw_init();
  183. #endif
  184. #ifdef CONFIG_LCD
  185. at91sam9263ek_lcd_hw_init();
  186. #endif
  187. return 0;
  188. }
  189. int dram_init(void)
  190. {
  191. gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
  192. CONFIG_SYS_SDRAM_SIZE);
  193. return 0;
  194. }
  195. #ifdef CONFIG_RESET_PHY_R
  196. void reset_phy(void)
  197. {
  198. }
  199. #endif