From: "Timo Teräs" <timo.teras@iki.fi>
To: linux-gpio@vger.kernel.org
Cc: "Timo Teräs" <timo.teras@iki.fi>
Subject: [PATCH] gpio: mcp23s08: support setting pullups from device tree data
Date: Fri, 4 Dec 2015 13:46:13 +0200 [thread overview]
Message-ID: <1449229573-25759-1-git-send-email-timo.teras@iki.fi> (raw)
Make pullup configurable from device tree data.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
---
I'm not fully certain how the pullup data should be made configurable via OF.
gpio-twl4030.c uses similar approach as this, but gpio-samsung.c makes the
pullup configuration seems to be part of the custom data in gpio specifiers.
Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt | 1 +
drivers/gpio/gpio-mcp23s08.c | 14 +++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt b/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
index f3332b9..c7d2128 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-mcp23s08.txt
@@ -59,6 +59,7 @@ Optional device specific properties:
On devices with only one interrupt output this property is useless.
- microchip,irq-active-high: Sets the INTPOL flag in the IOCON register. This
configures the IRQ output polarity as active high.
+- microchip,pullups: Configuration value for GPPU register.
Example I2C (with interrupt):
gpiom1: gpio@20 {
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 73db7ec..2320230 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -786,9 +786,12 @@ static int mcp230xx_probe(struct i2c_client *client,
match = of_match_device(of_match_ptr(mcp23s08_i2c_of_match),
&client->dev);
if (match) {
+ u32 pullups = 0;
pdata = &local_pdata;
pdata->base = -1;
- pdata->chip[0].pullups = 0;
+ of_property_read_u32(client->dev.of_node, "microchip,pullups",
+ &pullups);
+ pdata->chip[0].pullups = pullups;
pdata->irq_controller = of_property_read_bool(
client->dev.of_node,
"interrupt-controller");
@@ -910,9 +913,14 @@ static int mcp23s08_probe(struct spi_device *spi)
pdata = &local_pdata;
pdata->base = -1;
for (addr = 0; addr < ARRAY_SIZE(pdata->chip); addr++) {
- pdata->chip[addr].pullups = 0;
- if (spi_present_mask & (1 << addr))
+ u32 pullups = 0;
+ if (spi_present_mask & (1 << addr)) {
+ of_property_read_u32_index(spi->dev.of_node,
+ "microchip,pullups",
+ addr, &pullups);
chips++;
+ }
+ pdata->chip[addr].pullups = pullups;
}
pdata->irq_controller = of_property_read_bool(
spi->dev.of_node,
--
2.6.3
--
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
next reply other threads:[~2015-12-04 11:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-04 11:46 Timo Teräs [this message]
2015-12-07 6:53 ` [PATCH] gpio: mcp23s08: support setting pullups from device tree data Alexander Stein
2015-12-07 7:22 ` Timo Teras
2015-12-15 8:09 ` Alexander Stein
2015-12-15 9:23 ` Timo Teras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1449229573-25759-1-git-send-email-timo.teras@iki.fi \
--to=timo.teras@iki.fi \
--cc=linux-gpio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).