blob: 63891786dfa03aa867ca804e13e2b86ea9490b29 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* linux/include/asm-arm/arch-s3c2410/system.h
2 *
Ben Dooksf0560762006-12-17 19:59:20 +01003 * Copyright (c) 2003 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * S3C2410 - System function defines and includes
7 *
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.
Ben Dooks3c06cd12006-09-09 19:44:57 +010011*/
Linus Torvalds1da177e2005-04-16 15:20:36 -070012
13#include <asm/hardware.h>
14#include <asm/io.h>
15
16#include <asm/arch/map.h>
17#include <asm/arch/idle.h>
Ben Dooksd4156d52007-02-15 22:52:15 +010018#include <asm/arch/reset.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
Ben Dooks531b6172007-07-22 16:05:25 +010020#include <asm/plat-s3c/regs-watchdog.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/arch/regs-clock.h>
22
23void (*s3c24xx_idle)(void);
Ben Dooksd4156d52007-02-15 22:52:15 +010024void (*s3c24xx_reset_hook)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26void s3c24xx_default_idle(void)
27{
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 unsigned long tmp;
29 int i;
30
31 /* idle the system by using the idle mode which will wait for an
32 * interrupt to happen before restarting the system.
33 */
34
35 /* Warning: going into idle state upsets jtag scanning */
36
Matt Reimerb05f8712007-02-12 20:42:52 +010037 __raw_writel(__raw_readl(S3C2410_CLKCON) | S3C2410_CLKCON_IDLE,
38 S3C2410_CLKCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40 /* the samsung port seems to do a loop and then unset idle.. */
41 for (i = 0; i < 50; i++) {
Matt Reimerb05f8712007-02-12 20:42:52 +010042 tmp += __raw_readl(S3C2410_CLKCON); /* ensure loop not optimised out */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 }
44
45 /* this bit is not cleared on re-start... */
46
Matt Reimerb05f8712007-02-12 20:42:52 +010047 __raw_writel(__raw_readl(S3C2410_CLKCON) & ~S3C2410_CLKCON_IDLE,
48 S3C2410_CLKCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049}
50
51static void arch_idle(void)
52{
53 if (s3c24xx_idle != NULL)
54 (s3c24xx_idle)();
55 else
56 s3c24xx_default_idle();
57}
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059static void
60arch_reset(char mode)
61{
62 if (mode == 's') {
63 cpu_reset(0);
64 }
65
Ben Dooksd4156d52007-02-15 22:52:15 +010066 if (s3c24xx_reset_hook)
67 s3c24xx_reset_hook();
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 printk("arch_reset: attempting watchdog reset\n");
70
71 __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */
72
73 /* put initial values into count and data */
74 __raw_writel(0x100, S3C2410_WTCNT);
75 __raw_writel(0x100, S3C2410_WTDAT);
76
77 /* set the watchdog to go and reset... */
78 __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN |
Ben Dooks32d2dee2006-12-07 23:53:21 +010079 S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81 /* wait for reset to assert... */
82 mdelay(5000);
83
84 printk(KERN_ERR "Watchdog reset failed to assert reset\n");
85
86 /* we'll take a jump through zero as a poor second */
87 cpu_reset(0);
88}