igep00x0.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 <twl4030.h>
  25. #include <netdev.h>
  26. #include <asm/gpio.h>
  27. #include <asm/arch/omap_gpmc.h>
  28. #include <asm/io.h>
  29. #include <asm/arch/mem.h>
  30. #include <asm/arch/mmc_host_def.h>
  31. #include <asm/arch/mux.h>
  32. #include <asm/arch/sys_proto.h>
  33. #include <asm/mach-types.h>
  34. #include "igep00x0.h"
  35. DECLARE_GLOBAL_DATA_PTR;
  36. #if defined(CONFIG_CMD_NET)
  37. /* GPMC definitions for LAN9221 chips */
  38. static const u32 gpmc_lan_config[] = {
  39. NET_LAN9221_GPMC_CONFIG1,
  40. NET_LAN9221_GPMC_CONFIG2,
  41. NET_LAN9221_GPMC_CONFIG3,
  42. NET_LAN9221_GPMC_CONFIG4,
  43. NET_LAN9221_GPMC_CONFIG5,
  44. NET_LAN9221_GPMC_CONFIG6,
  45. };
  46. #endif
  47. /*
  48. * Routine: board_init
  49. * Description: Early hardware init.
  50. */
  51. int board_init(void)
  52. {
  53. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  54. /* boot param addr */
  55. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  56. return 0;
  57. }
  58. #if defined(CONFIG_SHOW_BOOT_PROGRESS) && !defined(CONFIG_SPL_BUILD)
  59. void show_boot_progress(int val)
  60. {
  61. if (val < 0) {
  62. /* something went wrong */
  63. return;
  64. }
  65. if (!gpio_request(IGEP00X0_GPIO_LED, ""))
  66. gpio_direction_output(IGEP00X0_GPIO_LED, 1);
  67. }
  68. #endif
  69. #ifdef CONFIG_SPL_BUILD
  70. /*
  71. * Routine: omap_rev_string
  72. * Description: For SPL builds output board rev
  73. */
  74. void omap_rev_string(void)
  75. {
  76. }
  77. /*
  78. * Routine: get_board_mem_timings
  79. * Description: If we use SPL then there is no x-loader nor config header
  80. * so we have to setup the DDR timings ourself on both banks.
  81. */
  82. void get_board_mem_timings(struct board_sdrc_timings *timings)
  83. {
  84. timings->mr = MICRON_V_MR_165;
  85. #ifdef CONFIG_BOOT_NAND
  86. timings->mcfg = MICRON_V_MCFG_200(256 << 20);
  87. timings->ctrla = MICRON_V_ACTIMA_200;
  88. timings->ctrlb = MICRON_V_ACTIMB_200;
  89. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
  90. #else
  91. if (get_cpu_family() == CPU_OMAP34XX) {
  92. timings->mcfg = NUMONYX_V_MCFG_165(256 << 20);
  93. timings->ctrla = NUMONYX_V_ACTIMA_165;
  94. timings->ctrlb = NUMONYX_V_ACTIMB_165;
  95. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  96. } else {
  97. timings->mcfg = NUMONYX_V_MCFG_200(256 << 20);
  98. timings->ctrla = NUMONYX_V_ACTIMA_200;
  99. timings->ctrlb = NUMONYX_V_ACTIMB_200;
  100. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
  101. }
  102. #endif
  103. }
  104. #endif
  105. #if defined(CONFIG_CMD_NET)
  106. /*
  107. * Routine: setup_net_chip
  108. * Description: Setting up the configuration GPMC registers specific to the
  109. * Ethernet hardware.
  110. */
  111. static void setup_net_chip(void)
  112. {
  113. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  114. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
  115. GPMC_SIZE_16M);
  116. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  117. writew(readw(&ctrl_base->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  118. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  119. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  120. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  121. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  122. &ctrl_base->gpmc_nadv_ale);
  123. /* Make GPIO 64 as output pin and send a magic pulse through it */
  124. if (!gpio_request(64, "")) {
  125. gpio_direction_output(64, 0);
  126. gpio_set_value(64, 1);
  127. udelay(1);
  128. gpio_set_value(64, 0);
  129. udelay(1);
  130. gpio_set_value(64, 1);
  131. }
  132. }
  133. #else
  134. static inline void setup_net_chip(void) {}
  135. #endif
  136. #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
  137. int board_mmc_init(bd_t *bis)
  138. {
  139. return omap_mmc_init(0, 0, 0, -1);
  140. }
  141. #endif
  142. /*
  143. * Routine: misc_init_r
  144. * Description: Configure board specific parts
  145. */
  146. int misc_init_r(void)
  147. {
  148. twl4030_power_init();
  149. setup_net_chip();
  150. dieid_num_r();
  151. return 0;
  152. }
  153. /*
  154. * Routine: set_muxconf_regs
  155. * Description: Setting up the configuration Mux registers specific to the
  156. * hardware. Many pins need to be moved from protect to primary
  157. * mode.
  158. */
  159. void set_muxconf_regs(void)
  160. {
  161. MUX_DEFAULT();
  162. #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0020)
  163. MUX_IGEP0020();
  164. #endif
  165. #if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0030)
  166. MUX_IGEP0030();
  167. #endif
  168. }
  169. #if defined(CONFIG_CMD_NET)
  170. int board_eth_init(bd_t *bis)
  171. {
  172. int rc = 0;
  173. #ifdef CONFIG_SMC911X
  174. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  175. #endif
  176. return rc;
  177. }
  178. #endif