[v2,5/7] pinctrl: mcp23s08: add open drain configuration for irq pinctrl

Message ID 1507266491-73971-6-git-send-email-preid@electromag.com.au
State New
Headers show
Series
  • pinctrl: mcp32s08: add support for mcp23018
Related show

Commit Message

Phil Reid Oct. 6, 2017, 5:08 a.m.
The mcp23s08 series device can be configured for wired and interupts
using an external pullup and open drain output via the IOCON_ODR bit.
And "microchip,irq-open-drain" property to enable this.

Signed-off-by: Phil Reid <preid@electromag.com.au>
---
 drivers/pinctrl/pinctrl-mcp23s08.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Sebastian Reichel Oct. 8, 2017, 9:16 p.m. | #1
Hi,

On Fri, Oct 06, 2017 at 01:08:09PM +0800, Phil Reid wrote:
> The mcp23s08 series device can be configured for wired and interupts
> using an external pullup and open drain output via the IOCON_ODR bit.
> And "microchip,irq-open-drain" property to enable this.
> 
> Signed-off-by: Phil Reid <preid@electromag.com.au>

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

> ---
>  drivers/pinctrl/pinctrl-mcp23s08.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
> index 8d356df..150f216 100644
> --- a/drivers/pinctrl/pinctrl-mcp23s08.c
> +++ b/drivers/pinctrl/pinctrl-mcp23s08.c
> @@ -780,6 +780,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
>  {
>  	int status, ret;
>  	bool mirror = false;
> +	bool open_drain = false;
>  
>  	mutex_init(&mcp->lock);
>  
> @@ -876,6 +877,8 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
>  					      "microchip,irq-active-high");
>  
>  		mirror = device_property_read_bool(dev, "microchip,irq-mirror");
> +		open_drain = device_property_read_bool(dev,
> +						    "microchip,irq-open-drain");
>  	}
>  
>  	if ((status & IOCON_SEQOP) || !(status & IOCON_HAEN) || mirror ||
> @@ -891,6 +894,9 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
>  		if (mirror)
>  			status |= IOCON_MIRROR | (IOCON_MIRROR << 8);
>  
> +		if (open_drain)
> +			status |= IOCON_ODR | (IOCON_ODR << 8);
> +
>  		if (type == MCP_TYPE_S18 || type == MCP_TYPE_018)
>  			status |= IOCON_INTCC | (IOCON_INTCC << 8);
>  
> -- 
> 1.8.3.1
>
Linus Walleij Oct. 11, 2017, 8:16 a.m. | #2
On Fri, Oct 6, 2017 at 7:08 AM, Phil Reid <preid@electromag.com.au> wrote:

> The mcp23s08 series device can be configured for wired and interupts
> using an external pullup and open drain output via the IOCON_ODR bit.
> And "microchip,irq-open-drain" property to enable this.
>
> Signed-off-by: Phil Reid <preid@electromag.com.au>

See my comment on patch 4/7 for directions on what to do with this
patch.

Use standard binding, look at irq descriptor props, IRQF_SHARED.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index 8d356df..150f216 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -780,6 +780,7 @@  static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
 {
 	int status, ret;
 	bool mirror = false;
+	bool open_drain = false;
 
 	mutex_init(&mcp->lock);
 
@@ -876,6 +877,8 @@  static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
 					      "microchip,irq-active-high");
 
 		mirror = device_property_read_bool(dev, "microchip,irq-mirror");
+		open_drain = device_property_read_bool(dev,
+						    "microchip,irq-open-drain");
 	}
 
 	if ((status & IOCON_SEQOP) || !(status & IOCON_HAEN) || mirror ||
@@ -891,6 +894,9 @@  static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
 		if (mirror)
 			status |= IOCON_MIRROR | (IOCON_MIRROR << 8);
 
+		if (open_drain)
+			status |= IOCON_ODR | (IOCON_ODR << 8);
+
 		if (type == MCP_TYPE_S18 || type == MCP_TYPE_018)
 			status |= IOCON_INTCC | (IOCON_INTCC << 8);