1 /* linux/arch/arm/mach-s5pv210/mach-smdkv210.c
2  *
3  * Copyright (c) 2010 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 
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/i2c.h>
14 #include <linux/init.h>
15 #include <linux/serial_core.h>
16 #include <linux/sysdev.h>
17 #include <linux/dm9000.h>
18 #include <linux/fb.h>
19 #include <linux/gpio.h>
20 #include <linux/delay.h>
21 #include <linux/pwm_backlight.h>
22 
23 #include <asm/mach/arch.h>
24 #include <asm/mach/map.h>
25 #include <asm/setup.h>
26 #include <asm/mach-types.h>
27 
28 #include <video/platform_lcd.h>
29 
30 #include <mach/map.h>
31 #include <mach/regs-clock.h>
32 #include <mach/regs-fb.h>
33 
34 #include <plat/regs-serial.h>
35 #include <plat/regs-srom.h>
36 #include <plat/gpio-cfg.h>
37 #include <plat/s5pv210.h>
38 #include <plat/devs.h>
39 #include <plat/cpu.h>
40 #include <plat/adc.h>
41 #include <plat/ts.h>
42 #include <plat/ata.h>
43 #include <plat/iic.h>
44 #include <plat/keypad.h>
45 #include <plat/pm.h>
46 #include <plat/fb.h>
47 #include <plat/s5p-time.h>
48 
49 /* Following are default values for UCON, ULCON and UFCON UART registers */
50 #define SMDKV210_UCON_DEFAULT	(S3C2410_UCON_TXILEVEL |	\
51 				 S3C2410_UCON_RXILEVEL |	\
52 				 S3C2410_UCON_TXIRQMODE |	\
53 				 S3C2410_UCON_RXIRQMODE |	\
54 				 S3C2410_UCON_RXFIFO_TOI |	\
55 				 S3C2443_UCON_RXERR_IRQEN)
56 
57 #define SMDKV210_ULCON_DEFAULT	S3C2410_LCON_CS8
58 
59 #define SMDKV210_UFCON_DEFAULT	(S3C2410_UFCON_FIFOMODE |	\
60 				 S5PV210_UFCON_TXTRIG4 |	\
61 				 S5PV210_UFCON_RXTRIG4)
62 
63 static struct s3c2410_uartcfg smdkv210_uartcfgs[] __initdata = {
64 	[0] = {
65 		.hwport		= 0,
66 		.flags		= 0,
67 		.ucon		= SMDKV210_UCON_DEFAULT,
68 		.ulcon		= SMDKV210_ULCON_DEFAULT,
69 		.ufcon		= SMDKV210_UFCON_DEFAULT,
70 	},
71 	[1] = {
72 		.hwport		= 1,
73 		.flags		= 0,
74 		.ucon		= SMDKV210_UCON_DEFAULT,
75 		.ulcon		= SMDKV210_ULCON_DEFAULT,
76 		.ufcon		= SMDKV210_UFCON_DEFAULT,
77 	},
78 	[2] = {
79 		.hwport		= 2,
80 		.flags		= 0,
81 		.ucon		= SMDKV210_UCON_DEFAULT,
82 		.ulcon		= SMDKV210_ULCON_DEFAULT,
83 		.ufcon		= SMDKV210_UFCON_DEFAULT,
84 	},
85 	[3] = {
86 		.hwport		= 3,
87 		.flags		= 0,
88 		.ucon		= SMDKV210_UCON_DEFAULT,
89 		.ulcon		= SMDKV210_ULCON_DEFAULT,
90 		.ufcon		= SMDKV210_UFCON_DEFAULT,
91 	},
92 };
93 
94 static struct s3c_ide_platdata smdkv210_ide_pdata __initdata = {
95 	.setup_gpio	= s5pv210_ide_setup_gpio,
96 };
97 
98 static uint32_t smdkv210_keymap[] __initdata = {
99 	/* KEY(row, col, keycode) */
100 	KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3),
101 	KEY(0, 6, KEY_4), KEY(0, 7, KEY_5),
102 	KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C),
103 	KEY(1, 6, KEY_D), KEY(1, 7, KEY_E)
104 };
105 
106 static struct matrix_keymap_data smdkv210_keymap_data __initdata = {
107 	.keymap		= smdkv210_keymap,
108 	.keymap_size	= ARRAY_SIZE(smdkv210_keymap),
109 };
110 
111 static struct samsung_keypad_platdata smdkv210_keypad_data __initdata = {
112 	.keymap_data	= &smdkv210_keymap_data,
113 	.rows		= 8,
114 	.cols		= 8,
115 };
116 
117 static struct resource smdkv210_dm9000_resources[] = {
118 	[0] = {
119 		.start	= S5PV210_PA_SROM_BANK5,
120 		.end	= S5PV210_PA_SROM_BANK5,
121 		.flags	= IORESOURCE_MEM,
122 	},
123 	[1] = {
124 		.start	= S5PV210_PA_SROM_BANK5 + 2,
125 		.end	= S5PV210_PA_SROM_BANK5 + 2,
126 		.flags	= IORESOURCE_MEM,
127 	},
128 	[2] = {
129 		.start	= IRQ_EINT(9),
130 		.end	= IRQ_EINT(9),
131 		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
132 	},
133 };
134 
135 static struct dm9000_plat_data smdkv210_dm9000_platdata = {
136 	.flags		= DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
137 	.dev_addr	= { 0x00, 0x09, 0xc0, 0xff, 0xec, 0x48 },
138 };
139 
140 struct platform_device smdkv210_dm9000 = {
141 	.name		= "dm9000",
142 	.id		= -1,
143 	.num_resources	= ARRAY_SIZE(smdkv210_dm9000_resources),
144 	.resource	= smdkv210_dm9000_resources,
145 	.dev		= {
146 		.platform_data	= &smdkv210_dm9000_platdata,
147 	},
148 };
149 
smdkv210_lte480wv_set_power(struct plat_lcd_data * pd,unsigned int power)150 static void smdkv210_lte480wv_set_power(struct plat_lcd_data *pd,
151 					unsigned int power)
152 {
153 	if (power) {
154 #if !defined(CONFIG_BACKLIGHT_PWM)
155 		gpio_request(S5PV210_GPD0(3), "GPD0");
156 		gpio_direction_output(S5PV210_GPD0(3), 1);
157 		gpio_free(S5PV210_GPD0(3));
158 #endif
159 
160 		/* fire nRESET on power up */
161 		gpio_request(S5PV210_GPH0(6), "GPH0");
162 
163 		gpio_direction_output(S5PV210_GPH0(6), 1);
164 
165 		gpio_set_value(S5PV210_GPH0(6), 0);
166 		mdelay(10);
167 
168 		gpio_set_value(S5PV210_GPH0(6), 1);
169 		mdelay(10);
170 
171 		gpio_free(S5PV210_GPH0(6));
172 	} else {
173 #if !defined(CONFIG_BACKLIGHT_PWM)
174 		gpio_request(S5PV210_GPD0(3), "GPD0");
175 		gpio_direction_output(S5PV210_GPD0(3), 0);
176 		gpio_free(S5PV210_GPD0(3));
177 #endif
178 	}
179 }
180 
181 static struct plat_lcd_data smdkv210_lcd_lte480wv_data = {
182 	.set_power	= smdkv210_lte480wv_set_power,
183 };
184 
185 static struct platform_device smdkv210_lcd_lte480wv = {
186 	.name			= "platform-lcd",
187 	.dev.parent		= &s3c_device_fb.dev,
188 	.dev.platform_data	= &smdkv210_lcd_lte480wv_data,
189 };
190 
191 static struct s3c_fb_pd_win smdkv210_fb_win0 = {
192 	.win_mode = {
193 		.left_margin	= 13,
194 		.right_margin	= 8,
195 		.upper_margin	= 7,
196 		.lower_margin	= 5,
197 		.hsync_len	= 3,
198 		.vsync_len	= 1,
199 		.xres		= 800,
200 		.yres		= 480,
201 	},
202 	.max_bpp	= 32,
203 	.default_bpp	= 24,
204 };
205 
206 static struct s3c_fb_platdata smdkv210_lcd0_pdata __initdata = {
207 	.win[0]		= &smdkv210_fb_win0,
208 	.vidcon0	= VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
209 	.vidcon1	= VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
210 	.setup_gpio	= s5pv210_fb_gpio_setup_24bpp,
211 };
212 
smdkv210_backlight_init(struct device * dev)213 static int smdkv210_backlight_init(struct device *dev)
214 {
215 	int ret;
216 
217 	ret = gpio_request(S5PV210_GPD0(3), "Backlight");
218 	if (ret) {
219 		printk(KERN_ERR "failed to request GPD for PWM-OUT 3\n");
220 		return ret;
221 	}
222 
223 	/* Configure GPIO pin with S5PV210_GPD_0_3_TOUT_3 */
224 	s3c_gpio_cfgpin(S5PV210_GPD0(3), S3C_GPIO_SFN(2));
225 
226 	return 0;
227 }
228 
smdkv210_backlight_exit(struct device * dev)229 static void smdkv210_backlight_exit(struct device *dev)
230 {
231 	s3c_gpio_cfgpin(S5PV210_GPD0(3), S3C_GPIO_OUTPUT);
232 	gpio_free(S5PV210_GPD0(3));
233 }
234 
235 static struct platform_pwm_backlight_data smdkv210_backlight_data = {
236 	.pwm_id		= 3,
237 	.max_brightness	= 255,
238 	.dft_brightness	= 255,
239 	.pwm_period_ns	= 78770,
240 	.init		= smdkv210_backlight_init,
241 	.exit		= smdkv210_backlight_exit,
242 };
243 
244 static struct platform_device smdkv210_backlight_device = {
245 	.name		= "pwm-backlight",
246 	.dev		= {
247 		.parent		= &s3c_device_timer[3].dev,
248 		.platform_data	= &smdkv210_backlight_data,
249 	},
250 };
251 
252 static struct platform_device *smdkv210_devices[] __initdata = {
253 	&s3c_device_adc,
254 	&s3c_device_cfcon,
255 	&s3c_device_fb,
256 	&s3c_device_hsmmc0,
257 	&s3c_device_hsmmc1,
258 	&s3c_device_hsmmc2,
259 	&s3c_device_hsmmc3,
260 	&s3c_device_i2c0,
261 	&s3c_device_i2c1,
262 	&s3c_device_i2c2,
263 	&s3c_device_rtc,
264 	&s3c_device_ts,
265 	&s3c_device_wdt,
266 	&s5pv210_device_ac97,
267 	&s5pv210_device_iis0,
268 	&s5pv210_device_spdif,
269 	&samsung_asoc_dma,
270 	&samsung_device_keypad,
271 	&smdkv210_dm9000,
272 	&smdkv210_lcd_lte480wv,
273 	&s3c_device_timer[3],
274 	&smdkv210_backlight_device,
275 };
276 
smdkv210_dm9000_init(void)277 static void __init smdkv210_dm9000_init(void)
278 {
279 	unsigned int tmp;
280 
281 	gpio_request(S5PV210_MP01(5), "nCS5");
282 	s3c_gpio_cfgpin(S5PV210_MP01(5), S3C_GPIO_SFN(2));
283 	gpio_free(S5PV210_MP01(5));
284 
285 	tmp = (5 << S5P_SROM_BCX__TACC__SHIFT);
286 	__raw_writel(tmp, S5P_SROM_BC5);
287 
288 	tmp = __raw_readl(S5P_SROM_BW);
289 	tmp &= (S5P_SROM_BW__CS_MASK << S5P_SROM_BW__NCS5__SHIFT);
290 	tmp |= (1 << S5P_SROM_BW__NCS5__SHIFT);
291 	__raw_writel(tmp, S5P_SROM_BW);
292 }
293 
294 static struct i2c_board_info smdkv210_i2c_devs0[] __initdata = {
295 	{ I2C_BOARD_INFO("24c08", 0x50), },     /* Samsung S524AD0XD1 */
296 	{ I2C_BOARD_INFO("wm8580", 0x1b), },
297 };
298 
299 static struct i2c_board_info smdkv210_i2c_devs1[] __initdata = {
300 	/* To Be Updated */
301 };
302 
303 static struct i2c_board_info smdkv210_i2c_devs2[] __initdata = {
304 	/* To Be Updated */
305 };
306 
307 static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
308 	.delay			= 10000,
309 	.presc			= 49,
310 	.oversampling_shift	= 2,
311 };
312 
smdkv210_map_io(void)313 static void __init smdkv210_map_io(void)
314 {
315 	s5p_init_io(NULL, 0, S5P_VA_CHIPID);
316 	s3c24xx_init_clocks(24000000);
317 	s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs));
318 	s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
319 }
320 
smdkv210_machine_init(void)321 static void __init smdkv210_machine_init(void)
322 {
323 	s3c_pm_init();
324 
325 	smdkv210_dm9000_init();
326 
327 	samsung_keypad_set_platdata(&smdkv210_keypad_data);
328 	s3c24xx_ts_set_platdata(&s3c_ts_platform);
329 
330 	s3c_i2c0_set_platdata(NULL);
331 	s3c_i2c1_set_platdata(NULL);
332 	s3c_i2c2_set_platdata(NULL);
333 	i2c_register_board_info(0, smdkv210_i2c_devs0,
334 			ARRAY_SIZE(smdkv210_i2c_devs0));
335 	i2c_register_board_info(1, smdkv210_i2c_devs1,
336 			ARRAY_SIZE(smdkv210_i2c_devs1));
337 	i2c_register_board_info(2, smdkv210_i2c_devs2,
338 			ARRAY_SIZE(smdkv210_i2c_devs2));
339 
340 	s3c_ide_set_platdata(&smdkv210_ide_pdata);
341 
342 	s3c_fb_set_platdata(&smdkv210_lcd0_pdata);
343 
344 	platform_add_devices(smdkv210_devices, ARRAY_SIZE(smdkv210_devices));
345 }
346 
347 MACHINE_START(SMDKV210, "SMDKV210")
348 	/* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
349 	.boot_params	= S5P_PA_SDRAM + 0x100,
350 	.init_irq	= s5pv210_init_irq,
351 	.map_io		= smdkv210_map_io,
352 	.init_machine	= smdkv210_machine_init,
353 	.timer		= &s5p_timer,
354 MACHINE_END
355