mach-goni.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /* linux/arch/arm/mach-s5pv210/mach-goni.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com/
  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/types.h>
  12. #include <linux/init.h>
  13. #include <linux/serial_core.h>
  14. #include <linux/fb.h>
  15. #include <linux/i2c.h>
  16. #include <linux/i2c-gpio.h>
  17. #include <linux/mfd/max8998.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/input.h>
  20. #include <linux/gpio.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/setup.h>
  24. #include <asm/mach-types.h>
  25. #include <mach/map.h>
  26. #include <mach/regs-clock.h>
  27. #include <mach/regs-fb.h>
  28. #include <plat/gpio-cfg.h>
  29. #include <plat/regs-serial.h>
  30. #include <plat/s5pv210.h>
  31. #include <plat/devs.h>
  32. #include <plat/cpu.h>
  33. #include <plat/fb.h>
  34. #include <plat/keypad.h>
  35. #include <plat/sdhci.h>
  36. /* Following are default values for UCON, ULCON and UFCON UART registers */
  37. #define GONI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
  38. S3C2410_UCON_RXILEVEL | \
  39. S3C2410_UCON_TXIRQMODE | \
  40. S3C2410_UCON_RXIRQMODE | \
  41. S3C2410_UCON_RXFIFO_TOI | \
  42. S3C2443_UCON_RXERR_IRQEN)
  43. #define GONI_ULCON_DEFAULT S3C2410_LCON_CS8
  44. #define GONI_UFCON_DEFAULT S3C2410_UFCON_FIFOMODE
  45. static struct s3c2410_uartcfg goni_uartcfgs[] __initdata = {
  46. [0] = {
  47. .hwport = 0,
  48. .flags = 0,
  49. .ucon = GONI_UCON_DEFAULT,
  50. .ulcon = GONI_ULCON_DEFAULT,
  51. .ufcon = GONI_UFCON_DEFAULT |
  52. S5PV210_UFCON_TXTRIG256 | S5PV210_UFCON_RXTRIG256,
  53. },
  54. [1] = {
  55. .hwport = 1,
  56. .flags = 0,
  57. .ucon = GONI_UCON_DEFAULT,
  58. .ulcon = GONI_ULCON_DEFAULT,
  59. .ufcon = GONI_UFCON_DEFAULT |
  60. S5PV210_UFCON_TXTRIG64 | S5PV210_UFCON_RXTRIG64,
  61. },
  62. [2] = {
  63. .hwport = 2,
  64. .flags = 0,
  65. .ucon = GONI_UCON_DEFAULT,
  66. .ulcon = GONI_ULCON_DEFAULT,
  67. .ufcon = GONI_UFCON_DEFAULT |
  68. S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16,
  69. },
  70. [3] = {
  71. .hwport = 3,
  72. .flags = 0,
  73. .ucon = GONI_UCON_DEFAULT,
  74. .ulcon = GONI_ULCON_DEFAULT,
  75. .ufcon = GONI_UFCON_DEFAULT |
  76. S5PV210_UFCON_TXTRIG16 | S5PV210_UFCON_RXTRIG16,
  77. },
  78. };
  79. /* Frame Buffer */
  80. static struct s3c_fb_pd_win goni_fb_win0 = {
  81. .win_mode = {
  82. .pixclock = 1000000000000ULL / ((16+16+2+480)*(28+3+2+800)*55),
  83. .left_margin = 16,
  84. .right_margin = 16,
  85. .upper_margin = 3,
  86. .lower_margin = 28,
  87. .hsync_len = 2,
  88. .vsync_len = 2,
  89. .xres = 480,
  90. .yres = 800,
  91. .refresh = 55,
  92. },
  93. .max_bpp = 32,
  94. .default_bpp = 16,
  95. };
  96. static struct s3c_fb_platdata goni_lcd_pdata __initdata = {
  97. .win[0] = &goni_fb_win0,
  98. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB |
  99. VIDCON0_CLKSEL_LCD,
  100. .vidcon1 = VIDCON1_INV_VCLK | VIDCON1_INV_VDEN
  101. | VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  102. .setup_gpio = s5pv210_fb_gpio_setup_24bpp,
  103. };
  104. /* KEYPAD */
  105. static uint32_t keymap[] __initdata = {
  106. /* KEY(row, col, keycode) */
  107. KEY(0, 1, KEY_MENU), /* Send */
  108. KEY(0, 2, KEY_BACK), /* End */
  109. KEY(1, 1, KEY_CONFIG), /* Half shot */
  110. KEY(1, 2, KEY_VOLUMEUP),
  111. KEY(2, 1, KEY_CAMERA), /* Full shot */
  112. KEY(2, 2, KEY_VOLUMEDOWN),
  113. };
  114. static struct matrix_keymap_data keymap_data __initdata = {
  115. .keymap = keymap,
  116. .keymap_size = ARRAY_SIZE(keymap),
  117. };
  118. static struct samsung_keypad_platdata keypad_data __initdata = {
  119. .keymap_data = &keymap_data,
  120. .rows = 3,
  121. .cols = 3,
  122. };
  123. /* MAX8998 regulators */
  124. #if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE)
  125. static struct regulator_init_data goni_ldo2_data = {
  126. .constraints = {
  127. .name = "VALIVE_1.1V",
  128. .min_uV = 1100000,
  129. .max_uV = 1100000,
  130. .apply_uV = 1,
  131. .always_on = 1,
  132. .state_mem = {
  133. .enabled = 1,
  134. },
  135. },
  136. };
  137. static struct regulator_init_data goni_ldo3_data = {
  138. .constraints = {
  139. .name = "VUSB/MIPI_1.1V",
  140. .min_uV = 1100000,
  141. .max_uV = 1100000,
  142. .apply_uV = 1,
  143. .always_on = 1,
  144. },
  145. };
  146. static struct regulator_init_data goni_ldo4_data = {
  147. .constraints = {
  148. .name = "VDAC_3.3V",
  149. .min_uV = 3300000,
  150. .max_uV = 3300000,
  151. .apply_uV = 1,
  152. },
  153. };
  154. static struct regulator_init_data goni_ldo5_data = {
  155. .constraints = {
  156. .name = "VTF_2.8V",
  157. .min_uV = 2800000,
  158. .max_uV = 2800000,
  159. .apply_uV = 1,
  160. },
  161. };
  162. static struct regulator_init_data goni_ldo6_data = {
  163. .constraints = {
  164. .name = "VCC_3.3V",
  165. .min_uV = 3300000,
  166. .max_uV = 3300000,
  167. .apply_uV = 1,
  168. },
  169. };
  170. static struct regulator_init_data goni_ldo7_data = {
  171. .constraints = {
  172. .name = "VLCD_1.8V",
  173. .min_uV = 1800000,
  174. .max_uV = 1800000,
  175. .apply_uV = 1,
  176. .always_on = 1,
  177. },
  178. };
  179. static struct regulator_init_data goni_ldo8_data = {
  180. .constraints = {
  181. .name = "VUSB/VADC_3.3V",
  182. .min_uV = 3300000,
  183. .max_uV = 3300000,
  184. .apply_uV = 1,
  185. .always_on = 1,
  186. },
  187. };
  188. static struct regulator_init_data goni_ldo9_data = {
  189. .constraints = {
  190. .name = "VCC/VCAM_2.8V",
  191. .min_uV = 2800000,
  192. .max_uV = 2800000,
  193. .apply_uV = 1,
  194. .always_on = 1,
  195. },
  196. };
  197. static struct regulator_init_data goni_ldo10_data = {
  198. .constraints = {
  199. .name = "VPLL_1.1V",
  200. .min_uV = 1100000,
  201. .max_uV = 1100000,
  202. .apply_uV = 1,
  203. .boot_on = 1,
  204. },
  205. };
  206. static struct regulator_init_data goni_ldo11_data = {
  207. .constraints = {
  208. .name = "CAM_IO_2.8V",
  209. .min_uV = 2800000,
  210. .max_uV = 2800000,
  211. .apply_uV = 1,
  212. .always_on = 1,
  213. },
  214. };
  215. static struct regulator_init_data goni_ldo12_data = {
  216. .constraints = {
  217. .name = "CAM_ISP_1.2V",
  218. .min_uV = 1200000,
  219. .max_uV = 1200000,
  220. .apply_uV = 1,
  221. .always_on = 1,
  222. },
  223. };
  224. static struct regulator_init_data goni_ldo13_data = {
  225. .constraints = {
  226. .name = "CAM_A_2.8V",
  227. .min_uV = 2800000,
  228. .max_uV = 2800000,
  229. .apply_uV = 1,
  230. .always_on = 1,
  231. },
  232. };
  233. static struct regulator_init_data goni_ldo14_data = {
  234. .constraints = {
  235. .name = "CAM_CIF_1.8V",
  236. .min_uV = 1800000,
  237. .max_uV = 1800000,
  238. .apply_uV = 1,
  239. .always_on = 1,
  240. },
  241. };
  242. static struct regulator_init_data goni_ldo15_data = {
  243. .constraints = {
  244. .name = "CAM_AF_3.3V",
  245. .min_uV = 3300000,
  246. .max_uV = 3300000,
  247. .apply_uV = 1,
  248. .always_on = 1,
  249. },
  250. };
  251. static struct regulator_init_data goni_ldo16_data = {
  252. .constraints = {
  253. .name = "VMIPI_1.8V",
  254. .min_uV = 1800000,
  255. .max_uV = 1800000,
  256. .apply_uV = 1,
  257. .always_on = 1,
  258. },
  259. };
  260. static struct regulator_init_data goni_ldo17_data = {
  261. .constraints = {
  262. .name = "VCC_3.0V_LCD",
  263. .min_uV = 3000000,
  264. .max_uV = 3000000,
  265. .apply_uV = 1,
  266. .always_on = 1,
  267. },
  268. };
  269. /* BUCK */
  270. static struct regulator_consumer_supply buck1_consumer[] = {
  271. { .supply = "vddarm", },
  272. };
  273. static struct regulator_consumer_supply buck2_consumer[] = {
  274. { .supply = "vddint", },
  275. };
  276. static struct regulator_init_data goni_buck1_data = {
  277. .constraints = {
  278. .name = "VARM_1.2V",
  279. .min_uV = 1200000,
  280. .max_uV = 1200000,
  281. .apply_uV = 1,
  282. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  283. REGULATOR_CHANGE_STATUS,
  284. },
  285. .num_consumer_supplies = ARRAY_SIZE(buck1_consumer),
  286. .consumer_supplies = buck1_consumer,
  287. };
  288. static struct regulator_init_data goni_buck2_data = {
  289. .constraints = {
  290. .name = "VINT_1.2V",
  291. .min_uV = 1200000,
  292. .max_uV = 1200000,
  293. .apply_uV = 1,
  294. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
  295. REGULATOR_CHANGE_STATUS,
  296. },
  297. .num_consumer_supplies = ARRAY_SIZE(buck2_consumer),
  298. .consumer_supplies = buck2_consumer,
  299. };
  300. static struct regulator_init_data goni_buck3_data = {
  301. .constraints = {
  302. .name = "VCC_1.8V",
  303. .min_uV = 1800000,
  304. .max_uV = 1800000,
  305. .apply_uV = 1,
  306. .state_mem = {
  307. .enabled = 1,
  308. },
  309. },
  310. };
  311. static struct regulator_init_data goni_buck4_data = {
  312. .constraints = {
  313. .name = "CAM_CORE_1.2V",
  314. .min_uV = 1200000,
  315. .max_uV = 1200000,
  316. .apply_uV = 1,
  317. .always_on = 1,
  318. },
  319. };
  320. static struct max8998_regulator_data goni_regulators[] = {
  321. { MAX8998_LDO2, &goni_ldo2_data },
  322. { MAX8998_LDO3, &goni_ldo3_data },
  323. { MAX8998_LDO4, &goni_ldo4_data },
  324. { MAX8998_LDO5, &goni_ldo5_data },
  325. { MAX8998_LDO6, &goni_ldo6_data },
  326. { MAX8998_LDO7, &goni_ldo7_data },
  327. { MAX8998_LDO8, &goni_ldo8_data },
  328. { MAX8998_LDO9, &goni_ldo9_data },
  329. { MAX8998_LDO10, &goni_ldo10_data },
  330. { MAX8998_LDO11, &goni_ldo11_data },
  331. { MAX8998_LDO12, &goni_ldo12_data },
  332. { MAX8998_LDO13, &goni_ldo13_data },
  333. { MAX8998_LDO14, &goni_ldo14_data },
  334. { MAX8998_LDO15, &goni_ldo15_data },
  335. { MAX8998_LDO16, &goni_ldo16_data },
  336. { MAX8998_LDO17, &goni_ldo17_data },
  337. { MAX8998_BUCK1, &goni_buck1_data },
  338. { MAX8998_BUCK2, &goni_buck2_data },
  339. { MAX8998_BUCK3, &goni_buck3_data },
  340. { MAX8998_BUCK4, &goni_buck4_data },
  341. };
  342. static struct max8998_platform_data goni_max8998_pdata = {
  343. .num_regulators = ARRAY_SIZE(goni_regulators),
  344. .regulators = goni_regulators,
  345. };
  346. #endif
  347. /* GPIO I2C PMIC */
  348. #define AP_I2C_GPIO_PMIC_BUS_4 4
  349. static struct i2c_gpio_platform_data goni_i2c_gpio_pmic_data = {
  350. .sda_pin = S5PV210_GPJ4(0), /* XMSMCSN */
  351. .scl_pin = S5PV210_GPJ4(3), /* XMSMIRQN */
  352. };
  353. static struct platform_device goni_i2c_gpio_pmic = {
  354. .name = "i2c-gpio",
  355. .id = AP_I2C_GPIO_PMIC_BUS_4,
  356. .dev = {
  357. .platform_data = &goni_i2c_gpio_pmic_data,
  358. },
  359. };
  360. static struct i2c_board_info i2c_gpio_pmic_devs[] __initdata = {
  361. #if defined(CONFIG_REGULATOR_MAX8998) || defined(CONFIG_REGULATOR_MAX8998_MODULE)
  362. {
  363. /* 0xCC when SRAD = 0 */
  364. I2C_BOARD_INFO("max8998", 0xCC >> 1),
  365. .platform_data = &goni_max8998_pdata,
  366. },
  367. #endif
  368. };
  369. /* PMIC Power button */
  370. static struct gpio_keys_button goni_gpio_keys_table[] = {
  371. {
  372. .code = KEY_POWER,
  373. .gpio = S5PV210_GPH2(6),
  374. .desc = "gpio-keys: KEY_POWER",
  375. .type = EV_KEY,
  376. .active_low = 1,
  377. .wakeup = 1,
  378. .debounce_interval = 1,
  379. },
  380. };
  381. static struct gpio_keys_platform_data goni_gpio_keys_data = {
  382. .buttons = goni_gpio_keys_table,
  383. .nbuttons = ARRAY_SIZE(goni_gpio_keys_table),
  384. };
  385. static struct platform_device goni_device_gpiokeys = {
  386. .name = "gpio-keys",
  387. .dev = {
  388. .platform_data = &goni_gpio_keys_data,
  389. },
  390. };
  391. static void __init goni_pmic_init(void)
  392. {
  393. /* AP_PMIC_IRQ: EINT7 */
  394. s3c_gpio_cfgpin(S5PV210_GPH0(7), S3C_GPIO_SFN(0xf));
  395. s3c_gpio_setpull(S5PV210_GPH0(7), S3C_GPIO_PULL_UP);
  396. /* nPower: EINT22 */
  397. s3c_gpio_cfgpin(S5PV210_GPH2(6), S3C_GPIO_SFN(0xf));
  398. s3c_gpio_setpull(S5PV210_GPH2(6), S3C_GPIO_PULL_UP);
  399. }
  400. /* MoviNAND */
  401. static struct s3c_sdhci_platdata goni_hsmmc0_data __initdata = {
  402. .max_width = 4,
  403. .cd_type = S3C_SDHCI_CD_PERMANENT,
  404. };
  405. /* Wireless LAN */
  406. static struct s3c_sdhci_platdata goni_hsmmc1_data __initdata = {
  407. .max_width = 4,
  408. .cd_type = S3C_SDHCI_CD_EXTERNAL,
  409. /* ext_cd_{init,cleanup} callbacks will be added later */
  410. };
  411. /* External Flash */
  412. #define GONI_EXT_FLASH_EN S5PV210_MP05(4)
  413. #define GONI_EXT_FLASH_CD S5PV210_GPH3(4)
  414. static struct s3c_sdhci_platdata goni_hsmmc2_data __initdata = {
  415. .max_width = 4,
  416. .cd_type = S3C_SDHCI_CD_GPIO,
  417. .ext_cd_gpio = GONI_EXT_FLASH_CD,
  418. .ext_cd_gpio_invert = 1,
  419. };
  420. static void goni_setup_sdhci(void)
  421. {
  422. gpio_request(GONI_EXT_FLASH_EN, "FLASH_EN");
  423. gpio_direction_output(GONI_EXT_FLASH_EN, 1);
  424. s3c_sdhci0_set_platdata(&goni_hsmmc0_data);
  425. s3c_sdhci1_set_platdata(&goni_hsmmc1_data);
  426. s3c_sdhci2_set_platdata(&goni_hsmmc2_data);
  427. };
  428. static struct platform_device *goni_devices[] __initdata = {
  429. &s3c_device_fb,
  430. &s5p_device_onenand,
  431. &goni_i2c_gpio_pmic,
  432. &goni_device_gpiokeys,
  433. &s5p_device_fimc0,
  434. &s5p_device_fimc1,
  435. &s5p_device_fimc2,
  436. &s3c_device_hsmmc0,
  437. &s3c_device_hsmmc1,
  438. &s3c_device_hsmmc2,
  439. &samsung_device_keypad,
  440. };
  441. static void __init goni_map_io(void)
  442. {
  443. s5p_init_io(NULL, 0, S5P_VA_CHIPID);
  444. s3c24xx_init_clocks(24000000);
  445. s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs));
  446. }
  447. static void __init goni_machine_init(void)
  448. {
  449. /* PMIC */
  450. goni_pmic_init();
  451. i2c_register_board_info(AP_I2C_GPIO_PMIC_BUS_4, i2c_gpio_pmic_devs,
  452. ARRAY_SIZE(i2c_gpio_pmic_devs));
  453. /* SDHCI */
  454. goni_setup_sdhci();
  455. /* FB */
  456. s3c_fb_set_platdata(&goni_lcd_pdata);
  457. /* KEYPAD */
  458. samsung_keypad_set_platdata(&keypad_data);
  459. platform_add_devices(goni_devices, ARRAY_SIZE(goni_devices));
  460. }
  461. MACHINE_START(GONI, "GONI")
  462. /* Maintainers: Kyungmin Park <kyungmin.park@samsung.com> */
  463. .phys_io = S3C_PA_UART & 0xfff00000,
  464. .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
  465. .boot_params = S5P_PA_SDRAM + 0x100,
  466. .init_irq = s5pv210_init_irq,
  467. .map_io = goni_map_io,
  468. .init_machine = goni_machine_init,
  469. .timer = &s3c24xx_timer,
  470. MACHINE_END