Commit 7375f2ac authored by Linus Walleij's avatar Linus Walleij Committed by Daniel Lezcano

thermal: ti-soc-thermal: Use GPIO descriptors

This switches the TI SoC thermal driver to use GPIO
descriptors instead of retrieveing a GPIO number from the
device tree and requesting the GPIO separately.

Cc: Keerthy <j-keerthy@ti.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200229210532.173430-1-linus.walleij@linaro.org
parent eb850462
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/types.h> #include <linux/types.h>
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/of_gpio.h>
#include <linux/io.h> #include <linux/io.h>
#include "ti-bandgap.h" #include "ti-bandgap.h"
...@@ -743,27 +742,13 @@ int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend) ...@@ -743,27 +742,13 @@ int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend)
static int ti_bandgap_tshut_init(struct ti_bandgap *bgp, static int ti_bandgap_tshut_init(struct ti_bandgap *bgp,
struct platform_device *pdev) struct platform_device *pdev)
{ {
int gpio_nr = bgp->tshut_gpio;
int status; int status;
/* Request for gpio_86 line */ status = request_irq(gpiod_to_irq(bgp->tshut_gpiod),
status = gpio_request(gpio_nr, "tshut"); ti_bandgap_tshut_irq_handler,
if (status < 0) {
dev_err(bgp->dev, "Could not request for TSHUT GPIO:%i\n", 86);
return status;
}
status = gpio_direction_input(gpio_nr);
if (status) {
dev_err(bgp->dev, "Cannot set input TSHUT GPIO %d\n", gpio_nr);
return status;
}
status = request_irq(gpio_to_irq(gpio_nr), ti_bandgap_tshut_irq_handler,
IRQF_TRIGGER_RISING, "tshut", NULL); IRQF_TRIGGER_RISING, "tshut", NULL);
if (status) { if (status)
gpio_free(gpio_nr);
dev_err(bgp->dev, "request irq failed for TSHUT"); dev_err(bgp->dev, "request irq failed for TSHUT");
}
return 0; return 0;
} }
...@@ -860,11 +845,10 @@ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev) ...@@ -860,11 +845,10 @@ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev)
} while (res); } while (res);
if (TI_BANDGAP_HAS(bgp, TSHUT)) { if (TI_BANDGAP_HAS(bgp, TSHUT)) {
bgp->tshut_gpio = of_get_gpio(node, 0); bgp->tshut_gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_IN);
if (!gpio_is_valid(bgp->tshut_gpio)) { if (IS_ERR(bgp->tshut_gpiod)) {
dev_err(&pdev->dev, "invalid gpio for tshut (%d)\n", dev_err(&pdev->dev, "invalid gpio for tshut\n");
bgp->tshut_gpio); return ERR_CAST(bgp->tshut_gpiod);
return ERR_PTR(-EINVAL);
} }
} }
...@@ -1046,10 +1030,8 @@ int ti_bandgap_probe(struct platform_device *pdev) ...@@ -1046,10 +1030,8 @@ int ti_bandgap_probe(struct platform_device *pdev)
put_fclock: put_fclock:
clk_put(bgp->fclock); clk_put(bgp->fclock);
free_irqs: free_irqs:
if (TI_BANDGAP_HAS(bgp, TSHUT)) { if (TI_BANDGAP_HAS(bgp, TSHUT))
free_irq(gpio_to_irq(bgp->tshut_gpio), NULL); free_irq(gpiod_to_irq(bgp->tshut_gpiod), NULL);
gpio_free(bgp->tshut_gpio);
}
return ret; return ret;
} }
...@@ -1079,10 +1061,8 @@ int ti_bandgap_remove(struct platform_device *pdev) ...@@ -1079,10 +1061,8 @@ int ti_bandgap_remove(struct platform_device *pdev)
if (TI_BANDGAP_HAS(bgp, TALERT)) if (TI_BANDGAP_HAS(bgp, TALERT))
free_irq(bgp->irq, bgp); free_irq(bgp->irq, bgp);
if (TI_BANDGAP_HAS(bgp, TSHUT)) { if (TI_BANDGAP_HAS(bgp, TSHUT))
free_irq(gpio_to_irq(bgp->tshut_gpio), NULL); free_irq(gpiod_to_irq(bgp->tshut_gpiod), NULL);
gpio_free(bgp->tshut_gpio);
}
return 0; return 0;
} }
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/err.h> #include <linux/err.h>
struct gpio_desc;
/** /**
* DOC: bandgap driver data structure * DOC: bandgap driver data structure
* ================================== * ==================================
...@@ -199,7 +201,7 @@ struct ti_bandgap { ...@@ -199,7 +201,7 @@ struct ti_bandgap {
struct clk *div_clk; struct clk *div_clk;
spinlock_t lock; /* shields this struct */ spinlock_t lock; /* shields this struct */
int irq; int irq;
int tshut_gpio; struct gpio_desc *tshut_gpiod;
u32 clk_rate; u32 clk_rate;
}; };
......
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