board-rx51-peripherals.c 25 KB

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