rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| 7 | * option) any later version. |
| 8 | * |
| 9 | * You should have received a copy of the GNU General Public License along |
| 10 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 11 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #include <linux/clk.h> |
| 16 | #include <linux/io.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/pm.h> |
| 19 | |
| 20 | #include <asm/reboot.h> |
| 21 | |
| 22 | #include <asm/mach-jz4740/base.h> |
| 23 | #include <asm/mach-jz4740/timer.h> |
| 24 | |
| 25 | #include "reset.h" |
| 26 | #include "clock.h" |
| 27 | |
| 28 | static void jz4740_halt(void) |
| 29 | { |
| 30 | while (1) { |
| 31 | __asm__(".set push;\n" |
| 32 | ".set mips3;\n" |
| 33 | "wait;\n" |
| 34 | ".set pop;\n" |
| 35 | ); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | #define JZ_REG_WDT_DATA 0x00 |
| 40 | #define JZ_REG_WDT_COUNTER_ENABLE 0x04 |
| 41 | #define JZ_REG_WDT_COUNTER 0x08 |
| 42 | #define JZ_REG_WDT_CTRL 0x0c |
| 43 | |
| 44 | static void jz4740_restart(char *command) |
| 45 | { |
| 46 | void __iomem *wdt_base = ioremap(JZ4740_WDT_BASE_ADDR, 0x0f); |
| 47 | |
| 48 | jz4740_timer_enable_watchdog(); |
| 49 | |
| 50 | writeb(0, wdt_base + JZ_REG_WDT_COUNTER_ENABLE); |
| 51 | |
| 52 | writew(0, wdt_base + JZ_REG_WDT_COUNTER); |
| 53 | writew(0, wdt_base + JZ_REG_WDT_DATA); |
| 54 | writew(BIT(2), wdt_base + JZ_REG_WDT_CTRL); |
| 55 | |
| 56 | writeb(1, wdt_base + JZ_REG_WDT_COUNTER_ENABLE); |
| 57 | jz4740_halt(); |
| 58 | } |
| 59 | |
| 60 | void jz4740_reset_init(void) |
| 61 | { |
| 62 | _machine_restart = jz4740_restart; |
| 63 | _machine_halt = jz4740_halt; |
| 64 | } |