From 07901a94f9f9b11cc3a4537e33229cb7e7df5d2a Mon Sep 17 00:00:00 2001 From: Alan Tull Date: Wed, 11 Oct 2017 11:34:44 -0500 Subject: [PATCH] gpio: gpio-dwapb: add optional reset Some platforms require reset to be released to allow register access. Signed-off-by: Alan Tull Reviewed-by: Philipp Zabel [Added DT bindings oneliner for standard reset binding] Signed-off-by: Linus Walleij --- Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt | 1 + drivers/gpio/gpio-dwapb.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt b/Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt index 4d6c8cd..4a75da7 100644 --- a/Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt +++ b/Documentation/devicetree/bindings/gpio/snps-dwapb-gpio.txt @@ -29,6 +29,7 @@ controller. - interrupts : The interrupt to the parent controller raised when GPIOs generate the interrupts. - snps,nr-gpios : The number of pins in the port, a single cell. +- resets : Reset line for the controller. Example: diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 5cdb7bc..d782ad1 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -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) @@ -629,6 +631,12 @@ static int dwapb_gpio_probe(struct platform_device *pdev) gpio->dev = &pdev->dev; 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, sizeof(*gpio->ports), GFP_KERNEL); if (!gpio->ports) @@ -680,6 +688,7 @@ static int dwapb_gpio_remove(struct platform_device *pdev) dwapb_gpio_unregister(gpio); dwapb_irq_teardown(gpio); + reset_control_assert(gpio->rst); return 0; } -- 2.7.4