board-omap3touchbook.c 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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 <linux/usb/phy.h>
  30. #include <linux/platform_data/spi-omap2-mcspi.h>
  31. #include <linux/spi/spi.h>
  32. #include <linux/spi/ads7846.h>
  33. #include <linux/regulator/machine.h>
  34. #include <linux/i2c/twl.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 <asm/system_info.h>
  40. #include "common.h"
  41. #include "gpmc.h"
  42. #include <linux/platform_data/mtd-nand-omap2.h>
  43. #include "mux.h"
  44. #include "hsmmc.h"
  45. #include "board-flash.h"
  46. #include "common-board-devices.h"
  47. #include <asm/setup.h>
  48. #define OMAP3_AC_GPIO 136
  49. #define OMAP3_TS_GPIO 162
  50. #define TB_BL_PWM_TIMER 9
  51. #define TB_KILL_POWER_GPIO 168
  52. #define NAND_CS 0
  53. static unsigned long touchbook_revision;
  54. static struct mtd_partition omap3touchbook_nand_partitions[] = {
  55. /* All the partition sizes are listed in terms of NAND block size */
  56. {
  57. .name = "X-Loader",
  58. .offset = 0,
  59. .size = 4 * NAND_BLOCK_SIZE,
  60. .mask_flags = MTD_WRITEABLE, /* force read-only */
  61. },
  62. {
  63. .name = "U-Boot",
  64. .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
  65. .size = 15 * NAND_BLOCK_SIZE,
  66. .mask_flags = MTD_WRITEABLE, /* force read-only */
  67. },
  68. {
  69. .name = "U-Boot Env",
  70. .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
  71. .size = 1 * NAND_BLOCK_SIZE,
  72. },
  73. {
  74. .name = "Kernel",
  75. .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
  76. .size = 32 * NAND_BLOCK_SIZE,
  77. },
  78. {
  79. .name = "File System",
  80. .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
  81. .size = MTDPART_SIZ_FULL,
  82. },
  83. };
  84. #include "sdram-micron-mt46h32m32lf-6.h"
  85. static struct omap2_hsmmc_info mmc[] = {
  86. {
  87. .mmc = 1,
  88. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  89. .gpio_wp = 29,
  90. .deferred = true,
  91. },
  92. {} /* Terminator */
  93. };
  94. static struct regulator_consumer_supply touchbook_vmmc1_supply[] = {
  95. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  96. };
  97. static struct regulator_consumer_supply touchbook_vsim_supply[] = {
  98. REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.0"),
  99. };
  100. static struct gpio_led gpio_leds[];
  101. static int touchbook_twl_gpio_setup(struct device *dev,
  102. unsigned gpio, unsigned ngpio)
  103. {
  104. /* gpio + 0 is "mmc0_cd" (input/IRQ) */
  105. mmc[0].gpio_cd = gpio + 0;
  106. omap_hsmmc_late_init(mmc);
  107. /* REVISIT: need ehci-omap hooks for external VBUS
  108. * power switch and overcurrent detect
  109. */
  110. gpio_request_one(gpio + 1, GPIOF_IN, "EHCI_nOC");
  111. /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
  112. gpio_request_one(gpio + TWL4030_GPIO_MAX, GPIOF_OUT_INIT_LOW,
  113. "nEN_USB_PWR");
  114. /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
  115. gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
  116. return 0;
  117. }
  118. static struct twl4030_gpio_platform_data touchbook_gpio_data = {
  119. .use_leds = true,
  120. .pullups = BIT(1),
  121. .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
  122. | BIT(15) | BIT(16) | BIT(17),
  123. .setup = touchbook_twl_gpio_setup,
  124. };
  125. static struct regulator_consumer_supply touchbook_vdac_supply[] = {
  126. {
  127. .supply = "vdac",
  128. },
  129. };
  130. static struct regulator_consumer_supply touchbook_vdvi_supply[] = {
  131. {
  132. .supply = "vdvi",
  133. },
  134. };
  135. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  136. static struct regulator_init_data touchbook_vmmc1 = {
  137. .constraints = {
  138. .min_uV = 1850000,
  139. .max_uV = 3150000,
  140. .valid_modes_mask = REGULATOR_MODE_NORMAL
  141. | REGULATOR_MODE_STANDBY,
  142. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  143. | REGULATOR_CHANGE_MODE
  144. | REGULATOR_CHANGE_STATUS,
  145. },
  146. .num_consumer_supplies = ARRAY_SIZE(touchbook_vmmc1_supply),
  147. .consumer_supplies = touchbook_vmmc1_supply,
  148. };
  149. /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
  150. static struct regulator_init_data touchbook_vsim = {
  151. .constraints = {
  152. .min_uV = 1800000,
  153. .max_uV = 3000000,
  154. .valid_modes_mask = REGULATOR_MODE_NORMAL
  155. | REGULATOR_MODE_STANDBY,
  156. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  157. | REGULATOR_CHANGE_MODE
  158. | REGULATOR_CHANGE_STATUS,
  159. },
  160. .num_consumer_supplies = ARRAY_SIZE(touchbook_vsim_supply),
  161. .consumer_supplies = touchbook_vsim_supply,
  162. };
  163. static struct twl4030_platform_data touchbook_twldata = {
  164. /* platform_data for children goes here */
  165. .gpio = &touchbook_gpio_data,
  166. .vmmc1 = &touchbook_vmmc1,
  167. .vsim = &touchbook_vsim,
  168. };
  169. static struct i2c_board_info __initdata touchBook_i2c_boardinfo[] = {
  170. {
  171. I2C_BOARD_INFO("bq27200", 0x55),
  172. },
  173. };
  174. static int __init omap3_touchbook_i2c_init(void)
  175. {
  176. /* Standard TouchBook bus */
  177. omap3_pmic_get_config(&touchbook_twldata,
  178. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_AUDIO,
  179. TWL_COMMON_REGULATOR_VDAC | TWL_COMMON_REGULATOR_VPLL2);
  180. touchbook_twldata.vdac->num_consumer_supplies =
  181. ARRAY_SIZE(touchbook_vdac_supply);
  182. touchbook_twldata.vdac->consumer_supplies = touchbook_vdac_supply;
  183. touchbook_twldata.vpll2->constraints.name = "VDVI";
  184. touchbook_twldata.vpll2->num_consumer_supplies =
  185. ARRAY_SIZE(touchbook_vdvi_supply);
  186. touchbook_twldata.vpll2->consumer_supplies = touchbook_vdvi_supply;
  187. omap3_pmic_init("twl4030", &touchbook_twldata);
  188. /* Additional TouchBook bus */
  189. omap_register_i2c_bus(3, 100, touchBook_i2c_boardinfo,
  190. ARRAY_SIZE(touchBook_i2c_boardinfo));
  191. return 0;
  192. }
  193. static struct ads7846_platform_data ads7846_pdata = {
  194. .x_min = 100,
  195. .y_min = 265,
  196. .x_max = 3950,
  197. .y_max = 3750,
  198. .x_plate_ohms = 40,
  199. .pressure_max = 255,
  200. .debounce_max = 10,
  201. .debounce_tol = 5,
  202. .debounce_rep = 1,
  203. .gpio_pendown = OMAP3_TS_GPIO,
  204. .keep_vref_on = 1,
  205. };
  206. static struct gpio_led gpio_leds[] = {
  207. {
  208. .name = "touchbook::usr0",
  209. .default_trigger = "heartbeat",
  210. .gpio = 150,
  211. },
  212. {
  213. .name = "touchbook::usr1",
  214. .default_trigger = "mmc0",
  215. .gpio = 149,
  216. },
  217. {
  218. .name = "touchbook::pmu_stat",
  219. .gpio = -EINVAL, /* gets replaced */
  220. .active_low = true,
  221. },
  222. };
  223. static struct gpio_led_platform_data gpio_led_info = {
  224. .leds = gpio_leds,
  225. .num_leds = ARRAY_SIZE(gpio_leds),
  226. };
  227. static struct platform_device leds_gpio = {
  228. .name = "leds-gpio",
  229. .id = -1,
  230. .dev = {
  231. .platform_data = &gpio_led_info,
  232. },
  233. };
  234. static struct gpio_keys_button gpio_buttons[] = {
  235. {
  236. .code = BTN_EXTRA,
  237. .gpio = 7,
  238. .desc = "user",
  239. .wakeup = 1,
  240. },
  241. {
  242. .code = KEY_POWER,
  243. .gpio = 183,
  244. .desc = "power",
  245. .wakeup = 1,
  246. },
  247. };
  248. static struct gpio_keys_platform_data gpio_key_info = {
  249. .buttons = gpio_buttons,
  250. .nbuttons = ARRAY_SIZE(gpio_buttons),
  251. };
  252. static struct platform_device keys_gpio = {
  253. .name = "gpio-keys",
  254. .id = -1,
  255. .dev = {
  256. .platform_data = &gpio_key_info,
  257. },
  258. };
  259. #ifdef CONFIG_OMAP_MUX
  260. static struct omap_board_mux board_mux[] __initdata = {
  261. { .reg_offset = OMAP_MUX_TERMINATOR },
  262. };
  263. #endif
  264. static struct platform_device *omap3_touchbook_devices[] __initdata = {
  265. &leds_gpio,
  266. &keys_gpio,
  267. };
  268. static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
  269. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  270. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  271. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  272. .phy_reset = true,
  273. .reset_gpio_port[0] = -EINVAL,
  274. .reset_gpio_port[1] = 147,
  275. .reset_gpio_port[2] = -EINVAL
  276. };
  277. static void omap3_touchbook_poweroff(void)
  278. {
  279. int pwr_off = TB_KILL_POWER_GPIO;
  280. if (gpio_request_one(pwr_off, GPIOF_OUT_INIT_LOW, "DVI reset") < 0)
  281. printk(KERN_ERR "Unable to get kill power GPIO\n");
  282. }
  283. static int __init early_touchbook_revision(char *p)
  284. {
  285. if (!p)
  286. return 0;
  287. return strict_strtoul(p, 10, &touchbook_revision);
  288. }
  289. early_param("tbr", early_touchbook_revision);
  290. static void __init omap3_touchbook_init(void)
  291. {
  292. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  293. pm_power_off = omap3_touchbook_poweroff;
  294. if (system_rev >= 0x20 && system_rev <= 0x34301000) {
  295. omap_mux_init_gpio(23, OMAP_PIN_INPUT);
  296. mmc[0].gpio_wp = 23;
  297. } else {
  298. omap_mux_init_gpio(29, OMAP_PIN_INPUT);
  299. }
  300. omap_hsmmc_init(mmc);
  301. omap3_touchbook_i2c_init();
  302. platform_add_devices(omap3_touchbook_devices,
  303. ARRAY_SIZE(omap3_touchbook_devices));
  304. omap_serial_init();
  305. omap_sdrc_init(mt46h32m32lf6_sdrc_params,
  306. mt46h32m32lf6_sdrc_params);
  307. omap_mux_init_gpio(170, OMAP_PIN_INPUT);
  308. /* REVISIT leave DVI powered down until it's needed ... */
  309. gpio_request_one(176, GPIOF_OUT_INIT_HIGH, "DVI_nPD");
  310. /* Touchscreen and accelerometer */
  311. omap_ads7846_init(4, OMAP3_TS_GPIO, 310, &ads7846_pdata);
  312. usb_bind_phy("musb-hdrc.0.auto", 0, "twl4030_usb");
  313. usb_musb_init(NULL);
  314. usbhs_init(&usbhs_bdata);
  315. board_nand_init(omap3touchbook_nand_partitions,
  316. ARRAY_SIZE(omap3touchbook_nand_partitions), NAND_CS,
  317. NAND_BUSWIDTH_16, NULL);
  318. /* Ensure SDRC pins are mux'd for self-refresh */
  319. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  320. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  321. }
  322. MACHINE_START(TOUCHBOOK, "OMAP3 touchbook Board")
  323. /* Maintainer: Gregoire Gentil - http://www.alwaysinnovating.com */
  324. .atag_offset = 0x100,
  325. .reserve = omap_reserve,
  326. .map_io = omap3_map_io,
  327. .init_early = omap3430_init_early,
  328. .init_irq = omap3_init_irq,
  329. .handle_irq = omap3_intc_handle_irq,
  330. .init_machine = omap3_touchbook_init,
  331. .init_late = omap3430_init_late,
  332. .init_time = omap3_secure_sync32k_timer_init,
  333. .restart = omap3xxx_restart,
  334. MACHINE_END