board-omap3beagle.c 12 KB

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