Hello,
I would like send this upstream next week, any feedback would be welcome before that.
Thanks.
Viresh Kumar (2): dt-bindings: firmware: Add bindings for ARM FFA firmware: arm_ffa: Setup of_node for ffa devices
.../devicetree/bindings/firmware/arm,ffa.yaml | 75 +++++++++++++++++++ drivers/firmware/arm_ffa/bus.c | 30 ++++++++ 2 files changed, 105 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/arm,ffa.yaml
This adds DT bindings for ARM's FFA framework. The bindings are used to provide a reserved memory region per FFA device.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- .../devicetree/bindings/firmware/arm,ffa.yaml | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Documentation/devicetree/bindings/firmware/arm,ffa.yaml
diff --git a/Documentation/devicetree/bindings/firmware/arm,ffa.yaml b/Documentation/devicetree/bindings/firmware/arm,ffa.yaml new file mode 100644 index 000000000000..b88d6cec7e16 --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/arm,ffa.yaml @@ -0,0 +1,75 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2021 ARM Ltd. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/arm,ffa.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Arm Firmware Framework for A-class + +maintainers: + - Viresh Kumar viresh.kumar@linaro.org + +description: | + ARM FFA (Arm Firmware Framework for A-class) is a framework designed to + facilitate communication and resource sharing between various software + components in an Arm system, such as operating systems, hypervisors, and + trusted execution environments (TEEs). It's particularly used in systems + leveraging the Armv8-A architecture and later. + + This binding is intended to define the interface the firmware implementing the + FFA provide in the device tree. + + https://developer.arm.com/documentation/den0077/ + +properties: + $nodename: + pattern: '^ffa(-[a-z0-9]+)?$' + + compatible: + const: arm,ffa + + vm-id: + description: Virtual machine identifier. + $ref: /schemas/types.yaml#/definitions/uint32 + + uuid: + description: Universally Unique Identifier. + $ref: /schemas/types.yaml#/definitions/uint32-matrix + minItems: 4 + maxItems: 4 + + memory-region: + maxItems: 1 + description: + Reserved memory allocated for sharing with other software components. + +additionalProperties: false + +required: + - compatible + - vm-id + - uuid + +examples: + - | + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + ffa_2_mem: ffamem@81000000 { + compatible = "restricted-dma-pool"; + reg = <0x81000000 0x00800000>; + }; + }; + + firmware { + ffa { + compatible = "arm,ffa"; + vm-id = <2>; + uuid = <0xc5b82091 0x48bbd4fe 0x244de7b7 0xbe28bb6e>; + memory-region = <&ffa_2_mem>; + }; + }; +...
Match and bind the of_node for the FFA device.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/firmware/arm_ffa/bus.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index dea3eb741d95..ca526e438e71 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -7,6 +7,8 @@
#include <linux/arm_ffa.h> #include <linux/device.h> +#include <linux/of.h> +#include <linux/of_device.h> #include <linux/fs.h> #include <linux/kernel.h> #include <linux/module.h> @@ -187,6 +189,32 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev) return valid; }
+static void ffa_device_of_setup(struct ffa_device *ffa_dev) +{ + struct device_node *np; + uuid_t uuid; + u32 val; + + /* vm-id and UUID must match */ + for_each_compatible_node(np, NULL, "arm,ffa") { + if (of_property_read_u32(np, "vm-id", &val)) + continue; + + if (ffa_dev->vm_id != val) + continue; + + if (of_property_read_u32_array(np, "uuid", (u32 *)&uuid, + sizeof(uuid) / sizeof(u32))) + continue; + + if (!uuid_equal(&ffa_dev->uuid, &uuid)) + continue; + + device_set_node(&ffa_dev->dev, of_fwnode_handle(np)); + break; + } +} + struct ffa_device * ffa_device_register(const struct ffa_partition_info *part_info, const struct ffa_ops *ops) @@ -222,6 +250,8 @@ ffa_device_register(const struct ffa_partition_info *part_info, import_uuid(&uuid, (u8 *)part_info->uuid); uuid_copy(&ffa_dev->uuid, &uuid);
+ ffa_device_of_setup(ffa_dev); + ret = device_register(&ffa_dev->dev); if (ret) { dev_err(dev, "unable to register device %s err=%d\n",
Provide .dma_configure() callback to make reserved-memory work for FFA devices.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- Forgot generating this earlier :(
drivers/firmware/arm_ffa/bus.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index ca526e438e71..e7fd25ba71a4 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -110,12 +110,21 @@ static struct attribute *ffa_device_attributes_attrs[] = { }; ATTRIBUTE_GROUPS(ffa_device_attributes);
+static int ffa_Device_dma_configure(struct device *dev) +{ + if (dev->of_node) + return of_dma_configure(dev, dev->of_node, true); + + return 0; +} + const struct bus_type ffa_bus_type = { .name = "arm_ffa", .match = ffa_device_match, .probe = ffa_device_probe, .remove = ffa_device_remove, .uevent = ffa_device_uevent, + .dma_configure = ffa_Device_dma_configure, .dev_groups = ffa_device_attributes_groups, }; EXPORT_SYMBOL_GPL(ffa_bus_type);