at91sam9263ek.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 <linux/sizes.h>
  11. #include <asm/arch/at91sam9263.h>
  12. #include <asm/arch/at91sam9_smc.h>
  13. #include <asm/arch/at91_common.h>
  14. #include <asm/arch/at91_matrix.h>
  15. #include <asm/arch/at91_pio.h>
  16. #include <asm/arch/clk.h>
  17. #include <asm/io.h>
  18. #include <asm/arch/gpio.h>
  19. #include <asm/arch/hardware.h>
  20. #include <lcd.h>
  21. #include <atmel_lcdc.h>
  22. #include <asm/mach-types.h>
  23. DECLARE_GLOBAL_DATA_PTR;
  24. /* ------------------------------------------------------------------------- */
  25. /*
  26. * Miscelaneous platform dependent initialisations
  27. */
  28. #ifdef CONFIG_CMD_NAND
  29. static void at91sam9263ek_nand_hw_init(void)
  30. {
  31. unsigned long csa;
  32. at91_smc_t *smc = (at91_smc_t *) ATMEL_BASE_SMC0;
  33. at91_matrix_t *matrix = (at91_matrix_t *) ATMEL_BASE_MATRIX;
  34. /* Enable CS3 */
  35. csa = readl(&matrix->csa[0]) | AT91_MATRIX_CSA_EBI_CS3A;
  36. writel(csa, &matrix->csa[0]);
  37. /* Enable CS3 */
  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_PIOA);
  57. at91_periph_clk_enable(ATMEL_ID_PIOCDE);
  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. }
  63. #endif
  64. #ifdef CONFIG_LCD
  65. vidinfo_t panel_info = {
  66. .vl_col = 240,
  67. .vl_row = 320,
  68. .vl_clk = 4965000,
  69. .vl_sync = ATMEL_LCDC_INVLINE_INVERTED |
  70. ATMEL_LCDC_INVFRAME_INVERTED,
  71. .vl_bpix = 3,
  72. .vl_tft = 1,
  73. .vl_hsync_len = 5,
  74. .vl_left_margin = 1,
  75. .vl_right_margin = 33,
  76. .vl_vsync_len = 1,
  77. .vl_upper_margin = 1,
  78. .vl_lower_margin = 0,
  79. .mmio = ATMEL_BASE_LCDC,
  80. };
  81. void lcd_enable(void)
  82. {
  83. at91_set_pio_value(AT91_PIO_PORTA, 30, 1); /* power up */
  84. }
  85. void lcd_disable(void)
  86. {
  87. at91_set_pio_value(AT91_PIO_PORTA, 30, 0); /* power down */
  88. }
  89. static void at91sam9263ek_lcd_hw_init(void)
  90. {
  91. at91_set_a_periph(AT91_PIO_PORTC, 1, 0); /* LCDHSYNC */
  92. at91_set_a_periph(AT91_PIO_PORTC, 2, 0); /* LCDDOTCK */
  93. at91_set_a_periph(AT91_PIO_PORTC, 3, 0); /* LCDDEN */
  94. at91_set_b_periph(AT91_PIO_PORTB, 9, 0); /* LCDCC */
  95. at91_set_a_periph(AT91_PIO_PORTC, 6, 0); /* LCDD2 */
  96. at91_set_a_periph(AT91_PIO_PORTC, 7, 0); /* LCDD3 */
  97. at91_set_a_periph(AT91_PIO_PORTC, 8, 0); /* LCDD4 */
  98. at91_set_a_periph(AT91_PIO_PORTC, 9, 0); /* LCDD5 */
  99. at91_set_a_periph(AT91_PIO_PORTC, 10, 0); /* LCDD6 */
  100. at91_set_a_periph(AT91_PIO_PORTC, 11, 0); /* LCDD7 */
  101. at91_set_a_periph(AT91_PIO_PORTC, 14, 0); /* LCDD10 */
  102. at91_set_a_periph(AT91_PIO_PORTC, 15, 0); /* LCDD11 */
  103. at91_set_a_periph(AT91_PIO_PORTC, 16, 0); /* LCDD12 */
  104. at91_set_b_periph(AT91_PIO_PORTC, 12, 0); /* LCDD13 */
  105. at91_set_a_periph(AT91_PIO_PORTC, 18, 0); /* LCDD14 */
  106. at91_set_a_periph(AT91_PIO_PORTC, 19, 0); /* LCDD15 */
  107. at91_set_a_periph(AT91_PIO_PORTC, 22, 0); /* LCDD18 */
  108. at91_set_a_periph(AT91_PIO_PORTC, 23, 0); /* LCDD19 */
  109. at91_set_a_periph(AT91_PIO_PORTC, 24, 0); /* LCDD20 */
  110. at91_set_b_periph(AT91_PIO_PORTC, 17, 0); /* LCDD21 */
  111. at91_set_a_periph(AT91_PIO_PORTC, 26, 0); /* LCDD22 */
  112. at91_set_a_periph(AT91_PIO_PORTC, 27, 0); /* LCDD23 */
  113. at91_periph_clk_enable(ATMEL_ID_LCDC);
  114. gd->fb_base = ATMEL_BASE_SRAM0;
  115. }
  116. #ifdef CONFIG_LCD_INFO
  117. #include <nand.h>
  118. #include <version.h>
  119. #ifdef CONFIG_MTD_NOR_FLASH
  120. extern flash_info_t flash_info[];
  121. #endif
  122. void lcd_show_board_info(void)
  123. {
  124. ulong dram_size, nand_size;
  125. #ifdef CONFIG_MTD_NOR_FLASH
  126. ulong flash_size;
  127. #endif
  128. int i;
  129. char temp[32];
  130. lcd_printf ("%s\n", U_BOOT_VERSION);
  131. lcd_printf ("(C) 2008 ATMEL Corp\n");
  132. lcd_printf ("at91support@atmel.com\n");
  133. lcd_printf ("%s CPU at %s MHz\n",
  134. ATMEL_CPU_NAME,
  135. strmhz(temp, get_cpu_clk_rate()));
  136. dram_size = 0;
  137. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
  138. dram_size += gd->bd->bi_dram[i].size;
  139. nand_size = 0;
  140. for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
  141. nand_size += get_nand_dev_by_index(i)->size;
  142. #ifdef CONFIG_MTD_NOR_FLASH
  143. flash_size = 0;
  144. for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++)
  145. flash_size += flash_info[i].size;
  146. #endif
  147. lcd_printf (" %ld MB SDRAM, %ld MB NAND",
  148. dram_size >> 20,
  149. nand_size >> 20 );
  150. #ifdef CONFIG_MTD_NOR_FLASH
  151. lcd_printf (",\n %ld MB NOR",
  152. flash_size >> 20);
  153. #endif
  154. lcd_puts ("\n");
  155. }
  156. #endif /* CONFIG_LCD_INFO */
  157. #endif
  158. #ifdef CONFIG_DEBUG_UART_BOARD_INIT
  159. void board_debug_uart_init(void)
  160. {
  161. at91_seriald_hw_init();
  162. }
  163. #endif
  164. #ifdef CONFIG_BOARD_EARLY_INIT_F
  165. int board_early_init_f(void)
  166. {
  167. #ifdef CONFIG_DEBUG_UART
  168. debug_uart_init();
  169. #endif
  170. return 0;
  171. }
  172. #endif
  173. int board_init(void)
  174. {
  175. /* arch number of AT91SAM9263EK-Board */
  176. gd->bd->bi_arch_number = MACH_TYPE_AT91SAM9263EK;
  177. /* adress of boot parameters */
  178. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  179. #ifdef CONFIG_CMD_NAND
  180. at91sam9263ek_nand_hw_init();
  181. #endif
  182. #ifdef CONFIG_USB_OHCI_NEW
  183. at91_uhp_hw_init();
  184. #endif
  185. #ifdef CONFIG_LCD
  186. at91sam9263ek_lcd_hw_init();
  187. #endif
  188. return 0;
  189. }
  190. int dram_init(void)
  191. {
  192. gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
  193. CONFIG_SYS_SDRAM_SIZE);
  194. return 0;
  195. }
  196. #ifdef CONFIG_RESET_PHY_R
  197. void reset_phy(void)
  198. {
  199. }
  200. #endif