mach-smdkv310.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /* linux/arch/arm/mach-exynos4/mach-smdkv310.c
  2. *
  3. * Copyright (c) 2010-2011 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/serial_core.h>
  11. #include <linux/delay.h>
  12. #include <linux/gpio.h>
  13. #include <linux/lcd.h>
  14. #include <linux/mmc/host.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/smsc911x.h>
  17. #include <linux/io.h>
  18. #include <linux/i2c.h>
  19. #include <linux/input.h>
  20. #include <linux/pwm_backlight.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach-types.h>
  23. #include <video/platform_lcd.h>
  24. #include <plat/regs-serial.h>
  25. #include <plat/regs-srom.h>
  26. #include <plat/regs-fb-v4.h>
  27. #include <plat/exynos4.h>
  28. #include <plat/cpu.h>
  29. #include <plat/devs.h>
  30. #include <plat/fb.h>
  31. #include <plat/keypad.h>
  32. #include <plat/sdhci.h>
  33. #include <plat/iic.h>
  34. #include <plat/pd.h>
  35. #include <plat/gpio-cfg.h>
  36. #include <plat/backlight.h>
  37. #include <mach/map.h>
  38. /* Following are default values for UCON, ULCON and UFCON UART registers */
  39. #define SMDKV310_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
  40. S3C2410_UCON_RXILEVEL | \
  41. S3C2410_UCON_TXIRQMODE | \
  42. S3C2410_UCON_RXIRQMODE | \
  43. S3C2410_UCON_RXFIFO_TOI | \
  44. S3C2443_UCON_RXERR_IRQEN)
  45. #define SMDKV310_ULCON_DEFAULT S3C2410_LCON_CS8
  46. #define SMDKV310_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
  47. S5PV210_UFCON_TXTRIG4 | \
  48. S5PV210_UFCON_RXTRIG4)
  49. static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = {
  50. [0] = {
  51. .hwport = 0,
  52. .flags = 0,
  53. .ucon = SMDKV310_UCON_DEFAULT,
  54. .ulcon = SMDKV310_ULCON_DEFAULT,
  55. .ufcon = SMDKV310_UFCON_DEFAULT,
  56. },
  57. [1] = {
  58. .hwport = 1,
  59. .flags = 0,
  60. .ucon = SMDKV310_UCON_DEFAULT,
  61. .ulcon = SMDKV310_ULCON_DEFAULT,
  62. .ufcon = SMDKV310_UFCON_DEFAULT,
  63. },
  64. [2] = {
  65. .hwport = 2,
  66. .flags = 0,
  67. .ucon = SMDKV310_UCON_DEFAULT,
  68. .ulcon = SMDKV310_ULCON_DEFAULT,
  69. .ufcon = SMDKV310_UFCON_DEFAULT,
  70. },
  71. [3] = {
  72. .hwport = 3,
  73. .flags = 0,
  74. .ucon = SMDKV310_UCON_DEFAULT,
  75. .ulcon = SMDKV310_ULCON_DEFAULT,
  76. .ufcon = SMDKV310_UFCON_DEFAULT,
  77. },
  78. };
  79. static struct s3c_sdhci_platdata smdkv310_hsmmc0_pdata __initdata = {
  80. .cd_type = S3C_SDHCI_CD_INTERNAL,
  81. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  82. #ifdef CONFIG_EXYNOS4_SDHCI_CH0_8BIT
  83. .max_width = 8,
  84. .host_caps = MMC_CAP_8_BIT_DATA,
  85. #endif
  86. };
  87. static struct s3c_sdhci_platdata smdkv310_hsmmc1_pdata __initdata = {
  88. .cd_type = S3C_SDHCI_CD_GPIO,
  89. .ext_cd_gpio = EXYNOS4_GPK0(2),
  90. .ext_cd_gpio_invert = 1,
  91. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  92. };
  93. static struct s3c_sdhci_platdata smdkv310_hsmmc2_pdata __initdata = {
  94. .cd_type = S3C_SDHCI_CD_INTERNAL,
  95. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  96. #ifdef CONFIG_EXYNOS4_SDHCI_CH2_8BIT
  97. .max_width = 8,
  98. .host_caps = MMC_CAP_8_BIT_DATA,
  99. #endif
  100. };
  101. static struct s3c_sdhci_platdata smdkv310_hsmmc3_pdata __initdata = {
  102. .cd_type = S3C_SDHCI_CD_GPIO,
  103. .ext_cd_gpio = EXYNOS4_GPK2(2),
  104. .ext_cd_gpio_invert = 1,
  105. .clk_type = S3C_SDHCI_CLK_DIV_EXTERNAL,
  106. };
  107. static void lcd_lte480wv_set_power(struct plat_lcd_data *pd,
  108. unsigned int power)
  109. {
  110. if (power) {
  111. #if !defined(CONFIG_BACKLIGHT_PWM)
  112. gpio_request_one(EXYNOS4_GPD0(1), GPIOF_OUT_INIT_HIGH, "GPD0");
  113. gpio_free(EXYNOS4_GPD0(1));
  114. #endif
  115. /* fire nRESET on power up */
  116. gpio_request(EXYNOS4_GPX0(6), "GPX0");
  117. gpio_direction_output(EXYNOS4_GPX0(6), 1);
  118. mdelay(100);
  119. gpio_set_value(EXYNOS4_GPX0(6), 0);
  120. mdelay(10);
  121. gpio_set_value(EXYNOS4_GPX0(6), 1);
  122. mdelay(10);
  123. gpio_free(EXYNOS4_GPX0(6));
  124. } else {
  125. #if !defined(CONFIG_BACKLIGHT_PWM)
  126. gpio_request_one(EXYNOS4_GPD0(1), GPIOF_OUT_INIT_LOW, "GPD0");
  127. gpio_free(EXYNOS4_GPD0(1));
  128. #endif
  129. }
  130. }
  131. static struct plat_lcd_data smdkv310_lcd_lte480wv_data = {
  132. .set_power = lcd_lte480wv_set_power,
  133. };
  134. static struct platform_device smdkv310_lcd_lte480wv = {
  135. .name = "platform-lcd",
  136. .dev.parent = &s5p_device_fimd0.dev,
  137. .dev.platform_data = &smdkv310_lcd_lte480wv_data,
  138. };
  139. static struct s3c_fb_pd_win smdkv310_fb_win0 = {
  140. .win_mode = {
  141. .left_margin = 13,
  142. .right_margin = 8,
  143. .upper_margin = 7,
  144. .lower_margin = 5,
  145. .hsync_len = 3,
  146. .vsync_len = 1,
  147. .xres = 800,
  148. .yres = 480,
  149. },
  150. .max_bpp = 32,
  151. .default_bpp = 24,
  152. };
  153. static struct s3c_fb_platdata smdkv310_lcd0_pdata __initdata = {
  154. .win[0] = &smdkv310_fb_win0,
  155. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  156. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  157. .setup_gpio = exynos4_fimd0_gpio_setup_24bpp,
  158. };
  159. static struct resource smdkv310_smsc911x_resources[] = {
  160. [0] = {
  161. .start = EXYNOS4_PA_SROM_BANK(1),
  162. .end = EXYNOS4_PA_SROM_BANK(1) + SZ_64K - 1,
  163. .flags = IORESOURCE_MEM,
  164. },
  165. [1] = {
  166. .start = IRQ_EINT(5),
  167. .end = IRQ_EINT(5),
  168. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
  169. },
  170. };
  171. static struct smsc911x_platform_config smsc9215_config = {
  172. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  173. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  174. .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
  175. .phy_interface = PHY_INTERFACE_MODE_MII,
  176. .mac = {0x00, 0x80, 0x00, 0x23, 0x45, 0x67},
  177. };
  178. static struct platform_device smdkv310_smsc911x = {
  179. .name = "smsc911x",
  180. .id = -1,
  181. .num_resources = ARRAY_SIZE(smdkv310_smsc911x_resources),
  182. .resource = smdkv310_smsc911x_resources,
  183. .dev = {
  184. .platform_data = &smsc9215_config,
  185. },
  186. };
  187. static uint32_t smdkv310_keymap[] __initdata = {
  188. /* KEY(row, col, keycode) */
  189. KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3),
  190. KEY(0, 6, KEY_4), KEY(0, 7, KEY_5),
  191. KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C),
  192. KEY(1, 6, KEY_D), KEY(1, 7, KEY_E)
  193. };
  194. static struct matrix_keymap_data smdkv310_keymap_data __initdata = {
  195. .keymap = smdkv310_keymap,
  196. .keymap_size = ARRAY_SIZE(smdkv310_keymap),
  197. };
  198. static struct samsung_keypad_platdata smdkv310_keypad_data __initdata = {
  199. .keymap_data = &smdkv310_keymap_data,
  200. .rows = 2,
  201. .cols = 8,
  202. };
  203. static struct i2c_board_info i2c_devs1[] __initdata = {
  204. {I2C_BOARD_INFO("wm8994", 0x1a),},
  205. };
  206. static struct platform_device *smdkv310_devices[] __initdata = {
  207. &s3c_device_hsmmc0,
  208. &s3c_device_hsmmc1,
  209. &s3c_device_hsmmc2,
  210. &s3c_device_hsmmc3,
  211. &s3c_device_i2c1,
  212. &s3c_device_rtc,
  213. &s3c_device_wdt,
  214. &exynos4_device_ac97,
  215. &exynos4_device_i2s0,
  216. &samsung_device_keypad,
  217. &exynos4_device_pd[PD_MFC],
  218. &exynos4_device_pd[PD_G3D],
  219. &exynos4_device_pd[PD_LCD0],
  220. &exynos4_device_pd[PD_LCD1],
  221. &exynos4_device_pd[PD_CAM],
  222. &exynos4_device_pd[PD_TV],
  223. &exynos4_device_pd[PD_GPS],
  224. &exynos4_device_spdif,
  225. &exynos4_device_sysmmu,
  226. &samsung_asoc_dma,
  227. &samsung_asoc_idma,
  228. &s5p_device_fimd0,
  229. &smdkv310_lcd_lte480wv,
  230. &smdkv310_smsc911x,
  231. &exynos4_device_ahci,
  232. };
  233. static void __init smdkv310_smsc911x_init(void)
  234. {
  235. u32 cs1;
  236. /* configure nCS1 width to 16 bits */
  237. cs1 = __raw_readl(S5P_SROM_BW) &
  238. ~(S5P_SROM_BW__CS_MASK << S5P_SROM_BW__NCS1__SHIFT);
  239. cs1 |= ((1 << S5P_SROM_BW__DATAWIDTH__SHIFT) |
  240. (1 << S5P_SROM_BW__WAITENABLE__SHIFT) |
  241. (1 << S5P_SROM_BW__BYTEENABLE__SHIFT)) <<
  242. S5P_SROM_BW__NCS1__SHIFT;
  243. __raw_writel(cs1, S5P_SROM_BW);
  244. /* set timing for nCS1 suitable for ethernet chip */
  245. __raw_writel((0x1 << S5P_SROM_BCX__PMC__SHIFT) |
  246. (0x9 << S5P_SROM_BCX__TACP__SHIFT) |
  247. (0xc << S5P_SROM_BCX__TCAH__SHIFT) |
  248. (0x1 << S5P_SROM_BCX__TCOH__SHIFT) |
  249. (0x6 << S5P_SROM_BCX__TACC__SHIFT) |
  250. (0x1 << S5P_SROM_BCX__TCOS__SHIFT) |
  251. (0x1 << S5P_SROM_BCX__TACS__SHIFT), S5P_SROM_BC1);
  252. }
  253. /* LCD Backlight data */
  254. static struct samsung_bl_gpio_info smdkv310_bl_gpio_info = {
  255. .no = EXYNOS4_GPD0(1),
  256. .func = S3C_GPIO_SFN(2),
  257. };
  258. static struct platform_pwm_backlight_data smdkv310_bl_data = {
  259. .pwm_id = 1,
  260. .pwm_period_ns = 1000,
  261. };
  262. static void __init smdkv310_map_io(void)
  263. {
  264. s5p_init_io(NULL, 0, S5P_VA_CHIPID);
  265. s3c24xx_init_clocks(24000000);
  266. s3c24xx_init_uarts(smdkv310_uartcfgs, ARRAY_SIZE(smdkv310_uartcfgs));
  267. }
  268. static void __init smdkv310_machine_init(void)
  269. {
  270. s3c_i2c1_set_platdata(NULL);
  271. i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
  272. smdkv310_smsc911x_init();
  273. s3c_sdhci0_set_platdata(&smdkv310_hsmmc0_pdata);
  274. s3c_sdhci1_set_platdata(&smdkv310_hsmmc1_pdata);
  275. s3c_sdhci2_set_platdata(&smdkv310_hsmmc2_pdata);
  276. s3c_sdhci3_set_platdata(&smdkv310_hsmmc3_pdata);
  277. samsung_keypad_set_platdata(&smdkv310_keypad_data);
  278. samsung_bl_set(&smdkv310_bl_gpio_info, &smdkv310_bl_data);
  279. s5p_fimd0_set_platdata(&smdkv310_lcd0_pdata);
  280. platform_add_devices(smdkv310_devices, ARRAY_SIZE(smdkv310_devices));
  281. }
  282. MACHINE_START(SMDKV310, "SMDKV310")
  283. /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
  284. /* Maintainer: Changhwan Youn <chaos.youn@samsung.com> */
  285. .atag_offset = 0x100,
  286. .init_irq = exynos4_init_irq,
  287. .map_io = smdkv310_map_io,
  288. .init_machine = smdkv310_machine_init,
  289. .timer = &exynos4_timer,
  290. MACHINE_END
  291. MACHINE_START(SMDKC210, "SMDKC210")
  292. /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
  293. .atag_offset = 0x100,
  294. .init_irq = exynos4_init_irq,
  295. .map_io = smdkv310_map_io,
  296. .init_machine = smdkv310_machine_init,
  297. .timer = &exynos4_timer,
  298. MACHINE_END