1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
4 * JZ4740 platform timer support
7 #include <linux/export.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
12 #include <asm/mach-jz4740/base.h>
13 #include <asm/mach-jz4740/timer.h>
15 void __iomem
*jz4740_timer_base
;
16 EXPORT_SYMBOL_GPL(jz4740_timer_base
);
18 void jz4740_timer_enable_watchdog(void)
20 writel(BIT(16), jz4740_timer_base
+ JZ_REG_TIMER_STOP_CLEAR
);
22 EXPORT_SYMBOL_GPL(jz4740_timer_enable_watchdog
);
24 void jz4740_timer_disable_watchdog(void)
26 writel(BIT(16), jz4740_timer_base
+ JZ_REG_TIMER_STOP_SET
);
28 EXPORT_SYMBOL_GPL(jz4740_timer_disable_watchdog
);
30 void __init
jz4740_timer_init(void)
32 jz4740_timer_base
= ioremap(JZ4740_TCU_BASE_ADDR
, 0x100);
34 if (!jz4740_timer_base
)
35 panic("Failed to ioremap timer registers");
37 /* Disable all timer clocks except for those used as system timers */
38 writel(0x000100fc, jz4740_timer_base
+ JZ_REG_TIMER_STOP_SET
);
40 /* Timer irqs are unmasked by default, mask them */
41 writel(0x00ff00ff, jz4740_timer_base
+ JZ_REG_TIMER_MASK_SET
);