board-rx51-peripherals.c 26 KB

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