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