mach-smdkv310.c 11 KB

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