devkit8000.c 4.5 KB

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