1 /* linux/arch/arm/mach-s3c2410/mach-jive.c
3 * Copyright 2007 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/interrupt.h>
16 #include <linux/list.h>
17 #include <linux/timer.h>
18 #include <linux/init.h>
19 #include <linux/sysdev.h>
20 #include <linux/serial_core.h>
21 #include <linux/platform_device.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/irq.h>
30 #include <asm/plat-s3c/regs-serial.h>
31 #include <asm/plat-s3c/nand.h>
33 #include <asm/arch/regs-power.h>
34 #include <asm/arch/regs-gpio.h>
35 #include <asm/arch/regs-mem.h>
36 #include <asm/arch/regs-lcd.h>
38 #include <asm/mach-types.h>
40 #include <linux/mtd/mtd.h>
41 #include <linux/mtd/nand.h>
42 #include <linux/mtd/nand_ecc.h>
43 #include <linux/mtd/partitions.h>
45 #include <asm/plat-s3c24xx/clock.h>
46 #include <asm/plat-s3c24xx/devs.h>
47 #include <asm/plat-s3c24xx/cpu.h>
48 #include <asm/plat-s3c24xx/pm.h>
49 #include <asm/plat-s3c24xx/udc.h>
51 static struct map_desc jive_iodesc[] __initdata = {
54 #define UCON S3C2410_UCON_DEFAULT
55 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE
56 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
58 static struct s3c2410_uartcfg jive_uartcfgs[] = {
82 /* Jive flash assignment
84 * 0x00000000-0x00028000 : uboot
85 * 0x00028000-0x0002c000 : uboot env
86 * 0x0002c000-0x00030000 : spare
87 * 0x00030000-0x00200000 : zimage A
88 * 0x00200000-0x01600000 : cramfs A
89 * 0x01600000-0x017d0000 : zimage B
90 * 0x017d0000-0x02bd0000 : cramfs B
91 * 0x02bd0000-0x03fd0000 : yaffs
93 static struct mtd_partition jive_imageA_nand_part[] = {
95 #ifdef CONFIG_MACH_JIVE_SHOW_BOOTLOADER
96 /* Don't allow access to the bootloader from linux */
100 .size = (160 * SZ_1K),
101 .mask_flags = MTD_WRITEABLE, /* force read-only */
107 .offset = (176 * SZ_1K),
108 .size = (16 * SZ_1K),
114 .name = "kernel (ro)",
115 .offset = (192 * SZ_1K),
116 .size = (SZ_2M) - (192 * SZ_1K),
117 .mask_flags = MTD_WRITEABLE, /* force read-only */
121 .size = (20 * SZ_1M),
122 .mask_flags = MTD_WRITEABLE, /* force read-only */
128 .offset = (44 * SZ_1M),
129 .size = (20 * SZ_1M),
132 /* bootloader environment */
135 .offset = (160 * SZ_1K),
136 .size = (16 * SZ_1K),
142 .offset = (22 * SZ_1M),
143 .size = (2 * SZ_1M) - (192 * SZ_1K),
146 .offset = (24 * SZ_1M) - (192*SZ_1K),
147 .size = (20 * SZ_1M),
151 static struct mtd_partition jive_imageB_nand_part[] = {
153 #ifdef CONFIG_MACH_JIVE_SHOW_BOOTLOADER
154 /* Don't allow access to the bootloader from linux */
158 .size = (160 * SZ_1K),
159 .mask_flags = MTD_WRITEABLE, /* force read-only */
165 .offset = (176 * SZ_1K),
166 .size = (16 * SZ_1K),
172 .name = "kernel (ro)",
173 .offset = (22 * SZ_1M),
174 .size = (2 * SZ_1M) - (192 * SZ_1K),
175 .mask_flags = MTD_WRITEABLE, /* force read-only */
179 .offset = (24 * SZ_1M) - (192 * SZ_1K),
180 .size = (20 * SZ_1M),
181 .mask_flags = MTD_WRITEABLE, /* force read-only */
187 .offset = (44 * SZ_1M),
188 .size = (20 * SZ_1M),
191 /* bootloader environment */
194 .offset = (160 * SZ_1K),
195 .size = (16 * SZ_1K),
201 .offset = (192 * SZ_1K),
202 .size = (2 * SZ_1M) - (192 * SZ_1K),
205 .offset = (2 * SZ_1M),
206 .size = (20 * SZ_1M),
210 static struct s3c2410_nand_set jive_nand_sets[] = {
214 .nr_partitions = ARRAY_SIZE(jive_imageA_nand_part),
215 .partitions = jive_imageA_nand_part,
219 static struct s3c2410_platform_nand jive_nand_info = {
220 /* set taken from osiris nand timings, possibly still conservative */
224 .sets = jive_nand_sets,
225 .nr_sets = ARRAY_SIZE(jive_nand_sets),
228 static int __init jive_mtdset(char *options)
230 struct s3c2410_nand_set *nand = &jive_nand_sets[0];
233 if (options == NULL || options[0] == '\0')
236 if (strict_strtoul(options, 10, &set)) {
237 printk(KERN_ERR "failed to parse mtdset=%s\n", options);
243 nand->nr_partitions = ARRAY_SIZE(jive_imageB_nand_part);
244 nand->partitions = jive_imageB_nand_part;
246 /* this is already setup in the nand info */
249 printk(KERN_ERR "Unknown mtd set %ld specified,"
250 "using default.", set);
256 /* parse the mtdset= option given to the kernel command line */
257 __setup("mtdset=", jive_mtdset);
259 static struct platform_device *jive_devices[] __initdata = {
265 &s3c_device_usbgadget,
268 static struct s3c2410_udc_mach_info jive_udc_cfg __initdata = {
269 .vbus_pin = S3C2410_GPG1, /* detect is on GPG1 */
272 /* Jive power management device */
275 static int jive_pm_suspend(struct sys_device *sd, pm_message_t state)
277 /* Write the magic value u-boot uses to check for resume into
278 * the INFORM0 register, and ensure INFORM1 is set to the
279 * correct address to resume from. */
281 __raw_writel(0x2BED, S3C2412_INFORM0);
282 __raw_writel(virt_to_phys(s3c2410_cpu_resume), S3C2412_INFORM1);
287 static int jive_pm_resume(struct sys_device *sd)
289 __raw_writel(0x0, S3C2412_INFORM0);
294 #define jive_pm_suspend NULL
295 #define jive_pm_resume NULL
298 static struct sysdev_class jive_pm_sysclass = {
300 .suspend = jive_pm_suspend,
301 .resume = jive_pm_resume,
304 static struct sys_device jive_pm_sysdev = {
305 .cls = &jive_pm_sysclass,
308 static void __init jive_map_io(void)
310 s3c24xx_init_io(jive_iodesc, ARRAY_SIZE(jive_iodesc));
311 s3c24xx_init_clocks(12000000);
312 s3c24xx_init_uarts(jive_uartcfgs, ARRAY_SIZE(jive_uartcfgs));
315 static void __init jive_machine_init(void)
317 /* register system devices for managing low level suspend */
319 sysdev_class_register(&jive_pm_sysclass);
320 sysdev_register(&jive_pm_sysdev);
322 /* write our sleep configurations for the IO. Pull down all unused
323 * IO, ensure that we have turned off all peripherals we do not
324 * need, and configure the ones we do need. */
328 __raw_writel(S3C2412_SLPCON_IN(0) |
329 S3C2412_SLPCON_PULL(1) |
330 S3C2412_SLPCON_HIGH(2) |
331 S3C2412_SLPCON_PULL(3) |
332 S3C2412_SLPCON_PULL(4) |
333 S3C2412_SLPCON_PULL(5) |
334 S3C2412_SLPCON_PULL(6) |
335 S3C2412_SLPCON_HIGH(7) |
336 S3C2412_SLPCON_PULL(8) |
337 S3C2412_SLPCON_PULL(9) |
338 S3C2412_SLPCON_PULL(10), S3C2412_GPBSLPCON);
342 __raw_writel(S3C2412_SLPCON_PULL(0) |
343 S3C2412_SLPCON_PULL(1) |
344 S3C2412_SLPCON_PULL(2) |
345 S3C2412_SLPCON_PULL(3) |
346 S3C2412_SLPCON_PULL(4) |
347 S3C2412_SLPCON_PULL(5) |
348 S3C2412_SLPCON_LOW(6) |
349 S3C2412_SLPCON_PULL(6) |
350 S3C2412_SLPCON_PULL(7) |
351 S3C2412_SLPCON_PULL(8) |
352 S3C2412_SLPCON_PULL(9) |
353 S3C2412_SLPCON_PULL(10) |
354 S3C2412_SLPCON_PULL(11) |
355 S3C2412_SLPCON_PULL(12) |
356 S3C2412_SLPCON_PULL(13) |
357 S3C2412_SLPCON_PULL(14) |
358 S3C2412_SLPCON_PULL(15), S3C2412_GPCSLPCON);
362 __raw_writel(S3C2412_SLPCON_ALL_PULL, S3C2412_GPDSLPCON);
366 __raw_writel(S3C2412_SLPCON_LOW(0) |
367 S3C2412_SLPCON_LOW(1) |
368 S3C2412_SLPCON_LOW(2) |
369 S3C2412_SLPCON_EINT(3) |
370 S3C2412_SLPCON_EINT(4) |
371 S3C2412_SLPCON_EINT(5) |
372 S3C2412_SLPCON_EINT(6) |
373 S3C2412_SLPCON_EINT(7), S3C2412_GPFSLPCON);
377 __raw_writel(S3C2412_SLPCON_IN(0) |
378 S3C2412_SLPCON_IN(1) |
379 S3C2412_SLPCON_IN(2) |
380 S3C2412_SLPCON_IN(3) |
381 S3C2412_SLPCON_IN(4) |
382 S3C2412_SLPCON_IN(5) |
383 S3C2412_SLPCON_IN(6) |
384 S3C2412_SLPCON_IN(7) |
385 S3C2412_SLPCON_PULL(8) |
386 S3C2412_SLPCON_PULL(9) |
387 S3C2412_SLPCON_IN(10) |
388 S3C2412_SLPCON_PULL(11) |
389 S3C2412_SLPCON_PULL(12) |
390 S3C2412_SLPCON_PULL(13) |
391 S3C2412_SLPCON_IN(14) |
392 S3C2412_SLPCON_PULL(15), S3C2412_GPGSLPCON);
396 __raw_writel(S3C2412_SLPCON_PULL(0) |
397 S3C2412_SLPCON_PULL(1) |
398 S3C2412_SLPCON_PULL(2) |
399 S3C2412_SLPCON_PULL(3) |
400 S3C2412_SLPCON_PULL(4) |
401 S3C2412_SLPCON_PULL(5) |
402 S3C2412_SLPCON_PULL(6) |
403 S3C2412_SLPCON_IN(7) |
404 S3C2412_SLPCON_IN(8) |
405 S3C2412_SLPCON_PULL(9) |
406 S3C2412_SLPCON_IN(10), S3C2412_GPHSLPCON);
408 /* initialise the power management now we've setup everything. */
412 s3c_device_nand.dev.platform_data = &jive_nand_info;
414 /* Turn off suspend on both USB ports, and switch the
415 * selectable USB port to USB device mode. */
417 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
418 S3C2410_MISCCR_USBSUSPND0 |
419 S3C2410_MISCCR_USBSUSPND1, 0x0);
421 s3c24xx_udc_set_platdata(&jive_udc_cfg);
423 platform_add_devices(jive_devices, ARRAY_SIZE(jive_devices));
426 MACHINE_START(JIVE, "JIVE")
427 /* Maintainer: Ben Dooks <ben@fluff.org> */
428 .phys_io = S3C2410_PA_UART,
429 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
430 .boot_params = S3C2410_SDRAM_PA + 0x100,
432 .init_irq = s3c24xx_init_irq,
433 .map_io = jive_map_io,
434 .init_machine = jive_machine_init,
435 .timer = &s3c24xx_timer,