public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFT/RFC] mfd: cs42l43: setup true links with software nodes
@ 2025-11-19  9:10 Bartosz Golaszewski
  2025-11-19  9:30 ` Charles Keepax
  0 siblings, 1 reply; 29+ messages in thread
From: Bartosz Golaszewski @ 2025-11-19  9:10 UTC (permalink / raw)
  To: David Rhodes, Richard Fitzgerald, Lee Jones, Mark Brown,
	Charles Keepax, Andy Shevchenko, Philipp Zabel, Linus Walleij,
	Maciej Strozek, Andy Shevchenko
  Cc: linux-sound, patches, linux-kernel, linux-spi,
	Bartosz Golaszewski

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Currently the SPI driver sets up a software node rerefencing the GPIO
controller exposing the chip-select GPIO but this node never gets
attached to the actual GPIO provider. The lookup uses the weird way GPIO
core performs the software node lookup by the swnode's name. We want to
switch to a true firmware node lookup so the actual link must exist.
Move the configuration to the MFD core and connect the SPI and pinctrl
sub-devices with software node references.

Fixes: 439fbc97502a ("spi: cs42l43: Add bridged cs35l56 amplifiers")
Reported-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Closes: https://lore.kernel.org/all/aRyf7qDdHKABppP8@opensource.cirrus.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
Hi Charles!

Please give this a try. It's only build-tested so far. I hope I
understood correctly that it's the SPI driver that needs the "cs" GPIO
from the pinctrl.

Bartosz
---
 drivers/mfd/cs42l43.c     | 25 +++++++++++++++++++++++--
 drivers/spi/spi-cs42l43.c | 33 ---------------------------------
 2 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/drivers/mfd/cs42l43.c b/drivers/mfd/cs42l43.c
index 107cfb983fec416bbdd31caa1e6a569026467735..629faf8674af651eb64aa63ec768ba18c1c8b311 100644
--- a/drivers/mfd/cs42l43.c
+++ b/drivers/mfd/cs42l43.c
@@ -14,6 +14,8 @@
 #include <linux/err.h>
 #include <linux/firmware.h>
 #include <linux/gpio/consumer.h>
+#include <linux/gpio/machine.h>
+#include <linux/gpio/property.h>
 #include <linux/jiffies.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/cs42l43.h>
@@ -512,9 +514,28 @@ static const char * const cs42l43_core_supplies[] = {
 
 static const char * const cs42l43_parent_supplies[] = { "vdd-amp" };
 
+static const struct software_node cs42l43_gpiochip_swnode = {
+	.name = "cs42l43-pinctrl",
+};
+
+static const struct property_entry cs42l43_cs_props[] = {
+	PROPERTY_ENTRY_GPIO("cs-gpios", &cs42l43_gpiochip_swnode, 0, GPIO_ACTIVE_LOW),
+	{ }
+};
+
+static const struct software_node cs42l43_spi_swnode = {
+	.properties = cs42l43_cs_props,
+};
+
 static const struct mfd_cell cs42l43_devs[] = {
-	{ .name = "cs42l43-pinctrl", },
-	{ .name = "cs42l43-spi", },
+	{
+		.name = "cs42l43-pinctrl",
+		.swnode = &cs42l43_gpiochip_swnode,
+	},
+	{
+		.name = "cs42l43-spi",
+		.swnode = &cs42l43_spi_swnode,
+	},
 	{
 		.name = "cs42l43-codec",
 		.parent_supplies = cs42l43_parent_supplies,
diff --git a/drivers/spi/spi-cs42l43.c b/drivers/spi/spi-cs42l43.c
index 14307dd800b744fee17edd864688a68c65666c68..fa844ce6cd7539bf764f792b99e8f8e191fc0c15 100644
--- a/drivers/spi/spi-cs42l43.c
+++ b/drivers/spi/spi-cs42l43.c
@@ -52,20 +52,6 @@ static struct spi_board_info amp_info_template = {
 	.mode			= SPI_MODE_0,
 };
 
-static const struct software_node cs42l43_gpiochip_swnode = {
-	.name			= "cs42l43-pinctrl",
-};
-
-static const struct software_node_ref_args cs42l43_cs_refs[] = {
-	SOFTWARE_NODE_REFERENCE(&cs42l43_gpiochip_swnode, 0, GPIO_ACTIVE_LOW),
-	SOFTWARE_NODE_REFERENCE(&swnode_gpio_undefined),
-};
-
-static const struct property_entry cs42l43_cs_props[] = {
-	PROPERTY_ENTRY_REF_ARRAY("cs-gpios", cs42l43_cs_refs),
-	{}
-};
-
 static int cs42l43_spi_tx(struct regmap *regmap, const u8 *buf, unsigned int len)
 {
 	const u8 *end = buf + len;
@@ -324,11 +310,6 @@ static void cs42l43_release_of_node(void *data)
 	fwnode_handle_put(data);
 }
 
-static void cs42l43_release_sw_node(void *data)
-{
-	software_node_unregister(&cs42l43_gpiochip_swnode);
-}
-
 static int cs42l43_spi_probe(struct platform_device *pdev)
 {
 	struct cs42l43 *cs42l43 = dev_get_drvdata(pdev->dev.parent);
@@ -402,20 +383,6 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
 				return dev_err_probe(priv->dev, ret,
 						     "Failed to get spk-id-gpios\n");
 		}
-
-		ret = software_node_register(&cs42l43_gpiochip_swnode);
-		if (ret)
-			return dev_err_probe(priv->dev, ret,
-					     "Failed to register gpio swnode\n");
-
-		ret = devm_add_action_or_reset(priv->dev, cs42l43_release_sw_node, NULL);
-		if (ret)
-			return ret;
-
-		ret = device_create_managed_software_node(&priv->ctlr->dev,
-							  cs42l43_cs_props, NULL);
-		if (ret)
-			return dev_err_probe(priv->dev, ret, "Failed to add swnode\n");
 	} else {
 		device_set_node(&priv->ctlr->dev, fwnode);
 	}

---
base-commit: fe4d0dea039f2befb93f27569593ec209843b0f5
change-id: 20251119-cs42l43-gpio-swnodes-8d4a7e732d09

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2025-11-20 12:33 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19  9:10 [PATCH RFT/RFC] mfd: cs42l43: setup true links with software nodes Bartosz Golaszewski
2025-11-19  9:30 ` Charles Keepax
2025-11-19  9:35   ` Andy Shevchenko
2025-11-19  9:40   ` Bartosz Golaszewski
2025-11-19  9:57     ` Charles Keepax
2025-11-19 10:20       ` Bartosz Golaszewski
2025-11-19 10:38       ` Bartosz Golaszewski
2025-11-19 10:47         ` Charles Keepax
2025-11-19 10:50           ` Bartosz Golaszewski
2025-11-19 10:58             ` Andy Shevchenko
2025-11-19 11:06               ` Bartosz Golaszewski
2025-11-19 11:24                 ` Charles Keepax
2025-11-19 11:53                   ` Andy Shevchenko
2025-11-19 12:08                     ` Bartosz Golaszewski
2025-11-19 11:58                   ` Bartosz Golaszewski
2025-11-19 12:53                     ` Charles Keepax
2025-11-19 13:07                       ` Bartosz Golaszewski
2025-11-19 13:26                         ` Charles Keepax
2025-11-19 13:34                           ` Bartosz Golaszewski
2025-11-19 14:11                             ` Andy Shevchenko
2025-11-19 14:15                               ` Bartosz Golaszewski
2025-11-19 14:23                                 ` Andy Shevchenko
2025-11-19 14:30                                   ` Bartosz Golaszewski
2025-11-19 20:38                                     ` Andy Shevchenko
2025-11-20  9:12                                       ` Bartosz Golaszewski
2025-11-20  9:56                                         ` Andy Shevchenko
2025-11-20 12:33                                           ` Bartosz Golaszewski
2025-11-19 14:09                           ` Bartosz Golaszewski
2025-11-19 14:45                             ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox