blob: 2f425d5d8af536d08ca34bf99be9a8f5ab5b7a1a [file] [log] [blame]
Darius Augulise9debd92010-10-21 07:42:29 +09001/* linux/arch/arm/mach-s3c64xx/mach-mini6410.c
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/
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13*/
14
15#include <linux/init.h>
16#include <linux/interrupt.h>
Darius Augulis2abca872010-10-19 16:06:54 +090017#include <linux/fb.h>
Darius Augulise9debd92010-10-21 07:42:29 +090018#include <linux/gpio.h>
19#include <linux/kernel.h>
20#include <linux/list.h>
21#include <linux/dm9000.h>
Darius Augulis1c5d76e2010-10-19 16:04:16 +090022#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h>
Darius Augulise9debd92010-10-21 07:42:29 +090024#include <linux/serial_core.h>
25#include <linux/types.h>
26
Jamie Iles774b51f2011-11-04 01:10:04 +000027#include <asm/hardware/vic.h>
Darius Augulise9debd92010-10-21 07:42:29 +090028#include <asm/mach-types.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>
Darius Augulis2abca872010-10-19 16:06:54 +090034#include <mach/regs-modem.h>
Darius Augulise9debd92010-10-21 07:42:29 +090035#include <mach/regs-srom.h>
Darius Augulise9debd92010-10-21 07:42:29 +090036
Darius Augulisfe894f92010-10-19 16:10:02 +090037#include <plat/adc.h>
Darius Augulise9debd92010-10-21 07:42:29 +090038#include <plat/cpu.h>
39#include <plat/devs.h>
Darius Augulis2abca872010-10-19 16:06:54 +090040#include <plat/fb.h>
Darius Augulis1c5d76e2010-10-19 16:04:16 +090041#include <plat/nand.h>
Darius Augulise9debd92010-10-21 07:42:29 +090042#include <plat/regs-serial.h>
Darius Augulisfe894f92010-10-19 16:10:02 +090043#include <plat/ts.h>
Ajay Kumar49965e62011-07-21 01:23:19 +090044#include <plat/regs-fb-v4.h>
Darius Augulisfe894f92010-10-19 16:10:02 +090045
Darius Augulisbbd7ac62010-10-19 16:09:59 +090046#include <video/platform_lcd.h>
Darius Augulise9debd92010-10-21 07:42:29 +090047
Kukjin Kimb024043b2011-12-22 23:27:42 +010048#include "common.h"
49
Darius Augulis8b8c87d2010-11-16 18:08:50 +090050#define UCON S3C2410_UCON_DEFAULT
Darius Augulise9debd92010-10-21 07:42:29 +090051#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB)
52#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
53
54static struct s3c2410_uartcfg mini6410_uartcfgs[] __initdata = {
55 [0] = {
56 .hwport = 0,
57 .flags = 0,
58 .ucon = UCON,
59 .ulcon = ULCON,
60 .ufcon = UFCON,
61 },
62 [1] = {
63 .hwport = 1,
64 .flags = 0,
65 .ucon = UCON,
66 .ulcon = ULCON,
67 .ufcon = UFCON,
68 },
69 [2] = {
70 .hwport = 2,
71 .flags = 0,
72 .ucon = UCON,
73 .ulcon = ULCON,
74 .ufcon = UFCON,
75 },
76 [3] = {
77 .hwport = 3,
78 .flags = 0,
79 .ucon = UCON,
80 .ulcon = ULCON,
81 .ufcon = UFCON,
82 },
83};
84
85/* DM9000AEP 10/100 ethernet controller */
86
87static struct resource mini6410_dm9k_resource[] = {
88 [0] = {
89 .start = S3C64XX_PA_XM0CSN1,
90 .end = S3C64XX_PA_XM0CSN1 + 1,
91 .flags = IORESOURCE_MEM
92 },
93 [1] = {
94 .start = S3C64XX_PA_XM0CSN1 + 4,
95 .end = S3C64XX_PA_XM0CSN1 + 5,
96 .flags = IORESOURCE_MEM
97 },
98 [2] = {
99 .start = S3C_EINT(7),
100 .end = S3C_EINT(7),
101 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL
102 }
103};
104
105static struct dm9000_plat_data mini6410_dm9k_pdata = {
106 .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
107};
108
109static struct platform_device mini6410_device_eth = {
110 .name = "dm9000",
111 .id = -1,
112 .num_resources = ARRAY_SIZE(mini6410_dm9k_resource),
113 .resource = mini6410_dm9k_resource,
114 .dev = {
115 .platform_data = &mini6410_dm9k_pdata,
116 },
117};
118
Darius Augulis1c5d76e2010-10-19 16:04:16 +0900119static struct mtd_partition mini6410_nand_part[] = {
120 [0] = {
121 .name = "uboot",
122 .size = SZ_1M,
123 .offset = 0,
124 },
125 [1] = {
126 .name = "kernel",
127 .size = SZ_2M,
128 .offset = SZ_1M,
129 },
130 [2] = {
131 .name = "rootfs",
132 .size = MTDPART_SIZ_FULL,
133 .offset = SZ_1M + SZ_2M,
134 },
135};
136
137static struct s3c2410_nand_set mini6410_nand_sets[] = {
138 [0] = {
139 .name = "nand",
140 .nr_chips = 1,
141 .nr_partitions = ARRAY_SIZE(mini6410_nand_part),
142 .partitions = mini6410_nand_part,
143 },
144};
145
146static struct s3c2410_platform_nand mini6410_nand_info = {
147 .tacls = 25,
148 .twrph0 = 55,
149 .twrph1 = 40,
150 .nr_sets = ARRAY_SIZE(mini6410_nand_sets),
151 .sets = mini6410_nand_sets,
152};
153
Thomas Abraham884924b2012-03-24 21:58:47 +0530154static struct s3c_fb_pd_win mini6410_lcd_type0_fb_win = {
Thomas Abraham884924b2012-03-24 21:58:47 +0530155 .max_bpp = 32,
156 .default_bpp = 16,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530157 .xres = 480,
158 .yres = 272,
159};
160
161static struct fb_videomode mini6410_lcd_type0_timing = {
162 /* 4.3" 480x272 */
163 .left_margin = 3,
164 .right_margin = 2,
165 .upper_margin = 1,
166 .lower_margin = 1,
167 .hsync_len = 40,
168 .vsync_len = 1,
169 .xres = 480,
170 .yres = 272,
Darius Augulis2abca872010-10-19 16:06:54 +0900171};
172
Thomas Abraham884924b2012-03-24 21:58:47 +0530173static struct s3c_fb_pd_win mini6410_lcd_type1_fb_win = {
Thomas Abraham884924b2012-03-24 21:58:47 +0530174 .max_bpp = 32,
175 .default_bpp = 16,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530176 .xres = 800,
177 .yres = 480,
178};
179
180static struct fb_videomode mini6410_lcd_type1_timing = {
181 /* 7.0" 800x480 */
182 .left_margin = 8,
183 .right_margin = 13,
184 .upper_margin = 7,
185 .lower_margin = 5,
186 .hsync_len = 3,
187 .vsync_len = 1,
188 .xres = 800,
189 .yres = 480,
Thomas Abraham884924b2012-03-24 21:58:47 +0530190};
191
192static struct s3c_fb_platdata mini6410_lcd_pdata[] __initdata = {
193 {
194 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530195 .vtiming = &mini6410_lcd_type0_timing,
Thomas Abraham884924b2012-03-24 21:58:47 +0530196 .win[0] = &mini6410_lcd_type0_fb_win,
197 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
198 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
199 }, {
200 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
Thomas Abraham79d3c412012-03-24 21:58:48 +0530201 .vtiming = &mini6410_lcd_type1_timing,
Thomas Abraham884924b2012-03-24 21:58:47 +0530202 .win[0] = &mini6410_lcd_type1_fb_win,
203 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
204 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
205 },
206 { },
Darius Augulis2abca872010-10-19 16:06:54 +0900207};
208
Darius Augulisbbd7ac62010-10-19 16:09:59 +0900209static void mini6410_lcd_power_set(struct plat_lcd_data *pd,
210 unsigned int power)
211{
212 if (power)
213 gpio_direction_output(S3C64XX_GPE(0), 1);
214 else
215 gpio_direction_output(S3C64XX_GPE(0), 0);
216}
217
218static struct plat_lcd_data mini6410_lcd_power_data = {
219 .set_power = mini6410_lcd_power_set,
220};
221
222static struct platform_device mini6410_lcd_powerdev = {
223 .name = "platform-lcd",
224 .dev.parent = &s3c_device_fb.dev,
225 .dev.platform_data = &mini6410_lcd_power_data,
226};
227
Darius Augulise9debd92010-10-21 07:42:29 +0900228static struct platform_device *mini6410_devices[] __initdata = {
229 &mini6410_device_eth,
230 &s3c_device_hsmmc0,
231 &s3c_device_hsmmc1,
232 &s3c_device_ohci,
Darius Augulis1c5d76e2010-10-19 16:04:16 +0900233 &s3c_device_nand,
Darius Augulis2abca872010-10-19 16:06:54 +0900234 &s3c_device_fb,
Darius Augulisbbd7ac62010-10-19 16:09:59 +0900235 &mini6410_lcd_powerdev,
Darius Augulisfe894f92010-10-19 16:10:02 +0900236 &s3c_device_adc,
237 &s3c_device_ts,
Darius Augulise9debd92010-10-21 07:42:29 +0900238};
239
240static void __init mini6410_map_io(void)
241{
Darius Augulis2abca872010-10-19 16:06:54 +0900242 u32 tmp;
243
Darius Augulise9debd92010-10-21 07:42:29 +0900244 s3c64xx_init_io(NULL, 0);
245 s3c24xx_init_clocks(12000000);
246 s3c24xx_init_uarts(mini6410_uartcfgs, ARRAY_SIZE(mini6410_uartcfgs));
Darius Augulis2abca872010-10-19 16:06:54 +0900247
248 /* set the LCD type */
249 tmp = __raw_readl(S3C64XX_SPCON);
250 tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
251 tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
252 __raw_writel(tmp, S3C64XX_SPCON);
253
254 /* remove the LCD bypass */
255 tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
256 tmp &= ~MIFPCON_LCD_BYPASS;
257 __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
258}
259
260/*
261 * mini6410_features string
262 *
263 * 0-9 LCD configuration
264 *
265 */
266static char mini6410_features_str[12] __initdata = "0";
267
268static int __init mini6410_features_setup(char *str)
269{
270 if (str)
271 strlcpy(mini6410_features_str, str,
272 sizeof(mini6410_features_str));
273 return 1;
274}
275
276__setup("mini6410=", mini6410_features_setup);
277
278#define FEATURE_SCREEN (1 << 0)
279
280struct mini6410_features_t {
281 int done;
282 int lcd_index;
283};
284
285static void mini6410_parse_features(
286 struct mini6410_features_t *features,
287 const char *features_str)
288{
289 const char *fp = features_str;
290
291 features->done = 0;
292 features->lcd_index = 0;
293
294 while (*fp) {
295 char f = *fp++;
296
297 switch (f) {
298 case '0'...'9': /* tft screen */
299 if (features->done & FEATURE_SCREEN) {
300 printk(KERN_INFO "MINI6410: '%c' ignored, "
301 "screen type already set\n", f);
302 } else {
303 int li = f - '0';
Thomas Abraham884924b2012-03-24 21:58:47 +0530304 if (li >= ARRAY_SIZE(mini6410_lcd_pdata))
Darius Augulis2abca872010-10-19 16:06:54 +0900305 printk(KERN_INFO "MINI6410: '%c' out "
306 "of range LCD mode\n", f);
307 else {
308 features->lcd_index = li;
309 }
310 }
311 features->done |= FEATURE_SCREEN;
312 break;
313 }
314 }
Darius Augulise9debd92010-10-21 07:42:29 +0900315}
316
317static void __init mini6410_machine_init(void)
318{
319 u32 cs1;
Darius Augulis2abca872010-10-19 16:06:54 +0900320 struct mini6410_features_t features = { 0 };
321
322 printk(KERN_INFO "MINI6410: Option string mini6410=%s\n",
323 mini6410_features_str);
324
325 /* Parse the feature string */
326 mini6410_parse_features(&features, mini6410_features_str);
327
Darius Augulis2abca872010-10-19 16:06:54 +0900328 printk(KERN_INFO "MINI6410: selected LCD display is %dx%d\n",
Thomas Abraham79d3c412012-03-24 21:58:48 +0530329 mini6410_lcd_pdata[features.lcd_index].win[0]->xres,
330 mini6410_lcd_pdata[features.lcd_index].win[0]->yres);
Darius Augulise9debd92010-10-21 07:42:29 +0900331
Darius Augulis1c5d76e2010-10-19 16:04:16 +0900332 s3c_nand_set_platdata(&mini6410_nand_info);
Thomas Abraham884924b2012-03-24 21:58:47 +0530333 s3c_fb_set_platdata(&mini6410_lcd_pdata[features.lcd_index]);
Naveen Krishna Chatradhi08047652011-08-19 21:56:10 +0900334 s3c24xx_ts_set_platdata(NULL);
Darius Augulis1c5d76e2010-10-19 16:04:16 +0900335
Darius Augulise9debd92010-10-21 07:42:29 +0900336 /* configure nCS1 width to 16 bits */
337
338 cs1 = __raw_readl(S3C64XX_SROM_BW) &
339 ~(S3C64XX_SROM_BW__CS_MASK << S3C64XX_SROM_BW__NCS1__SHIFT);
340 cs1 |= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT) |
341 (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT) |
342 (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT)) <<
343 S3C64XX_SROM_BW__NCS1__SHIFT;
344 __raw_writel(cs1, S3C64XX_SROM_BW);
345
346 /* set timing for nCS1 suitable for ethernet chip */
347
348 __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) |
349 (6 << S3C64XX_SROM_BCX__TACP__SHIFT) |
350 (4 << S3C64XX_SROM_BCX__TCAH__SHIFT) |
351 (1 << S3C64XX_SROM_BCX__TCOH__SHIFT) |
352 (13 << S3C64XX_SROM_BCX__TACC__SHIFT) |
353 (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) |
354 (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1);
355
Darius Augulis2abca872010-10-19 16:06:54 +0900356 gpio_request(S3C64XX_GPF(15), "LCD power");
357 gpio_request(S3C64XX_GPE(0), "LCD power");
358
Darius Augulise9debd92010-10-21 07:42:29 +0900359 platform_add_devices(mini6410_devices, ARRAY_SIZE(mini6410_devices));
360}
361
362MACHINE_START(MINI6410, "MINI6410")
363 /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
Nicolas Pitre170a5902011-07-05 22:38:17 -0400364 .atag_offset = 0x100,
Darius Augulise9debd92010-10-21 07:42:29 +0900365 .init_irq = s3c6410_init_irq,
Jamie Iles774b51f2011-11-04 01:10:04 +0000366 .handle_irq = vic_handle_irq,
Darius Augulise9debd92010-10-21 07:42:29 +0900367 .map_io = mini6410_map_io,
368 .init_machine = mini6410_machine_init,
369 .timer = &s3c24xx_timer,
Kukjin Kimff84ded2012-01-03 14:03:30 +0100370 .restart = s3c64xx_restart,
Darius Augulise9debd92010-10-21 07:42:29 +0900371MACHINE_END