[PATCH v3] x86/platform/geode: reference the real node of the cs5535 GPIO controller

Bartosz Golaszewski posted 1 patch 2 hours ago
arch/x86/Kconfig                       | 10 +++++-----
arch/x86/platform/geode/geode-common.c | 12 +++++-------
2 files changed, 10 insertions(+), 12 deletions(-)
[PATCH v3] x86/platform/geode: reference the real node of the cs5535 GPIO controller
Posted by Bartosz Golaszewski 2 hours ago
GPIO software node lookup should rely exclusively on matching the
addresses of the referenced firmware nodes. Commit e5d527be7e69 ("gpio:
swnode: don't use the swnode's name as the key for GPIO lookup") tried to
enforce this but had to be reverted: it broke existing users who abuse the
software node mechanism by creating "dummy" software nodes named after the
device they want to get GPIOs from, without ever attaching them to the
actual GPIO devices. Those users rely on GPIOLIB matching the label of the
GPIO controller against the name of the software node rather than on a real
firmware node link.

Un-reverting e5d527be7e69 therefore requires converting all such users to
real firmware node lookup. The geode board setup is one of them: it
references the cs5535 GPIO controller through a locally-defined dummy node
named "cs5535-gpio".

The cs5535 MFD driver now exports the software node associated with its
GPIO controller cell as cs5535_gpio_swnode. Use it as the target of the
GPIO software node references in geode-common.c instead of the dummy node,
so the lookup resolves by firmware node address. As the referenced node
must exist at lookup time, make the cs5535 driver built-in for all boards
selecting GEODE_COMMON (depend on GPIO_CS5535=y). The node is exported in
the "CS5535" namespace, so import it in this module.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
This is a follow-up to the MFD change that exposed the software node
associated with the GPIO cell of the cs5535 MFD device.

Merging strategy: it's probably too late for Lee to pick it up but with
an Ack from the x86 maintainers, I'd still like to queue it through the
GPIO tree for the v7.2 merge window after the MFD pull request goes
upstream.
---
Changes in v3:
- Reworded the commit message as requested by Borislav
- Link to v2: https://patch.msgid.link/20260522-cs5535-swnode-v2-1-08b2ba64886c@oss.qualcomm.com

Changes in v2:
- Drop the MFD patch that's already in linux-next
- Rebase on top of current linux-next
- Rephrase the commit message, mention the namespace import
- Link to v1: https://patch.msgid.link/20260429-cs5535-swnode-v1-0-2bc5e17ddcf9@oss.qualcomm.com
---
 arch/x86/Kconfig                       | 10 +++++-----
 arch/x86/platform/geode/geode-common.c | 12 +++++-------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f24810015234e00a441645f61648ce9aa174a293..63c31b91341bd50f57626d44ad34648a25233393 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -3028,7 +3028,7 @@ config GEODE_COMMON
 
 config ALIX
 	bool "PCEngines ALIX System Support (LED setup)"
-	select GPIOLIB
+	depends on GPIO_CS5535=y
 	select GEODE_COMMON
 	help
 	  This option enables system support for the PCEngines ALIX.
@@ -3036,21 +3036,21 @@ config ALIX
 	  ALIX2/3/6 boards.  However, other system specific setup should
 	  get added here.
 
-	  Note: You must still enable the drivers for GPIO and LED support
-	  (GPIO_CS5535 & LEDS_GPIO) to actually use the LEDs
+	  Note: You must still enable the drivers for LED support (LEDS_GPIO)
+	  to actually use the LEDs
 
 	  Note: You have to set alix.force=1 for boards with Award BIOS.
 
 config NET5501
 	bool "Soekris Engineering net5501 System Support (LEDS, GPIO, etc)"
-	select GPIOLIB
+	depends on GPIO_CS5535=y
 	select GEODE_COMMON
 	help
 	  This option enables system support for the Soekris Engineering net5501.
 
 config GEOS
 	bool "Traverse Technologies GEOS System Support (LEDS, GPIO, etc)"
-	select GPIOLIB
+	depends on GPIO_CS5535=y
 	select GEODE_COMMON
 	depends on DMI
 	help
diff --git a/arch/x86/platform/geode/geode-common.c b/arch/x86/platform/geode/geode-common.c
index 1843ae385e2dc038fde6fb02f6de0b818e22d8dd..679b4b07b790db3ce1c06bd6639bba7516ca3f71 100644
--- a/arch/x86/platform/geode/geode-common.c
+++ b/arch/x86/platform/geode/geode-common.c
@@ -9,15 +9,12 @@
 #include <linux/gpio/property.h>
 #include <linux/input.h>
 #include <linux/leds.h>
+#include <linux/mfd/cs5535.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
 #include "geode-common.h"
 
-static const struct software_node geode_gpiochip_node = {
-	.name = "cs5535-gpio",
-};
-
 static const struct property_entry geode_gpio_keys_props[] = {
 	PROPERTY_ENTRY_U32("poll-interval", 20),
 	{ }
@@ -44,7 +41,6 @@ static const struct software_node geode_restart_key_node = {
 };
 
 static const struct software_node *geode_gpio_keys_swnodes[] __initconst = {
-	&geode_gpiochip_node,
 	&geode_gpio_keys_node,
 	&geode_restart_key_node,
 	NULL
@@ -66,7 +62,7 @@ int __init geode_create_restart_key(unsigned int pin)
 	struct platform_device *pd;
 	int err;
 
-	geode_restart_gpio_ref = SOFTWARE_NODE_REFERENCE(&geode_gpiochip_node,
+	geode_restart_gpio_ref = SOFTWARE_NODE_REFERENCE(&cs5535_gpio_swnode,
 							 pin, GPIO_ACTIVE_LOW);
 
 	err = software_node_register_node_group(geode_gpio_keys_swnodes);
@@ -143,7 +139,7 @@ int __init geode_create_leds(const char *label, const struct geode_led *leds,
 			goto err_free_names;
 		}
 
-		gpio_refs[i] = SOFTWARE_NODE_REFERENCE(&geode_gpiochip_node,
+		gpio_refs[i] = SOFTWARE_NODE_REFERENCE(&cs5535_gpio_swnode,
 						       leds[i].pin,
 						       GPIO_ACTIVE_LOW);
 		props[i * 3 + 0] =
@@ -188,3 +184,5 @@ int __init geode_create_leds(const char *label, const struct geode_led *leds,
 	kfree(swnodes);
 	return err;
 }
+
+MODULE_IMPORT_NS("CS5535");

---
base-commit: 550604d6c9b9efc8d068aff94dc301694a7afdee
change-id: 20260429-cs5535-swnode-0f731d2bbe10

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>