board-omap3beagle.c 14 KB

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