OSDN Git Service

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 151
[uclinux-h8/linux.git] / arch / mips / jz4740 / timer.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *  Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
4  *  JZ4740 platform timer support
5  */
6
7 #include <linux/export.h>
8 #include <linux/io.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11
12 #include <asm/mach-jz4740/base.h>
13 #include <asm/mach-jz4740/timer.h>
14
15 void __iomem *jz4740_timer_base;
16 EXPORT_SYMBOL_GPL(jz4740_timer_base);
17
18 void jz4740_timer_enable_watchdog(void)
19 {
20         writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_CLEAR);
21 }
22 EXPORT_SYMBOL_GPL(jz4740_timer_enable_watchdog);
23
24 void jz4740_timer_disable_watchdog(void)
25 {
26         writel(BIT(16), jz4740_timer_base + JZ_REG_TIMER_STOP_SET);
27 }
28 EXPORT_SYMBOL_GPL(jz4740_timer_disable_watchdog);
29
30 void __init jz4740_timer_init(void)
31 {
32         jz4740_timer_base = ioremap(JZ4740_TCU_BASE_ADDR, 0x100);
33
34         if (!jz4740_timer_base)
35                 panic("Failed to ioremap timer registers");
36
37         /* Disable all timer clocks except for those used as system timers */
38         writel(0x000100fc, jz4740_timer_base + JZ_REG_TIMER_STOP_SET);
39
40         /* Timer irqs are unmasked by default, mask them */
41         writel(0x00ff00ff, jz4740_timer_base + JZ_REG_TIMER_MASK_SET);
42 }