board-rx51-peripherals.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. /*
  2. * linux/arch/arm/mach-omap2/board-rx51-peripherals.c
  3. *
  4. * Copyright (C) 2008-2009 Nokia
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/input.h>
  14. #include <linux/input/matrix_keypad.h>
  15. #include <linux/spi/spi.h>
  16. #include <linux/wl12xx.h>
  17. #include <linux/i2c.h>
  18. #include <linux/i2c/twl.h>
  19. #include <linux/clk.h>
  20. #include <linux/delay.h>
  21. #include <linux/regulator/machine.h>
  22. #include <linux/gpio.h>
  23. #include <linux/gpio_keys.h>
  24. #include <linux/mmc/host.h>
  25. #include <plat/mcspi.h>
  26. #include <plat/board.h>
  27. #include <plat/common.h>
  28. #include <plat/dma.h>
  29. #include <plat/gpmc.h>
  30. #include <plat/onenand.h>
  31. #include <plat/gpmc-smc91x.h>
  32. #include <mach/board-rx51.h>
  33. #include <sound/tlv320aic3x.h>
  34. #include <sound/tpa6130a2-plat.h>
  35. #include <../drivers/staging/iio/light/tsl2563.h>
  36. #include "mux.h"
  37. #include "hsmmc.h"
  38. #define SYSTEM_REV_B_USES_VAUX3 0x1699
  39. #define SYSTEM_REV_S_USES_VAUX3 0x8
  40. #define RX51_WL1251_POWER_GPIO 87
  41. #define RX51_WL1251_IRQ_GPIO 42
  42. /* list all spi devices here */
  43. enum {
  44. RX51_SPI_WL1251,
  45. RX51_SPI_MIPID, /* LCD panel */
  46. RX51_SPI_TSC2005, /* Touch Controller */
  47. };
  48. static struct wl12xx_platform_data wl1251_pdata;
  49. #if defined(CONFIG_SENSORS_TSL2563) || defined(CONFIG_SENSORS_TSL2563_MODULE)
  50. static struct tsl2563_platform_data rx51_tsl2563_platform_data = {
  51. .cover_comp_gain = 16,
  52. };
  53. #endif
  54. static struct omap2_mcspi_device_config wl1251_mcspi_config = {
  55. .turbo_mode = 0,
  56. .single_channel = 1,
  57. };
  58. static struct omap2_mcspi_device_config mipid_mcspi_config = {
  59. .turbo_mode = 0,
  60. .single_channel = 1,
  61. };
  62. static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
  63. .turbo_mode = 0,
  64. .single_channel = 1,
  65. };
  66. static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
  67. [RX51_SPI_WL1251] = {
  68. .modalias = "wl1251",
  69. .bus_num = 4,
  70. .chip_select = 0,
  71. .max_speed_hz = 48000000,
  72. .mode = SPI_MODE_3,
  73. .controller_data = &wl1251_mcspi_config,
  74. .platform_data = &wl1251_pdata,
  75. },
  76. [RX51_SPI_MIPID] = {
  77. .modalias = "acx565akm",
  78. .bus_num = 1,
  79. .chip_select = 2,
  80. .max_speed_hz = 6000000,
  81. .controller_data = &mipid_mcspi_config,
  82. },
  83. [RX51_SPI_TSC2005] = {
  84. .modalias = "tsc2005",
  85. .bus_num = 1,
  86. .chip_select = 0,
  87. /* .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),*/
  88. .max_speed_hz = 6000000,
  89. .controller_data = &tsc2005_mcspi_config,
  90. /* .platform_data = &tsc2005_config,*/
  91. },
  92. };
  93. static struct platform_device rx51_charger_device = {
  94. .name = "isp1704_charger",
  95. };
  96. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  97. #define RX51_GPIO_CAMERA_LENS_COVER 110
  98. #define RX51_GPIO_CAMERA_FOCUS 68
  99. #define RX51_GPIO_CAMERA_CAPTURE 69
  100. #define RX51_GPIO_KEYPAD_SLIDE 71
  101. #define RX51_GPIO_LOCK_BUTTON 113
  102. #define RX51_GPIO_PROXIMITY 89
  103. #define RX51_GPIO_DEBOUNCE_TIMEOUT 10
  104. static struct gpio_keys_button rx51_gpio_keys[] = {
  105. {
  106. .desc = "Camera Lens Cover",
  107. .type = EV_SW,
  108. .code = SW_CAMERA_LENS_COVER,
  109. .gpio = RX51_GPIO_CAMERA_LENS_COVER,
  110. .active_low = 1,
  111. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  112. }, {
  113. .desc = "Camera Focus",
  114. .type = EV_KEY,
  115. .code = KEY_CAMERA_FOCUS,
  116. .gpio = RX51_GPIO_CAMERA_FOCUS,
  117. .active_low = 1,
  118. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  119. }, {
  120. .desc = "Camera Capture",
  121. .type = EV_KEY,
  122. .code = KEY_CAMERA,
  123. .gpio = RX51_GPIO_CAMERA_CAPTURE,
  124. .active_low = 1,
  125. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  126. }, {
  127. .desc = "Lock Button",
  128. .type = EV_KEY,
  129. .code = KEY_SCREENLOCK,
  130. .gpio = RX51_GPIO_LOCK_BUTTON,
  131. .active_low = 1,
  132. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  133. }, {
  134. .desc = "Keypad Slide",
  135. .type = EV_SW,
  136. .code = SW_KEYPAD_SLIDE,
  137. .gpio = RX51_GPIO_KEYPAD_SLIDE,
  138. .active_low = 1,
  139. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  140. }, {
  141. .desc = "Proximity Sensor",
  142. .type = EV_SW,
  143. .code = SW_FRONT_PROXIMITY,
  144. .gpio = RX51_GPIO_PROXIMITY,
  145. .active_low = 0,
  146. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  147. }
  148. };
  149. static struct gpio_keys_platform_data rx51_gpio_keys_data = {
  150. .buttons = rx51_gpio_keys,
  151. .nbuttons = ARRAY_SIZE(rx51_gpio_keys),
  152. };
  153. static struct platform_device rx51_gpio_keys_device = {
  154. .name = "gpio-keys",
  155. .id = -1,
  156. .dev = {
  157. .platform_data = &rx51_gpio_keys_data,
  158. },
  159. };
  160. static void __init rx51_add_gpio_keys(void)
  161. {
  162. platform_device_register(&rx51_gpio_keys_device);
  163. }
  164. #else
  165. static void __init rx51_add_gpio_keys(void)
  166. {
  167. }
  168. #endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
  169. static uint32_t board_keymap[] = {
  170. /*
  171. * Note that KEY(x, 8, KEY_XXX) entries represent "entrire row
  172. * connected to the ground" matrix state.
  173. */
  174. KEY(0, 0, KEY_Q),
  175. KEY(0, 1, KEY_O),
  176. KEY(0, 2, KEY_P),
  177. KEY(0, 3, KEY_COMMA),
  178. KEY(0, 4, KEY_BACKSPACE),
  179. KEY(0, 6, KEY_A),
  180. KEY(0, 7, KEY_S),
  181. KEY(1, 0, KEY_W),
  182. KEY(1, 1, KEY_D),
  183. KEY(1, 2, KEY_F),
  184. KEY(1, 3, KEY_G),
  185. KEY(1, 4, KEY_H),
  186. KEY(1, 5, KEY_J),
  187. KEY(1, 6, KEY_K),
  188. KEY(1, 7, KEY_L),
  189. KEY(2, 0, KEY_E),
  190. KEY(2, 1, KEY_DOT),
  191. KEY(2, 2, KEY_UP),
  192. KEY(2, 3, KEY_ENTER),
  193. KEY(2, 5, KEY_Z),
  194. KEY(2, 6, KEY_X),
  195. KEY(2, 7, KEY_C),
  196. KEY(2, 8, KEY_F9),
  197. KEY(3, 0, KEY_R),
  198. KEY(3, 1, KEY_V),
  199. KEY(3, 2, KEY_B),
  200. KEY(3, 3, KEY_N),
  201. KEY(3, 4, KEY_M),
  202. KEY(3, 5, KEY_SPACE),
  203. KEY(3, 6, KEY_SPACE),
  204. KEY(3, 7, KEY_LEFT),
  205. KEY(4, 0, KEY_T),
  206. KEY(4, 1, KEY_DOWN),
  207. KEY(4, 2, KEY_RIGHT),
  208. KEY(4, 4, KEY_LEFTCTRL),
  209. KEY(4, 5, KEY_RIGHTALT),
  210. KEY(4, 6, KEY_LEFTSHIFT),
  211. KEY(4, 8, KEY_F10),
  212. KEY(5, 0, KEY_Y),
  213. KEY(5, 8, KEY_F11),
  214. KEY(6, 0, KEY_U),
  215. KEY(7, 0, KEY_I),
  216. KEY(7, 1, KEY_F7),
  217. KEY(7, 2, KEY_F8),
  218. };
  219. static struct matrix_keymap_data board_map_data = {
  220. .keymap = board_keymap,
  221. .keymap_size = ARRAY_SIZE(board_keymap),
  222. };
  223. static struct twl4030_keypad_data rx51_kp_data = {
  224. .keymap_data = &board_map_data,
  225. .rows = 8,
  226. .cols = 8,
  227. .rep = 1,
  228. };
  229. static struct twl4030_madc_platform_data rx51_madc_data = {
  230. .irq_line = 1,
  231. };
  232. /* Enable input logic and pull all lines up when eMMC is on. */
  233. static struct omap_board_mux rx51_mmc2_on_mux[] = {
  234. OMAP3_MUX(SDMMC2_CMD, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  235. OMAP3_MUX(SDMMC2_DAT0, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  236. OMAP3_MUX(SDMMC2_DAT1, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  237. OMAP3_MUX(SDMMC2_DAT2, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  238. OMAP3_MUX(SDMMC2_DAT3, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  239. OMAP3_MUX(SDMMC2_DAT4, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  240. OMAP3_MUX(SDMMC2_DAT5, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  241. OMAP3_MUX(SDMMC2_DAT6, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  242. OMAP3_MUX(SDMMC2_DAT7, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  243. { .reg_offset = OMAP_MUX_TERMINATOR },
  244. };
  245. /* Disable input logic and pull all lines down when eMMC is off. */
  246. static struct omap_board_mux rx51_mmc2_off_mux[] = {
  247. OMAP3_MUX(SDMMC2_CMD, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  248. OMAP3_MUX(SDMMC2_DAT0, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  249. OMAP3_MUX(SDMMC2_DAT1, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  250. OMAP3_MUX(SDMMC2_DAT2, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  251. OMAP3_MUX(SDMMC2_DAT3, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  252. OMAP3_MUX(SDMMC2_DAT4, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  253. OMAP3_MUX(SDMMC2_DAT5, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  254. OMAP3_MUX(SDMMC2_DAT6, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  255. OMAP3_MUX(SDMMC2_DAT7, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  256. { .reg_offset = OMAP_MUX_TERMINATOR },
  257. };
  258. static struct omap_mux_partition *partition;
  259. /*
  260. * Current flows to eMMC when eMMC is off and the data lines are pulled up,
  261. * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
  262. */
  263. static void rx51_mmc2_remux(struct device *dev, int slot, int power_on)
  264. {
  265. if (power_on)
  266. omap_mux_write_array(partition, rx51_mmc2_on_mux);
  267. else
  268. omap_mux_write_array(partition, rx51_mmc2_off_mux);
  269. }
  270. static struct omap2_hsmmc_info mmc[] __initdata = {
  271. {
  272. .name = "external",
  273. .mmc = 1,
  274. .caps = MMC_CAP_4_BIT_DATA,
  275. .cover_only = true,
  276. .gpio_cd = 160,
  277. .gpio_wp = -EINVAL,
  278. .power_saving = true,
  279. },
  280. {
  281. .name = "internal",
  282. .mmc = 2,
  283. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  284. /* See also rx51_mmc2_remux */
  285. .gpio_cd = -EINVAL,
  286. .gpio_wp = -EINVAL,
  287. .nonremovable = true,
  288. .power_saving = true,
  289. .remux = rx51_mmc2_remux,
  290. },
  291. {} /* Terminator */
  292. };
  293. static struct regulator_consumer_supply rx51_vmmc1_supply =
  294. REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.0");
  295. static struct regulator_consumer_supply rx51_vaux3_supply =
  296. REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1");
  297. static struct regulator_consumer_supply rx51_vsim_supply =
  298. REGULATOR_SUPPLY("vmmc_aux", "mmci-omap-hs.1");
  299. static struct regulator_consumer_supply rx51_vmmc2_supplies[] = {
  300. /* tlv320aic3x analog supplies */
  301. REGULATOR_SUPPLY("AVDD", "2-0018"),
  302. REGULATOR_SUPPLY("DRVDD", "2-0018"),
  303. REGULATOR_SUPPLY("AVDD", "2-0019"),
  304. REGULATOR_SUPPLY("DRVDD", "2-0019"),
  305. /* tpa6130a2 */
  306. REGULATOR_SUPPLY("Vdd", "2-0060"),
  307. /* Keep vmmc as last item. It is not iterated for newer boards */
  308. REGULATOR_SUPPLY("vmmc", "mmci-omap-hs.1"),
  309. };
  310. static struct regulator_consumer_supply rx51_vio_supplies[] = {
  311. /* tlv320aic3x digital supplies */
  312. REGULATOR_SUPPLY("IOVDD", "2-0018"),
  313. REGULATOR_SUPPLY("DVDD", "2-0018"),
  314. REGULATOR_SUPPLY("IOVDD", "2-0019"),
  315. REGULATOR_SUPPLY("DVDD", "2-0019"),
  316. };
  317. static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
  318. REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
  319. };
  320. static struct regulator_consumer_supply rx51_vdac_supply[] = {
  321. REGULATOR_SUPPLY("vdda_dac", "omapdss"),
  322. };
  323. static struct regulator_init_data rx51_vaux1 = {
  324. .constraints = {
  325. .name = "V28",
  326. .min_uV = 2800000,
  327. .max_uV = 2800000,
  328. .always_on = true, /* due battery cover sensor */
  329. .valid_modes_mask = REGULATOR_MODE_NORMAL
  330. | REGULATOR_MODE_STANDBY,
  331. .valid_ops_mask = REGULATOR_CHANGE_MODE
  332. | REGULATOR_CHANGE_STATUS,
  333. },
  334. .num_consumer_supplies = ARRAY_SIZE(rx51_vaux1_consumers),
  335. .consumer_supplies = rx51_vaux1_consumers,
  336. };
  337. static struct regulator_init_data rx51_vaux2 = {
  338. .constraints = {
  339. .name = "VCSI",
  340. .min_uV = 1800000,
  341. .max_uV = 1800000,
  342. .valid_modes_mask = REGULATOR_MODE_NORMAL
  343. | REGULATOR_MODE_STANDBY,
  344. .valid_ops_mask = REGULATOR_CHANGE_MODE
  345. | REGULATOR_CHANGE_STATUS,
  346. },
  347. };
  348. /* VAUX3 - adds more power to VIO_18 rail */
  349. static struct regulator_init_data rx51_vaux3_cam = {
  350. .constraints = {
  351. .name = "VCAM_DIG_18",
  352. .min_uV = 1800000,
  353. .max_uV = 1800000,
  354. .apply_uV = true,
  355. .valid_modes_mask = REGULATOR_MODE_NORMAL
  356. | REGULATOR_MODE_STANDBY,
  357. .valid_ops_mask = REGULATOR_CHANGE_MODE
  358. | REGULATOR_CHANGE_STATUS,
  359. },
  360. };
  361. static struct regulator_init_data rx51_vaux3_mmc = {
  362. .constraints = {
  363. .name = "VMMC2_30",
  364. .min_uV = 2800000,
  365. .max_uV = 3000000,
  366. .apply_uV = true,
  367. .valid_modes_mask = REGULATOR_MODE_NORMAL
  368. | REGULATOR_MODE_STANDBY,
  369. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  370. | REGULATOR_CHANGE_MODE
  371. | REGULATOR_CHANGE_STATUS,
  372. },
  373. .num_consumer_supplies = 1,
  374. .consumer_supplies = &rx51_vaux3_supply,
  375. };
  376. static struct regulator_init_data rx51_vaux4 = {
  377. .constraints = {
  378. .name = "VCAM_ANA_28",
  379. .min_uV = 2800000,
  380. .max_uV = 2800000,
  381. .apply_uV = true,
  382. .valid_modes_mask = REGULATOR_MODE_NORMAL
  383. | REGULATOR_MODE_STANDBY,
  384. .valid_ops_mask = REGULATOR_CHANGE_MODE
  385. | REGULATOR_CHANGE_STATUS,
  386. },
  387. };
  388. static struct regulator_init_data rx51_vmmc1 = {
  389. .constraints = {
  390. .min_uV = 1850000,
  391. .max_uV = 3150000,
  392. .valid_modes_mask = REGULATOR_MODE_NORMAL
  393. | REGULATOR_MODE_STANDBY,
  394. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  395. | REGULATOR_CHANGE_MODE
  396. | REGULATOR_CHANGE_STATUS,
  397. },
  398. .num_consumer_supplies = 1,
  399. .consumer_supplies = &rx51_vmmc1_supply,
  400. };
  401. static struct regulator_init_data rx51_vmmc2 = {
  402. .constraints = {
  403. .name = "V28_A",
  404. .min_uV = 2800000,
  405. .max_uV = 3000000,
  406. .apply_uV = true,
  407. .valid_modes_mask = REGULATOR_MODE_NORMAL
  408. | REGULATOR_MODE_STANDBY,
  409. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  410. | REGULATOR_CHANGE_MODE
  411. | REGULATOR_CHANGE_STATUS,
  412. },
  413. .num_consumer_supplies = ARRAY_SIZE(rx51_vmmc2_supplies),
  414. .consumer_supplies = rx51_vmmc2_supplies,
  415. };
  416. static struct regulator_init_data rx51_vsim = {
  417. .constraints = {
  418. .name = "VMMC2_IO_18",
  419. .min_uV = 1800000,
  420. .max_uV = 1800000,
  421. .apply_uV = true,
  422. .valid_modes_mask = REGULATOR_MODE_NORMAL
  423. | REGULATOR_MODE_STANDBY,
  424. .valid_ops_mask = REGULATOR_CHANGE_MODE
  425. | REGULATOR_CHANGE_STATUS,
  426. },
  427. .num_consumer_supplies = 1,
  428. .consumer_supplies = &rx51_vsim_supply,
  429. };
  430. static struct regulator_init_data rx51_vdac = {
  431. .constraints = {
  432. .name = "VDAC",
  433. .min_uV = 1800000,
  434. .max_uV = 1800000,
  435. .apply_uV = true,
  436. .valid_modes_mask = REGULATOR_MODE_NORMAL
  437. | REGULATOR_MODE_STANDBY,
  438. .valid_ops_mask = REGULATOR_CHANGE_MODE
  439. | REGULATOR_CHANGE_STATUS,
  440. },
  441. .num_consumer_supplies = 1,
  442. .consumer_supplies = rx51_vdac_supply,
  443. };
  444. static struct regulator_init_data rx51_vio = {
  445. .constraints = {
  446. .min_uV = 1800000,
  447. .max_uV = 1800000,
  448. .valid_modes_mask = REGULATOR_MODE_NORMAL
  449. | REGULATOR_MODE_STANDBY,
  450. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  451. | REGULATOR_CHANGE_MODE
  452. | REGULATOR_CHANGE_STATUS,
  453. },
  454. .num_consumer_supplies = ARRAY_SIZE(rx51_vio_supplies),
  455. .consumer_supplies = rx51_vio_supplies,
  456. };
  457. static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
  458. {
  459. /* FIXME this gpio setup is just a placeholder for now */
  460. gpio_request(gpio + 6, "backlight_pwm");
  461. gpio_direction_output(gpio + 6, 0);
  462. gpio_request(gpio + 7, "speaker_en");
  463. gpio_direction_output(gpio + 7, 1);
  464. return 0;
  465. }
  466. static struct twl4030_gpio_platform_data rx51_gpio_data = {
  467. .gpio_base = OMAP_MAX_GPIO_LINES,
  468. .irq_base = TWL4030_GPIO_IRQ_BASE,
  469. .irq_end = TWL4030_GPIO_IRQ_END,
  470. .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
  471. | BIT(4) | BIT(5)
  472. | BIT(8) | BIT(9) | BIT(10) | BIT(11)
  473. | BIT(12) | BIT(13) | BIT(14) | BIT(15)
  474. | BIT(16) | BIT(17) ,
  475. .setup = rx51_twlgpio_setup,
  476. };
  477. static struct twl4030_usb_data rx51_usb_data = {
  478. .usb_mode = T2_USB_MODE_ULPI,
  479. };
  480. static struct twl4030_ins sleep_on_seq[] __initdata = {
  481. /*
  482. * Turn off everything
  483. */
  484. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
  485. };
  486. static struct twl4030_script sleep_on_script __initdata = {
  487. .script = sleep_on_seq,
  488. .size = ARRAY_SIZE(sleep_on_seq),
  489. .flags = TWL4030_SLEEP_SCRIPT,
  490. };
  491. static struct twl4030_ins wakeup_seq[] __initdata = {
  492. /*
  493. * Reenable everything
  494. */
  495. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
  496. };
  497. static struct twl4030_script wakeup_script __initdata = {
  498. .script = wakeup_seq,
  499. .size = ARRAY_SIZE(wakeup_seq),
  500. .flags = TWL4030_WAKEUP12_SCRIPT,
  501. };
  502. static struct twl4030_ins wakeup_p3_seq[] __initdata = {
  503. /*
  504. * Reenable everything
  505. */
  506. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
  507. };
  508. static struct twl4030_script wakeup_p3_script __initdata = {
  509. .script = wakeup_p3_seq,
  510. .size = ARRAY_SIZE(wakeup_p3_seq),
  511. .flags = TWL4030_WAKEUP3_SCRIPT,
  512. };
  513. static struct twl4030_ins wrst_seq[] __initdata = {
  514. /*
  515. * Reset twl4030.
  516. * Reset VDD1 regulator.
  517. * Reset VDD2 regulator.
  518. * Reset VPLL1 regulator.
  519. * Enable sysclk output.
  520. * Reenable twl4030.
  521. */
  522. {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
  523. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
  524. 0x13},
  525. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
  526. {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
  527. {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
  528. {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
  529. {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
  530. {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
  531. };
  532. static struct twl4030_script wrst_script __initdata = {
  533. .script = wrst_seq,
  534. .size = ARRAY_SIZE(wrst_seq),
  535. .flags = TWL4030_WRST_SCRIPT,
  536. };
  537. static struct twl4030_script *twl4030_scripts[] __initdata = {
  538. /* wakeup12 script should be loaded before sleep script, otherwise a
  539. board might hit retention before loading of wakeup script is
  540. completed. This can cause boot failures depending on timing issues.
  541. */
  542. &wakeup_script,
  543. &sleep_on_script,
  544. &wakeup_p3_script,
  545. &wrst_script,
  546. };
  547. static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
  548. { .resource = RES_VDD1, .devgroup = -1,
  549. .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
  550. .remap_sleep = RES_STATE_OFF
  551. },
  552. { .resource = RES_VDD2, .devgroup = -1,
  553. .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
  554. .remap_sleep = RES_STATE_OFF
  555. },
  556. { .resource = RES_VPLL1, .devgroup = -1,
  557. .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
  558. .remap_sleep = RES_STATE_OFF
  559. },
  560. { .resource = RES_VPLL2, .devgroup = -1,
  561. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  562. },
  563. { .resource = RES_VAUX1, .devgroup = -1,
  564. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  565. },
  566. { .resource = RES_VAUX2, .devgroup = -1,
  567. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  568. },
  569. { .resource = RES_VAUX3, .devgroup = -1,
  570. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  571. },
  572. { .resource = RES_VAUX4, .devgroup = -1,
  573. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  574. },
  575. { .resource = RES_VMMC1, .devgroup = -1,
  576. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  577. },
  578. { .resource = RES_VMMC2, .devgroup = -1,
  579. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  580. },
  581. { .resource = RES_VDAC, .devgroup = -1,
  582. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  583. },
  584. { .resource = RES_VSIM, .devgroup = -1,
  585. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  586. },
  587. { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  588. .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  589. },
  590. { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  591. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  592. },
  593. { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  594. .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  595. },
  596. { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
  597. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  598. },
  599. { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  600. .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
  601. },
  602. { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  603. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  604. },
  605. { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  606. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  607. },
  608. { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  609. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  610. },
  611. { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
  612. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  613. },
  614. { .resource = RES_32KCLKOUT, .devgroup = -1,
  615. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  616. },
  617. { .resource = RES_RESET, .devgroup = -1,
  618. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  619. },
  620. { .resource = RES_Main_Ref, .devgroup = -1,
  621. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  622. },
  623. { 0, 0},
  624. };
  625. static struct twl4030_power_data rx51_t2scripts_data __initdata = {
  626. .scripts = twl4030_scripts,
  627. .num = ARRAY_SIZE(twl4030_scripts),
  628. .resource_config = twl4030_rconfig,
  629. };
  630. static struct twl4030_platform_data rx51_twldata __initdata = {
  631. .irq_base = TWL4030_IRQ_BASE,
  632. .irq_end = TWL4030_IRQ_END,
  633. /* platform_data for children goes here */
  634. .gpio = &rx51_gpio_data,
  635. .keypad = &rx51_kp_data,
  636. .madc = &rx51_madc_data,
  637. .usb = &rx51_usb_data,
  638. .power = &rx51_t2scripts_data,
  639. .vaux1 = &rx51_vaux1,
  640. .vaux2 = &rx51_vaux2,
  641. .vaux4 = &rx51_vaux4,
  642. .vmmc1 = &rx51_vmmc1,
  643. .vsim = &rx51_vsim,
  644. .vdac = &rx51_vdac,
  645. .vio = &rx51_vio,
  646. };
  647. static struct tpa6130a2_platform_data rx51_tpa6130a2_data __initdata_or_module = {
  648. .id = TPA6130A2,
  649. .power_gpio = 98,
  650. };
  651. static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
  652. {
  653. I2C_BOARD_INFO("twl5030", 0x48),
  654. .flags = I2C_CLIENT_WAKE,
  655. .irq = INT_34XX_SYS_NIRQ,
  656. .platform_data = &rx51_twldata,
  657. },
  658. };
  659. /* Audio setup data */
  660. static struct aic3x_setup_data rx51_aic34_setup = {
  661. .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED,
  662. .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT,
  663. };
  664. static struct aic3x_pdata rx51_aic3x_data = {
  665. .setup = &rx51_aic34_setup,
  666. .gpio_reset = 60,
  667. };
  668. static struct aic3x_pdata rx51_aic3x_data2 = {
  669. .gpio_reset = 60,
  670. };
  671. static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
  672. {
  673. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  674. .platform_data = &rx51_aic3x_data,
  675. },
  676. {
  677. I2C_BOARD_INFO("tlv320aic3x", 0x19),
  678. .platform_data = &rx51_aic3x_data2,
  679. },
  680. #if defined(CONFIG_SENSORS_TSL2563) || defined(CONFIG_SENSORS_TSL2563_MODULE)
  681. {
  682. I2C_BOARD_INFO("tsl2563", 0x29),
  683. .platform_data = &rx51_tsl2563_platform_data,
  684. },
  685. #endif
  686. {
  687. I2C_BOARD_INFO("tpa6130a2", 0x60),
  688. .platform_data = &rx51_tpa6130a2_data,
  689. }
  690. };
  691. static int __init rx51_i2c_init(void)
  692. {
  693. if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
  694. system_rev >= SYSTEM_REV_B_USES_VAUX3) {
  695. rx51_twldata.vaux3 = &rx51_vaux3_mmc;
  696. /* Only older boards use VMMC2 for internal MMC */
  697. rx51_vmmc2.num_consumer_supplies--;
  698. } else {
  699. rx51_twldata.vaux3 = &rx51_vaux3_cam;
  700. }
  701. rx51_twldata.vmmc2 = &rx51_vmmc2;
  702. omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
  703. ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
  704. omap_register_i2c_bus(2, 100, rx51_peripherals_i2c_board_info_2,
  705. ARRAY_SIZE(rx51_peripherals_i2c_board_info_2));
  706. omap_register_i2c_bus(3, 400, NULL, 0);
  707. return 0;
  708. }
  709. #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
  710. defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
  711. static struct mtd_partition onenand_partitions[] = {
  712. {
  713. .name = "bootloader",
  714. .offset = 0,
  715. .size = 0x20000,
  716. .mask_flags = MTD_WRITEABLE, /* Force read-only */
  717. },
  718. {
  719. .name = "config",
  720. .offset = MTDPART_OFS_APPEND,
  721. .size = 0x60000,
  722. },
  723. {
  724. .name = "log",
  725. .offset = MTDPART_OFS_APPEND,
  726. .size = 0x40000,
  727. },
  728. {
  729. .name = "kernel",
  730. .offset = MTDPART_OFS_APPEND,
  731. .size = 0x200000,
  732. },
  733. {
  734. .name = "initfs",
  735. .offset = MTDPART_OFS_APPEND,
  736. .size = 0x200000,
  737. },
  738. {
  739. .name = "rootfs",
  740. .offset = MTDPART_OFS_APPEND,
  741. .size = MTDPART_SIZ_FULL,
  742. },
  743. };
  744. static struct omap_onenand_platform_data board_onenand_data[] = {
  745. {
  746. .cs = 0,
  747. .gpio_irq = 65,
  748. .parts = onenand_partitions,
  749. .nr_parts = ARRAY_SIZE(onenand_partitions),
  750. .flags = ONENAND_SYNC_READWRITE,
  751. }
  752. };
  753. #endif
  754. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  755. static struct omap_smc91x_platform_data board_smc91x_data = {
  756. .cs = 1,
  757. .gpio_irq = 54,
  758. .gpio_pwrdwn = 86,
  759. .gpio_reset = 164,
  760. .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
  761. };
  762. static void __init board_smc91x_init(void)
  763. {
  764. omap_mux_init_gpio(54, OMAP_PIN_INPUT_PULLDOWN);
  765. omap_mux_init_gpio(86, OMAP_PIN_OUTPUT);
  766. omap_mux_init_gpio(164, OMAP_PIN_OUTPUT);
  767. gpmc_smc91x_init(&board_smc91x_data);
  768. }
  769. #else
  770. static inline void board_smc91x_init(void)
  771. {
  772. }
  773. #endif
  774. static void rx51_wl1251_set_power(bool enable)
  775. {
  776. gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
  777. }
  778. static void __init rx51_init_wl1251(void)
  779. {
  780. int irq, ret;
  781. ret = gpio_request(RX51_WL1251_POWER_GPIO, "wl1251 power");
  782. if (ret < 0)
  783. goto error;
  784. ret = gpio_direction_output(RX51_WL1251_POWER_GPIO, 0);
  785. if (ret < 0)
  786. goto err_power;
  787. ret = gpio_request(RX51_WL1251_IRQ_GPIO, "wl1251 irq");
  788. if (ret < 0)
  789. goto err_power;
  790. ret = gpio_direction_input(RX51_WL1251_IRQ_GPIO);
  791. if (ret < 0)
  792. goto err_irq;
  793. irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
  794. if (irq < 0)
  795. goto err_irq;
  796. wl1251_pdata.set_power = rx51_wl1251_set_power;
  797. rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
  798. return;
  799. err_irq:
  800. gpio_free(RX51_WL1251_IRQ_GPIO);
  801. err_power:
  802. gpio_free(RX51_WL1251_POWER_GPIO);
  803. error:
  804. printk(KERN_ERR "wl1251 board initialisation failed\n");
  805. wl1251_pdata.set_power = NULL;
  806. /*
  807. * Now rx51_peripherals_spi_board_info[1].irq is zero and
  808. * set_power is null, and wl1251_probe() will fail.
  809. */
  810. }
  811. void __init rx51_peripherals_init(void)
  812. {
  813. rx51_i2c_init();
  814. gpmc_onenand_init(board_onenand_data);
  815. board_smc91x_init();
  816. rx51_add_gpio_keys();
  817. rx51_init_wl1251();
  818. spi_register_board_info(rx51_peripherals_spi_board_info,
  819. ARRAY_SIZE(rx51_peripherals_spi_board_info));
  820. partition = omap_mux_get("core");
  821. if (partition)
  822. omap2_hsmmc_init(mmc);
  823. platform_device_register(&rx51_charger_device);
  824. }