mach-smdkv310.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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.h>
  21. #include <linux/pwm_backlight.h>
  22. #include <linux/platform_data/i2c-s3c2410.h>
  23. #include <linux/platform_data/s3c-hsotg.h>
  24. #include <linux/platform_data/usb-ehci-s5p.h>
  25. #include <linux/platform_data/usb-exynos.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach-types.h>
  28. #include <video/platform_lcd.h>
  29. #include <video/samsung_fimd.h>
  30. #include <plat/regs-serial.h>
  31. #include <plat/regs-srom.h>
  32. #include <plat/cpu.h>
  33. #include <plat/devs.h>
  34. #include <plat/fb.h>
  35. #include <plat/keypad.h>
  36. #include <plat/sdhci.h>
  37. #include <plat/gpio-cfg.h>
  38. #include <plat/backlight.h>
  39. #include <plat/mfc.h>
  40. #include <plat/clock.h>
  41. #include <plat/hdmi.h>
  42. #include <mach/map.h>
  43. #include <drm/exynos_drm.h>
  44. #include "common.h"
  45. /* Following are default values for UCON, ULCON and UFCON UART registers */
  46. #define SMDKV310_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
  47. S3C2410_UCON_RXILEVEL | \
  48. S3C2410_UCON_TXIRQMODE | \
  49. S3C2410_UCON_RXIRQMODE | \
  50. S3C2410_UCON_RXFIFO_TOI | \
  51. S3C2443_UCON_RXERR_IRQEN)
  52. #define SMDKV310_ULCON_DEFAULT S3C2410_LCON_CS8
  53. #define SMDKV310_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
  54. S5PV210_UFCON_TXTRIG4 | \
  55. S5PV210_UFCON_RXTRIG4)
  56. static struct s3c2410_uartcfg smdkv310_uartcfgs[] __initdata = {
  57. [0] = {
  58. .hwport = 0,
  59. .flags = 0,
  60. .ucon = SMDKV310_UCON_DEFAULT,
  61. .ulcon = SMDKV310_ULCON_DEFAULT,
  62. .ufcon = SMDKV310_UFCON_DEFAULT,
  63. },
  64. [1] = {
  65. .hwport = 1,
  66. .flags = 0,
  67. .ucon = SMDKV310_UCON_DEFAULT,
  68. .ulcon = SMDKV310_ULCON_DEFAULT,
  69. .ufcon = SMDKV310_UFCON_DEFAULT,
  70. },
  71. [2] = {
  72. .hwport = 2,
  73. .flags = 0,
  74. .ucon = SMDKV310_UCON_DEFAULT,
  75. .ulcon = SMDKV310_ULCON_DEFAULT,
  76. .ufcon = SMDKV310_UFCON_DEFAULT,
  77. },
  78. [3] = {
  79. .hwport = 3,
  80. .flags = 0,
  81. .ucon = SMDKV310_UCON_DEFAULT,
  82. .ulcon = SMDKV310_ULCON_DEFAULT,
  83. .ufcon = SMDKV310_UFCON_DEFAULT,
  84. },
  85. };
  86. static struct s3c_sdhci_platdata smdkv310_hsmmc0_pdata __initdata = {
  87. .cd_type = S3C_SDHCI_CD_INTERNAL,
  88. #ifdef CONFIG_EXYNOS4_SDHCI_CH0_8BIT
  89. .max_width = 8,
  90. .host_caps = MMC_CAP_8_BIT_DATA,
  91. #endif
  92. };
  93. static struct s3c_sdhci_platdata smdkv310_hsmmc1_pdata __initdata = {
  94. .cd_type = S3C_SDHCI_CD_GPIO,
  95. .ext_cd_gpio = EXYNOS4_GPK0(2),
  96. .ext_cd_gpio_invert = 1,
  97. };
  98. static struct s3c_sdhci_platdata smdkv310_hsmmc2_pdata __initdata = {
  99. .cd_type = S3C_SDHCI_CD_INTERNAL,
  100. #ifdef CONFIG_EXYNOS4_SDHCI_CH2_8BIT
  101. .max_width = 8,
  102. .host_caps = MMC_CAP_8_BIT_DATA,
  103. #endif
  104. };
  105. static struct s3c_sdhci_platdata smdkv310_hsmmc3_pdata __initdata = {
  106. .cd_type = S3C_SDHCI_CD_GPIO,
  107. .ext_cd_gpio = EXYNOS4_GPK2(2),
  108. .ext_cd_gpio_invert = 1,
  109. };
  110. static void lcd_lte480wv_set_power(struct plat_lcd_data *pd,
  111. unsigned int power)
  112. {
  113. if (power) {
  114. #if !defined(CONFIG_BACKLIGHT_PWM)
  115. gpio_request_one(EXYNOS4_GPD0(1), GPIOF_OUT_INIT_HIGH, "GPD0");
  116. gpio_free(EXYNOS4_GPD0(1));
  117. #endif
  118. /* fire nRESET on power up */
  119. gpio_request_one(EXYNOS4_GPX0(6), GPIOF_OUT_INIT_HIGH, "GPX0");
  120. mdelay(100);
  121. gpio_set_value(EXYNOS4_GPX0(6), 0);
  122. mdelay(10);
  123. gpio_set_value(EXYNOS4_GPX0(6), 1);
  124. mdelay(10);
  125. gpio_free(EXYNOS4_GPX0(6));
  126. } else {
  127. #if !defined(CONFIG_BACKLIGHT_PWM)
  128. gpio_request_one(EXYNOS4_GPD0(1), GPIOF_OUT_INIT_LOW, "GPD0");
  129. gpio_free(EXYNOS4_GPD0(1));
  130. #endif
  131. }
  132. }
  133. static struct plat_lcd_data smdkv310_lcd_lte480wv_data = {
  134. .set_power = lcd_lte480wv_set_power,
  135. };
  136. static struct platform_device smdkv310_lcd_lte480wv = {
  137. .name = "platform-lcd",
  138. .dev.parent = &s5p_device_fimd0.dev,
  139. .dev.platform_data = &smdkv310_lcd_lte480wv_data,
  140. };
  141. #ifdef CONFIG_DRM_EXYNOS_FIMD
  142. static struct exynos_drm_fimd_pdata drm_fimd_pdata = {
  143. .panel = {
  144. .timing = {
  145. .left_margin = 13,
  146. .right_margin = 8,
  147. .upper_margin = 7,
  148. .lower_margin = 5,
  149. .hsync_len = 3,
  150. .vsync_len = 1,
  151. .xres = 800,
  152. .yres = 480,
  153. },
  154. },
  155. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  156. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  157. .default_win = 0,
  158. .bpp = 32,
  159. };
  160. #else
  161. static struct s3c_fb_pd_win smdkv310_fb_win0 = {
  162. .max_bpp = 32,
  163. .default_bpp = 24,
  164. .xres = 800,
  165. .yres = 480,
  166. };
  167. static struct fb_videomode smdkv310_lcd_timing = {
  168. .left_margin = 13,
  169. .right_margin = 8,
  170. .upper_margin = 7,
  171. .lower_margin = 5,
  172. .hsync_len = 3,
  173. .vsync_len = 1,
  174. .xres = 800,
  175. .yres = 480,
  176. };
  177. static struct s3c_fb_platdata smdkv310_lcd0_pdata __initdata = {
  178. .win[0] = &smdkv310_fb_win0,
  179. .vtiming = &smdkv310_lcd_timing,
  180. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  181. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  182. .setup_gpio = exynos4_fimd0_gpio_setup_24bpp,
  183. };
  184. #endif
  185. static struct resource smdkv310_smsc911x_resources[] = {
  186. [0] = DEFINE_RES_MEM(EXYNOS4_PA_SROM_BANK(1), SZ_64K),
  187. [1] = DEFINE_RES_NAMED(IRQ_EINT(5), 1, NULL, IORESOURCE_IRQ \
  188. | IRQF_TRIGGER_LOW),
  189. };
  190. static struct smsc911x_platform_config smsc9215_config = {
  191. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  192. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  193. .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY,
  194. .phy_interface = PHY_INTERFACE_MODE_MII,
  195. .mac = {0x00, 0x80, 0x00, 0x23, 0x45, 0x67},
  196. };
  197. static struct platform_device smdkv310_smsc911x = {
  198. .name = "smsc911x",
  199. .id = -1,
  200. .num_resources = ARRAY_SIZE(smdkv310_smsc911x_resources),
  201. .resource = smdkv310_smsc911x_resources,
  202. .dev = {
  203. .platform_data = &smsc9215_config,
  204. },
  205. };
  206. static uint32_t smdkv310_keymap[] __initdata = {
  207. /* KEY(row, col, keycode) */
  208. KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3),
  209. KEY(0, 6, KEY_4), KEY(0, 7, KEY_5),
  210. KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C),
  211. KEY(1, 6, KEY_D), KEY(1, 7, KEY_E)
  212. };
  213. static struct matrix_keymap_data smdkv310_keymap_data __initdata = {
  214. .keymap = smdkv310_keymap,
  215. .keymap_size = ARRAY_SIZE(smdkv310_keymap),
  216. };
  217. static struct samsung_keypad_platdata smdkv310_keypad_data __initdata = {
  218. .keymap_data = &smdkv310_keymap_data,
  219. .rows = 2,
  220. .cols = 8,
  221. };
  222. static struct i2c_board_info i2c_devs1[] __initdata = {
  223. {I2C_BOARD_INFO("wm8994", 0x1a),},
  224. };
  225. /* USB EHCI */
  226. static struct s5p_ehci_platdata smdkv310_ehci_pdata;
  227. static void __init smdkv310_ehci_init(void)
  228. {
  229. struct s5p_ehci_platdata *pdata = &smdkv310_ehci_pdata;
  230. s5p_ehci_set_platdata(pdata);
  231. }
  232. /* USB OHCI */
  233. static struct exynos4_ohci_platdata smdkv310_ohci_pdata;
  234. static void __init smdkv310_ohci_init(void)
  235. {
  236. struct exynos4_ohci_platdata *pdata = &smdkv310_ohci_pdata;
  237. exynos4_ohci_set_platdata(pdata);
  238. }
  239. /* USB OTG */
  240. static struct s3c_hsotg_plat smdkv310_hsotg_pdata;
  241. /* Audio device */
  242. static struct platform_device smdkv310_device_audio = {
  243. .name = "smdk-audio",
  244. .id = -1,
  245. };
  246. static struct platform_device *smdkv310_devices[] __initdata = {
  247. &s3c_device_hsmmc0,
  248. &s3c_device_hsmmc1,
  249. &s3c_device_hsmmc2,
  250. &s3c_device_hsmmc3,
  251. &s3c_device_i2c1,
  252. &s5p_device_i2c_hdmiphy,
  253. &s3c_device_rtc,
  254. &s3c_device_usb_hsotg,
  255. &s3c_device_wdt,
  256. &s5p_device_ehci,
  257. &s5p_device_fimc0,
  258. &s5p_device_fimc1,
  259. &s5p_device_fimc2,
  260. &s5p_device_fimc3,
  261. &s5p_device_fimc_md,
  262. &s5p_device_g2d,
  263. &s5p_device_jpeg,
  264. &exynos4_device_ac97,
  265. &exynos4_device_i2s0,
  266. &exynos4_device_ohci,
  267. &samsung_device_keypad,
  268. &s5p_device_mfc,
  269. &s5p_device_mfc_l,
  270. &s5p_device_mfc_r,
  271. &exynos4_device_spdif,
  272. &samsung_asoc_idma,
  273. &s5p_device_fimd0,
  274. &smdkv310_device_audio,
  275. &smdkv310_lcd_lte480wv,
  276. &smdkv310_smsc911x,
  277. &exynos4_device_ahci,
  278. &s5p_device_hdmi,
  279. &s5p_device_mixer,
  280. };
  281. static void __init smdkv310_smsc911x_init(void)
  282. {
  283. u32 cs1;
  284. /* configure nCS1 width to 16 bits */
  285. cs1 = __raw_readl(S5P_SROM_BW) &
  286. ~(S5P_SROM_BW__CS_MASK << S5P_SROM_BW__NCS1__SHIFT);
  287. cs1 |= ((1 << S5P_SROM_BW__DATAWIDTH__SHIFT) |
  288. (1 << S5P_SROM_BW__WAITENABLE__SHIFT) |
  289. (1 << S5P_SROM_BW__BYTEENABLE__SHIFT)) <<
  290. S5P_SROM_BW__NCS1__SHIFT;
  291. __raw_writel(cs1, S5P_SROM_BW);
  292. /* set timing for nCS1 suitable for ethernet chip */
  293. __raw_writel((0x1 << S5P_SROM_BCX__PMC__SHIFT) |
  294. (0x9 << S5P_SROM_BCX__TACP__SHIFT) |
  295. (0xc << S5P_SROM_BCX__TCAH__SHIFT) |
  296. (0x1 << S5P_SROM_BCX__TCOH__SHIFT) |
  297. (0x6 << S5P_SROM_BCX__TACC__SHIFT) |
  298. (0x1 << S5P_SROM_BCX__TCOS__SHIFT) |
  299. (0x1 << S5P_SROM_BCX__TACS__SHIFT), S5P_SROM_BC1);
  300. }
  301. /* LCD Backlight data */
  302. static struct samsung_bl_gpio_info smdkv310_bl_gpio_info = {
  303. .no = EXYNOS4_GPD0(1),
  304. .func = S3C_GPIO_SFN(2),
  305. };
  306. static struct platform_pwm_backlight_data smdkv310_bl_data = {
  307. .pwm_id = 1,
  308. .pwm_period_ns = 1000,
  309. };
  310. /* I2C module and id for HDMIPHY */
  311. static struct i2c_board_info hdmiphy_info = {
  312. I2C_BOARD_INFO("hdmiphy-exynos4210", 0x38),
  313. };
  314. static struct pwm_lookup smdkv310_pwm_lookup[] = {
  315. PWM_LOOKUP("s3c24xx-pwm.1", 0, "pwm-backlight.0", NULL),
  316. };
  317. static void s5p_tv_setup(void)
  318. {
  319. /* direct HPD to HDMI chip */
  320. WARN_ON(gpio_request_one(EXYNOS4_GPX3(7), GPIOF_IN, "hpd-plug"));
  321. s3c_gpio_cfgpin(EXYNOS4_GPX3(7), S3C_GPIO_SFN(0x3));
  322. s3c_gpio_setpull(EXYNOS4_GPX3(7), S3C_GPIO_PULL_NONE);
  323. }
  324. static void __init smdkv310_map_io(void)
  325. {
  326. exynos_init_io(NULL, 0);
  327. s3c24xx_init_clocks(clk_xusbxti.rate);
  328. s3c24xx_init_uarts(smdkv310_uartcfgs, ARRAY_SIZE(smdkv310_uartcfgs));
  329. }
  330. static void __init smdkv310_reserve(void)
  331. {
  332. s5p_mfc_reserve_mem(0x43000000, 8 << 20, 0x51000000, 8 << 20);
  333. }
  334. static void __init smdkv310_machine_init(void)
  335. {
  336. s3c_i2c1_set_platdata(NULL);
  337. i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
  338. smdkv310_smsc911x_init();
  339. s3c_sdhci0_set_platdata(&smdkv310_hsmmc0_pdata);
  340. s3c_sdhci1_set_platdata(&smdkv310_hsmmc1_pdata);
  341. s3c_sdhci2_set_platdata(&smdkv310_hsmmc2_pdata);
  342. s3c_sdhci3_set_platdata(&smdkv310_hsmmc3_pdata);
  343. s5p_tv_setup();
  344. s5p_i2c_hdmiphy_set_platdata(NULL);
  345. s5p_hdmi_set_platdata(&hdmiphy_info, NULL, 0);
  346. samsung_keypad_set_platdata(&smdkv310_keypad_data);
  347. samsung_bl_set(&smdkv310_bl_gpio_info, &smdkv310_bl_data);
  348. pwm_add_table(smdkv310_pwm_lookup, ARRAY_SIZE(smdkv310_pwm_lookup));
  349. #ifdef CONFIG_DRM_EXYNOS_FIMD
  350. s5p_device_fimd0.dev.platform_data = &drm_fimd_pdata;
  351. exynos4_fimd0_gpio_setup_24bpp();
  352. #else
  353. s5p_fimd0_set_platdata(&smdkv310_lcd0_pdata);
  354. #endif
  355. smdkv310_ehci_init();
  356. smdkv310_ohci_init();
  357. s3c_hsotg_set_platdata(&smdkv310_hsotg_pdata);
  358. platform_add_devices(smdkv310_devices, ARRAY_SIZE(smdkv310_devices));
  359. }
  360. MACHINE_START(SMDKV310, "SMDKV310")
  361. /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
  362. /* Maintainer: Changhwan Youn <chaos.youn@samsung.com> */
  363. .atag_offset = 0x100,
  364. .smp = smp_ops(exynos_smp_ops),
  365. .init_irq = exynos4_init_irq,
  366. .map_io = smdkv310_map_io,
  367. .init_machine = smdkv310_machine_init,
  368. .init_time = exynos4_timer_init,
  369. .reserve = &smdkv310_reserve,
  370. .restart = exynos4_restart,
  371. MACHINE_END
  372. MACHINE_START(SMDKC210, "SMDKC210")
  373. /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
  374. .atag_offset = 0x100,
  375. .smp = smp_ops(exynos_smp_ops),
  376. .init_irq = exynos4_init_irq,
  377. .map_io = smdkv310_map_io,
  378. .init_machine = smdkv310_machine_init,
  379. .init_late = exynos_init_late,
  380. .init_time = exynos4_timer_init,
  381. .reserve = &smdkv310_reserve,
  382. .restart = exynos4_restart,
  383. MACHINE_END