blob: 34f51950b46e86862fd4679bf4e73779a97f6067 [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 = {
155 .win_mode = { /* 4.3" 480x272 */
156 .left_margin = 3,
157 .right_margin = 2,
158 .upper_margin = 1,
159 .lower_margin = 1,
160 .hsync_len = 40,
161 .vsync_len = 1,
162 .xres = 480,
163 .yres = 272,
Darius Augulis2abca872010-10-19 16:06:54 +0900164 },
Thomas Abraham884924b2012-03-24 21:58:47 +0530165 .max_bpp = 32,
166 .default_bpp = 16,
Darius Augulis2abca872010-10-19 16:06:54 +0900167};
168
Thomas Abraham884924b2012-03-24 21:58:47 +0530169static struct s3c_fb_pd_win mini6410_lcd_type1_fb_win = {
170 .win_mode = { /* 7.0" 800x480 */
171 .left_margin = 8,
172 .right_margin = 13,
173 .upper_margin = 7,
174 .lower_margin = 5,
175 .hsync_len = 3,
176 .vsync_len = 1,
177 .xres = 800,
178 .yres = 480,
179 },
180 .max_bpp = 32,
181 .default_bpp = 16,
182};
183
184static struct s3c_fb_platdata mini6410_lcd_pdata[] __initdata = {
185 {
186 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
187 .win[0] = &mini6410_lcd_type0_fb_win,
188 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
189 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
190 }, {
191 .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
192 .win[0] = &mini6410_lcd_type1_fb_win,
193 .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
194 .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
195 },
196 { },
Darius Augulis2abca872010-10-19 16:06:54 +0900197};
198
Darius Augulisbbd7ac62010-10-19 16:09:59 +0900199static void mini6410_lcd_power_set(struct plat_lcd_data *pd,
200 unsigned int power)
201{
202 if (power)
203 gpio_direction_output(S3C64XX_GPE(0), 1);
204 else
205 gpio_direction_output(S3C64XX_GPE(0), 0);
206}
207
208static struct plat_lcd_data mini6410_lcd_power_data = {
209 .set_power = mini6410_lcd_power_set,
210};
211
212static struct platform_device mini6410_lcd_powerdev = {
213 .name = "platform-lcd",
214 .dev.parent = &s3c_device_fb.dev,
215 .dev.platform_data = &mini6410_lcd_power_data,
216};
217
Darius Augulise9debd92010-10-21 07:42:29 +0900218static struct platform_device *mini6410_devices[] __initdata = {
219 &mini6410_device_eth,
220 &s3c_device_hsmmc0,
221 &s3c_device_hsmmc1,
222 &s3c_device_ohci,
Darius Augulis1c5d76e2010-10-19 16:04:16 +0900223 &s3c_device_nand,
Darius Augulis2abca872010-10-19 16:06:54 +0900224 &s3c_device_fb,
Darius Augulisbbd7ac62010-10-19 16:09:59 +0900225 &mini6410_lcd_powerdev,
Darius Augulisfe894f92010-10-19 16:10:02 +0900226 &s3c_device_adc,
227 &s3c_device_ts,
Darius Augulise9debd92010-10-21 07:42:29 +0900228};
229
230static void __init mini6410_map_io(void)
231{
Darius Augulis2abca872010-10-19 16:06:54 +0900232 u32 tmp;
233
Darius Augulise9debd92010-10-21 07:42:29 +0900234 s3c64xx_init_io(NULL, 0);
235 s3c24xx_init_clocks(12000000);
236 s3c24xx_init_uarts(mini6410_uartcfgs, ARRAY_SIZE(mini6410_uartcfgs));
Darius Augulis2abca872010-10-19 16:06:54 +0900237
238 /* set the LCD type */
239 tmp = __raw_readl(S3C64XX_SPCON);
240 tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
241 tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
242 __raw_writel(tmp, S3C64XX_SPCON);
243
244 /* remove the LCD bypass */
245 tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
246 tmp &= ~MIFPCON_LCD_BYPASS;
247 __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
248}
249
250/*
251 * mini6410_features string
252 *
253 * 0-9 LCD configuration
254 *
255 */
256static char mini6410_features_str[12] __initdata = "0";
257
258static int __init mini6410_features_setup(char *str)
259{
260 if (str)
261 strlcpy(mini6410_features_str, str,
262 sizeof(mini6410_features_str));
263 return 1;
264}
265
266__setup("mini6410=", mini6410_features_setup);
267
268#define FEATURE_SCREEN (1 << 0)
269
270struct mini6410_features_t {
271 int done;
272 int lcd_index;
273};
274
275static void mini6410_parse_features(
276 struct mini6410_features_t *features,
277 const char *features_str)
278{
279 const char *fp = features_str;
280
281 features->done = 0;
282 features->lcd_index = 0;
283
284 while (*fp) {
285 char f = *fp++;
286
287 switch (f) {
288 case '0'...'9': /* tft screen */
289 if (features->done & FEATURE_SCREEN) {
290 printk(KERN_INFO "MINI6410: '%c' ignored, "
291 "screen type already set\n", f);
292 } else {
293 int li = f - '0';
Thomas Abraham884924b2012-03-24 21:58:47 +0530294 if (li >= ARRAY_SIZE(mini6410_lcd_pdata))
Darius Augulis2abca872010-10-19 16:06:54 +0900295 printk(KERN_INFO "MINI6410: '%c' out "
296 "of range LCD mode\n", f);
297 else {
298 features->lcd_index = li;
299 }
300 }
301 features->done |= FEATURE_SCREEN;
302 break;
303 }
304 }
Darius Augulise9debd92010-10-21 07:42:29 +0900305}
306
307static void __init mini6410_machine_init(void)
308{
309 u32 cs1;
Darius Augulis2abca872010-10-19 16:06:54 +0900310 struct mini6410_features_t features = { 0 };
311
312 printk(KERN_INFO "MINI6410: Option string mini6410=%s\n",
313 mini6410_features_str);
314
315 /* Parse the feature string */
316 mini6410_parse_features(&features, mini6410_features_str);
317
Darius Augulis2abca872010-10-19 16:06:54 +0900318 printk(KERN_INFO "MINI6410: selected LCD display is %dx%d\n",
Thomas Abraham884924b2012-03-24 21:58:47 +0530319 mini6410_lcd_pdata[features.lcd_index].win[0]->win_mode.xres,
320 mini6410_lcd_pdata[features.lcd_index].win[0]->win_mode.yres);
Darius Augulise9debd92010-10-21 07:42:29 +0900321
Darius Augulis1c5d76e2010-10-19 16:04:16 +0900322 s3c_nand_set_platdata(&mini6410_nand_info);
Thomas Abraham884924b2012-03-24 21:58:47 +0530323 s3c_fb_set_platdata(&mini6410_lcd_pdata[features.lcd_index]);
Naveen Krishna Chatradhi08047652011-08-19 21:56:10 +0900324 s3c24xx_ts_set_platdata(NULL);
Darius Augulis1c5d76e2010-10-19 16:04:16 +0900325
Darius Augulise9debd92010-10-21 07:42:29 +0900326 /* configure nCS1 width to 16 bits */
327
328 cs1 = __raw_readl(S3C64XX_SROM_BW) &
329 ~(S3C64XX_SROM_BW__CS_MASK << S3C64XX_SROM_BW__NCS1__SHIFT);
330 cs1 |= ((1 << S3C64XX_SROM_BW__DATAWIDTH__SHIFT) |
331 (1 << S3C64XX_SROM_BW__WAITENABLE__SHIFT) |
332 (1 << S3C64XX_SROM_BW__BYTEENABLE__SHIFT)) <<
333 S3C64XX_SROM_BW__NCS1__SHIFT;
334 __raw_writel(cs1, S3C64XX_SROM_BW);
335
336 /* set timing for nCS1 suitable for ethernet chip */
337
338 __raw_writel((0 << S3C64XX_SROM_BCX__PMC__SHIFT) |
339 (6 << S3C64XX_SROM_BCX__TACP__SHIFT) |
340 (4 << S3C64XX_SROM_BCX__TCAH__SHIFT) |
341 (1 << S3C64XX_SROM_BCX__TCOH__SHIFT) |
342 (13 << S3C64XX_SROM_BCX__TACC__SHIFT) |
343 (4 << S3C64XX_SROM_BCX__TCOS__SHIFT) |
344 (0 << S3C64XX_SROM_BCX__TACS__SHIFT), S3C64XX_SROM_BC1);
345
Darius Augulis2abca872010-10-19 16:06:54 +0900346 gpio_request(S3C64XX_GPF(15), "LCD power");
347 gpio_request(S3C64XX_GPE(0), "LCD power");
348
Darius Augulise9debd92010-10-21 07:42:29 +0900349 platform_add_devices(mini6410_devices, ARRAY_SIZE(mini6410_devices));
350}
351
352MACHINE_START(MINI6410, "MINI6410")
353 /* Maintainer: Darius Augulis <augulis.darius@gmail.com> */
Nicolas Pitre170a5902011-07-05 22:38:17 -0400354 .atag_offset = 0x100,
Darius Augulise9debd92010-10-21 07:42:29 +0900355 .init_irq = s3c6410_init_irq,
Jamie Iles774b51f2011-11-04 01:10:04 +0000356 .handle_irq = vic_handle_irq,
Darius Augulise9debd92010-10-21 07:42:29 +0900357 .map_io = mini6410_map_io,
358 .init_machine = mini6410_machine_init,
359 .timer = &s3c24xx_timer,
Kukjin Kimff84ded2012-01-03 14:03:30 +0100360 .restart = s3c64xx_restart,
Darius Augulise9debd92010-10-21 07:42:29 +0900361MACHINE_END