overo.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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/mmc_host_def.h>
  36. #include <asm/arch/mux.h>
  37. #include <asm/arch/mem.h>
  38. #include <asm/arch/sys_proto.h>
  39. #include <asm/arch/gpio.h>
  40. #include <asm/mach-types.h>
  41. #include "overo.h"
  42. #if defined(CONFIG_CMD_NET)
  43. static void setup_net_chip(void);
  44. #endif
  45. /* GPMC definitions for LAN9221 chips on Tobi expansion boards */
  46. static const u32 gpmc_lan_config[] = {
  47. NET_LAN9221_GPMC_CONFIG1,
  48. NET_LAN9221_GPMC_CONFIG2,
  49. NET_LAN9221_GPMC_CONFIG3,
  50. NET_LAN9221_GPMC_CONFIG4,
  51. NET_LAN9221_GPMC_CONFIG5,
  52. NET_LAN9221_GPMC_CONFIG6,
  53. /*CONFIG7- computed as params */
  54. };
  55. /*
  56. * Routine: board_init
  57. * Description: Early hardware init.
  58. */
  59. int board_init(void)
  60. {
  61. DECLARE_GLOBAL_DATA_PTR;
  62. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  63. /* board id for Linux */
  64. gd->bd->bi_arch_number = MACH_TYPE_OVERO;
  65. /* boot param addr */
  66. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  67. return 0;
  68. }
  69. /*
  70. * Routine: get_board_revision
  71. * Description: Returns the board revision
  72. */
  73. int get_board_revision(void)
  74. {
  75. int revision;
  76. if (!omap_request_gpio(112) &&
  77. !omap_request_gpio(113) &&
  78. !omap_request_gpio(115)) {
  79. omap_set_gpio_direction(112, 1);
  80. omap_set_gpio_direction(113, 1);
  81. omap_set_gpio_direction(115, 1);
  82. revision = omap_get_gpio_datain(115) << 2 |
  83. omap_get_gpio_datain(113) << 1 |
  84. omap_get_gpio_datain(112);
  85. omap_free_gpio(112);
  86. omap_free_gpio(113);
  87. omap_free_gpio(115);
  88. } else {
  89. printf("Error: unable to acquire board revision GPIOs\n");
  90. revision = -1;
  91. }
  92. return revision;
  93. }
  94. /*
  95. * Routine: get_sdio2_config
  96. * Description: Return information about the wifi module connection
  97. * Returns 0 if the module connects though a level translator
  98. * Returns 1 if the module connects directly
  99. */
  100. int get_sdio2_config(void)
  101. {
  102. int sdio_direct;
  103. if (!omap_request_gpio(130) && !omap_request_gpio(139)) {
  104. omap_set_gpio_direction(130, 0);
  105. omap_set_gpio_direction(139, 1);
  106. sdio_direct = 1;
  107. omap_set_gpio_dataout(130, 0);
  108. if (omap_get_gpio_datain(139) == 0) {
  109. omap_set_gpio_dataout(130, 1);
  110. if (omap_get_gpio_datain(139) == 1)
  111. sdio_direct = 0;
  112. }
  113. omap_free_gpio(130);
  114. omap_free_gpio(139);
  115. } else {
  116. printf("Error: unable to acquire sdio2 clk GPIOs\n");
  117. sdio_direct = -1;
  118. }
  119. return sdio_direct;
  120. }
  121. /*
  122. * Routine: misc_init_r
  123. * Description: Configure board specific parts
  124. */
  125. int misc_init_r(void)
  126. {
  127. twl4030_power_init();
  128. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  129. #if defined(CONFIG_CMD_NET)
  130. setup_net_chip();
  131. #endif
  132. printf("Board revision: %d\n", get_board_revision());
  133. switch (get_sdio2_config()) {
  134. case 0:
  135. printf("Tranceiver detected on mmc2\n");
  136. MUX_OVERO_SDIO2_TRANSCEIVER();
  137. break;
  138. case 1:
  139. printf("Direct connection on mmc2\n");
  140. MUX_OVERO_SDIO2_DIRECT();
  141. break;
  142. default:
  143. printf("Unable to detect mmc2 connection type\n");
  144. }
  145. dieid_num_r();
  146. return 0;
  147. }
  148. /*
  149. * Routine: set_muxconf_regs
  150. * Description: Setting up the configuration Mux registers specific to the
  151. * hardware. Many pins need to be moved from protect to primary
  152. * mode.
  153. */
  154. void set_muxconf_regs(void)
  155. {
  156. MUX_OVERO();
  157. }
  158. #if defined(CONFIG_CMD_NET)
  159. /*
  160. * Routine: setup_net_chip
  161. * Description: Setting up the configuration GPMC registers specific to the
  162. * Ethernet hardware.
  163. */
  164. static void setup_net_chip(void)
  165. {
  166. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  167. /* first lan chip */
  168. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
  169. GPMC_SIZE_16M);
  170. /* second lan chip */
  171. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], 0x2B000000,
  172. GPMC_SIZE_16M);
  173. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  174. writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  175. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  176. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  177. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  178. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  179. &ctrl_base->gpmc_nadv_ale);
  180. /* Make GPIO 64 as output pin and send a magic pulse through it */
  181. if (!omap_request_gpio(64)) {
  182. omap_set_gpio_direction(64, 0);
  183. omap_set_gpio_dataout(64, 1);
  184. udelay(1);
  185. omap_set_gpio_dataout(64, 0);
  186. udelay(1);
  187. omap_set_gpio_dataout(64, 1);
  188. }
  189. }
  190. #endif
  191. int board_eth_init(bd_t *bis)
  192. {
  193. int rc = 0;
  194. #ifdef CONFIG_SMC911X
  195. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  196. #endif
  197. return rc;
  198. }
  199. #ifdef CONFIG_GENERIC_MMC
  200. int board_mmc_init(bd_t *bis)
  201. {
  202. omap_mmc_init(0);
  203. return 0;
  204. }
  205. #endif