devkit8000.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. * See file CREDITS for list of people who contributed to this
  18. * project.
  19. *
  20. * This program is free software; you can redistribute it and/or
  21. * modify it under the terms of the GNU General Public License as
  22. * published by the Free Software Foundation; either version 2 of
  23. * the License, or (at your option) any later version.
  24. *
  25. * This program is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU General Public License
  31. * along with this program; if not, write to the Free Software
  32. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33. * MA 02111-1307 USA
  34. */
  35. #include <common.h>
  36. #include <twl4030.h>
  37. #include <asm/io.h>
  38. #include <asm/arch/mmc_host_def.h>
  39. #include <asm/arch/mux.h>
  40. #include <asm/arch/sys_proto.h>
  41. #include <asm/arch/mem.h>
  42. #include <asm/mach-types.h>
  43. #include "devkit8000.h"
  44. #include <asm/gpio.h>
  45. #ifdef CONFIG_DRIVER_DM9000
  46. #include <net.h>
  47. #include <netdev.h>
  48. #endif
  49. DECLARE_GLOBAL_DATA_PTR;
  50. static u32 gpmc_net_config[GPMC_MAX_REG] = {
  51. NET_GPMC_CONFIG1,
  52. NET_GPMC_CONFIG2,
  53. NET_GPMC_CONFIG3,
  54. NET_GPMC_CONFIG4,
  55. NET_GPMC_CONFIG5,
  56. NET_GPMC_CONFIG6,
  57. 0
  58. };
  59. /*
  60. * Routine: board_init
  61. * Description: Early hardware init.
  62. */
  63. int board_init(void)
  64. {
  65. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  66. /* board id for Linux */
  67. gd->bd->bi_arch_number = MACH_TYPE_DEVKIT8000;
  68. /* boot param addr */
  69. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  70. return 0;
  71. }
  72. /* Configure GPMC registers for DM9000 */
  73. static void gpmc_dm9000_config(void)
  74. {
  75. enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
  76. CONFIG_DM9000_BASE, GPMC_SIZE_16M);
  77. }
  78. /*
  79. * Routine: misc_init_r
  80. * Description: Configure board specific parts
  81. */
  82. int misc_init_r(void)
  83. {
  84. struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
  85. #ifdef CONFIG_DRIVER_DM9000
  86. uchar enetaddr[6];
  87. u32 die_id_0;
  88. #endif
  89. twl4030_power_init();
  90. #ifdef CONFIG_TWL4030_LED
  91. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  92. #endif
  93. #ifdef CONFIG_DRIVER_DM9000
  94. /* Configure GPMC registers for DM9000 */
  95. enable_gpmc_cs_config(gpmc_net_config, &gpmc_cfg->cs[6],
  96. CONFIG_DM9000_BASE, GPMC_SIZE_16M);
  97. /* Use OMAP DIE_ID as MAC address */
  98. if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
  99. printf("ethaddr not set, using Die ID\n");
  100. die_id_0 = readl(&id_base->die_id_0);
  101. enetaddr[0] = 0x02; /* locally administered */
  102. enetaddr[1] = readl(&id_base->die_id_1) & 0xff;
  103. enetaddr[2] = (die_id_0 & 0xff000000) >> 24;
  104. enetaddr[3] = (die_id_0 & 0x00ff0000) >> 16;
  105. enetaddr[4] = (die_id_0 & 0x0000ff00) >> 8;
  106. enetaddr[5] = (die_id_0 & 0x000000ff);
  107. eth_setenv_enetaddr("ethaddr", enetaddr);
  108. }
  109. #endif
  110. dieid_num_r();
  111. return 0;
  112. }
  113. /*
  114. * Routine: set_muxconf_regs
  115. * Description: Setting up the configuration Mux registers specific to the
  116. * hardware. Many pins need to be moved from protect to primary
  117. * mode.
  118. */
  119. void set_muxconf_regs(void)
  120. {
  121. MUX_DEVKIT8000();
  122. }
  123. #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
  124. int board_mmc_init(bd_t *bis)
  125. {
  126. return omap_mmc_init(0, 0, 0, -1, -1);
  127. }
  128. #endif
  129. #if defined(CONFIG_DRIVER_DM9000) & !defined(CONFIG_SPL_BUILD)
  130. /*
  131. * Routine: board_eth_init
  132. * Description: Setting up the Ethernet hardware.
  133. */
  134. int board_eth_init(bd_t *bis)
  135. {
  136. return dm9000_initialize(bis);
  137. }
  138. #endif
  139. #ifdef CONFIG_SPL_OS_BOOT
  140. /*
  141. * Do board specific preperation before SPL
  142. * Linux boot
  143. */
  144. void spl_board_prepare_for_linux(void)
  145. {
  146. gpmc_dm9000_config();
  147. }
  148. /*
  149. * devkit8000 specific implementation of spl_start_uboot()
  150. *
  151. * RETURN
  152. * 0 if the button is not pressed
  153. * 1 if the button is pressed
  154. */
  155. int spl_start_uboot(void)
  156. {
  157. int val = 0;
  158. if (!gpio_request(CONFIG_SPL_OS_BOOT_KEY, "U-Boot key")) {
  159. gpio_direction_input(CONFIG_SPL_OS_BOOT_KEY);
  160. val = gpio_get_value(CONFIG_SPL_OS_BOOT_KEY);
  161. gpio_free(CONFIG_SPL_OS_BOOT_KEY);
  162. }
  163. return !val;
  164. }
  165. #endif
  166. /*
  167. * Routine: get_board_mem_timings
  168. * Description: If we use SPL then there is no x-loader nor config header
  169. * so we have to setup the DDR timings ourself on the first bank. This
  170. * provides the timing values back to the function that configures
  171. * the memory. We have either one or two banks of 128MB DDR.
  172. */
  173. void get_board_mem_timings(struct board_sdrc_timings *timings)
  174. {
  175. /* General SDRC config */
  176. timings->mcfg = MICRON_V_MCFG_165(128 << 20);
  177. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  178. /* AC timings */
  179. timings->ctrla = MICRON_V_ACTIMA_165;
  180. timings->ctrlb = MICRON_V_ACTIMB_165;
  181. timings->mr = MICRON_V_MR_165;
  182. }