board-omap3beagle.c 14 KB

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