board-rx51-peripherals.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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/i2c.h>
  17. #include <linux/i2c/twl4030.h>
  18. #include <linux/clk.h>
  19. #include <linux/delay.h>
  20. #include <linux/regulator/machine.h>
  21. #include <linux/gpio.h>
  22. #include <linux/mmc/host.h>
  23. #include <mach/mcspi.h>
  24. #include <mach/mux.h>
  25. #include <mach/board.h>
  26. #include <mach/common.h>
  27. #include <mach/dma.h>
  28. #include <mach/gpmc.h>
  29. #include <mach/onenand.h>
  30. #include <mach/gpmc-smc91x.h>
  31. #include "mmc-twl4030.h"
  32. #define SYSTEM_REV_B_USES_VAUX3 0x1699
  33. #define SYSTEM_REV_S_USES_VAUX3 0x8
  34. static int board_keymap[] = {
  35. KEY(0, 0, KEY_Q),
  36. KEY(0, 1, KEY_O),
  37. KEY(0, 2, KEY_P),
  38. KEY(0, 3, KEY_COMMA),
  39. KEY(0, 4, KEY_BACKSPACE),
  40. KEY(0, 6, KEY_A),
  41. KEY(0, 7, KEY_S),
  42. KEY(1, 0, KEY_W),
  43. KEY(1, 1, KEY_D),
  44. KEY(1, 2, KEY_F),
  45. KEY(1, 3, KEY_G),
  46. KEY(1, 4, KEY_H),
  47. KEY(1, 5, KEY_J),
  48. KEY(1, 6, KEY_K),
  49. KEY(1, 7, KEY_L),
  50. KEY(2, 0, KEY_E),
  51. KEY(2, 1, KEY_DOT),
  52. KEY(2, 2, KEY_UP),
  53. KEY(2, 3, KEY_ENTER),
  54. KEY(2, 5, KEY_Z),
  55. KEY(2, 6, KEY_X),
  56. KEY(2, 7, KEY_C),
  57. KEY(3, 0, KEY_R),
  58. KEY(3, 1, KEY_V),
  59. KEY(3, 2, KEY_B),
  60. KEY(3, 3, KEY_N),
  61. KEY(3, 4, KEY_M),
  62. KEY(3, 5, KEY_SPACE),
  63. KEY(3, 6, KEY_SPACE),
  64. KEY(3, 7, KEY_LEFT),
  65. KEY(4, 0, KEY_T),
  66. KEY(4, 1, KEY_DOWN),
  67. KEY(4, 2, KEY_RIGHT),
  68. KEY(4, 4, KEY_LEFTCTRL),
  69. KEY(4, 5, KEY_RIGHTALT),
  70. KEY(4, 6, KEY_LEFTSHIFT),
  71. KEY(5, 0, KEY_Y),
  72. KEY(6, 0, KEY_U),
  73. KEY(7, 0, KEY_I),
  74. KEY(7, 1, KEY_F7),
  75. KEY(7, 2, KEY_F8),
  76. KEY(0xff, 2, KEY_F9),
  77. KEY(0xff, 4, KEY_F10),
  78. KEY(0xff, 5, KEY_F11),
  79. };
  80. static struct matrix_keymap_data board_map_data = {
  81. .keymap = board_keymap,
  82. .keymap_size = ARRAY_SIZE(board_keymap),
  83. };
  84. static struct twl4030_keypad_data rx51_kp_data = {
  85. .keymap_data = &board_map_data,
  86. .rows = 8,
  87. .cols = 8,
  88. .rep = 1,
  89. };
  90. static struct twl4030_madc_platform_data rx51_madc_data = {
  91. .irq_line = 1,
  92. };
  93. static struct twl4030_hsmmc_info mmc[] = {
  94. {
  95. .name = "external",
  96. .mmc = 1,
  97. .wires = 4,
  98. .cover_only = true,
  99. .gpio_cd = 160,
  100. .gpio_wp = -EINVAL,
  101. .power_saving = true,
  102. },
  103. {
  104. .name = "internal",
  105. .mmc = 2,
  106. .wires = 8,
  107. .gpio_cd = -EINVAL,
  108. .gpio_wp = -EINVAL,
  109. .nonremovable = true,
  110. .power_saving = true,
  111. },
  112. {} /* Terminator */
  113. };
  114. static struct regulator_consumer_supply rx51_vmmc1_supply = {
  115. .supply = "vmmc",
  116. };
  117. static struct regulator_consumer_supply rx51_vmmc2_supply = {
  118. .supply = "vmmc",
  119. };
  120. static struct regulator_consumer_supply rx51_vsim_supply = {
  121. .supply = "vmmc_aux",
  122. };
  123. static struct regulator_init_data rx51_vaux1 = {
  124. .constraints = {
  125. .name = "V28",
  126. .min_uV = 2800000,
  127. .max_uV = 2800000,
  128. .valid_modes_mask = REGULATOR_MODE_NORMAL
  129. | REGULATOR_MODE_STANDBY,
  130. .valid_ops_mask = REGULATOR_CHANGE_MODE
  131. | REGULATOR_CHANGE_STATUS,
  132. },
  133. };
  134. static struct regulator_init_data rx51_vaux2 = {
  135. .constraints = {
  136. .name = "VCSI",
  137. .min_uV = 1800000,
  138. .max_uV = 1800000,
  139. .valid_modes_mask = REGULATOR_MODE_NORMAL
  140. | REGULATOR_MODE_STANDBY,
  141. .valid_ops_mask = REGULATOR_CHANGE_MODE
  142. | REGULATOR_CHANGE_STATUS,
  143. },
  144. };
  145. /* VAUX3 - adds more power to VIO_18 rail */
  146. static struct regulator_init_data rx51_vaux3_cam = {
  147. .constraints = {
  148. .name = "VCAM_DIG_18",
  149. .min_uV = 1800000,
  150. .max_uV = 1800000,
  151. .apply_uV = true,
  152. .valid_modes_mask = REGULATOR_MODE_NORMAL
  153. | REGULATOR_MODE_STANDBY,
  154. .valid_ops_mask = REGULATOR_CHANGE_MODE
  155. | REGULATOR_CHANGE_STATUS,
  156. },
  157. };
  158. static struct regulator_init_data rx51_vaux3_mmc = {
  159. .constraints = {
  160. .name = "VMMC2_30",
  161. .min_uV = 2800000,
  162. .max_uV = 3000000,
  163. .apply_uV = true,
  164. .valid_modes_mask = REGULATOR_MODE_NORMAL
  165. | REGULATOR_MODE_STANDBY,
  166. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  167. | REGULATOR_CHANGE_MODE
  168. | REGULATOR_CHANGE_STATUS,
  169. },
  170. .num_consumer_supplies = 1,
  171. .consumer_supplies = &rx51_vmmc2_supply,
  172. };
  173. static struct regulator_init_data rx51_vaux4 = {
  174. .constraints = {
  175. .name = "VCAM_ANA_28",
  176. .min_uV = 2800000,
  177. .max_uV = 2800000,
  178. .apply_uV = true,
  179. .valid_modes_mask = REGULATOR_MODE_NORMAL
  180. | REGULATOR_MODE_STANDBY,
  181. .valid_ops_mask = REGULATOR_CHANGE_MODE
  182. | REGULATOR_CHANGE_STATUS,
  183. },
  184. };
  185. static struct regulator_init_data rx51_vmmc1 = {
  186. .constraints = {
  187. .min_uV = 1850000,
  188. .max_uV = 3150000,
  189. .valid_modes_mask = REGULATOR_MODE_NORMAL
  190. | REGULATOR_MODE_STANDBY,
  191. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  192. | REGULATOR_CHANGE_MODE
  193. | REGULATOR_CHANGE_STATUS,
  194. },
  195. .num_consumer_supplies = 1,
  196. .consumer_supplies = &rx51_vmmc1_supply,
  197. };
  198. static struct regulator_init_data rx51_vmmc2 = {
  199. .constraints = {
  200. .name = "VMMC2_30",
  201. .min_uV = 1850000,
  202. .max_uV = 3150000,
  203. .apply_uV = true,
  204. .valid_modes_mask = REGULATOR_MODE_NORMAL
  205. | REGULATOR_MODE_STANDBY,
  206. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  207. | REGULATOR_CHANGE_MODE
  208. | REGULATOR_CHANGE_STATUS,
  209. },
  210. .num_consumer_supplies = 1,
  211. .consumer_supplies = &rx51_vmmc2_supply,
  212. };
  213. static struct regulator_init_data rx51_vsim = {
  214. .constraints = {
  215. .name = "VMMC2_IO_18",
  216. .min_uV = 1800000,
  217. .max_uV = 1800000,
  218. .apply_uV = true,
  219. .valid_modes_mask = REGULATOR_MODE_NORMAL
  220. | REGULATOR_MODE_STANDBY,
  221. .valid_ops_mask = REGULATOR_CHANGE_MODE
  222. | REGULATOR_CHANGE_STATUS,
  223. },
  224. .num_consumer_supplies = 1,
  225. .consumer_supplies = &rx51_vsim_supply,
  226. };
  227. static struct regulator_init_data rx51_vdac = {
  228. .constraints = {
  229. .min_uV = 1800000,
  230. .max_uV = 1800000,
  231. .valid_modes_mask = REGULATOR_MODE_NORMAL
  232. | REGULATOR_MODE_STANDBY,
  233. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
  234. | REGULATOR_CHANGE_MODE
  235. | REGULATOR_CHANGE_STATUS,
  236. },
  237. };
  238. static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n)
  239. {
  240. /* FIXME this gpio setup is just a placeholder for now */
  241. gpio_request(gpio + 6, "backlight_pwm");
  242. gpio_direction_output(gpio + 6, 0);
  243. gpio_request(gpio + 7, "speaker_en");
  244. gpio_direction_output(gpio + 7, 1);
  245. /* set up MMC adapters, linking their regulators to them */
  246. twl4030_mmc_init(mmc);
  247. rx51_vmmc1_supply.dev = mmc[0].dev;
  248. rx51_vmmc2_supply.dev = mmc[1].dev;
  249. rx51_vsim_supply.dev = mmc[1].dev;
  250. return 0;
  251. }
  252. static struct twl4030_gpio_platform_data rx51_gpio_data = {
  253. .gpio_base = OMAP_MAX_GPIO_LINES,
  254. .irq_base = TWL4030_GPIO_IRQ_BASE,
  255. .irq_end = TWL4030_GPIO_IRQ_END,
  256. .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3)
  257. | BIT(4) | BIT(5)
  258. | BIT(8) | BIT(9) | BIT(10) | BIT(11)
  259. | BIT(12) | BIT(13) | BIT(14) | BIT(15)
  260. | BIT(16) | BIT(17) ,
  261. .setup = rx51_twlgpio_setup,
  262. };
  263. static struct twl4030_usb_data rx51_usb_data = {
  264. .usb_mode = T2_USB_MODE_ULPI,
  265. };
  266. static struct twl4030_ins sleep_on_seq[] __initdata = {
  267. /*
  268. * Turn off VDD1 and VDD2.
  269. */
  270. {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
  271. {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
  272. /*
  273. * And also turn off the OMAP3 PLLs and the sysclk output.
  274. */
  275. {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
  276. {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_OFF), 3},
  277. };
  278. static struct twl4030_script sleep_on_script __initdata = {
  279. .script = sleep_on_seq,
  280. .size = ARRAY_SIZE(sleep_on_seq),
  281. .flags = TWL4030_SLEEP_SCRIPT,
  282. };
  283. static struct twl4030_ins wakeup_seq[] __initdata = {
  284. /*
  285. * Reenable the OMAP3 PLLs.
  286. * Wakeup VDD1 and VDD2.
  287. * Reenable sysclk output.
  288. */
  289. {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
  290. {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
  291. {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
  292. {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
  293. };
  294. static struct twl4030_script wakeup_script __initdata = {
  295. .script = wakeup_seq,
  296. .size = ARRAY_SIZE(wakeup_seq),
  297. .flags = TWL4030_WAKEUP12_SCRIPT,
  298. };
  299. static struct twl4030_ins wakeup_p3_seq[] __initdata = {
  300. /*
  301. * Wakeup VDD1 (dummy to be able to insert a delay)
  302. * Enable CLKEN
  303. */
  304. {MSG_SINGULAR(DEV_GRP_P1, 0x17, RES_STATE_ACTIVE), 3},
  305. };
  306. static struct twl4030_script wakeup_p3_script __initdata = {
  307. .script = wakeup_p3_seq,
  308. .size = ARRAY_SIZE(wakeup_p3_seq),
  309. .flags = TWL4030_WAKEUP3_SCRIPT,
  310. };
  311. static struct twl4030_ins wrst_seq[] __initdata = {
  312. /*
  313. * Reset twl4030.
  314. * Reset VDD1 regulator.
  315. * Reset VDD2 regulator.
  316. * Reset VPLL1 regulator.
  317. * Enable sysclk output.
  318. * Reenable twl4030.
  319. */
  320. {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
  321. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, 0, 1, RES_STATE_ACTIVE),
  322. 0x13},
  323. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 2, RES_STATE_WRST), 0x13},
  324. {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP, 0, 3, RES_STATE_OFF), 0x13},
  325. {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD1, RES_STATE_WRST), 0x13},
  326. {MSG_SINGULAR(DEV_GRP_NULL, RES_VDD2, RES_STATE_WRST), 0x13},
  327. {MSG_SINGULAR(DEV_GRP_NULL, RES_VPLL1, RES_STATE_WRST), 0x35},
  328. {MSG_SINGULAR(DEV_GRP_P1, RES_HFCLKOUT, RES_STATE_ACTIVE), 2},
  329. {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
  330. };
  331. static struct twl4030_script wrst_script __initdata = {
  332. .script = wrst_seq,
  333. .size = ARRAY_SIZE(wrst_seq),
  334. .flags = TWL4030_WRST_SCRIPT,
  335. };
  336. static struct twl4030_script *twl4030_scripts[] __initdata = {
  337. /* wakeup12 script should be loaded before sleep script, otherwise a
  338. board might hit retention before loading of wakeup script is
  339. completed. This can cause boot failures depending on timing issues.
  340. */
  341. &wakeup_script,
  342. &sleep_on_script,
  343. &wakeup_p3_script,
  344. &wrst_script,
  345. };
  346. static struct twl4030_resconfig twl4030_rconfig[] __initdata = {
  347. { .resource = RES_VINTANA1, .devgroup = -1, .type = -1, .type2 = 1 },
  348. { .resource = RES_VINTANA2, .devgroup = -1, .type = -1, .type2 = 1 },
  349. { .resource = RES_VINTDIG, .devgroup = -1, .type = -1, .type2 = 1 },
  350. { .resource = RES_VMMC1, .devgroup = -1, .type = -1, .type2 = 3},
  351. { .resource = RES_VMMC2, .devgroup = DEV_GRP_NULL, .type = -1,
  352. .type2 = 3},
  353. { .resource = RES_VAUX1, .devgroup = -1, .type = -1, .type2 = 3},
  354. { .resource = RES_VAUX2, .devgroup = -1, .type = -1, .type2 = 3},
  355. { .resource = RES_VAUX3, .devgroup = -1, .type = -1, .type2 = 3},
  356. { .resource = RES_VAUX4, .devgroup = -1, .type = -1, .type2 = 3},
  357. { .resource = RES_VPLL2, .devgroup = -1, .type = -1, .type2 = 3},
  358. { .resource = RES_VDAC, .devgroup = -1, .type = -1, .type2 = 3},
  359. { .resource = RES_VSIM, .devgroup = DEV_GRP_NULL, .type = -1,
  360. .type2 = 3},
  361. { .resource = RES_CLKEN, .devgroup = DEV_GRP_P3, .type = -1,
  362. .type2 = 1 },
  363. { 0, 0},
  364. };
  365. static struct twl4030_power_data rx51_t2scripts_data __initdata = {
  366. .scripts = twl4030_scripts,
  367. .num = ARRAY_SIZE(twl4030_scripts),
  368. .resource_config = twl4030_rconfig,
  369. };
  370. static struct twl4030_platform_data rx51_twldata __initdata = {
  371. .irq_base = TWL4030_IRQ_BASE,
  372. .irq_end = TWL4030_IRQ_END,
  373. /* platform_data for children goes here */
  374. .gpio = &rx51_gpio_data,
  375. .keypad = &rx51_kp_data,
  376. .madc = &rx51_madc_data,
  377. .usb = &rx51_usb_data,
  378. .power = &rx51_t2scripts_data,
  379. .vaux1 = &rx51_vaux1,
  380. .vaux2 = &rx51_vaux2,
  381. .vaux4 = &rx51_vaux4,
  382. .vmmc1 = &rx51_vmmc1,
  383. .vsim = &rx51_vsim,
  384. .vdac = &rx51_vdac,
  385. };
  386. static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
  387. {
  388. I2C_BOARD_INFO("twl5030", 0x48),
  389. .flags = I2C_CLIENT_WAKE,
  390. .irq = INT_34XX_SYS_NIRQ,
  391. .platform_data = &rx51_twldata,
  392. },
  393. };
  394. static int __init rx51_i2c_init(void)
  395. {
  396. if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
  397. system_rev >= SYSTEM_REV_B_USES_VAUX3)
  398. rx51_twldata.vaux3 = &rx51_vaux3_mmc;
  399. else {
  400. rx51_twldata.vaux3 = &rx51_vaux3_cam;
  401. rx51_twldata.vmmc2 = &rx51_vmmc2;
  402. }
  403. omap_register_i2c_bus(1, 2200, rx51_peripherals_i2c_board_info_1,
  404. ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
  405. omap_register_i2c_bus(2, 100, NULL, 0);
  406. omap_register_i2c_bus(3, 400, NULL, 0);
  407. return 0;
  408. }
  409. #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
  410. defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
  411. static struct mtd_partition onenand_partitions[] = {
  412. {
  413. .name = "bootloader",
  414. .offset = 0,
  415. .size = 0x20000,
  416. .mask_flags = MTD_WRITEABLE, /* Force read-only */
  417. },
  418. {
  419. .name = "config",
  420. .offset = MTDPART_OFS_APPEND,
  421. .size = 0x60000,
  422. },
  423. {
  424. .name = "log",
  425. .offset = MTDPART_OFS_APPEND,
  426. .size = 0x40000,
  427. },
  428. {
  429. .name = "kernel",
  430. .offset = MTDPART_OFS_APPEND,
  431. .size = 0x200000,
  432. },
  433. {
  434. .name = "initfs",
  435. .offset = MTDPART_OFS_APPEND,
  436. .size = 0x200000,
  437. },
  438. {
  439. .name = "rootfs",
  440. .offset = MTDPART_OFS_APPEND,
  441. .size = MTDPART_SIZ_FULL,
  442. },
  443. };
  444. static struct omap_onenand_platform_data board_onenand_data = {
  445. .cs = 0,
  446. .gpio_irq = 65,
  447. .parts = onenand_partitions,
  448. .nr_parts = ARRAY_SIZE(onenand_partitions),
  449. .flags = ONENAND_SYNC_READWRITE,
  450. };
  451. static void __init board_onenand_init(void)
  452. {
  453. gpmc_onenand_init(&board_onenand_data);
  454. }
  455. #else
  456. static inline void board_onenand_init(void)
  457. {
  458. }
  459. #endif
  460. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  461. static struct omap_smc91x_platform_data board_smc91x_data = {
  462. .cs = 1,
  463. .gpio_irq = 54,
  464. .gpio_pwrdwn = 86,
  465. .gpio_reset = 164,
  466. .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
  467. };
  468. static void __init board_smc91x_init(void)
  469. {
  470. omap_cfg_reg(U8_34XX_GPIO54_DOWN);
  471. omap_cfg_reg(G25_34XX_GPIO86_OUT);
  472. omap_cfg_reg(H19_34XX_GPIO164_OUT);
  473. gpmc_smc91x_init(&board_smc91x_data);
  474. }
  475. #else
  476. static inline void board_smc91x_init(void)
  477. {
  478. }
  479. #endif
  480. void __init rx51_peripherals_init(void)
  481. {
  482. rx51_i2c_init();
  483. board_onenand_init();
  484. board_smc91x_init();
  485. }