From: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.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@yoseli.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