spi bus extensions were introduced to decouple spi busses when they are
wired to connectors. Combined with devicetree overlays, they introduce
an additional level of indirection, which is needed to decouple the
overlay (describing the hardware available on addon baord) and the base
tree (describing resources provided to the addon board).
For instance, the following devicetree fragment, available once
overlays are applied, is legit:
```
spi1: spi@abcd0000 {
compatible = "xyz,spi-ctrl";
spi-bus-extension@0 {
reg = <0>;
spi-bus = <&spi-ctrl>;
};
...
};
connector {
spi-ctrl {
spi-parent = <&spi1>;
#address-cells = <1>;
#size-cells = <0>;
spi-bus-extension@0 {
reg = <0>;
spi-bus = <&spi-other-connector>;
};
device@1 {
compatible = "xyz,foo";
reg = <1>;
};
};
devices {
other-connector {
spi-at-other-connector {
spi-parent = <&spi-ctrl>;
#address-cells = <1>;
#size-cells = <0>;
device@2 {
compatible = "xyz,bar";
reg = <2>;
};
};
};
};
};
```
Current processing done when a spi adapter is registered registers
spi clients described at the adapter node level.
With spi bus extensions, the process needs to look also at
extensions to register devices described in those extensions and so
connected to the adapter.
Extend of_spi_register_children() to look recursively at those
spi bus extensions.
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
---
drivers/spi/spi.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index ea271e37c72d3dc099c5147ec404050ee0bbf046..015f86c6f3228a8746dc517112d466051b50e3db 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2528,9 +2528,17 @@ static void of_register_spi_children(struct spi_controller *ctlr,
struct device_node *node)
{
struct spi_device *spi;
- struct device_node *nc;
+ struct device_node *nc, *extension;
+ /*
+ * Register device directly described in this bus node before looking
+ * at extensions.
+ */
for_each_available_child_of_node(node, nc) {
+ /* Filter out extension node */
+ if (of_node_name_eq(nc, "spi-bus-extension"))
+ continue;
+
if (of_node_test_and_set_flag(nc, OF_POPULATED))
continue;
@@ -2541,6 +2549,23 @@ static void of_register_spi_children(struct spi_controller *ctlr,
of_node_clear_flag(nc, OF_POPULATED);
}
}
+
+ /* Look at extensions */
+ for_each_available_child_of_node(node, nc) {
+ if (!of_node_name_eq(nc, "spi-bus-extension"))
+ continue;
+
+ extension = of_parse_phandle(nc, "spi-bus", 0);
+ if (!extension)
+ continue;
+
+ /*
+ * Register children available at this extension possibly
+ * walking other chained extensions.
+ */
+ of_register_spi_children(ctlr, extension);
+ of_node_put(extension);
+ }
}
/**
--
2.50.1
On 29/07/2025 11:51, Ayush Singh wrote: > for_each_available_child_of_node(node, nc) { > + /* Filter out extension node */ > + if (of_node_name_eq(nc, "spi-bus-extension")) > + continue; > + > if (of_node_test_and_set_flag(nc, OF_POPULATED)) > continue; > > @@ -2541,6 +2549,23 @@ static void of_register_spi_children(struct spi_controller *ctlr, > of_node_clear_flag(nc, OF_POPULATED); > } > } > + > + /* Look at extensions */ > + for_each_available_child_of_node(node, nc) { > + if (!of_node_name_eq(nc, "spi-bus-extension")) Where did you document the new ABI? There is no DT bindings patch with it. Best regards, Krzysztof
On 7/29/25 18:16, Krzysztof Kozlowski wrote: > On 29/07/2025 11:51, Ayush Singh wrote: >> for_each_available_child_of_node(node, nc) { >> + /* Filter out extension node */ >> + if (of_node_name_eq(nc, "spi-bus-extension")) >> + continue; >> + >> if (of_node_test_and_set_flag(nc, OF_POPULATED)) >> continue; >> >> @@ -2541,6 +2549,23 @@ static void of_register_spi_children(struct spi_controller *ctlr, >> of_node_clear_flag(nc, OF_POPULATED); >> } >> } >> + >> + /* Look at extensions */ >> + for_each_available_child_of_node(node, nc) { >> + if (!of_node_name_eq(nc, "spi-bus-extension")) > Where did you document the new ABI? There is no DT bindings patch with it. Patch 4 is the dt bindings patch. I will reorder the patches in any future to make the dt bindings patch 1. Here is a direct link in case it got lost in mail: https://lore.kernel.org/all/20250729-spi-bus-extension-v1-4-b20c73f2161a@beagleboard.org/ > > > Best regards, > Krzysztof Best Regards, Ayush Singh
On 29/07/2025 14:52, Ayush Singh wrote: > On 7/29/25 18:16, Krzysztof Kozlowski wrote: > >> On 29/07/2025 11:51, Ayush Singh wrote: >>> for_each_available_child_of_node(node, nc) { >>> + /* Filter out extension node */ >>> + if (of_node_name_eq(nc, "spi-bus-extension")) >>> + continue; >>> + >>> if (of_node_test_and_set_flag(nc, OF_POPULATED)) >>> continue; >>> >>> @@ -2541,6 +2549,23 @@ static void of_register_spi_children(struct spi_controller *ctlr, >>> of_node_clear_flag(nc, OF_POPULATED); >>> } >>> } >>> + >>> + /* Look at extensions */ >>> + for_each_available_child_of_node(node, nc) { >>> + if (!of_node_name_eq(nc, "spi-bus-extension")) >> Where did you document the new ABI? There is no DT bindings patch with it. > > Patch 4 is the dt bindings patch. I will reorder the patches in any > future to make the dt bindings patch 1. > > Here is a direct link in case it got lost in mail: > https://lore.kernel.org/all/20250729-spi-bus-extension-v1-4-b20c73f2161a@beagleboard.org/ I found it, just did not spot as a binding because my filters expect certain subjects (see submitting patches in DT subdir). Best regards, Krzysztof
© 2016 - 2025 Red Hat, Inc.