blob: 41aeb731c5a0ea93713625606ef722887392987a [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>
18
19#include <asm/arch/regs-watchdog.h>
20#include <asm/arch/regs-clock.h>
21
22void (*s3c24xx_idle)(void);
23
24void s3c24xx_default_idle(void)
25{
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 unsigned long tmp;
27 int i;
28
29 /* idle the system by using the idle mode which will wait for an
30 * interrupt to happen before restarting the system.
31 */
32
33 /* Warning: going into idle state upsets jtag scanning */
34
Matt Reimerb05f8712007-02-12 20:42:52 +010035 __raw_writel(__raw_readl(S3C2410_CLKCON) | S3C2410_CLKCON_IDLE,
36 S3C2410_CLKCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38 /* the samsung port seems to do a loop and then unset idle.. */
39 for (i = 0; i < 50; i++) {
Matt Reimerb05f8712007-02-12 20:42:52 +010040 tmp += __raw_readl(S3C2410_CLKCON); /* ensure loop not optimised out */
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 }
42
43 /* this bit is not cleared on re-start... */
44
Matt Reimerb05f8712007-02-12 20:42:52 +010045 __raw_writel(__raw_readl(S3C2410_CLKCON) & ~S3C2410_CLKCON_IDLE,
46 S3C2410_CLKCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
49static void arch_idle(void)
50{
51 if (s3c24xx_idle != NULL)
52 (s3c24xx_idle)();
53 else
54 s3c24xx_default_idle();
55}
56
57
58static void
59arch_reset(char mode)
60{
61 if (mode == 's') {
62 cpu_reset(0);
63 }
64
65 printk("arch_reset: attempting watchdog reset\n");
66
67 __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */
68
69 /* put initial values into count and data */
70 __raw_writel(0x100, S3C2410_WTCNT);
71 __raw_writel(0x100, S3C2410_WTDAT);
72
73 /* set the watchdog to go and reset... */
74 __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN |
Ben Dooks32d2dee2006-12-07 23:53:21 +010075 S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON);
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
77 /* wait for reset to assert... */
78 mdelay(5000);
79
80 printk(KERN_ERR "Watchdog reset failed to assert reset\n");
81
82 /* we'll take a jump through zero as a poor second */
83 cpu_reset(0);
84}