beagle.c 16 KB

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