board-rx51-peripherals.c 24 KB

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