board-rx51-peripherals.c 26 KB

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