overo.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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/omap_gpmc.h>
  40. #include <asm/gpio.h>
  41. #include <asm/mach-types.h>
  42. #include "overo.h"
  43. DECLARE_GLOBAL_DATA_PTR;
  44. #define TWL4030_I2C_BUS 0
  45. #define EXPANSION_EEPROM_I2C_BUS 2
  46. #define EXPANSION_EEPROM_I2C_ADDRESS 0x51
  47. #define GUMSTIX_SUMMIT 0x01000200
  48. #define GUMSTIX_TOBI 0x02000200
  49. #define GUMSTIX_TOBI_DUO 0x03000200
  50. #define GUMSTIX_PALO35 0x04000200
  51. #define GUMSTIX_PALO43 0x05000200
  52. #define GUMSTIX_CHESTNUT43 0x06000200
  53. #define GUMSTIX_PINTO 0x07000200
  54. #define GUMSTIX_GALLOP43 0x08000200
  55. #define ETTUS_USRP_E 0x01000300
  56. #define GUMSTIX_NO_EEPROM 0xffffffff
  57. static struct {
  58. unsigned int device_vendor;
  59. unsigned char revision;
  60. unsigned char content;
  61. char fab_revision[8];
  62. char env_var[16];
  63. char env_setting[64];
  64. } expansion_config;
  65. #if defined(CONFIG_CMD_NET)
  66. static void setup_net_chip(void);
  67. #endif
  68. /* GPMC definitions for LAN9221 chips on Tobi expansion boards */
  69. static const u32 gpmc_lan_config[] = {
  70. NET_LAN9221_GPMC_CONFIG1,
  71. NET_LAN9221_GPMC_CONFIG2,
  72. NET_LAN9221_GPMC_CONFIG3,
  73. NET_LAN9221_GPMC_CONFIG4,
  74. NET_LAN9221_GPMC_CONFIG5,
  75. NET_LAN9221_GPMC_CONFIG6,
  76. /*CONFIG7- computed as params */
  77. };
  78. /*
  79. * Routine: board_init
  80. * Description: Early hardware init.
  81. */
  82. int board_init(void)
  83. {
  84. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  85. /* board id for Linux */
  86. gd->bd->bi_arch_number = MACH_TYPE_OVERO;
  87. /* boot param addr */
  88. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  89. return 0;
  90. }
  91. /*
  92. * Routine: get_board_revision
  93. * Description: Returns the board revision
  94. */
  95. int get_board_revision(void)
  96. {
  97. int revision;
  98. if (!gpio_request(112, "") &&
  99. !gpio_request(113, "") &&
  100. !gpio_request(115, "")) {
  101. gpio_direction_input(112);
  102. gpio_direction_input(113);
  103. gpio_direction_input(115);
  104. revision = gpio_get_value(115) << 2 |
  105. gpio_get_value(113) << 1 |
  106. gpio_get_value(112);
  107. } else {
  108. printf("Error: unable to acquire board revision GPIOs\n");
  109. revision = -1;
  110. }
  111. return revision;
  112. }
  113. /*
  114. * Routine: get_sdio2_config
  115. * Description: Return information about the wifi module connection
  116. * Returns 0 if the module connects though a level translator
  117. * Returns 1 if the module connects directly
  118. */
  119. int get_sdio2_config(void)
  120. {
  121. int sdio_direct;
  122. if (!gpio_request(130, "") && !gpio_request(139, "")) {
  123. gpio_direction_output(130, 0);
  124. gpio_direction_input(139);
  125. sdio_direct = 1;
  126. gpio_set_value(130, 0);
  127. if (gpio_get_value(139) == 0) {
  128. gpio_set_value(130, 1);
  129. if (gpio_get_value(139) == 1)
  130. sdio_direct = 0;
  131. }
  132. gpio_direction_input(130);
  133. } else {
  134. printf("Error: unable to acquire sdio2 clk GPIOs\n");
  135. sdio_direct = -1;
  136. }
  137. return sdio_direct;
  138. }
  139. /*
  140. * Routine: get_expansion_id
  141. * Description: This function checks for expansion board by checking I2C
  142. * bus 2 for the availability of an AT24C01B serial EEPROM.
  143. * returns the device_vendor field from the EEPROM
  144. */
  145. unsigned int get_expansion_id(void)
  146. {
  147. i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
  148. /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */
  149. if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
  150. i2c_set_bus_num(TWL4030_I2C_BUS);
  151. return GUMSTIX_NO_EEPROM;
  152. }
  153. /* read configuration data */
  154. i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
  155. sizeof(expansion_config));
  156. i2c_set_bus_num(TWL4030_I2C_BUS);
  157. return expansion_config.device_vendor;
  158. }
  159. /*
  160. * Routine: misc_init_r
  161. * Description: Configure board specific parts
  162. */
  163. int misc_init_r(void)
  164. {
  165. twl4030_power_init();
  166. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  167. #if defined(CONFIG_CMD_NET)
  168. setup_net_chip();
  169. #endif
  170. printf("Board revision: %d\n", get_board_revision());
  171. switch (get_sdio2_config()) {
  172. case 0:
  173. printf("Tranceiver detected on mmc2\n");
  174. MUX_OVERO_SDIO2_TRANSCEIVER();
  175. break;
  176. case 1:
  177. printf("Direct connection on mmc2\n");
  178. MUX_OVERO_SDIO2_DIRECT();
  179. break;
  180. default:
  181. printf("Unable to detect mmc2 connection type\n");
  182. }
  183. switch (get_expansion_id()) {
  184. case GUMSTIX_SUMMIT:
  185. printf("Recognized Summit expansion board (rev %d %s)\n",
  186. expansion_config.revision,
  187. expansion_config.fab_revision);
  188. setenv("defaultdisplay", "dvi");
  189. break;
  190. case GUMSTIX_TOBI:
  191. printf("Recognized Tobi expansion board (rev %d %s)\n",
  192. expansion_config.revision,
  193. expansion_config.fab_revision);
  194. setenv("defaultdisplay", "dvi");
  195. break;
  196. case GUMSTIX_TOBI_DUO:
  197. printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
  198. expansion_config.revision,
  199. expansion_config.fab_revision);
  200. /* second lan chip */
  201. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4],
  202. 0x2B000000, GPMC_SIZE_16M);
  203. break;
  204. case GUMSTIX_PALO35:
  205. printf("Recognized Palo35 expansion board (rev %d %s)\n",
  206. expansion_config.revision,
  207. expansion_config.fab_revision);
  208. setenv("defaultdisplay", "lcd35");
  209. break;
  210. case GUMSTIX_PALO43:
  211. printf("Recognized Palo43 expansion board (rev %d %s)\n",
  212. expansion_config.revision,
  213. expansion_config.fab_revision);
  214. setenv("defaultdisplay", "lcd43");
  215. break;
  216. case GUMSTIX_CHESTNUT43:
  217. printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
  218. expansion_config.revision,
  219. expansion_config.fab_revision);
  220. setenv("defaultdisplay", "lcd43");
  221. break;
  222. case GUMSTIX_PINTO:
  223. printf("Recognized Pinto expansion board (rev %d %s)\n",
  224. expansion_config.revision,
  225. expansion_config.fab_revision);
  226. break;
  227. case GUMSTIX_GALLOP43:
  228. printf("Recognized Gallop43 expansion board (rev %d %s)\n",
  229. expansion_config.revision,
  230. expansion_config.fab_revision);
  231. setenv("defaultdisplay", "lcd43");
  232. break;
  233. case ETTUS_USRP_E:
  234. printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
  235. expansion_config.revision,
  236. expansion_config.fab_revision);
  237. MUX_USRP_E();
  238. setenv("defaultdisplay", "dvi");
  239. break;
  240. case GUMSTIX_NO_EEPROM:
  241. printf("No EEPROM on expansion board\n");
  242. break;
  243. default:
  244. printf("Unrecognized expansion board\n");
  245. }
  246. if (expansion_config.content == 1)
  247. setenv(expansion_config.env_var, expansion_config.env_setting);
  248. dieid_num_r();
  249. return 0;
  250. }
  251. /*
  252. * Routine: set_muxconf_regs
  253. * Description: Setting up the configuration Mux registers specific to the
  254. * hardware. Many pins need to be moved from protect to primary
  255. * mode.
  256. */
  257. void set_muxconf_regs(void)
  258. {
  259. MUX_OVERO();
  260. }
  261. #if defined(CONFIG_CMD_NET)
  262. /*
  263. * Routine: setup_net_chip
  264. * Description: Setting up the configuration GPMC registers specific to the
  265. * Ethernet hardware.
  266. */
  267. static void setup_net_chip(void)
  268. {
  269. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  270. /* first lan chip */
  271. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
  272. GPMC_SIZE_16M);
  273. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  274. writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  275. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  276. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  277. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  278. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  279. &ctrl_base->gpmc_nadv_ale);
  280. /* Make GPIO 64 as output pin and send a magic pulse through it */
  281. if (!gpio_request(64, "")) {
  282. gpio_direction_output(64, 0);
  283. gpio_set_value(64, 1);
  284. udelay(1);
  285. gpio_set_value(64, 0);
  286. udelay(1);
  287. gpio_set_value(64, 1);
  288. }
  289. }
  290. #endif
  291. int board_eth_init(bd_t *bis)
  292. {
  293. int rc = 0;
  294. #ifdef CONFIG_SMC911X
  295. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  296. #endif
  297. return rc;
  298. }
  299. #ifdef CONFIG_GENERIC_MMC
  300. int board_mmc_init(bd_t *bis)
  301. {
  302. omap_mmc_init(0);
  303. return 0;
  304. }
  305. #endif