board-rx51-peripherals.c 26 KB

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