1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright 2010 Darius Augulis <augulis.darius@gmail.com>
4 // Copyright 2008 Openmoko, Inc.
5 // Copyright 2008 Simtec Electronics
6 // Ben Dooks <ben@simtec.co.uk>
7 // http://armlinux.simtec.co.uk/
9 #include <linux/init.h>
10 #include <linux/interrupt.h>
12 #include <linux/gpio.h>
13 #include <linux/kernel.h>
14 #include <linux/list.h>
15 #include <linux/dm9000.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/platform_device.h>
19 #include <linux/serial_core.h>
20 #include <linux/serial_s3c.h>
21 #include <linux/types.h>
23 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/map.h>
28 #include "regs-gpio.h"
29 #include "gpio-samsung.h"
30 #include <mach/irqs.h>
32 #include <linux/soc/samsung/s3c-adc.h>
36 #include <linux/platform_data/mtd-nand-s3c2410.h>
37 #include <linux/platform_data/touchscreen-s3c2410.h>
39 #include <video/platform_lcd.h>
40 #include <video/samsung_fimd.h>
43 #include "regs-modem-s3c64xx.h"
44 #include "regs-srom-s3c64xx.h"
46 #define UCON S3C2410_UCON_DEFAULT
47 #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
48 #define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
50 static struct s3c2410_uartcfg real6410_uartcfgs
[] __initdata
= {
81 /* DM9000AEP 10/100 ethernet controller */
83 static struct resource real6410_dm9k_resource
[] = {
84 [0] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN1
, 2),
85 [1] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN1
+ 4, 2),
86 [2] = DEFINE_RES_NAMED(S3C_EINT(7), 1, NULL
, IORESOURCE_IRQ \
87 | IORESOURCE_IRQ_HIGHLEVEL
),
90 static struct dm9000_plat_data real6410_dm9k_pdata
= {
91 .flags
= (DM9000_PLATF_16BITONLY
| DM9000_PLATF_NO_EEPROM
),
94 static struct platform_device real6410_device_eth
= {
97 .num_resources
= ARRAY_SIZE(real6410_dm9k_resource
),
98 .resource
= real6410_dm9k_resource
,
100 .platform_data
= &real6410_dm9k_pdata
,
104 static struct s3c_fb_pd_win real6410_lcd_type0_fb_win
= {
111 static struct fb_videomode real6410_lcd_type0_timing
= {
121 static struct s3c_fb_pd_win real6410_lcd_type1_fb_win
= {
128 static struct fb_videomode real6410_lcd_type1_timing
= {
140 static struct s3c_fb_platdata real6410_lcd_pdata
[] __initdata
= {
142 .setup_gpio
= s3c64xx_fb_gpio_setup_24bpp
,
143 .vtiming
= &real6410_lcd_type0_timing
,
144 .win
[0] = &real6410_lcd_type0_fb_win
,
145 .vidcon0
= VIDCON0_VIDOUT_RGB
| VIDCON0_PNRMODE_RGB
,
146 .vidcon1
= VIDCON1_INV_HSYNC
| VIDCON1_INV_VSYNC
,
148 .setup_gpio
= s3c64xx_fb_gpio_setup_24bpp
,
149 .vtiming
= &real6410_lcd_type1_timing
,
150 .win
[0] = &real6410_lcd_type1_fb_win
,
151 .vidcon0
= VIDCON0_VIDOUT_RGB
| VIDCON0_PNRMODE_RGB
,
152 .vidcon1
= VIDCON1_INV_HSYNC
| VIDCON1_INV_VSYNC
,
157 static struct mtd_partition real6410_nand_part
[] = {
170 .size
= MTDPART_SIZ_FULL
,
171 .offset
= SZ_1M
+ SZ_2M
,
175 static struct s3c2410_nand_set real6410_nand_sets
[] = {
179 .nr_partitions
= ARRAY_SIZE(real6410_nand_part
),
180 .partitions
= real6410_nand_part
,
184 static struct s3c2410_platform_nand real6410_nand_info
= {
188 .nr_sets
= ARRAY_SIZE(real6410_nand_sets
),
189 .sets
= real6410_nand_sets
,
190 .engine_type
= NAND_ECC_ENGINE_TYPE_SOFT
,
193 static struct platform_device
*real6410_devices
[] __initdata
= {
194 &real6410_device_eth
,
203 static void __init
real6410_map_io(void)
207 s3c64xx_init_io(NULL
, 0);
208 s3c24xx_init_clocks(12000000);
209 s3c24xx_init_uarts(real6410_uartcfgs
, ARRAY_SIZE(real6410_uartcfgs
));
210 s3c64xx_set_timer_source(S3C64XX_PWM3
, S3C64XX_PWM4
);
212 /* set the LCD type */
213 tmp
= __raw_readl(S3C64XX_SPCON
);
214 tmp
&= ~S3C64XX_SPCON_LCD_SEL_MASK
;
215 tmp
|= S3C64XX_SPCON_LCD_SEL_RGB
;
216 __raw_writel(tmp
, S3C64XX_SPCON
);
218 /* remove the LCD bypass */
219 tmp
= __raw_readl(S3C64XX_MODEM_MIFPCON
);
220 tmp
&= ~MIFPCON_LCD_BYPASS
;
221 __raw_writel(tmp
, S3C64XX_MODEM_MIFPCON
);
225 * real6410_features string
227 * 0-9 LCD configuration
230 static char real6410_features_str
[12] __initdata
= "0";
232 static int __init
real6410_features_setup(char *str
)
235 strlcpy(real6410_features_str
, str
,
236 sizeof(real6410_features_str
));
240 __setup("real6410=", real6410_features_setup
);
242 #define FEATURE_SCREEN (1 << 0)
244 struct real6410_features_t
{
249 static void real6410_parse_features(
250 struct real6410_features_t
*features
,
251 const char *features_str
)
253 const char *fp
= features_str
;
256 features
->lcd_index
= 0;
262 case '0'...'9': /* tft screen */
263 if (features
->done
& FEATURE_SCREEN
) {
264 printk(KERN_INFO
"REAL6410: '%c' ignored, "
265 "screen type already set\n", f
);
268 if (li
>= ARRAY_SIZE(real6410_lcd_pdata
))
269 printk(KERN_INFO
"REAL6410: '%c' out "
270 "of range LCD mode\n", f
);
272 features
->lcd_index
= li
;
275 features
->done
|= FEATURE_SCREEN
;
281 static void __init
real6410_machine_init(void)
284 struct real6410_features_t features
= { 0 };
286 printk(KERN_INFO
"REAL6410: Option string real6410=%s\n",
287 real6410_features_str
);
289 /* Parse the feature string */
290 real6410_parse_features(&features
, real6410_features_str
);
292 printk(KERN_INFO
"REAL6410: selected LCD display is %dx%d\n",
293 real6410_lcd_pdata
[features
.lcd_index
].win
[0]->xres
,
294 real6410_lcd_pdata
[features
.lcd_index
].win
[0]->yres
);
296 s3c_fb_set_platdata(&real6410_lcd_pdata
[features
.lcd_index
]);
297 s3c_nand_set_platdata(&real6410_nand_info
);
298 s3c64xx_ts_set_platdata(NULL
);
300 /* configure nCS1 width to 16 bits */
302 cs1
= __raw_readl(S3C64XX_SROM_BW
) &
303 ~(S3C64XX_SROM_BW__CS_MASK
<< S3C64XX_SROM_BW__NCS1__SHIFT
);
304 cs1
|= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT
) |
305 (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT
) |
306 (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT
)) <<
307 S3C64XX_SROM_BW__NCS1__SHIFT
;
308 __raw_writel(cs1
, S3C64XX_SROM_BW
);
310 /* set timing for nCS1 suitable for ethernet chip */
312 __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT
) |
313 (6 << S3C64XX_SROM_BCX__TACP__SHIFT
) |
314 (4 << S3C64XX_SROM_BCX__TCAH__SHIFT
) |
315 (1 << S3C64XX_SROM_BCX__TCOH__SHIFT
) |
316 (13 << S3C64XX_SROM_BCX__TACC__SHIFT
) |
317 (4 << S3C64XX_SROM_BCX__TCOS__SHIFT
) |
318 (0 << S3C64XX_SROM_BCX__TACS__SHIFT
), S3C64XX_SROM_BC1
);
320 gpio_request(S3C64XX_GPF(15), "LCD power");
322 platform_add_devices(real6410_devices
, ARRAY_SIZE(real6410_devices
));
325 MACHINE_START(REAL6410
, "REAL6410")
326 /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
327 .atag_offset
= 0x100,
328 .nr_irqs
= S3C64XX_NR_IRQS
,
329 .init_irq
= s3c6410_init_irq
,
330 .map_io
= real6410_map_io
,
331 .init_machine
= real6410_machine_init
,
332 .init_time
= s3c64xx_timer_init
,