All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pci: imx: use vpcie-supply if defined by device-tree
@ 2022-04-13 22:54 Tim Harvey
  2022-04-14  9:14 ` EXT: " Ian Ray
  2022-04-22  8:46 ` sbabic
  0 siblings, 2 replies; 4+ messages in thread
From: Tim Harvey @ 2022-04-13 22:54 UTC (permalink / raw)
  To: Stefano Babic, Fabio Estevam, NXP i . MX U-Boot Team, u-boot
  Cc: Tim Harvey, Ian Ray, Sebastian Reichel, Marek Vasut

If vpcie-supply is defined by device-tree use that if
CONFIG_PCIE_IMX_POWER_GPIO is not defined.

Note that after this the following boards which define
CONFIG_PCIE_IMX_POWER_GPIO in their board header file as well as their
device-tree should be able to remove CONFIG_PCIE_IMX_PERST_GPIO without
consequence:
 - mx6sabresd
 - mx6sxsabresd
 - novena

Note that the ge_bx50v3 board uses CONFIG_PCIE_IMX_POWER_GPIO and does
not have vpcie-supply defined in it's pcie node in the dt thus removing
CONFIG_PCIE_IMX_POWER_GPIO globally can't be done until that board adds
vpcie-supply.

Cc: Ian Ray <ian.ray@ge.com> (maintainer:GE BX50V3 BOARD)
Cc: Sebastian Reichel <sebastian.reichel@collabora.com> (maintainer:GE BX50V3 BOARD)
Cc: Fabio Estevam <festevam@gmail.com> (maintainer:MX6SABRESD BOARD)
Cc: Marek Vasut <marex@denx.de> (maintainer:NOVENA BOARD)
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 arch/arm/include/asm/arch-mx6/sys_proto.h |  2 +-
 drivers/pci/pcie_imx.c                    | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
index c49759af92d1..c7542e4b04e1 100644
--- a/arch/arm/include/asm/arch-mx6/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
@@ -18,7 +18,7 @@
 #define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \
 				   USBPHY_PWD_RXPWDRX))
 
-int imx6_pcie_toggle_power(void);
+int imx6_pcie_toggle_power(struct udevice *vpcie);
 int imx6_pcie_toggle_reset(struct gpio_desc *gpio, bool active_high);
 
 enum ldo_reg {
diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c
index 2cec3900e9ad..f8daedbce359 100644
--- a/drivers/pci/pcie_imx.c
+++ b/drivers/pci/pcie_imx.c
@@ -14,6 +14,7 @@
 #include <log.h>
 #include <malloc.h>
 #include <pci.h>
+#include <power/regulator.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/iomux.h>
 #include <asm/arch/crm_regs.h>
@@ -102,6 +103,7 @@ struct imx_pcie_priv {
 	void __iomem		*cfg_base;
 	struct gpio_desc	reset_gpio;
 	bool			reset_active_high;
+	struct udevice		*vpcie;
 };
 
 /*
@@ -530,7 +532,7 @@ static int imx6_pcie_init_phy(void)
 	return 0;
 }
 
-__weak int imx6_pcie_toggle_power(void)
+__weak int imx6_pcie_toggle_power(struct udevice *vpcie)
 {
 #ifdef CONFIG_PCIE_IMX_POWER_GPIO
 	gpio_request(CONFIG_PCIE_IMX_POWER_GPIO, "pcie_power");
@@ -540,6 +542,15 @@ __weak int imx6_pcie_toggle_power(void)
 	mdelay(20);
 	gpio_free(CONFIG_PCIE_IMX_POWER_GPIO);
 #endif
+
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
+	if (vpcie) {
+		regulator_set_enable(vpcie, false);
+		mdelay(20);
+		regulator_set_enable(vpcie, true);
+		mdelay(20);
+	}
+#endif
 	return 0;
 }
 
@@ -598,7 +609,7 @@ static int imx6_pcie_deassert_core_reset(struct imx_pcie_priv *priv)
 {
 	struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
 
-	imx6_pcie_toggle_power();
+	imx6_pcie_toggle_power(priv->vpcie);
 
 	enable_pcie_clock();
 
@@ -717,6 +728,10 @@ static int imx_pcie_dm_probe(struct udevice *dev)
 {
 	struct imx_pcie_priv *priv = dev_get_priv(dev);
 
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
+	device_get_supply_regulator(dev, "vpcie-supply", &priv->vpcie);
+#endif
+
 	/* if PERST# valid from dt then assert it */
 	gpio_request_by_name(dev, "reset-gpio", 0, &priv->reset_gpio,
 			     GPIOD_IS_OUT);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: EXT: [PATCH] pci: imx: use vpcie-supply if defined by device-tree
  2022-04-13 22:54 [PATCH] pci: imx: use vpcie-supply if defined by device-tree Tim Harvey
@ 2022-04-14  9:14 ` Ian Ray
  2022-04-14 15:46   ` Tim Harvey
  2022-04-22  8:46 ` sbabic
  1 sibling, 1 reply; 4+ messages in thread
From: Ian Ray @ 2022-04-14  9:14 UTC (permalink / raw)
  To: Tim Harvey
  Cc: Stefano Babic, Fabio Estevam, NXP i . MX U-Boot Team, u-boot,
	Sebastian Reichel, Marek Vasut

On Wed, Apr 13, 2022 at 03:54:37PM -0700, Tim Harvey wrote:
> 
> If vpcie-supply is defined by device-tree use that if
> CONFIG_PCIE_IMX_POWER_GPIO is not defined.
> 
> Note that after this the following boards which define
> CONFIG_PCIE_IMX_POWER_GPIO in their board header file as well as their
> device-tree should be able to remove CONFIG_PCIE_IMX_PERST_GPIO without
> consequence:
>  - mx6sabresd
>  - mx6sxsabresd
>  - novena
> 
> Note that the ge_bx50v3 board uses CONFIG_PCIE_IMX_POWER_GPIO and does
> not have vpcie-supply defined in it's pcie node in the dt thus removing
> CONFIG_PCIE_IMX_POWER_GPIO globally can't be done until that board adds
> vpcie-supply.

The use of CONFIG_PCIE_IMX_POWER_GPIO by ge_bx50v3 appears to be a
mistake.  That GPIO is actually an input "Q7_3V3_PCIE_WAKE#_IN".  Thank
you for the report -- I will prepare a patch to remove that #define.


> 
> Cc: Ian Ray <ian.ray@ge.com> (maintainer:GE BX50V3 BOARD)
> Cc: Sebastian Reichel <sebastian.reichel@collabora.com> (maintainer:GE BX50V3 BOARD)
> Cc: Fabio Estevam <festevam@gmail.com> (maintainer:MX6SABRESD BOARD)
> Cc: Marek Vasut <marex@denx.de> (maintainer:NOVENA BOARD)
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> ---
>  arch/arm/include/asm/arch-mx6/sys_proto.h |  2 +-
>  drivers/pci/pcie_imx.c                    | 19 +++++++++++++++++--
>  2 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
> index c49759af92d1..c7542e4b04e1 100644
> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> @@ -18,7 +18,7 @@
>  #define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \
>  				   USBPHY_PWD_RXPWDRX))
>  
> -int imx6_pcie_toggle_power(void);
> +int imx6_pcie_toggle_power(struct udevice *vpcie);
>  int imx6_pcie_toggle_reset(struct gpio_desc *gpio, bool active_high);
>  
>  enum ldo_reg {
> diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c
> index 2cec3900e9ad..f8daedbce359 100644
> --- a/drivers/pci/pcie_imx.c
> +++ b/drivers/pci/pcie_imx.c
> @@ -14,6 +14,7 @@
>  #include <log.h>
>  #include <malloc.h>
>  #include <pci.h>
> +#include <power/regulator.h>
>  #include <asm/arch/clock.h>
>  #include <asm/arch/iomux.h>
>  #include <asm/arch/crm_regs.h>
> @@ -102,6 +103,7 @@ struct imx_pcie_priv {
>  	void __iomem		*cfg_base;
>  	struct gpio_desc	reset_gpio;
>  	bool			reset_active_high;
> +	struct udevice		*vpcie;
>  };
>  
>  /*
> @@ -530,7 +532,7 @@ static int imx6_pcie_init_phy(void)
>  	return 0;
>  }
>  
> -__weak int imx6_pcie_toggle_power(void)
> +__weak int imx6_pcie_toggle_power(struct udevice *vpcie)
>  {
>  #ifdef CONFIG_PCIE_IMX_POWER_GPIO
>  	gpio_request(CONFIG_PCIE_IMX_POWER_GPIO, "pcie_power");
> @@ -540,6 +542,15 @@ __weak int imx6_pcie_toggle_power(void)
>  	mdelay(20);
>  	gpio_free(CONFIG_PCIE_IMX_POWER_GPIO);
>  #endif
> +
> +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> +	if (vpcie) {
> +		regulator_set_enable(vpcie, false);
> +		mdelay(20);
> +		regulator_set_enable(vpcie, true);
> +		mdelay(20);
> +	}
> +#endif
>  	return 0;
>  }
>  
> @@ -598,7 +609,7 @@ static int imx6_pcie_deassert_core_reset(struct imx_pcie_priv *priv)
>  {
>  	struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
>  
> -	imx6_pcie_toggle_power();
> +	imx6_pcie_toggle_power(priv->vpcie);
>  
>  	enable_pcie_clock();
>  
> @@ -717,6 +728,10 @@ static int imx_pcie_dm_probe(struct udevice *dev)
>  {
>  	struct imx_pcie_priv *priv = dev_get_priv(dev);
>  
> +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> +	device_get_supply_regulator(dev, "vpcie-supply", &priv->vpcie);
> +#endif
> +
>  	/* if PERST# valid from dt then assert it */
>  	gpio_request_by_name(dev, "reset-gpio", 0, &priv->reset_gpio,
>  			     GPIOD_IS_OUT);
> -- 
> 2.17.1
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: EXT: [PATCH] pci: imx: use vpcie-supply if defined by device-tree
  2022-04-14  9:14 ` EXT: " Ian Ray
@ 2022-04-14 15:46   ` Tim Harvey
  0 siblings, 0 replies; 4+ messages in thread
From: Tim Harvey @ 2022-04-14 15:46 UTC (permalink / raw)
  To: Ian Ray
  Cc: Stefano Babic, Fabio Estevam, NXP i . MX U-Boot Team, u-boot,
	Sebastian Reichel, Marek Vasut

On Thu, Apr 14, 2022 at 2:14 AM Ian Ray <ian.ray@ge.com> wrote:
>
> On Wed, Apr 13, 2022 at 03:54:37PM -0700, Tim Harvey wrote:
> >
> > If vpcie-supply is defined by device-tree use that if
> > CONFIG_PCIE_IMX_POWER_GPIO is not defined.
> >
> > Note that after this the following boards which define
> > CONFIG_PCIE_IMX_POWER_GPIO in their board header file as well as their
> > device-tree should be able to remove CONFIG_PCIE_IMX_PERST_GPIO without
> > consequence:
> >  - mx6sabresd
> >  - mx6sxsabresd
> >  - novena
> >
> > Note that the ge_bx50v3 board uses CONFIG_PCIE_IMX_POWER_GPIO and does
> > not have vpcie-supply defined in it's pcie node in the dt thus removing
> > CONFIG_PCIE_IMX_POWER_GPIO globally can't be done until that board adds
> > vpcie-supply.
>
> The use of CONFIG_PCIE_IMX_POWER_GPIO by ge_bx50v3 appears to be a
> mistake.  That GPIO is actually an input "Q7_3V3_PCIE_WAKE#_IN".  Thank
> you for the report -- I will prepare a patch to remove that #define.
>

Ian,

Great... cc me on that patch if you don't mind.

Marek, looks like you're the maintainer of the novena board, do you
have one around to test PCI reset with CONFIG_PCIE_IMX_POWER_GPIO
removed?

Fabio, looks like you're the maintainer of the mx6sabresd and
mx6sxsabresd boards, do you have one around to test PCI reset with
CONFIG_PCIE_IMX_POWER_GPIO removed?

If Marke and Fabio can confirm that removing
CONFIG_PCIE_IMX_POWER_GPIO isn't an issue I can submit a series with
this followed by the removal of CONFIG_PCIE_IMX_POWER_GPIO.

Best Regards,

Tim

>
> >
> > Cc: Ian Ray <ian.ray@ge.com> (maintainer:GE BX50V3 BOARD)
> > Cc: Sebastian Reichel <sebastian.reichel@collabora.com> (maintainer:GE BX50V3 BOARD)
> > Cc: Fabio Estevam <festevam@gmail.com> (maintainer:MX6SABRESD BOARD)
> > Cc: Marek Vasut <marex@denx.de> (maintainer:NOVENA BOARD)
> > Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> > ---
> >  arch/arm/include/asm/arch-mx6/sys_proto.h |  2 +-
> >  drivers/pci/pcie_imx.c                    | 19 +++++++++++++++++--
> >  2 files changed, 18 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
> > index c49759af92d1..c7542e4b04e1 100644
> > --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> > +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> > @@ -18,7 +18,7 @@
> >  #define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \
> >                                  USBPHY_PWD_RXPWDRX))
> >
> > -int imx6_pcie_toggle_power(void);
> > +int imx6_pcie_toggle_power(struct udevice *vpcie);
> >  int imx6_pcie_toggle_reset(struct gpio_desc *gpio, bool active_high);
> >
> >  enum ldo_reg {
> > diff --git a/drivers/pci/pcie_imx.c b/drivers/pci/pcie_imx.c
> > index 2cec3900e9ad..f8daedbce359 100644
> > --- a/drivers/pci/pcie_imx.c
> > +++ b/drivers/pci/pcie_imx.c
> > @@ -14,6 +14,7 @@
> >  #include <log.h>
> >  #include <malloc.h>
> >  #include <pci.h>
> > +#include <power/regulator.h>
> >  #include <asm/arch/clock.h>
> >  #include <asm/arch/iomux.h>
> >  #include <asm/arch/crm_regs.h>
> > @@ -102,6 +103,7 @@ struct imx_pcie_priv {
> >       void __iomem            *cfg_base;
> >       struct gpio_desc        reset_gpio;
> >       bool                    reset_active_high;
> > +     struct udevice          *vpcie;
> >  };
> >
> >  /*
> > @@ -530,7 +532,7 @@ static int imx6_pcie_init_phy(void)
> >       return 0;
> >  }
> >
> > -__weak int imx6_pcie_toggle_power(void)
> > +__weak int imx6_pcie_toggle_power(struct udevice *vpcie)
> >  {
> >  #ifdef CONFIG_PCIE_IMX_POWER_GPIO
> >       gpio_request(CONFIG_PCIE_IMX_POWER_GPIO, "pcie_power");
> > @@ -540,6 +542,15 @@ __weak int imx6_pcie_toggle_power(void)
> >       mdelay(20);
> >       gpio_free(CONFIG_PCIE_IMX_POWER_GPIO);
> >  #endif
> > +
> > +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> > +     if (vpcie) {
> > +             regulator_set_enable(vpcie, false);
> > +             mdelay(20);
> > +             regulator_set_enable(vpcie, true);
> > +             mdelay(20);
> > +     }
> > +#endif
> >       return 0;
> >  }
> >
> > @@ -598,7 +609,7 @@ static int imx6_pcie_deassert_core_reset(struct imx_pcie_priv *priv)
> >  {
> >       struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
> >
> > -     imx6_pcie_toggle_power();
> > +     imx6_pcie_toggle_power(priv->vpcie);
> >
> >       enable_pcie_clock();
> >
> > @@ -717,6 +728,10 @@ static int imx_pcie_dm_probe(struct udevice *dev)
> >  {
> >       struct imx_pcie_priv *priv = dev_get_priv(dev);
> >
> > +#if CONFIG_IS_ENABLED(DM_REGULATOR)
> > +     device_get_supply_regulator(dev, "vpcie-supply", &priv->vpcie);
> > +#endif
> > +
> >       /* if PERST# valid from dt then assert it */
> >       gpio_request_by_name(dev, "reset-gpio", 0, &priv->reset_gpio,
> >                            GPIOD_IS_OUT);
> > --
> > 2.17.1
> >
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] pci: imx: use vpcie-supply if defined by device-tree
  2022-04-13 22:54 [PATCH] pci: imx: use vpcie-supply if defined by device-tree Tim Harvey
  2022-04-14  9:14 ` EXT: " Ian Ray
@ 2022-04-22  8:46 ` sbabic
  1 sibling, 0 replies; 4+ messages in thread
From: sbabic @ 2022-04-22  8:46 UTC (permalink / raw)
  To: Tim Harvey, u-boot

> If vpcie-supply is defined by device-tree use that if
> CONFIG_PCIE_IMX_POWER_GPIO is not defined.
> Note that after this the following boards which define
> CONFIG_PCIE_IMX_POWER_GPIO in their board header file as well as their
> device-tree should be able to remove CONFIG_PCIE_IMX_PERST_GPIO without
> consequence:
>  - mx6sabresd
>  - mx6sxsabresd
>  - novena
> Note that the ge_bx50v3 board uses CONFIG_PCIE_IMX_POWER_GPIO and does
> not have vpcie-supply defined in it's pcie node in the dt thus removing
> CONFIG_PCIE_IMX_POWER_GPIO globally can't be done until that board adds
> vpcie-supply.
> Cc: Ian Ray <ian.ray@ge.com> (maintainer:GE BX50V3 BOARD)
> Cc: Sebastian Reichel <sebastian.reichel@collabora.com> (maintainer:GE BX50V3 BOARD)
> Cc: Fabio Estevam <festevam@gmail.com> (maintainer:MX6SABRESD BOARD)
> Cc: Marek Vasut <marex@denx.de> (maintainer:NOVENA BOARD)
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-22  8:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13 22:54 [PATCH] pci: imx: use vpcie-supply if defined by device-tree Tim Harvey
2022-04-14  9:14 ` EXT: " Ian Ray
2022-04-14 15:46   ` Tim Harvey
2022-04-22  8:46 ` sbabic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.