pm9261.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. * Copyright (C) 2008 Ronetix Ilko Iliev (www.ronetix.at)
  7. * Copyright (C) 2009 Jean-Christopher PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
  8. */
  9. #include <common.h>
  10. #include <linux/sizes.h>
  11. #include <asm/io.h>
  12. #include <asm/gpio.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/at91_matrix.h>
  17. #include <asm/arch/clk.h>
  18. #include <asm/arch/gpio.h>
  19. #include <lcd.h>
  20. #include <atmel_lcdc.h>
  21. #if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_DRIVER_DM9000)
  22. #include <net.h>
  23. #endif
  24. #include <netdev.h>
  25. #include <asm/mach-types.h>
  26. DECLARE_GLOBAL_DATA_PTR;
  27. /* ------------------------------------------------------------------------- */
  28. /*
  29. * Miscelaneous platform dependent initialisations
  30. */
  31. #ifdef CONFIG_CMD_NAND
  32. static void pm9261_nand_hw_init(void)
  33. {
  34. unsigned long csa;
  35. struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
  36. struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
  37. /* Enable CS3 */
  38. csa = readl(&matrix->csa) | AT91_MATRIX_CSA_EBI_CS3A;
  39. writel(csa, &matrix->csa);
  40. /* Configure SMC CS3 for NAND/SmartMedia */
  41. writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
  42. AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
  43. &smc->cs[3].setup);
  44. writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
  45. AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
  46. &smc->cs[3].pulse);
  47. writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
  48. &smc->cs[3].cycle);
  49. writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
  50. AT91_SMC_MODE_EXNW_DISABLE |
  51. #ifdef CONFIG_SYS_NAND_DBW_16
  52. AT91_SMC_MODE_DBW_16 |
  53. #else /* CONFIG_SYS_NAND_DBW_8 */
  54. AT91_SMC_MODE_DBW_8 |
  55. #endif
  56. AT91_SMC_MODE_TDF_CYCLE(2),
  57. &smc->cs[3].mode);
  58. at91_periph_clk_enable(ATMEL_ID_PIOA);
  59. at91_periph_clk_enable(ATMEL_ID_PIOC);
  60. /* Configure RDY/BSY */
  61. gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
  62. /* Enable NandFlash */
  63. gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
  64. at91_set_a_periph(AT91_PIO_PORTC, 0, 0); /* NANDOE */
  65. at91_set_a_periph(AT91_PIO_PORTC, 1, 0); /* NANDWE */
  66. }
  67. #endif
  68. #ifdef CONFIG_DRIVER_DM9000
  69. static void pm9261_dm9000_hw_init(void)
  70. {
  71. struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
  72. /* Configure SMC CS2 for DM9000 */
  73. writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
  74. AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
  75. &smc->cs[2].setup);
  76. writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(8) |
  77. AT91_SMC_PULSE_NRD(4) | AT91_SMC_PULSE_NCS_RD(8),
  78. &smc->cs[2].pulse);
  79. writel(AT91_SMC_CYCLE_NWE(16) | AT91_SMC_CYCLE_NRD(16),
  80. &smc->cs[2].cycle);
  81. writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
  82. AT91_SMC_MODE_EXNW_DISABLE |
  83. AT91_SMC_MODE_BAT | AT91_SMC_MODE_DBW_16 |
  84. AT91_SMC_MODE_TDF_CYCLE(1),
  85. &smc->cs[2].mode);
  86. /* Configure Interrupt pin as input, no pull-up */
  87. at91_periph_clk_enable(ATMEL_ID_PIOA);
  88. at91_set_pio_input(AT91_PIO_PORTA, 24, 0);
  89. }
  90. #endif
  91. #ifdef CONFIG_LCD
  92. vidinfo_t panel_info = {
  93. .vl_col = 240,
  94. .vl_row = 320,
  95. .vl_clk = 4965000,
  96. .vl_sync = ATMEL_LCDC_INVLINE_INVERTED |
  97. ATMEL_LCDC_INVFRAME_INVERTED,
  98. .vl_bpix = 3,
  99. .vl_tft = 1,
  100. .vl_hsync_len = 5,
  101. .vl_left_margin = 1,
  102. .vl_right_margin = 33,
  103. .vl_vsync_len = 1,
  104. .vl_upper_margin = 1,
  105. .vl_lower_margin = 0,
  106. .mmio = ATMEL_BASE_LCDC,
  107. };
  108. void lcd_enable(void)
  109. {
  110. at91_set_pio_value(AT91_PIO_PORTA, 22, 0); /* power up */
  111. }
  112. void lcd_disable(void)
  113. {
  114. at91_set_pio_value(AT91_PIO_PORTA, 22, 1); /* power down */
  115. }
  116. static void pm9261_lcd_hw_init(void)
  117. {
  118. at91_set_a_periph(AT91_PIO_PORTB, 1, 0); /* LCDHSYNC */
  119. at91_set_a_periph(AT91_PIO_PORTB, 2, 0); /* LCDDOTCK */
  120. at91_set_a_periph(AT91_PIO_PORTB, 3, 0); /* LCDDEN */
  121. at91_set_a_periph(AT91_PIO_PORTB, 4, 0); /* LCDCC */
  122. at91_set_a_periph(AT91_PIO_PORTB, 7, 0); /* LCDD2 */
  123. at91_set_a_periph(AT91_PIO_PORTB, 8, 0); /* LCDD3 */
  124. at91_set_a_periph(AT91_PIO_PORTB, 9, 0); /* LCDD4 */
  125. at91_set_a_periph(AT91_PIO_PORTB, 10, 0); /* LCDD5 */
  126. at91_set_a_periph(AT91_PIO_PORTB, 11, 0); /* LCDD6 */
  127. at91_set_a_periph(AT91_PIO_PORTB, 12, 0); /* LCDD7 */
  128. at91_set_a_periph(AT91_PIO_PORTB, 15, 0); /* LCDD10 */
  129. at91_set_a_periph(AT91_PIO_PORTB, 16, 0); /* LCDD11 */
  130. at91_set_a_periph(AT91_PIO_PORTB, 17, 0); /* LCDD12 */
  131. at91_set_a_periph(AT91_PIO_PORTB, 18, 0); /* LCDD13 */
  132. at91_set_a_periph(AT91_PIO_PORTB, 19, 0); /* LCDD14 */
  133. at91_set_a_periph(AT91_PIO_PORTB, 20, 0); /* LCDD15 */
  134. at91_set_b_periph(AT91_PIO_PORTB, 23, 0); /* LCDD18 */
  135. at91_set_b_periph(AT91_PIO_PORTB, 24, 0); /* LCDD19 */
  136. at91_set_b_periph(AT91_PIO_PORTB, 25, 0); /* LCDD20 */
  137. at91_set_b_periph(AT91_PIO_PORTB, 26, 0); /* LCDD21 */
  138. at91_set_b_periph(AT91_PIO_PORTB, 27, 0); /* LCDD22 */
  139. at91_set_b_periph(AT91_PIO_PORTB, 28, 0); /* LCDD23 */
  140. at91_system_clk_enable(AT91_PMC_HCK1);
  141. gd->fb_base = ATMEL_BASE_SRAM;
  142. }
  143. #ifdef CONFIG_LCD_INFO
  144. #include <nand.h>
  145. #include <version.h>
  146. extern flash_info_t flash_info[];
  147. void lcd_show_board_info(void)
  148. {
  149. ulong dram_size, nand_size, flash_size;
  150. int i;
  151. char temp[32];
  152. lcd_printf ("%s\n", U_BOOT_VERSION);
  153. lcd_printf ("(C) 2009 Ronetix GmbH\n");
  154. lcd_printf ("support@ronetix.at\n");
  155. lcd_printf ("%s CPU at %s MHz",
  156. CONFIG_SYS_AT91_CPU_NAME,
  157. strmhz(temp, get_cpu_clk_rate()));
  158. dram_size = 0;
  159. for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
  160. dram_size += gd->bd->bi_dram[i].size;
  161. nand_size = 0;
  162. for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
  163. nand_size += get_nand_dev_by_index(i)->size;
  164. flash_size = 0;
  165. for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++)
  166. flash_size += flash_info[i].size;
  167. lcd_printf ("%ld MB SDRAM, %ld MB NAND\n%ld MB NOR Flash\n"
  168. "%ld MB DataFlash\n",
  169. dram_size >> 20,
  170. nand_size >> 20,
  171. flash_size >> 20);
  172. }
  173. #endif /* CONFIG_LCD_INFO */
  174. #endif /* CONFIG_LCD */
  175. int board_early_init_f(void)
  176. {
  177. return 0;
  178. }
  179. int board_init(void)
  180. {
  181. /* arch number of PM9261-Board */
  182. gd->bd->bi_arch_number = MACH_TYPE_PM9261;
  183. /* adress of boot parameters */
  184. gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
  185. #ifdef CONFIG_CMD_NAND
  186. pm9261_nand_hw_init();
  187. #endif
  188. #ifdef CONFIG_DRIVER_DM9000
  189. pm9261_dm9000_hw_init();
  190. #endif
  191. #ifdef CONFIG_LCD
  192. pm9261_lcd_hw_init();
  193. #endif
  194. return 0;
  195. }
  196. #ifdef CONFIG_DRIVER_DM9000
  197. int board_eth_init(bd_t *bis)
  198. {
  199. return dm9000_initialize(bis);
  200. }
  201. #endif
  202. int dram_init(void)
  203. {
  204. /* dram_init must store complete ramsize in gd->ram_size */
  205. gd->ram_size = get_ram_size((void *)PHYS_SDRAM,
  206. PHYS_SDRAM_SIZE);
  207. return 0;
  208. }
  209. int dram_init_banksize(void)
  210. {
  211. gd->bd->bi_dram[0].start = PHYS_SDRAM;
  212. gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
  213. return 0;
  214. }
  215. #ifdef CONFIG_RESET_PHY_R
  216. void reset_phy(void)
  217. {
  218. #ifdef CONFIG_DRIVER_DM9000
  219. /*
  220. * Initialize ethernet HW addr prior to starting Linux,
  221. * needed for nfsroot
  222. */
  223. eth_init();
  224. #endif
  225. }
  226. #endif
  227. #ifdef CONFIG_DISPLAY_BOARDINFO
  228. int checkboard (void)
  229. {
  230. char buf[32];
  231. printf ("Board : Ronetix PM9261\n");
  232. printf ("Crystal frequency: %8s MHz\n",
  233. strmhz(buf, get_main_clk_rate()));
  234. printf ("CPU clock : %8s MHz\n",
  235. strmhz(buf, get_cpu_clk_rate()));
  236. printf ("Master clock : %8s MHz\n",
  237. strmhz(buf, get_mck_clk_rate()));
  238. return 0;
  239. }
  240. #endif