overo.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Maintainer : Steve Sakoman <steve@sakoman.com>
  3. *
  4. * Derived from Beagle Board, 3430 SDP, and OMAP3EVM code by
  5. * Richard Woodruff <r-woodruff2@ti.com>
  6. * Syed Mohammed Khasim <khasim@ti.com>
  7. * Sunil Kumar <sunilsaini05@gmail.com>
  8. * Shashi Ranjan <shashiranjanmca05@gmail.com>
  9. *
  10. * (C) Copyright 2004-2008
  11. * Texas Instruments, <www.ti.com>
  12. *
  13. * See file CREDITS for list of people who contributed to this
  14. * project.
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License as
  18. * published by the Free Software Foundation; either version 2 of
  19. * the License, or (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  29. * MA 02111-1307 USA
  30. */
  31. #include <common.h>
  32. #include <netdev.h>
  33. #include <twl4030.h>
  34. #include <asm/io.h>
  35. #include <asm/arch/mux.h>
  36. #include <asm/arch/mem.h>
  37. #include <asm/arch/sys_proto.h>
  38. #include <asm/arch/gpio.h>
  39. #include <asm/mach-types.h>
  40. #include "overo.h"
  41. #if defined(CONFIG_CMD_NET)
  42. static void setup_net_chip(void);
  43. #endif
  44. /* GPMC definitions for LAN9221 chips on Tobi expansion boards */
  45. static const u32 gpmc_lan_config[] = {
  46. NET_LAN9221_GPMC_CONFIG1,
  47. NET_LAN9221_GPMC_CONFIG2,
  48. NET_LAN9221_GPMC_CONFIG3,
  49. NET_LAN9221_GPMC_CONFIG4,
  50. NET_LAN9221_GPMC_CONFIG5,
  51. NET_LAN9221_GPMC_CONFIG6,
  52. /*CONFIG7- computed as params */
  53. };
  54. /*
  55. * Routine: board_init
  56. * Description: Early hardware init.
  57. */
  58. int board_init(void)
  59. {
  60. DECLARE_GLOBAL_DATA_PTR;
  61. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  62. /* board id for Linux */
  63. gd->bd->bi_arch_number = MACH_TYPE_OVERO;
  64. /* boot param addr */
  65. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  66. return 0;
  67. }
  68. /*
  69. * Routine: get_board_revision
  70. * Description: Returns the board revision
  71. */
  72. int get_board_revision(void)
  73. {
  74. int revision;
  75. if (!omap_request_gpio(112) &&
  76. !omap_request_gpio(113) &&
  77. !omap_request_gpio(115)) {
  78. omap_set_gpio_direction(112, 1);
  79. omap_set_gpio_direction(113, 1);
  80. omap_set_gpio_direction(115, 1);
  81. revision = omap_get_gpio_datain(115) << 2 |
  82. omap_get_gpio_datain(113) << 1 |
  83. omap_get_gpio_datain(112);
  84. omap_free_gpio(112);
  85. omap_free_gpio(113);
  86. omap_free_gpio(115);
  87. } else {
  88. printf("Error: unable to acquire board revision GPIOs\n");
  89. revision = -1;
  90. }
  91. return revision;
  92. }
  93. /*
  94. * Routine: misc_init_r
  95. * Description: Configure board specific parts
  96. */
  97. int misc_init_r(void)
  98. {
  99. twl4030_power_init();
  100. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  101. #if defined(CONFIG_CMD_NET)
  102. setup_net_chip();
  103. #endif
  104. printf("Board revision: %d\n", get_board_revision());
  105. dieid_num_r();
  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_OVERO();
  117. }
  118. #if defined(CONFIG_CMD_NET)
  119. /*
  120. * Routine: setup_net_chip
  121. * Description: Setting up the configuration GPMC registers specific to the
  122. * Ethernet hardware.
  123. */
  124. static void setup_net_chip(void)
  125. {
  126. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  127. /* first lan chip */
  128. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
  129. GPMC_SIZE_16M);
  130. /* second lan chip */
  131. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], 0x2B000000,
  132. GPMC_SIZE_16M);
  133. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  134. writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  135. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  136. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  137. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  138. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  139. &ctrl_base->gpmc_nadv_ale);
  140. /* Make GPIO 64 as output pin and send a magic pulse through it */
  141. if (!omap_request_gpio(64)) {
  142. omap_set_gpio_direction(64, 0);
  143. omap_set_gpio_dataout(64, 1);
  144. udelay(1);
  145. omap_set_gpio_dataout(64, 0);
  146. udelay(1);
  147. omap_set_gpio_dataout(64, 1);
  148. }
  149. }
  150. #endif
  151. int board_eth_init(bd_t *bis)
  152. {
  153. int rc = 0;
  154. #ifdef CONFIG_SMC911X
  155. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  156. #endif
  157. return rc;
  158. }