diff options
Diffstat (limited to 'arch/arm/mach-at91/sysirq_mask.c')
-rw-r--r-- | arch/arm/mach-at91/sysirq_mask.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/arch/arm/mach-at91/sysirq_mask.c b/arch/arm/mach-at91/sysirq_mask.c new file mode 100644 index 000000000000..2ba694f9626b --- /dev/null +++ b/arch/arm/mach-at91/sysirq_mask.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * sysirq_mask.c - System-interrupt masking | ||
3 | * | ||
4 | * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com> | ||
5 | * | ||
6 | * Functions to disable system interrupts from backup-powered peripherals. | ||
7 | * | ||
8 | * The RTC and RTT-peripherals are generally powered by backup power (VDDBU) | ||
9 | * and are not reset on wake-up, user, watchdog or software reset. This means | ||
10 | * that their interrupts may be enabled during early boot (e.g. after a user | ||
11 | * reset). | ||
12 | * | ||
13 | * As the RTC and RTT share the system-interrupt line with the PIT, an | ||
14 | * interrupt occurring before a handler has been installed would lead to the | ||
15 | * system interrupt being disabled and prevent the system from booting. | ||
16 | * | ||
17 | * This program is free software; you can redistribute it and/or modify | ||
18 | * it under the terms of the GNU General Public License as published by | ||
19 | * the Free Software Foundation; either version 2 of the License, or | ||
20 | * (at your option) any later version. | ||
21 | */ | ||
22 | |||
23 | #include <linux/io.h> | ||
24 | #include <mach/at91_rtt.h> | ||
25 | |||
26 | #include "generic.h" | ||
27 | |||
28 | #define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */ | ||
29 | #define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */ | ||
30 | |||
31 | void __init at91_sysirq_mask_rtc(u32 rtc_base) | ||
32 | { | ||
33 | void __iomem *base; | ||
34 | u32 mask; | ||
35 | |||
36 | base = ioremap(rtc_base, 64); | ||
37 | if (!base) | ||
38 | return; | ||
39 | |||
40 | mask = readl_relaxed(base + AT91_RTC_IMR); | ||
41 | if (mask) { | ||
42 | pr_info("AT91: Disabling rtc irq\n"); | ||
43 | writel_relaxed(mask, base + AT91_RTC_IDR); | ||
44 | (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */ | ||
45 | } | ||
46 | |||
47 | iounmap(base); | ||
48 | } | ||
49 | |||
50 | void __init at91_sysirq_mask_rtt(u32 rtt_base) | ||
51 | { | ||
52 | void __iomem *base; | ||
53 | void __iomem *reg; | ||
54 | u32 mode; | ||
55 | |||
56 | base = ioremap(rtt_base, 16); | ||
57 | if (!base) | ||
58 | return; | ||
59 | |||
60 | reg = base + AT91_RTT_MR; | ||
61 | |||
62 | mode = readl_relaxed(reg); | ||
63 | if (mode & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)) { | ||
64 | pr_info("AT91: Disabling rtt irq\n"); | ||
65 | mode &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN); | ||
66 | writel_relaxed(mode, reg); | ||
67 | (void)readl_relaxed(reg); /* flush */ | ||
68 | } | ||
69 | |||
70 | iounmap(base); | ||
71 | } | ||