blob: d0b9f09b7269952eeb8445d2d13bf9afeb33d95e [file] [log] [blame]
Ben Dooks5718df92008-10-21 14:07:09 +01001/* linux/arch/arm/mach-s3c6410/mach-smdk6410.c
2 *
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12*/
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/interrupt.h>
17#include <linux/list.h>
18#include <linux/timer.h>
19#include <linux/init.h>
20#include <linux/serial_core.h>
21#include <linux/platform_device.h>
22#include <linux/io.h>
Ben Dooks096941e2008-10-31 16:14:59 +000023#include <linux/i2c.h>
Ben Dooks438a5d42008-11-19 15:41:34 +000024#include <linux/fb.h>
25#include <linux/gpio.h>
26#include <linux/delay.h>
27
28#include <video/platform_lcd.h>
Ben Dooks5718df92008-10-21 14:07:09 +010029
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/irq.h>
33
34#include <mach/hardware.h>
Ben Dooks438a5d42008-11-19 15:41:34 +000035#include <mach/regs-fb.h>
Ben Dooks5718df92008-10-21 14:07:09 +010036#include <mach/map.h>
37
38#include <asm/irq.h>
39#include <asm/mach-types.h>
40
41#include <plat/regs-serial.h>
Ben Dooksd6662c32008-12-12 00:24:40 +000042#include <plat/regs-modem.h>
43#include <plat/regs-gpio.h>
44#include <plat/regs-sys.h>
Ben Dooksd85fa242008-10-31 16:14:52 +000045#include <plat/iic.h>
Ben Dooks438a5d42008-11-19 15:41:34 +000046#include <plat/fb.h>
Ben Dooks5718df92008-10-21 14:07:09 +010047
48#include <plat/s3c6410.h>
49#include <plat/clock.h>
50#include <plat/devs.h>
51#include <plat/cpu.h>
52
53#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
54#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
55#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
56
57static struct s3c2410_uartcfg smdk6410_uartcfgs[] __initdata = {
58 [0] = {
59 .hwport = 0,
60 .flags = 0,
61 .ucon = 0x3c5,
62 .ulcon = 0x03,
63 .ufcon = 0x51,
64 },
65 [1] = {
66 .hwport = 1,
67 .flags = 0,
68 .ucon = 0x3c5,
69 .ulcon = 0x03,
70 .ufcon = 0x51,
71 },
72};
73
Ben Dooks438a5d42008-11-19 15:41:34 +000074/* framebuffer and LCD setup. */
75
76/* GPF15 = LCD backlight control
77 * GPF13 => Panel power
78 * GPN5 = LCD nRESET signal
79 * PWM_TOUT1 => backlight brightness
80 */
81
82static void smdk6410_lcd_power_set(struct plat_lcd_data *pd,
83 unsigned int power)
84{
85 if (power) {
86 gpio_direction_output(S3C64XX_GPF(13), 1);
87 gpio_direction_output(S3C64XX_GPF(15), 1);
88
89 /* fire nRESET on power up */
90 gpio_direction_output(S3C64XX_GPN(5), 0);
91 msleep(10);
92 gpio_direction_output(S3C64XX_GPN(5), 1);
93 msleep(1);
94 } else {
95 gpio_direction_output(S3C64XX_GPF(15), 0);
96 gpio_direction_output(S3C64XX_GPF(13), 0);
97 }
98}
99
100static struct plat_lcd_data smdk6410_lcd_power_data = {
101 .set_power = smdk6410_lcd_power_set,
102};
103
104static struct platform_device smdk6410_lcd_powerdev = {
105 .name = "platform-lcd",
106 .dev.parent = &s3c_device_fb.dev,
107 .dev.platform_data = &smdk6410_lcd_power_data,
108};
109
110static struct s3c_fb_pd_win smdk6410_fb_win0 = {
111 /* this is to ensure we use win0 */
112 .win_mode = {
113 .pixclock = 41094,
114 .left_margin = 8,
115 .right_margin = 13,
116 .upper_margin = 7,
117 .lower_margin = 5,
118 .hsync_len = 3,
119 .vsync_len = 1,
120 .xres = 800,
121 .yres = 480,
122 },
123 .max_bpp = 32,
124 .default_bpp = 16,
125};
126
127/* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
128static struct s3c_fb_platdata smdk6410_lcd_pdata __initdata = {
129 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
130 .win[0] = &smdk6410_fb_win0,
131 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
132 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
133};
134
Mark Brown027191a2009-01-23 16:29:43 +0000135static struct map_desc smdk6410_iodesc[] = {};
Ben Dooks5718df92008-10-21 14:07:09 +0100136
137static struct platform_device *smdk6410_devices[] __initdata = {
Ben Dooksb24636c2008-11-03 20:14:53 +0000138#ifdef CONFIG_SMDK6410_SD_CH0
Ben Dooks39057f22008-10-31 16:14:29 +0000139 &s3c_device_hsmmc0,
Ben Dooksb24636c2008-11-03 20:14:53 +0000140#endif
141#ifdef CONFIG_SMDK6410_SD_CH1
142 &s3c_device_hsmmc1,
143#endif
Ben Dooksd85fa242008-10-31 16:14:52 +0000144 &s3c_device_i2c0,
Ben Dooksd7ea3742008-10-31 16:14:57 +0000145 &s3c_device_i2c1,
Ben Dooks438a5d42008-11-19 15:41:34 +0000146 &s3c_device_fb,
147 &smdk6410_lcd_powerdev,
Ben Dooks5718df92008-10-21 14:07:09 +0100148};
149
Ben Dooks096941e2008-10-31 16:14:59 +0000150static struct i2c_board_info i2c_devs0[] __initdata = {
151 { I2C_BOARD_INFO("24c08", 0x50), },
Mark Brown7789747972009-01-23 16:29:41 +0000152 { I2C_BOARD_INFO("wm8580", 0x1b), },
Ben Dooks096941e2008-10-31 16:14:59 +0000153};
154
155static struct i2c_board_info i2c_devs1[] __initdata = {
156 { I2C_BOARD_INFO("24c128", 0x57), }, /* Samsung S524AD0XD1 */
Ben Dooks5718df92008-10-21 14:07:09 +0100157};
158
Ben Dooks5718df92008-10-21 14:07:09 +0100159static void __init smdk6410_map_io(void)
160{
Ben Dooksd6662c32008-12-12 00:24:40 +0000161 u32 tmp;
162
Ben Dooks5718df92008-10-21 14:07:09 +0100163 s3c64xx_init_io(smdk6410_iodesc, ARRAY_SIZE(smdk6410_iodesc));
164 s3c24xx_init_clocks(12000000);
165 s3c24xx_init_uarts(smdk6410_uartcfgs, ARRAY_SIZE(smdk6410_uartcfgs));
Ben Dooksd6662c32008-12-12 00:24:40 +0000166
167 /* set the LCD type */
168
169 tmp = __raw_readl(S3C64XX_SPCON);
170 tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
171 tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
172 __raw_writel(tmp, S3C64XX_SPCON);
173
174 /* remove the lcd bypass */
175 tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
176 tmp &= ~MIFPCON_LCD_BYPASS;
177 __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
Ben Dooks5718df92008-10-21 14:07:09 +0100178}
179
180static void __init smdk6410_machine_init(void)
181{
Ben Dooksd85fa242008-10-31 16:14:52 +0000182 s3c_i2c0_set_platdata(NULL);
Ben Dooksd7ea3742008-10-31 16:14:57 +0000183 s3c_i2c1_set_platdata(NULL);
Ben Dooks438a5d42008-11-19 15:41:34 +0000184 s3c_fb_set_platdata(&smdk6410_lcd_pdata);
Ben Dooks096941e2008-10-31 16:14:59 +0000185
Mark Brownb7f9a942009-04-08 16:12:35 +0100186 gpio_request(S3C64XX_GPN(5), "LCD power");
187 gpio_request(S3C64XX_GPF(13), "LCD power");
188 gpio_request(S3C64XX_GPF(15), "LCD power");
189
Ben Dooks096941e2008-10-31 16:14:59 +0000190 i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
191 i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
192
Ben Dooks5718df92008-10-21 14:07:09 +0100193 platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));
194}
195
196MACHINE_START(SMDK6410, "SMDK6410")
197 /* Maintainer: Ben Dooks <ben@fluff.org> */
198 .phys_io = S3C_PA_UART & 0xfff00000,
199 .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
200 .boot_params = S3C64XX_PA_SDRAM + 0x100,
201
202 .init_irq = s3c6410_init_irq,
203 .map_io = smdk6410_map_io,
204 .init_machine = smdk6410_machine_init,
205 .timer = &s3c24xx_timer,
206MACHINE_END