board-omap3touchbook.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. /*
  2. * linux/arch/arm/mach-omap2/board-omap3touchbook.c
  3. *
  4. * Copyright (C) 2009 Always Innovating
  5. *
  6. * Modified from mach-omap2/board-omap3beagleboard.c
  7. *
  8. * Initial code: Grégoire Gentil, Tim Yamin
  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 <plat/mcspi.h>
  30. #include <linux/spi/spi.h>
  31. #include <linux/spi/ads7846.h>
  32. #include <linux/regulator/machine.h>
  33. #include <linux/i2c/twl.h>
  34. #include <mach/hardware.h>
  35. #include <asm/mach-types.h>
  36. #include <asm/mach/arch.h>
  37. #include <asm/mach/map.h>
  38. #include <asm/mach/flash.h>
  39. #include <plat/board.h>
  40. #include <plat/common.h>
  41. #include <plat/gpmc.h>
  42. #include <plat/nand.h>
  43. #include <plat/usb.h>
  44. #include "mux.h"
  45. #include "hsmmc.h"
  46. #include "timer-gp.h"
  47. #include "common-board-devices.h"
  48. #include <asm/setup.h>
  49. #define NAND_BLOCK_SIZE SZ_128K
  50. #define OMAP3_AC_GPIO 136
  51. #define OMAP3_TS_GPIO 162
  52. #define TB_BL_PWM_TIMER 9
  53. #define TB_KILL_POWER_GPIO 168
  54. static unsigned long touchbook_revision;
  55. static struct mtd_partition omap3touchbook_nand_partitions[] = {
  56. /* All the partition sizes are listed in terms of NAND block size */
  57. {
  58. .name = "X-Loader",
  59. .offset = 0,
  60. .size = 4 * NAND_BLOCK_SIZE,
  61. .mask_flags = MTD_WRITEABLE, /* force read-only */
  62. },
  63. {
  64. .name = "U-Boot",
  65. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  66. .size = 15 * NAND_BLOCK_SIZE,
  67. .mask_flags = MTD_WRITEABLE, /* force read-only */
  68. },
  69. {
  70. .name = "U-Boot Env",
  71. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  72. .size = 1 * NAND_BLOCK_SIZE,
  73. },
  74. {
  75. .name = "Kernel",
  76. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  77. .size = 32 * NAND_BLOCK_SIZE,
  78. },
  79. {
  80. .name = "File System",
  81. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  82. .size = MTDPART_SIZ_FULL,
  83. },
  84. };
  85. #include "sdram-micron-mt46h32m32lf-6.h"
  86. static struct omap2_hsmmc_info mmc[] = {
  87. {
  88. .mmc = 1,
  89. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  90. .gpio_wp = 29,
  91. },
  92. {} /* Terminator */
  93. };
  94. static struct platform_device omap3_touchbook_lcd_device = {
  95. .name = "omap3touchbook_lcd",
  96. .id = -1,
  97. };
  98. static struct omap_lcd_config omap3_touchbook_lcd_config __initdata = {
  99. .ctrl_name = "internal",
  100. };
  101. static struct regulator_consumer_supply touchbook_vmmc1_supply = {
  102. .supply = "vmmc",
  103. };
  104. static struct regulator_consumer_supply touchbook_vsim_supply = {
  105. .supply = "vmmc_aux",
  106. };
  107. static struct gpio_led gpio_leds[];
  108. static int touchbook_twl_gpio_setup(struct device *dev,
  109. unsigned gpio, unsigned ngpio)
  110. {
  111. if (system_rev >= 0x20 && system_rev <= 0x34301000) {
  112. omap_mux_init_gpio(23, OMAP_PIN_INPUT);
  113. mmc[0].gpio_wp = 23;
  114. } else {
  115. omap_mux_init_gpio(29, OMAP_PIN_INPUT);
  116. }
  117. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  118. mmc[0].gpio_cd = gpio + 0;
  119. omap2_hsmmc_init(mmc);
  120. /* link regulators to MMC adapters */
  121. touchbook_vmmc1_supply.dev = mmc[0].dev;
  122. touchbook_vsim_supply.dev = mmc[0].dev;
  123. /* REVISIT: need ehci-omap hooks for external VBUS
  124. * power switch and overcurrent detect
  125. */
  126. gpio_request(gpio + 1, "EHCI_nOC");
  127. gpio_direction_input(gpio + 1);
  128. /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
  129. gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
  130. gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
  131. /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
  132. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  133. return 0;
  134. }
  135. static struct twl4030_gpio_platform_data touchbook_gpio_data = {
  136. .gpio_base = OMAP_MAX_GPIO_LINES,
  137. .irq_base = TWL4030_GPIO_IRQ_BASE,
  138. .irq_end = TWL4030_GPIO_IRQ_END,
  139. .use_leds = true,
  140. .pullups = BIT(1),
  141. .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
  142. | BIT(15) | BIT(16) | BIT(17),
  143. .setup = touchbook_twl_gpio_setup,
  144. };
  145. static struct regulator_consumer_supply touchbook_vdac_supply = {
  146. .supply = "vdac",
  147. .dev = &omap3_touchbook_lcd_device.dev,
  148. };
  149. static struct regulator_consumer_supply touchbook_vdvi_supply = {
  150. .supply = "vdvi",
  151. .dev = &omap3_touchbook_lcd_device.dev,
  152. };
  153. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  154. static struct regulator_init_data touchbook_vmmc1 = {
  155. .constraints = {
  156. .min_uV = 1850000,
  157. .max_uV = 3150000,
  158. .valid_modes_mask = REGULATOR_MODE_NORMAL
  159. | REGULATOR_MODE_STANDBY,
  160. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  161. | REGULATOR_CHANGE_MODE
  162. | REGULATOR_CHANGE_STATUS,
  163. },
  164. .num_consumer_supplies = 1,
  165. .consumer_supplies = &touchbook_vmmc1_supply,
  166. };
  167. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  168. static struct regulator_init_data touchbook_vsim = {
  169. .constraints = {
  170. .min_uV = 1800000,
  171. .max_uV = 3000000,
  172. .valid_modes_mask = REGULATOR_MODE_NORMAL
  173. | REGULATOR_MODE_STANDBY,
  174. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  175. | REGULATOR_CHANGE_MODE
  176. | REGULATOR_CHANGE_STATUS,
  177. },
  178. .num_consumer_supplies = 1,
  179. .consumer_supplies = &touchbook_vsim_supply,
  180. };
  181. /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
  182. static struct regulator_init_data touchbook_vdac = {
  183. .constraints = {
  184. .min_uV = 1800000,
  185. .max_uV = 1800000,
  186. .valid_modes_mask = REGULATOR_MODE_NORMAL
  187. | REGULATOR_MODE_STANDBY,
  188. .valid_ops_mask = REGULATOR_CHANGE_MODE
  189. | REGULATOR_CHANGE_STATUS,
  190. },
  191. .num_consumer_supplies = 1,
  192. .consumer_supplies = &touchbook_vdac_supply,
  193. };
  194. /* VPLL2 for digital video outputs */
  195. static struct regulator_init_data touchbook_vpll2 = {
  196. .constraints = {
  197. .name = "VDVI",
  198. .min_uV = 1800000,
  199. .max_uV = 1800000,
  200. .valid_modes_mask = REGULATOR_MODE_NORMAL
  201. | REGULATOR_MODE_STANDBY,
  202. .valid_ops_mask = REGULATOR_CHANGE_MODE
  203. | REGULATOR_CHANGE_STATUS,
  204. },
  205. .num_consumer_supplies = 1,
  206. .consumer_supplies = &touchbook_vdvi_supply,
  207. };
  208. static struct twl4030_usb_data touchbook_usb_data = {
  209. .usb_mode = T2_USB_MODE_ULPI,
  210. };
  211. static struct twl4030_codec_audio_data touchbook_audio_data;
  212. static struct twl4030_codec_data touchbook_codec_data = {
  213. .audio_mclk = 26000000,
  214. .audio = &touchbook_audio_data,
  215. };
  216. static struct twl4030_platform_data touchbook_twldata = {
  217. .irq_base = TWL4030_IRQ_BASE,
  218. .irq_end = TWL4030_IRQ_END,
  219. /* platform_data for children goes here */
  220. .usb = &touchbook_usb_data,
  221. .gpio = &touchbook_gpio_data,
  222. .codec = &touchbook_codec_data,
  223. .vmmc1 = &touchbook_vmmc1,
  224. .vsim = &touchbook_vsim,
  225. .vdac = &touchbook_vdac,
  226. .vpll2 = &touchbook_vpll2,
  227. };
  228. static struct i2c_board_info __initdata touchBook_i2c_boardinfo[] = {
  229. {
  230. I2C_BOARD_INFO("bq27200", 0x55),
  231. },
  232. };
  233. static int __init omap3_touchbook_i2c_init(void)
  234. {
  235. /* Standard TouchBook bus */
  236. omap3_pmic_init("twl4030", &touchbook_twldata);
  237. /* Additional TouchBook bus */
  238. omap_register_i2c_bus(3, 100, touchBook_i2c_boardinfo,
  239. ARRAY_SIZE(touchBook_i2c_boardinfo));
  240. return 0;
  241. }
  242. static struct ads7846_platform_data ads7846_pdata = {
  243. .x_min = 100,
  244. .y_min = 265,
  245. .x_max = 3950,
  246. .y_max = 3750,
  247. .x_plate_ohms = 40,
  248. .pressure_max = 255,
  249. .debounce_max = 10,
  250. .debounce_tol = 5,
  251. .debounce_rep = 1,
  252. .gpio_pendown = OMAP3_TS_GPIO,
  253. .keep_vref_on = 1,
  254. };
  255. static struct gpio_led gpio_leds[] = {
  256. {
  257. .name = "touchbook::usr0",
  258. .default_trigger = "heartbeat",
  259. .gpio = 150,
  260. },
  261. {
  262. .name = "touchbook::usr1",
  263. .default_trigger = "mmc0",
  264. .gpio = 149,
  265. },
  266. {
  267. .name = "touchbook::pmu_stat",
  268. .gpio = -EINVAL, /* gets replaced */
  269. .active_low = true,
  270. },
  271. };
  272. static struct gpio_led_platform_data gpio_led_info = {
  273. .leds = gpio_leds,
  274. .num_leds = ARRAY_SIZE(gpio_leds),
  275. };
  276. static struct platform_device leds_gpio = {
  277. .name = "leds-gpio",
  278. .id = -1,
  279. .dev = {
  280. .platform_data = &gpio_led_info,
  281. },
  282. };
  283. static struct gpio_keys_button gpio_buttons[] = {
  284. {
  285. .code = BTN_EXTRA,
  286. .gpio = 7,
  287. .desc = "user",
  288. .wakeup = 1,
  289. },
  290. {
  291. .code = KEY_POWER,
  292. .gpio = 183,
  293. .desc = "power",
  294. .wakeup = 1,
  295. },
  296. };
  297. static struct gpio_keys_platform_data gpio_key_info = {
  298. .buttons = gpio_buttons,
  299. .nbuttons = ARRAY_SIZE(gpio_buttons),
  300. };
  301. static struct platform_device keys_gpio = {
  302. .name = "gpio-keys",
  303. .id = -1,
  304. .dev = {
  305. .platform_data = &gpio_key_info,
  306. },
  307. };
  308. static struct omap_board_config_kernel omap3_touchbook_config[] __initdata = {
  309. { OMAP_TAG_LCD, &omap3_touchbook_lcd_config },
  310. };
  311. #ifdef CONFIG_OMAP_MUX
  312. static struct omap_board_mux board_mux[] __initdata = {
  313. { .reg_offset = OMAP_MUX_TERMINATOR },
  314. };
  315. #endif
  316. static void __init omap3_touchbook_init_early(void)
  317. {
  318. omap2_init_common_infrastructure();
  319. omap2_init_common_devices(mt46h32m32lf6_sdrc_params,
  320. mt46h32m32lf6_sdrc_params);
  321. }
  322. static void __init omap3_touchbook_init_irq(void)
  323. {
  324. omap_init_irq();
  325. #ifdef CONFIG_OMAP_32K_TIMER
  326. omap2_gp_clockevent_set_gptimer(12);
  327. #endif
  328. }
  329. static struct platform_device *omap3_touchbook_devices[] __initdata = {
  330. &omap3_touchbook_lcd_device,
  331. &leds_gpio,
  332. &keys_gpio,
  333. };
  334. static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
  335. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  336. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  337. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  338. .phy_reset = true,
  339. .reset_gpio_port[0] = -EINVAL,
  340. .reset_gpio_port[1] = 147,
  341. .reset_gpio_port[2] = -EINVAL
  342. };
  343. static void omap3_touchbook_poweroff(void)
  344. {
  345. int r;
  346. r = gpio_request(TB_KILL_POWER_GPIO, "DVI reset");
  347. if (r < 0) {
  348. printk(KERN_ERR "Unable to get kill power GPIO\n");
  349. return;
  350. }
  351. gpio_direction_output(TB_KILL_POWER_GPIO, 0);
  352. }
  353. static int __init early_touchbook_revision(char *p)
  354. {
  355. if (!p)
  356. return 0;
  357. return strict_strtoul(p, 10, &touchbook_revision);
  358. }
  359. early_param("tbr", early_touchbook_revision);
  360. static struct omap_musb_board_data musb_board_data = {
  361. .interface_type = MUSB_INTERFACE_ULPI,
  362. .mode = MUSB_OTG,
  363. .power = 100,
  364. };
  365. static void __init omap3_touchbook_init(void)
  366. {
  367. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  368. omap_board_config = omap3_touchbook_config;
  369. omap_board_config_size = ARRAY_SIZE(omap3_touchbook_config);
  370. pm_power_off = omap3_touchbook_poweroff;
  371. omap3_touchbook_i2c_init();
  372. platform_add_devices(omap3_touchbook_devices,
  373. ARRAY_SIZE(omap3_touchbook_devices));
  374. omap_serial_init();
  375. omap_mux_init_gpio(170, OMAP_PIN_INPUT);
  376. gpio_request(176, "DVI_nPD");
  377. /* REVISIT leave DVI powered down until it's needed ... */
  378. gpio_direction_output(176, true);
  379. /* Touchscreen and accelerometer */
  380. omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
  381. usb_musb_init(&musb_board_data);
  382. usbhs_init(&usbhs_bdata);
  383. omap_nand_flash_init(NAND_BUSWIDTH_16, omap3touchbook_nand_partitions,
  384. ARRAY_SIZE(omap3touchbook_nand_partitions));
  385. /* Ensure SDRC pins are mux'd for self-refresh */
  386. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  387. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  388. }
  389. MACHINE_START(TOUCHBOOK, "OMAP3 touchbook Board")
  390. /* Maintainer: Gregoire Gentil - http://www.alwaysinnovating.com */
  391. .boot_params = 0x80000100,
  392. .reserve = omap_reserve,
  393. .map_io = omap3_map_io,
  394. .init_early = omap3_touchbook_init_early,
  395. .init_irq = omap3_touchbook_init_irq,
  396. .init_machine = omap3_touchbook_init,
  397. .timer = &omap_timer,
  398. MACHINE_END