From: Alan Tull <atull@kernel.org>
To: Hoan Tran <hotran@apm.com>, Linus Walleij <linus.walleij@linaro.org>
Cc: Alan Tull <atull@kernel.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] gpio: gpio-dwapb: add optional reset
Date: Tue, 10 Oct 2017 16:26:17 -0500 [thread overview]
Message-ID: <20171010212617.3397-1-atull@kernel.org> (raw)
Some platforms require reset to be released to allow register
access.
Signed-off-by: Alan Tull <atull@kernel.org>
---
drivers/gpio/gpio-dwapb.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index 5cdb7bc..f7ac625 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -25,6 +25,7 @@
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/reset.h>
#include <linux/spinlock.h>
#include <linux/platform_data/gpio-dwapb.h>
#include <linux/slab.h>
@@ -98,6 +99,7 @@ struct dwapb_gpio {
unsigned int nr_ports;
struct irq_domain *domain;
unsigned int flags;
+ struct reset_control *rst;
};
static inline u32 gpio_reg_v2_convert(unsigned int offset)
@@ -612,6 +614,7 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
int err;
struct device *dev = &pdev->dev;
struct dwapb_platform_data *pdata = dev_get_platdata(dev);
+ struct reset_control *rst;
if (!pdata) {
pdata = dwapb_gpio_get_pdata(dev);
@@ -629,6 +632,15 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
gpio->dev = &pdev->dev;
gpio->nr_ports = pdata->nports;
+ rst = devm_reset_control_get_optional_exclusive(dev, NULL);
+ if (IS_ERR(rst)) {
+ if (PTR_ERR(rst) == -EPROBE_DEFER)
+ return PTR_ERR(rst);
+ } else {
+ reset_control_deassert(rst);
+ gpio->rst = rst;
+ }
+
gpio->ports = devm_kcalloc(&pdev->dev, gpio->nr_ports,
sizeof(*gpio->ports), GFP_KERNEL);
if (!gpio->ports)
@@ -680,6 +692,8 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
dwapb_gpio_unregister(gpio);
dwapb_irq_teardown(gpio);
+ if (gpio->rst)
+ reset_control_assert(gpio->rst);
return 0;
}
--
2.7.4
next reply other threads:[~2017-10-10 21:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 21:26 Alan Tull [this message]
2017-10-11 8:31 ` [PATCH] gpio: gpio-dwapb: add optional reset Linus Walleij
2017-10-11 10:56 ` Philipp Zabel
2017-10-11 16:05 ` Alan Tull
-- strict thread matches above, loose matches on Subject: below --
2017-10-11 16:34 Alan Tull
2017-10-11 17:47 ` Alan Tull
2017-10-12 8:18 ` Philipp Zabel
2017-10-12 8:26 ` Linus Walleij
2017-10-12 14:34 ` Alan Tull
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=20171010212617.3397-1-atull@kernel.org \
--to=atull@kernel.org \
--cc=hotran@apm.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@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).