board-rx51-peripherals.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  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/spi/tsc2005.h>
  18. #include <linux/i2c.h>
  19. #include <linux/i2c/twl.h>
  20. #include <linux/clk.h>
  21. #include <linux/delay.h>
  22. #include <linux/regulator/machine.h>
  23. #include <linux/gpio.h>
  24. #include <linux/gpio_keys.h>
  25. #include <linux/gpio/machine.h>
  26. #include <linux/omap-gpmc.h>
  27. #include <linux/mmc/host.h>
  28. #include <linux/power/isp1704_charger.h>
  29. #include <linux/platform_data/spi-omap2-mcspi.h>
  30. #include <linux/platform_data/mtd-onenand-omap2.h>
  31. #include <asm/system_info.h>
  32. #include "common.h"
  33. #include <linux/omap-dma.h>
  34. #include "board-rx51.h"
  35. #include <sound/tlv320aic3x.h>
  36. #include <sound/tpa6130a2-plat.h>
  37. #include <media/si4713.h>
  38. #include <linux/platform_data/leds-lp55xx.h>
  39. #include <linux/platform_data/tsl2563.h>
  40. #include <linux/lis3lv02d.h>
  41. #include <video/omap-panel-data.h>
  42. #if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
  43. #include <media/ir-rx51.h>
  44. #endif
  45. #include "mux.h"
  46. #include "omap-pm.h"
  47. #include "hsmmc.h"
  48. #include "common-board-devices.h"
  49. #include "soc.h"
  50. #include "omap-secure.h"
  51. #define SYSTEM_REV_B_USES_VAUX3 0x1699
  52. #define SYSTEM_REV_S_USES_VAUX3 0x8
  53. #define RX51_WL1251_POWER_GPIO 87
  54. #define RX51_WL1251_IRQ_GPIO 42
  55. #define RX51_FMTX_RESET_GPIO 163
  56. #define RX51_FMTX_IRQ 53
  57. #define RX51_LP5523_CHIP_EN_GPIO 41
  58. #define RX51_USB_TRANSCEIVER_RST_GPIO 67
  59. #define RX51_TSC2005_RESET_GPIO 104
  60. #define RX51_TSC2005_IRQ_GPIO 100
  61. #define LIS302_IRQ1_GPIO 181
  62. #define LIS302_IRQ2_GPIO 180 /* Not yet in use */
  63. /* List all SPI devices here. Note that the list/probe order seems to matter! */
  64. enum {
  65. RX51_SPI_WL1251,
  66. RX51_SPI_TSC2005, /* Touch Controller */
  67. RX51_SPI_MIPID, /* LCD panel */
  68. };
  69. static struct wl1251_platform_data wl1251_pdata;
  70. static struct tsc2005_platform_data tsc2005_pdata;
  71. #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
  72. static int lis302_setup(void)
  73. {
  74. int err;
  75. int irq1 = LIS302_IRQ1_GPIO;
  76. int irq2 = LIS302_IRQ2_GPIO;
  77. /* gpio for interrupt pin 1 */
  78. err = gpio_request(irq1, "lis3lv02dl_irq1");
  79. if (err) {
  80. printk(KERN_ERR "lis3lv02dl: gpio request failed\n");
  81. goto out;
  82. }
  83. /* gpio for interrupt pin 2 */
  84. err = gpio_request(irq2, "lis3lv02dl_irq2");
  85. if (err) {
  86. gpio_free(irq1);
  87. printk(KERN_ERR "lis3lv02dl: gpio request failed\n");
  88. goto out;
  89. }
  90. gpio_direction_input(irq1);
  91. gpio_direction_input(irq2);
  92. out:
  93. return err;
  94. }
  95. static int lis302_release(void)
  96. {
  97. gpio_free(LIS302_IRQ1_GPIO);
  98. gpio_free(LIS302_IRQ2_GPIO);
  99. return 0;
  100. }
  101. static struct lis3lv02d_platform_data rx51_lis3lv02d_data = {
  102. .click_flags = LIS3_CLICK_SINGLE_X | LIS3_CLICK_SINGLE_Y |
  103. LIS3_CLICK_SINGLE_Z,
  104. /* Limits are 0.5g * value */
  105. .click_thresh_x = 8,
  106. .click_thresh_y = 8,
  107. .click_thresh_z = 10,
  108. /* Click must be longer than time limit */
  109. .click_time_limit = 9,
  110. /* Kind of debounce filter */
  111. .click_latency = 50,
  112. /* Limits for all axis. millig-value / 18 to get HW values */
  113. .wakeup_flags = LIS3_WAKEUP_X_HI | LIS3_WAKEUP_Y_HI,
  114. .wakeup_thresh = 800 / 18,
  115. .wakeup_flags2 = LIS3_WAKEUP_Z_HI ,
  116. .wakeup_thresh2 = 900 / 18,
  117. .hipass_ctrl = LIS3_HIPASS1_DISABLE | LIS3_HIPASS2_DISABLE,
  118. /* Interrupt line 2 for click detection, line 1 for thresholds */
  119. .irq_cfg = LIS3_IRQ2_CLICK | LIS3_IRQ1_FF_WU_12,
  120. .axis_x = LIS3_DEV_X,
  121. .axis_y = LIS3_INV_DEV_Y,
  122. .axis_z = LIS3_INV_DEV_Z,
  123. .setup_resources = lis302_setup,
  124. .release_resources = lis302_release,
  125. .st_min_limits = {-32, 3, 3},
  126. .st_max_limits = {-3, 32, 32},
  127. };
  128. #endif
  129. #if defined(CONFIG_SENSORS_TSL2563) || defined(CONFIG_SENSORS_TSL2563_MODULE)
  130. static struct tsl2563_platform_data rx51_tsl2563_platform_data = {
  131. .cover_comp_gain = 16,
  132. };
  133. #endif
  134. #if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
  135. static struct lp55xx_led_config rx51_lp5523_led_config[] = {
  136. {
  137. .name = "lp5523:kb1",
  138. .chan_nr = 0,
  139. .led_current = 50,
  140. .max_current = 100,
  141. }, {
  142. .name = "lp5523:kb2",
  143. .chan_nr = 1,
  144. .led_current = 50,
  145. .max_current = 100,
  146. }, {
  147. .name = "lp5523:kb3",
  148. .chan_nr = 2,
  149. .led_current = 50,
  150. .max_current = 100,
  151. }, {
  152. .name = "lp5523:kb4",
  153. .chan_nr = 3,
  154. .led_current = 50,
  155. .max_current = 100,
  156. }, {
  157. .name = "lp5523:b",
  158. .chan_nr = 4,
  159. .led_current = 50,
  160. .max_current = 100,
  161. }, {
  162. .name = "lp5523:g",
  163. .chan_nr = 5,
  164. .led_current = 50,
  165. .max_current = 100,
  166. }, {
  167. .name = "lp5523:r",
  168. .chan_nr = 6,
  169. .led_current = 50,
  170. .max_current = 100,
  171. }, {
  172. .name = "lp5523:kb5",
  173. .chan_nr = 7,
  174. .led_current = 50,
  175. .max_current = 100,
  176. }, {
  177. .name = "lp5523:kb6",
  178. .chan_nr = 8,
  179. .led_current = 50,
  180. .max_current = 100,
  181. }
  182. };
  183. static struct lp55xx_platform_data rx51_lp5523_platform_data = {
  184. .led_config = rx51_lp5523_led_config,
  185. .num_channels = ARRAY_SIZE(rx51_lp5523_led_config),
  186. .clock_mode = LP55XX_CLOCK_AUTO,
  187. .enable_gpio = RX51_LP5523_CHIP_EN_GPIO,
  188. };
  189. #endif
  190. #define RX51_LCD_RESET_GPIO 90
  191. static struct panel_acx565akm_platform_data acx_pdata = {
  192. .name = "lcd",
  193. .source = "sdi.0",
  194. .reset_gpio = RX51_LCD_RESET_GPIO,
  195. .datapairs = 2,
  196. };
  197. static struct omap2_mcspi_device_config wl1251_mcspi_config = {
  198. .turbo_mode = 0,
  199. };
  200. static struct omap2_mcspi_device_config mipid_mcspi_config = {
  201. .turbo_mode = 0,
  202. };
  203. static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
  204. .turbo_mode = 0,
  205. };
  206. static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
  207. [RX51_SPI_WL1251] = {
  208. .modalias = "wl1251",
  209. .bus_num = 4,
  210. .chip_select = 0,
  211. .max_speed_hz = 48000000,
  212. .mode = SPI_MODE_3,
  213. .controller_data = &wl1251_mcspi_config,
  214. .platform_data = &wl1251_pdata,
  215. },
  216. [RX51_SPI_MIPID] = {
  217. .modalias = "acx565akm",
  218. .bus_num = 1,
  219. .chip_select = 2,
  220. .max_speed_hz = 6000000,
  221. .controller_data = &mipid_mcspi_config,
  222. .platform_data = &acx_pdata,
  223. },
  224. [RX51_SPI_TSC2005] = {
  225. .modalias = "tsc2005",
  226. .bus_num = 1,
  227. .chip_select = 0,
  228. .max_speed_hz = 6000000,
  229. .controller_data = &tsc2005_mcspi_config,
  230. .platform_data = &tsc2005_pdata,
  231. },
  232. };
  233. static struct platform_device rx51_battery_device = {
  234. .name = "rx51-battery",
  235. .id = -1,
  236. };
  237. static void rx51_charger_set_power(bool on)
  238. {
  239. gpio_set_value(RX51_USB_TRANSCEIVER_RST_GPIO, on);
  240. }
  241. static struct isp1704_charger_data rx51_charger_data = {
  242. .set_power = rx51_charger_set_power,
  243. };
  244. static struct platform_device rx51_charger_device = {
  245. .name = "isp1704_charger",
  246. .dev = {
  247. .platform_data = &rx51_charger_data,
  248. },
  249. };
  250. static void __init rx51_charger_init(void)
  251. {
  252. WARN_ON(gpio_request_one(RX51_USB_TRANSCEIVER_RST_GPIO,
  253. GPIOF_OUT_INIT_HIGH, "isp1704_reset"));
  254. platform_device_register(&rx51_battery_device);
  255. platform_device_register(&rx51_charger_device);
  256. }
  257. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  258. #define RX51_GPIO_CAMERA_LENS_COVER 110
  259. #define RX51_GPIO_CAMERA_FOCUS 68
  260. #define RX51_GPIO_CAMERA_CAPTURE 69
  261. #define RX51_GPIO_KEYPAD_SLIDE 71
  262. #define RX51_GPIO_LOCK_BUTTON 113
  263. #define RX51_GPIO_PROXIMITY 89
  264. #define RX51_GPIO_DEBOUNCE_TIMEOUT 10
  265. static struct gpio_keys_button rx51_gpio_keys[] = {
  266. {
  267. .desc = "Camera Lens Cover",
  268. .type = EV_SW,
  269. .code = SW_CAMERA_LENS_COVER,
  270. .gpio = RX51_GPIO_CAMERA_LENS_COVER,
  271. .active_low = 1,
  272. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  273. }, {
  274. .desc = "Camera Focus",
  275. .type = EV_KEY,
  276. .code = KEY_CAMERA_FOCUS,
  277. .gpio = RX51_GPIO_CAMERA_FOCUS,
  278. .active_low = 1,
  279. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  280. }, {
  281. .desc = "Camera Capture",
  282. .type = EV_KEY,
  283. .code = KEY_CAMERA,
  284. .gpio = RX51_GPIO_CAMERA_CAPTURE,
  285. .active_low = 1,
  286. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  287. }, {
  288. .desc = "Lock Button",
  289. .type = EV_KEY,
  290. .code = KEY_SCREENLOCK,
  291. .gpio = RX51_GPIO_LOCK_BUTTON,
  292. .active_low = 1,
  293. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  294. }, {
  295. .desc = "Keypad Slide",
  296. .type = EV_SW,
  297. .code = SW_KEYPAD_SLIDE,
  298. .gpio = RX51_GPIO_KEYPAD_SLIDE,
  299. .active_low = 1,
  300. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  301. }, {
  302. .desc = "Proximity Sensor",
  303. .type = EV_SW,
  304. .code = SW_FRONT_PROXIMITY,
  305. .gpio = RX51_GPIO_PROXIMITY,
  306. .active_low = 0,
  307. .debounce_interval = RX51_GPIO_DEBOUNCE_TIMEOUT,
  308. }
  309. };
  310. static struct gpio_keys_platform_data rx51_gpio_keys_data = {
  311. .buttons = rx51_gpio_keys,
  312. .nbuttons = ARRAY_SIZE(rx51_gpio_keys),
  313. };
  314. static struct platform_device rx51_gpio_keys_device = {
  315. .name = "gpio-keys",
  316. .id = -1,
  317. .dev = {
  318. .platform_data = &rx51_gpio_keys_data,
  319. },
  320. };
  321. static void __init rx51_add_gpio_keys(void)
  322. {
  323. platform_device_register(&rx51_gpio_keys_device);
  324. }
  325. #else
  326. static void __init rx51_add_gpio_keys(void)
  327. {
  328. }
  329. #endif /* CONFIG_KEYBOARD_GPIO || CONFIG_KEYBOARD_GPIO_MODULE */
  330. static uint32_t board_keymap[] = {
  331. /*
  332. * Note that KEY(x, 8, KEY_XXX) entries represent "entrire row
  333. * connected to the ground" matrix state.
  334. */
  335. KEY(0, 0, KEY_Q),
  336. KEY(0, 1, KEY_O),
  337. KEY(0, 2, KEY_P),
  338. KEY(0, 3, KEY_COMMA),
  339. KEY(0, 4, KEY_BACKSPACE),
  340. KEY(0, 6, KEY_A),
  341. KEY(0, 7, KEY_S),
  342. KEY(1, 0, KEY_W),
  343. KEY(1, 1, KEY_D),
  344. KEY(1, 2, KEY_F),
  345. KEY(1, 3, KEY_G),
  346. KEY(1, 4, KEY_H),
  347. KEY(1, 5, KEY_J),
  348. KEY(1, 6, KEY_K),
  349. KEY(1, 7, KEY_L),
  350. KEY(2, 0, KEY_E),
  351. KEY(2, 1, KEY_DOT),
  352. KEY(2, 2, KEY_UP),
  353. KEY(2, 3, KEY_ENTER),
  354. KEY(2, 5, KEY_Z),
  355. KEY(2, 6, KEY_X),
  356. KEY(2, 7, KEY_C),
  357. KEY(2, 8, KEY_F9),
  358. KEY(3, 0, KEY_R),
  359. KEY(3, 1, KEY_V),
  360. KEY(3, 2, KEY_B),
  361. KEY(3, 3, KEY_N),
  362. KEY(3, 4, KEY_M),
  363. KEY(3, 5, KEY_SPACE),
  364. KEY(3, 6, KEY_SPACE),
  365. KEY(3, 7, KEY_LEFT),
  366. KEY(4, 0, KEY_T),
  367. KEY(4, 1, KEY_DOWN),
  368. KEY(4, 2, KEY_RIGHT),
  369. KEY(4, 4, KEY_LEFTCTRL),
  370. KEY(4, 5, KEY_RIGHTALT),
  371. KEY(4, 6, KEY_LEFTSHIFT),
  372. KEY(4, 8, KEY_F10),
  373. KEY(5, 0, KEY_Y),
  374. KEY(5, 8, KEY_F11),
  375. KEY(6, 0, KEY_U),
  376. KEY(7, 0, KEY_I),
  377. KEY(7, 1, KEY_F7),
  378. KEY(7, 2, KEY_F8),
  379. };
  380. static struct matrix_keymap_data board_map_data = {
  381. .keymap = board_keymap,
  382. .keymap_size = ARRAY_SIZE(board_keymap),
  383. };
  384. static struct twl4030_keypad_data rx51_kp_data = {
  385. .keymap_data = &board_map_data,
  386. .rows = 8,
  387. .cols = 8,
  388. .rep = 1,
  389. };
  390. /* Enable input logic and pull all lines up when eMMC is on. */
  391. static struct omap_board_mux rx51_mmc2_on_mux[] = {
  392. OMAP3_MUX(SDMMC2_CMD, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  393. OMAP3_MUX(SDMMC2_DAT0, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  394. OMAP3_MUX(SDMMC2_DAT1, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  395. OMAP3_MUX(SDMMC2_DAT2, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  396. OMAP3_MUX(SDMMC2_DAT3, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  397. OMAP3_MUX(SDMMC2_DAT4, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  398. OMAP3_MUX(SDMMC2_DAT5, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  399. OMAP3_MUX(SDMMC2_DAT6, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  400. OMAP3_MUX(SDMMC2_DAT7, OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0),
  401. { .reg_offset = OMAP_MUX_TERMINATOR },
  402. };
  403. /* Disable input logic and pull all lines down when eMMC is off. */
  404. static struct omap_board_mux rx51_mmc2_off_mux[] = {
  405. OMAP3_MUX(SDMMC2_CMD, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  406. OMAP3_MUX(SDMMC2_DAT0, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  407. OMAP3_MUX(SDMMC2_DAT1, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  408. OMAP3_MUX(SDMMC2_DAT2, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  409. OMAP3_MUX(SDMMC2_DAT3, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  410. OMAP3_MUX(SDMMC2_DAT4, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  411. OMAP3_MUX(SDMMC2_DAT5, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  412. OMAP3_MUX(SDMMC2_DAT6, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  413. OMAP3_MUX(SDMMC2_DAT7, OMAP_PULL_ENA | OMAP_MUX_MODE0),
  414. { .reg_offset = OMAP_MUX_TERMINATOR },
  415. };
  416. static struct omap_mux_partition *partition;
  417. /*
  418. * Current flows to eMMC when eMMC is off and the data lines are pulled up,
  419. * so pull them down. N.B. we pull 8 lines because we are using 8 lines.
  420. */
  421. static void rx51_mmc2_remux(struct device *dev, int power_on)
  422. {
  423. if (power_on)
  424. omap_mux_write_array(partition, rx51_mmc2_on_mux);
  425. else
  426. omap_mux_write_array(partition, rx51_mmc2_off_mux);
  427. }
  428. static struct omap2_hsmmc_info mmc[] __initdata = {
  429. {
  430. .name = "external",
  431. .mmc = 1,
  432. .caps = MMC_CAP_4_BIT_DATA,
  433. .cover_only = true,
  434. .gpio_cd = 160,
  435. .gpio_wp = -EINVAL,
  436. },
  437. {
  438. .name = "internal",
  439. .mmc = 2,
  440. .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  441. /* See also rx51_mmc2_remux */
  442. .gpio_cd = -EINVAL,
  443. .gpio_wp = -EINVAL,
  444. .nonremovable = true,
  445. .remux = rx51_mmc2_remux,
  446. },
  447. {} /* Terminator */
  448. };
  449. static struct regulator_consumer_supply rx51_vmmc1_supply[] = {
  450. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
  451. };
  452. static struct regulator_consumer_supply rx51_vaux2_supply[] = {
  453. REGULATOR_SUPPLY("vdds_csib", "omap3isp"),
  454. };
  455. static struct regulator_consumer_supply rx51_vaux3_supply[] = {
  456. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
  457. };
  458. static struct regulator_consumer_supply rx51_vsim_supply[] = {
  459. REGULATOR_SUPPLY("vmmc_aux", "omap_hsmmc.1"),
  460. };
  461. static struct regulator_consumer_supply rx51_vmmc2_supplies[] = {
  462. /* tlv320aic3x analog supplies */
  463. REGULATOR_SUPPLY("AVDD", "2-0018"),
  464. REGULATOR_SUPPLY("DRVDD", "2-0018"),
  465. REGULATOR_SUPPLY("AVDD", "2-0019"),
  466. REGULATOR_SUPPLY("DRVDD", "2-0019"),
  467. /* tpa6130a2 */
  468. REGULATOR_SUPPLY("Vdd", "2-0060"),
  469. /* Keep vmmc as last item. It is not iterated for newer boards */
  470. REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
  471. };
  472. static struct regulator_consumer_supply rx51_vio_supplies[] = {
  473. /* tlv320aic3x digital supplies */
  474. REGULATOR_SUPPLY("IOVDD", "2-0018"),
  475. REGULATOR_SUPPLY("DVDD", "2-0018"),
  476. REGULATOR_SUPPLY("IOVDD", "2-0019"),
  477. REGULATOR_SUPPLY("DVDD", "2-0019"),
  478. /* Si4713 IO supply */
  479. REGULATOR_SUPPLY("vio", "2-0063"),
  480. /* lis3lv02d */
  481. REGULATOR_SUPPLY("Vdd_IO", "3-001d"),
  482. };
  483. static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
  484. REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
  485. REGULATOR_SUPPLY("vdds_sdi", "omapdss_sdi.0"),
  486. /* Si4713 supply */
  487. REGULATOR_SUPPLY("vdd", "2-0063"),
  488. /* lis3lv02d */
  489. REGULATOR_SUPPLY("Vdd", "3-001d"),
  490. };
  491. static struct regulator_init_data rx51_vaux1 = {
  492. .constraints = {
  493. .name = "V28",
  494. .min_uV = 2800000,
  495. .max_uV = 2800000,
  496. .always_on = true, /* due battery cover sensor */
  497. .valid_modes_mask = REGULATOR_MODE_NORMAL
  498. | REGULATOR_MODE_STANDBY,
  499. .valid_ops_mask = REGULATOR_CHANGE_MODE
  500. | REGULATOR_CHANGE_STATUS,
  501. },
  502. .num_consumer_supplies = ARRAY_SIZE(rx51_vaux1_consumers),
  503. .consumer_supplies = rx51_vaux1_consumers,
  504. };
  505. static struct regulator_init_data rx51_vaux2 = {
  506. .constraints = {
  507. .name = "VCSI",
  508. .min_uV = 1800000,
  509. .max_uV = 1800000,
  510. .valid_modes_mask = REGULATOR_MODE_NORMAL
  511. | REGULATOR_MODE_STANDBY,
  512. .valid_ops_mask = REGULATOR_CHANGE_MODE
  513. | REGULATOR_CHANGE_STATUS,
  514. },
  515. .num_consumer_supplies = ARRAY_SIZE(rx51_vaux2_supply),
  516. .consumer_supplies = rx51_vaux2_supply,
  517. };
  518. /* VAUX3 - adds more power to VIO_18 rail */
  519. static struct regulator_init_data rx51_vaux3_cam = {
  520. .constraints = {
  521. .name = "VCAM_DIG_18",
  522. .min_uV = 1800000,
  523. .max_uV = 1800000,
  524. .apply_uV = true,
  525. .valid_modes_mask = REGULATOR_MODE_NORMAL
  526. | REGULATOR_MODE_STANDBY,
  527. .valid_ops_mask = REGULATOR_CHANGE_MODE
  528. | REGULATOR_CHANGE_STATUS,
  529. },
  530. };
  531. static struct regulator_init_data rx51_vaux3_mmc = {
  532. .constraints = {
  533. .name = "VMMC2_30",
  534. .min_uV = 2800000,
  535. .max_uV = 3000000,
  536. .apply_uV = true,
  537. .valid_modes_mask = REGULATOR_MODE_NORMAL
  538. | REGULATOR_MODE_STANDBY,
  539. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  540. | REGULATOR_CHANGE_MODE
  541. | REGULATOR_CHANGE_STATUS,
  542. },
  543. .num_consumer_supplies = ARRAY_SIZE(rx51_vaux3_supply),
  544. .consumer_supplies = rx51_vaux3_supply,
  545. };
  546. static struct regulator_init_data rx51_vaux4 = {
  547. .constraints = {
  548. .name = "VCAM_ANA_28",
  549. .min_uV = 2800000,
  550. .max_uV = 2800000,
  551. .apply_uV = true,
  552. .valid_modes_mask = REGULATOR_MODE_NORMAL
  553. | REGULATOR_MODE_STANDBY,
  554. .valid_ops_mask = REGULATOR_CHANGE_MODE
  555. | REGULATOR_CHANGE_STATUS,
  556. },
  557. };
  558. static struct regulator_init_data rx51_vmmc1 = {
  559. .constraints = {
  560. .min_uV = 1850000,
  561. .max_uV = 3150000,
  562. .valid_modes_mask = REGULATOR_MODE_NORMAL
  563. | REGULATOR_MODE_STANDBY,
  564. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  565. | REGULATOR_CHANGE_MODE
  566. | REGULATOR_CHANGE_STATUS,
  567. },
  568. .num_consumer_supplies = ARRAY_SIZE(rx51_vmmc1_supply),
  569. .consumer_supplies = rx51_vmmc1_supply,
  570. };
  571. static struct regulator_init_data rx51_vmmc2 = {
  572. .constraints = {
  573. .name = "V28_A",
  574. .min_uV = 2800000,
  575. .max_uV = 3000000,
  576. .always_on = true, /* due VIO leak to AIC34 VDDs */
  577. .apply_uV = true,
  578. .valid_modes_mask = REGULATOR_MODE_NORMAL
  579. | REGULATOR_MODE_STANDBY,
  580. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  581. | REGULATOR_CHANGE_MODE
  582. | REGULATOR_CHANGE_STATUS,
  583. },
  584. .num_consumer_supplies = ARRAY_SIZE(rx51_vmmc2_supplies),
  585. .consumer_supplies = rx51_vmmc2_supplies,
  586. };
  587. static struct regulator_init_data rx51_vpll1 = {
  588. .constraints = {
  589. .name = "VPLL",
  590. .min_uV = 1800000,
  591. .max_uV = 1800000,
  592. .apply_uV = true,
  593. .always_on = true,
  594. .valid_modes_mask = REGULATOR_MODE_NORMAL
  595. | REGULATOR_MODE_STANDBY,
  596. .valid_ops_mask = REGULATOR_CHANGE_MODE,
  597. },
  598. };
  599. static struct regulator_init_data rx51_vpll2 = {
  600. .constraints = {
  601. .name = "VSDI_CSI",
  602. .min_uV = 1800000,
  603. .max_uV = 1800000,
  604. .apply_uV = true,
  605. .always_on = true,
  606. .valid_modes_mask = REGULATOR_MODE_NORMAL
  607. | REGULATOR_MODE_STANDBY,
  608. .valid_ops_mask = REGULATOR_CHANGE_MODE,
  609. },
  610. };
  611. static struct regulator_init_data rx51_vsim = {
  612. .constraints = {
  613. .name = "VMMC2_IO_18",
  614. .min_uV = 1800000,
  615. .max_uV = 1800000,
  616. .apply_uV = true,
  617. .valid_modes_mask = REGULATOR_MODE_NORMAL
  618. | REGULATOR_MODE_STANDBY,
  619. .valid_ops_mask = REGULATOR_CHANGE_MODE
  620. | REGULATOR_CHANGE_STATUS,
  621. },
  622. .num_consumer_supplies = ARRAY_SIZE(rx51_vsim_supply),
  623. .consumer_supplies = rx51_vsim_supply,
  624. };
  625. static struct regulator_init_data rx51_vio = {
  626. .constraints = {
  627. .min_uV = 1800000,
  628. .max_uV = 1800000,
  629. .valid_modes_mask = REGULATOR_MODE_NORMAL
  630. | REGULATOR_MODE_STANDBY,
  631. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  632. | REGULATOR_CHANGE_MODE
  633. | REGULATOR_CHANGE_STATUS,
  634. },
  635. .num_consumer_supplies = ARRAY_SIZE(rx51_vio_supplies),
  636. .consumer_supplies = rx51_vio_supplies,
  637. };
  638. static struct regulator_init_data rx51_vintana1 = {
  639. .constraints = {
  640. .name = "VINTANA1",
  641. .min_uV = 1500000,
  642. .max_uV = 1500000,
  643. .always_on = true,
  644. .valid_modes_mask = REGULATOR_MODE_NORMAL
  645. | REGULATOR_MODE_STANDBY,
  646. .valid_ops_mask = REGULATOR_CHANGE_MODE,
  647. },
  648. };
  649. static struct regulator_init_data rx51_vintana2 = {
  650. .constraints = {
  651. .name = "VINTANA2",
  652. .min_uV = 2750000,
  653. .max_uV = 2750000,
  654. .apply_uV = true,
  655. .always_on = true,
  656. .valid_modes_mask = REGULATOR_MODE_NORMAL
  657. | REGULATOR_MODE_STANDBY,
  658. .valid_ops_mask = REGULATOR_CHANGE_MODE,
  659. },
  660. };
  661. static struct regulator_init_data rx51_vintdig = {
  662. .constraints = {
  663. .name = "VINTDIG",
  664. .min_uV = 1500000,
  665. .max_uV = 1500000,
  666. .always_on = true,
  667. .valid_modes_mask = REGULATOR_MODE_NORMAL
  668. | REGULATOR_MODE_STANDBY,
  669. .valid_ops_mask = REGULATOR_CHANGE_MODE,
  670. },
  671. };
  672. static struct gpiod_lookup_table rx51_fmtx_gpios_table = {
  673. .dev_id = "2-0063",
  674. .table = {
  675. GPIO_LOOKUP("gpio.6", 3, "reset", GPIO_ACTIVE_HIGH), /* 163 */
  676. { },
  677. },
  678. };
  679. static __init void rx51_gpio_init(void)
  680. {
  681. gpiod_add_lookup_table(&rx51_fmtx_gpios_table);
  682. }
  683. static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
  684. {
  685. /* FIXME this gpio setup is just a placeholder for now */
  686. gpio_request_one(gpio + 6, GPIOF_OUT_INIT_LOW, "backlight_pwm");
  687. gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "speaker_en");
  688. return 0;
  689. }
  690. static struct twl4030_gpio_platform_data rx51_gpio_data = {
  691. .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
  692. | BIT(4) | BIT(5)
  693. | BIT(8) | BIT(9) | BIT(10) | BIT(11)
  694. | BIT(12) | BIT(13) | BIT(14) | BIT(15)
  695. | BIT(16) | BIT(17) ,
  696. .setup = rx51_twlgpio_setup,
  697. };
  698. static struct twl4030_ins sleep_on_seq[] __initdata = {
  699. /*
  700. * Turn off everything
  701. */
  702. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_SLEEP), 2},
  703. };
  704. static struct twl4030_script sleep_on_script __initdata = {
  705. .script = sleep_on_seq,
  706. .size = ARRAY_SIZE(sleep_on_seq),
  707. .flags = TWL4030_SLEEP_SCRIPT,
  708. };
  709. static struct twl4030_ins wakeup_seq[] __initdata = {
  710. /*
  711. * Reenable everything
  712. */
  713. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
  714. };
  715. static struct twl4030_script wakeup_script __initdata = {
  716. .script = wakeup_seq,
  717. .size = ARRAY_SIZE(wakeup_seq),
  718. .flags = TWL4030_WAKEUP12_SCRIPT,
  719. };
  720. static struct twl4030_ins wakeup_p3_seq[] __initdata = {
  721. /*
  722. * Reenable everything
  723. */
  724. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 1, 0, RES_STATE_ACTIVE), 2},
  725. };
  726. static struct twl4030_script wakeup_p3_script __initdata = {
  727. .script = wakeup_p3_seq,
  728. .size = ARRAY_SIZE(wakeup_p3_seq),
  729. .flags = TWL4030_WAKEUP3_SCRIPT,
  730. };
  731. static struct twl4030_ins wrst_seq[] __initdata = {
  732. /*
  733. * Reset twl4030.
  734. * Reset VDD1 regulator.
  735. * Reset VDD2 regulator.
  736. * Reset VPLL1 regulator.
  737. * Enable sysclk output.
  738. * Reenable twl4030.
  739. */
  740. {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
  741. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
  742. 0x13},
  743. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
  744. {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
  745. {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
  746. {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
  747. {MSG_SINGULAR(DEV_GRP_P3, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
  748. {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
  749. };
  750. static struct twl4030_script wrst_script __initdata = {
  751. .script = wrst_seq,
  752. .size = ARRAY_SIZE(wrst_seq),
  753. .flags = TWL4030_WRST_SCRIPT,
  754. };
  755. static struct twl4030_script *twl4030_scripts[] __initdata = {
  756. /* wakeup12 script should be loaded before sleep script, otherwise a
  757. board might hit retention before loading of wakeup script is
  758. completed. This can cause boot failures depending on timing issues.
  759. */
  760. &wakeup_script,
  761. &sleep_on_script,
  762. &wakeup_p3_script,
  763. &wrst_script,
  764. };
  765. static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
  766. { .resource = RES_VDD1, .devgroup = -1,
  767. .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
  768. .remap_sleep = RES_STATE_OFF
  769. },
  770. { .resource = RES_VDD2, .devgroup = -1,
  771. .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
  772. .remap_sleep = RES_STATE_OFF
  773. },
  774. { .resource = RES_VPLL1, .devgroup = -1,
  775. .type = 1, .type2 = -1, .remap_off = RES_STATE_OFF,
  776. .remap_sleep = RES_STATE_OFF
  777. },
  778. { .resource = RES_VPLL2, .devgroup = -1,
  779. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  780. },
  781. { .resource = RES_VAUX1, .devgroup = -1,
  782. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  783. },
  784. { .resource = RES_VAUX2, .devgroup = -1,
  785. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  786. },
  787. { .resource = RES_VAUX3, .devgroup = -1,
  788. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  789. },
  790. { .resource = RES_VAUX4, .devgroup = -1,
  791. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  792. },
  793. { .resource = RES_VMMC1, .devgroup = -1,
  794. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  795. },
  796. { .resource = RES_VMMC2, .devgroup = -1,
  797. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  798. },
  799. { .resource = RES_VDAC, .devgroup = -1,
  800. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  801. },
  802. { .resource = RES_VSIM, .devgroup = -1,
  803. .type = -1, .type2 = 3, .remap_off = -1, .remap_sleep = -1
  804. },
  805. { .resource = RES_VINTANA1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  806. .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  807. },
  808. { .resource = RES_VINTANA2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  809. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  810. },
  811. { .resource = RES_VINTDIG, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  812. .type = -1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  813. },
  814. { .resource = RES_VIO, .devgroup = DEV_GRP_P3,
  815. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  816. },
  817. { .resource = RES_CLKEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  818. .type = 1, .type2 = -1 , .remap_off = -1, .remap_sleep = -1
  819. },
  820. { .resource = RES_REGEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  821. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  822. },
  823. { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  824. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  825. },
  826. { .resource = RES_SYSEN, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
  827. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  828. },
  829. { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
  830. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  831. },
  832. { .resource = RES_32KCLKOUT, .devgroup = -1,
  833. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  834. },
  835. { .resource = RES_RESET, .devgroup = -1,
  836. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  837. },
  838. { .resource = RES_MAIN_REF, .devgroup = -1,
  839. .type = 1, .type2 = -1, .remap_off = -1, .remap_sleep = -1
  840. },
  841. { 0, 0},
  842. };
  843. static struct twl4030_power_data rx51_t2scripts_data __initdata = {
  844. .scripts = twl4030_scripts,
  845. .num = ARRAY_SIZE(twl4030_scripts),
  846. .resource_config = twl4030_rconfig,
  847. };
  848. static struct twl4030_vibra_data rx51_vibra_data __initdata = {
  849. .coexist = 0,
  850. };
  851. static struct twl4030_audio_data rx51_audio_data __initdata = {
  852. .audio_mclk = 26000000,
  853. .vibra = &rx51_vibra_data,
  854. };
  855. static struct twl4030_platform_data rx51_twldata __initdata = {
  856. /* platform_data for children goes here */
  857. .gpio = &rx51_gpio_data,
  858. .keypad = &rx51_kp_data,
  859. .power = &rx51_t2scripts_data,
  860. .audio = &rx51_audio_data,
  861. .vaux1 = &rx51_vaux1,
  862. .vaux2 = &rx51_vaux2,
  863. .vaux4 = &rx51_vaux4,
  864. .vmmc1 = &rx51_vmmc1,
  865. .vpll1 = &rx51_vpll1,
  866. .vpll2 = &rx51_vpll2,
  867. .vsim = &rx51_vsim,
  868. .vintana1 = &rx51_vintana1,
  869. .vintana2 = &rx51_vintana2,
  870. .vintdig = &rx51_vintdig,
  871. .vio = &rx51_vio,
  872. };
  873. static struct tpa6130a2_platform_data rx51_tpa6130a2_data __initdata_or_module = {
  874. .power_gpio = 98,
  875. };
  876. /* Audio setup data */
  877. static struct aic3x_setup_data rx51_aic34_setup = {
  878. .gpio_func[0] = AIC3X_GPIO1_FUNC_DISABLED,
  879. .gpio_func[1] = AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT,
  880. };
  881. static struct aic3x_pdata rx51_aic3x_data = {
  882. .setup = &rx51_aic34_setup,
  883. .gpio_reset = 60,
  884. };
  885. static struct aic3x_pdata rx51_aic3x_data2 = {
  886. .gpio_reset = 60,
  887. };
  888. #if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713)
  889. static struct si4713_platform_data rx51_si4713_platform_data = {
  890. .is_platform_device = true
  891. };
  892. #endif
  893. static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = {
  894. #if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713)
  895. {
  896. I2C_BOARD_INFO("si4713", 0x63),
  897. .platform_data = &rx51_si4713_platform_data,
  898. },
  899. #endif
  900. {
  901. I2C_BOARD_INFO("tlv320aic3x", 0x18),
  902. .platform_data = &rx51_aic3x_data,
  903. },
  904. {
  905. I2C_BOARD_INFO("tlv320aic3x", 0x19),
  906. .platform_data = &rx51_aic3x_data2,
  907. },
  908. #if defined(CONFIG_SENSORS_TSL2563) || defined(CONFIG_SENSORS_TSL2563_MODULE)
  909. {
  910. I2C_BOARD_INFO("tsl2563", 0x29),
  911. .platform_data = &rx51_tsl2563_platform_data,
  912. },
  913. #endif
  914. #if defined(CONFIG_LEDS_LP5523) || defined(CONFIG_LEDS_LP5523_MODULE)
  915. {
  916. I2C_BOARD_INFO("lp5523", 0x32),
  917. .platform_data = &rx51_lp5523_platform_data,
  918. },
  919. #endif
  920. {
  921. I2C_BOARD_INFO("bq27200", 0x55),
  922. },
  923. {
  924. I2C_BOARD_INFO("tpa6130a2", 0x60),
  925. .platform_data = &rx51_tpa6130a2_data,
  926. }
  927. };
  928. static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_3[] = {
  929. #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
  930. {
  931. I2C_BOARD_INFO("lis3lv02d", 0x1d),
  932. .platform_data = &rx51_lis3lv02d_data,
  933. },
  934. #endif
  935. };
  936. static int __init rx51_i2c_init(void)
  937. {
  938. #if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713)
  939. int err;
  940. #endif
  941. if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
  942. system_rev >= SYSTEM_REV_B_USES_VAUX3) {
  943. rx51_twldata.vaux3 = &rx51_vaux3_mmc;
  944. /* Only older boards use VMMC2 for internal MMC */
  945. rx51_vmmc2.num_consumer_supplies--;
  946. } else {
  947. rx51_twldata.vaux3 = &rx51_vaux3_cam;
  948. }
  949. rx51_twldata.vmmc2 = &rx51_vmmc2;
  950. omap3_pmic_get_config(&rx51_twldata,
  951. TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC,
  952. TWL_COMMON_REGULATOR_VDAC);
  953. rx51_twldata.vdac->constraints.apply_uV = true;
  954. rx51_twldata.vdac->constraints.name = "VDAC";
  955. omap_pmic_init(1, 2200, "twl5030", 7 + OMAP_INTC_START, &rx51_twldata);
  956. #if IS_ENABLED(CONFIG_I2C_SI4713) && IS_ENABLED(CONFIG_PLATFORM_SI4713)
  957. err = gpio_request_one(RX51_FMTX_IRQ, GPIOF_DIR_IN, "si4713 irq");
  958. if (err) {
  959. printk(KERN_ERR "Cannot request si4713 irq gpio. %d\n", err);
  960. return err;
  961. }
  962. rx51_peripherals_i2c_board_info_2[0].irq = gpio_to_irq(RX51_FMTX_IRQ);
  963. #endif
  964. omap_register_i2c_bus(2, 100, rx51_peripherals_i2c_board_info_2,
  965. ARRAY_SIZE(rx51_peripherals_i2c_board_info_2));
  966. #if defined(CONFIG_SENSORS_LIS3_I2C) || defined(CONFIG_SENSORS_LIS3_I2C_MODULE)
  967. rx51_lis3lv02d_data.irq2 = gpio_to_irq(LIS302_IRQ2_GPIO);
  968. rx51_peripherals_i2c_board_info_3[0].irq = gpio_to_irq(LIS302_IRQ1_GPIO);
  969. #endif
  970. omap_register_i2c_bus(3, 400, rx51_peripherals_i2c_board_info_3,
  971. ARRAY_SIZE(rx51_peripherals_i2c_board_info_3));
  972. return 0;
  973. }
  974. #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
  975. defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
  976. static struct mtd_partition onenand_partitions[] = {
  977. {
  978. .name = "bootloader",
  979. .offset = 0,
  980. .size = 0x20000,
  981. .mask_flags = MTD_WRITEABLE, /* Force read-only */
  982. },
  983. {
  984. .name = "config",
  985. .offset = MTDPART_OFS_APPEND,
  986. .size = 0x60000,
  987. },
  988. {
  989. .name = "log",
  990. .offset = MTDPART_OFS_APPEND,
  991. .size = 0x40000,
  992. },
  993. {
  994. .name = "kernel",
  995. .offset = MTDPART_OFS_APPEND,
  996. .size = 0x200000,
  997. },
  998. {
  999. .name = "initfs",
  1000. .offset = MTDPART_OFS_APPEND,
  1001. .size = 0x200000,
  1002. },
  1003. {
  1004. .name = "rootfs",
  1005. .offset = MTDPART_OFS_APPEND,
  1006. .size = MTDPART_SIZ_FULL,
  1007. },
  1008. };
  1009. static struct omap_onenand_platform_data board_onenand_data[] = {
  1010. {
  1011. .cs = 0,
  1012. .gpio_irq = 65,
  1013. .parts = onenand_partitions,
  1014. .nr_parts = ARRAY_SIZE(onenand_partitions),
  1015. .flags = ONENAND_SYNC_READWRITE,
  1016. }
  1017. };
  1018. #endif
  1019. static struct gpio rx51_wl1251_gpios[] __initdata = {
  1020. { RX51_WL1251_IRQ_GPIO, GPIOF_IN, "wl1251 irq" },
  1021. };
  1022. static void __init rx51_init_wl1251(void)
  1023. {
  1024. int irq, ret;
  1025. ret = gpio_request_array(rx51_wl1251_gpios,
  1026. ARRAY_SIZE(rx51_wl1251_gpios));
  1027. if (ret < 0)
  1028. goto error;
  1029. irq = gpio_to_irq(RX51_WL1251_IRQ_GPIO);
  1030. if (irq < 0)
  1031. goto err_irq;
  1032. wl1251_pdata.power_gpio = RX51_WL1251_POWER_GPIO;
  1033. rx51_peripherals_spi_board_info[RX51_SPI_WL1251].irq = irq;
  1034. return;
  1035. err_irq:
  1036. gpio_free(RX51_WL1251_IRQ_GPIO);
  1037. error:
  1038. printk(KERN_ERR "wl1251 board initialisation failed\n");
  1039. wl1251_pdata.power_gpio = -1;
  1040. /*
  1041. * Now rx51_peripherals_spi_board_info[1].irq is zero and
  1042. * set_power is null, and wl1251_probe() will fail.
  1043. */
  1044. }
  1045. static struct tsc2005_platform_data tsc2005_pdata = {
  1046. .ts_pressure_max = 2048,
  1047. .ts_pressure_fudge = 2,
  1048. .ts_x_max = 4096,
  1049. .ts_x_fudge = 4,
  1050. .ts_y_max = 4096,
  1051. .ts_y_fudge = 7,
  1052. .ts_x_plate_ohm = 280,
  1053. .esd_timeout_ms = 8000,
  1054. };
  1055. static struct gpio rx51_tsc2005_gpios[] __initdata = {
  1056. { RX51_TSC2005_IRQ_GPIO, GPIOF_IN, "tsc2005 IRQ" },
  1057. { RX51_TSC2005_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "tsc2005 reset" },
  1058. };
  1059. static void rx51_tsc2005_set_reset(bool enable)
  1060. {
  1061. gpio_set_value(RX51_TSC2005_RESET_GPIO, enable);
  1062. }
  1063. static void __init rx51_init_tsc2005(void)
  1064. {
  1065. int r;
  1066. omap_mux_init_gpio(RX51_TSC2005_RESET_GPIO, OMAP_PIN_OUTPUT);
  1067. omap_mux_init_gpio(RX51_TSC2005_IRQ_GPIO, OMAP_PIN_INPUT_PULLUP);
  1068. r = gpio_request_array(rx51_tsc2005_gpios,
  1069. ARRAY_SIZE(rx51_tsc2005_gpios));
  1070. if (r < 0) {
  1071. printk(KERN_ERR "tsc2005 board initialization failed\n");
  1072. tsc2005_pdata.esd_timeout_ms = 0;
  1073. return;
  1074. }
  1075. tsc2005_pdata.set_reset = rx51_tsc2005_set_reset;
  1076. rx51_peripherals_spi_board_info[RX51_SPI_TSC2005].irq =
  1077. gpio_to_irq(RX51_TSC2005_IRQ_GPIO);
  1078. }
  1079. #if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
  1080. static struct lirc_rx51_platform_data rx51_lirc_data = {
  1081. .set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
  1082. .pwm_timer = 9, /* Use GPT 9 for CIR */
  1083. };
  1084. static struct platform_device rx51_lirc_device = {
  1085. .name = "lirc_rx51",
  1086. .id = -1,
  1087. .dev = {
  1088. .platform_data = &rx51_lirc_data,
  1089. },
  1090. };
  1091. static void __init rx51_init_lirc(void)
  1092. {
  1093. platform_device_register(&rx51_lirc_device);
  1094. }
  1095. #else
  1096. static void __init rx51_init_lirc(void)
  1097. {
  1098. }
  1099. #endif
  1100. static struct platform_device madc_hwmon = {
  1101. .name = "twl4030_madc_hwmon",
  1102. .id = -1,
  1103. };
  1104. static void __init rx51_init_twl4030_hwmon(void)
  1105. {
  1106. platform_device_register(&madc_hwmon);
  1107. }
  1108. static struct platform_device omap3_rom_rng_device = {
  1109. .name = "omap3-rom-rng",
  1110. .id = -1,
  1111. .dev = {
  1112. .platform_data = rx51_secure_rng_call,
  1113. },
  1114. };
  1115. static void __init rx51_init_omap3_rom_rng(void)
  1116. {
  1117. if (omap_type() == OMAP2_DEVICE_TYPE_SEC) {
  1118. pr_info("RX-51: Registring OMAP3 HWRNG device\n");
  1119. platform_device_register(&omap3_rom_rng_device);
  1120. }
  1121. }
  1122. void __init rx51_peripherals_init(void)
  1123. {
  1124. rx51_gpio_init();
  1125. rx51_i2c_init();
  1126. regulator_has_full_constraints();
  1127. gpmc_onenand_init(board_onenand_data);
  1128. rx51_add_gpio_keys();
  1129. rx51_init_wl1251();
  1130. rx51_init_tsc2005();
  1131. rx51_init_lirc();
  1132. spi_register_board_info(rx51_peripherals_spi_board_info,
  1133. ARRAY_SIZE(rx51_peripherals_spi_board_info));
  1134. partition = omap_mux_get("core");
  1135. if (partition)
  1136. omap_hsmmc_init(mmc);
  1137. rx51_charger_init();
  1138. rx51_init_twl4030_hwmon();
  1139. rx51_init_omap3_rom_rng();
  1140. }