board-omap3beagle.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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/mtd/mtd.h>
  26. #include <linux/mtd/partitions.h>
  27. #include <linux/mtd/nand.h>
  28. #include <linux/mmc/host.h>
  29. #include <linux/regulator/machine.h>
  30. #include <linux/i2c/twl.h>
  31. #include <mach/hardware.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 <plat/board.h>
  37. #include <plat/common.h>
  38. #include <plat/display.h>
  39. #include <plat/gpmc.h>
  40. #include <plat/nand.h>
  41. #include <plat/usb.h>
  42. #include "mux.h"
  43. #include "hsmmc.h"
  44. #include "timer-gp.h"
  45. #define NAND_BLOCK_SIZE SZ_128K
  46. /*
  47. * OMAP3 Beagle revision
  48. * Run time detection of Beagle revision is done by reading GPIO.
  49. * GPIO ID -
  50. * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
  51. * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
  52. * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
  53. * XM = GPIO173, GPIO172, GPIO171: 0 0 0
  54. */
  55. enum {
  56. OMAP3BEAGLE_BOARD_UNKN = 0,
  57. OMAP3BEAGLE_BOARD_AXBX,
  58. OMAP3BEAGLE_BOARD_C1_3,
  59. OMAP3BEAGLE_BOARD_C4,
  60. OMAP3BEAGLE_BOARD_XM,
  61. };
  62. static u8 omap3_beagle_version;
  63. static u8 omap3_beagle_get_rev(void)
  64. {
  65. return omap3_beagle_version;
  66. }
  67. static void __init omap3_beagle_init_rev(void)
  68. {
  69. int ret;
  70. u16 beagle_rev = 0;
  71. omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
  72. omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
  73. omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
  74. ret = gpio_request(171, "rev_id_0");
  75. if (ret < 0)
  76. goto fail0;
  77. ret = gpio_request(172, "rev_id_1");
  78. if (ret < 0)
  79. goto fail1;
  80. ret = gpio_request(173, "rev_id_2");
  81. if (ret < 0)
  82. goto fail2;
  83. gpio_direction_input(171);
  84. gpio_direction_input(172);
  85. gpio_direction_input(173);
  86. beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
  87. | (gpio_get_value(173) << 2);
  88. switch (beagle_rev) {
  89. case 7:
  90. printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
  91. omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
  92. break;
  93. case 6:
  94. printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
  95. omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
  96. break;
  97. case 5:
  98. printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
  99. omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
  100. break;
  101. case 0:
  102. printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
  103. omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
  104. break;
  105. default:
  106. printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
  107. omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
  108. }
  109. return;
  110. fail2:
  111. gpio_free(172);
  112. fail1:
  113. gpio_free(171);
  114. fail0:
  115. printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
  116. omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
  117. return;
  118. }
  119. static struct mtd_partition omap3beagle_nand_partitions[] = {
  120. /* All the partition sizes are listed in terms of NAND block size */
  121. {
  122. .name = "X-Loader",
  123. .offset = 0,
  124. .size = 4 * NAND_BLOCK_SIZE,
  125. .mask_flags = MTD_WRITEABLE, /* force read-only */
  126. },
  127. {
  128. .name = "U-Boot",
  129. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  130. .size = 15 * NAND_BLOCK_SIZE,
  131. .mask_flags = MTD_WRITEABLE, /* force read-only */
  132. },
  133. {
  134. .name = "U-Boot Env",
  135. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  136. .size = 1 * NAND_BLOCK_SIZE,
  137. },
  138. {
  139. .name = "Kernel",
  140. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  141. .size = 32 * NAND_BLOCK_SIZE,
  142. },
  143. {
  144. .name = "File System",
  145. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  146. .size = MTDPART_SIZ_FULL,
  147. },
  148. };
  149. static struct omap_nand_platform_data omap3beagle_nand_data = {
  150. .options = NAND_BUSWIDTH_16,
  151. .parts = omap3beagle_nand_partitions,
  152. .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
  153. .dma_channel = -1, /* disable DMA in OMAP NAND driver */
  154. .nand_setup = NULL,
  155. .dev_ready = NULL,
  156. };
  157. /* DSS */
  158. static int beagle_enable_dvi(struct omap_dss_device *dssdev)
  159. {
  160. if (gpio_is_valid(dssdev->reset_gpio))
  161. gpio_set_value(dssdev->reset_gpio, 1);
  162. return 0;
  163. }
  164. static void beagle_disable_dvi(struct omap_dss_device *dssdev)
  165. {
  166. if (gpio_is_valid(dssdev->reset_gpio))
  167. gpio_set_value(dssdev->reset_gpio, 0);
  168. }
  169. static struct omap_dss_device beagle_dvi_device = {
  170. .type = OMAP_DISPLAY_TYPE_DPI,
  171. .name = "dvi",
  172. .driver_name = "generic_panel",
  173. .phy.dpi.data_lines = 24,
  174. .reset_gpio = 170,
  175. .platform_enable = beagle_enable_dvi,
  176. .platform_disable = beagle_disable_dvi,
  177. };
  178. static struct omap_dss_device beagle_tv_device = {
  179. .name = "tv",
  180. .driver_name = "venc",
  181. .type = OMAP_DISPLAY_TYPE_VENC,
  182. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  183. };
  184. static struct omap_dss_device *beagle_dss_devices[] = {
  185. &beagle_dvi_device,
  186. &beagle_tv_device,
  187. };
  188. static struct omap_dss_board_info beagle_dss_data = {
  189. .num_devices = ARRAY_SIZE(beagle_dss_devices),
  190. .devices = beagle_dss_devices,
  191. .default_device = &beagle_dvi_device,
  192. };
  193. static struct platform_device beagle_dss_device = {
  194. .name = "omapdss",
  195. .id = -1,
  196. .dev = {
  197. .platform_data = &beagle_dss_data,
  198. },
  199. };
  200. static struct regulator_consumer_supply beagle_vdac_supply =
  201. REGULATOR_SUPPLY("vdda_dac", "omapdss");
  202. static struct regulator_consumer_supply beagle_vdvi_supply =
  203. REGULATOR_SUPPLY("vdds_dsi", "omapdss");
  204. static void __init beagle_display_init(void)
  205. {
  206. int r;
  207. r = gpio_request(beagle_dvi_device.reset_gpio, "DVI reset");
  208. if (r < 0) {
  209. printk(KERN_ERR "Unable to get DVI reset GPIO\n");
  210. return;
  211. }
  212. gpio_direction_output(beagle_dvi_device.reset_gpio, 0);
  213. }
  214. #include "sdram-micron-mt46h32m32lf-6.h"
  215. static struct omap2_hsmmc_info mmc[] = {
  216. {
  217. .mmc = 1,
  218. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  219. .gpio_wp = 29,
  220. },
  221. {} /* Terminator */
  222. };
  223. static struct regulator_consumer_supply beagle_vmmc1_supply = {
  224. .supply = "vmmc",
  225. };
  226. static struct regulator_consumer_supply beagle_vsim_supply = {
  227. .supply = "vmmc_aux",
  228. };
  229. static struct gpio_led gpio_leds[];
  230. static int beagle_twl_gpio_setup(struct device *dev,
  231. unsigned gpio, unsigned ngpio)
  232. {
  233. if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
  234. mmc[0].gpio_wp = -EINVAL;
  235. } else if ((omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
  236. (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C4)) {
  237. omap_mux_init_gpio(23, OMAP_PIN_INPUT);
  238. mmc[0].gpio_wp = 23;
  239. } else {
  240. omap_mux_init_gpio(29, OMAP_PIN_INPUT);
  241. }
  242. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  243. mmc[0].gpio_cd = gpio + 0;
  244. omap2_hsmmc_init(mmc);
  245. /* link regulators to MMC adapters */
  246. beagle_vmmc1_supply.dev = mmc[0].dev;
  247. beagle_vsim_supply.dev = mmc[0].dev;
  248. /* REVISIT: need ehci-omap hooks for external VBUS
  249. * power switch and overcurrent detect
  250. */
  251. gpio_request(gpio + 1, "EHCI_nOC");
  252. gpio_direction_input(gpio + 1);
  253. /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
  254. gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
  255. gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
  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. .gpio_base = OMAP_MAX_GPIO_LINES,
  262. .irq_base = TWL4030_GPIO_IRQ_BASE,
  263. .irq_end = TWL4030_GPIO_IRQ_END,
  264. .use_leds = true,
  265. .pullups = BIT(1),
  266. .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
  267. | BIT(15) | BIT(16) | BIT(17),
  268. .setup = beagle_twl_gpio_setup,
  269. };
  270. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  271. static struct regulator_init_data beagle_vmmc1 = {
  272. .constraints = {
  273. .min_uV = 1850000,
  274. .max_uV = 3150000,
  275. .valid_modes_mask = REGULATOR_MODE_NORMAL
  276. | REGULATOR_MODE_STANDBY,
  277. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  278. | REGULATOR_CHANGE_MODE
  279. | REGULATOR_CHANGE_STATUS,
  280. },
  281. .num_consumer_supplies = 1,
  282. .consumer_supplies = &beagle_vmmc1_supply,
  283. };
  284. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  285. static struct regulator_init_data beagle_vsim = {
  286. .constraints = {
  287. .min_uV = 1800000,
  288. .max_uV = 3000000,
  289. .valid_modes_mask = REGULATOR_MODE_NORMAL
  290. | REGULATOR_MODE_STANDBY,
  291. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  292. | REGULATOR_CHANGE_MODE
  293. | REGULATOR_CHANGE_STATUS,
  294. },
  295. .num_consumer_supplies = 1,
  296. .consumer_supplies = &beagle_vsim_supply,
  297. };
  298. /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
  299. static struct regulator_init_data beagle_vdac = {
  300. .constraints = {
  301. .min_uV = 1800000,
  302. .max_uV = 1800000,
  303. .valid_modes_mask = REGULATOR_MODE_NORMAL
  304. | REGULATOR_MODE_STANDBY,
  305. .valid_ops_mask = REGULATOR_CHANGE_MODE
  306. | REGULATOR_CHANGE_STATUS,
  307. },
  308. .num_consumer_supplies = 1,
  309. .consumer_supplies = &beagle_vdac_supply,
  310. };
  311. /* VPLL2 for digital video outputs */
  312. static struct regulator_init_data beagle_vpll2 = {
  313. .constraints = {
  314. .name = "VDVI",
  315. .min_uV = 1800000,
  316. .max_uV = 1800000,
  317. .valid_modes_mask = REGULATOR_MODE_NORMAL
  318. | REGULATOR_MODE_STANDBY,
  319. .valid_ops_mask = REGULATOR_CHANGE_MODE
  320. | REGULATOR_CHANGE_STATUS,
  321. },
  322. .num_consumer_supplies = 1,
  323. .consumer_supplies = &beagle_vdvi_supply,
  324. };
  325. static struct twl4030_usb_data beagle_usb_data = {
  326. .usb_mode = T2_USB_MODE_ULPI,
  327. };
  328. static struct twl4030_codec_audio_data beagle_audio_data = {
  329. .audio_mclk = 26000000,
  330. };
  331. static struct twl4030_codec_data beagle_codec_data = {
  332. .audio_mclk = 26000000,
  333. .audio = &beagle_audio_data,
  334. };
  335. static struct twl4030_platform_data beagle_twldata = {
  336. .irq_base = TWL4030_IRQ_BASE,
  337. .irq_end = TWL4030_IRQ_END,
  338. /* platform_data for children goes here */
  339. .usb = &beagle_usb_data,
  340. .gpio = &beagle_gpio_data,
  341. .codec = &beagle_codec_data,
  342. .vmmc1 = &beagle_vmmc1,
  343. .vsim = &beagle_vsim,
  344. .vdac = &beagle_vdac,
  345. .vpll2 = &beagle_vpll2,
  346. };
  347. static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
  348. {
  349. I2C_BOARD_INFO("twl4030", 0x48),
  350. .flags = I2C_CLIENT_WAKE,
  351. .irq = INT_34XX_SYS_NIRQ,
  352. .platform_data = &beagle_twldata,
  353. },
  354. };
  355. static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
  356. {
  357. I2C_BOARD_INFO("eeprom", 0x50),
  358. },
  359. };
  360. static int __init omap3_beagle_i2c_init(void)
  361. {
  362. omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
  363. ARRAY_SIZE(beagle_i2c_boardinfo));
  364. /* Bus 3 is attached to the DVI port where devices like the pico DLP
  365. * projector don't work reliably with 400kHz */
  366. omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));
  367. return 0;
  368. }
  369. static struct gpio_led gpio_leds[] = {
  370. {
  371. .name = "beagleboard::usr0",
  372. .default_trigger = "heartbeat",
  373. .gpio = 150,
  374. },
  375. {
  376. .name = "beagleboard::usr1",
  377. .default_trigger = "mmc0",
  378. .gpio = 149,
  379. },
  380. {
  381. .name = "beagleboard::pmu_stat",
  382. .gpio = -EINVAL, /* gets replaced */
  383. .active_low = true,
  384. },
  385. };
  386. static struct gpio_led_platform_data gpio_led_info = {
  387. .leds = gpio_leds,
  388. .num_leds = ARRAY_SIZE(gpio_leds),
  389. };
  390. static struct platform_device leds_gpio = {
  391. .name = "leds-gpio",
  392. .id = -1,
  393. .dev = {
  394. .platform_data = &gpio_led_info,
  395. },
  396. };
  397. static struct gpio_keys_button gpio_buttons[] = {
  398. {
  399. .code = BTN_EXTRA,
  400. .gpio = 7,
  401. .desc = "user",
  402. .wakeup = 1,
  403. },
  404. };
  405. static struct gpio_keys_platform_data gpio_key_info = {
  406. .buttons = gpio_buttons,
  407. .nbuttons = ARRAY_SIZE(gpio_buttons),
  408. };
  409. static struct platform_device keys_gpio = {
  410. .name = "gpio-keys",
  411. .id = -1,
  412. .dev = {
  413. .platform_data = &gpio_key_info,
  414. },
  415. };
  416. static void __init omap3_beagle_init_irq(void)
  417. {
  418. omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
  419. mt46h32m32lf6_sdrc_params);
  420. omap_init_irq();
  421. #ifdef CONFIG_OMAP_32K_TIMER
  422. omap2_gp_clockevent_set_gptimer(12);
  423. #endif
  424. omap_gpio_init();
  425. }
  426. static struct platform_device *omap3_beagle_devices[] __initdata = {
  427. &leds_gpio,
  428. &keys_gpio,
  429. &beagle_dss_device,
  430. };
  431. static void __init omap3beagle_flash_init(void)
  432. {
  433. u8 cs = 0;
  434. u8 nandcs = GPMC_CS_NUM + 1;
  435. /* find out the chip-select on which NAND exists */
  436. while (cs < GPMC_CS_NUM) {
  437. u32 ret = 0;
  438. ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
  439. if ((ret & 0xC00) == 0x800) {
  440. printk(KERN_INFO "Found NAND on CS%d\n", cs);
  441. if (nandcs > GPMC_CS_NUM)
  442. nandcs = cs;
  443. }
  444. cs++;
  445. }
  446. if (nandcs > GPMC_CS_NUM) {
  447. printk(KERN_INFO "NAND: Unable to find configuration "
  448. "in GPMC\n ");
  449. return;
  450. }
  451. if (nandcs < GPMC_CS_NUM) {
  452. omap3beagle_nand_data.cs = nandcs;
  453. printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
  454. if (gpmc_nand_init(&omap3beagle_nand_data) < 0)
  455. printk(KERN_ERR "Unable to register NAND device\n");
  456. }
  457. }
  458. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  459. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  460. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  461. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  462. .phy_reset = true,
  463. .reset_gpio_port[0] = -EINVAL,
  464. .reset_gpio_port[1] = 147,
  465. .reset_gpio_port[2] = -EINVAL
  466. };
  467. #ifdef CONFIG_OMAP_MUX
  468. static struct omap_board_mux board_mux[] __initdata = {
  469. { .reg_offset = OMAP_MUX_TERMINATOR },
  470. };
  471. #else
  472. #define board_mux NULL
  473. #endif
  474. static struct omap_musb_board_data musb_board_data = {
  475. .interface_type = MUSB_INTERFACE_ULPI,
  476. .mode = MUSB_OTG,
  477. .power = 100,
  478. };
  479. static void __init omap3_beagle_init(void)
  480. {
  481. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  482. omap3_beagle_init_rev();
  483. omap3_beagle_i2c_init();
  484. platform_add_devices(omap3_beagle_devices,
  485. ARRAY_SIZE(omap3_beagle_devices));
  486. omap_serial_init();
  487. omap_mux_init_gpio(170, OMAP_PIN_INPUT);
  488. gpio_request(170, "DVI_nPD");
  489. /* REVISIT leave DVI powered down until it's needed ... */
  490. gpio_direction_output(170, true);
  491. usb_musb_init(&musb_board_data);
  492. usb_ehci_init(&ehci_pdata);
  493. omap3beagle_flash_init();
  494. /* Ensure SDRC pins are mux'd for self-refresh */
  495. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  496. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  497. beagle_display_init();
  498. }
  499. MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
  500. /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
  501. .boot_params = 0x80000100,
  502. .map_io = omap3_map_io,
  503. .reserve = omap_reserve,
  504. .init_irq = omap3_beagle_init_irq,
  505. .init_machine = omap3_beagle_init,
  506. .timer = &omap_timer,
  507. MACHINE_END