lkml.org 
[lkml]   [2020]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] soc: keembay: Add Keem Bay IMR driver
Date
From: Daniele Alessandrelli <daniele.alessandrelli@intel.com>

Keem Bay bootloader sets up a temporary Isolated Memory Region (IMR) to
protect itself during pre-Linux boot.

This temporary IMR remains active even when control is passed to the
Linux Kernel. It is Kernel responsibility to remove such an IMR during
initialization.

This driver adds such functionality.

The driver is loaded during `early_init`, which should ensure that the
IMR is removed before devices that may try to access the IMR are
initialized.

Signed-off-by: Daniele Alessandrelli <daniele.alessandrelli@intel.com>
---
MAINTAINERS | 5 ++++
drivers/soc/Kconfig | 1 +
drivers/soc/Makefile | 1 +
drivers/soc/keembay/Kconfig | 22 +++++++++++++++++
drivers/soc/keembay/Makefile | 5 ++++
drivers/soc/keembay/keembay-imr.c | 40 +++++++++++++++++++++++++++++++
6 files changed, 74 insertions(+)
create mode 100644 drivers/soc/keembay/Kconfig
create mode 100644 drivers/soc/keembay/Makefile
create mode 100644 drivers/soc/keembay/keembay-imr.c

diff --git a/MAINTAINERS b/MAINTAINERS
index b816a453b10e..59f1923a0f25 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9194,6 +9194,11 @@ S: Maintained
W: http://lse.sourceforge.net/kdump/
F: Documentation/admin-guide/kdump/

+KEEMBAY IMR
+M: Daniele Alessandrelli <daniele.alessandrelli@intel.com>
+S: Maintained
+F: drivers/soc/keembay/keembay-imr.c
+
KEENE FM RADIO TRANSMITTER DRIVER
M: Hans Verkuil <hverkuil@xs4all.nl>
L: linux-media@vger.kernel.org
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 425ab6f7e375..eeeba3ef7338 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -9,6 +9,7 @@ source "drivers/soc/bcm/Kconfig"
source "drivers/soc/fsl/Kconfig"
source "drivers/soc/imx/Kconfig"
source "drivers/soc/ixp4xx/Kconfig"
+source "drivers/soc/keembay/Kconfig"
source "drivers/soc/mediatek/Kconfig"
source "drivers/soc/qcom/Kconfig"
source "drivers/soc/renesas/Kconfig"
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index 36452bed86ef..65c981207283 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -13,6 +13,7 @@ obj-y += fsl/
obj-$(CONFIG_ARCH_GEMINI) += gemini/
obj-y += imx/
obj-$(CONFIG_ARCH_IXP4XX) += ixp4xx/
+obj-y += keembay/
obj-$(CONFIG_SOC_XWAY) += lantiq/
obj-y += mediatek/
obj-y += amlogic/
diff --git a/drivers/soc/keembay/Kconfig b/drivers/soc/keembay/Kconfig
new file mode 100644
index 000000000000..2161bce131b3
--- /dev/null
+++ b/drivers/soc/keembay/Kconfig
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Keem Bay SoC drivers.
+#
+
+menu "Keem Bay SoC drivers"
+
+config KEEMBAY_IMR
+ bool "Clean-up Keem Bay bootloader IMR at boot"
+ depends on ARM64
+ help
+ This option makes the Kernel clean up the Isolated Memory Region
+ (IMR) set up by Keem Bay bootloader (U-boot) to protect itself during
+ early boot.
+
+ The IMR number to be cleaned up is taken from the device tree
+ (property 'u-boot-imr' of the 'chosen' node).
+
+ If you are compiling the Kernel for a Keem Bay SoC select Y,
+ otherwise select N.
+
+endmenu
diff --git a/drivers/soc/keembay/Makefile b/drivers/soc/keembay/Makefile
new file mode 100644
index 000000000000..dacfdb9f5fc1
--- /dev/null
+++ b/drivers/soc/keembay/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Makefile for Keem Bay SoC drivers.
+#
+obj-$(CONFIG_KEEMBAY_IMR) += keembay-imr.o
diff --git a/drivers/soc/keembay/keembay-imr.c b/drivers/soc/keembay/keembay-imr.c
new file mode 100644
index 000000000000..eabbdd6e69a7
--- /dev/null
+++ b/drivers/soc/keembay/keembay-imr.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2019-2020 Intel Corporation
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/arm-smccc.h>
+#include <linux/init.h>
+#include <linux/of.h>
+#include <linux/printk.h>
+#include <linux/types.h>
+
+/* Keem Bay SiP SVC for clearing an IMR. */
+#define KMB_SIP_SVC_IMR_CLEAR 0x8200ff13
+
+static int __init clear_imr(u64 imr)
+{
+ struct arm_smccc_res res = { 0 };
+
+ arm_smccc_smc(KMB_SIP_SVC_IMR_CLEAR, imr, 0, 0, 0, 0, 0, 0, &res);
+
+ return res.a0;
+}
+
+static int __init kmb_imr_init(void)
+{
+ u32 imr;
+ int rc;
+
+ rc = of_property_read_u32(of_chosen, "u-boot-imr", &imr);
+ if (rc) {
+ pr_warn("Skipping IMR clean-up: No U-Boot IMR defined in device tree\n");
+ return 0;
+ }
+ pr_info("Disabling Keem Bay U-boot IMR: %u\n", imr);
+
+ return clear_imr(imr);
+}
+early_initcall(kmb_imr_init);
--
2.21.1
\
 
 \ /
  Last update: 2020-04-21 18:37    [W:0.305 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site