[PATCH] pci: pci_mvebu: Add support for reset-gpios

Stefan Roese sr at denx.de
Fri Aug 5 13:01:27 CEST 2022


On 28.07.22 15:03, Pali Rohár wrote:
> Release PERST# signal via GPIO when "reset-gpios" is defined in device tree.
> 
> Signed-off-by: Pali Rohár <pali at kernel.org>
> ---
>   drivers/pci/pci_mvebu.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/pci/pci_mvebu.c b/drivers/pci/pci_mvebu.c
> index d80f87e0cfc6..269c027db204 100644
> --- a/drivers/pci/pci_mvebu.c
> +++ b/drivers/pci/pci_mvebu.c
> @@ -22,6 +22,7 @@
>   #include <asm/io.h>
>   #include <asm/arch/cpu.h>
>   #include <asm/arch/soc.h>
> +#include <asm-generic/gpio.h>
>   #include <linux/bitops.h>
>   #include <linux/delay.h>
>   #include <linux/errno.h>
> @@ -60,6 +61,7 @@ struct mvebu_pcie {
>   	struct resource mem;
>   	void __iomem *iobase;
>   	struct resource io;
> +	struct gpio_desc reset_gpio;
>   	u32 intregs;
>   	u32 port;
>   	u32 lane;
> @@ -416,6 +418,14 @@ static int mvebu_pcie_probe(struct udevice *dev)
>   	struct udevice *ctlr = pci_get_controller(dev);
>   	struct pci_controller *hose = dev_get_uclass_priv(ctlr);
>   	u32 reg;
> +	int ret;
> +
> +	/* Request for optional PERST# GPIO */
> +	ret = gpio_request_by_name(dev, "reset-gpios", 0, &pcie->reset_gpio, GPIOD_IS_OUT);
> +	if (ret && ret != -ENOENT) {
> +		printf("%s: unable to request reset-gpios: %d\n", pcie->name, ret);
> +		return ret;
> +	}
>   
>   	/*
>   	 * Change Class Code of PCI Bridge device to PCI Bridge (0x600400)
> @@ -537,6 +547,10 @@ static int mvebu_pcie_probe(struct udevice *dev)
>   	pcie->cfgcache[(PCI_PREF_MEMORY_BASE - 0x10) / 4] =
>   		PCI_PREF_RANGE_TYPE_64 | (PCI_PREF_RANGE_TYPE_64 << 16);
>   
> +	/* Release PERST# via GPIO when it was defined */
> +	if (dm_gpio_is_valid(&pcie->reset_gpio))
> +		dm_gpio_set_value(&pcie->reset_gpio, 0);
> +
>   	mvebu_pcie_wait_for_link(pcie);
>   
>   	return 0;

While running some build tests, this error shows on some Kirkwood
boards:

$ make pogo_v4_defconfig
$ make -s -j20
===================== WARNING ======================
This board does not use CONFIG_TIMER (Driver Model
for Timer drivers). Please update the board to use
CONFIG_TIMER before the v2023.01 release. Failure to
update by the deadline may result in board removal.
See doc/develop/driver-model/migration.rst for more info.
====================================================
===================== WARNING ======================
This board does not use CONFIG_DM_SERIAL (Driver Model
for Serial drivers). Please update the board to use
CONFIG_DM_SERIAL before the v2023.04 release. Failure to
update by the deadline may result in board removal.
See doc/develop/driver-model/migration.rst for more info.
====================================================
/opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd: 
drivers/pci/pci_mvebu.o: in function `mvebu_pcie_probe':
/home/stefan/git/u-boot/u-boot-marvell/drivers/pci/pci_mvebu.c:424: 
undefined reference to `gpio_request_by_name'
/opt/kernel.org/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ld.bfd: 
/home/stefan/git/u-boot/u-boot-marvell/drivers/pci/pci_mvebu.c:552: 
undefined reference to `dm_gpio_set_value'
make: *** [Makefile:1818: u-boot] Error 1

Could you please take a look and make sure, that world build succeeds?

Thanks,
Stefan


More information about the U-Boot mailing list