mach-nuri.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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/gpio_keys.h>
  15. #include <linux/gpio.h>
  16. #include <linux/regulator/machine.h>
  17. #include <linux/regulator/fixed.h>
  18. #include <linux/mmc/host.h>
  19. #include <linux/fb.h>
  20. #include <linux/pwm_backlight.h>
  21. #include <video/platform_lcd.h>
  22. #include <asm/mach/arch.h>
  23. #include <asm/mach-types.h>
  24. #include <plat/regs-serial.h>
  25. #include <plat/exynos4.h>
  26. #include <plat/cpu.h>
  27. #include <plat/devs.h>
  28. #include <plat/sdhci.h>
  29. #include <plat/ehci.h>
  30. #include <plat/clock.h>
  31. #include <mach/map.h>
  32. /* Following are default values for UCON, ULCON and UFCON UART registers */
  33. #define NURI_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
  34. S3C2410_UCON_RXILEVEL | \
  35. S3C2410_UCON_TXIRQMODE | \
  36. S3C2410_UCON_RXIRQMODE | \
  37. S3C2410_UCON_RXFIFO_TOI | \
  38. S3C2443_UCON_RXERR_IRQEN)
  39. #define NURI_ULCON_DEFAULT S3C2410_LCON_CS8
  40. #define NURI_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
  41. S5PV210_UFCON_TXTRIG256 | \
  42. S5PV210_UFCON_RXTRIG256)
  43. enum fixed_regulator_id {
  44. FIXED_REG_ID_MMC = 0,
  45. };
  46. static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {
  47. {
  48. .hwport = 0,
  49. .ucon = NURI_UCON_DEFAULT,
  50. .ulcon = NURI_ULCON_DEFAULT,
  51. .ufcon = NURI_UFCON_DEFAULT,
  52. },
  53. {
  54. .hwport = 1,
  55. .ucon = NURI_UCON_DEFAULT,
  56. .ulcon = NURI_ULCON_DEFAULT,
  57. .ufcon = NURI_UFCON_DEFAULT,
  58. },
  59. {
  60. .hwport = 2,
  61. .ucon = NURI_UCON_DEFAULT,
  62. .ulcon = NURI_ULCON_DEFAULT,
  63. .ufcon = NURI_UFCON_DEFAULT,
  64. },
  65. {
  66. .hwport = 3,
  67. .ucon = NURI_UCON_DEFAULT,
  68. .ulcon = NURI_ULCON_DEFAULT,
  69. .ufcon = NURI_UFCON_DEFAULT,
  70. },
  71. };
  72. /* eMMC */
  73. static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = {
  74. .max_width = 8,
  75. .host_caps = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
  76. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
  77. MMC_CAP_DISABLE | MMC_CAP_ERASE),
  78. .cd_type = S3C_SDHCI_CD_PERMANENT,
  79. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  80. };
  81. static struct regulator_consumer_supply emmc_supplies[] = {
  82. REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"),
  83. REGULATOR_SUPPLY("vmmc", "dw_mmc"),
  84. };
  85. static struct regulator_init_data emmc_fixed_voltage_init_data = {
  86. .constraints = {
  87. .name = "VMEM_VDD_2.8V",
  88. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  89. },
  90. .num_consumer_supplies = ARRAY_SIZE(emmc_supplies),
  91. .consumer_supplies = emmc_supplies,
  92. };
  93. static struct fixed_voltage_config emmc_fixed_voltage_config = {
  94. .supply_name = "MASSMEMORY_EN (inverted)",
  95. .microvolts = 2800000,
  96. .gpio = EXYNOS4_GPL1(1),
  97. .enable_high = false,
  98. .init_data = &emmc_fixed_voltage_init_data,
  99. };
  100. static struct platform_device emmc_fixed_voltage = {
  101. .name = "reg-fixed-voltage",
  102. .id = FIXED_REG_ID_MMC,
  103. .dev = {
  104. .platform_data = &emmc_fixed_voltage_config,
  105. },
  106. };
  107. /* SD */
  108. static struct s3c_sdhci_platdata nuri_hsmmc2_data __initdata = {
  109. .max_width = 4,
  110. .host_caps = MMC_CAP_4_BIT_DATA |
  111. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
  112. MMC_CAP_DISABLE,
  113. .ext_cd_gpio = EXYNOS4_GPX3(3), /* XEINT_27 */
  114. .ext_cd_gpio_invert = 1,
  115. .cd_type = S3C_SDHCI_CD_GPIO,
  116. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  117. };
  118. /* WLAN */
  119. static struct s3c_sdhci_platdata nuri_hsmmc3_data __initdata = {
  120. .max_width = 4,
  121. .host_caps = MMC_CAP_4_BIT_DATA |
  122. MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
  123. .cd_type = S3C_SDHCI_CD_EXTERNAL,
  124. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  125. };
  126. static void __init nuri_sdhci_init(void)
  127. {
  128. s3c_sdhci0_set_platdata(&nuri_hsmmc0_data);
  129. s3c_sdhci2_set_platdata(&nuri_hsmmc2_data);
  130. s3c_sdhci3_set_platdata(&nuri_hsmmc3_data);
  131. }
  132. /* GPIO KEYS */
  133. static struct gpio_keys_button nuri_gpio_keys_tables[] = {
  134. {
  135. .code = KEY_VOLUMEUP,
  136. .gpio = EXYNOS4_GPX2(0), /* XEINT16 */
  137. .desc = "gpio-keys: KEY_VOLUMEUP",
  138. .type = EV_KEY,
  139. .active_low = 1,
  140. .debounce_interval = 1,
  141. }, {
  142. .code = KEY_VOLUMEDOWN,
  143. .gpio = EXYNOS4_GPX2(1), /* XEINT17 */
  144. .desc = "gpio-keys: KEY_VOLUMEDOWN",
  145. .type = EV_KEY,
  146. .active_low = 1,
  147. .debounce_interval = 1,
  148. }, {
  149. .code = KEY_POWER,
  150. .gpio = EXYNOS4_GPX2(7), /* XEINT23 */
  151. .desc = "gpio-keys: KEY_POWER",
  152. .type = EV_KEY,
  153. .active_low = 1,
  154. .wakeup = 1,
  155. .debounce_interval = 1,
  156. },
  157. };
  158. static struct gpio_keys_platform_data nuri_gpio_keys_data = {
  159. .buttons = nuri_gpio_keys_tables,
  160. .nbuttons = ARRAY_SIZE(nuri_gpio_keys_tables),
  161. };
  162. static struct platform_device nuri_gpio_keys = {
  163. .name = "gpio-keys",
  164. .dev = {
  165. .platform_data = &nuri_gpio_keys_data,
  166. },
  167. };
  168. static void nuri_lcd_power_on(struct plat_lcd_data *pd, unsigned int power)
  169. {
  170. int gpio = EXYNOS4_GPE1(5);
  171. gpio_request(gpio, "LVDS_nSHDN");
  172. gpio_direction_output(gpio, power);
  173. gpio_free(gpio);
  174. }
  175. static int nuri_bl_init(struct device *dev)
  176. {
  177. int ret, gpio = EXYNOS4_GPE2(3);
  178. ret = gpio_request(gpio, "LCD_LDO_EN");
  179. if (!ret)
  180. gpio_direction_output(gpio, 0);
  181. return ret;
  182. }
  183. static int nuri_bl_notify(struct device *dev, int brightness)
  184. {
  185. if (brightness < 1)
  186. brightness = 0;
  187. gpio_set_value(EXYNOS4_GPE2(3), 1);
  188. return brightness;
  189. }
  190. static void nuri_bl_exit(struct device *dev)
  191. {
  192. gpio_free(EXYNOS4_GPE2(3));
  193. }
  194. /* nuri pwm backlight */
  195. static struct platform_pwm_backlight_data nuri_backlight_data = {
  196. .pwm_id = 0,
  197. .pwm_period_ns = 30000,
  198. .max_brightness = 100,
  199. .dft_brightness = 50,
  200. .init = nuri_bl_init,
  201. .notify = nuri_bl_notify,
  202. .exit = nuri_bl_exit,
  203. };
  204. static struct platform_device nuri_backlight_device = {
  205. .name = "pwm-backlight",
  206. .id = -1,
  207. .dev = {
  208. .parent = &s3c_device_timer[0].dev,
  209. .platform_data = &nuri_backlight_data,
  210. },
  211. };
  212. static struct plat_lcd_data nuri_lcd_platform_data = {
  213. .set_power = nuri_lcd_power_on,
  214. };
  215. static struct platform_device nuri_lcd_device = {
  216. .name = "platform-lcd",
  217. .id = -1,
  218. .dev = {
  219. .platform_data = &nuri_lcd_platform_data,
  220. },
  221. };
  222. /* I2C1 */
  223. static struct i2c_board_info i2c1_devs[] __initdata = {
  224. /* Gyro, To be updated */
  225. };
  226. /* GPIO I2C 5 (PMIC) */
  227. static struct i2c_board_info i2c5_devs[] __initdata = {
  228. /* max8997, To be updated */
  229. };
  230. /* USB EHCI */
  231. static struct s5p_ehci_platdata nuri_ehci_pdata;
  232. static void __init nuri_ehci_init(void)
  233. {
  234. struct s5p_ehci_platdata *pdata = &nuri_ehci_pdata;
  235. s5p_ehci_set_platdata(pdata);
  236. }
  237. static struct platform_device *nuri_devices[] __initdata = {
  238. /* Samsung Platform Devices */
  239. &emmc_fixed_voltage,
  240. &s3c_device_hsmmc0,
  241. &s3c_device_hsmmc2,
  242. &s3c_device_hsmmc3,
  243. &s3c_device_wdt,
  244. &s3c_device_timer[0],
  245. &s5p_device_ehci,
  246. /* NURI Devices */
  247. &nuri_gpio_keys,
  248. &nuri_lcd_device,
  249. &nuri_backlight_device,
  250. };
  251. static void __init nuri_map_io(void)
  252. {
  253. s5p_init_io(NULL, 0, S5P_VA_CHIPID);
  254. s3c24xx_init_clocks(24000000);
  255. s3c24xx_init_uarts(nuri_uartcfgs, ARRAY_SIZE(nuri_uartcfgs));
  256. }
  257. static void __init nuri_machine_init(void)
  258. {
  259. nuri_sdhci_init();
  260. i2c_register_board_info(1, i2c1_devs, ARRAY_SIZE(i2c1_devs));
  261. i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
  262. nuri_ehci_init();
  263. clk_xusbxti.rate = 24000000;
  264. /* Last */
  265. platform_add_devices(nuri_devices, ARRAY_SIZE(nuri_devices));
  266. }
  267. MACHINE_START(NURI, "NURI")
  268. /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
  269. .boot_params = S5P_PA_SDRAM + 0x100,
  270. .init_irq = exynos4_init_irq,
  271. .map_io = nuri_map_io,
  272. .init_machine = nuri_machine_init,
  273. .timer = &exynos4_timer,
  274. MACHINE_END