board-rx51-peripherals.c 21 KB

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