board-omap3beagle.c 14 KB

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