DistroKit Mailinglist
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: distrokit@pengutronix.de
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [DistroKit] [PATCH 4/4] v7a: lxa-mc1: add new image for -scmi variant
Date: Tue,  2 Jul 2024 14:28:49 +0200	[thread overview]
Message-ID: <20240702122849.4008988-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240702122849.4008988-1-a.fatoum@pengutronix.de>

The SCMI protocol allows normal world OS to request access to clocks,
resets, voltage regulators and more controlled by the secure world.

This replaces silicon provider services with a vendor-independent
interface. We already use this on the STM32MP13, where the SCMI provider
is OP-TEE. This is currently an idiosyncrasy of the STM32MP1 & STM32MP2
platforms and other platforms use TF-A as SCMI provider.

TF-A for STM32MP1 already has SCMI support included out of the box, but
doesn't lock the peripherals against direct normal world use by default.

We can thus test SCMI by just exchanging normal world device tree for
ones that describe access to resources via SCMI. We do this by replacing
the barebox device tree with the SCMI variant and it will take care to
select the SCMI device tree during boot up.

The kernel device trees should eventually be upstreamed.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 configs/platform-v7a/dts/bootstate.dtsi       |  1 +
 .../platform-v7a/dts/stm32mp1-scmi-smc.dtsi   | 49 +++++++++++++++
 .../dts/stm32mp157c-lxa-mc1-scmi.dts          | 63 +++++++++++++++++++
 configs/platform-v7a/platformconfig           |  3 +-
 .../platforms/image-lxa-mc1-scmi.in           | 15 +++++
 .../platform-v7a/rules/barebox-stm32mp.make   |  1 +
 .../rules/image-lxa-mc1-scmi.make             | 34 ++++++++++
 7 files changed, 165 insertions(+), 1 deletion(-)
 create mode 100644 configs/platform-v7a/dts/stm32mp1-scmi-smc.dtsi
 create mode 100644 configs/platform-v7a/dts/stm32mp157c-lxa-mc1-scmi.dts
 create mode 100644 configs/platform-v7a/platforms/image-lxa-mc1-scmi.in
 create mode 100644 configs/platform-v7a/rules/image-lxa-mc1-scmi.make

diff --git a/configs/platform-v7a/dts/bootstate.dtsi b/configs/platform-v7a/dts/bootstate.dtsi
index c0cade1e705b..22041e5cc1c4 100644
--- a/configs/platform-v7a/dts/bootstate.dtsi
+++ b/configs/platform-v7a/dts/bootstate.dtsi
@@ -102,6 +102,7 @@
 
 /** STM32MP1 ******************************************************************/
 #if defined(stm32mp157c_lxa_mc1_dts) || \
+    defined(stm32mp157c_lxa_mc1_scmi_dts) || \
     defined(stm32mp157c_dk2_dts) || \
     defined(stm32mp157c_ev1_dts) || \
     defined(stm32mp135f_dk_dts)
diff --git a/configs/platform-v7a/dts/stm32mp1-scmi-smc.dtsi b/configs/platform-v7a/dts/stm32mp1-scmi-smc.dtsi
new file mode 100644
index 000000000000..590df657e907
--- /dev/null
+++ b/configs/platform-v7a/dts/stm32mp1-scmi-smc.dtsi
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+
+/ {
+	firmware {
+		scmi: scmi {
+			compatible = "arm,scmi-smc";
+			shmem = <&scmi0_shm>;
+			arm,smc-id = <0x82002000>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			scmi_clk: protocol@14 {
+				reg = <0x14>;
+				#clock-cells = <1>;
+			};
+
+			scmi_reset: protocol@16 {
+				reg = <0x16>;
+				#reset-cells = <1>;
+			};
+		};
+	};
+
+	soc {
+		sram@2ffff000 {
+			compatible = "mmio-sram";
+			reg = <0x2ffff000 0x1000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0x2ffff000 0x1000>;
+
+			scmi0_shm: scmi_shm@0 {
+				compatible = "arm,scmi-shmem";
+				reg = <0 0x80>;
+			};
+
+			scmi1_shm: scmi_shm@200 {
+				compatible = "arm,scmi-shmem";
+				reg = <0x200 0x80>;
+			};
+		};
+	};
+};
+
+/delete-node/ &clk_hse;
+/delete-node/ &clk_hsi;
+/delete-node/ &clk_lse;
+/delete-node/ &clk_lsi;
+/delete-node/ &clk_csi;
diff --git a/configs/platform-v7a/dts/stm32mp157c-lxa-mc1-scmi.dts b/configs/platform-v7a/dts/stm32mp157c-lxa-mc1-scmi.dts
new file mode 100644
index 000000000000..b524e49a4cfc
--- /dev/null
+++ b/configs/platform-v7a/dts/stm32mp157c-lxa-mc1-scmi.dts
@@ -0,0 +1,63 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
+#include <st/stm32mp157c-lxa-mc1.dts>
+#include "stm32mp1-scmi-smc.dtsi"
+
+/ {
+	model = "Linux Automation MC-1 SCMI board";
+	compatible = "lxa,stm32mp157c-mc1-scmi", "lxa,stm32mp157c-mc1",
+			   "oct,stm32mp15xx-osd32", "st,stm32mp157";
+
+};
+
+&cpu0 {
+	clocks = <&scmi_clk CK_SCMI_MPU>;
+};
+
+&cpu1 {
+	clocks = <&scmi_clk CK_SCMI_MPU>;
+};
+
+&dsi {
+	clocks = <&rcc DSI_K>, <&scmi_clk CK_SCMI_HSE>, <&rcc DSI_PX>;
+};
+
+&gpioz {
+	clocks = <&scmi_clk CK_SCMI_GPIOZ>;
+};
+
+&hash1 {
+	clocks = <&scmi_clk CK_SCMI_HASH1>;
+	resets = <&scmi_reset RST_SCMI_HASH1>;
+};
+
+&i2c4 {
+	clocks = <&scmi_clk CK_SCMI_I2C4>;
+	resets = <&scmi_reset RST_SCMI_I2C4>;
+};
+
+&iwdg2 {
+	clocks = <&rcc IWDG2>, <&scmi_clk CK_SCMI_LSI>;
+};
+
+&mdma1 {
+	resets = <&scmi_reset RST_SCMI_MDMA>;
+};
+
+&rcc {
+	compatible = "st,stm32mp1-rcc-secure", "syscon";
+	clock-names = "hse", "hsi", "csi", "lse", "lsi";
+	clocks = <&scmi_clk CK_SCMI_HSE>,
+		 <&scmi_clk CK_SCMI_HSI>,
+		 <&scmi_clk CK_SCMI_CSI>,
+		 <&scmi_clk CK_SCMI_LSE>,
+		 <&scmi_clk CK_SCMI_LSI>;
+};
+
+&rng1 {
+	clocks = <&scmi_clk CK_SCMI_RNG1>;
+	resets = <&scmi_reset RST_SCMI_RNG1>;
+};
+
+&rtc {
+	clocks = <&scmi_clk CK_SCMI_RTCAPB>, <&scmi_clk CK_SCMI_RTC>;
+};
diff --git a/configs/platform-v7a/platformconfig b/configs/platform-v7a/platformconfig
index 1ab6e1b61668..57029b39fc37 100644
--- a/configs/platform-v7a/platformconfig
+++ b/configs/platform-v7a/platformconfig
@@ -138,7 +138,7 @@ PTXCONF_KERNEL_IMAGE_Z=y
 PTXCONF_KERNEL_IMAGE="zImage"
 PTXCONF_KERNEL_DTB=y
 PTXCONF_KERNEL_DTS_PATH="${PTXDIST_PLATFORMCONFIG_SUBDIR}/dts:${KERNEL_DIR}/arch/${GENERIC_KERNEL_ARCH}/boot/dts"
-PTXCONF_KERNEL_DTS="ti/omap/am335x-bone.dts ti/omap/am335x-boneblack.dts arm/vexpress-v2p-ca9.dts broadcom/bcm2836-rpi-2-b.dts nxp/imx/imx6q-sabrelite.dts nxp/imx/imx6sx-udoo-neo-full.dts nxp/imx/imx6dl-riotboard.dts nxp/imx/imx6q-nitrogen6x.dts nxp/imx/imx6qp-nitrogen6_max.dts broadcom/bcm2837-rpi-3-b.dts broadcom/bcm2837-rpi-cm3-io3.dts broadcom/bcm2711-rpi-4-b.dts broadcom/bcm2711-rpi-400.dts st/stm32mp157c-dk2.dts st/stm32mp157c-ev1.dts st/stm32mp157c-lxa-mc1.dts st/stm32mp135f-dk.dts microchip/at91-sama5d27_som1_ek.dts at91-sama5d27_giantboard.dts at91-sama5d4_wifx_l1.dts"
+PTXCONF_KERNEL_DTS="ti/omap/am335x-bone.dts ti/omap/am335x-boneblack.dts arm/vexpress-v2p-ca9.dts broadcom/bcm2836-rpi-2-b.dts nxp/imx/imx6q-sabrelite.dts nxp/imx/imx6sx-udoo-neo-full.dts nxp/imx/imx6dl-riotboard.dts nxp/imx/imx6q-nitrogen6x.dts nxp/imx/imx6qp-nitrogen6_max.dts broadcom/bcm2837-rpi-3-b.dts broadcom/bcm2837-rpi-cm3-io3.dts broadcom/bcm2711-rpi-4-b.dts broadcom/bcm2711-rpi-400.dts st/stm32mp157c-dk2.dts st/stm32mp157c-ev1.dts st/stm32mp157c-lxa-mc1.dts stm32mp157c-lxa-mc1-scmi.dts st/stm32mp135f-dk.dts microchip/at91-sama5d27_som1_ek.dts at91-sama5d27_giantboard.dts at91-sama5d4_wifx_l1.dts"
 # PTXCONF_KERNEL_DTBO is not set
 # PTXCONF_KERNEL_CODE_SIGNING is not set
 # PTXCONF_KERNEL_ZSTD is not set
@@ -260,6 +260,7 @@ PTXCONF_IMAGE_KERNEL_INSTALL_EARLY=y
 # PTXCONF_IMAGE_KERNEL_LZOP is not set
 # end of Generate images/linuximage    
 
+PTXCONF_IMAGE_LXA_MC1_SCMI=y
 PTXCONF_IMAGE_LXA_MC1=y
 PTXCONF_IMAGE_RAUC=y
 PTXCONF_IMAGE_RAUC_BUNDLE_VERSION="${PTXDIST_BSP_AUTOVERSION}"
diff --git a/configs/platform-v7a/platforms/image-lxa-mc1-scmi.in b/configs/platform-v7a/platforms/image-lxa-mc1-scmi.in
new file mode 100644
index 000000000000..728ce474c472
--- /dev/null
+++ b/configs/platform-v7a/platforms/image-lxa-mc1-scmi.in
@@ -0,0 +1,15 @@
+## SECTION=image
+
+config IMAGE_LXA_MC1_SCMI
+	tristate
+	select HOST_GENIMAGE
+	select HOST_TF_A
+	select IMAGE_ROOT_EXT
+	select BAREBOX_STM32MP
+	select TF_A
+	prompt "Generate images/lxa-mc1-scmi.hdimg"
+	help
+	  Generate GPT image for the Linux Automation MC-1, but coordinate
+	  control of secure resources like the clock controller with TF-A.
+
+	  If unsure, use the non-SCMI image generated by IMAGE_LXA_MC1.
diff --git a/configs/platform-v7a/rules/barebox-stm32mp.make b/configs/platform-v7a/rules/barebox-stm32mp.make
index e39d7c12dbc9..525886252a24 100644
--- a/configs/platform-v7a/rules/barebox-stm32mp.make
+++ b/configs/platform-v7a/rules/barebox-stm32mp.make
@@ -51,6 +51,7 @@ BAREBOX_STM32MP_FIP_DTBS := \
 	stm32mp157c-dk2.dtb \
 	stm32mp157c-ev1.dtb \
 	stm32mp157c-lxa-mc1.dtb \
+	stm32mp157c-lxa-mc1-scmi.dtb \
 	stm32mp135f-dk.dtb
 
 BAREBOX_STM32MP_IMAGES := $(addprefix $(BAREBOX_STM32MP_BUILD_DIR)/,$(BAREBOX_STM32MP_IMAGES))
diff --git a/configs/platform-v7a/rules/image-lxa-mc1-scmi.make b/configs/platform-v7a/rules/image-lxa-mc1-scmi.make
new file mode 100644
index 000000000000..7dc7863012fa
--- /dev/null
+++ b/configs/platform-v7a/rules/image-lxa-mc1-scmi.make
@@ -0,0 +1,34 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2024 by Ahmad Fatoum <a.fatoum@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+IMAGE_PACKAGES-$(PTXCONF_IMAGE_LXA_MC1_SCMI) += image-lxa-mc1-scmi
+
+IMAGE_LXA_MC1_SCMI_ENV := STM32MP_BOARD=stm32mp157c-lxa-mc1 SCMI=-scmi
+
+#
+# Paths and names
+#
+IMAGE_LXA_MC1_SCMI		:= image-lxa-mc1-scmi
+IMAGE_LXA_MC1_SCMI_DIR		:= $(BUILDDIR)/$(IMAGE_LXA_MC1_SCMI)
+IMAGE_LXA_MC1_SCMI_IMAGE	:= $(IMAGEDIR)/lxa-mc1-scmi.hdimg
+IMAGE_LXA_MC1_SCMI_FILES	:= $(IMAGEDIR)/root.tgz
+IMAGE_LXA_MC1_SCMI_CONFIG	:= stm32mp.config
+
+# ----------------------------------------------------------------------------
+# Image
+# ----------------------------------------------------------------------------
+
+$(IMAGE_LXA_MC1_SCMI_IMAGE):
+	@$(call targetinfo)
+	@$(call image/genimage, IMAGE_LXA_MC1_SCMI)
+	@$(call finish)
+
+# vim: syntax=make
-- 
2.39.2




  parent reply	other threads:[~2024-07-02 12:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02 12:28 [DistroKit] [PATCH 1/4] v7a: barebox: update to v2024.07.0 Ahmad Fatoum
2024-07-02 12:28 ` [DistroKit] [PATCH 2/4] v7a: barebox: derive stable MAC address from machine ID Ahmad Fatoum
2024-07-02 12:28 ` [DistroKit] [PATCH 3/4] v7a: images: stm32mp: add support for building SCMI enabled images Ahmad Fatoum
2024-07-02 12:28 ` Ahmad Fatoum [this message]
2024-07-03  9:13 ` [DistroKit] [PATCH 1/4] v7a: barebox: update to v2024.07.0 Robert Schwebel
2024-07-03  9:44   ` Ahmad Fatoum
2024-07-03  9:57     ` Robert Schwebel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240702122849.4008988-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=distrokit@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox