mirror of
https://github.com/torvalds/linux.git
synced 2024-12-06 19:11:31 +00:00
PCI: histb: 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. Link: https://lore.kernel.org/r/20220906204301.3736813-1-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
ae6b9a65af
commit
1d26a55fbe
@ -10,11 +10,11 @@
|
|||||||
|
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_gpio.h>
|
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
#include <linux/phy/phy.h>
|
#include <linux/phy/phy.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
@ -60,7 +60,7 @@ struct histb_pcie {
|
|||||||
struct reset_control *sys_reset;
|
struct reset_control *sys_reset;
|
||||||
struct reset_control *bus_reset;
|
struct reset_control *bus_reset;
|
||||||
void __iomem *ctrl;
|
void __iomem *ctrl;
|
||||||
int reset_gpio;
|
struct gpio_desc *reset_gpio;
|
||||||
struct regulator *vpcie;
|
struct regulator *vpcie;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -212,8 +212,8 @@ static void histb_pcie_host_disable(struct histb_pcie *hipcie)
|
|||||||
clk_disable_unprepare(hipcie->sys_clk);
|
clk_disable_unprepare(hipcie->sys_clk);
|
||||||
clk_disable_unprepare(hipcie->bus_clk);
|
clk_disable_unprepare(hipcie->bus_clk);
|
||||||
|
|
||||||
if (gpio_is_valid(hipcie->reset_gpio))
|
if (hipcie->reset_gpio)
|
||||||
gpio_set_value_cansleep(hipcie->reset_gpio, 0);
|
gpiod_set_value_cansleep(hipcie->reset_gpio, 1);
|
||||||
|
|
||||||
if (hipcie->vpcie)
|
if (hipcie->vpcie)
|
||||||
regulator_disable(hipcie->vpcie);
|
regulator_disable(hipcie->vpcie);
|
||||||
@ -235,8 +235,8 @@ static int histb_pcie_host_enable(struct dw_pcie_rp *pp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpio_is_valid(hipcie->reset_gpio))
|
if (hipcie->reset_gpio)
|
||||||
gpio_set_value_cansleep(hipcie->reset_gpio, 1);
|
gpiod_set_value_cansleep(hipcie->reset_gpio, 0);
|
||||||
|
|
||||||
ret = clk_prepare_enable(hipcie->bus_clk);
|
ret = clk_prepare_enable(hipcie->bus_clk);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -298,10 +298,7 @@ static int histb_pcie_probe(struct platform_device *pdev)
|
|||||||
struct histb_pcie *hipcie;
|
struct histb_pcie *hipcie;
|
||||||
struct dw_pcie *pci;
|
struct dw_pcie *pci;
|
||||||
struct dw_pcie_rp *pp;
|
struct dw_pcie_rp *pp;
|
||||||
struct device_node *np = pdev->dev.of_node;
|
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
enum of_gpio_flags of_flags;
|
|
||||||
unsigned long flag = GPIOF_DIR_OUT;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
hipcie = devm_kzalloc(dev, sizeof(*hipcie), GFP_KERNEL);
|
hipcie = devm_kzalloc(dev, sizeof(*hipcie), GFP_KERNEL);
|
||||||
@ -336,17 +333,19 @@ static int histb_pcie_probe(struct platform_device *pdev)
|
|||||||
hipcie->vpcie = NULL;
|
hipcie->vpcie = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
hipcie->reset_gpio = of_get_named_gpio_flags(np,
|
hipcie->reset_gpio = devm_gpiod_get_optional(dev, "reset",
|
||||||
"reset-gpios", 0, &of_flags);
|
GPIOD_OUT_HIGH);
|
||||||
if (of_flags & OF_GPIO_ACTIVE_LOW)
|
ret = PTR_ERR_OR_ZERO(hipcie->reset_gpio);
|
||||||
flag |= GPIOF_ACTIVE_LOW;
|
if (ret) {
|
||||||
if (gpio_is_valid(hipcie->reset_gpio)) {
|
dev_err(dev, "unable to request reset gpio: %d\n", ret);
|
||||||
ret = devm_gpio_request_one(dev, hipcie->reset_gpio,
|
return ret;
|
||||||
flag, "PCIe device power control");
|
}
|
||||||
if (ret) {
|
|
||||||
dev_err(dev, "unable to request gpio\n");
|
ret = gpiod_set_consumer_name(hipcie->reset_gpio,
|
||||||
return ret;
|
"PCIe device power control");
|
||||||
}
|
if (ret) {
|
||||||
|
dev_err(dev, "unable to set reset gpio name: %d\n", ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
hipcie->aux_clk = devm_clk_get(dev, "aux");
|
hipcie->aux_clk = devm_clk_get(dev, "aux");
|
||||||
|
Loading…
Reference in New Issue
Block a user