board-rx51-peripherals.c 13 KB

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