Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / arm / mach-at91 / sysirq_mask.c
blobf8bc3511a8c8b49c82084a21593e74ffbfa6ccd6
1 /*
2 * sysirq_mask.c - System-interrupt masking
4 * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com>
6 * Functions to disable system interrupts from backup-powered peripherals.
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).
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.
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.
23 #include <linux/io.h>
24 #include <mach/at91_rtt.h>
26 #include "generic.h"
28 #define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */
29 #define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */
30 #define AT91_RTC_IRQ_MASK 0x1f /* Available IRQs mask */
32 void __init at91_sysirq_mask_rtc(u32 rtc_base)
34 void __iomem *base;
36 base = ioremap(rtc_base, 64);
37 if (!base)
38 return;
41 * sam9x5 SoCs have the following errata:
42 * "RTC: Interrupt Mask Register cannot be used
43 * Interrupt Mask Register read always returns 0."
45 * Hence we're not relying on IMR values to disable
46 * interrupts.
48 writel_relaxed(AT91_RTC_IRQ_MASK, base + AT91_RTC_IDR);
49 (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */
51 iounmap(base);
54 void __init at91_sysirq_mask_rtt(u32 rtt_base)
56 void __iomem *base;
57 void __iomem *reg;
58 u32 mode;
60 base = ioremap(rtt_base, 16);
61 if (!base)
62 return;
64 reg = base + AT91_RTT_MR;
66 mode = readl_relaxed(reg);
67 if (mode & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)) {
68 pr_info("AT91: Disabling rtt irq\n");
69 mode &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
70 writel_relaxed(mode, reg);
71 (void)readl_relaxed(reg); /* flush */
74 iounmap(base);