ARM: S5PC100: Add RTC support for S5PC100
[linux-3.10.git] / arch / arm / mach-s5pc100 / mach-smdkc100.c
1 /* linux/arch/arm/mach-s5pc100/mach-smdkc100.c
2  *
3  * Copyright 2009 Samsung Electronics Co.
4  * Author: Byungho Min <bhmin@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
12 #include <linux/kernel.h>
13 #include <linux/types.h>
14 #include <linux/interrupt.h>
15 #include <linux/list.h>
16 #include <linux/timer.h>
17 #include <linux/init.h>
18 #include <linux/serial_core.h>
19 #include <linux/platform_device.h>
20 #include <linux/io.h>
21 #include <linux/gpio.h>
22 #include <linux/i2c.h>
23 #include <linux/fb.h>
24 #include <linux/delay.h>
25 #include <linux/input.h>
26
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29
30 #include <mach/map.h>
31 #include <mach/regs-fb.h>
32 #include <video/platform_lcd.h>
33
34 #include <asm/irq.h>
35 #include <asm/mach-types.h>
36
37 #include <plat/regs-serial.h>
38 #include <plat/gpio-cfg.h>
39
40 #include <plat/clock.h>
41 #include <plat/devs.h>
42 #include <plat/cpu.h>
43 #include <plat/s5pc100.h>
44 #include <plat/fb.h>
45 #include <plat/iic.h>
46 #include <plat/ata.h>
47 #include <plat/adc.h>
48 #include <plat/keypad.h>
49 #include <plat/ts.h>
50
51 /* Following are default values for UCON, ULCON and UFCON UART registers */
52 #define S5PC100_UCON_DEFAULT    (S3C2410_UCON_TXILEVEL |        \
53                                  S3C2410_UCON_RXILEVEL |        \
54                                  S3C2410_UCON_TXIRQMODE |       \
55                                  S3C2410_UCON_RXIRQMODE |       \
56                                  S3C2410_UCON_RXFIFO_TOI |      \
57                                  S3C2443_UCON_RXERR_IRQEN)
58
59 #define S5PC100_ULCON_DEFAULT   S3C2410_LCON_CS8
60
61 #define S5PC100_UFCON_DEFAULT   (S3C2410_UFCON_FIFOMODE |       \
62                                  S3C2440_UFCON_RXTRIG8 |        \
63                                  S3C2440_UFCON_TXTRIG16)
64
65 static struct s3c2410_uartcfg smdkc100_uartcfgs[] __initdata = {
66         [0] = {
67                 .hwport      = 0,
68                 .flags       = 0,
69                 .ucon        = S5PC100_UCON_DEFAULT,
70                 .ulcon       = S5PC100_ULCON_DEFAULT,
71                 .ufcon       = S5PC100_UFCON_DEFAULT,
72         },
73         [1] = {
74                 .hwport      = 1,
75                 .flags       = 0,
76                 .ucon        = S5PC100_UCON_DEFAULT,
77                 .ulcon       = S5PC100_ULCON_DEFAULT,
78                 .ufcon       = S5PC100_UFCON_DEFAULT,
79         },
80         [2] = {
81                 .hwport      = 2,
82                 .flags       = 0,
83                 .ucon        = S5PC100_UCON_DEFAULT,
84                 .ulcon       = S5PC100_ULCON_DEFAULT,
85                 .ufcon       = S5PC100_UFCON_DEFAULT,
86         },
87         [3] = {
88                 .hwport      = 3,
89                 .flags       = 0,
90                 .ucon        = S5PC100_UCON_DEFAULT,
91                 .ulcon       = S5PC100_ULCON_DEFAULT,
92                 .ufcon       = S5PC100_UFCON_DEFAULT,
93         },
94 };
95
96 /* I2C0 */
97 static struct i2c_board_info i2c_devs0[] __initdata = {
98 };
99
100 /* I2C1 */
101 static struct i2c_board_info i2c_devs1[] __initdata = {
102 };
103
104 /* LCD power controller */
105 static void smdkc100_lcd_power_set(struct plat_lcd_data *pd,
106                                    unsigned int power)
107 {
108         /* backlight */
109         gpio_direction_output(S5PC100_GPD(0), power);
110
111         if (power) {
112                 /* module reset */
113                 gpio_direction_output(S5PC100_GPH0(6), 1);
114                 mdelay(100);
115                 gpio_direction_output(S5PC100_GPH0(6), 0);
116                 mdelay(10);
117                 gpio_direction_output(S5PC100_GPH0(6), 1);
118                 mdelay(10);
119         }
120 }
121
122 static struct plat_lcd_data smdkc100_lcd_power_data = {
123         .set_power      = smdkc100_lcd_power_set,
124 };
125
126 static struct platform_device smdkc100_lcd_powerdev = {
127         .name                   = "platform-lcd",
128         .dev.parent             = &s3c_device_fb.dev,
129         .dev.platform_data      = &smdkc100_lcd_power_data,
130 };
131
132 /* Frame Buffer */
133 static struct s3c_fb_pd_win smdkc100_fb_win0 = {
134         /* this is to ensure we use win0 */
135         .win_mode       = {
136                 .pixclock = 1000000000000ULL / ((8+13+3+800)*(7+5+1+480)*80),
137                 .left_margin    = 8,
138                 .right_margin   = 13,
139                 .upper_margin   = 7,
140                 .lower_margin   = 5,
141                 .hsync_len      = 3,
142                 .vsync_len      = 1,
143                 .xres           = 800,
144                 .yres           = 480,
145         },
146         .max_bpp        = 32,
147         .default_bpp    = 16,
148 };
149
150 static struct s3c_fb_platdata smdkc100_lcd_pdata __initdata = {
151         .win[0]         = &smdkc100_fb_win0,
152         .vidcon0        = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
153         .vidcon1        = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
154         .setup_gpio     = s5pc100_fb_gpio_setup_24bpp,
155 };
156
157 static struct s3c_ide_platdata smdkc100_ide_pdata __initdata = {
158         .setup_gpio     = s5pc100_ide_setup_gpio,
159 };
160
161 static uint32_t smdkc100_keymap[] __initdata = {
162         /* KEY(row, col, keycode) */
163         KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3),
164         KEY(0, 6, KEY_4), KEY(0, 7, KEY_5),
165         KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C),
166         KEY(1, 6, KEY_D), KEY(1, 7, KEY_E)
167 };
168
169 static struct matrix_keymap_data smdkc100_keymap_data __initdata = {
170         .keymap         = smdkc100_keymap,
171         .keymap_size    = ARRAY_SIZE(smdkc100_keymap),
172 };
173
174 static struct samsung_keypad_platdata smdkc100_keypad_data __initdata = {
175         .keymap_data    = &smdkc100_keymap_data,
176         .rows           = 2,
177         .cols           = 8,
178 };
179
180 static struct platform_device *smdkc100_devices[] __initdata = {
181         &s3c_device_adc,
182         &s3c_device_cfcon,
183         &s3c_device_i2c0,
184         &s3c_device_i2c1,
185         &s3c_device_fb,
186         &s3c_device_hsmmc0,
187         &s3c_device_hsmmc1,
188         &s3c_device_hsmmc2,
189         &s3c_device_ts,
190         &s3c_device_wdt,
191         &smdkc100_lcd_powerdev,
192         &s5pc100_device_iis0,
193         &samsung_device_keypad,
194         &s5pc100_device_ac97,
195         &s3c_device_rtc,
196 };
197
198 static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
199         .delay                  = 10000,
200         .presc                  = 49,
201         .oversampling_shift     = 2,
202 };
203
204 static void __init smdkc100_map_io(void)
205 {
206         s5p_init_io(NULL, 0, S5P_VA_CHIPID);
207         s3c24xx_init_clocks(12000000);
208         s3c24xx_init_uarts(smdkc100_uartcfgs, ARRAY_SIZE(smdkc100_uartcfgs));
209 }
210
211 static void __init smdkc100_machine_init(void)
212 {
213         s3c24xx_ts_set_platdata(&s3c_ts_platform);
214
215         /* I2C */
216         s3c_i2c0_set_platdata(NULL);
217         s3c_i2c1_set_platdata(NULL);
218         i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
219         i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
220
221         s3c_fb_set_platdata(&smdkc100_lcd_pdata);
222         s3c_ide_set_platdata(&smdkc100_ide_pdata);
223
224         samsung_keypad_set_platdata(&smdkc100_keypad_data);
225
226         /* LCD init */
227         gpio_request(S5PC100_GPD(0), "GPD");
228         gpio_request(S5PC100_GPH0(6), "GPH0");
229         smdkc100_lcd_power_set(&smdkc100_lcd_power_data, 0);
230         platform_add_devices(smdkc100_devices, ARRAY_SIZE(smdkc100_devices));
231 }
232
233 MACHINE_START(SMDKC100, "SMDKC100")
234         /* Maintainer: Byungho Min <bhmin@samsung.com> */
235         .phys_io        = S3C_PA_UART & 0xfff00000,
236         .io_pg_offst    = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
237         .boot_params    = S5P_PA_SDRAM + 0x100,
238         .init_irq       = s5pc100_init_irq,
239         .map_io         = smdkc100_map_io,
240         .init_machine   = smdkc100_machine_init,
241         .timer          = &s3c24xx_timer,
242 MACHINE_END