summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/sysirq_mask.c
blob: f8bc3511a8c8b49c82084a21593e74ffbfa6ccd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * sysirq_mask.c - System-interrupt masking
 *
 * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com>
 *
 * Functions to disable system interrupts from backup-powered peripherals.
 *
 * The RTC and RTT-peripherals are generally powered by backup power (VDDBU)
 * and are not reset on wake-up, user, watchdog or software reset. This means
 * that their interrupts may be enabled during early boot (e.g. after a user
 * reset).
 *
 * As the RTC and RTT share the system-interrupt line with the PIT, an
 * interrupt occurring before a handler has been installed would lead to the
 * system interrupt being disabled and prevent the system from booting.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#include <linux/io.h>
#include <mach/at91_rtt.h>

#include "generic.h"

#define AT91_RTC_IDR		0x24	/* Interrupt Disable Register */
#define AT91_RTC_IMR		0x28	/* Interrupt Mask Register */
#define AT91_RTC_IRQ_MASK	0x1f	/* Available IRQs mask */

void __init at91_sysirq_mask_rtc(u32 rtc_base)
{
	void __iomem *base;

	base = ioremap(rtc_base, 64);
	if (!base)
		return;

	/*
	 * sam9x5 SoCs have the following errata:
	 * "RTC: Interrupt Mask Register cannot be used
	 *  Interrupt Mask Register read always returns 0."
	 *
	 * Hence we're not relying on IMR values to disable
	 * interrupts.
	 */
	writel_relaxed(AT91_RTC_IRQ_MASK, base + AT91_RTC_IDR);
	(void)readl_relaxed(base + AT91_RTC_IMR);	/* flush */

	iounmap(base);
}

void __init at91_sysirq_mask_rtt(u32 rtt_base)
{
	void __iomem *base;
	void __iomem *reg;
	u32 mode;

	base = ioremap(rtt_base, 16);
	if (!base)
		return;

	reg = base + AT91_RTT_MR;

	mode = readl_relaxed(reg);
	if (mode & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)) {
		pr_info("AT91: Disabling rtt irq\n");
		mode &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
		writel_relaxed(mode, reg);
		(void)readl_relaxed(reg);			/* flush */
	}

	iounmap(base);
}