summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2020-07-01 11:11:07 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-07-11 06:14:04 +0200
commit53d48be1757d379bcdeb94a63deeeea8e9965353 (patch)
tree3b926cc6b321c5c06a9f00a123b1eb06c1896a81 /arch/arm/mach-at91
parentc0edbe48a4e00194cf4490b7c673e6f4a91d251f (diff)
downloadbarebox-53d48be1757d379bcdeb94a63deeeea8e9965353.tar.gz
barebox-53d48be1757d379bcdeb94a63deeeea8e9965353.tar.xz
ARM: at91: add necessary Advanced Interrupt Controller configuration
Without reconfiguration of the AIC redirection, the OS interrupt handling will misbehave later on. Add it to the SoC init. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r--arch/arm/mach-at91/Makefile2
-rw-r--r--arch/arm/mach-at91/aic.c28
-rw-r--r--arch/arm/mach-at91/include/mach/aic.h9
-rw-r--r--arch/arm/mach-at91/sama5d2.c2
4 files changed, 40 insertions, 1 deletions
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 7c8399ee76..254bbeef27 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -1,4 +1,4 @@
-obj-y += setup.o
+obj-y += setup.o aic.o
lwl-y += at91_pmc_ll.o ddramc_ll.o matrix.o
lwl-$(CONFIG_CLOCKSOURCE_ATMEL_PIT) += early_udelay.o
diff --git a/arch/arm/mach-at91/aic.c b/arch/arm/mach-at91/aic.c
new file mode 100644
index 0000000000..b40f1d214b
--- /dev/null
+++ b/arch/arm/mach-at91/aic.c
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: BSD-1-Clause
+/*
+ * Copyright (c) 2015, Atmel Corporation
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ */
+
+#include <mach/aic.h>
+#include <io.h>
+
+#define SFR_AICREDIR 0x54
+#define SFR_SN1 0x50 /* Serial Number 1 Register */
+
+void at91_aic_redir(void __iomem *sfr, u32 key)
+{
+ u32 key32;
+
+ if (readl(sfr + SFR_AICREDIR) & 0x01)
+ return;
+
+ key32 = readl(sfr + SFR_SN1) ^ key;
+ writel(key32 | 0x01, sfr + SFR_AICREDIR);
+ /* bits[31:1] = key */
+ /* bit[0] = 1 => all interrupts redirected to AIC */
+ /* bit[0] = 0 => secure interrupts directed to SAIC,
+ others to AIC (default) */
+}
diff --git a/arch/arm/mach-at91/include/mach/aic.h b/arch/arm/mach-at91/include/mach/aic.h
new file mode 100644
index 0000000000..c1f026b60c
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/aic.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-1-Clause */
+#ifndef __AT91_AIC_H_
+#define __AT91_AIC_H_
+
+#include <linux/compiler.h>
+
+void at91_aic_redir(void __iomem *sfr, u32 key);
+
+#endif
diff --git a/arch/arm/mach-at91/sama5d2.c b/arch/arm/mach-at91/sama5d2.c
index 2f74b0b38d..c498b09645 100644
--- a/arch/arm/mach-at91/sama5d2.c
+++ b/arch/arm/mach-at91/sama5d2.c
@@ -3,6 +3,7 @@
#include <common.h>
#include <of.h>
#include <init.h>
+#include <mach/aic.h>
#include <mach/sama5d2.h>
#include <asm/cache-l2x0.h>
#include <asm/mmu.h>
@@ -44,6 +45,7 @@ static int sama5d2_init(void)
if (!of_machine_is_compatible("atmel,sama5d2"))
return 0;
+ at91_aic_redir(SAMA5D2_BASE_SFR, SAMA5D2_AICREDIR_KEY);
sama5d2_can_ram_init();
sama5d2_l2x0_init();