board-rx51-peripherals.c 17 KB

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