[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20260113-mcp23s17-multiple-addr-names-v1-1-f14b60f92c82@yoseli.org>
Date: Tue, 13 Jan 2026 15:29:47 +0100
From: Jean-Michel Hautbois via B4 Relay <devnull+jeanmichel.hautbois.yoseli.org@...nel.org>
To: Linus Walleij <linusw@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Himanshu Bhavani <himanshu.bhavani@...iconsignals.io>
Cc: linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org,
Jean-Michel Hautbois <jeanmichel.hautbois@...eli.org>
Subject: [PATCH 1/2] pinctrl: mcp23s08: support gpio-line-names
From: Jean-Michel Hautbois <jeanmichel.hautbois@...eli.org>
The MCP23S08/17/18 SPI driver supports multiple chips sharing the same
SPI chip select by using the hardware address pins (A0-A2). Each chip
gets its own gpio_chip instance, but they all share the parent device
tree node.
Without setting gpio_chip.offset, the gpio-line-names property cannot
be used because gpiolib assigns all chips names starting at index 0.
Set offset based on cumulative GPIO count to enable sequential
gpio-line-names in device tree:
microchip,spi-present-mask = /bits/ 8 <0x03>; /* chips 0 and 1 */
gpio-line-names =
/* Chip 0: 16 names */
"EXP0_A0", "EXP0_A1", ..., "EXP0_B7",
/* Chip 1: 16 names */
"EXP1_A0", "EXP1_A1", ..., "EXP1_B7";
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@...eli.org>
---
drivers/pinctrl/pinctrl-mcp23s08_spi.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
index 54f61c8cb1c0..105efc85c3e7 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
@@ -141,6 +141,7 @@ static int mcp23s08_probe(struct spi_device *spi)
unsigned long spi_present_mask;
unsigned int ngpio = 0;
unsigned int addr;
+ unsigned int line_offset = 0;
int chips;
int ret;
u32 v;
@@ -178,6 +179,9 @@ static int mcp23s08_probe(struct spi_device *spi)
if (ret)
return ret;
+ data->mcp[addr]->chip.offset = line_offset;
+ line_offset += data->mcp[addr]->chip.ngpio;
+
data->mcp[addr]->pinctrl_desc.name = devm_kasprintf(dev, GFP_KERNEL,
"mcp23xxx-pinctrl.%d",
addr);
--
2.39.5
Powered by blists - more mailing lists