PCI: mvebu: Use gpio_desc to carry around gpio
Use a gpio_desc to carry around the gpio, so we can then make use of the GPIOF_ACTIVE_LOW property rather than carrying that around as well. This also avoids needing to use gpio_is_valid() to check whether we have a GPIO; checking for a non-NULL descriptor is simpler. Tested-by: Willy Tarreau <w@1wt.eu> (Iomega iConnect Kirkwood, MiraBox Armada 370) Tested-by: Andrew Lunn <andrew@lunn.ch> (D-Link DIR664 Kirkwood) Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> (Armada XP GP) Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
19fdb80091
commit
8a182c2e4b
|
@ -119,8 +119,7 @@ struct mvebu_pcie_port {
|
||||||
unsigned int io_target;
|
unsigned int io_target;
|
||||||
unsigned int io_attr;
|
unsigned int io_attr;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
int reset_gpio;
|
struct gpio_desc *reset_gpio;
|
||||||
int reset_active_low;
|
|
||||||
char *reset_name;
|
char *reset_name;
|
||||||
struct mvebu_sw_pci_bridge bridge;
|
struct mvebu_sw_pci_bridge bridge;
|
||||||
struct device_node *dn;
|
struct device_node *dn;
|
||||||
|
@ -940,7 +939,7 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
|
||||||
{
|
{
|
||||||
struct device *dev = &pcie->pdev->dev;
|
struct device *dev = &pcie->pdev->dev;
|
||||||
enum of_gpio_flags flags;
|
enum of_gpio_flags flags;
|
||||||
int ret;
|
int reset_gpio, ret;
|
||||||
|
|
||||||
port->pcie = pcie;
|
port->pcie = pcie;
|
||||||
|
|
||||||
|
@ -980,15 +979,15 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
|
||||||
port->io_attr = -1;
|
port->io_attr = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
port->reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0,
|
reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags);
|
||||||
&flags);
|
if (reset_gpio == -EPROBE_DEFER) {
|
||||||
if (port->reset_gpio == -EPROBE_DEFER) {
|
ret = reset_gpio;
|
||||||
ret = port->reset_gpio;
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpio_is_valid(port->reset_gpio)) {
|
if (gpio_is_valid(reset_gpio)) {
|
||||||
port->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
|
unsigned long gpio_flags;
|
||||||
|
|
||||||
port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
|
port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
|
||||||
port->name);
|
port->name);
|
||||||
if (!port->reset_name) {
|
if (!port->reset_name) {
|
||||||
|
@ -996,13 +995,24 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = devm_gpio_request_one(dev, port->reset_gpio,
|
if (flags & OF_GPIO_ACTIVE_LOW) {
|
||||||
GPIOF_DIR_OUT, port->reset_name);
|
dev_info(dev, "%s: reset gpio is active low\n",
|
||||||
|
of_node_full_name(child));
|
||||||
|
gpio_flags = GPIOF_ACTIVE_LOW |
|
||||||
|
GPIOF_OUT_INIT_LOW;
|
||||||
|
} else {
|
||||||
|
gpio_flags = GPIOF_OUT_INIT_HIGH;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = devm_gpio_request_one(dev, reset_gpio, gpio_flags,
|
||||||
|
port->reset_name);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret == -EPROBE_DEFER)
|
if (ret == -EPROBE_DEFER)
|
||||||
goto err;
|
goto err;
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
port->reset_gpio = gpio_to_desc(reset_gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
port->clk = of_clk_get_by_name(child, NULL);
|
port->clk = of_clk_get_by_name(child, NULL);
|
||||||
|
@ -1104,15 +1114,14 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
|
||||||
if (!child)
|
if (!child)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (gpio_is_valid(port->reset_gpio)) {
|
if (port->reset_gpio) {
|
||||||
u32 reset_udelay = 20000;
|
u32 reset_udelay = 20000;
|
||||||
|
|
||||||
of_property_read_u32(child, "reset-delay-us",
|
of_property_read_u32(child, "reset-delay-us",
|
||||||
&reset_udelay);
|
&reset_udelay);
|
||||||
|
|
||||||
gpio_set_value_cansleep(port->reset_gpio,
|
gpiod_set_value_cansleep(port->reset_gpio, 0);
|
||||||
!!port->reset_active_low);
|
msleep(reset_udelay / 1000);
|
||||||
msleep(reset_udelay/1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = clk_prepare_enable(port->clk);
|
ret = clk_prepare_enable(port->clk);
|
||||||
|
|
Loading…
Reference in New Issue