[PATCH] Expand MCP23S08 driver for use as interrupt controller.(v3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To be used as interrupt controller, pin control callbacks needed to
setup the registers.

Signed-off-by: Joe Burmeister <joe.burmeister@xxxxxxxxxxxxx>
---
 drivers/pinctrl/pinctrl-mcp23s08.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index 98905d4a79ca..3fc63cb5b332 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -264,6 +264,12 @@ static int mcp_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
 			return ret;
 		status = (data & BIT(pin)) ? 1 : 0;
 		break;
+	case PIN_CONFIG_OUTPUT:
+		ret = mcp_read(mcp, MCP_IODIR, &data);
+		if (ret < 0)
+			return ret;
+		status = (data & BIT(pin)) ? 0 : 1; /* true is input */
+		break;
 	default:
 		dev_err(mcp->dev, "Invalid config param %04x\n", param);
 		return -ENOTSUPP;
@@ -291,6 +297,13 @@ static int mcp_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
 		case PIN_CONFIG_BIAS_PULL_UP:
 			ret = mcp_set_bit(mcp, MCP_GPPU, pin, arg);
 			break;
+		case PIN_CONFIG_OUTPUT:
+			ret = mcp_set_bit(mcp, MCP_IODIR, pin, false);
+			if (!ret && arg)
+				ret = mcp_set_bit(mcp, MCP_GPPU, pin, true);
+			else
+				ret = mcp_set_bit(mcp, MCP_GPPU, pin, false);
+			break;
 		default:
 			dev_err(mcp->dev, "Invalid config param %04x\n", param);
 			return -ENOTSUPP;
-- 
2.20.1




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux