Skip to contentSkip to conversation

pinctrl: mcp23s08: Fixups for mcp23x17

PATCH In review Thomas Preston 3 participants 6 messages Aug 28, 2020 – Sep 12, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover pinctrl: mcp23s08: Fixups for mcp23x17

Hi again,
Second round of these mcp23s03 driver fixups.

Changes since v1:
- Split up the fixups patch.
- I'm pretty certain the "mcp23x16" structs are typos, so I put it as 0001, because the second patch doesn't really make sense without it.
- I lost the (MCP_GPIO << 1) + 1 changes because the regmap handles GPIOB 0x13 with .val_bits = 16.
- Dropped the interrupt-controller changes.

Thanks again,
Thomas

Thomas Preston (2):
pinctrl: mcp23s08: Fix mcp23x17_regmap initialiser
pinctrl: mcp23s08: Fix mcp23x17 precious range

 drivers/pinctrl/pinctrl-mcp23s08.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/2 pinctrl: mcp23s08: Fix mcp23x17_regmap initialiser

The mcp23x17_regmap is initialised with structs named "mcp23x16". However, the mcp23s08 driver doesn't support the MCP23016 device yet, so this appears to be a typo.

Fixes 8f38910ba4f6 ("pinctrl: mcp23s08: switch to regmap caching")
---
 drivers/pinctrl/pinctrl-mcp23s08.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/pinctrl/pinctrl-mcp23s08.c +11 -11
index 42b12ea14d6be..87cde8fb08dd9 100644
@@ -87,7 +87,7 @@ const struct regmap_config mcp23x08_regmap = {
 };
 EXPORT_SYMBOL_GPL(mcp23x08_regmap);
 
-static const struct reg_default mcp23x16_defaults[] = {
+static const struct reg_default mcp23x17_defaults[] = {
 	{.reg = MCP_IODIR << 1,		.def = 0xffff},
 	{.reg = MCP_IPOL << 1,		.def = 0x0000},
 	{.reg = MCP_GPINTEN << 1,	.def = 0x0000},
@@ -98,23 +98,23 @@ static const struct reg_default mcp23x16_defaults[] = {
 	{.reg = MCP_OLAT << 1,		.def = 0x0000},
 };
 
-static const struct regmap_range mcp23x16_volatile_range = {
+static const struct regmap_range mcp23x17_volatile_range = {
 	.range_min = MCP_INTF << 1,
 	.range_max = MCP_GPIO << 1,
 };
 
-static const struct regmap_access_table mcp23x16_volatile_table = {
-	.yes_ranges = &mcp23x16_volatile_range,
+static const struct regmap_access_table mcp23x17_volatile_table = {
+	.yes_ranges = &mcp23x17_volatile_range,
 	.n_yes_ranges = 1,
 };
 
-static const struct regmap_range mcp23x16_precious_range = {
+static const struct regmap_range mcp23x17_precious_range = {
 	.range_min = MCP_GPIO << 1,
 	.range_max = MCP_GPIO << 1,
 };
 
-static const struct regmap_access_table mcp23x16_precious_table = {
-	.yes_ranges = &mcp23x16_precious_range,
+static const struct regmap_access_table mcp23x17_precious_table = {
+	.yes_ranges = &mcp23x17_precious_range,
 	.n_yes_ranges = 1,
 };
 
@@ -124,10 +124,10 @@ const struct regmap_config mcp23x17_regmap = {
 
 	.reg_stride = 2,
 	.max_register = MCP_OLAT << 1,
-	.volatile_table = &mcp23x16_volatile_table,
-	.precious_table = &mcp23x16_precious_table,
-	.reg_defaults = mcp23x16_defaults,
-	.num_reg_defaults = ARRAY_SIZE(mcp23x16_defaults),
+	.volatile_table = &mcp23x17_volatile_table,
+	.precious_table = &mcp23x17_precious_table,
+	.reg_defaults = mcp23x17_defaults,
+	.num_reg_defaults = ARRAY_SIZE(mcp23x17_defaults),
 	.cache_type = REGCACHE_FLAT,
 	.val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
Signature · 1 line
2.26.2
#2 lore raw

PATCH v2 2/2 pinctrl: mcp23s08: Fix mcp23x17 precious range

In reply to Thomas Preston

On page 23 of the datasheet [0] it says "The register remains unchanged until the interrupt is cleared via a read of INTCAP or GPIO." Include INTCAPA and INTCAPB registers in precious range, so that they aren't accidentally cleared when we read via debugfs.

[0] https://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf

Fixes 8f38910ba4f6 ("pinctrl: mcp23s08: switch to regmap caching")
---
 drivers/pinctrl/pinctrl-mcp23s08.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-mcp23s08.c +1 -1
index 87cde8fb08dd9..7edb067f5e76a 100644
@@ -109,7 +109,7 @@ static const struct regmap_access_table mcp23x17_volatile_table = {
 };
 
 static const struct regmap_range mcp23x17_precious_range = {
-	.range_min = MCP_GPIO << 1,
+	.range_min = MCP_INTCAP << 1,
 	.range_max = MCP_GPIO << 1,
 };
 
Signature · 1 line
2.26.2
#3 lore raw

Re: [PATCH v2 2/2] pinctrl: mcp23s08: Fix mcp23x17 precious range

Quoted 8 lines · Thomas Preston

On page 23 of the datasheet [0] it says "The register remains unchanged until the interrupt is cleared via a read of INTCAP or GPIO." Include INTCAPA and INTCAPB registers in precious range, so that they aren't accidentally cleared when we read via debugfs.

[0] https://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf

I would convert it to tag Datasheet: https://...

Maybe Linus can amend this when applying.

Quoted 22 lines
Fixes 8f38910ba4f6 ("pinctrl: mcp23s08: switch to regmap caching")
---
 drivers/pinctrl/pinctrl-mcp23s08.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-mcp23s08.c +1 -2
index 87cde8fb08dd9..7edb067f5e76a 100644
@@ -109,7 +109,7 @@ static const struct regmap_access_table mcp23x17_volatile_table = {
 };
 
 static const struct regmap_range mcp23x17_precious_range = {
-       .range_min = MCP_GPIO << 1,
+       .range_min = MCP_INTCAP << 1,
        .range_max = MCP_GPIO << 1,
 };
 
--

2.26.2

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on the v2 series
#4 lore raw
In reply to Thomas Preston
Quoted 3 lines · Thomas Preston

Hi again,
Second round of these mcp23s03 driver fixups.

v2 makes sense to me, thanks!

Quoted 21 lines

Changes since v1:
- Split up the fixups patch.
- I'm pretty certain the "mcp23x16" structs are typos, so I put it as 0001, because the second patch doesn't really make sense without it.
- I lost the (MCP_GPIO << 1) + 1 changes because the regmap handles GPIOB 0x13 with .val_bits = 16.
- Dropped the interrupt-controller changes.

Thanks again,
Thomas

Thomas Preston (2):
pinctrl: mcp23s08: Fix mcp23x17_regmap initialiser
pinctrl: mcp23s08: Fix mcp23x17 precious range

 drivers/pinctrl/pinctrl-mcp23s08.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

--
2.26.2

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
In reply to Thomas Preston
Quoted 10 lines · Thomas Preston

Hi again,
Second round of these mcp23s03 driver fixups.

Changes since v1:
- Split up the fixups patch.
- I'm pretty certain the "mcp23x16" structs are typos, so I put it as 0001, because the second patch doesn't really make sense without it.
- I lost the (MCP_GPIO << 1) + 1 changes because the regmap handles GPIOB 0x13 with .val_bits = 16.
- Dropped the interrupt-controller changes.

Patches applied!

Yours,
Linus Walleij