Skip to contentSkip to conversation

Introduce bus domains controller framework

RFC In review Benjamin Gaignard 3 participants 11 messages Jan 28, 2019 – Feb 18, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Introduce bus domains controller framework

Bus domains controllers allow to divided system on chip into multiple domains that can be used to select by who hardware blocks could be accessed. A domain could be a cluster of CPUs (or coprocessors), a range of addresses or a group of hardware blocks.

Framework architecture is inspirated by pinctrl framework:
- a default configuration could be applied before bind the driver
- configurations could be apllied dynamically by drivers
- device node provides the bus domains configurations

An example of bus domains controller is STM32 ETZPC hardware block which got 3 domains:
- secure: hardware blocks are only accessible by software running on trust zone.
- non-secure: hardware blocks are accessible by non-secure software (i.e. linux kernel).
- coprocessor: hardware blocks are only accessible by the corpocessor. Up to 94 hardware blocks of the soc could be managed by ETZPC and assigned to one of the three domains.

At least two other hardware blocks can take benefits of this:
- ARM TZC-400: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0504c/index.html
which is able to manage up to 8 regions in address space.
- IMX Ressource Domain Controller (RDC): supports four domains and up to eight regions

It is an RFC, comments are welcome to help to create this framework, thanks. Benjamin

Benjamin Gaignard (7):
devicetree: bindings: Document domains controller bindings
domainsctrl: Introduce domains controller framework
base: Add calls to domains controller
devicetree: bindings: domainsctrl: Add STM32 ETZPC bindings
bus: domainsctrl: Add driver for STM32 ETZPC controller
ARM: dts: stm32: Add domainsctrl node for stm32mp157 SoC
ARM: dts: stm32: enable domains controller node on stm32mp157c-ed1

 .../bindings/bus/domains/domainsctrl.txt           |  55 +++++
 .../bindings/bus/domains/st,stm32-etzpc.txt        |  14 ++
 arch/arm/boot/dts/stm32mp157c-ev1.dts              |   2 +
 arch/arm/boot/dts/stm32mp157c.dtsi                 |   7 +
 drivers/base/dd.c                                  |   9 +
 drivers/bus/Kconfig                                |   2 +
 drivers/bus/Makefile                               |   2 +
 drivers/bus/domains/Kconfig                        |  14 ++
 drivers/bus/domains/Makefile                       |   2 +
 drivers/bus/domains/domainsctrl.c                  | 234 +++++++++++++++++++++
 drivers/bus/domains/stm32-etzpc.c                  | 140 ++++++++++++
 include/dt-bindings/bus/domains/stm32-etzpc.h      |  25 +++
 include/linux/domainsctrl.h                        |  70 ++++++
 13 files changed, 576 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/domains/domainsctrl.txt
 create mode 100644 Documentation/devicetree/bindings/bus/domains/st,stm32-etzpc.txt
 create mode 100644 drivers/bus/domains/Kconfig
 create mode 100644 drivers/bus/domains/Makefile
 create mode 100644 drivers/bus/domains/domainsctrl.c
 create mode 100644 drivers/bus/domains/stm32-etzpc.c
 create mode 100644 include/dt-bindings/bus/domains/stm32-etzpc.h
 create mode 100644 include/linux/domainsctrl.h
Signature · 7 lines
2.15.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw

RFC v2 1/7 devicetree: bindings: Document domains controller bindings

Document commons domains controller bindings for controller and client devices.

---
version 2:
- complete rework of bindings description to try to give a better definition of what bus domains could be.

 .../bindings/bus/domains/domainsctrl.txt           | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/domains/domainsctrl.txt
Documentation/devicetree/bindings/bus/domains/domainsctrl.txt new file +55 -0
new file mode 100644
index 000000000000..a3fced91842d
@@ -0,0 +1,55 @@
+Common Domains Controller bindings properties
+
+Bus domains controllers allow to divided system on chip into multiple domains
+that can be used to select by who hardware blocks could be accessed.
+A domain could be a cluster of CPUs (or coprocessors), a range of addresses or
+a group of hardware blocks.
+
+This device tree bindings can be used to bind bus domain consumer devices with
+their bus domains provided by bus domains controllers. A bus domain provider
+can be represented by any node in the device tree and can provide one or more
+bus domains. A consumer node can refer to the provider by a phandle and a set
+of phandle arguments of length specified by the #domainctrl-cells property in
+the bus domain provider node.
+
+==Bus domain provider==
+
+Required properties:
+- #domainctrl-cells	: Number of cells in a bus domain specifier;
+			  Can be any value as specified by device tree binding
+			  documentation of a particular provider.
+
+==Bus domain consumer==
+
+Required properties:
+- domainsctrl-X		: A list of bus domain specifiers, as defined by
+			  bindings of the bus domain controller that is the
+			  bus domain provider.
+
+Optional properties:
+- domainsctrl-names	: A list of bus domain name string sorted in the same
+			  order as the domainsctrl-X proprerties. Consumer
+			  drivers will use domainsctrl-names to match bus
+			  domains with bus domains specifiers.
+  			  Note that "default" and "unbind" are reserved names 
+			  used by the framework.
+
+Example of usage with:
+- a domains controller with a 2 parameters cell
+- a domains controller with a 3 parameters cell
+- a client device node using the both controllers and 2 configurations
+  named "default" and "unbind"
+
+ctrl0: ctrl@0 {
+	#domainctrl-cells = <2>;
+};
+
+ctrl1: ctrl@1 {
+	#domainctrl-cells = <3>;
+};
+
+foo@0 {
+	domains-names = "default", "unbind";
+	domainctrl-0 = <&ctrl0 1 2>, <&ctrl1 3 4 5>;
+	domainctrl-1 = <&ctrl0 6 7>, <&ctrl1 8 9 0>;
+};
Signature · 7 lines
2.15.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw

Re: [RFC v2 1/7] devicetree: bindings: Document domains controller bindings

Quoted 3 lines · Benjamin Gaignard

Document commons domains controller bindings for controller and client devices.

Gentle ping to get comments on those bindings,

Thanks,
Benjamin

Quoted 74 lines

---
version 2:
- complete rework of bindings description to try to give a better definition of what bus domains could be.

 .../bindings/bus/domains/domainsctrl.txt           | 55 ++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/domains/domainsctrl.txt
Documentation/devicetree/bindings/bus/domains/domainsctrl.txt new file +55 -1
new file mode 100644
index 000000000000..a3fced91842d
@@ -0,0 +1,55 @@
+Common Domains Controller bindings properties
+
+Bus domains controllers allow to divided system on chip into multiple domains
+that can be used to select by who hardware blocks could be accessed.
+A domain could be a cluster of CPUs (or coprocessors), a range of addresses or
+a group of hardware blocks.
+
+This device tree bindings can be used to bind bus domain consumer devices with
+their bus domains provided by bus domains controllers. A bus domain provider
+can be represented by any node in the device tree and can provide one or more
+bus domains. A consumer node can refer to the provider by a phandle and a set
+of phandle arguments of length specified by the #domainctrl-cells property in
+the bus domain provider node.
+
+==Bus domain provider==
+
+Required properties:
+- #domainctrl-cells    : Number of cells in a bus domain specifier;
+                         Can be any value as specified by device tree binding
+                         documentation of a particular provider.
+
+==Bus domain consumer==
+
+Required properties:
+- domainsctrl-X                : A list of bus domain specifiers, as defined by
+                         bindings of the bus domain controller that is the
+                         bus domain provider.
+
+Optional properties:
+- domainsctrl-names    : A list of bus domain name string sorted in the same
+                         order as the domainsctrl-X proprerties. Consumer
+                         drivers will use domainsctrl-names to match bus
+                         domains with bus domains specifiers.
+                         Note that "default" and "unbind" are reserved names
+                         used by the framework.
+
+Example of usage with:
+- a domains controller with a 2 parameters cell
+- a domains controller with a 3 parameters cell
+- a client device node using the both controllers and 2 configurations
+  named "default" and "unbind"
+
+ctrl0: ctrl@0 {
+       #domainctrl-cells = <2>;
+};
+
+ctrl1: ctrl@1 {
+       #domainctrl-cells = <3>;
+};
+
+foo@0 {
+       domains-names = "default", "unbind";
+       domainctrl-0 = <&ctrl0 1 2>, <&ctrl1 3 4 5>;
+       domainctrl-1 = <&ctrl0 6 7>, <&ctrl1 8 9 0>;
+};
--

2.15.0

Signature · 7 lines
Benjamin Gaignard

Graphic Study Group

Linaro.org │ Open source software for ARM SoCs

Follow Linaro: Facebook | Twitter | Blog
#3 lore raw

RFC v2 2/7 domainsctrl: Introduce domains controller framework

In reply to Benjamin Gaignard

The goal of this framework is to offer an interface for the hardware blocks controlling bus accesses rights.

Bus domains controllers are typically used to control if a hardware block can perform read or write operations on bus.

Smarter domains controllers could be able to define accesses rights per hardware blocks to control where they can read or write.

Domains controller configurations are provided in device node, parsed by the framework and send to the driver to apply them. Each controller may need different number and type of inputs to configure a domain so device-tree properties size have to be define by using "#domainctrl-cells".
Domains configurations properties have to be named "domainsctrl-X" on device node.
"domainsctrl-names" keyword can also be used to give a name to a specific configuration.

Example of device-tree:

ctrl0: domainsctrl@0 {
	#domainctrl-cells = <2>;
      };
foo: foo@0 {
	domainsctrl-names = "default", "setting1";
	domainsctrl-0 = <&ctrl0 1 2>;
	domainsctrl-1 = <&ctrl0 3 4>;
};

Configurations could be applied with functions like domainsctrl_set_config_by_index() or domainsctrl_set_config_by_name().

domainsctrl_set_default_config() function will apply the configuration named "default" (if existing) or the configuration with index 0 (i.e. domainsctrl-0).

Drivers could register/unregister themselves be calling domainsctrl_register/domainsctrl_unregister functions.

When a configuration has to be applied the driver callback, provided in the ops at registration time, set_config is called by the framework.

---
 drivers/bus/Kconfig               |   2 +
 drivers/bus/Makefile              |   2 +
 drivers/bus/domains/Kconfig       |   7 ++
 drivers/bus/domains/Makefile      |   1 +
 drivers/bus/domains/domainsctrl.c | 234 ++++++++++++++++++++++++++++++++++++++
 include/linux/domainsctrl.h       |  70 ++++++++++++
 6 files changed, 316 insertions(+)
 create mode 100644 drivers/bus/domains/Kconfig
 create mode 100644 drivers/bus/domains/Makefile
 create mode 100644 drivers/bus/domains/domainsctrl.c
 create mode 100644 include/linux/domainsctrl.h
drivers/bus/Kconfig +2 -0
index 1851112ccc29..a0f7a67c1296 100644
@@ -183,4 +183,6 @@ config DA8XX_MSTPRI
 
 source "drivers/bus/fsl-mc/Kconfig"
 
+source "drivers/bus/domains/Kconfig"
+
 endmenu
drivers/bus/Makefile +2 -0
index ca300b1914ce..d7e95edba33d 100644
@@ -32,3 +32,5 @@ obj-$(CONFIG_UNIPHIER_SYSTEM_BUS)	+= uniphier-system-bus.o
 obj-$(CONFIG_VEXPRESS_CONFIG)	+= vexpress-config.o
 
 obj-$(CONFIG_DA8XX_MSTPRI)	+= da8xx-mstpri.o
+
+obj-$(CONFIG_DOMAINS_CONTROLLERS) 	+= domains/
drivers/bus/domains/Kconfig new file +7 -0
new file mode 100644
index 000000000000..5ba15f750bee
@@ -0,0 +1,7 @@
+menu "Bus Domains Controllers"
+
+config DOMAINS_CONTROLLERS
+	bool "Support of bus domains controllers"
+	depends on OF
+
+endmenu
drivers/bus/domains/Makefile new file +1 -0
new file mode 100644
index 000000000000..262338b7cad5
@@ -0,0 +1 @@
+obj-$(CONFIG_DOMAINS_CONTROLLERS) += domainsctrl.o
drivers/bus/domains/domainsctrl.c new file +234 -0

234 lines not on this page · raw message

include/linux/domainsctrl.h new file +70 -0

70 lines not on this page · raw message

Signature · 1 line
2.15.0
#4 lore raw

Re: [RFC v2 2/7] domainsctrl: Introduce domains controller framework

Quoted 2 lines · Benjamin Gaignard

The goal of this framework is to offer an interface for the hardware blocks controlling bus accesses rights.

drivers/bus/domains/domainsctrl.c line 231

Quoted 5 lines
drivers/bus/domains/domainsctrl.c new file +5 -0
+static int __init domainsctrl_init(void)
+{
+	pr_info("initialized bus domain controller subsystem\n");
+	return 0;
+}

Not sure if this print is really helpful? But that's very minor.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

RFC v2 3/7 base: Add calls to domains controller

In reply to Benjamin Gaignard

To avoid modifying all the drivers call domainsctrl_set_default_config before probe to apply the configuration define in device node (if any).

When unbinding the device try to apply configuration named "unbind".

---
 drivers/base/dd.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/base/dd.c +9 -0
index 8ac10af17c00..2880fe893096 100644
@@ -20,6 +20,7 @@
 #include <linux/device.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
+#include <linux/domainsctrl.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/kthread.h>
@@ -478,6 +479,10 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 re_probe:
 	dev->driver = drv;
 
+	ret = domainsctrl_set_default_config(dev);
+	if (ret)
+		goto domainctrl_failed;
+
 	/* If using pinctrl, bind pins now before probing */
 	ret = pinctrl_bind_pins(dev);
 	if (ret)
@@ -548,6 +553,8 @@ static int really_probe(struct device *dev, struct device_driver *drv)
 		blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
 					     BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
 pinctrl_bind_failed:
+	domainsctrl_set_config_by_name(dev, "unbind");
+domainctrl_failed:
 	device_links_no_driver(dev);
 	devres_release_all(dev);
 	driver_sysfs_remove(dev);
@@ -970,6 +977,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
 		device_links_driver_cleanup(dev);
 		arch_teardown_dma_ops(dev);
 
+		domainsctrl_set_config_by_name(dev, "unbind");
+
 		devres_release_all(dev);
 		dev->driver = NULL;
 		dev_set_drvdata(dev, NULL);
Signature · 7 lines
2.15.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#6 lore raw

Re: [RFC v2 3/7] base: Add calls to domains controller

Quoted 2 lines · Benjamin Gaignard

To avoid modifying all the drivers call domainsctrl_set_default_config before probe to apply the configuration define in device node (if any).

#7 lore raw

RFC v2 4/7 devicetree: bindings: domainsctrl: Add STM32 ETZPC bindings

In reply to Benjamin Gaignard

Describe STM32 Extended TrustZone Protection bindings.

---
 .../devicetree/bindings/bus/domains/st,stm32-etzpc.txt     | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/domains/st,stm32-etzpc.txt
Documentation/devicetree/bindings/bus/domains/st,stm32-etzpc.txt new file +14 -0
new file mode 100644
index 000000000000..8f0a990ab59c
@@ -0,0 +1,14 @@
+STMicroelectronics STM32 Extended TrustZone Protection driver
+
+Required properties:
+ - compatible : must be "st,stm32-etzpc"
+ - reg : physical base address of the IP registers and length of memory
+         mapped region.
+ - #domainctrl-cells : must be 2
+
+Example:
+	etzpc@5c007000 {
+		compatible = "st,stm32-etzpc";
+		reg = <0x5c007000 0x400>;
+		#domainctrl-cells = <2>;
+	};
Signature · 1 line
2.15.0
#8 lore raw

RFC v2 5/7 bus: domainsctrl: Add driver for STM32 ETZPC controller

In reply to Benjamin Gaignard

STM32 Extended TrustZone Protection Controller (ETZPC) got 3 domains:
- secure: hardware blocks are only accessible by software running on trust zone.
- non-secure: hardware blocks are accessible by non-secure software (i.e. linux kernel).
- coprocessor: hardware blocks are only accessible by the corpocessor.

Each hardware block status is defined by a 2 bits field and all of them are packed into 32 bits registers. ETZPC can manage up to 94 hardware blocks.

---
 drivers/bus/domains/Kconfig                   |   7 ++
 drivers/bus/domains/Makefile                  |   1 +
 drivers/bus/domains/stm32-etzpc.c             | 140 ++++++++++++++++++++++++++
 include/dt-bindings/bus/domains/stm32-etzpc.h |  25 +++++
 4 files changed, 173 insertions(+)
 create mode 100644 drivers/bus/domains/stm32-etzpc.c
 create mode 100644 include/dt-bindings/bus/domains/stm32-etzpc.h
drivers/bus/domains/Kconfig +7 -0
index 5ba15f750bee..7afd209e8c4f 100644
@@ -4,4 +4,11 @@ config DOMAINS_CONTROLLERS
 	bool "Support of bus domains controllers"
 	depends on OF
 
+config STM32_ETZPC
+	bool "STM32 ETZPC Domain Controller"
+	depends on DOMAINS_CONTROLLERS && MACH_STM32MP157
+	help
+	  Select y to enable STM32 Extended TrustZone Protection
+	  Controller (ETZPC)
+
 endmenu
drivers/bus/domains/Makefile +1 -0
index 262338b7cad5..8000de6023a5 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_DOMAINS_CONTROLLERS) += domainsctrl.o
+obj-$(CONFIG_STM32_ETZPC) += stm32-etzpc.o
drivers/bus/domains/stm32-etzpc.c new file +140 -0

140 lines not on this page · raw message

include/dt-bindings/bus/domains/stm32-etzpc.h new file +25 -0
new file mode 100644
index 000000000000..93190fa29a9c
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) STMicroelectronics 2018 - All Rights Reserved
+ * Author: Benjamin Gaignard <[email protected]> for STMicroelectronics.
+ */
+
+#ifndef _STM32_ETZPC_H_
+#define _STM32_ETZPC_H_
+
+/* ETZPC domains: secure, non-secure or coprocessor*/
+#define STM32_ETZPC_SECURE	1
+#define STM32_ETPCZ_COPRO	2
+#define STM32_ETZPC_NON_SECURE	3
+
+/* ETZPC hard blaokcs index */
+#define STM32_ETZPC_USART1	3
+#define STM32_ETZPC_SPI6	4
+#define STM32_ETZPC_I2C4	5
+#define STM32_ETZPC_RNG1	7
+#define STM32_ETZPC_HASH1	8
+#define STM32_ETZPC_CRYP1	9
+#define STM32_ETZPC_I2C6	12
+#define STM32_ETZPC_CEC		38
+
+#endif /* _STM32_ETZPC_H_ */
Signature · 1 line
2.15.0
#9 lore raw

RFC v2 6/7 ARM: dts: stm32: Add domainsctrl node for stm32mp157 SoC

In reply to Benjamin Gaignard

Declare ETZPC device as a domains controller node for stm32mp157 SoC

---
 arch/arm/boot/dts/stm32mp157c.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/boot/dts/stm32mp157c.dtsi +7 -0
index 8bf1c17f8cef..d15510a78630 100644
@@ -1106,6 +1106,13 @@
 			status = "disabled";
 		};
 
+		etzpc: etzpc@5c007000 {
+			compatible = "st,stm32-etzpc";
+			reg = <0x5c007000 0x400>;
+			#domainctrl-cells = <2>;
+			status = "okay";
+		};
+
 		i2c6: i2c@5c009000 {
 			compatible = "st,stm32f7-i2c";
 			reg = <0x5c009000 0x400>;
Signature · 1 line
2.15.0
#10 lore raw

RFC v2 7/7 ARM: dts: stm32: enable domains controller node on stm32mp157c-ed1

In reply to Benjamin Gaignard

Enable ETZPC and set configuration for CEC node

---
 arch/arm/boot/dts/stm32mp157c-ev1.dts | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/boot/dts/stm32mp157c-ev1.dts +2 -0
index 063ee8ac5dcb..29142ca3d685 100644
@@ -6,6 +6,7 @@
 /dts-v1/;
 
 #include "stm32mp157c-ed1.dts"
+#include <dt-bindings/bus/domains/stm32-etzpc.h>
 #include <dt-bindings/gpio/gpio.h>
 
 / {
@@ -32,6 +33,7 @@
 &cec {
 	pinctrl-names = "default";
 	pinctrl-0 = <&cec_pins_a>;
+	domainctrl-0 = <&etzpc STM32_ETZPC_CEC STM32_ETZPC_NON_SECURE>;
 	status = "okay";
 };
 
Signature · 1 line
2.15.0