overo.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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. gpio_free(112);
  108. gpio_free(113);
  109. gpio_free(115);
  110. } else {
  111. printf("Error: unable to acquire board revision GPIOs\n");
  112. revision = -1;
  113. }
  114. return revision;
  115. }
  116. /*
  117. * Routine: get_sdio2_config
  118. * Description: Return information about the wifi module connection
  119. * Returns 0 if the module connects though a level translator
  120. * Returns 1 if the module connects directly
  121. */
  122. int get_sdio2_config(void)
  123. {
  124. int sdio_direct;
  125. if (!gpio_request(130, "") && !gpio_request(139, "")) {
  126. gpio_direction_output(130, 0);
  127. gpio_direction_input(139);
  128. sdio_direct = 1;
  129. gpio_set_value(130, 0);
  130. if (gpio_get_value(139) == 0) {
  131. gpio_set_value(130, 1);
  132. if (gpio_get_value(139) == 1)
  133. sdio_direct = 0;
  134. }
  135. gpio_free(130);
  136. gpio_free(139);
  137. } else {
  138. printf("Error: unable to acquire sdio2 clk GPIOs\n");
  139. sdio_direct = -1;
  140. }
  141. return sdio_direct;
  142. }
  143. /*
  144. * Routine: get_expansion_id
  145. * Description: This function checks for expansion board by checking I2C
  146. * bus 2 for the availability of an AT24C01B serial EEPROM.
  147. * returns the device_vendor field from the EEPROM
  148. */
  149. unsigned int get_expansion_id(void)
  150. {
  151. i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
  152. /* return GUMSTIX_NO_EEPROM if eeprom doesn't respond */
  153. if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
  154. i2c_set_bus_num(TWL4030_I2C_BUS);
  155. return GUMSTIX_NO_EEPROM;
  156. }
  157. /* read configuration data */
  158. i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
  159. sizeof(expansion_config));
  160. i2c_set_bus_num(TWL4030_I2C_BUS);
  161. return expansion_config.device_vendor;
  162. }
  163. /*
  164. * Routine: misc_init_r
  165. * Description: Configure board specific parts
  166. */
  167. int misc_init_r(void)
  168. {
  169. twl4030_power_init();
  170. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  171. #if defined(CONFIG_CMD_NET)
  172. setup_net_chip();
  173. #endif
  174. printf("Board revision: %d\n", get_board_revision());
  175. switch (get_sdio2_config()) {
  176. case 0:
  177. printf("Tranceiver detected on mmc2\n");
  178. MUX_OVERO_SDIO2_TRANSCEIVER();
  179. break;
  180. case 1:
  181. printf("Direct connection on mmc2\n");
  182. MUX_OVERO_SDIO2_DIRECT();
  183. break;
  184. default:
  185. printf("Unable to detect mmc2 connection type\n");
  186. }
  187. switch (get_expansion_id()) {
  188. case GUMSTIX_SUMMIT:
  189. printf("Recognized Summit expansion board (rev %d %s)\n",
  190. expansion_config.revision,
  191. expansion_config.fab_revision);
  192. setenv("defaultdisplay", "dvi");
  193. break;
  194. case GUMSTIX_TOBI:
  195. printf("Recognized Tobi expansion board (rev %d %s)\n",
  196. expansion_config.revision,
  197. expansion_config.fab_revision);
  198. setenv("defaultdisplay", "dvi");
  199. break;
  200. case GUMSTIX_TOBI_DUO:
  201. printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
  202. expansion_config.revision,
  203. expansion_config.fab_revision);
  204. break;
  205. case GUMSTIX_PALO35:
  206. printf("Recognized Palo35 expansion board (rev %d %s)\n",
  207. expansion_config.revision,
  208. expansion_config.fab_revision);
  209. setenv("defaultdisplay", "lcd35");
  210. break;
  211. case GUMSTIX_PALO43:
  212. printf("Recognized Palo43 expansion board (rev %d %s)\n",
  213. expansion_config.revision,
  214. expansion_config.fab_revision);
  215. setenv("defaultdisplay", "lcd43");
  216. break;
  217. case GUMSTIX_CHESTNUT43:
  218. printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
  219. expansion_config.revision,
  220. expansion_config.fab_revision);
  221. setenv("defaultdisplay", "lcd43");
  222. break;
  223. case GUMSTIX_PINTO:
  224. printf("Recognized Pinto expansion board (rev %d %s)\n",
  225. expansion_config.revision,
  226. expansion_config.fab_revision);
  227. break;
  228. case GUMSTIX_GALLOP43:
  229. printf("Recognized Gallop43 expansion board (rev %d %s)\n",
  230. expansion_config.revision,
  231. expansion_config.fab_revision);
  232. setenv("defaultdisplay", "lcd43");
  233. break;
  234. case ETTUS_USRP_E:
  235. printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
  236. expansion_config.revision,
  237. expansion_config.fab_revision);
  238. MUX_USRP_E();
  239. setenv("defaultdisplay", "dvi");
  240. break;
  241. case GUMSTIX_NO_EEPROM:
  242. printf("No EEPROM on expansion board\n");
  243. break;
  244. default:
  245. printf("Unrecognized expansion board\n");
  246. }
  247. if (expansion_config.content == 1)
  248. setenv(expansion_config.env_var, expansion_config.env_setting);
  249. dieid_num_r();
  250. return 0;
  251. }
  252. /*
  253. * Routine: set_muxconf_regs
  254. * Description: Setting up the configuration Mux registers specific to the
  255. * hardware. Many pins need to be moved from protect to primary
  256. * mode.
  257. */
  258. void set_muxconf_regs(void)
  259. {
  260. MUX_OVERO();
  261. }
  262. #if defined(CONFIG_CMD_NET)
  263. /*
  264. * Routine: setup_net_chip
  265. * Description: Setting up the configuration GPMC registers specific to the
  266. * Ethernet hardware.
  267. */
  268. static void setup_net_chip(void)
  269. {
  270. struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
  271. /* first lan chip */
  272. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[5], 0x2C000000,
  273. GPMC_SIZE_16M);
  274. /* second lan chip */
  275. enable_gpmc_cs_config(gpmc_lan_config, &gpmc_cfg->cs[4], 0x2B000000,
  276. GPMC_SIZE_16M);
  277. /* Enable off mode for NWE in PADCONF_GPMC_NWE register */
  278. writew(readw(&ctrl_base ->gpmc_nwe) | 0x0E00, &ctrl_base->gpmc_nwe);
  279. /* Enable off mode for NOE in PADCONF_GPMC_NADV_ALE register */
  280. writew(readw(&ctrl_base->gpmc_noe) | 0x0E00, &ctrl_base->gpmc_noe);
  281. /* Enable off mode for ALE in PADCONF_GPMC_NADV_ALE register */
  282. writew(readw(&ctrl_base->gpmc_nadv_ale) | 0x0E00,
  283. &ctrl_base->gpmc_nadv_ale);
  284. /* Make GPIO 64 as output pin and send a magic pulse through it */
  285. if (!gpio_request(64, "")) {
  286. gpio_direction_output(64, 0);
  287. gpio_set_value(64, 1);
  288. udelay(1);
  289. gpio_set_value(64, 0);
  290. udelay(1);
  291. gpio_set_value(64, 1);
  292. }
  293. }
  294. #endif
  295. int board_eth_init(bd_t *bis)
  296. {
  297. int rc = 0;
  298. #ifdef CONFIG_SMC911X
  299. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  300. #endif
  301. return rc;
  302. }
  303. #ifdef CONFIG_GENERIC_MMC
  304. int board_mmc_init(bd_t *bis)
  305. {
  306. omap_mmc_init(0);
  307. return 0;
  308. }
  309. #endif