blob: 0525cb3ef406cfd40b104fe32a5be2bc54930df3 [file] [log] [blame]
Byungho Mine1197662009-06-23 21:40:28 +09001/* 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>
Naveen Krishna Ch2211f282010-06-22 07:54:18 +090025#include <linux/input.h>
Banajit Goswamibaa0c062011-02-28 20:37:21 +053026#include <linux/pwm_backlight.h>
Byungho Mine1197662009-06-23 21:40:28 +090027
28#include <asm/mach/arch.h>
29#include <asm/mach/map.h>
30
31#include <mach/map.h>
Kyungmin Park079b0322009-11-17 08:41:20 +010032#include <mach/regs-fb.h>
Banajit Goswamibaa0c062011-02-28 20:37:21 +053033#include <mach/regs-gpio.h>
34
Kyungmin Park079b0322009-11-17 08:41:20 +010035#include <video/platform_lcd.h>
Byungho Mine1197662009-06-23 21:40:28 +090036
37#include <asm/irq.h>
38#include <asm/mach-types.h>
39
40#include <plat/regs-serial.h>
Kyungmin Park079b0322009-11-17 08:41:20 +010041#include <plat/gpio-cfg.h>
Byungho Mine1197662009-06-23 21:40:28 +090042
43#include <plat/clock.h>
44#include <plat/devs.h>
45#include <plat/cpu.h>
46#include <plat/s5pc100.h>
Kyungmin Park079b0322009-11-17 08:41:20 +010047#include <plat/fb.h>
Kyungmin Park067f1312009-11-17 08:41:22 +010048#include <plat/iic.h>
Abhilash Kesavan66194a72010-06-08 17:02:08 +090049#include <plat/ata.h>
Naveen Krishna Ch327b9032010-06-30 21:50:24 +090050#include <plat/adc.h>
Naveen Krishna Ch2211f282010-06-22 07:54:18 +090051#include <plat/keypad.h>
Naveen Krishna Ch327b9032010-06-30 21:50:24 +090052#include <plat/ts.h>
Seungwhan Youn068b4322010-10-14 10:35:23 +090053#include <plat/audio.h>
Byungho Mine1197662009-06-23 21:40:28 +090054
Marek Szyprowski13e51fa2010-05-18 11:30:49 +020055/* Following are default values for UCON, ULCON and UFCON UART registers */
Kukjin Kimc8def082010-07-21 09:19:51 +090056#define SMDKC100_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
Marek Szyprowski13e51fa2010-05-18 11:30:49 +020057 S3C2410_UCON_RXILEVEL | \
58 S3C2410_UCON_TXIRQMODE | \
59 S3C2410_UCON_RXIRQMODE | \
60 S3C2410_UCON_RXFIFO_TOI | \
61 S3C2443_UCON_RXERR_IRQEN)
62
Kukjin Kimc8def082010-07-21 09:19:51 +090063#define SMDKC100_ULCON_DEFAULT S3C2410_LCON_CS8
Marek Szyprowski13e51fa2010-05-18 11:30:49 +020064
Kukjin Kimc8def082010-07-21 09:19:51 +090065#define SMDKC100_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
Marek Szyprowski13e51fa2010-05-18 11:30:49 +020066 S3C2440_UFCON_RXTRIG8 | \
67 S3C2440_UFCON_TXTRIG16)
Byungho Mine1197662009-06-23 21:40:28 +090068
69static struct s3c2410_uartcfg smdkc100_uartcfgs[] __initdata = {
70 [0] = {
71 .hwport = 0,
72 .flags = 0,
Kukjin Kimc8def082010-07-21 09:19:51 +090073 .ucon = SMDKC100_UCON_DEFAULT,
74 .ulcon = SMDKC100_ULCON_DEFAULT,
75 .ufcon = SMDKC100_UFCON_DEFAULT,
Byungho Mine1197662009-06-23 21:40:28 +090076 },
77 [1] = {
78 .hwport = 1,
79 .flags = 0,
Kukjin Kimc8def082010-07-21 09:19:51 +090080 .ucon = SMDKC100_UCON_DEFAULT,
81 .ulcon = SMDKC100_ULCON_DEFAULT,
82 .ufcon = SMDKC100_UFCON_DEFAULT,
Byungho Mine1197662009-06-23 21:40:28 +090083 },
84 [2] = {
85 .hwport = 2,
86 .flags = 0,
Kukjin Kimc8def082010-07-21 09:19:51 +090087 .ucon = SMDKC100_UCON_DEFAULT,
88 .ulcon = SMDKC100_ULCON_DEFAULT,
89 .ufcon = SMDKC100_UFCON_DEFAULT,
Byungho Mine1197662009-06-23 21:40:28 +090090 },
91 [3] = {
92 .hwport = 3,
93 .flags = 0,
Kukjin Kimc8def082010-07-21 09:19:51 +090094 .ucon = SMDKC100_UCON_DEFAULT,
95 .ulcon = SMDKC100_ULCON_DEFAULT,
96 .ufcon = SMDKC100_UFCON_DEFAULT,
Byungho Mine1197662009-06-23 21:40:28 +090097 },
98};
99
Kyungmin Park067f1312009-11-17 08:41:22 +0100100/* I2C0 */
101static struct i2c_board_info i2c_devs0[] __initdata = {
Jassi Brarb0f39c22010-11-22 15:37:19 +0900102 {I2C_BOARD_INFO("wm8580", 0x1b),},
Kyungmin Park067f1312009-11-17 08:41:22 +0100103};
104
105/* I2C1 */
106static struct i2c_board_info i2c_devs1[] __initdata = {
107};
108
Kyungmin Park079b0322009-11-17 08:41:20 +0100109/* LCD power controller */
110static void smdkc100_lcd_power_set(struct plat_lcd_data *pd,
111 unsigned int power)
112{
Kyungmin Park079b0322009-11-17 08:41:20 +0100113 if (power) {
114 /* module reset */
115 gpio_direction_output(S5PC100_GPH0(6), 1);
116 mdelay(100);
117 gpio_direction_output(S5PC100_GPH0(6), 0);
118 mdelay(10);
119 gpio_direction_output(S5PC100_GPH0(6), 1);
120 mdelay(10);
121 }
122}
123
124static struct plat_lcd_data smdkc100_lcd_power_data = {
125 .set_power = smdkc100_lcd_power_set,
126};
127
128static struct platform_device smdkc100_lcd_powerdev = {
129 .name = "platform-lcd",
130 .dev.parent = &s3c_device_fb.dev,
131 .dev.platform_data = &smdkc100_lcd_power_data,
132};
133
134/* Frame Buffer */
135static struct s3c_fb_pd_win smdkc100_fb_win0 = {
136 /* this is to ensure we use win0 */
137 .win_mode = {
Kyungmin Park079b0322009-11-17 08:41:20 +0100138 .left_margin = 8,
139 .right_margin = 13,
140 .upper_margin = 7,
141 .lower_margin = 5,
142 .hsync_len = 3,
143 .vsync_len = 1,
144 .xres = 800,
145 .yres = 480,
Maurus Cuelenaeredaf695f2010-08-10 18:02:44 -0700146 .refresh = 80,
Kyungmin Park079b0322009-11-17 08:41:20 +0100147 },
148 .max_bpp = 32,
149 .default_bpp = 16,
150};
151
152static struct s3c_fb_platdata smdkc100_lcd_pdata __initdata = {
153 .win[0] = &smdkc100_fb_win0,
154 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
155 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
156 .setup_gpio = s5pc100_fb_gpio_setup_24bpp,
157};
158
Abhilash Kesavan66194a72010-06-08 17:02:08 +0900159static struct s3c_ide_platdata smdkc100_ide_pdata __initdata = {
160 .setup_gpio = s5pc100_ide_setup_gpio,
161};
162
Naveen Krishna Ch2211f282010-06-22 07:54:18 +0900163static uint32_t smdkc100_keymap[] __initdata = {
164 /* KEY(row, col, keycode) */
165 KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3),
166 KEY(0, 6, KEY_4), KEY(0, 7, KEY_5),
167 KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C),
168 KEY(1, 6, KEY_D), KEY(1, 7, KEY_E)
169};
170
171static struct matrix_keymap_data smdkc100_keymap_data __initdata = {
172 .keymap = smdkc100_keymap,
173 .keymap_size = ARRAY_SIZE(smdkc100_keymap),
174};
175
176static struct samsung_keypad_platdata smdkc100_keypad_data __initdata = {
177 .keymap_data = &smdkc100_keymap_data,
178 .rows = 2,
179 .cols = 8,
180};
181
Banajit Goswamibaa0c062011-02-28 20:37:21 +0530182static int smdkc100_backlight_init(struct device *dev)
183{
184 int ret;
185
186 ret = gpio_request(S5PC100_GPD(0), "Backlight");
187 if (ret) {
188 printk(KERN_ERR "failed to request GPF for PWM-OUT0\n");
189 return ret;
190 }
191
192 /* Configure GPIO pin with S5PC100_GPD_TOUT_0 */
193 s3c_gpio_cfgpin(S5PC100_GPD(0), S3C_GPIO_SFN(2));
194
195 return 0;
196}
197
198static void smdkc100_backlight_exit(struct device *dev)
199{
200 s3c_gpio_cfgpin(S5PC100_GPD(0), S3C_GPIO_OUTPUT);
201 gpio_free(S5PC100_GPD(0));
202}
203
204static struct platform_pwm_backlight_data smdkc100_backlight_data = {
205 .pwm_id = 0,
206 .max_brightness = 255,
207 .dft_brightness = 255,
208 .pwm_period_ns = 78770,
209 .init = smdkc100_backlight_init,
210 .exit = smdkc100_backlight_exit,
211};
212
213static struct platform_device smdkc100_backlight_device = {
214 .name = "pwm-backlight",
215 .dev = {
216 .parent = &s3c_device_timer[0].dev,
217 .platform_data = &smdkc100_backlight_data,
218 },
219};
220
Byungho Mine1197662009-06-23 21:40:28 +0900221static struct platform_device *smdkc100_devices[] __initdata = {
Naveen Krishna Ch327b9032010-06-30 21:50:24 +0900222 &s3c_device_adc,
Banajit Goswamic4023612010-06-18 12:12:06 +0530223 &s3c_device_cfcon,
Kyungmin Park067f1312009-11-17 08:41:22 +0100224 &s3c_device_i2c0,
225 &s3c_device_i2c1,
Kyungmin Park079b0322009-11-17 08:41:20 +0100226 &s3c_device_fb,
Kyungmin Park0c318622009-11-17 08:41:24 +0100227 &s3c_device_hsmmc0,
228 &s3c_device_hsmmc1,
229 &s3c_device_hsmmc2,
Naveen Krishna Ch327b9032010-06-30 21:50:24 +0900230 &s3c_device_ts,
Banajit Goswamic4023612010-06-18 12:12:06 +0530231 &s3c_device_wdt,
Kyungmin Park079b0322009-11-17 08:41:20 +0100232 &smdkc100_lcd_powerdev,
Jassi Brarb0f39c22010-11-22 15:37:19 +0900233 &samsung_asoc_dma,
Jassi Brar99c56e02010-05-18 16:02:44 +0900234 &s5pc100_device_iis0,
Naveen Krishna Ch2211f282010-06-22 07:54:18 +0900235 &samsung_device_keypad,
Jassi Brar99c56e02010-05-18 16:02:44 +0900236 &s5pc100_device_ac97,
Atul Dahiyafa9ce742010-07-21 17:38:23 +0900237 &s3c_device_rtc,
Sylwester Nawrockidb94a2f2010-08-09 16:55:35 +0900238 &s5p_device_fimc0,
239 &s5p_device_fimc1,
240 &s5p_device_fimc2,
Seungwhan Youn068b4322010-10-14 10:35:23 +0900241 &s5pc100_device_spdif,
Banajit Goswamibaa0c062011-02-28 20:37:21 +0530242 &s3c_device_timer[0],
243 &smdkc100_backlight_device,
Byungho Mine1197662009-06-23 21:40:28 +0900244};
245
Naveen Krishna Ch327b9032010-06-30 21:50:24 +0900246static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
247 .delay = 10000,
248 .presc = 49,
249 .oversampling_shift = 2,
Byungho Mine1197662009-06-23 21:40:28 +0900250};
251
252static void __init smdkc100_map_io(void)
253{
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200254 s5p_init_io(NULL, 0, S5P_VA_CHIPID);
Byungho Mine1197662009-06-23 21:40:28 +0900255 s3c24xx_init_clocks(12000000);
256 s3c24xx_init_uarts(smdkc100_uartcfgs, ARRAY_SIZE(smdkc100_uartcfgs));
257}
258
259static void __init smdkc100_machine_init(void)
260{
Naveen Krishna Ch327b9032010-06-30 21:50:24 +0900261 s3c24xx_ts_set_platdata(&s3c_ts_platform);
262
Kyungmin Park067f1312009-11-17 08:41:22 +0100263 /* I2C */
264 s3c_i2c0_set_platdata(NULL);
265 s3c_i2c1_set_platdata(NULL);
266 i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
267 i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
268
Kyungmin Park079b0322009-11-17 08:41:20 +0100269 s3c_fb_set_platdata(&smdkc100_lcd_pdata);
Abhilash Kesavan66194a72010-06-08 17:02:08 +0900270 s3c_ide_set_platdata(&smdkc100_ide_pdata);
Kyungmin Park079b0322009-11-17 08:41:20 +0100271
Naveen Krishna Ch2211f282010-06-22 07:54:18 +0900272 samsung_keypad_set_platdata(&smdkc100_keypad_data);
Kyungmin Park079b0322009-11-17 08:41:20 +0100273
Seungwhan Youn068b4322010-10-14 10:35:23 +0900274 s5pc100_spdif_setup_gpio(S5PC100_SPDIF_GPD);
275
Kyungmin Park079b0322009-11-17 08:41:20 +0100276 /* LCD init */
Kyungmin Park079b0322009-11-17 08:41:20 +0100277 gpio_request(S5PC100_GPH0(6), "GPH0");
278 smdkc100_lcd_power_set(&smdkc100_lcd_power_data, 0);
Byungho Mine1197662009-06-23 21:40:28 +0900279 platform_add_devices(smdkc100_devices, ARRAY_SIZE(smdkc100_devices));
280}
281
282MACHINE_START(SMDKC100, "SMDKC100")
283 /* Maintainer: Byungho Min <bhmin@samsung.com> */
Marek Szyprowskiacc84702010-05-20 07:51:08 +0200284 .boot_params = S5P_PA_SDRAM + 0x100,
Byungho Mine1197662009-06-23 21:40:28 +0900285 .init_irq = s5pc100_init_irq,
286 .map_io = smdkc100_map_io,
287 .init_machine = smdkc100_machine_init,
288 .timer = &s3c24xx_timer,
289MACHINE_END