ARM: mvebu: switch to using gpiod API in pm-board code

This switches PM code to use the newer gpiod API instead of legacy
gpio API that we want to retire.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
This commit is contained in:
Dmitry Torokhov 2022-11-15 15:12:41 -08:00 committed by Gregory CLEMENT
parent d10886a4e6
commit 4839e77bb3

View file

@ -8,19 +8,19 @@
*/ */
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_gpio.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "common.h" #include "common.h"
#define ARMADA_PIC_NR_GPIOS 3 #define ARMADA_PIC_NR_GPIOS 3
static void __iomem *gpio_ctrl; static void __iomem *gpio_ctrl;
static int pic_gpios[ARMADA_PIC_NR_GPIOS]; static struct gpio_desc *pic_gpios[ARMADA_PIC_NR_GPIOS];
static int pic_raw_gpios[ARMADA_PIC_NR_GPIOS]; static int pic_raw_gpios[ARMADA_PIC_NR_GPIOS];
static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd) static void mvebu_armada_pm_enter(void __iomem *sdram_reg, u32 srcmd)
@ -90,27 +90,17 @@ static int __init mvebu_armada_pm_init(void)
char *name; char *name;
struct of_phandle_args args; struct of_phandle_args args;
pic_gpios[i] = of_get_named_gpio(np, "ctrl-gpios", i);
if (pic_gpios[i] < 0) {
ret = -ENODEV;
goto out;
}
name = kasprintf(GFP_KERNEL, "pic-pin%d", i); name = kasprintf(GFP_KERNEL, "pic-pin%d", i);
if (!name) { if (!name) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
ret = gpio_request(pic_gpios[i], name); pic_gpios[i] = fwnode_gpiod_get_index(of_fwnode_handle(np),
if (ret < 0) { "ctrl", i, GPIOD_OUT_HIGH,
kfree(name); name);
goto out; ret = PTR_ERR_OR_ZERO(pic_gpios[i]);
} if (ret) {
ret = gpio_direction_output(pic_gpios[i], 0);
if (ret < 0) {
gpio_free(pic_gpios[i]);
kfree(name); kfree(name);
goto out; goto out;
} }
@ -118,7 +108,7 @@ static int __init mvebu_armada_pm_init(void)
ret = of_parse_phandle_with_fixed_args(np, "ctrl-gpios", 2, ret = of_parse_phandle_with_fixed_args(np, "ctrl-gpios", 2,
i, &args); i, &args);
if (ret < 0) { if (ret < 0) {
gpio_free(pic_gpios[i]); gpiod_put(pic_gpios[i]);
kfree(name); kfree(name);
goto out; goto out;
} }