|
9 | 9 | #include <linux/kernel.h> |
10 | 10 | #include <linux/init.h> |
11 | 11 | #include <linux/delay.h> |
| 12 | +#include <linux/gpio/consumer.h> |
12 | 13 | #include <linux/mm.h> |
13 | 14 | #include <linux/vmalloc.h> |
14 | 15 | #include <linux/clk.h> |
15 | 16 | #include <linux/of_platform.h> |
16 | | -#include <linux/of_gpio.h> |
17 | 17 | #include <linux/of_irq.h> |
18 | 18 | #include <linux/of_pci.h> |
19 | 19 |
|
|
62 | 62 | __iomem void *ltq_pci_mapped_cfg; |
63 | 63 | static __iomem void *ltq_pci_membase; |
64 | 64 |
|
65 | | -static int reset_gpio; |
| 65 | +static struct gpio_desc *reset_gpio; |
66 | 66 | static struct clk *clk_pci, *clk_external; |
67 | 67 | static struct resource pci_io_resource; |
68 | 68 | static struct resource pci_mem_resource; |
@@ -95,6 +95,7 @@ static int ltq_pci_startup(struct platform_device *pdev) |
95 | 95 | struct device_node *node = pdev->dev.of_node; |
96 | 96 | const __be32 *req_mask, *bus_clk; |
97 | 97 | u32 temp_buffer; |
| 98 | + int error; |
98 | 99 |
|
99 | 100 | /* get our clocks */ |
100 | 101 | clk_pci = clk_get(&pdev->dev, NULL); |
@@ -123,17 +124,14 @@ static int ltq_pci_startup(struct platform_device *pdev) |
123 | 124 | clk_disable(clk_external); |
124 | 125 |
|
125 | 126 | /* 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; |
136 | 133 | } |
| 134 | + gpiod_set_consumer_name(reset_gpio, "pci_reset"); |
137 | 135 |
|
138 | 136 | /* enable auto-switching between PCI and EBU */ |
139 | 137 | ltq_pci_w32(0xa, PCI_CR_CLK_CTRL); |
@@ -195,11 +193,11 @@ static int ltq_pci_startup(struct platform_device *pdev) |
195 | 193 | ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_PCC_IEN) | 0x10, LTQ_EBU_PCC_IEN); |
196 | 194 |
|
197 | 195 | /* 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); |
200 | 198 | wmb(); |
201 | 199 | mdelay(1); |
202 | | - __gpio_set_value(reset_gpio, 1); |
| 200 | + gpiod_set_value_cansleep(reset_gpio, 0); |
203 | 201 | } |
204 | 202 | return 0; |
205 | 203 | } |
|
0 commit comments