STM32 ETZPC bus controller
Subsystems (2)
v2 cover STM32 ETZPC bus controller
STM32 Extended TrustZone Protection controller act like a firewall on the platform bus. Depending of its configuration devices could be accessible by the TrustZone, the co-processor or the non-secure world. ETZPC configuration could evolve at runtime for example to switch a device from non-secure world to co-processor.
The series introduce 'firewall' helpers to handle the new devices-tree properties. These properties are not dedicated to ETZPC and will be reused for STM32 next generation of bus controller.
version 2:
- fix unit name into st,stm32-etzpc.yaml example and DT
Benjamin Gaignard (5):
dt-bindings: bus: Add firewall bindings
bus: stm32: Introduce firewall controller helpers
dt-bindings: bus: Add STM32 ETZPC firewall controller
bus: stm32: Add stm32 ETZPC firewall bus controller
ARM: dts: stm32: Use ETZPC firewall bus
.../bindings/bus/stm32/firewall-consumer.yaml | 25 ++ .../bindings/bus/stm32/firewall-provider.yaml | 18 ++ .../bindings/bus/stm32/st,stm32-etzpc.yaml | 46 ++++ arch/arm/boot/dts/stm32mp151.dtsi | 7 +- drivers/bus/Kconfig | 2 + drivers/bus/Makefile | 2 + drivers/bus/stm32/Kconfig | 11 + drivers/bus/stm32/Makefile | 2 + drivers/bus/stm32/firewall.c | 266 +++++++++++++++++++++ drivers/bus/stm32/firewall.h | 75 ++++++ drivers/bus/stm32/stm32-etzpc.c | 160 +++++++++++++ include/dt-bindings/bus/stm32/stm32-etzpc.h | 90 +++++++ 12 files changed, 702 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml create mode 100644 Documentation/devicetree/bindings/bus/stm32/firewall-provider.yaml create mode 100644 Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml create mode 100644 drivers/bus/stm32/Kconfig create mode 100644 drivers/bus/stm32/Makefile create mode 100644 drivers/bus/stm32/firewall.c create mode 100644 drivers/bus/stm32/firewall.h create mode 100644 drivers/bus/stm32/stm32-etzpc.c create mode 100644 include/dt-bindings/bus/stm32/stm32-etzpc.h
Signature · 1 line
2.15.0
PATCH v2 1/5 dt-bindings: bus: Add firewall bindings
Add schemas for firewall consumer and provider.
--- .../bindings/bus/stm32/firewall-consumer.yaml | 25 ++++++++++++++++++++++ .../bindings/bus/stm32/firewall-provider.yaml | 18 ++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml create mode 100644 Documentation/devicetree/bindings/bus/stm32/firewall-provider.yaml
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +25 -0
@@ -0,0 +1,25 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bus/stm32/firewall-consumer.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Common Bus Firewall consumer binding + +maintainers: + - Benjamin Gaignard <[email protected]> + +# always select the core schema +select: true + +properties: + firewall-0: true + + firewall-names: true + +patternProperties: + "firewall-[0-9]": + $ref: "/schemas/types.yaml#/definitions/phandle-array" + +dependencies: + firewall-names: [ firewall-0 ]
Documentation/devicetree/bindings/bus/stm32/firewall-provider.yaml new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bus/stm32/firewall-provider.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Common Bus Firewall provider binding + +maintainers: + - Benjamin Gaignard <[email protected]> + +properties: + '#firewall-cells': + $ref: /schemas/types.yaml#/definitions/uint32 + description: Number of cells in a bus firewall specifier + +required: + - '#firewall-cells'
Signature · 1 line
2.15.0
PATCH v2 2/5 bus: stm32: Introduce firewall controller helpers
In reply to Benjamin GaignardThe goal of these helpers are to offer an interface for the hardware blocks controlling bus accesses rights.
Bus firewall controllers are typically used to control if a hardware block can perform read or write operations on bus.
Smarter firewall controllers could be able to define accesses rights per hardware blocks to control where they can read or write.
Firewall controller configurations are provided in device node, parsed by the helpers and send to the driver to apply them. Each controller may need different number and type of inputs to configure the firewall so device-tree properties size have to be define by using "#firewall-cells".
Firewall configurations properties have to be named "firewall-X" on device node.
"firewall-names" keyword can also be used to give a name to a specific configuration.
Example of device-tree:
ctrl0: firewall@0 {
#firewall-cells = <2>;
};foo: foo@0 {
firewall-names = "default", "setting1";
firewall-0 = <&ctrl0 1 2>;
firewall-1 = <&ctrl0 3 4>;
};Configurations could be applied with functions like firewall_set_config_by_index() or firewall_set_config_by_name().
firewall_set_default_config() function will apply the configuration named "default" (if existing) or the configuration with index 0 (i.e. firewall-0).
Drivers could register/unregister themselves be calling firewall_register/firewall_unregister functions.
--- drivers/bus/Kconfig | 2 + drivers/bus/Makefile | 2 + drivers/bus/stm32/Kconfig | 3 + drivers/bus/stm32/Makefile | 1 + drivers/bus/stm32/firewall.c | 266 +++++++++++++++++++++++++++++++++++++++++++ drivers/bus/stm32/firewall.h | 75 ++++++++++++ 6 files changed, 349 insertions(+) create mode 100644 drivers/bus/stm32/Kconfig create mode 100644 drivers/bus/stm32/Makefile create mode 100644 drivers/bus/stm32/firewall.c create mode 100644 drivers/bus/stm32/firewall.h
drivers/bus/Kconfig +2 -0
@@ -203,4 +203,6 @@ config DA8XX_MSTPRI source "drivers/bus/fsl-mc/Kconfig" source "drivers/bus/mhi/Kconfig" +source "drivers/bus/stm32/Kconfig" + endmenu
drivers/bus/Makefile +2 -0
@@ -37,3 +37,5 @@ obj-$(CONFIG_DA8XX_MSTPRI) += da8xx-mstpri.o # MHI obj-$(CONFIG_MHI_BUS) += mhi/ + +obj-$(CONFIG_MACH_STM32MP157) += stm32/
drivers/bus/stm32/Kconfig new file +3 -0
@@ -0,0 +1,3 @@ +config FIREWALL_CONTROLLERS + bool "Support of bus firewall controllers" + depends on OF
drivers/bus/stm32/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_FIREWALL_CONTROLLERS) += firewall.o
drivers/bus/stm32/firewall.c new file +266 -0
266 lines not on this page · raw message
drivers/bus/stm32/firewall.h new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
2.15.0
PATCH v2 3/5 dt-bindings: bus: Add STM32 ETZPC firewall controller
In reply to Benjamin GaignardDocument STM32 ETZPC firewall controller bindings
---
version 2:
- fix unit name into st,stm32-etzpc.yaml example
.../bindings/bus/stm32/st,stm32-etzpc.yaml | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml
Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml new file +46 -0
@@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bus/stm32/st,stm32-etzpc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STM32 Extended TrustZone Protection controller + +maintainers: + - Benjamin Gaignard <[email protected]> + +description: STMicroelectronics's STM32 firewall bus controller implementation + +allOf: + - $ref: "firewall-provider.yaml#" + - $ref: /schemas/simple-bus.yaml# + +properties: + compatible: + contains: + enum: + - st,stm32-etzpc-bus + + reg: + maxItems: 1 + + '#firewall-cells': + const: 2 + +required: + - compatible + - reg + - '#firewall-cells' + +examples: + - | + soc@5c007000 { + compatible = "st,stm32-etzpc-bus", "simple-bus"; + reg = <0x5c007000 0x400>; + #firewall-cells = <2>; + #address-cells = <1>; + #size-cells = <1>; + ranges; + }; + +...
Signature · 7 lines
2.15.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 4/5 bus: stm32: Add stm32 ETZPC firewall bus controller
In reply to Benjamin GaignardAdd STM32 Extended TrustZone Protection bus controller. For each of device-tree nodes it will check and apply firewall configuration. If it doesn't match the device will not be probed by platform bus.
A device could be configured to be accessible by trusted world, co-processor or non-secure world.
--- drivers/bus/stm32/Kconfig | 8 ++ drivers/bus/stm32/Makefile | 1 + drivers/bus/stm32/stm32-etzpc.c | 160 ++++++++++++++++++++++++++++ include/dt-bindings/bus/stm32/stm32-etzpc.h | 90 ++++++++++++++++ 4 files changed, 259 insertions(+) create mode 100644 drivers/bus/stm32/stm32-etzpc.c create mode 100644 include/dt-bindings/bus/stm32/stm32-etzpc.h
drivers/bus/stm32/Kconfig +8 -0
@@ -1,3 +1,11 @@ config FIREWALL_CONTROLLERS bool "Support of bus firewall controllers" depends on OF + +config STM32_ETZPC + bool "STM32 ETZPC bus controller" + depends on MACH_STM32MP157 + select FIREWALL_CONTROLLERS + help + Select y to enable STM32 Extended TrustZone Protection + Controller (ETZPC)
drivers/bus/stm32/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_FIREWALL_CONTROLLERS) += firewall.o +obj-$(CONFIG_STM32_ETZPC) += stm32-etzpc.o
drivers/bus/stm32/stm32-etzpc.c new file +160 -0
160 lines not on this page · raw message
include/dt-bindings/bus/stm32/stm32-etzpc.h new file +90 -0
90 lines not on this page · raw message
Signature · 7 lines
2.15.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 5/5 ARM: dts: stm32: Use ETZPC firewall bus
In reply to Benjamin GaignardAllow STM32 ETZPC to check firewall configuration before populating the platform bus.
---
version 2:
- fix unit name in soc node
arch/arm/boot/dts/stm32mp151.dtsi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/boot/dts/stm32mp151.dtsi +5 -2
@@ -4,6 +4,7 @@ * Author: Ludovic Barre <[email protected]> for STMicroelectronics. */ #include <dt-bindings/interrupt-controller/arm-gic.h> +#include <dt-bindings/bus/stm32/stm32-etzpc.h> #include <dt-bindings/clock/stm32mp1-clks.h> #include <dt-bindings/reset/stm32mp1-resets.h>
@@ -110,8 +111,10 @@ status = "disabled"; }; - soc { - compatible = "simple-bus"; + etzpc_bus: soc@5c007000 { + compatible = "st,stm32-etzpc-bus", "simple-bus"; + reg = <0x5c007000 0x400>; + #firewall-cells = <2>; #address-cells = <1>; #size-cells = <1>; interrupt-parent = <&intc>;
Signature · 1 line
2.15.0