mfd: stmpe: Switch to using gpiod API
This patch switches the driver away from legacy gpio/of_gpio API to gpiod API, and removes use of of_get_named_gpio_flags() which I want to make private to gpiolib. We also need to patch relevant DTS files, as the original code relied on the fact that of_get_named_gpio_flags() would fetch any data encoded in GPIO flags, even if it does not reflect valid flags for a GPIO. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/YxeS1BK2OBH1P/kO@google.com
This commit is contained in:
parent
62a0261c9f
commit
ac3e91199d
@ -993,7 +993,7 @@
|
|||||||
touchscreen@41 {
|
touchscreen@41 {
|
||||||
compatible = "st,stmpe811";
|
compatible = "st,stmpe811";
|
||||||
reg = <0x41>;
|
reg = <0x41>;
|
||||||
irq-gpio = <&gpio TEGRA_GPIO(V, 0) IRQ_TYPE_LEVEL_LOW>;
|
irq-gpio = <&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>;
|
||||||
interrupt-controller;
|
interrupt-controller;
|
||||||
id = <0>;
|
id = <0>;
|
||||||
blocks = <0x5>;
|
blocks = <0x5>;
|
||||||
|
@ -976,7 +976,7 @@
|
|||||||
touchscreen@41 {
|
touchscreen@41 {
|
||||||
compatible = "st,stmpe811";
|
compatible = "st,stmpe811";
|
||||||
reg = <0x41>;
|
reg = <0x41>;
|
||||||
irq-gpio = <&gpio TEGRA_GPIO(V, 0) IRQ_TYPE_LEVEL_LOW>;
|
irq-gpio = <&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>;
|
||||||
interrupt-controller;
|
interrupt-controller;
|
||||||
id = <0>;
|
id = <0>;
|
||||||
blocks = <0x5>;
|
blocks = <0x5>;
|
||||||
|
@ -849,7 +849,7 @@
|
|||||||
touchscreen@41 {
|
touchscreen@41 {
|
||||||
compatible = "st,stmpe811";
|
compatible = "st,stmpe811";
|
||||||
reg = <0x41>;
|
reg = <0x41>;
|
||||||
irq-gpio = <&gpio TEGRA_GPIO(V, 0) IRQ_TYPE_LEVEL_LOW>;
|
irq-gpio = <&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>;
|
||||||
interrupt-controller;
|
interrupt-controller;
|
||||||
id = <0>;
|
id = <0>;
|
||||||
blocks = <0x5>;
|
blocks = <0x5>;
|
||||||
|
@ -8,14 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/export.h>
|
#include <linux/export.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/irq.h>
|
#include <linux/irq.h>
|
||||||
#include <linux/irqdomain.h>
|
#include <linux/irqdomain.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_gpio.h>
|
|
||||||
#include <linux/pm.h>
|
#include <linux/pm.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
@ -30,17 +29,12 @@
|
|||||||
* @irq_trigger: IRQ trigger to use for the interrupt to the host
|
* @irq_trigger: IRQ trigger to use for the interrupt to the host
|
||||||
* @autosleep: bool to enable/disable stmpe autosleep
|
* @autosleep: bool to enable/disable stmpe autosleep
|
||||||
* @autosleep_timeout: inactivity timeout in milliseconds for autosleep
|
* @autosleep_timeout: inactivity timeout in milliseconds for autosleep
|
||||||
* @irq_over_gpio: true if gpio is used to get irq
|
|
||||||
* @irq_gpio: gpio number over which irq will be requested (significant only if
|
|
||||||
* irq_over_gpio is true)
|
|
||||||
*/
|
*/
|
||||||
struct stmpe_platform_data {
|
struct stmpe_platform_data {
|
||||||
int id;
|
int id;
|
||||||
unsigned int blocks;
|
unsigned int blocks;
|
||||||
unsigned int irq_trigger;
|
unsigned int irq_trigger;
|
||||||
bool autosleep;
|
bool autosleep;
|
||||||
bool irq_over_gpio;
|
|
||||||
int irq_gpio;
|
|
||||||
int autosleep_timeout;
|
int autosleep_timeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1349,13 +1343,6 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
|
|||||||
if (pdata->id < 0)
|
if (pdata->id < 0)
|
||||||
pdata->id = -1;
|
pdata->id = -1;
|
||||||
|
|
||||||
pdata->irq_gpio = of_get_named_gpio_flags(np, "irq-gpio", 0,
|
|
||||||
&pdata->irq_trigger);
|
|
||||||
if (gpio_is_valid(pdata->irq_gpio))
|
|
||||||
pdata->irq_over_gpio = 1;
|
|
||||||
else
|
|
||||||
pdata->irq_trigger = IRQF_TRIGGER_NONE;
|
|
||||||
|
|
||||||
of_property_read_u32(np, "st,autosleep-timeout",
|
of_property_read_u32(np, "st,autosleep-timeout",
|
||||||
&pdata->autosleep_timeout);
|
&pdata->autosleep_timeout);
|
||||||
|
|
||||||
@ -1381,6 +1368,7 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)
|
|||||||
struct stmpe_platform_data *pdata;
|
struct stmpe_platform_data *pdata;
|
||||||
struct device_node *np = ci->dev->of_node;
|
struct device_node *np = ci->dev->of_node;
|
||||||
struct stmpe *stmpe;
|
struct stmpe *stmpe;
|
||||||
|
struct gpio_desc *irq_gpio;
|
||||||
int ret;
|
int ret;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
@ -1434,18 +1422,20 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)
|
|||||||
if (ci->init)
|
if (ci->init)
|
||||||
ci->init(stmpe);
|
ci->init(stmpe);
|
||||||
|
|
||||||
if (pdata->irq_over_gpio) {
|
irq_gpio = devm_gpiod_get_optional(ci->dev, "irq", GPIOD_ASIS);
|
||||||
ret = devm_gpio_request_one(ci->dev, pdata->irq_gpio,
|
ret = PTR_ERR_OR_ZERO(irq_gpio);
|
||||||
GPIOF_DIR_IN, "stmpe");
|
if (ret) {
|
||||||
if (ret) {
|
dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n", ret);
|
||||||
dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n",
|
return ret;
|
||||||
ret);
|
}
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
stmpe->irq = gpio_to_irq(pdata->irq_gpio);
|
if (irq_gpio) {
|
||||||
|
stmpe->irq = gpiod_to_irq(irq_gpio);
|
||||||
|
pdata->irq_trigger = gpiod_is_active_low(irq_gpio) ?
|
||||||
|
IRQF_TRIGGER_LOW : IRQF_TRIGGER_HIGH;
|
||||||
} else {
|
} else {
|
||||||
stmpe->irq = ci->irq;
|
stmpe->irq = ci->irq;
|
||||||
|
pdata->irq_trigger = IRQF_TRIGGER_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmpe->irq < 0) {
|
if (stmpe->irq < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user