beagle.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /*
  2. * (C) Copyright 2004-2011
  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 <linux/mtd/nand.h>
  38. #include <asm/io.h>
  39. #include <asm/arch/mmc_host_def.h>
  40. #include <asm/arch/mux.h>
  41. #include <asm/arch/mem.h>
  42. #include <asm/arch/sys_proto.h>
  43. #include <asm/gpio.h>
  44. #include <asm/mach-types.h>
  45. #ifdef CONFIG_USB_EHCI
  46. #include <usb.h>
  47. #include <asm/arch/clocks.h>
  48. #include <asm/arch/clocks_omap3.h>
  49. #include <asm/arch/ehci_omap3.h>
  50. /* from drivers/usb/host/ehci-core.h */
  51. extern struct ehci_hccr *hccr;
  52. extern volatile struct ehci_hcor *hcor;
  53. #endif
  54. #include "beagle.h"
  55. #include <command.h>
  56. #define pr_debug(fmt, args...) debug(fmt, ##args)
  57. #define TWL4030_I2C_BUS 0
  58. #define EXPANSION_EEPROM_I2C_BUS 1
  59. #define EXPANSION_EEPROM_I2C_ADDRESS 0x50
  60. #define TINCANTOOLS_ZIPPY 0x01000100
  61. #define TINCANTOOLS_ZIPPY2 0x02000100
  62. #define TINCANTOOLS_TRAINER 0x04000100
  63. #define TINCANTOOLS_SHOWDOG 0x03000100
  64. #define KBADC_BEAGLEFPGA 0x01000600
  65. #define LW_BEAGLETOUCH 0x01000700
  66. #define BRAINMUX_LCDOG 0x01000800
  67. #define BRAINMUX_LCDOGTOUCH 0x02000800
  68. #define BBTOYS_WIFI 0x01000B00
  69. #define BBTOYS_VGA 0x02000B00
  70. #define BBTOYS_LCD 0x03000B00
  71. #define BEAGLE_NO_EEPROM 0xffffffff
  72. DECLARE_GLOBAL_DATA_PTR;
  73. static struct {
  74. unsigned int device_vendor;
  75. unsigned char revision;
  76. unsigned char content;
  77. char fab_revision[8];
  78. char env_var[16];
  79. char env_setting[64];
  80. } expansion_config;
  81. /*
  82. * Routine: board_init
  83. * Description: Early hardware init.
  84. */
  85. int board_init(void)
  86. {
  87. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  88. /* board id for Linux */
  89. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE;
  90. /* boot param addr */
  91. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  92. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  93. status_led_set (STATUS_LED_BOOT, STATUS_LED_ON);
  94. #endif
  95. return 0;
  96. }
  97. /*
  98. * Routine: get_board_revision
  99. * Description: Detect if we are running on a Beagle revision Ax/Bx,
  100. * C1/2/3, C4 or xM. This can be done by reading
  101. * the level of GPIO173, GPIO172 and GPIO171. This should
  102. * result in
  103. * GPIO173, GPIO172, GPIO171: 1 1 1 => Ax/Bx
  104. * GPIO173, GPIO172, GPIO171: 1 1 0 => C1/2/3
  105. * GPIO173, GPIO172, GPIO171: 1 0 1 => C4
  106. * GPIO173, GPIO172, GPIO171: 0 0 0 => xM
  107. */
  108. int get_board_revision(void)
  109. {
  110. int revision;
  111. if (!gpio_request(171, "") &&
  112. !gpio_request(172, "") &&
  113. !gpio_request(173, "")) {
  114. gpio_direction_input(171);
  115. gpio_direction_input(172);
  116. gpio_direction_input(173);
  117. revision = gpio_get_value(173) << 2 |
  118. gpio_get_value(172) << 1 |
  119. gpio_get_value(171);
  120. } else {
  121. printf("Error: unable to acquire board revision GPIOs\n");
  122. revision = -1;
  123. }
  124. return revision;
  125. }
  126. #ifdef CONFIG_SPL_BUILD
  127. /*
  128. * Routine: get_board_mem_timings
  129. * Description: If we use SPL then there is no x-loader nor config header
  130. * so we have to setup the DDR timings ourself on both banks.
  131. */
  132. void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl,
  133. u32 *mr)
  134. {
  135. int pop_mfr, pop_id;
  136. /*
  137. * We need to identify what PoP memory is on the board so that
  138. * we know what timings to use. If we can't identify it then
  139. * we know it's an xM. To map the ID values please see nand_ids.c
  140. */
  141. identify_nand_chip(&pop_mfr, &pop_id);
  142. *mr = MICRON_V_MR_165;
  143. switch (get_board_revision()) {
  144. case REVISION_C4:
  145. if (pop_mfr == NAND_MFR_STMICRO && pop_id == 0xba) {
  146. /* 512MB DDR */
  147. *mcfg = NUMONYX_V_MCFG_165(512 << 20);
  148. *ctrla = NUMONYX_V_ACTIMA_165;
  149. *ctrlb = NUMONYX_V_ACTIMB_165;
  150. *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  151. break;
  152. } else if (pop_mfr == NAND_MFR_MICRON && pop_id == 0xbc) {
  153. /* Beagleboard Rev C5, 256MB DDR */
  154. *mcfg = MICRON_V_MCFG_200(256 << 20);
  155. *ctrla = MICRON_V_ACTIMA_200;
  156. *ctrlb = MICRON_V_ACTIMB_200;
  157. *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
  158. break;
  159. }
  160. case REVISION_XM_A:
  161. case REVISION_XM_B:
  162. case REVISION_XM_C:
  163. if (pop_mfr == 0) {
  164. /* 256MB DDR */
  165. *mcfg = MICRON_V_MCFG_200(256 << 20);
  166. *ctrla = MICRON_V_ACTIMA_200;
  167. *ctrlb = MICRON_V_ACTIMB_200;
  168. *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
  169. } else {
  170. /* 512MB DDR */
  171. *mcfg = NUMONYX_V_MCFG_165(512 << 20);
  172. *ctrla = NUMONYX_V_ACTIMA_165;
  173. *ctrlb = NUMONYX_V_ACTIMB_165;
  174. *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  175. }
  176. break;
  177. default:
  178. /* Assume 128MB and Micron/165MHz timings to be safe */
  179. *mcfg = MICRON_V_MCFG_165(128 << 20);
  180. *ctrla = MICRON_V_ACTIMA_165;
  181. *ctrlb = MICRON_V_ACTIMB_165;
  182. *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
  183. }
  184. }
  185. #endif
  186. /*
  187. * Routine: get_expansion_id
  188. * Description: This function checks for expansion board by checking I2C
  189. * bus 1 for the availability of an AT24C01B serial EEPROM.
  190. * returns the device_vendor field from the EEPROM
  191. */
  192. unsigned int get_expansion_id(void)
  193. {
  194. i2c_set_bus_num(EXPANSION_EEPROM_I2C_BUS);
  195. /* return BEAGLE_NO_EEPROM if eeprom doesn't respond */
  196. if (i2c_probe(EXPANSION_EEPROM_I2C_ADDRESS) == 1) {
  197. i2c_set_bus_num(TWL4030_I2C_BUS);
  198. return BEAGLE_NO_EEPROM;
  199. }
  200. /* read configuration data */
  201. i2c_read(EXPANSION_EEPROM_I2C_ADDRESS, 0, 1, (u8 *)&expansion_config,
  202. sizeof(expansion_config));
  203. i2c_set_bus_num(TWL4030_I2C_BUS);
  204. return expansion_config.device_vendor;
  205. }
  206. /*
  207. * Configure DSS to display background color on DVID
  208. * Configure VENC to display color bar on S-Video
  209. */
  210. void beagle_display_init(void)
  211. {
  212. omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH);
  213. switch (get_board_revision()) {
  214. case REVISION_AXBX:
  215. case REVISION_CX:
  216. case REVISION_C4:
  217. omap3_dss_panel_config(&dvid_cfg);
  218. break;
  219. case REVISION_XM_A:
  220. case REVISION_XM_B:
  221. case REVISION_XM_C:
  222. default:
  223. omap3_dss_panel_config(&dvid_cfg_xm);
  224. break;
  225. }
  226. }
  227. /*
  228. * Routine: misc_init_r
  229. * Description: Configure board specific parts
  230. */
  231. int misc_init_r(void)
  232. {
  233. struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE;
  234. struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
  235. struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE;
  236. /* Enable i2c2 pullup resisters */
  237. writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1);
  238. switch (get_board_revision()) {
  239. case REVISION_AXBX:
  240. printf("Beagle Rev Ax/Bx\n");
  241. setenv("beaglerev", "AxBx");
  242. break;
  243. case REVISION_CX:
  244. printf("Beagle Rev C1/C2/C3\n");
  245. setenv("beaglerev", "Cx");
  246. MUX_BEAGLE_C();
  247. break;
  248. case REVISION_C4:
  249. printf("Beagle Rev C4\n");
  250. setenv("beaglerev", "C4");
  251. MUX_BEAGLE_C();
  252. /* Set VAUX2 to 1.8V for EHCI PHY */
  253. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  254. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  255. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  256. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  257. break;
  258. case REVISION_XM_A:
  259. printf("Beagle xM Rev A\n");
  260. setenv("beaglerev", "xMA");
  261. MUX_BEAGLE_XM();
  262. /* Set VAUX2 to 1.8V for EHCI PHY */
  263. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  264. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  265. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  266. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  267. break;
  268. case REVISION_XM_B:
  269. printf("Beagle xM Rev B\n");
  270. setenv("beaglerev", "xMB");
  271. MUX_BEAGLE_XM();
  272. /* Set VAUX2 to 1.8V for EHCI PHY */
  273. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  274. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  275. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  276. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  277. break;
  278. case REVISION_XM_C:
  279. printf("Beagle xM Rev C\n");
  280. setenv("beaglerev", "xMC");
  281. MUX_BEAGLE_XM();
  282. /* Set VAUX2 to 1.8V for EHCI PHY */
  283. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  284. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  285. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  286. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  287. break;
  288. default:
  289. printf("Beagle unknown 0x%02x\n", get_board_revision());
  290. MUX_BEAGLE_XM();
  291. /* Set VAUX2 to 1.8V for EHCI PHY */
  292. twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
  293. TWL4030_PM_RECEIVER_VAUX2_VSEL_18,
  294. TWL4030_PM_RECEIVER_VAUX2_DEV_GRP,
  295. TWL4030_PM_RECEIVER_DEV_GRP_P1);
  296. }
  297. switch (get_expansion_id()) {
  298. case TINCANTOOLS_ZIPPY:
  299. printf("Recognized Tincantools Zippy board (rev %d %s)\n",
  300. expansion_config.revision,
  301. expansion_config.fab_revision);
  302. MUX_TINCANTOOLS_ZIPPY();
  303. setenv("buddy", "zippy");
  304. break;
  305. case TINCANTOOLS_ZIPPY2:
  306. printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
  307. expansion_config.revision,
  308. expansion_config.fab_revision);
  309. MUX_TINCANTOOLS_ZIPPY();
  310. setenv("buddy", "zippy2");
  311. break;
  312. case TINCANTOOLS_TRAINER:
  313. printf("Recognized Tincantools Trainer board (rev %d %s)\n",
  314. expansion_config.revision,
  315. expansion_config.fab_revision);
  316. MUX_TINCANTOOLS_ZIPPY();
  317. MUX_TINCANTOOLS_TRAINER();
  318. setenv("buddy", "trainer");
  319. break;
  320. case TINCANTOOLS_SHOWDOG:
  321. printf("Recognized Tincantools Showdow board (rev %d %s)\n",
  322. expansion_config.revision,
  323. expansion_config.fab_revision);
  324. /* Place holder for DSS2 definition for showdog lcd */
  325. setenv("defaultdisplay", "showdoglcd");
  326. setenv("buddy", "showdog");
  327. break;
  328. case KBADC_BEAGLEFPGA:
  329. printf("Recognized KBADC Beagle FPGA board\n");
  330. MUX_KBADC_BEAGLEFPGA();
  331. setenv("buddy", "beaglefpga");
  332. break;
  333. case LW_BEAGLETOUCH:
  334. printf("Recognized Liquidware BeagleTouch board\n");
  335. setenv("buddy", "beagletouch");
  336. break;
  337. case BRAINMUX_LCDOG:
  338. printf("Recognized Brainmux LCDog board\n");
  339. setenv("buddy", "lcdog");
  340. break;
  341. case BRAINMUX_LCDOGTOUCH:
  342. printf("Recognized Brainmux LCDog Touch board\n");
  343. setenv("buddy", "lcdogtouch");
  344. break;
  345. case BBTOYS_WIFI:
  346. printf("Recognized BeagleBoardToys WiFi board\n");
  347. MUX_BBTOYS_WIFI()
  348. setenv("buddy", "bbtoys-wifi");
  349. break;;
  350. case BBTOYS_VGA:
  351. printf("Recognized BeagleBoardToys VGA board\n");
  352. break;;
  353. case BBTOYS_LCD:
  354. printf("Recognized BeagleBoardToys LCD board\n");
  355. break;;
  356. case BEAGLE_NO_EEPROM:
  357. printf("No EEPROM on expansion board\n");
  358. setenv("buddy", "none");
  359. break;
  360. default:
  361. printf("Unrecognized expansion board: %x\n",
  362. expansion_config.device_vendor);
  363. setenv("buddy", "unknown");
  364. }
  365. if (expansion_config.content == 1)
  366. setenv(expansion_config.env_var, expansion_config.env_setting);
  367. twl4030_power_init();
  368. switch (get_board_revision()) {
  369. case REVISION_XM_A:
  370. case REVISION_XM_B:
  371. twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
  372. break;
  373. default:
  374. twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
  375. break;
  376. }
  377. /* Set GPIO states before they are made outputs */
  378. writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1,
  379. &gpio6_base->setdataout);
  380. writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  381. GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout);
  382. /* Configure GPIOs to output */
  383. writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
  384. writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 |
  385. GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe);
  386. dieid_num_r();
  387. beagle_display_init();
  388. omap3_dss_enable();
  389. return 0;
  390. }
  391. /*
  392. * Routine: set_muxconf_regs
  393. * Description: Setting up the configuration Mux registers specific to the
  394. * hardware. Many pins need to be moved from protect to primary
  395. * mode.
  396. */
  397. void set_muxconf_regs(void)
  398. {
  399. MUX_BEAGLE();
  400. }
  401. #if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD)
  402. int board_mmc_init(bd_t *bis)
  403. {
  404. omap_mmc_init(0);
  405. return 0;
  406. }
  407. #endif
  408. #ifdef CONFIG_USB_EHCI
  409. #define GPIO_PHY_RESET 147
  410. /* Reset is needed otherwise the kernel-driver will throw an error. */
  411. int ehci_hcd_stop(void)
  412. {
  413. pr_debug("Resetting OMAP3 EHCI\n");
  414. gpio_set_value(GPIO_PHY_RESET, 0);
  415. writel(OMAP_UHH_SYSCONFIG_SOFTRESET, OMAP3_UHH_BASE + OMAP_UHH_SYSCONFIG);
  416. /* disable USB clocks */
  417. struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
  418. sr32(&prcm_base->iclken_usbhost, 0, 1, 0);
  419. sr32(&prcm_base->fclken_usbhost, 0, 2, 0);
  420. sr32(&prcm_base->iclken3_core, 2, 1, 0);
  421. sr32(&prcm_base->fclken3_core, 2, 1, 0);
  422. return 0;
  423. }
  424. /* Call usb_stop() before starting the kernel */
  425. void show_boot_progress(int val)
  426. {
  427. if(val == 15)
  428. usb_stop();
  429. }
  430. /*
  431. * Initialize the OMAP3 EHCI controller and PHY on the BeagleBoard.
  432. * Based on "drivers/usb/host/ehci-omap.c" from Linux 2.6.37.
  433. * See there for additional Copyrights.
  434. */
  435. int ehci_hcd_init(void)
  436. {
  437. pr_debug("Initializing OMAP3 ECHI\n");
  438. /* Put the PHY in RESET */
  439. gpio_request(GPIO_PHY_RESET, "");
  440. gpio_direction_output(GPIO_PHY_RESET, 0);
  441. gpio_set_value(GPIO_PHY_RESET, 0);
  442. /* Hold the PHY in RESET for enough time till DIR is high */
  443. /* Refer: ISSUE1 */
  444. udelay(10);
  445. struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
  446. /* Enable USBHOST_L3_ICLK (USBHOST_MICLK) */
  447. sr32(&prcm_base->iclken_usbhost, 0, 1, 1);
  448. /*
  449. * Enable USBHOST_48M_FCLK (USBHOST_FCLK1)
  450. * and USBHOST_120M_FCLK (USBHOST_FCLK2)
  451. */
  452. sr32(&prcm_base->fclken_usbhost, 0, 2, 3);
  453. /* Enable USBTTL_ICLK */
  454. sr32(&prcm_base->iclken3_core, 2, 1, 1);
  455. /* Enable USBTTL_FCLK */
  456. sr32(&prcm_base->fclken3_core, 2, 1, 1);
  457. pr_debug("USB clocks enabled\n");
  458. /* perform TLL soft reset, and wait until reset is complete */
  459. writel(OMAP_USBTLL_SYSCONFIG_SOFTRESET,
  460. OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSCONFIG);
  461. /* Wait for TLL reset to complete */
  462. while (!(readl(OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSSTATUS)
  463. & OMAP_USBTLL_SYSSTATUS_RESETDONE));
  464. pr_debug("TLL reset done\n");
  465. writel(OMAP_USBTLL_SYSCONFIG_ENAWAKEUP |
  466. OMAP_USBTLL_SYSCONFIG_SIDLEMODE |
  467. OMAP_USBTLL_SYSCONFIG_CACTIVITY,
  468. OMAP3_USBTLL_BASE + OMAP_USBTLL_SYSCONFIG);
  469. /* Put UHH in NoIdle/NoStandby mode */
  470. writel(OMAP_UHH_SYSCONFIG_ENAWAKEUP
  471. | OMAP_UHH_SYSCONFIG_SIDLEMODE
  472. | OMAP_UHH_SYSCONFIG_CACTIVITY
  473. | OMAP_UHH_SYSCONFIG_MIDLEMODE,
  474. OMAP3_UHH_BASE + OMAP_UHH_SYSCONFIG);
  475. /* setup burst configurations */
  476. writel(OMAP_UHH_HOSTCONFIG_INCR4_BURST_EN
  477. | OMAP_UHH_HOSTCONFIG_INCR8_BURST_EN
  478. | OMAP_UHH_HOSTCONFIG_INCR16_BURST_EN,
  479. OMAP3_UHH_BASE + OMAP_UHH_HOSTCONFIG);
  480. /*
  481. * Refer ISSUE1:
  482. * Hold the PHY in RESET for enough time till
  483. * PHY is settled and ready
  484. */
  485. udelay(10);
  486. gpio_set_value(GPIO_PHY_RESET, 1);
  487. hccr = (struct ehci_hccr *)(OMAP3_EHCI_BASE);
  488. hcor = (struct ehci_hcor *)(OMAP3_EHCI_BASE + 0x10);
  489. pr_debug("OMAP3 EHCI init done\n");
  490. return 0;
  491. }
  492. #endif /* CONFIG_USB_EHCI */
  493. #ifndef CONFIG_SPL_BUILD
  494. /*
  495. * This command returns the status of the user button on beagle xM
  496. * Input - none
  497. * Returns - 1 if button is held down
  498. * 0 if button is not held down
  499. */
  500. int do_userbutton(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  501. {
  502. int button = 0;
  503. int gpio;
  504. /*
  505. * pass address parameter as argv[0] (aka command name),
  506. * and all remaining args
  507. */
  508. switch (get_board_revision()) {
  509. case REVISION_AXBX:
  510. case REVISION_CX:
  511. case REVISION_C4:
  512. gpio = 7;
  513. break;
  514. case REVISION_XM_A:
  515. case REVISION_XM_B:
  516. case REVISION_XM_C:
  517. default:
  518. gpio = 4;
  519. break;
  520. }
  521. gpio_request(gpio, "");
  522. gpio_direction_input(gpio);
  523. printf("The user button is currently ");
  524. if (gpio_get_value(gpio))
  525. {
  526. button = 1;
  527. printf("PRESSED.\n");
  528. }
  529. else
  530. {
  531. button = 0;
  532. printf("NOT pressed.\n");
  533. }
  534. return !button;
  535. }
  536. /* -------------------------------------------------------------------- */
  537. U_BOOT_CMD(
  538. userbutton, CONFIG_SYS_MAXARGS, 1, do_userbutton,
  539. "Return the status of the BeagleBoard USER button",
  540. ""
  541. );
  542. #endif