Commit 07901a94 authored by Alan Tull's avatar Alan Tull Committed by Linus Walleij

gpio: gpio-dwapb: add optional reset

Some platforms require reset to be released to allow register
access.
Signed-off-by: default avatarAlan Tull <atull@kernel.org>
Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
[Added DT bindings oneliner for standard reset binding]
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent f76a2d9d
...@@ -29,6 +29,7 @@ controller. ...@@ -29,6 +29,7 @@ controller.
- interrupts : The interrupt to the parent controller raised when GPIOs - interrupts : The interrupt to the parent controller raised when GPIOs
generate the interrupts. generate the interrupts.
- snps,nr-gpios : The number of pins in the port, a single cell. - snps,nr-gpios : The number of pins in the port, a single cell.
- resets : Reset line for the controller.
Example: Example:
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h> #include <linux/property.h>
#include <linux/reset.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/platform_data/gpio-dwapb.h> #include <linux/platform_data/gpio-dwapb.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -98,6 +99,7 @@ struct dwapb_gpio { ...@@ -98,6 +99,7 @@ struct dwapb_gpio {
unsigned int nr_ports; unsigned int nr_ports;
struct irq_domain *domain; struct irq_domain *domain;
unsigned int flags; unsigned int flags;
struct reset_control *rst;
}; };
static inline u32 gpio_reg_v2_convert(unsigned int offset) static inline u32 gpio_reg_v2_convert(unsigned int offset)
...@@ -629,6 +631,12 @@ static int dwapb_gpio_probe(struct platform_device *pdev) ...@@ -629,6 +631,12 @@ static int dwapb_gpio_probe(struct platform_device *pdev)
gpio->dev = &pdev->dev; gpio->dev = &pdev->dev;
gpio->nr_ports = pdata->nports; gpio->nr_ports = pdata->nports;
gpio->rst = devm_reset_control_get_optional_shared(dev, NULL);
if (IS_ERR(gpio->rst))
return PTR_ERR(gpio->rst);
reset_control_deassert(gpio->rst);
gpio->ports = devm_kcalloc(&pdev->dev, gpio->nr_ports, gpio->ports = devm_kcalloc(&pdev->dev, gpio->nr_ports,
sizeof(*gpio->ports), GFP_KERNEL); sizeof(*gpio->ports), GFP_KERNEL);
if (!gpio->ports) if (!gpio->ports)
...@@ -680,6 +688,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev) ...@@ -680,6 +688,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev)
dwapb_gpio_unregister(gpio); dwapb_gpio_unregister(gpio);
dwapb_irq_teardown(gpio); dwapb_irq_teardown(gpio);
reset_control_assert(gpio->rst);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment