Skip to content

Commit 90c2d2e

Browse files
dtortsbogend
authored andcommitted
MIPS: pci: lantiq: switch to using gpiod API
This patch switches the driver from legacy gpio API to the newer gpiod API. Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 056a68c commit 90c2d2e

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

arch/mips/pci/pci-lantiq.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include <linux/kernel.h>
1010
#include <linux/init.h>
1111
#include <linux/delay.h>
12+
#include <linux/gpio/consumer.h>
1213
#include <linux/mm.h>
1314
#include <linux/vmalloc.h>
1415
#include <linux/clk.h>
1516
#include <linux/of_platform.h>
16-
#include <linux/of_gpio.h>
1717
#include <linux/of_irq.h>
1818
#include <linux/of_pci.h>
1919

@@ -62,7 +62,7 @@
6262
__iomem void *ltq_pci_mapped_cfg;
6363
static __iomem void *ltq_pci_membase;
6464

65-
static int reset_gpio;
65+
static struct gpio_desc *reset_gpio;
6666
static struct clk *clk_pci, *clk_external;
6767
static struct resource pci_io_resource;
6868
static struct resource pci_mem_resource;
@@ -95,6 +95,7 @@ static int ltq_pci_startup(struct platform_device *pdev)
9595
struct device_node *node = pdev->dev.of_node;
9696
const __be32 *req_mask, *bus_clk;
9797
u32 temp_buffer;
98+
int error;
9899

99100
/* get our clocks */
100101
clk_pci = clk_get(&pdev->dev, NULL);
@@ -123,17 +124,14 @@ static int ltq_pci_startup(struct platform_device *pdev)
123124
clk_disable(clk_external);
124125

125126
/* setup reset gpio used by pci */
126-
reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
127-
if (gpio_is_valid(reset_gpio)) {
128-
int ret = devm_gpio_request(&pdev->dev,
129-
reset_gpio, "pci-reset");
130-
if (ret) {
131-
dev_err(&pdev->dev,
132-
"failed to request gpio %d\n", reset_gpio);
133-
return ret;
134-
}
135-
gpio_direction_output(reset_gpio, 1);
127+
reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
128+
GPIOD_OUT_LOW);
129+
error = PTR_ERR_OR_ZERO(reset_gpio);
130+
if (error) {
131+
dev_err(&pdev->dev, "failed to request gpio: %d\n", error);
132+
return error;
136133
}
134+
gpiod_set_consumer_name(reset_gpio, "pci_reset");
137135

138136
/* enable auto-switching between PCI and EBU */
139137
ltq_pci_w32(0xa, PCI_CR_CLK_CTRL);
@@ -195,11 +193,11 @@ static int ltq_pci_startup(struct platform_device *pdev)
195193
ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_PCC_IEN) | 0x10, LTQ_EBU_PCC_IEN);
196194

197195
/* toggle reset pin */
198-
if (gpio_is_valid(reset_gpio)) {
199-
__gpio_set_value(reset_gpio, 0);
196+
if (reset_gpio) {
197+
gpiod_set_value_cansleep(reset_gpio, 1);
200198
wmb();
201199
mdelay(1);
202-
__gpio_set_value(reset_gpio, 1);
200+
gpiod_set_value_cansleep(reset_gpio, 0);
203201
}
204202
return 0;
205203
}

0 commit comments

Comments
 (0)