STM32 ETZPC bus controller
Subsystems (2)
v4 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 4:
- use bus API
version 3:
- add description in firewall consumer bindings
- add Linus reviewed-by tag
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 | 36 +++ .../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 | 251 +++++++++++++++++++++ drivers/bus/stm32/firewall.h | 66 ++++++ drivers/bus/stm32/stm32-etzpc.c | 163 +++++++++++++ include/dt-bindings/bus/stm32/stm32-etzpc.h | 90 ++++++++ 12 files changed, 692 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 v4 1/5 dt-bindings: bus: Add firewall bindings
Add schemas for firewall consumer and provider.
--- .../bindings/bus/stm32/firewall-consumer.yaml | 36 ++++++++++++++++++++++ .../bindings/bus/stm32/firewall-provider.yaml | 18 +++++++++++ 2 files changed, 54 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 +36 -0
@@ -0,0 +1,36 @@ +# 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 + +description: | + Firewall properties provide the possible firewall bus controller + configurations for a device. + Bus firewall controllers are typically used to control if a hardware + block can perform read or write operations on bus. + The contents of the firewall bus configuration properties are defined by + the binding for the individual firewall controller device. + + The first configuration 'firewall-0' or the one named 'default' is + applied before probing the device itself. + +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
Rob Herring
maintainerRe: [PATCH v4 1/5] dt-bindings: bus: Add firewall bindings
Quoted 17 lines · Benjamin Gaignard
Add schemas for firewall consumer and provider.
Signed-off-by Benjamin Gaignard <[email protected]>Reviewed-by Linus Walleij <[email protected]>--- .../bindings/bus/stm32/firewall-consumer.yaml | 36 ++++++++++++++++++++++ .../bindings/bus/stm32/firewall-provider.yaml | 18 +++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml create mode 100644 Documentation/devicetree/bindings/bus/stm32/firewall-provider.yamlDocumentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +0
-0
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml line 7
Quoted 7 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +7
-0@@ -0,0 +1,36 @@ +# 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
I'm all for common bindings, but I want to see more than 1 user before accepting this. There's been some other postings for similar h/w (AFAICT) recently.
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml line 18
Quoted 11 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +11
-0+ +description: | + Firewall properties provide the possible firewall bus controller + configurations for a device. + Bus firewall controllers are typically used to control if a hardware + block can perform read or write operations on bus. + The contents of the firewall bus configuration properties are defined by + the binding for the individual firewall controller device. + + The first configuration 'firewall-0' or the one named 'default' is + applied before probing the device itself.
This is a Linux implementation detail and debatable whether the core should do this or drivers.
Quoted 5 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +5
-0+ +maintainers: + - Benjamin Gaignard <[email protected]> + +# always select the core schema
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml line 33
Quoted 10 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +10
-0+select: true + +properties: + firewall-0: true + + firewall-names: true + +patternProperties: + "firewall-[0-9]": + $ref: "/schemas/types.yaml#/definitions/phandle-array"
So I guess multiple properties is to encode all the modes into DT like pinctrl does. Is that really necessary? I don't think so as I wouldn't expect modes to be defined by the consumer, but by the provider in this case. To use pinctrl as a example, we could have pad setting per MMC speed. That has to be in the consumer side as the pinctrl knows nothing about MMC.
Rob
Re: [PATCH v4 1/5] dt-bindings: bus: Add firewall bindings
Quoted 29 lines · Rob Herring
Quoted 17 lines · Benjamin Gaignard
Add schemas for firewall consumer and provider.
Signed-off-by Benjamin Gaignard <[email protected]>Reviewed-by Linus Walleij <[email protected]>--- .../bindings/bus/stm32/firewall-consumer.yaml | 36 ++++++++++++++++++++++ .../bindings/bus/stm32/firewall-provider.yaml | 18 +++++++++++ 2 files changed, 54 insertions(+)create mode 100644
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yamlcreate mode 100644Documentation/devicetree/bindings/bus/stm32/firewall-provider.yamlDocumentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +0
-0Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml line 7
Quoted 7 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +7
-0@@ -0,0 +1,36 @@ +# 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 bindingI'm all for common bindings, but I want to see more than 1 user before accepting this. There's been some other postings for similar h/w (AFAICT) recently.
Quoted 13 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml line 18
Quoted 11 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +11
-0+ +description: | + Firewall properties provide the possible firewall bus controller + configurations for a device. + Bus firewall controllers are typically used to control if a hardware + block can perform read or write operations on bus. + The contents of the firewall bus configuration properties are defined by + the binding for the individual firewall controller device. + + The first configuration 'firewall-0' or the one named 'default' is + applied before probing the device itself.This is a Linux implementation detail and debatable whether the core should do this or drivers.
I could prefix the property with 'st,stm32' so it will dedicated to STM32 SoCs.
Will it sound better for you ?
From Greg comments in the previous versions of this patch I understand that
it isn't something to be done in the core. The best I can do here is to keep it as
helpers for STM32 SoCs.
Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +13
-0+ +maintainers: + - Benjamin Gaignard <[email protected]> + +# always select the core schema +select: true + +properties: + firewall-0: true + + firewall-names: true + +patternProperties:
Quoted 8 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml line 33
Quoted 2 lines
Documentation/devicetree/bindings/bus/stm32/firewall-consumer.yaml new file +2
-0+ "firewall-[0-9]": + $ref: "/schemas/types.yaml#/definitions/phandle-array"So I guess multiple properties is to encode all the modes into DT like pinctrl does. Is that really necessary? I don't think so as I wouldn't expect modes to be defined by the consumer, but by the provider in this case. To use pinctrl as a example, we could have pad setting per MMC speed. That has to be in the consumer side as the pinctrl knows nothing about MMC.
I expect to be able to set phandle on different firewall controllers. I don't know if it is possible with the same structure than for pins controllers.
Quoted 2 lines
Rob
PATCH v4 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.
---
version 4:
- use bus API
drivers/bus/Kconfig | 2 + drivers/bus/Makefile | 2 + drivers/bus/stm32/Kconfig | 3 + drivers/bus/stm32/Makefile | 1 + drivers/bus/stm32/firewall.c | 251 +++++++++++++++++++++++++++++++++++++++++++ drivers/bus/stm32/firewall.h | 66 ++++++++++++ 6 files changed, 325 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 +251 -0
251 lines not on this page · raw message
drivers/bus/stm32/firewall.h new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.15.0
PATCH v4 3/5 dt-bindings: bus: Add STM32 ETZPC firewall controller
In reply to Benjamin GaignardDocument STM32 ETZPC firewall controller bindings
--- .../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 · 1 line
2.15.0
Rob Herring
maintainerRe: [PATCH v4 3/5] dt-bindings: bus: Add STM32 ETZPC firewall controller
Quoted 20 lines · Benjamin Gaignard
Document STM32 ETZPC firewall controller bindings
Signed-off-by Benjamin Gaignard <[email protected]>--- .../bindings/bus/stm32/st,stm32-etzpc.yaml | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yamlDocumentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml new file +6
-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# +
Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml line 16
Quoted 10 lines
Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml new file +10
-0+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#
Your bus has controls/setup, it's not a simple-bus.
Do you expect an old kernel or one with support for "st,stm32-etzpc-bus" disabled to work? How's it going to know if certain nodes can't be accessed without that support?
Quoted 33 lines
Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml new file +30
-0+ +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 · 1 line
2.15.0
Re: [PATCH v4 3/5] dt-bindings: bus: Add STM32 ETZPC firewall controller
Quoted 33 lines · Rob Herring
Quoted 20 lines · Benjamin Gaignard
Document STM32 ETZPC firewall controller bindings
Signed-off-by Benjamin Gaignard <[email protected]>--- .../bindings/bus/stm32/st,stm32-etzpc.yaml | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+)create mode 100644
Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yamlDocumentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml new file +6
-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# +Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml line 16
Quoted 10 lines
Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml new file +10
-0+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#Your bus has controls/setup, it's not a simple-bus.
Quoted 3 lines
Do you expect an old kernel or one with support for "st,stm32-etzpc-bus" disabled to work? How's it going to know if certain nodes can't be accessed without that support?
It already works with simple bus.
The goal behind implementing firewall bus controllers is to expose this in the DT
rather than hide it in the boot stages.
Quoted 34 lines
Quoted 34 lines
Documentation/devicetree/bindings/bus/stm32/st,stm32-etzpc.yaml new file +30
-0+ +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 · 1 line
2.15.0
PATCH v4 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 | 163 ++++++++++++++++++++++++++++ include/dt-bindings/bus/stm32/stm32-etzpc.h | 90 +++++++++++++++ 4 files changed, 262 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 +163 -0
163 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 · 1 line
2.15.0
PATCH v4 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.
--- 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