blob: 9d218a53d631005376f85e01f2c7a13434f1267c [file] [log] [blame]
Krzysztof Kozlowski28a196f2017-12-25 20:54:33 +01001// SPDX-License-Identifier: GPL-2.0
2//
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/
Darius Auguliseab5cfa2010-07-28 23:03:43 +03008
Darius Auguliseab5cfa2010-07-28 23:03:43 +03009#include <linux/init.h>
Darius Augulisc115f67c2010-10-19 13:52:29 +090010#include <linux/interrupt.h>
11#include <linux/fb.h>
12#include <linux/gpio.h>
13#include <linux/kernel.h>
14#include <linux/list.h>
Darius Augulisff266c02010-08-01 23:38:43 +030015#include <linux/dm9000.h>
Darius Augulis88fbade2010-10-19 13:52:32 +090016#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h>
Darius Auguliseab5cfa2010-07-28 23:03:43 +030018#include <linux/platform_device.h>
Darius Augulisc115f67c2010-10-19 13:52:29 +090019#include <linux/serial_core.h>
Tushar Behera334a1c72014-02-14 10:32:45 +090020#include <linux/serial_s3c.h>
Darius Augulisc115f67c2010-10-19 13:52:29 +090021#include <linux/types.h>
22
Darius Auguliseab5cfa2010-07-28 23:03:43 +030023#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25#include <asm/mach/map.h>
Darius Augulisc115f67c2010-10-19 13:52:29 +090026
Arnd Bergmannc6ff1322019-09-02 18:37:30 +020027#include "map.h"
28#include "regs-gpio.h"
29#include "gpio-samsung.h"
Arnd Bergmannba279042015-02-27 22:06:58 +010030#include <mach/irqs.h>
Darius Augulisc115f67c2010-10-19 13:52:29 +090031
Arnd Bergmann7dbad032020-08-06 20:20:39 +020032#include <linux/soc/samsung/s3c-adc.h>
Arnd Bergmannc6ff1322019-09-02 18:37:30 +020033#include "cpu.h"
34#include "devs.h"
35#include "fb.h"
Arnd Bergmann436d42c2012-08-24 15:22:12 +020036#include <linux/platform_data/mtd-nand-s3c2410.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020037#include <linux/platform_data/touchscreen-s3c2410.h>
Darius Auguliseab5cfa2010-07-28 23:03:43 +030038
Darius Augulisc115f67c2010-10-19 13:52:29 +090039#include <video/platform_lcd.h>
Leela Krishna Amudala5a213a52012-08-08 09:44:49 +090040#include <video/samsung_fimd.h>
Darius Auguliseab5cfa2010-07-28 23:03:43 +030041
Arnd Bergmann71b91142019-09-02 17:47:55 +020042#include "s3c64xx.h"
43#include "regs-modem-s3c64xx.h"
44#include "regs-srom-s3c64xx.h"
Kukjin Kimb024043b2011-12-22 23:27:42 +010045
Darius Augulis8b8c87d2010-11-16 18:08:50 +090046#define UCON S3C2410_UCON_DEFAULT
Darius Augulis591cd252010-09-09 21:40:22 +090047#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
48#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
Darius Auguliseab5cfa2010-07-28 23:03:43 +030049
50static struct s3c2410_uartcfg real6410_uartcfgs[] __initdata = {
51 [0] = {
Darius Augulis591cd252010-09-09 21:40:22 +090052 .hwport = 0,
53 .flags = 0,
54 .ucon = UCON,
55 .ulcon = ULCON,
56 .ufcon = UFCON,
Darius Auguliseab5cfa2010-07-28 23:03:43 +030057 },
58 [1] = {
Darius Augulis591cd252010-09-09 21:40:22 +090059 .hwport = 1,
60 .flags = 0,
61 .ucon = UCON,
62 .ulcon = ULCON,
63 .ufcon = UFCON,
Darius Auguliseab5cfa2010-07-28 23:03:43 +030064 },
65 [2] = {
Darius Augulis591cd252010-09-09 21:40:22 +090066 .hwport = 2,
67 .flags = 0,
68 .ucon = UCON,
69 .ulcon = ULCON,
70 .ufcon = UFCON,
Darius Auguliseab5cfa2010-07-28 23:03:43 +030071 },
72 [3] = {
Darius Augulis591cd252010-09-09 21:40:22 +090073 .hwport = 3,
74 .flags = 0,
75 .ucon = UCON,
76 .ulcon = ULCON,
77 .ufcon = UFCON,
Darius Auguliseab5cfa2010-07-28 23:03:43 +030078 },
79};
80
Darius Augulisff266c02010-08-01 23:38:43 +030081/* DM9000AEP 10/100 ethernet controller */
82
83static struct resource real6410_dm9k_resource[] = {
Tushar Beheraae03a332012-05-12 16:12:29 +090084 [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),
Darius Augulisff266c02010-08-01 23:38:43 +030088};
89
90static struct dm9000_plat_data real6410_dm9k_pdata = {
Darius Augulis591cd252010-09-09 21:40:22 +090091 .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
Darius Augulisff266c02010-08-01 23:38:43 +030092};
93
94static struct platform_device real6410_device_eth = {
Darius Augulis591cd252010-09-09 21:40:22 +090095 .name = "dm9000",
96 .id = -1,
97 .num_resources = ARRAY_SIZE(real6410_dm9k_resource),
98 .resource = real6410_dm9k_resource,
99 .dev = {
100 .platform_data = &real6410_dm9k_pdata,
101 },
Darius Augulisff266c02010-08-01 23:38:43 +0300102};
103
Thomas Abraham884924b2012-03-24 21:58:47 +0530104static struct s3c_fb_pd_win real6410_lcd_type0_fb_win = {
Thomas Abraham884924b2012-03-24 21:58:47 +0530105 .max_bpp = 32,
106 .default_bpp = 16,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530107 .xres = 480,
108 .yres = 272,
Darius Augulisc115f67c2010-10-19 13:52:29 +0900109};
110
Thomas Abraham79d3c412012-03-24 21:58:48 +0530111static struct fb_videomode real6410_lcd_type0_timing = {
112 /* 4.3" 480x272 */
113 .left_margin = 3,
114 .right_margin = 2,
115 .upper_margin = 1,
116 .lower_margin = 1,
117 .hsync_len = 40,
118 .vsync_len = 1,
Darius Augulisc115f67c2010-10-19 13:52:29 +0900119};
120
Thomas Abraham884924b2012-03-24 21:58:47 +0530121static struct s3c_fb_pd_win real6410_lcd_type1_fb_win = {
Thomas Abraham884924b2012-03-24 21:58:47 +0530122 .max_bpp = 32,
123 .default_bpp = 16,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530124 .xres = 800,
125 .yres = 480,
126};
127
128static struct fb_videomode real6410_lcd_type1_timing = {
129 /* 7.0" 800x480 */
130 .left_margin = 8,
131 .right_margin = 13,
132 .upper_margin = 7,
133 .lower_margin = 5,
134 .hsync_len = 3,
135 .vsync_len = 1,
136 .xres = 800,
137 .yres = 480,
Thomas Abraham884924b2012-03-24 21:58:47 +0530138};
139
140static struct s3c_fb_platdata real6410_lcd_pdata[] __initdata = {
141 {
142 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530143 .vtiming = &real6410_lcd_type0_timing,
Thomas Abraham884924b2012-03-24 21:58:47 +0530144 .win[0] = &real6410_lcd_type0_fb_win,
145 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
146 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
147 }, {
148 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530149 .vtiming = &real6410_lcd_type1_timing,
Thomas Abraham884924b2012-03-24 21:58:47 +0530150 .win[0] = &real6410_lcd_type1_fb_win,
151 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
152 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
153 },
154 { },
Darius Augulisc115f67c2010-10-19 13:52:29 +0900155};
156
Darius Augulis88fbade2010-10-19 13:52:32 +0900157static struct mtd_partition real6410_nand_part[] = {
158 [0] = {
159 .name = "uboot",
160 .size = SZ_1M,
161 .offset = 0,
162 },
163 [1] = {
164 .name = "kernel",
165 .size = SZ_2M,
166 .offset = SZ_1M,
167 },
168 [2] = {
169 .name = "rootfs",
170 .size = MTDPART_SIZ_FULL,
171 .offset = SZ_1M + SZ_2M,
172 },
173};
174
175static struct s3c2410_nand_set real6410_nand_sets[] = {
176 [0] = {
177 .name = "nand",
178 .nr_chips = 1,
179 .nr_partitions = ARRAY_SIZE(real6410_nand_part),
180 .partitions = real6410_nand_part,
181 },
182};
183
184static struct s3c2410_platform_nand real6410_nand_info = {
185 .tacls = 25,
186 .twrph0 = 55,
187 .twrph1 = 40,
188 .nr_sets = ARRAY_SIZE(real6410_nand_sets),
189 .sets = real6410_nand_sets,
Miquel Raynalbace41f2020-08-27 10:51:58 +0200190 .engine_type = NAND_ECC_ENGINE_TYPE_SOFT,
Darius Augulis88fbade2010-10-19 13:52:32 +0900191};
192
Darius Augulisff266c02010-08-01 23:38:43 +0300193static struct platform_device *real6410_devices[] __initdata = {
194 &real6410_device_eth,
Darius Augulisce611d72010-08-02 01:39:25 +0300195 &s3c_device_hsmmc0,
196 &s3c_device_hsmmc1,
Darius Augulisc115f67c2010-10-19 13:52:29 +0900197 &s3c_device_fb,
Darius Augulis88fbade2010-10-19 13:52:32 +0900198 &s3c_device_nand,
Darius Augulis4374c452010-10-19 13:52:34 +0900199 &s3c_device_adc,
Darius Augulis10dcc7a2010-10-19 13:52:37 +0900200 &s3c_device_ohci,
Darius Augulis4374c452010-10-19 13:52:34 +0900201};
202
Darius Auguliseab5cfa2010-07-28 23:03:43 +0300203static void __init real6410_map_io(void)
204{
Darius Augulisc115f67c2010-10-19 13:52:29 +0900205 u32 tmp;
206
Darius Auguliseab5cfa2010-07-28 23:03:43 +0300207 s3c64xx_init_io(NULL, 0);
208 s3c24xx_init_clocks(12000000);
209 s3c24xx_init_uarts(real6410_uartcfgs, ARRAY_SIZE(real6410_uartcfgs));
Krzysztof Kozlowskia1342f62020-08-20 22:42:03 +0200210 s3c64xx_set_timer_source(S3C64XX_PWM3, S3C64XX_PWM4);
Darius Augulisc115f67c2010-10-19 13:52:29 +0900211
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);
217
218 /* remove the LCD bypass */
219 tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
220 tmp &= ~MIFPCON_LCD_BYPASS;
221 __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
222}
223
224/*
225 * real6410_features string
226 *
227 * 0-9 LCD configuration
228 *
229 */
230static char real6410_features_str[12] __initdata = "0";
231
232static int __init real6410_features_setup(char *str)
233{
234 if (str)
235 strlcpy(real6410_features_str, str,
236 sizeof(real6410_features_str));
237 return 1;
238}
239
240__setup("real6410=", real6410_features_setup);
241
242#define FEATURE_SCREEN (1 << 0)
243
244struct real6410_features_t {
245 int done;
246 int lcd_index;
247};
248
249static void real6410_parse_features(
250 struct real6410_features_t *features,
251 const char *features_str)
252{
253 const char *fp = features_str;
254
255 features->done = 0;
256 features->lcd_index = 0;
257
258 while (*fp) {
259 char f = *fp++;
260
261 switch (f) {
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);
266 } else {
267 int li = f - '0';
Thomas Abraham884924b2012-03-24 21:58:47 +0530268 if (li >= ARRAY_SIZE(real6410_lcd_pdata))
Darius Augulisc115f67c2010-10-19 13:52:29 +0900269 printk(KERN_INFO "REAL6410: '%c' out "
270 "of range LCD mode\n", f);
271 else {
272 features->lcd_index = li;
273 }
274 }
275 features->done |= FEATURE_SCREEN;
276 break;
277 }
278 }
Darius Auguliseab5cfa2010-07-28 23:03:43 +0300279}
280
281static void __init real6410_machine_init(void)
282{
Darius Augulisff266c02010-08-01 23:38:43 +0300283 u32 cs1;
Darius Augulisc115f67c2010-10-19 13:52:29 +0900284 struct real6410_features_t features = { 0 };
285
286 printk(KERN_INFO "REAL6410: Option string real6410=%s\n",
287 real6410_features_str);
288
289 /* Parse the feature string */
290 real6410_parse_features(&features, real6410_features_str);
291
Darius Augulisc115f67c2010-10-19 13:52:29 +0900292 printk(KERN_INFO "REAL6410: selected LCD display is %dx%d\n",
Thomas Abraham79d3c412012-03-24 21:58:48 +0530293 real6410_lcd_pdata[features.lcd_index].win[0]->xres,
294 real6410_lcd_pdata[features.lcd_index].win[0]->yres);
Darius Augulisc115f67c2010-10-19 13:52:29 +0900295
Thomas Abraham884924b2012-03-24 21:58:47 +0530296 s3c_fb_set_platdata(&real6410_lcd_pdata[features.lcd_index]);
Darius Augulis88fbade2010-10-19 13:52:32 +0900297 s3c_nand_set_platdata(&real6410_nand_info);
Arnd Bergmanna829ae52015-03-02 09:47:23 +0100298 s3c64xx_ts_set_platdata(NULL);
Darius Augulisff266c02010-08-01 23:38:43 +0300299
300 /* configure nCS1 width to 16 bits */
301
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);
309
310 /* set timing for nCS1 suitable for ethernet chip */
311
312 __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) |
Darius Augulis591cd252010-09-09 21:40:22 +0900313 (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);
Darius Augulisff266c02010-08-01 23:38:43 +0300319
Darius Augulisc115f67c2010-10-19 13:52:29 +0900320 gpio_request(S3C64XX_GPF(15), "LCD power");
321
Darius Augulisff266c02010-08-01 23:38:43 +0300322 platform_add_devices(real6410_devices, ARRAY_SIZE(real6410_devices));
Darius Auguliseab5cfa2010-07-28 23:03:43 +0300323}
324
325MACHINE_START(REAL6410, "REAL6410")
326 /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
Nicolas Pitre170a5902011-07-05 22:38:17 -0400327 .atag_offset = 0x100,
Arnd Bergmannba279042015-02-27 22:06:58 +0100328 .nr_irqs = S3C64XX_NR_IRQS,
Darius Auguliseab5cfa2010-07-28 23:03:43 +0300329 .init_irq = s3c6410_init_irq,
Darius Auguliseab5cfa2010-07-28 23:03:43 +0300330 .map_io = real6410_map_io,
331 .init_machine = real6410_machine_init,
Krzysztof Kozlowskia1342f62020-08-20 22:42:03 +0200332 .init_time = s3c64xx_timer_init,
Darius Auguliseab5cfa2010-07-28 23:03:43 +0300333MACHINE_END