igep0020.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * (C) Copyright 2010
  3. * ISEE 2007 SL, <www.iseebcn.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <netdev.h>
  25. #include <twl4030.h>
  26. #include <asm/io.h>
  27. #include <asm/gpio.h>
  28. #include <asm/arch/mem.h>
  29. #include <asm/arch/mmc_host_def.h>
  30. #include <asm/arch/mux.h>
  31. #include <asm/arch/sys_proto.h>
  32. #include <asm/arch/omap_gpmc.h>
  33. #include <asm/mach-types.h>
  34. #include "igep0020.h"
  35. DECLARE_GLOBAL_DATA_PTR;
  36. /* GPMC definitions for LAN9221 chips */
  37. static const u32 gpmc_lan_config[] = {
  38. NET_LAN9221_GPMC_CONFIG1,
  39. NET_LAN9221_GPMC_CONFIG2,
  40. NET_LAN9221_GPMC_CONFIG3,
  41. NET_LAN9221_GPMC_CONFIG4,
  42. NET_LAN9221_GPMC_CONFIG5,
  43. NET_LAN9221_GPMC_CONFIG6,
  44. };
  45. /*
  46. * Routine: board_init
  47. * Description: Early hardware init.
  48. */
  49. int board_init(void)
  50. {
  51. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  52. /* boot param addr */
  53. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  54. return 0;
  55. }
  56. #ifdef CONFIG_SPL_BUILD
  57. /*
  58. * Routine: omap_rev_string
  59. * Description: For SPL builds output board rev
  60. */
  61. void omap_rev_string(void)
  62. {
  63. }
  64. /*
  65. * Routine: get_board_mem_timings
  66. * Description: If we use SPL then there is no x-loader nor config header
  67. * so we have to setup the DDR timings ourself on both banks.
  68. */
  69. void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
  70. u32 *mr)
  71. {
  72. *mr = MICRON_V_MR_165;
  73. #ifdef CONFIG_BOOT_NAND
  74. *mcfg = MICRON_V_MCFG_200(256 << 20);
  75. *ctrla = MICRON_V_ACTIMA_200;
  76. *ctrlb = MICRON_V_ACTIMB_200;
  77. *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
  78. #else
  79. if (get_cpu_family() == CPU_OMAP34XX) {
  80. *mcfg = NUMONYX_V_MCFG_165(256 << 20);
  81. *ctrla = NUMONYX_V_ACTIMA_165;
  82. *ctrlb = NUMONYX_V_ACTIMB_165;
  83. *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  84. } else {
  85. *mcfg = NUMONYX_V_MCFG_200(256 << 20);
  86. *ctrla = NUMONYX_V_ACTIMA_200;
  87. *ctrlb = NUMONYX_V_ACTIMB_200;
  88. *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
  89. }
  90. #endif
  91. }
  92. #endif
  93. /*
  94. * Routine: setup_net_chip
  95. * Description: Setting up the configuration GPMC registers specific to the
  96. * Ethernet hardware.
  97. */
  98. #if defined(CONFIG_CMD_NET)
  99. static void setup_net_chip(void)
  100. {
  101. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  102. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
  103. GPMC_SIZE_16M);
  104. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  105. writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  106. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  107. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  108. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  109. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  110. &ctrl_base->gpmc_nadv_ale);
  111. /* Make GPIO 64 as output pin and send a magic pulse through it */
  112. if (!gpio_request(64, "")) {
  113. gpio_direction_output(64, 0);
  114. gpio_set_value(64, 1);
  115. udelay(1);
  116. gpio_set_value(64, 0);
  117. udelay(1);
  118. gpio_set_value(64, 1);
  119. }
  120. }
  121. #endif
  122. #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
  123. int board_mmc_init(bd_t *bis)
  124. {
  125. omap_mmc_init(0, 0, 0);
  126. return 0;
  127. }
  128. #endif
  129. /*
  130. * Routine: misc_init_r
  131. * Description: Configure board specific parts
  132. */
  133. int misc_init_r(void)
  134. {
  135. twl4030_power_init();
  136. #if defined(CONFIG_CMD_NET)
  137. setup_net_chip();
  138. #endif
  139. dieid_num_r();
  140. return 0;
  141. }
  142. /*
  143. * Routine: set_muxconf_regs
  144. * Description: Setting up the configuration Mux registers specific to the
  145. * hardware. Many pins need to be moved from protect to primary
  146. * mode.
  147. */
  148. void set_muxconf_regs(void)
  149. {
  150. MUX_DEFAULT();
  151. }
  152. int board_eth_init(bd_t *bis)
  153. {
  154. int rc = 0;
  155. #ifdef CONFIG_SMC911X
  156. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  157. #endif
  158. return rc;
  159. }