devkit8000.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2004-2008
  4. * Texas Instruments, <www.ti.com>
  5. *
  6. * Author :
  7. * Sunil Kumar <sunilsaini05@gmail.com>
  8. * Shashi Ranjan <shashiranjanmca05@gmail.com>
  9. *
  10. * (C) Copyright 2009
  11. * Frederik Kriewitz <frederik@kriewitz.eu>
  12. *
  13. * Derived from Beagle Board and 3430 SDP code by
  14. * Richard Woodruff <r-woodruff2@ti.com>
  15. * Syed Mohammed Khasim <khasim@ti.com>
  16. *
  17. */
  18. #include <common.h>
  19. #include <dm.h>
  20. #include <env.h>
  21. #include <malloc.h>
  22. #include <ns16550.h>
  23. #include <twl4030.h>
  24. #include <asm/io.h>
  25. #include <asm/arch/mmc_host_def.h>
  26. #include <asm/arch/mux.h>
  27. #include <asm/arch/sys_proto.h>
  28. #include <asm/arch/mem.h>
  29. #include <asm/mach-types.h>
  30. #include "devkit8000.h"
  31. #include <asm/gpio.h>
  32. #ifdef CONFIG_DRIVER_DM9000
  33. #include <net.h>
  34. #include <netdev.h>
  35. #endif
  36. DECLARE_GLOBAL_DATA_PTR;
  37. static u32 gpmc_net_config[GPMC_MAX_REG] = {
  38. NET_GPMC_CONFIG1,
  39. NET_GPMC_CONFIG2,
  40. NET_GPMC_CONFIG3,
  41. NET_GPMC_CONFIG4,
  42. NET_GPMC_CONFIG5,
  43. NET_GPMC_CONFIG6,
  44. 0
  45. };
  46. static const struct ns16550_platdata devkit8000_serial = {
  47. .base = OMAP34XX_UART3,
  48. .reg_shift = 2,
  49. .clock = V_NS16550_CLK,
  50. .fcr = UART_FCR_DEFVAL,
  51. };
  52. U_BOOT_DEVICE(devkit8000_uart) = {
  53. "ns16550_serial",
  54. &devkit8000_serial
  55. };
  56. /*
  57. * Routine: board_init
  58. * Description: Early hardware init.
  59. */
  60. int board_init(void)
  61. {
  62. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  63. /* board id for Linux */
  64. gd->bd->bi_arch_number = MACH_TYPE_DEVKIT8000;
  65. /* boot param addr */
  66. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  67. return 0;
  68. }
  69. /* Configure GPMC registers for DM9000 */
  70. static void gpmc_dm9000_config(void)
  71. {
  72. enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
  73. CONFIG_DM9000_BASE, GPMC_SIZE_16M);
  74. }
  75. /*
  76. * Routine: misc_init_r
  77. * Description: Configure board specific parts
  78. */
  79. int misc_init_r(void)
  80. {
  81. struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
  82. #ifdef CONFIG_DRIVER_DM9000
  83. uchar enetaddr[6];
  84. u32 die_id_0;
  85. #endif
  86. twl4030_power_init();
  87. #ifdef CONFIG_TWL4030_LED
  88. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  89. #endif
  90. #ifdef CONFIG_DRIVER_DM9000
  91. /* Configure GPMC registers for DM9000 */
  92. enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
  93. CONFIG_DM9000_BASE, GPMC_SIZE_16M);
  94. /* Use OMAP DIE_ID as MAC address */
  95. if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
  96. printf("ethaddr not set, using Die ID\n");
  97. die_id_0 = readl(&id_base->die_id_0);
  98. enetaddr[0] = 0x02; /* locally administered */
  99. enetaddr[1] = readl(&id_base->die_id_1) & 0xff;
  100. enetaddr[2] = (die_id_0 & 0xff000000) >> 24;
  101. enetaddr[3] = (die_id_0 & 0x00ff0000) >> 16;
  102. enetaddr[4] = (die_id_0 & 0x0000ff00) >> 8;
  103. enetaddr[5] = (die_id_0 & 0x000000ff);
  104. eth_env_set_enetaddr("ethaddr", enetaddr);
  105. }
  106. #endif
  107. omap_die_id_display();
  108. return 0;
  109. }
  110. /*
  111. * Routine: set_muxconf_regs
  112. * Description: Setting up the configuration Mux registers specific to the
  113. * hardware. Many pins need to be moved from protect to primary
  114. * mode.
  115. */
  116. void set_muxconf_regs(void)
  117. {
  118. MUX_DEVKIT8000();
  119. }
  120. #if defined(CONFIG_MMC)
  121. int board_mmc_init(bd_t *bis)
  122. {
  123. return omap_mmc_init(0, 0, 0, -1, -1);
  124. }
  125. #endif
  126. #if defined(CONFIG_MMC)
  127. void board_mmc_power_init(void)
  128. {
  129. twl4030_power_mmc_init(0);
  130. }
  131. #endif
  132. #if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD)
  133. /*
  134. * Routine: board_eth_init
  135. * Description: Setting up the Ethernet hardware.
  136. */
  137. int board_eth_init(bd_t *bis)
  138. {
  139. return dm9000_initialize(bis);
  140. }
  141. #endif
  142. #ifdef CONFIG_SPL_OS_BOOT
  143. /*
  144. * Do board specific preparation before SPL
  145. * Linux boot
  146. */
  147. void spl_board_prepare_for_linux(void)
  148. {
  149. gpmc_dm9000_config();
  150. }
  151. /*
  152. * devkit8000 specific implementation of spl_start_uboot()
  153. *
  154. * RETURN
  155. * 0 if the button is not pressed
  156. * 1 if the button is pressed
  157. */
  158. int spl_start_uboot(void)
  159. {
  160. int val = 0;
  161. if (!gpio_request(SPL_OS_BOOT_KEY, "U-Boot key")) {
  162. gpio_direction_input(SPL_OS_BOOT_KEY);
  163. val = gpio_get_value(SPL_OS_BOOT_KEY);
  164. gpio_free(SPL_OS_BOOT_KEY);
  165. }
  166. return !val;
  167. }
  168. #endif
  169. /*
  170. * Routine: get_board_mem_timings
  171. * Description: If we use SPL then there is no x-loader nor config header
  172. * so we have to setup the DDR timings ourself on the first bank. This
  173. * provides the timing values back to the function that configures
  174. * the memory. We have either one or two banks of 128MB DDR.
  175. */
  176. void get_board_mem_timings(struct board_sdrc_timings *timings)
  177. {
  178. /* General SDRC config */
  179. timings->mcfg = MICRON_V_MCFG_165(128 << 20);
  180. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  181. /* AC timings */
  182. timings->ctrla = MICRON_V_ACTIMA_165;
  183. timings->ctrlb = MICRON_V_ACTIMB_165;
  184. timings->mr = MICRON_V_MR_165;
  185. }