Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* linux/include/asm-arm/arch-s3c2410/system.h |
| 2 | * |
Ben Dooks | f056076 | 2006-12-17 19:59:20 +0100 | [diff] [blame] | 3 | * Copyright (c) 2003 Simtec Electronics |
| 4 | * Ben Dooks <ben@simtec.co.uk> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
| 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 Dooks | 3c06cd1 | 2006-09-09 19:44:57 +0100 | [diff] [blame] | 11 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | #include <asm/hardware.h> |
| 14 | #include <asm/io.h> |
| 15 | |
| 16 | #include <asm/arch/map.h> |
| 17 | #include <asm/arch/idle.h> |
Ben Dooks | d4156d5 | 2007-02-15 22:52:15 +0100 | [diff] [blame] | 18 | #include <asm/arch/reset.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Ben Dooks | 531b617 | 2007-07-22 16:05:25 +0100 | [diff] [blame] | 20 | #include <asm/plat-s3c/regs-watchdog.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/arch/regs-clock.h> |
| 22 | |
Ben Dooks | d652074 | 2007-12-23 03:09:31 +0100 | [diff] [blame] | 23 | #include <linux/clk.h> |
| 24 | #include <linux/err.h> |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | void (*s3c24xx_idle)(void); |
Ben Dooks | d4156d5 | 2007-02-15 22:52:15 +0100 | [diff] [blame] | 27 | void (*s3c24xx_reset_hook)(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
| 29 | void s3c24xx_default_idle(void) |
| 30 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | unsigned long tmp; |
| 32 | int i; |
| 33 | |
| 34 | /* idle the system by using the idle mode which will wait for an |
| 35 | * interrupt to happen before restarting the system. |
| 36 | */ |
| 37 | |
| 38 | /* Warning: going into idle state upsets jtag scanning */ |
| 39 | |
Matt Reimer | b05f871 | 2007-02-12 20:42:52 +0100 | [diff] [blame] | 40 | __raw_writel(__raw_readl(S3C2410_CLKCON) | S3C2410_CLKCON_IDLE, |
| 41 | S3C2410_CLKCON); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
| 43 | /* the samsung port seems to do a loop and then unset idle.. */ |
| 44 | for (i = 0; i < 50; i++) { |
Matt Reimer | b05f871 | 2007-02-12 20:42:52 +0100 | [diff] [blame] | 45 | tmp += __raw_readl(S3C2410_CLKCON); /* ensure loop not optimised out */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | /* this bit is not cleared on re-start... */ |
| 49 | |
Matt Reimer | b05f871 | 2007-02-12 20:42:52 +0100 | [diff] [blame] | 50 | __raw_writel(__raw_readl(S3C2410_CLKCON) & ~S3C2410_CLKCON_IDLE, |
| 51 | S3C2410_CLKCON); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | static void arch_idle(void) |
| 55 | { |
| 56 | if (s3c24xx_idle != NULL) |
| 57 | (s3c24xx_idle)(); |
| 58 | else |
| 59 | s3c24xx_default_idle(); |
| 60 | } |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | static void |
| 63 | arch_reset(char mode) |
| 64 | { |
Ben Dooks | d652074 | 2007-12-23 03:09:31 +0100 | [diff] [blame] | 65 | struct clk *wdtclk; |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | if (mode == 's') { |
| 68 | cpu_reset(0); |
| 69 | } |
| 70 | |
Ben Dooks | d4156d5 | 2007-02-15 22:52:15 +0100 | [diff] [blame] | 71 | if (s3c24xx_reset_hook) |
| 72 | s3c24xx_reset_hook(); |
| 73 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | printk("arch_reset: attempting watchdog reset\n"); |
| 75 | |
| 76 | __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ |
| 77 | |
Ben Dooks | d652074 | 2007-12-23 03:09:31 +0100 | [diff] [blame] | 78 | wdtclk = clk_get(NULL, "watchdog"); |
| 79 | if (!IS_ERR(wdtclk)) { |
| 80 | clk_enable(wdtclk); |
| 81 | } else |
| 82 | printk(KERN_WARNING "%s: warning: cannot get watchdog clock\n", __func__); |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | /* put initial values into count and data */ |
Ben Dooks | ff44b49 | 2007-12-23 03:09:32 +0100 | [diff] [blame] | 85 | __raw_writel(0x80, S3C2410_WTCNT); |
| 86 | __raw_writel(0x80, S3C2410_WTDAT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | /* set the watchdog to go and reset... */ |
| 89 | __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN | |
Ben Dooks | 32d2dee | 2006-12-07 23:53:21 +0100 | [diff] [blame] | 90 | S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
| 92 | /* wait for reset to assert... */ |
Ben Dooks | ff44b49 | 2007-12-23 03:09:32 +0100 | [diff] [blame] | 93 | mdelay(500); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
| 95 | printk(KERN_ERR "Watchdog reset failed to assert reset\n"); |
| 96 | |
Ben Dooks | ff44b49 | 2007-12-23 03:09:32 +0100 | [diff] [blame] | 97 | /* delay to allow the serial port to show the message */ |
| 98 | mdelay(50); |
| 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | /* we'll take a jump through zero as a poor second */ |
| 101 | cpu_reset(0); |
| 102 | } |