board-rx51-peripherals.c 27 KB

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