board-omap3beagle.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /*
  2. * linux/arch/arm/mach-omap2/board-omap3beagle.c
  3. *
  4. * Copyright (C) 2008 Texas Instruments
  5. *
  6. * Modified from mach-omap2/board-3430sdp.c
  7. *
  8. * Initial code: Syed Mohammed Khasim
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <linux/err.h>
  19. #include <linux/clk.h>
  20. #include <linux/io.h>
  21. #include <linux/leds.h>
  22. #include <linux/gpio.h>
  23. #include <linux/input.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/opp.h>
  26. #include <linux/mtd/mtd.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/mtd/nand.h>
  29. #include <linux/mmc/host.h>
  30. #include <linux/regulator/machine.h>
  31. #include <linux/i2c/twl.h>
  32. #include <mach/hardware.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/flash.h>
  37. #include <plat/board.h>
  38. #include <plat/common.h>
  39. #include <video/omapdss.h>
  40. #include <video/omap-panel-generic-dpi.h>
  41. #include <plat/gpmc.h>
  42. #include <plat/nand.h>
  43. #include <plat/usb.h>
  44. #include <plat/omap_device.h>
  45. #include "mux.h"
  46. #include "hsmmc.h"
  47. #include "pm.h"
  48. #include "common-board-devices.h"
  49. /*
  50. * OMAP3 Beagle revision
  51. * Run time detection of Beagle revision is done by reading GPIO.
  52. * GPIO ID -
  53. * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
  54. * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
  55. * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
  56. * XM = GPIO173, GPIO172, GPIO171: 0 0 0
  57. */
  58. enum {
  59. OMAP3BEAGLE_BOARD_UNKN = 0,
  60. OMAP3BEAGLE_BOARD_AXBX,
  61. OMAP3BEAGLE_BOARD_C1_3,
  62. OMAP3BEAGLE_BOARD_C4,
  63. OMAP3BEAGLE_BOARD_XM,
  64. };
  65. static u8 omap3_beagle_version;
  66. static u8 omap3_beagle_get_rev(void)
  67. {
  68. return omap3_beagle_version;
  69. }
  70. static struct gpio omap3_beagle_rev_gpios[] __initdata = {
  71. { 171, GPIOF_IN, "rev_id_0" },
  72. { 172, GPIOF_IN, "rev_id_1" },
  73. { 173, GPIOF_IN, "rev_id_2" },
  74. };
  75. static void __init omap3_beagle_init_rev(void)
  76. {
  77. int ret;
  78. u16 beagle_rev = 0;
  79. omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
  80. omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
  81. omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
  82. ret = gpio_request_array(omap3_beagle_rev_gpios,
  83. ARRAY_SIZE(omap3_beagle_rev_gpios));
  84. if (ret < 0) {
  85. printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
  86. omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
  87. return;
  88. }
  89. beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
  90. | (gpio_get_value(173) << 2);
  91. gpio_free_array(omap3_beagle_rev_gpios,
  92. ARRAY_SIZE(omap3_beagle_rev_gpios));
  93. switch (beagle_rev) {
  94. case 7:
  95. printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
  96. omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
  97. break;
  98. case 6:
  99. printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
  100. omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
  101. break;
  102. case 5:
  103. printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
  104. omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
  105. break;
  106. case 0:
  107. printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
  108. omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
  109. break;
  110. default:
  111. printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
  112. omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
  113. }
  114. }
  115. static struct mtd_partition omap3beagle_nand_partitions[] = {
  116. /* All the partition sizes are listed in terms of NAND block size */
  117. {
  118. .name = "X-Loader",
  119. .offset = 0,
  120. .size = 4 * NAND_BLOCK_SIZE,
  121. .mask_flags = MTD_WRITEABLE, /* force read-only */
  122. },
  123. {
  124. .name = "U-Boot",
  125. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  126. .size = 15 * NAND_BLOCK_SIZE,
  127. .mask_flags = MTD_WRITEABLE, /* force read-only */
  128. },
  129. {
  130. .name = "U-Boot Env",
  131. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  132. .size = 1 * NAND_BLOCK_SIZE,
  133. },
  134. {
  135. .name = "Kernel",
  136. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  137. .size = 32 * NAND_BLOCK_SIZE,
  138. },
  139. {
  140. .name = "File System",
  141. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  142. .size = MTDPART_SIZ_FULL,
  143. },
  144. };
  145. /* DSS */
  146. static int beagle_enable_dvi(struct omap_dss_device *dssdev)
  147. {
  148. if (gpio_is_valid(dssdev->reset_gpio))
  149. gpio_set_value(dssdev->reset_gpio, 1);
  150. return 0;
  151. }
  152. static void beagle_disable_dvi(struct omap_dss_device *dssdev)
  153. {
  154. if (gpio_is_valid(dssdev->reset_gpio))
  155. gpio_set_value(dssdev->reset_gpio, 0);
  156. }
  157. static struct panel_generic_dpi_data dvi_panel = {
  158. .name = "generic",
  159. .platform_enable = beagle_enable_dvi,
  160. .platform_disable = beagle_disable_dvi,
  161. };
  162. static struct omap_dss_device beagle_dvi_device = {
  163. .type = OMAP_DISPLAY_TYPE_DPI,
  164. .name = "dvi",
  165. .driver_name = "generic_dpi_panel",
  166. .data = &dvi_panel,
  167. .phy.dpi.data_lines = 24,
  168. .reset_gpio = -EINVAL,
  169. };
  170. static struct omap_dss_device beagle_tv_device = {
  171. .name = "tv",
  172. .driver_name = "venc",
  173. .type = OMAP_DISPLAY_TYPE_VENC,
  174. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  175. };
  176. static struct omap_dss_device *beagle_dss_devices[] = {
  177. &beagle_dvi_device,
  178. &beagle_tv_device,
  179. };
  180. static struct omap_dss_board_info beagle_dss_data = {
  181. .num_devices = ARRAY_SIZE(beagle_dss_devices),
  182. .devices = beagle_dss_devices,
  183. .default_device = &beagle_dvi_device,
  184. };
  185. static void __init beagle_display_init(void)
  186. {
  187. int r;
  188. r = gpio_request_one(beagle_dvi_device.reset_gpio, GPIOF_OUT_INIT_LOW,
  189. "DVI reset");
  190. if (r < 0)
  191. printk(KERN_ERR "Unable to get DVI reset GPIO\n");
  192. }
  193. #include "sdram-micron-mt46h32m32lf-6.h"
  194. static struct omap2_hsmmc_info mmc[] = {
  195. {
  196. .mmc = 1,
  197. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  198. .gpio_wp = 29,
  199. },
  200. {} /* Terminator */
  201. };
  202. static struct regulator_consumer_supply beagle_vmmc1_supply[] = {
  203. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  204. };
  205. static struct regulator_consumer_supply beagle_vsim_supply[] = {
  206. REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
  207. };
  208. static struct gpio_led gpio_leds[];
  209. static int beagle_twl_gpio_setup(struct device *dev,
  210. unsigned gpio, unsigned ngpio)
  211. {
  212. int r, usb_pwr_level;
  213. if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
  214. mmc[0].gpio_wp = -EINVAL;
  215. } else if ((omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
  216. (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C4)) {
  217. omap_mux_init_gpio(23, OMAP_PIN_INPUT);
  218. mmc[0].gpio_wp = 23;
  219. } else {
  220. omap_mux_init_gpio(29, OMAP_PIN_INPUT);
  221. }
  222. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  223. mmc[0].gpio_cd = gpio + 0;
  224. omap2_hsmmc_init(mmc);
  225. /*
  226. * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active
  227. * high / others active low)
  228. * DVI reset GPIO is different between beagle revisions
  229. */
  230. if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
  231. usb_pwr_level = GPIOF_OUT_INIT_HIGH;
  232. beagle_dvi_device.reset_gpio = 129;
  233. /*
  234. * gpio + 1 on Xm controls the TFP410's enable line (active low)
  235. * gpio + 2 control varies depending on the board rev as below:
  236. * P7/P8 revisions(prototype): Camera EN
  237. * A2+ revisions (production): LDO (DVI, serial, led blocks)
  238. */
  239. r = gpio_request_one(gpio + 1, GPIOF_OUT_INIT_LOW,
  240. "nDVI_PWR_EN");
  241. if (r)
  242. pr_err("%s: unable to configure nDVI_PWR_EN\n",
  243. __func__);
  244. r = gpio_request_one(gpio + 2, GPIOF_OUT_INIT_HIGH,
  245. "DVI_LDO_EN");
  246. if (r)
  247. pr_err("%s: unable to configure DVI_LDO_EN\n",
  248. __func__);
  249. } else {
  250. usb_pwr_level = GPIOF_OUT_INIT_LOW;
  251. beagle_dvi_device.reset_gpio = 170;
  252. /*
  253. * REVISIT: need ehci-omap hooks for external VBUS
  254. * power switch and overcurrent detect
  255. */
  256. if (gpio_request_one(gpio + 1, GPIOF_IN, "EHCI_nOC"))
  257. pr_err("%s: unable to configure EHCI_nOC\n", __func__);
  258. }
  259. gpio_request_one(gpio + TWL4030_GPIO_MAX, usb_pwr_level, "nEN_USB_PWR");
  260. /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
  261. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  262. return 0;
  263. }
  264. static struct twl4030_gpio_platform_data beagle_gpio_data = {
  265. .gpio_base = OMAP_MAX_GPIO_LINES,
  266. .irq_base = TWL4030_GPIO_IRQ_BASE,
  267. .irq_end = TWL4030_GPIO_IRQ_END,
  268. .use_leds = true,
  269. .pullups = BIT(1),
  270. .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
  271. | BIT(15) | BIT(16) | BIT(17),
  272. .setup = beagle_twl_gpio_setup,
  273. };
  274. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  275. static struct regulator_init_data beagle_vmmc1 = {
  276. .constraints = {
  277. .min_uV = 1850000,
  278. .max_uV = 3150000,
  279. .valid_modes_mask = REGULATOR_MODE_NORMAL
  280. | REGULATOR_MODE_STANDBY,
  281. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  282. | REGULATOR_CHANGE_MODE
  283. | REGULATOR_CHANGE_STATUS,
  284. },
  285. .num_consumer_supplies = ARRAY_SIZE(beagle_vmmc1_supply),
  286. .consumer_supplies = beagle_vmmc1_supply,
  287. };
  288. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  289. static struct regulator_init_data beagle_vsim = {
  290. .constraints = {
  291. .min_uV = 1800000,
  292. .max_uV = 3000000,
  293. .valid_modes_mask = REGULATOR_MODE_NORMAL
  294. | REGULATOR_MODE_STANDBY,
  295. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  296. | REGULATOR_CHANGE_MODE
  297. | REGULATOR_CHANGE_STATUS,
  298. },
  299. .num_consumer_supplies = ARRAY_SIZE(beagle_vsim_supply),
  300. .consumer_supplies = beagle_vsim_supply,
  301. };
  302. static struct twl4030_platform_data beagle_twldata = {
  303. /* platform_data for children goes here */
  304. .gpio = &beagle_gpio_data,
  305. .vmmc1 = &beagle_vmmc1,
  306. .vsim = &beagle_vsim,
  307. };
  308. static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
  309. {
  310. I2C_BOARD_INFO("eeprom", 0x50),
  311. },
  312. };
  313. static int __init omap3_beagle_i2c_init(void)
  314. {
  315. omap3_pmic_get_config(&beagle_twldata,
  316. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_AUDIO,
  317. TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
  318. beagle_twldata.vpll2->constraints.name = "VDVI";
  319. omap3_pmic_init("twl4030", &beagle_twldata);
  320. /* Bus 3 is attached to the DVI port where devices like the pico DLP
  321. * projector don't work reliably with 400kHz */
  322. omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));
  323. return 0;
  324. }
  325. static struct gpio_led gpio_leds[] = {
  326. {
  327. .name = "beagleboard::usr0",
  328. .default_trigger = "heartbeat",
  329. .gpio = 150,
  330. },
  331. {
  332. .name = "beagleboard::usr1",
  333. .default_trigger = "mmc0",
  334. .gpio = 149,
  335. },
  336. {
  337. .name = "beagleboard::pmu_stat",
  338. .gpio = -EINVAL, /* gets replaced */
  339. .active_low = true,
  340. },
  341. };
  342. static struct gpio_led_platform_data gpio_led_info = {
  343. .leds = gpio_leds,
  344. .num_leds = ARRAY_SIZE(gpio_leds),
  345. };
  346. static struct platform_device leds_gpio = {
  347. .name = "leds-gpio",
  348. .id = -1,
  349. .dev = {
  350. .platform_data = &gpio_led_info,
  351. },
  352. };
  353. static struct gpio_keys_button gpio_buttons[] = {
  354. {
  355. .code = BTN_EXTRA,
  356. .gpio = 7,
  357. .desc = "user",
  358. .wakeup = 1,
  359. },
  360. };
  361. static struct gpio_keys_platform_data gpio_key_info = {
  362. .buttons = gpio_buttons,
  363. .nbuttons = ARRAY_SIZE(gpio_buttons),
  364. };
  365. static struct platform_device keys_gpio = {
  366. .name = "gpio-keys",
  367. .id = -1,
  368. .dev = {
  369. .platform_data = &gpio_key_info,
  370. },
  371. };
  372. static void __init omap3_beagle_init_early(void)
  373. {
  374. omap2_init_common_infrastructure();
  375. omap2_init_common_devices(mt46h32m32lf6_sdrc_params,
  376. mt46h32m32lf6_sdrc_params);
  377. }
  378. static void __init omap3_beagle_init_irq(void)
  379. {
  380. omap3_init_irq();
  381. }
  382. static struct platform_device *omap3_beagle_devices[] __initdata = {
  383. &leds_gpio,
  384. &keys_gpio,
  385. };
  386. static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
  387. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  388. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  389. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  390. .phy_reset = true,
  391. .reset_gpio_port[0] = -EINVAL,
  392. .reset_gpio_port[1] = 147,
  393. .reset_gpio_port[2] = -EINVAL
  394. };
  395. #ifdef CONFIG_OMAP_MUX
  396. static struct omap_board_mux board_mux[] __initdata = {
  397. { .reg_offset = OMAP_MUX_TERMINATOR },
  398. };
  399. #endif
  400. static void __init beagle_opp_init(void)
  401. {
  402. int r = 0;
  403. /* Initialize the omap3 opp table */
  404. if (omap3_opp_init()) {
  405. pr_err("%s: opp default init failed\n", __func__);
  406. return;
  407. }
  408. /* Custom OPP enabled for XM */
  409. if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
  410. struct omap_hwmod *mh = omap_hwmod_lookup("mpu");
  411. struct omap_hwmod *dh = omap_hwmod_lookup("iva");
  412. struct device *dev;
  413. if (!mh || !dh) {
  414. pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n",
  415. __func__, mh, dh);
  416. return;
  417. }
  418. /* Enable MPU 1GHz and lower opps */
  419. dev = &mh->od->pdev.dev;
  420. r = opp_enable(dev, 800000000);
  421. /* TODO: MPU 1GHz needs SR and ABB */
  422. /* Enable IVA 800MHz and lower opps */
  423. dev = &dh->od->pdev.dev;
  424. r |= opp_enable(dev, 660000000);
  425. /* TODO: DSP 800MHz needs SR and ABB */
  426. if (r) {
  427. pr_err("%s: failed to enable higher opp %d\n",
  428. __func__, r);
  429. /*
  430. * Cleanup - disable the higher freqs - we dont care
  431. * about the results
  432. */
  433. dev = &mh->od->pdev.dev;
  434. opp_disable(dev, 800000000);
  435. dev = &dh->od->pdev.dev;
  436. opp_disable(dev, 660000000);
  437. }
  438. }
  439. return;
  440. }
  441. static void __init omap3_beagle_init(void)
  442. {
  443. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  444. omap3_beagle_init_rev();
  445. omap3_beagle_i2c_init();
  446. platform_add_devices(omap3_beagle_devices,
  447. ARRAY_SIZE(omap3_beagle_devices));
  448. omap_display_init(&beagle_dss_data);
  449. omap_serial_init();
  450. omap_mux_init_gpio(170, OMAP_PIN_INPUT);
  451. /* REVISIT leave DVI powered down until it's needed ... */
  452. gpio_request_one(170, GPIOF_OUT_INIT_HIGH, "DVI_nPD");
  453. usb_musb_init(NULL);
  454. usbhs_init(&usbhs_bdata);
  455. omap_nand_flash_init(NAND_BUSWIDTH_16, omap3beagle_nand_partitions,
  456. ARRAY_SIZE(omap3beagle_nand_partitions));
  457. /* Ensure msecure is mux'd to be able to set the RTC. */
  458. omap_mux_init_signal("sys_drm_msecure", OMAP_PIN_OFF_OUTPUT_HIGH);
  459. /* Ensure SDRC pins are mux'd for self-refresh */
  460. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  461. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  462. beagle_display_init();
  463. beagle_opp_init();
  464. }
  465. MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
  466. /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
  467. .boot_params = 0x80000100,
  468. .reserve = omap_reserve,
  469. .map_io = omap3_map_io,
  470. .init_early = omap3_beagle_init_early,
  471. .init_irq = omap3_beagle_init_irq,
  472. .init_machine = omap3_beagle_init,
  473. .timer = &omap3_secure_timer,
  474. MACHINE_END