mach-qt2410.c 7.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/* linux/arch/arm/mach-s3c2410/mach-qt2410.c
 *
 * Copyright (C) 2006 by OpenMoko, Inc.
 * Author: Harald Welte <laforge@openmoko.org>
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 *
 */

#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/init.h>
30
#include <linux/gpio.h>
K
Kay Sievers 已提交
31
#include <linux/device.h>
32 33
#include <linux/platform_device.h>
#include <linux/serial_core.h>
34
#include <linux/serial_s3c.h>
35
#include <linux/spi/spi.h>
36
#include <linux/spi/spi_gpio.h>
37
#include <linux/io.h>
38 39 40 41 42 43 44 45 46
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/nand_ecc.h>
#include <linux/mtd/partitions.h>

#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>

47
#include <mach/hardware.h>
48 49 50
#include <asm/irq.h>
#include <asm/mach-types.h>

51
#include <linux/platform_data/leds-s3c24xx.h>
52
#include <mach/regs-lcd.h>
53
#include <mach/fb.h>
54 55 56
#include <linux/platform_data/mtd-nand-s3c2410.h>
#include <linux/platform_data/usb-s3c2410_udc.h>
#include <linux/platform_data/i2c-s3c2410.h>
57
#include <mach/gpio-samsung.h>
58

59
#include <plat/gpio-cfg.h>
60 61 62
#include <plat/devs.h>
#include <plat/cpu.h>
#include <plat/pm.h>
63
#include <plat/samsung-time.h>
64

65
#include "common.h"
66
#include "common-smdk.h"
67

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
static struct map_desc qt2410_iodesc[] __initdata = {
	{ 0xe0000000, __phys_to_pfn(S3C2410_CS3+0x01000000), SZ_1M, MT_DEVICE }
};

#define UCON S3C2410_UCON_DEFAULT
#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE

static struct s3c2410_uartcfg smdk2410_uartcfgs[] = {
	[0] = {
		.hwport	     = 0,
		.flags	     = 0,
		.ucon	     = UCON,
		.ulcon	     = ULCON,
		.ufcon	     = UFCON,
	},
	[1] = {
		.hwport	     = 1,
		.flags	     = 0,
		.ucon	     = UCON,
		.ulcon	     = ULCON,
		.ufcon	     = UFCON,
	},
	[2] = {
		.hwport	     = 2,
		.flags	     = 0,
		.ucon	     = UCON,
		.ulcon	     = ULCON,
		.ufcon	     = UFCON,
	}
};

/* LCD driver info */

K
Krzysztof Helt 已提交
102 103 104
static struct s3c2410fb_display qt2410_lcd_cfg[] __initdata = {
	{
		/* Configuration for 640x480 SHARP LQ080V3DG01 */
105 106 107 108 109
		.lcdcon5 = S3C2410_LCDCON5_FRM565 |
			   S3C2410_LCDCON5_INVVLINE |
			   S3C2410_LCDCON5_INVVFRAME |
			   S3C2410_LCDCON5_PWREN |
			   S3C2410_LCDCON5_HWSWP,
K
Krzysztof Helt 已提交
110

111
		.type		= S3C2410_LCDCON1_TFT,
K
Krzysztof Helt 已提交
112 113 114
		.width		= 640,
		.height		= 480,

115
		.pixclock	= 40000, /* HCLK/4 */
K
Krzysztof Helt 已提交
116 117 118
		.xres		= 640,
		.yres		= 480,
		.bpp		= 16,
119 120
		.left_margin	= 44,
		.right_margin	= 116,
121
		.hsync_len	= 96,
122 123
		.upper_margin	= 19,
		.lower_margin	= 11,
124
		.vsync_len	= 15,
125
	},
K
Krzysztof Helt 已提交
126 127
	{
		/* Configuration for 480x640 toppoly TD028TTEC1 */
128 129 130 131 132
		.lcdcon5 = S3C2410_LCDCON5_FRM565 |
			   S3C2410_LCDCON5_INVVLINE |
			   S3C2410_LCDCON5_INVVFRAME |
			   S3C2410_LCDCON5_PWREN |
			   S3C2410_LCDCON5_HWSWP,
K
Krzysztof Helt 已提交
133

134
		.type		= S3C2410_LCDCON1_TFT,
K
Krzysztof Helt 已提交
135 136
		.width		= 480,
		.height		= 640,
137
		.pixclock	= 40000, /* HCLK/4 */
K
Krzysztof Helt 已提交
138 139 140
		.xres		= 480,
		.yres		= 640,
		.bpp		= 16,
141 142
		.left_margin	= 8,
		.right_margin	= 24,
143
		.hsync_len	= 8,
144 145
		.upper_margin	= 2,
		.lower_margin	= 4,
146
		.vsync_len	= 2,
147
	},
K
Krzysztof Helt 已提交
148 149
	{
		/* Config for 240x320 LCD */
150 151 152 153 154
		.lcdcon5 = S3C2410_LCDCON5_FRM565 |
			   S3C2410_LCDCON5_INVVLINE |
			   S3C2410_LCDCON5_INVVFRAME |
			   S3C2410_LCDCON5_PWREN |
			   S3C2410_LCDCON5_HWSWP,
K
Krzysztof Helt 已提交
155

156
		.type		= S3C2410_LCDCON1_TFT,
K
Krzysztof Helt 已提交
157 158
		.width		= 240,
		.height		= 320,
159
		.pixclock	= 100000, /* HCLK/10 */
K
Krzysztof Helt 已提交
160 161 162
		.xres		= 240,
		.yres		= 320,
		.bpp		= 16,
163 164
		.left_margin	= 13,
		.right_margin	= 8,
165
		.hsync_len	= 4,
166 167
		.upper_margin	= 2,
		.lower_margin	= 7,
168
		.vsync_len	= 4,
169 170 171 172
	},
};


K
Krzysztof Helt 已提交
173 174 175 176
static struct s3c2410fb_mach_info qt2410_fb_info __initdata = {
	.displays 	= qt2410_lcd_cfg,
	.num_displays 	= ARRAY_SIZE(qt2410_lcd_cfg),
	.default_display = 0,
177 178 179 180 181 182 183

	.lpcsel		= ((0xCE6) & ~7) | 1<<4,
};

/* CS8900 */

static struct resource qt2410_cs89x0_resources[] = {
184 185
	[0] = DEFINE_RES_MEM(0x19000000, 17),
	[1] = DEFINE_RES_IRQ(IRQ_EINT9),
186 187 188 189 190 191 192 193 194 195 196
};

static struct platform_device qt2410_cs89x0 = {
	.name		= "cirrus-cs89x0",
	.num_resources	= ARRAY_SIZE(qt2410_cs89x0_resources),
	.resource	= qt2410_cs89x0_resources,
};

/* LED */

static struct s3c24xx_led_platdata qt2410_pdata_led = {
197
	.gpio		= S3C2410_GPB(0),
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
	.flags		= S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
	.name		= "led",
	.def_trigger	= "timer",
};

static struct platform_device qt2410_led = {
	.name		= "s3c24xx_led",
	.id		= 0,
	.dev		= {
		.platform_data = &qt2410_pdata_led,
	},
};

/* SPI */

213 214 215 216
static struct spi_gpio_platform_data spi_gpio_cfg = {
	.sck		= S3C2410_GPG(7),
	.mosi		= S3C2410_GPG(6),
	.miso		= S3C2410_GPG(5),
217 218 219
};

static struct platform_device qt2410_spi = {
220 221 222
	.name		= "spi-gpio",
	.id		= 1,
	.dev.platform_data = &spi_gpio_cfg,
223 224 225 226 227
};

/* Board devices */

static struct platform_device *qt2410_devices[] __initdata = {
228
	&s3c_device_ohci,
229 230
	&s3c_device_lcd,
	&s3c_device_wdt,
231
	&s3c_device_i2c0,
232 233 234 235 236 237 238 239
	&s3c_device_iis,
	&s3c_device_sdi,
	&s3c_device_usbgadget,
	&qt2410_spi,
	&qt2410_cs89x0,
	&qt2410_led,
};

240
static struct mtd_partition __initdata qt2410_nand_part[] = {
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
	[0] = {
		.name	= "U-Boot",
		.size	= 0x30000,
		.offset	= 0,
	},
	[1] = {
		.name	= "U-Boot environment",
		.offset = 0x30000,
		.size	= 0x4000,
	},
	[2] = {
		.name	= "kernel",
		.offset = 0x34000,
		.size	= SZ_2M,
	},
	[3] = {
		.name	= "initrd",
		.offset	= 0x234000,
		.size	= SZ_4M,
	},
	[4] = {
		.name	= "jffs2",
		.offset = 0x634000,
		.size	= 0x39cc000,
	},
};

268
static struct s3c2410_nand_set __initdata qt2410_nand_sets[] = {
269 270 271 272 273 274 275 276 277 278 279 280
	[0] = {
		.name		= "NAND",
		.nr_chips	= 1,
		.nr_partitions	= ARRAY_SIZE(qt2410_nand_part),
		.partitions	= qt2410_nand_part,
	},
};

/* choose a set of timings which should suit most 512Mbit
 * chips and beyond.
 */

281
static struct s3c2410_platform_nand __initdata qt2410_nand_info = {
282 283 284 285 286
	.tacls		= 20,
	.twrph0		= 60,
	.twrph1		= 20,
	.nr_sets	= ARRAY_SIZE(qt2410_nand_sets),
	.sets		= qt2410_nand_sets,
287
	.ecc_mode       = NAND_ECC_SOFT,
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
};

/* UDC */

static struct s3c2410_udc_mach_info qt2410_udc_cfg = {
};

static char tft_type = 's';

static int __init qt2410_tft_setup(char *str)
{
	tft_type = str[0];
	return 1;
}

__setup("tft=", qt2410_tft_setup);

static void __init qt2410_map_io(void)
{
	s3c24xx_init_io(qt2410_iodesc, ARRAY_SIZE(qt2410_iodesc));
	s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
309
	samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
310 311
}

312 313 314 315 316 317
static void __init qt2410_init_time(void)
{
	s3c2410_init_clocks(12000000);
	samsung_timer_init();
}

318 319
static void __init qt2410_machine_init(void)
{
320
	s3c_nand_set_platdata(&qt2410_nand_info);
321 322 323

	switch (tft_type) {
	case 'p': /* production */
K
Krzysztof Helt 已提交
324
		qt2410_fb_info.default_display = 1;
325 326
		break;
	case 'b': /* big */
K
Krzysztof Helt 已提交
327
		qt2410_fb_info.default_display = 0;
328 329 330
		break;
	case 's': /* small */
	default:
K
Krzysztof Helt 已提交
331
		qt2410_fb_info.default_display = 2;
332 333
		break;
	}
K
Krzysztof Helt 已提交
334
	s3c24xx_fb_set_platdata(&qt2410_fb_info);
335

336 337 338
	/* set initial state of the LED GPIO */
	WARN_ON(gpio_request_one(S3C2410_GPB(0), GPIOF_OUT_INIT_HIGH, NULL));
	gpio_free(S3C2410_GPB(0));
339 340

	s3c24xx_udc_set_platdata(&qt2410_udc_cfg);
341
	s3c_i2c0_set_platdata(NULL);
342

343 344
	WARN_ON(gpio_request(S3C2410_GPB(5), "spi cs"));
	gpio_direction_output(S3C2410_GPB(5), 1);
345

346
	platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices));
347
	s3c_pm_init();
348 349 350
}

MACHINE_START(QT2410, "QT2410")
351
	.atag_offset	= 0x100,
352
	.map_io		= qt2410_map_io,
353
	.init_irq	= s3c2410_init_irq,
354
	.init_machine	= qt2410_machine_init,
355
	.init_time	= qt2410_init_time,
356
MACHINE_END