beagle.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*
  2. * (C) Copyright 2004-2008
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * Author :
  6. * Sunil Kumar <sunilsaini05@gmail.com>
  7. * Shashi Ranjan <shashiranjanmca05@gmail.com>
  8. *
  9. * Derived from Beagle Board and 3430 SDP code by
  10. * Richard Woodruff <r-woodruff2@ti.com>
  11. * Syed Mohammed Khasim <khasim@ti.com>
  12. *
  13. *
  14. * See file CREDITS for list of people who contributed to this
  15. * project.
  16. *
  17. * This program is free software; you can redistribute it and/or
  18. * modify it under the terms of the GNU General Public License as
  19. * published by the Free Software Foundation; either version 2 of
  20. * the License, or (at your option) any later version.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30. * MA 02111-1307 USA
  31. */
  32. #include <common.h>
  33. #ifdef CONFIG_STATUS_LED
  34. #include <status_led.h>
  35. #endif
  36. #include <twl4030.h>
  37. #include <asm/io.h>
  38. #include <asm/arch/mmc_host_def.h>
  39. #include <asm/arch/mux.h>
  40. #include <asm/arch/sys_proto.h>
  41. #include <asm/arch/gpio.h>
  42. #include <asm/mach-types.h>
  43. #include "beagle.h"
  44. #define TWL4030_I2C_BUS 0
  45. #define EXPANSION_EEPROM_I2C_BUS 1
  46. #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
  47. #define TINCANTOOLS_ZIPPY 0x01000100
  48. #define TINCANTOOLS_ZIPPY2 0x02000100
  49. #define TINCANTOOLS_TRAINER 0x04000100
  50. #define TINCANTOOLS_SHOWDOG 0x03000100
  51. #define KBADC_BEAGLEFPGA 0x01000600
  52. #define BEAGLE_NO_EEPROM 0xffffffff
  53. DECLARE_GLOBAL_DATA_PTR;
  54. static struct {
  55. unsigned int device_vendor;
  56. unsigned char revision;
  57. unsigned char content;
  58. char fab_revision[8];
  59. char env_var[16];
  60. char env_setting[64];
  61. } expansion_config;
  62. /*
  63. * Routine: board_init
  64. * Description: Early hardware init.
  65. */
  66. int board_init(void)
  67. {
  68. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  69. /* board id for Linux */
  70. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
  71. /* boot param addr */
  72. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  73. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  74. status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
  75. #endif
  76. return 0;
  77. }
  78. /*
  79. * Routine: get_board_revision
  80. * Description: Detect if we are running on a Beagle revision Ax/Bx,
  81. * C1/2/3, C4 or xM. This can be done by reading
  82. * the level of GPIO173, GPIO172 and GPIO171. This should
  83. * result in
  84. * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
  85. * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
  86. * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
  87. * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
  88. */
  89. int get_board_revision(void)
  90. {
  91. int revision;
  92. if (!omap_request_gpio(171) &&
  93. !omap_request_gpio(172) &&
  94. !omap_request_gpio(173)) {
  95. omap_set_gpio_direction(171, 1);
  96. omap_set_gpio_direction(172, 1);
  97. omap_set_gpio_direction(173, 1);
  98. revision = omap_get_gpio_datain(173) << 2 |
  99. omap_get_gpio_datain(172) << 1 |
  100. omap_get_gpio_datain(171);
  101. omap_free_gpio(171);
  102. omap_free_gpio(172);
  103. omap_free_gpio(173);
  104. } else {
  105. printf("Error: unable to acquire board revision GPIOs\n");
  106. revision = -1;
  107. }
  108. return revision;
  109. }
  110. /*
  111. * Routine: get_expansion_id
  112. * Description: This function checks for expansion board by checking I2C
  113. * bus 1 for the availability of an AT24C01B serial EEPROM.
  114. * returns the device_vendor field from the EEPROM
  115. */
  116. unsigned int get_expansion_id(void)
  117. {
  118. i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
  119. /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
  120. if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
  121. i2c_set_bus_num(TWL4030_I2C_BUS);
  122. return BEAGLE_NO_EEPROM;
  123. }
  124. /* read configuration data */
  125. i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
  126. sizeof(expansion_config));
  127. i2c_set_bus_num(TWL4030_I2C_BUS);
  128. return expansion_config.device_vendor;
  129. }
  130. /*
  131. * Routine: misc_init_r
  132. * Description: Configure board specific parts
  133. */
  134. int misc_init_r(void)
  135. {
  136. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  137. struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
  138. struct control_prog_io *prog_io_base = (struct gpio *)OMAP34XX_CTRL_BASE;
  139. /* Enable i2c2 pullup resisters */
  140. writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
  141. switch (get_board_revision()) {
  142. case REVISION_AXBX:
  143. printf("Beagle Rev Ax/Bx\n");
  144. setenv("beaglerev", "AxBx");
  145. setenv("mpurate", "600");
  146. break;
  147. case REVISION_CX:
  148. printf("Beagle Rev C1/C2/C3\n");
  149. setenv("beaglerev", "Cx");
  150. setenv("mpurate", "600");
  151. MUX_BEAGLE_C();
  152. break;
  153. case REVISION_C4:
  154. printf("Beagle Rev C4\n");
  155. setenv("beaglerev", "C4");
  156. setenv("mpurate", "720");
  157. MUX_BEAGLE_C();
  158. /* Set VAUX2 to 1.8V for EHCI PHY */
  159. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  160. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  161. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  162. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  163. break;
  164. case REVISION_XM:
  165. printf("Beagle xM Rev A\n");
  166. setenv("beaglerev", "xMA");
  167. setenv("mpurate", "1000");
  168. MUX_BEAGLE_XM();
  169. /* Set VAUX2 to 1.8V for EHCI PHY */
  170. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  171. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  172. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  173. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  174. break;
  175. default:
  176. printf("Beagle unknown 0x%02x\n", get_board_revision());
  177. }
  178. switch (get_expansion_id()) {
  179. case TINCANTOOLS_ZIPPY:
  180. printf("Recognized Tincantools Zippy board (rev %d %s)\n",
  181. expansion_config.revision,
  182. expansion_config.fab_revision);
  183. MUX_TINCANTOOLS_ZIPPY();
  184. setenv("buddy", "zippy");
  185. break;
  186. case TINCANTOOLS_ZIPPY2:
  187. printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
  188. expansion_config.revision,
  189. expansion_config.fab_revision);
  190. MUX_TINCANTOOLS_ZIPPY();
  191. setenv("buddy", "zippy2");
  192. break;
  193. case TINCANTOOLS_TRAINER:
  194. printf("Recognized Tincantools Trainer board (rev %d %s)\n",
  195. expansion_config.revision,
  196. expansion_config.fab_revision);
  197. MUX_TINCANTOOLS_ZIPPY();
  198. MUX_TINCANTOOLS_TRAINER();
  199. setenv("buddy", "trainer");
  200. break;
  201. case TINCANTOOLS_SHOWDOG:
  202. printf("Recognized Tincantools Showdow board (rev %d %s)\n",
  203. expansion_config.revision,
  204. expansion_config.fab_revision);
  205. /* Place holder for DSS2 definition for showdog lcd */
  206. setenv("defaultdisplay", "showdoglcd");
  207. setenv("buddy", "showdog");
  208. break;
  209. case KBADC_BEAGLEFPGA:
  210. printf("Recognized KBADC Beagle FPGA board\n");
  211. MUX_KBADC_BEAGLEFPGA();
  212. setenv("buddy", "beaglefpga");
  213. break;
  214. case BEAGLE_NO_EEPROM:
  215. printf("No EEPROM on expansion board\n");
  216. setenv("buddy", "none");
  217. break;
  218. default:
  219. printf("Unrecognized expansion board: %x\n",
  220. expansion_config.device_vendor);
  221. setenv("buddy", "unknown");
  222. }
  223. if (expansion_config.content == 1)
  224. setenv(expansion_config.env_var, expansion_config.env_setting);
  225. twl4030_power_init();
  226. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  227. /* Configure GPIOs to output */
  228. writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
  229. writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  230. GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
  231. /* Set GPIOs */
  232. writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
  233. &gpio6_base->setdataout);
  234. writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  235. GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
  236. dieid_num_r();
  237. return 0;
  238. }
  239. /*
  240. * Routine: set_muxconf_regs
  241. * Description: Setting up the configuration Mux registers specific to the
  242. * hardware. Many pins need to be moved from protect to primary
  243. * mode.
  244. */
  245. void set_muxconf_regs(void)
  246. {
  247. MUX_BEAGLE();
  248. }
  249. #ifdef CONFIG_GENERIC_MMC
  250. int board_mmc_init(bd_t *bis)
  251. {
  252. omap_mmc_init(0);
  253. return 0;
  254. }
  255. #endif