mfd: hi655x-pmic: Replace legacy gpio interface for gpiod interface
Considering the current transition of the GPIO subsystem, remove all dependencies of the legacy GPIO interface (linux/gpio.h and linux /of_gpio.h) and replace it with the descriptor-based GPIO approach. Signed-off-by: Maíra Canal <maira.canal@usp.br> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/Yk2maZuf+5FGL+eg@fedora
This commit is contained in:
parent
54c861f930
commit
7f5aaa4a0a
@ -9,14 +9,13 @@
|
|||||||
* Fei Wang <w.f@huawei.com>
|
* Fei Wang <w.f@huawei.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/gpio.h>
|
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/mfd/core.h>
|
#include <linux/mfd/core.h>
|
||||||
#include <linux/mfd/hi655x-pmic.h>
|
#include <linux/mfd/hi655x-pmic.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of_gpio.h>
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/of_platform.h>
|
#include <linux/of_platform.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
@ -94,7 +93,6 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
|
|||||||
int ret;
|
int ret;
|
||||||
struct hi655x_pmic *pmic;
|
struct hi655x_pmic *pmic;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct device_node *np = dev->of_node;
|
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
|
|
||||||
pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
|
pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
|
||||||
@ -120,21 +118,12 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
hi655x_local_irq_clear(pmic->regmap);
|
hi655x_local_irq_clear(pmic->regmap);
|
||||||
|
|
||||||
pmic->gpio = of_get_named_gpio(np, "pmic-gpios", 0);
|
pmic->gpio = devm_gpiod_get_optional(dev, "pmic", GPIOD_IN);
|
||||||
if (!gpio_is_valid(pmic->gpio)) {
|
if (IS_ERR(pmic->gpio))
|
||||||
dev_err(dev, "Failed to get the pmic-gpios\n");
|
return dev_err_probe(dev, PTR_ERR(pmic->gpio),
|
||||||
return -ENODEV;
|
"Failed to request hi655x pmic-gpio");
|
||||||
}
|
|
||||||
|
|
||||||
ret = devm_gpio_request_one(dev, pmic->gpio, GPIOF_IN,
|
ret = regmap_add_irq_chip(pmic->regmap, gpiod_to_irq(pmic->gpio),
|
||||||
"hi655x_pmic_irq");
|
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(dev, "Failed to request gpio %d ret = %d\n",
|
|
||||||
pmic->gpio, ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = regmap_add_irq_chip(pmic->regmap, gpio_to_irq(pmic->gpio),
|
|
||||||
IRQF_TRIGGER_LOW | IRQF_NO_SUSPEND, 0,
|
IRQF_TRIGGER_LOW | IRQF_NO_SUSPEND, 0,
|
||||||
&hi655x_irq_chip, &pmic->irq_data);
|
&hi655x_irq_chip, &pmic->irq_data);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -149,7 +138,7 @@ static int hi655x_pmic_probe(struct platform_device *pdev)
|
|||||||
regmap_irq_get_domain(pmic->irq_data));
|
regmap_irq_get_domain(pmic->irq_data));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Failed to register device %d\n", ret);
|
dev_err(dev, "Failed to register device %d\n", ret);
|
||||||
regmap_del_irq_chip(gpio_to_irq(pmic->gpio), pmic->irq_data);
|
regmap_del_irq_chip(gpiod_to_irq(pmic->gpio), pmic->irq_data);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +149,7 @@ static int hi655x_pmic_remove(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct hi655x_pmic *pmic = platform_get_drvdata(pdev);
|
struct hi655x_pmic *pmic = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
regmap_del_irq_chip(gpio_to_irq(pmic->gpio), pmic->irq_data);
|
regmap_del_irq_chip(gpiod_to_irq(pmic->gpio), pmic->irq_data);
|
||||||
mfd_remove_devices(&pdev->dev);
|
mfd_remove_devices(&pdev->dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#ifndef __HI655X_PMIC_H
|
#ifndef __HI655X_PMIC_H
|
||||||
#define __HI655X_PMIC_H
|
#define __HI655X_PMIC_H
|
||||||
|
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
|
|
||||||
/* Hi655x registers are mapped to memory bus in 4 bytes stride */
|
/* Hi655x registers are mapped to memory bus in 4 bytes stride */
|
||||||
#define HI655X_STRIDE 4
|
#define HI655X_STRIDE 4
|
||||||
#define HI655X_BUS_ADDR(x) ((x) << 2)
|
#define HI655X_BUS_ADDR(x) ((x) << 2)
|
||||||
@ -53,7 +55,7 @@ struct hi655x_pmic {
|
|||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
int gpio;
|
struct gpio_desc *gpio;
|
||||||
unsigned int ver;
|
unsigned int ver;
|
||||||
struct regmap_irq_chip_data *irq_data;
|
struct regmap_irq_chip_data *irq_data;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user