mach-nuri.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. /*
  2. * linux/arch/arm/mach-exynos4/mach-nuri.c
  3. *
  4. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  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/platform_device.h>
  11. #include <linux/serial_core.h>
  12. #include <linux/input.h>
  13. #include <linux/i2c.h>
  14. #include <linux/i2c/atmel_mxt_ts.h>
  15. #include <linux/gpio_keys.h>
  16. #include <linux/gpio.h>
  17. #include <linux/regulator/machine.h>
  18. #include <linux/regulator/fixed.h>
  19. #include <linux/mmc/host.h>
  20. #include <linux/fb.h>
  21. #include <linux/pwm_backlight.h>
  22. #include <video/platform_lcd.h>
  23. #include <asm/mach/arch.h>
  24. #include <asm/mach-types.h>
  25. #include <plat/regs-serial.h>
  26. #include <plat/exynos4.h>
  27. #include <plat/cpu.h>
  28. #include <plat/devs.h>
  29. #include <plat/sdhci.h>
  30. #include <plat/ehci.h>
  31. #include <plat/clock.h>
  32. #include <plat/gpio-cfg.h>
  33. #include <plat/iic.h>
  34. #include <mach/map.h>
  35. /* Following are default values for UCON, ULCON and UFCON UART registers */
  36. #define NURI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
  37. S3C2410_UCON_RXILEVEL | \
  38. S3C2410_UCON_TXIRQMODE | \
  39. S3C2410_UCON_RXIRQMODE | \
  40. S3C2410_UCON_RXFIFO_TOI | \
  41. S3C2443_UCON_RXERR_IRQEN)
  42. #define NURI_ULCON_DEFAULT S3C2410_LCON_CS8
  43. #define NURI_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
  44. S5PV210_UFCON_TXTRIG256 | \
  45. S5PV210_UFCON_RXTRIG256)
  46. enum fixed_regulator_id {
  47. FIXED_REG_ID_MMC = 0,
  48. };
  49. static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {
  50. {
  51. .hwport = 0,
  52. .ucon = NURI_UCON_DEFAULT,
  53. .ulcon = NURI_ULCON_DEFAULT,
  54. .ufcon = NURI_UFCON_DEFAULT,
  55. },
  56. {
  57. .hwport = 1,
  58. .ucon = NURI_UCON_DEFAULT,
  59. .ulcon = NURI_ULCON_DEFAULT,
  60. .ufcon = NURI_UFCON_DEFAULT,
  61. },
  62. {
  63. .hwport = 2,
  64. .ucon = NURI_UCON_DEFAULT,
  65. .ulcon = NURI_ULCON_DEFAULT,
  66. .ufcon = NURI_UFCON_DEFAULT,
  67. },
  68. {
  69. .hwport = 3,
  70. .ucon = NURI_UCON_DEFAULT,
  71. .ulcon = NURI_ULCON_DEFAULT,
  72. .ufcon = NURI_UFCON_DEFAULT,
  73. },
  74. };
  75. /* eMMC */
  76. static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = {
  77. .max_width = 8,
  78. .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
  79. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
  80. MMC_CAP_DISABLE | MMC_CAP_ERASE),
  81. .cd_type = S3C_SDHCI_CD_PERMANENT,
  82. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  83. };
  84. static struct regulator_consumer_supply emmc_supplies[] = {
  85. REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
  86. REGULATOR_SUPPLY("vmmc", "dw_mmc"),
  87. };
  88. static struct regulator_init_data emmc_fixed_voltage_init_data = {
  89. .constraints = {
  90. .name = "VMEM_VDD_2.8V",
  91. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  92. },
  93. .num_consumer_supplies = ARRAY_SIZE(emmc_supplies),
  94. .consumer_supplies = emmc_supplies,
  95. };
  96. static struct fixed_voltage_config emmc_fixed_voltage_config = {
  97. .supply_name = "MASSMEMORY_EN (inverted)",
  98. .microvolts = 2800000,
  99. .gpio = EXYNOS4_GPL1(1),
  100. .enable_high = false,
  101. .init_data = &emmc_fixed_voltage_init_data,
  102. };
  103. static struct platform_device emmc_fixed_voltage = {
  104. .name = "reg-fixed-voltage",
  105. .id = FIXED_REG_ID_MMC,
  106. .dev = {
  107. .platform_data = &emmc_fixed_voltage_config,
  108. },
  109. };
  110. /* SD */
  111. static struct s3c_sdhci_platdata nuri_hsmmc2_data __initdata = {
  112. .max_width = 4,
  113. .host_caps = MMC_CAP_4_BIT_DATA |
  114. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
  115. MMC_CAP_DISABLE,
  116. .ext_cd_gpio = EXYNOS4_GPX3(3), /* XEINT_27 */
  117. .ext_cd_gpio_invert = 1,
  118. .cd_type = S3C_SDHCI_CD_GPIO,
  119. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  120. };
  121. /* WLAN */
  122. static struct s3c_sdhci_platdata nuri_hsmmc3_data __initdata = {
  123. .max_width = 4,
  124. .host_caps = MMC_CAP_4_BIT_DATA |
  125. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  126. .cd_type = S3C_SDHCI_CD_EXTERNAL,
  127. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  128. };
  129. static void __init nuri_sdhci_init(void)
  130. {
  131. s3c_sdhci0_set_platdata(&nuri_hsmmc0_data);
  132. s3c_sdhci2_set_platdata(&nuri_hsmmc2_data);
  133. s3c_sdhci3_set_platdata(&nuri_hsmmc3_data);
  134. }
  135. /* GPIO KEYS */
  136. static struct gpio_keys_button nuri_gpio_keys_tables[] = {
  137. {
  138. .code = KEY_VOLUMEUP,
  139. .gpio = EXYNOS4_GPX2(0), /* XEINT16 */
  140. .desc = "gpio-keys: KEY_VOLUMEUP",
  141. .type = EV_KEY,
  142. .active_low = 1,
  143. .debounce_interval = 1,
  144. }, {
  145. .code = KEY_VOLUMEDOWN,
  146. .gpio = EXYNOS4_GPX2(1), /* XEINT17 */
  147. .desc = "gpio-keys: KEY_VOLUMEDOWN",
  148. .type = EV_KEY,
  149. .active_low = 1,
  150. .debounce_interval = 1,
  151. }, {
  152. .code = KEY_POWER,
  153. .gpio = EXYNOS4_GPX2(7), /* XEINT23 */
  154. .desc = "gpio-keys: KEY_POWER",
  155. .type = EV_KEY,
  156. .active_low = 1,
  157. .wakeup = 1,
  158. .debounce_interval = 1,
  159. },
  160. };
  161. static struct gpio_keys_platform_data nuri_gpio_keys_data = {
  162. .buttons = nuri_gpio_keys_tables,
  163. .nbuttons = ARRAY_SIZE(nuri_gpio_keys_tables),
  164. };
  165. static struct platform_device nuri_gpio_keys = {
  166. .name = "gpio-keys",
  167. .dev = {
  168. .platform_data = &nuri_gpio_keys_data,
  169. },
  170. };
  171. static void nuri_lcd_power_on(struct plat_lcd_data *pd, unsigned int power)
  172. {
  173. int gpio = EXYNOS4_GPE1(5);
  174. gpio_request(gpio, "LVDS_nSHDN");
  175. gpio_direction_output(gpio, power);
  176. gpio_free(gpio);
  177. }
  178. static int nuri_bl_init(struct device *dev)
  179. {
  180. int ret, gpio = EXYNOS4_GPE2(3);
  181. ret = gpio_request(gpio, "LCD_LDO_EN");
  182. if (!ret)
  183. gpio_direction_output(gpio, 0);
  184. return ret;
  185. }
  186. static int nuri_bl_notify(struct device *dev, int brightness)
  187. {
  188. if (brightness < 1)
  189. brightness = 0;
  190. gpio_set_value(EXYNOS4_GPE2(3), 1);
  191. return brightness;
  192. }
  193. static void nuri_bl_exit(struct device *dev)
  194. {
  195. gpio_free(EXYNOS4_GPE2(3));
  196. }
  197. /* nuri pwm backlight */
  198. static struct platform_pwm_backlight_data nuri_backlight_data = {
  199. .pwm_id = 0,
  200. .pwm_period_ns = 30000,
  201. .max_brightness = 100,
  202. .dft_brightness = 50,
  203. .init = nuri_bl_init,
  204. .notify = nuri_bl_notify,
  205. .exit = nuri_bl_exit,
  206. };
  207. static struct platform_device nuri_backlight_device = {
  208. .name = "pwm-backlight",
  209. .id = -1,
  210. .dev = {
  211. .parent = &s3c_device_timer[0].dev,
  212. .platform_data = &nuri_backlight_data,
  213. },
  214. };
  215. static struct plat_lcd_data nuri_lcd_platform_data = {
  216. .set_power = nuri_lcd_power_on,
  217. };
  218. static struct platform_device nuri_lcd_device = {
  219. .name = "platform-lcd",
  220. .id = -1,
  221. .dev = {
  222. .platform_data = &nuri_lcd_platform_data,
  223. },
  224. };
  225. /* I2C1 */
  226. static struct i2c_board_info i2c1_devs[] __initdata = {
  227. /* Gyro, To be updated */
  228. };
  229. /* TSP */
  230. static u8 mxt_init_vals[] = {
  231. /* MXT_GEN_COMMAND(6) */
  232. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  233. /* MXT_GEN_POWER(7) */
  234. 0x20, 0xff, 0x32,
  235. /* MXT_GEN_ACQUIRE(8) */
  236. 0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
  237. /* MXT_TOUCH_MULTI(9) */
  238. 0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
  239. 0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
  240. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  241. 0x00,
  242. /* MXT_TOUCH_KEYARRAY(15) */
  243. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
  244. 0x00,
  245. /* MXT_SPT_GPIOPWM(19) */
  246. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  247. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  248. /* MXT_PROCI_GRIPFACE(20) */
  249. 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
  250. 0x0f, 0x0a,
  251. /* MXT_PROCG_NOISE(22) */
  252. 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
  253. 0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
  254. /* MXT_TOUCH_PROXIMITY(23) */
  255. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  256. 0x00, 0x00, 0x00, 0x00, 0x00,
  257. /* MXT_PROCI_ONETOUCH(24) */
  258. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  259. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  260. /* MXT_SPT_SELFTEST(25) */
  261. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  262. 0x00, 0x00, 0x00, 0x00,
  263. /* MXT_PROCI_TWOTOUCH(27) */
  264. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  265. /* MXT_SPT_CTECONFIG(28) */
  266. 0x00, 0x00, 0x02, 0x08, 0x10, 0x00,
  267. };
  268. static struct mxt_platform_data mxt_platform_data = {
  269. .config = mxt_init_vals,
  270. .config_length = ARRAY_SIZE(mxt_init_vals),
  271. .x_line = 18,
  272. .y_line = 11,
  273. .x_size = 1024,
  274. .y_size = 600,
  275. .blen = 0x1,
  276. .threshold = 0x28,
  277. .voltage = 2800000, /* 2.8V */
  278. .orient = MXT_DIAGONAL_COUNTER,
  279. .irqflags = IRQF_TRIGGER_FALLING,
  280. };
  281. static struct s3c2410_platform_i2c i2c3_data __initdata = {
  282. .flags = 0,
  283. .bus_num = 3,
  284. .slave_addr = 0x10,
  285. .frequency = 400 * 1000,
  286. .sda_delay = 100,
  287. };
  288. static struct i2c_board_info i2c3_devs[] __initdata = {
  289. {
  290. I2C_BOARD_INFO("atmel_mxt_ts", 0x4a),
  291. .platform_data = &mxt_platform_data,
  292. .irq = IRQ_EINT(4),
  293. },
  294. };
  295. static void __init nuri_tsp_init(void)
  296. {
  297. int gpio;
  298. /* TOUCH_INT: XEINT_4 */
  299. gpio = EXYNOS4_GPX0(4);
  300. gpio_request(gpio, "TOUCH_INT");
  301. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
  302. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_UP);
  303. }
  304. /* GPIO I2C 5 (PMIC) */
  305. static struct i2c_board_info i2c5_devs[] __initdata = {
  306. /* max8997, To be updated */
  307. };
  308. /* USB EHCI */
  309. static struct s5p_ehci_platdata nuri_ehci_pdata;
  310. static void __init nuri_ehci_init(void)
  311. {
  312. struct s5p_ehci_platdata *pdata = &nuri_ehci_pdata;
  313. s5p_ehci_set_platdata(pdata);
  314. }
  315. static struct platform_device *nuri_devices[] __initdata = {
  316. /* Samsung Platform Devices */
  317. &emmc_fixed_voltage,
  318. &s3c_device_hsmmc0,
  319. &s3c_device_hsmmc2,
  320. &s3c_device_hsmmc3,
  321. &s3c_device_wdt,
  322. &s3c_device_timer[0],
  323. &s5p_device_ehci,
  324. &s3c_device_i2c3,
  325. /* NURI Devices */
  326. &nuri_gpio_keys,
  327. &nuri_lcd_device,
  328. &nuri_backlight_device,
  329. };
  330. static void __init nuri_map_io(void)
  331. {
  332. s5p_init_io(NULL, 0, S5P_VA_CHIPID);
  333. s3c24xx_init_clocks(24000000);
  334. s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs));
  335. }
  336. static void __init nuri_machine_init(void)
  337. {
  338. nuri_sdhci_init();
  339. nuri_tsp_init();
  340. i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
  341. s3c_i2c3_set_platdata(&i2c3_data);
  342. i2c_register_board_info(3, i2c3_devs, ARRAY_SIZE(i2c3_devs));
  343. i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
  344. nuri_ehci_init();
  345. clk_xusbxti.rate = 24000000;
  346. /* Last */
  347. platform_add_devices(nuri_devices, ARRAY_SIZE(nuri_devices));
  348. }
  349. MACHINE_START(NURI, "NURI")
  350. /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
  351. .boot_params = S5P_PA_SDRAM + 0x100,
  352. .init_irq = exynos4_init_irq,
  353. .map_io = nuri_map_io,
  354. .init_machine = nuri_machine_init,
  355. .timer = &exynos4_timer,
  356. MACHINE_END