board-rx51-peripherals.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. /*
  2. * linux/arch/arm/mach-omap2/board-rx51-flash.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_platform_data rx51_twldata = {
  257. .irq_base = TWL4030_IRQ_BASE,
  258. .irq_end = TWL4030_IRQ_END,
  259. /* platform_data for children goes here */
  260. .gpio = &rx51_gpio_data,
  261. .keypad = &rx51_kp_data,
  262. .madc = &rx51_madc_data,
  263. .vaux1 = &rx51_vaux1,
  264. .vaux2 = &rx51_vaux2,
  265. .vaux4 = &rx51_vaux4,
  266. .vmmc1 = &rx51_vmmc1,
  267. .vsim = &rx51_vsim,
  268. .vdac = &rx51_vdac,
  269. };
  270. static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = {
  271. {
  272. I2C_BOARD_INFO("twl5030", 0x48),
  273. .flags = I2C_CLIENT_WAKE,
  274. .irq = INT_34XX_SYS_NIRQ,
  275. .platform_data = &rx51_twldata,
  276. },
  277. };
  278. static int __init rx51_i2c_init(void)
  279. {
  280. if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) ||
  281. system_rev >= SYSTEM_REV_B_USES_VAUX3)
  282. rx51_twldata.vaux3 = &rx51_vaux3_mmc;
  283. else {
  284. rx51_twldata.vaux3 = &rx51_vaux3_cam;
  285. rx51_twldata.vmmc2 = &rx51_vmmc2;
  286. }
  287. omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1,
  288. ARRAY_SIZE(rx51_peripherals_i2c_board_info_1));
  289. omap_register_i2c_bus(2, 100, NULL, 0);
  290. omap_register_i2c_bus(3, 400, NULL, 0);
  291. return 0;
  292. }
  293. #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
  294. defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
  295. static struct mtd_partition onenand_partitions[] = {
  296. {
  297. .name = "bootloader",
  298. .offset = 0,
  299. .size = 0x20000,
  300. .mask_flags = MTD_WRITEABLE, /* Force read-only */
  301. },
  302. {
  303. .name = "config",
  304. .offset = MTDPART_OFS_APPEND,
  305. .size = 0x60000,
  306. },
  307. {
  308. .name = "log",
  309. .offset = MTDPART_OFS_APPEND,
  310. .size = 0x40000,
  311. },
  312. {
  313. .name = "kernel",
  314. .offset = MTDPART_OFS_APPEND,
  315. .size = 0x200000,
  316. },
  317. {
  318. .name = "initfs",
  319. .offset = MTDPART_OFS_APPEND,
  320. .size = 0x200000,
  321. },
  322. {
  323. .name = "rootfs",
  324. .offset = MTDPART_OFS_APPEND,
  325. .size = MTDPART_SIZ_FULL,
  326. },
  327. };
  328. static struct omap_onenand_platform_data board_onenand_data = {
  329. .cs = 0,
  330. .gpio_irq = 65,
  331. .parts = onenand_partitions,
  332. .nr_parts = ARRAY_SIZE(onenand_partitions),
  333. .flags = ONENAND_SYNC_READWRITE,
  334. };
  335. static void __init board_onenand_init(void)
  336. {
  337. gpmc_onenand_init(&board_onenand_data);
  338. }
  339. #else
  340. static inline void board_onenand_init(void)
  341. {
  342. }
  343. #endif
  344. #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
  345. static struct omap_smc91x_platform_data board_smc91x_data = {
  346. .cs = 1,
  347. .gpio_irq = 54,
  348. .gpio_pwrdwn = 86,
  349. .gpio_reset = 164,
  350. .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
  351. };
  352. static void __init board_smc91x_init(void)
  353. {
  354. omap_cfg_reg(U8_34XX_GPIO54_DOWN);
  355. omap_cfg_reg(G25_34XX_GPIO86_OUT);
  356. omap_cfg_reg(H19_34XX_GPIO164_OUT);
  357. gpmc_smc91x_init(&board_smc91x_data);
  358. }
  359. #else
  360. static inline void board_smc91x_init(void)
  361. {
  362. }
  363. #endif
  364. void __init rx51_peripherals_init(void)
  365. {
  366. rx51_i2c_init();
  367. board_onenand_init();
  368. board_smc91x_init();
  369. }