mach-nuri.c 7.1 KB

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