board-rx51-peripherals.c 24 KB

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