board-rx51-peripherals.c 23 KB

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