board-omap3pandora.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /*
  2. * board-omap3pandora.c (Pandora Handheld Console)
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  16. * 02110-1301 USA
  17. *
  18. */
  19. #include <linux/init.h>
  20. #include <linux/kernel.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/spi/ads7846.h>
  24. #include <linux/regulator/machine.h>
  25. #include <linux/i2c/twl.h>
  26. #include <linux/spi/wl12xx.h>
  27. #include <linux/mtd/partitions.h>
  28. #include <linux/mtd/nand.h>
  29. #include <linux/leds.h>
  30. #include <linux/input.h>
  31. #include <linux/input/matrix_keypad.h>
  32. #include <linux/gpio_keys.h>
  33. #include <linux/mmc/card.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <plat/board.h>
  38. #include <plat/common.h>
  39. #include <mach/gpio.h>
  40. #include <mach/hardware.h>
  41. #include <plat/mcspi.h>
  42. #include <plat/usb.h>
  43. #include <plat/display.h>
  44. #include <plat/nand.h>
  45. #include "mux.h"
  46. #include "sdram-micron-mt46h32m32lf-6.h"
  47. #include "hsmmc.h"
  48. #define PANDORA_WIFI_IRQ_GPIO 21
  49. #define PANDORA_WIFI_NRESET_GPIO 23
  50. #define OMAP3_PANDORA_TS_GPIO 94
  51. #define NAND_BLOCK_SIZE SZ_128K
  52. static struct mtd_partition omap3pandora_nand_partitions[] = {
  53. {
  54. .name = "xloader",
  55. .offset = 0,
  56. .size = 4 * NAND_BLOCK_SIZE,
  57. .mask_flags = MTD_WRITEABLE
  58. }, {
  59. .name = "uboot",
  60. .offset = MTDPART_OFS_APPEND,
  61. .size = 15 * NAND_BLOCK_SIZE,
  62. }, {
  63. .name = "uboot-env",
  64. .offset = MTDPART_OFS_APPEND,
  65. .size = 1 * NAND_BLOCK_SIZE,
  66. }, {
  67. .name = "boot",
  68. .offset = MTDPART_OFS_APPEND,
  69. .size = 80 * NAND_BLOCK_SIZE,
  70. }, {
  71. .name = "rootfs",
  72. .offset = MTDPART_OFS_APPEND,
  73. .size = MTDPART_SIZ_FULL,
  74. },
  75. };
  76. static struct omap_nand_platform_data pandora_nand_data = {
  77. .cs = 0,
  78. .devsize = 1, /* '0' for 8-bit, '1' for 16-bit device */
  79. .parts = omap3pandora_nand_partitions,
  80. .nr_parts = ARRAY_SIZE(omap3pandora_nand_partitions),
  81. };
  82. static struct gpio_led pandora_gpio_leds[] = {
  83. {
  84. .name = "pandora::sd1",
  85. .default_trigger = "mmc0",
  86. .gpio = 128,
  87. }, {
  88. .name = "pandora::sd2",
  89. .default_trigger = "mmc1",
  90. .gpio = 129,
  91. }, {
  92. .name = "pandora::bluetooth",
  93. .gpio = 158,
  94. }, {
  95. .name = "pandora::wifi",
  96. .gpio = 159,
  97. },
  98. };
  99. static struct gpio_led_platform_data pandora_gpio_led_data = {
  100. .leds = pandora_gpio_leds,
  101. .num_leds = ARRAY_SIZE(pandora_gpio_leds),
  102. };
  103. static struct platform_device pandora_leds_gpio = {
  104. .name = "leds-gpio",
  105. .id = -1,
  106. .dev = {
  107. .platform_data = &pandora_gpio_led_data,
  108. },
  109. };
  110. #define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
  111. { \
  112. .gpio = gpio_num, \
  113. .type = ev_type, \
  114. .code = ev_code, \
  115. .active_low = act_low, \
  116. .debounce_interval = 4, \
  117. .desc = "btn " descr, \
  118. }
  119. #define GPIO_BUTTON_LOW(gpio_num, event_code, description) \
  120. GPIO_BUTTON(gpio_num, EV_KEY, event_code, 1, description)
  121. static struct gpio_keys_button pandora_gpio_keys[] = {
  122. GPIO_BUTTON_LOW(110, KEY_UP, "up"),
  123. GPIO_BUTTON_LOW(103, KEY_DOWN, "down"),
  124. GPIO_BUTTON_LOW(96, KEY_LEFT, "left"),
  125. GPIO_BUTTON_LOW(98, KEY_RIGHT, "right"),
  126. GPIO_BUTTON_LOW(109, KEY_PAGEUP, "game 1"),
  127. GPIO_BUTTON_LOW(111, KEY_END, "game 2"),
  128. GPIO_BUTTON_LOW(106, KEY_PAGEDOWN, "game 3"),
  129. GPIO_BUTTON_LOW(101, KEY_HOME, "game 4"),
  130. GPIO_BUTTON_LOW(102, KEY_RIGHTSHIFT, "l"),
  131. GPIO_BUTTON_LOW(97, KEY_KPPLUS, "l2"),
  132. GPIO_BUTTON_LOW(105, KEY_RIGHTCTRL, "r"),
  133. GPIO_BUTTON_LOW(107, KEY_KPMINUS, "r2"),
  134. GPIO_BUTTON_LOW(104, KEY_LEFTCTRL, "ctrl"),
  135. GPIO_BUTTON_LOW(99, KEY_MENU, "menu"),
  136. GPIO_BUTTON_LOW(176, KEY_COFFEE, "hold"),
  137. GPIO_BUTTON(100, EV_KEY, KEY_LEFTALT, 0, "alt"),
  138. GPIO_BUTTON(108, EV_SW, SW_LID, 1, "lid"),
  139. };
  140. static struct gpio_keys_platform_data pandora_gpio_key_info = {
  141. .buttons = pandora_gpio_keys,
  142. .nbuttons = ARRAY_SIZE(pandora_gpio_keys),
  143. };
  144. static struct platform_device pandora_keys_gpio = {
  145. .name = "gpio-keys",
  146. .id = -1,
  147. .dev = {
  148. .platform_data = &pandora_gpio_key_info,
  149. },
  150. };
  151. static const uint32_t board_keymap[] = {
  152. /* row, col, code */
  153. KEY(0, 0, KEY_9),
  154. KEY(0, 1, KEY_8),
  155. KEY(0, 2, KEY_I),
  156. KEY(0, 3, KEY_J),
  157. KEY(0, 4, KEY_N),
  158. KEY(0, 5, KEY_M),
  159. KEY(1, 0, KEY_0),
  160. KEY(1, 1, KEY_7),
  161. KEY(1, 2, KEY_U),
  162. KEY(1, 3, KEY_H),
  163. KEY(1, 4, KEY_B),
  164. KEY(1, 5, KEY_SPACE),
  165. KEY(2, 0, KEY_BACKSPACE),
  166. KEY(2, 1, KEY_6),
  167. KEY(2, 2, KEY_Y),
  168. KEY(2, 3, KEY_G),
  169. KEY(2, 4, KEY_V),
  170. KEY(2, 5, KEY_FN),
  171. KEY(3, 0, KEY_O),
  172. KEY(3, 1, KEY_5),
  173. KEY(3, 2, KEY_T),
  174. KEY(3, 3, KEY_F),
  175. KEY(3, 4, KEY_C),
  176. KEY(4, 0, KEY_P),
  177. KEY(4, 1, KEY_4),
  178. KEY(4, 2, KEY_R),
  179. KEY(4, 3, KEY_D),
  180. KEY(4, 4, KEY_X),
  181. KEY(5, 0, KEY_K),
  182. KEY(5, 1, KEY_3),
  183. KEY(5, 2, KEY_E),
  184. KEY(5, 3, KEY_S),
  185. KEY(5, 4, KEY_Z),
  186. KEY(6, 0, KEY_L),
  187. KEY(6, 1, KEY_2),
  188. KEY(6, 2, KEY_W),
  189. KEY(6, 3, KEY_A),
  190. KEY(6, 4, KEY_DOT),
  191. KEY(7, 0, KEY_ENTER),
  192. KEY(7, 1, KEY_1),
  193. KEY(7, 2, KEY_Q),
  194. KEY(7, 3, KEY_LEFTSHIFT),
  195. KEY(7, 4, KEY_COMMA),
  196. };
  197. static struct matrix_keymap_data board_map_data = {
  198. .keymap = board_keymap,
  199. .keymap_size = ARRAY_SIZE(board_keymap),
  200. };
  201. static struct twl4030_keypad_data pandora_kp_data = {
  202. .keymap_data = &board_map_data,
  203. .rows = 8,
  204. .cols = 6,
  205. .rep = 1,
  206. };
  207. static struct omap_dss_device pandora_lcd_device = {
  208. .name = "lcd",
  209. .driver_name = "tpo_td043mtea1_panel",
  210. .type = OMAP_DISPLAY_TYPE_DPI,
  211. .phy.dpi.data_lines = 24,
  212. .reset_gpio = 157,
  213. };
  214. static struct omap_dss_device pandora_tv_device = {
  215. .name = "tv",
  216. .driver_name = "venc",
  217. .type = OMAP_DISPLAY_TYPE_VENC,
  218. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  219. };
  220. static struct omap_dss_device *pandora_dss_devices[] = {
  221. &pandora_lcd_device,
  222. &pandora_tv_device,
  223. };
  224. static struct omap_dss_board_info pandora_dss_data = {
  225. .num_devices = ARRAY_SIZE(pandora_dss_devices),
  226. .devices = pandora_dss_devices,
  227. .default_device = &pandora_lcd_device,
  228. };
  229. static struct platform_device pandora_dss_device = {
  230. .name = "omapdss",
  231. .id = -1,
  232. .dev = {
  233. .platform_data = &pandora_dss_data,
  234. },
  235. };
  236. static void pandora_wl1251_init_card(struct mmc_card *card)
  237. {
  238. /*
  239. * We have TI wl1251 attached to MMC3. Pass this information to
  240. * SDIO core because it can't be probed by normal methods.
  241. */
  242. card->quirks |= MMC_QUIRK_NONSTD_SDIO;
  243. card->cccr.wide_bus = 1;
  244. card->cis.vendor = 0x104c;
  245. card->cis.device = 0x9066;
  246. card->cis.blksize = 512;
  247. card->cis.max_dtr = 20000000;
  248. }
  249. static struct omap2_hsmmc_info omap3pandora_mmc[] = {
  250. {
  251. .mmc = 1,
  252. .wires = 4,
  253. .gpio_cd = -EINVAL,
  254. .gpio_wp = 126,
  255. .ext_clock = 0,
  256. },
  257. {
  258. .mmc = 2,
  259. .wires = 4,
  260. .gpio_cd = -EINVAL,
  261. .gpio_wp = 127,
  262. .ext_clock = 1,
  263. .transceiver = true,
  264. },
  265. {
  266. .mmc = 3,
  267. .wires = 4,
  268. .gpio_cd = -EINVAL,
  269. .gpio_wp = -EINVAL,
  270. .init_card = pandora_wl1251_init_card,
  271. },
  272. {} /* Terminator */
  273. };
  274. static int omap3pandora_twl_gpio_setup(struct device *dev,
  275. unsigned gpio, unsigned ngpio)
  276. {
  277. int ret, gpio_32khz;
  278. /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
  279. omap3pandora_mmc[0].gpio_cd = gpio + 0;
  280. omap3pandora_mmc[1].gpio_cd = gpio + 1;
  281. omap2_hsmmc_init(omap3pandora_mmc);
  282. /* gpio + 13 drives 32kHz buffer for wifi module */
  283. gpio_32khz = gpio + 13;
  284. ret = gpio_request(gpio_32khz, "wifi 32kHz");
  285. if (ret < 0) {
  286. pr_err("Cannot get GPIO line %d, ret=%d\n", gpio_32khz, ret);
  287. goto fail;
  288. }
  289. ret = gpio_direction_output(gpio_32khz, 1);
  290. if (ret < 0) {
  291. pr_err("Cannot set GPIO line %d, ret=%d\n", gpio_32khz, ret);
  292. goto fail_direction;
  293. }
  294. return 0;
  295. fail_direction:
  296. gpio_free(gpio_32khz);
  297. fail:
  298. return -ENODEV;
  299. }
  300. static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
  301. .gpio_base = OMAP_MAX_GPIO_LINES,
  302. .irq_base = TWL4030_GPIO_IRQ_BASE,
  303. .irq_end = TWL4030_GPIO_IRQ_END,
  304. .setup = omap3pandora_twl_gpio_setup,
  305. };
  306. static struct regulator_consumer_supply pandora_vmmc1_supply =
  307. REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
  308. static struct regulator_consumer_supply pandora_vmmc2_supply =
  309. REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
  310. static struct regulator_consumer_supply pandora_vdda_dac_supply =
  311. REGULATOR_SUPPLY("vdda_dac", "omapdss");
  312. static struct regulator_consumer_supply pandora_vdds_supplies[] = {
  313. REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
  314. REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
  315. };
  316. static struct regulator_consumer_supply pandora_vcc_lcd_supply =
  317. REGULATOR_SUPPLY("vcc", "display0");
  318. static struct regulator_consumer_supply pandora_usb_phy_supply =
  319. REGULATOR_SUPPLY("hsusb0", "ehci-omap.0");
  320. /* ads7846 on SPI and 2 nub controllers on I2C */
  321. static struct regulator_consumer_supply pandora_vaux4_supplies[] = {
  322. REGULATOR_SUPPLY("vcc", "spi1.0"),
  323. REGULATOR_SUPPLY("vcc", "3-0066"),
  324. REGULATOR_SUPPLY("vcc", "3-0067"),
  325. };
  326. static struct regulator_consumer_supply pandora_adac_supply =
  327. REGULATOR_SUPPLY("vcc", "soc-audio");
  328. /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
  329. static struct regulator_init_data pandora_vmmc1 = {
  330. .constraints = {
  331. .min_uV = 1850000,
  332. .max_uV = 3150000,
  333. .valid_modes_mask = REGULATOR_MODE_NORMAL
  334. | REGULATOR_MODE_STANDBY,
  335. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  336. | REGULATOR_CHANGE_MODE
  337. | REGULATOR_CHANGE_STATUS,
  338. },
  339. .num_consumer_supplies = 1,
  340. .consumer_supplies = &pandora_vmmc1_supply,
  341. };
  342. /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */
  343. static struct regulator_init_data pandora_vmmc2 = {
  344. .constraints = {
  345. .min_uV = 1850000,
  346. .max_uV = 3150000,
  347. .valid_modes_mask = REGULATOR_MODE_NORMAL
  348. | REGULATOR_MODE_STANDBY,
  349. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  350. | REGULATOR_CHANGE_MODE
  351. | REGULATOR_CHANGE_STATUS,
  352. },
  353. .num_consumer_supplies = 1,
  354. .consumer_supplies = &pandora_vmmc2_supply,
  355. };
  356. /* VDAC for DSS driving S-Video */
  357. static struct regulator_init_data pandora_vdac = {
  358. .constraints = {
  359. .min_uV = 1800000,
  360. .max_uV = 1800000,
  361. .apply_uV = true,
  362. .valid_modes_mask = REGULATOR_MODE_NORMAL
  363. | REGULATOR_MODE_STANDBY,
  364. .valid_ops_mask = REGULATOR_CHANGE_MODE
  365. | REGULATOR_CHANGE_STATUS,
  366. },
  367. .num_consumer_supplies = 1,
  368. .consumer_supplies = &pandora_vdda_dac_supply,
  369. };
  370. /* VPLL2 for digital video outputs */
  371. static struct regulator_init_data pandora_vpll2 = {
  372. .constraints = {
  373. .min_uV = 1800000,
  374. .max_uV = 1800000,
  375. .apply_uV = true,
  376. .valid_modes_mask = REGULATOR_MODE_NORMAL
  377. | REGULATOR_MODE_STANDBY,
  378. .valid_ops_mask = REGULATOR_CHANGE_MODE
  379. | REGULATOR_CHANGE_STATUS,
  380. },
  381. .num_consumer_supplies = ARRAY_SIZE(pandora_vdds_supplies),
  382. .consumer_supplies = pandora_vdds_supplies,
  383. };
  384. /* VAUX1 for LCD */
  385. static struct regulator_init_data pandora_vaux1 = {
  386. .constraints = {
  387. .min_uV = 3000000,
  388. .max_uV = 3000000,
  389. .apply_uV = true,
  390. .valid_modes_mask = REGULATOR_MODE_NORMAL
  391. | REGULATOR_MODE_STANDBY,
  392. .valid_ops_mask = REGULATOR_CHANGE_MODE
  393. | REGULATOR_CHANGE_STATUS,
  394. },
  395. .num_consumer_supplies = 1,
  396. .consumer_supplies = &pandora_vcc_lcd_supply,
  397. };
  398. /* VAUX2 for USB host PHY */
  399. static struct regulator_init_data pandora_vaux2 = {
  400. .constraints = {
  401. .min_uV = 1800000,
  402. .max_uV = 1800000,
  403. .apply_uV = true,
  404. .valid_modes_mask = REGULATOR_MODE_NORMAL
  405. | REGULATOR_MODE_STANDBY,
  406. .valid_ops_mask = REGULATOR_CHANGE_MODE
  407. | REGULATOR_CHANGE_STATUS,
  408. },
  409. .num_consumer_supplies = 1,
  410. .consumer_supplies = &pandora_usb_phy_supply,
  411. };
  412. /* VAUX4 for ads7846 and nubs */
  413. static struct regulator_init_data pandora_vaux4 = {
  414. .constraints = {
  415. .min_uV = 2800000,
  416. .max_uV = 2800000,
  417. .apply_uV = true,
  418. .valid_modes_mask = REGULATOR_MODE_NORMAL
  419. | REGULATOR_MODE_STANDBY,
  420. .valid_ops_mask = REGULATOR_CHANGE_MODE
  421. | REGULATOR_CHANGE_STATUS,
  422. },
  423. .num_consumer_supplies = ARRAY_SIZE(pandora_vaux4_supplies),
  424. .consumer_supplies = pandora_vaux4_supplies,
  425. };
  426. /* VSIM for audio DAC */
  427. static struct regulator_init_data pandora_vsim = {
  428. .constraints = {
  429. .min_uV = 2800000,
  430. .max_uV = 2800000,
  431. .apply_uV = true,
  432. .valid_modes_mask = REGULATOR_MODE_NORMAL
  433. | REGULATOR_MODE_STANDBY,
  434. .valid_ops_mask = REGULATOR_CHANGE_MODE
  435. | REGULATOR_CHANGE_STATUS,
  436. },
  437. .num_consumer_supplies = 1,
  438. .consumer_supplies = &pandora_adac_supply,
  439. };
  440. static struct twl4030_usb_data omap3pandora_usb_data = {
  441. .usb_mode = T2_USB_MODE_ULPI,
  442. };
  443. static struct twl4030_codec_audio_data omap3pandora_audio_data = {
  444. .audio_mclk = 26000000,
  445. };
  446. static struct twl4030_codec_data omap3pandora_codec_data = {
  447. .audio_mclk = 26000000,
  448. .audio = &omap3pandora_audio_data,
  449. };
  450. static struct twl4030_platform_data omap3pandora_twldata = {
  451. .irq_base = TWL4030_IRQ_BASE,
  452. .irq_end = TWL4030_IRQ_END,
  453. .gpio = &omap3pandora_gpio_data,
  454. .usb = &omap3pandora_usb_data,
  455. .codec = &omap3pandora_codec_data,
  456. .vmmc1 = &pandora_vmmc1,
  457. .vmmc2 = &pandora_vmmc2,
  458. .vdac = &pandora_vdac,
  459. .vpll2 = &pandora_vpll2,
  460. .vaux1 = &pandora_vaux1,
  461. .vaux2 = &pandora_vaux2,
  462. .vaux4 = &pandora_vaux4,
  463. .vsim = &pandora_vsim,
  464. .keypad = &pandora_kp_data,
  465. };
  466. static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
  467. {
  468. I2C_BOARD_INFO("tps65950", 0x48),
  469. .flags = I2C_CLIENT_WAKE,
  470. .irq = INT_34XX_SYS_NIRQ,
  471. .platform_data = &omap3pandora_twldata,
  472. },
  473. };
  474. static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
  475. {
  476. I2C_BOARD_INFO("bq27500", 0x55),
  477. .flags = I2C_CLIENT_WAKE,
  478. },
  479. };
  480. static int __init omap3pandora_i2c_init(void)
  481. {
  482. omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
  483. ARRAY_SIZE(omap3pandora_i2c_boardinfo));
  484. /* i2c2 pins are not connected */
  485. omap_register_i2c_bus(3, 100, omap3pandora_i2c3_boardinfo,
  486. ARRAY_SIZE(omap3pandora_i2c3_boardinfo));
  487. return 0;
  488. }
  489. static void __init omap3pandora_ads7846_init(void)
  490. {
  491. int gpio = OMAP3_PANDORA_TS_GPIO;
  492. int ret;
  493. ret = gpio_request(gpio, "ads7846_pen_down");
  494. if (ret < 0) {
  495. printk(KERN_ERR "Failed to request GPIO %d for "
  496. "ads7846 pen down IRQ\n", gpio);
  497. return;
  498. }
  499. gpio_direction_input(gpio);
  500. }
  501. static int ads7846_get_pendown_state(void)
  502. {
  503. return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
  504. }
  505. static struct ads7846_platform_data ads7846_config = {
  506. .x_max = 0x0fff,
  507. .y_max = 0x0fff,
  508. .x_plate_ohms = 180,
  509. .pressure_max = 255,
  510. .debounce_max = 10,
  511. .debounce_tol = 3,
  512. .debounce_rep = 1,
  513. .get_pendown_state = ads7846_get_pendown_state,
  514. .keep_vref_on = 1,
  515. };
  516. static struct omap2_mcspi_device_config ads7846_mcspi_config = {
  517. .turbo_mode = 0,
  518. .single_channel = 1, /* 0: slave, 1: master */
  519. };
  520. static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
  521. {
  522. .modalias = "ads7846",
  523. .bus_num = 1,
  524. .chip_select = 0,
  525. .max_speed_hz = 1500000,
  526. .controller_data = &ads7846_mcspi_config,
  527. .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
  528. .platform_data = &ads7846_config,
  529. }, {
  530. .modalias = "tpo_td043mtea1_panel_spi",
  531. .bus_num = 1,
  532. .chip_select = 1,
  533. .max_speed_hz = 375000,
  534. .platform_data = &pandora_lcd_device,
  535. }
  536. };
  537. static void __init omap3pandora_init_irq(void)
  538. {
  539. omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
  540. mt46h32m32lf6_sdrc_params);
  541. omap_init_irq();
  542. omap_gpio_init();
  543. }
  544. static void pandora_wl1251_set_power(bool enable)
  545. {
  546. /*
  547. * Keep power always on until wl1251_sdio driver learns to re-init
  548. * the chip after powering it down and back up.
  549. */
  550. }
  551. static struct wl12xx_platform_data pandora_wl1251_pdata = {
  552. .set_power = pandora_wl1251_set_power,
  553. .use_eeprom = true,
  554. };
  555. static struct platform_device pandora_wl1251_data = {
  556. .name = "wl1251_data",
  557. .id = -1,
  558. .dev = {
  559. .platform_data = &pandora_wl1251_pdata,
  560. },
  561. };
  562. static void pandora_wl1251_init(void)
  563. {
  564. int ret;
  565. ret = gpio_request(PANDORA_WIFI_IRQ_GPIO, "wl1251 irq");
  566. if (ret < 0)
  567. goto fail;
  568. ret = gpio_direction_input(PANDORA_WIFI_IRQ_GPIO);
  569. if (ret < 0)
  570. goto fail_irq;
  571. pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO);
  572. if (pandora_wl1251_pdata.irq < 0)
  573. goto fail_irq;
  574. ret = gpio_request(PANDORA_WIFI_NRESET_GPIO, "wl1251 nreset");
  575. if (ret < 0)
  576. goto fail_irq;
  577. /* start powered so that it probes with MMC subsystem */
  578. ret = gpio_direction_output(PANDORA_WIFI_NRESET_GPIO, 1);
  579. if (ret < 0)
  580. goto fail_nreset;
  581. return;
  582. fail_nreset:
  583. gpio_free(PANDORA_WIFI_NRESET_GPIO);
  584. fail_irq:
  585. gpio_free(PANDORA_WIFI_IRQ_GPIO);
  586. fail:
  587. printk(KERN_ERR "wl1251 board initialisation failed\n");
  588. }
  589. static struct platform_device *omap3pandora_devices[] __initdata = {
  590. &pandora_leds_gpio,
  591. &pandora_keys_gpio,
  592. &pandora_dss_device,
  593. &pandora_wl1251_data,
  594. };
  595. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  596. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  597. .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  598. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  599. .phy_reset = true,
  600. .reset_gpio_port[0] = 16,
  601. .reset_gpio_port[1] = -EINVAL,
  602. .reset_gpio_port[2] = -EINVAL
  603. };
  604. #ifdef CONFIG_OMAP_MUX
  605. static struct omap_board_mux board_mux[] __initdata = {
  606. { .reg_offset = OMAP_MUX_TERMINATOR },
  607. };
  608. #else
  609. #define board_mux NULL
  610. #endif
  611. static struct omap_musb_board_data musb_board_data = {
  612. .interface_type = MUSB_INTERFACE_ULPI,
  613. .mode = MUSB_OTG,
  614. .power = 100,
  615. };
  616. static void __init omap3pandora_init(void)
  617. {
  618. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  619. omap3pandora_i2c_init();
  620. pandora_wl1251_init();
  621. platform_add_devices(omap3pandora_devices,
  622. ARRAY_SIZE(omap3pandora_devices));
  623. omap_serial_init();
  624. spi_register_board_info(omap3pandora_spi_board_info,
  625. ARRAY_SIZE(omap3pandora_spi_board_info));
  626. omap3pandora_ads7846_init();
  627. usb_ehci_init(&ehci_pdata);
  628. usb_musb_init(&musb_board_data);
  629. gpmc_nand_init(&pandora_nand_data);
  630. /* Ensure SDRC pins are mux'd for self-refresh */
  631. omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
  632. omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
  633. }
  634. MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
  635. .phys_io = 0x48000000,
  636. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  637. .boot_params = 0x80000100,
  638. .map_io = omap3_map_io,
  639. .reserve = omap_reserve,
  640. .init_irq = omap3pandora_init_irq,
  641. .init_machine = omap3pandora_init,
  642. .timer = &omap_timer,
  643. MACHINE_END