board-rx51-peripherals.c 13 KB

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