beagle.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. #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/sys_proto.h>
  38. #include <asm/arch/gpio.h>
  39. #include <asm/mach-types.h>
  40. #include "beagle.h"
  41. #define TWL4030_I2C_BUS 0
  42. #define EXPANSION_EEPROM_I2C_BUS 1
  43. #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
  44. #define TINCANTOOLS_ZIPPY 0x01000100
  45. #define TINCANTOOLS_ZIPPY2 0x02000100
  46. #define TINCANTOOLS_TRAINER 0x04000100
  47. #define TINCANTOOLS_SHOWDOG 0x03000100
  48. #define KBADC_BEAGLEFPGA 0x01000600
  49. #define BEAGLE_NO_EEPROM 0xffffffff
  50. static struct {
  51. unsigned int device_vendor;
  52. unsigned char revision;
  53. unsigned char content;
  54. char fab_revision[8];
  55. char env_var[16];
  56. char env_setting[64];
  57. } expansion_config;
  58. /*
  59. * Routine: board_init
  60. * Description: Early hardware init.
  61. */
  62. int board_init(void)
  63. {
  64. DECLARE_GLOBAL_DATA_PTR;
  65. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  66. /* board id for Linux */
  67. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
  68. /* boot param addr */
  69. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  70. return 0;
  71. }
  72. /*
  73. * Routine: get_board_revision
  74. * Description: Detect if we are running on a Beagle revision Ax/Bx,
  75. * C1/2/3, C4 or xM. This can be done by reading
  76. * the level of GPIO173, GPIO172 and GPIO171. This should
  77. * result in
  78. * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
  79. * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
  80. * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
  81. * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
  82. */
  83. int get_board_revision(void)
  84. {
  85. int revision;
  86. if (!omap_request_gpio(171) &&
  87. !omap_request_gpio(172) &&
  88. !omap_request_gpio(173)) {
  89. omap_set_gpio_direction(171, 1);
  90. omap_set_gpio_direction(172, 1);
  91. omap_set_gpio_direction(173, 1);
  92. revision = omap_get_gpio_datain(173) << 2 |
  93. omap_get_gpio_datain(172) << 1 |
  94. omap_get_gpio_datain(171);
  95. omap_free_gpio(171);
  96. omap_free_gpio(172);
  97. omap_free_gpio(173);
  98. } else {
  99. printf("Error: unable to acquire board revision GPIOs\n");
  100. revision = -1;
  101. }
  102. return revision;
  103. }
  104. /*
  105. * Routine: get_expansion_id
  106. * Description: This function checks for expansion board by checking I2C
  107. * bus 1 for the availability of an AT24C01B serial EEPROM.
  108. * returns the device_vendor field from the EEPROM
  109. */
  110. unsigned int get_expansion_id(void)
  111. {
  112. i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
  113. /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
  114. if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
  115. i2c_set_bus_num(TWL4030_I2C_BUS);
  116. return BEAGLE_NO_EEPROM;
  117. }
  118. /* read configuration data */
  119. i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
  120. sizeof(expansion_config));
  121. i2c_set_bus_num(TWL4030_I2C_BUS);
  122. return expansion_config.device_vendor;
  123. }
  124. /*
  125. * Routine: misc_init_r
  126. * Description: Configure board specific parts
  127. */
  128. int misc_init_r(void)
  129. {
  130. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  131. struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
  132. switch (get_board_revision()) {
  133. case REVISION_AXBX:
  134. printf("Beagle Rev Ax/Bx\n");
  135. setenv("beaglerev", "AxBx");
  136. setenv("mpurate", "600");
  137. break;
  138. case REVISION_CX:
  139. printf("Beagle Rev C1/C2/C3\n");
  140. setenv("beaglerev", "Cx");
  141. setenv("mpurate", "600");
  142. MUX_BEAGLE_C();
  143. break;
  144. case REVISION_C4:
  145. printf("Beagle Rev C4\n");
  146. setenv("beaglerev", "C4");
  147. setenv("mpurate", "720");
  148. MUX_BEAGLE_C();
  149. /* Set VAUX2 to 1.8V for EHCI PHY */
  150. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  151. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  152. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  153. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  154. break;
  155. case REVISION_XM:
  156. printf("Beagle xM Rev A\n");
  157. setenv("beaglerev", "xMA");
  158. setenv("mpurate", "1000");
  159. MUX_BEAGLE_XM();
  160. /* Set VAUX2 to 1.8V for EHCI PHY */
  161. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  162. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  163. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  164. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  165. break;
  166. default:
  167. printf("Beagle unknown 0x%02x\n", get_board_revision());
  168. }
  169. switch (get_expansion_id()) {
  170. case TINCANTOOLS_ZIPPY:
  171. printf("Recognized Tincantools Zippy board (rev %d %s)\n",
  172. expansion_config.revision,
  173. expansion_config.fab_revision);
  174. MUX_TINCANTOOLS_ZIPPY();
  175. setenv("buddy", "zippy");
  176. break;
  177. case TINCANTOOLS_ZIPPY2:
  178. printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
  179. expansion_config.revision,
  180. expansion_config.fab_revision);
  181. MUX_TINCANTOOLS_ZIPPY();
  182. setenv("buddy", "zippy2");
  183. break;
  184. case TINCANTOOLS_TRAINER:
  185. printf("Recognized Tincantools Trainer board (rev %d %s)\n",
  186. expansion_config.revision,
  187. expansion_config.fab_revision);
  188. MUX_TINCANTOOLS_ZIPPY();
  189. MUX_TINCANTOOLS_TRAINER();
  190. setenv("buddy", "trainer");
  191. break;
  192. case TINCANTOOLS_SHOWDOG:
  193. printf("Recognized Tincantools Showdow board (rev %d %s)\n",
  194. expansion_config.revision,
  195. expansion_config.fab_revision);
  196. /* Place holder for DSS2 definition for showdog lcd */
  197. setenv("defaultdisplay", "showdoglcd");
  198. setenv("buddy", "showdog");
  199. break;
  200. case KBADC_BEAGLEFPGA:
  201. printf("Recognized KBADC Beagle FPGA board\n");
  202. MUX_KBADC_BEAGLEFPGA();
  203. setenv("buddy", "beaglefpga");
  204. break;
  205. case BEAGLE_NO_EEPROM:
  206. printf("No EEPROM on expansion board\n");
  207. setenv("buddy", "none");
  208. break;
  209. default:
  210. printf("Unrecognized expansion board: %x\n",
  211. expansion_config.device_vendor);
  212. setenv("buddy", "unknown");
  213. }
  214. if (expansion_config.content == 1)
  215. setenv(expansion_config.env_var, expansion_config.env_setting);
  216. twl4030_power_init();
  217. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  218. /* Configure GPIOs to output */
  219. writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
  220. writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  221. GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
  222. /* Set GPIOs */
  223. writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
  224. &gpio6_base->setdataout);
  225. writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  226. GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
  227. dieid_num_r();
  228. return 0;
  229. }
  230. /*
  231. * Routine: set_muxconf_regs
  232. * Description: Setting up the configuration Mux registers specific to the
  233. * hardware. Many pins need to be moved from protect to primary
  234. * mode.
  235. */
  236. void set_muxconf_regs(void)
  237. {
  238. MUX_BEAGLE();
  239. }
  240. #ifdef CONFIG_GENERIC_MMC
  241. int board_mmc_init(bd_t *bis)
  242. {
  243. omap_mmc_init(0);
  244. return 0;
  245. }
  246. #endif