Merge branch 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cascardo/linux.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 #include <linux/pwm_backlight.h>
27
28 #include <asm/hardware/vic.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31
32 #include <mach/map.h>
33 #include <mach/regs-gpio.h>
34
35 #include <video/platform_lcd.h>
36
37 #include <asm/irq.h>
38 #include <asm/mach-types.h>
39
40 #include <plat/regs-serial.h>
41 #include <plat/gpio-cfg.h>
42
43 #include <plat/clock.h>
44 #include <plat/devs.h>
45 #include <plat/cpu.h>
46 #include <plat/fb.h>
47 #include <plat/iic.h>
48 #include <plat/ata.h>
49 #include <plat/adc.h>
50 #include <plat/keypad.h>
51 #include <plat/ts.h>
52 #include <plat/audio.h>
53 #include <plat/backlight.h>
54 #include <plat/regs-fb-v4.h>
55
56 #include "common.h"
57
58 /* Following are default values for UCON, ULCON and UFCON UART registers */
59 #define SMDKC100_UCON_DEFAULT   (S3C2410_UCON_TXILEVEL |        \
60                                  S3C2410_UCON_RXILEVEL |        \
61                                  S3C2410_UCON_TXIRQMODE |       \
62                                  S3C2410_UCON_RXIRQMODE |       \
63                                  S3C2410_UCON_RXFIFO_TOI |      \
64                                  S3C2443_UCON_RXERR_IRQEN)
65
66 #define SMDKC100_ULCON_DEFAULT  S3C2410_LCON_CS8
67
68 #define SMDKC100_UFCON_DEFAULT  (S3C2410_UFCON_FIFOMODE |       \
69                                  S3C2440_UFCON_RXTRIG8 |        \
70                                  S3C2440_UFCON_TXTRIG16)
71
72 static struct s3c2410_uartcfg smdkc100_uartcfgs[] __initdata = {
73         [0] = {
74                 .hwport      = 0,
75                 .flags       = 0,
76                 .ucon        = SMDKC100_UCON_DEFAULT,
77                 .ulcon       = SMDKC100_ULCON_DEFAULT,
78                 .ufcon       = SMDKC100_UFCON_DEFAULT,
79         },
80         [1] = {
81                 .hwport      = 1,
82                 .flags       = 0,
83                 .ucon        = SMDKC100_UCON_DEFAULT,
84                 .ulcon       = SMDKC100_ULCON_DEFAULT,
85                 .ufcon       = SMDKC100_UFCON_DEFAULT,
86         },
87         [2] = {
88                 .hwport      = 2,
89                 .flags       = 0,
90                 .ucon        = SMDKC100_UCON_DEFAULT,
91                 .ulcon       = SMDKC100_ULCON_DEFAULT,
92                 .ufcon       = SMDKC100_UFCON_DEFAULT,
93         },
94         [3] = {
95                 .hwport      = 3,
96                 .flags       = 0,
97                 .ucon        = SMDKC100_UCON_DEFAULT,
98                 .ulcon       = SMDKC100_ULCON_DEFAULT,
99                 .ufcon       = SMDKC100_UFCON_DEFAULT,
100         },
101 };
102
103 /* I2C0 */
104 static struct i2c_board_info i2c_devs0[] __initdata = {
105         {I2C_BOARD_INFO("wm8580", 0x1b),},
106 };
107
108 /* I2C1 */
109 static struct i2c_board_info i2c_devs1[] __initdata = {
110 };
111
112 /* LCD power controller */
113 static void smdkc100_lcd_power_set(struct plat_lcd_data *pd,
114                                    unsigned int power)
115 {
116         if (power) {
117                 /* module reset */
118                 gpio_direction_output(S5PC100_GPH0(6), 1);
119                 mdelay(100);
120                 gpio_direction_output(S5PC100_GPH0(6), 0);
121                 mdelay(10);
122                 gpio_direction_output(S5PC100_GPH0(6), 1);
123                 mdelay(10);
124         }
125 }
126
127 static struct plat_lcd_data smdkc100_lcd_power_data = {
128         .set_power      = smdkc100_lcd_power_set,
129 };
130
131 static struct platform_device smdkc100_lcd_powerdev = {
132         .name                   = "platform-lcd",
133         .dev.parent             = &s3c_device_fb.dev,
134         .dev.platform_data      = &smdkc100_lcd_power_data,
135 };
136
137 /* Frame Buffer */
138 static struct s3c_fb_pd_win smdkc100_fb_win0 = {
139         /* this is to ensure we use win0 */
140         .win_mode       = {
141                 .left_margin    = 8,
142                 .right_margin   = 13,
143                 .upper_margin   = 7,
144                 .lower_margin   = 5,
145                 .hsync_len      = 3,
146                 .vsync_len      = 1,
147                 .xres           = 800,
148                 .yres           = 480,
149                 .refresh        = 80,
150         },
151         .max_bpp        = 32,
152         .default_bpp    = 16,
153 };
154
155 static struct s3c_fb_platdata smdkc100_lcd_pdata __initdata = {
156         .win[0]         = &smdkc100_fb_win0,
157         .vidcon0        = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
158         .vidcon1        = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
159         .setup_gpio     = s5pc100_fb_gpio_setup_24bpp,
160 };
161
162 static struct s3c_ide_platdata smdkc100_ide_pdata __initdata = {
163         .setup_gpio     = s5pc100_ide_setup_gpio,
164 };
165
166 static uint32_t smdkc100_keymap[] __initdata = {
167         /* KEY(row, col, keycode) */
168         KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3),
169         KEY(0, 6, KEY_4), KEY(0, 7, KEY_5),
170         KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C),
171         KEY(1, 6, KEY_D), KEY(1, 7, KEY_E)
172 };
173
174 static struct matrix_keymap_data smdkc100_keymap_data __initdata = {
175         .keymap         = smdkc100_keymap,
176         .keymap_size    = ARRAY_SIZE(smdkc100_keymap),
177 };
178
179 static struct samsung_keypad_platdata smdkc100_keypad_data __initdata = {
180         .keymap_data    = &smdkc100_keymap_data,
181         .rows           = 2,
182         .cols           = 8,
183 };
184
185 static struct platform_device *smdkc100_devices[] __initdata = {
186         &s3c_device_adc,
187         &s3c_device_cfcon,
188         &s3c_device_i2c0,
189         &s3c_device_i2c1,
190         &s3c_device_fb,
191         &s3c_device_hsmmc0,
192         &s3c_device_hsmmc1,
193         &s3c_device_hsmmc2,
194         &s3c_device_ts,
195         &s3c_device_wdt,
196         &smdkc100_lcd_powerdev,
197         &samsung_asoc_dma,
198         &s5pc100_device_iis0,
199         &samsung_device_keypad,
200         &s5pc100_device_ac97,
201         &s3c_device_rtc,
202         &s5p_device_fimc0,
203         &s5p_device_fimc1,
204         &s5p_device_fimc2,
205         &s5pc100_device_spdif,
206 };
207
208 /* LCD Backlight data */
209 static struct samsung_bl_gpio_info smdkc100_bl_gpio_info = {
210         .no = S5PC100_GPD(0),
211         .func = S3C_GPIO_SFN(2),
212 };
213
214 static struct platform_pwm_backlight_data smdkc100_bl_data = {
215         .pwm_id = 0,
216 };
217
218 static void __init smdkc100_map_io(void)
219 {
220         s5pc100_init_io(NULL, 0);
221         s3c24xx_init_clocks(12000000);
222         s3c24xx_init_uarts(smdkc100_uartcfgs, ARRAY_SIZE(smdkc100_uartcfgs));
223 }
224
225 static void __init smdkc100_machine_init(void)
226 {
227         s3c24xx_ts_set_platdata(NULL);
228
229         /* I2C */
230         s3c_i2c0_set_platdata(NULL);
231         s3c_i2c1_set_platdata(NULL);
232         i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
233         i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
234
235         s3c_fb_set_platdata(&smdkc100_lcd_pdata);
236         s3c_ide_set_platdata(&smdkc100_ide_pdata);
237
238         samsung_keypad_set_platdata(&smdkc100_keypad_data);
239
240         s5pc100_spdif_setup_gpio(S5PC100_SPDIF_GPD);
241
242         /* LCD init */
243         gpio_request(S5PC100_GPH0(6), "GPH0");
244         smdkc100_lcd_power_set(&smdkc100_lcd_power_data, 0);
245
246         samsung_bl_set(&smdkc100_bl_gpio_info, &smdkc100_bl_data);
247
248         platform_add_devices(smdkc100_devices, ARRAY_SIZE(smdkc100_devices));
249 }
250
251 MACHINE_START(SMDKC100, "SMDKC100")
252         /* Maintainer: Byungho Min <bhmin@samsung.com> */
253         .atag_offset    = 0x100,
254         .init_irq       = s5pc100_init_irq,
255         .handle_irq     = vic_handle_irq,
256         .map_io         = smdkc100_map_io,
257         .init_machine   = smdkc100_machine_init,
258         .timer          = &s3c24xx_timer,
259         .restart        = s5pc100_restart,
260 MACHINE_END