All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Samuel Holland <samuel@sholland.org>
Cc: Jagan Teki <jagan@amarulasolutions.com>,
	u-boot@lists.denx.de, Icenowy Zheng <uwu@icenowy.me>,
	Jernej Skrabec <jernej.skrabec@gmail.com>
Subject: Re: [RFC PATCH 02/17] sunxi: remove CONFIG_MACPWR
Date: Wed, 14 Dec 2022 14:23:03 +0000	[thread overview]
Message-ID: <20221214142303.115f23a1@donnerap.cambridge.arm.com> (raw)
In-Reply-To: <fdadd3a4-b9f9-e80b-29f4-c4cf1c9bae5b@sholland.org>

On Wed, 14 Dec 2022 03:09:22 -0600
Samuel Holland <samuel@sholland.org> wrote:

Hi Samuel,

> Thanks for this cleanup! With the two issues below addressed, it looks
> good to me.

many thanks for having such a thorough look!

> On 12/5/22 18:45, Andre Przywara wrote:
> > The CONFIG_MACPWR Kconfig symbol is used to point to a GPIO that enables
> > the power for the Ethernet "MAC" (mostly PHY, really).
> > In the DT this is described with the phy-supply property in the MAC DT
> > node, pointing to a (GPIO controlled) regulator. Since we need Ethernet
> > only in U-Boot proper, and use a DM driver there, we should use the DT
> > instead of hardcoding this.
> > 
> > Add code to the sun8i_emac and sunxi_emac drivers to check the DT for
> > that regulator and enable it, at probe time. Then drop the current code
> > from board.c, which was doing that job before.
> > This allows us to remove the MACPWR Kconfig definition and the respective
> > values from the defconfigs.  
> 
> ... and we don't care about sun7i-gmac here because there's no U-Boot
> driver for it, and the Linux driver already uses the devicetree.

If you mean the Gigabit MAC on the A20 (allwinner,sun7i-a20-gmac), that's
implemented in drivers/net/designware.c. And this code already parses
phy-supply. I think I tried it on my BananaPi, but can double check.

> 
> > Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> > ---
> >  arch/arm/mach-sunxi/Kconfig           |  7 -------
> >  board/sunxi/board.c                   | 10 ----------
> >  configs/Bananapi_M2_Ultra_defconfig   |  1 -
> >  configs/Bananapi_defconfig            |  1 -
> >  configs/Bananapro_defconfig           |  1 -
> >  configs/Lamobo_R1_defconfig           |  1 -
> >  configs/Mele_A1000_defconfig          |  1 -
> >  configs/Orangepi_defconfig            |  1 -
> >  configs/Orangepi_mini_defconfig       |  1 -
> >  configs/bananapi_m1_plus_defconfig    |  1 -
> >  configs/bananapi_m2_plus_h3_defconfig |  1 -
> >  configs/bananapi_m2_plus_h5_defconfig |  1 -
> >  configs/i12-tvbox_defconfig           |  1 -
> >  configs/jesurun_q5_defconfig          |  1 -
> >  configs/mixtile_loftq_defconfig       |  1 -
> >  configs/nanopi_m1_plus_defconfig      |  1 -
> >  configs/nanopi_neo_plus2_defconfig    |  1 -
> >  configs/nanopi_r1s_h5_defconfig       |  1 -
> >  configs/orangepi_pc2_defconfig        |  1 -
> >  configs/orangepi_plus2e_defconfig     |  1 -
> >  configs/orangepi_plus_defconfig       |  1 -
> >  configs/orangepi_win_defconfig        |  1 -
> >  configs/pine_h64_defconfig            |  1 -
> >  configs/zeropi_defconfig              |  1 -
> >  drivers/net/sun8i_emac.c              |  9 +++++++--
> >  drivers/net/sunxi_emac.c              | 10 ++++++++--
> >  26 files changed, 15 insertions(+), 43 deletions(-)
> > 
> > diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> > index 5f95fe72d08..6220175d612 100644
> > --- a/arch/arm/mach-sunxi/Kconfig
> > +++ b/arch/arm/mach-sunxi/Kconfig
> > @@ -645,13 +645,6 @@ config OLD_SUNXI_KERNEL_COMPAT
> >  	Set this to enable various workarounds for old kernels, this results in
> >  	sub-optimal settings for newer kernels, only enable if needed.
> >  
> > -config MACPWR
> > -	string "MAC power pin"
> > -	default ""
> > -	help
> > -	  Set the pin used to power the MAC. This takes a string in the format
> > -	  understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
> > -
> >  config MMC0_CD_PIN
> >  	string "Card detect pin for mmc0"
> >  	default "PF6" if MACH_SUN8I_A83T || MACH_SUNXI_H3_H5 || MACH_SUN50I
> > diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> > index ec35a7f06bd..3077cc71ebd 100644
> > --- a/board/sunxi/board.c
> > +++ b/board/sunxi/board.c
> > @@ -228,15 +228,6 @@ int board_init(void)
> >  	if (ret)
> >  		return ret;
> >  
> > -	/* strcmp() would look better, but doesn't get optimised away. */
> > -	if (CONFIG_MACPWR[0]) {
> > -		macpwr_pin = sunxi_name_to_gpio(CONFIG_MACPWR);
> > -		if (macpwr_pin >= 0) {
> > -			gpio_request(macpwr_pin, "macpwr");
> > -			gpio_direction_output(macpwr_pin, 1);
> > -		}
> > -	}
> > -
> >  #if CONFIG_IS_ENABLED(DM_I2C)
> >  	/*
> >  	 * Temporary workaround for enabling I2C clocks until proper sunxi DM
> > @@ -244,7 +235,6 @@ int board_init(void)
> >  	 */
> >  	i2c_init_board();
> >  #endif
> > -
> >  	eth_init_board();
> >  
> >  	return 0;
> > diff --git a/configs/Bananapi_M2_Ultra_defconfig b/configs/Bananapi_M2_Ultra_defconfig
> > index 0bd163afdd7..1c4b90ab9d2 100644
> > --- a/configs/Bananapi_M2_Ultra_defconfig
> > +++ b/configs/Bananapi_M2_Ultra_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-r40-bananapi-m2-ultra"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN8I_R40=y
> >  CONFIG_DRAM_CLK=576
> > -CONFIG_MACPWR="PA17"  
> 
> This GPIO is actually the PHY reset line, not its power supply. Since
> that line has a pull up, I don't think this was necessary to begin with.

Ha, good find. Indeed the schematic confirms that. And the BPi M2 Berry
uses the same connection, but doesn't mention PA17 at all (neither in the
defconfig nor in the DT). I don't have a M2U, but will play around with my
M2 Berry, to simulate that.

> >  CONFIG_MMC0_CD_PIN="PH13"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  CONFIG_USB1_VBUS_PIN="PH23"
> > diff --git a/configs/Bananapi_defconfig b/configs/Bananapi_defconfig
> > index 2814d77c187..2a590e141d9 100644
> > --- a/configs/Bananapi_defconfig
> > +++ b/configs/Bananapi_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-bananapi"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN7I=y
> >  CONFIG_DRAM_CLK=432
> > -CONFIG_MACPWR="PH23"
> >  CONFIG_VIDEO_COMPOSITE=y
> >  CONFIG_GMAC_TX_DELAY=3
> >  CONFIG_AHCI=y
> > diff --git a/configs/Bananapro_defconfig b/configs/Bananapro_defconfig
> > index 11375991c81..4b56195d4f2 100644
> > --- a/configs/Bananapro_defconfig
> > +++ b/configs/Bananapro_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-bananapro"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN7I=y
> >  CONFIG_DRAM_CLK=432
> > -CONFIG_MACPWR="PH23"
> >  CONFIG_USB1_VBUS_PIN="PH0"
> >  CONFIG_USB2_VBUS_PIN="PH1"
> >  CONFIG_VIDEO_COMPOSITE=y
> > diff --git a/configs/Lamobo_R1_defconfig b/configs/Lamobo_R1_defconfig
> > index d51601ff10f..fc63a7fbd46 100644
> > --- a/configs/Lamobo_R1_defconfig
> > +++ b/configs/Lamobo_R1_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-lamobo-r1"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN7I=y
> >  CONFIG_DRAM_CLK=432
> > -CONFIG_MACPWR="PH23"
> >  CONFIG_MMC0_CD_PIN="PH10"
> >  CONFIG_GMAC_TX_DELAY=4
> >  CONFIG_AHCI=y
> > diff --git a/configs/Mele_A1000_defconfig b/configs/Mele_A1000_defconfig
> > index 3424b976772..a407550f6bd 100644
> > --- a/configs/Mele_A1000_defconfig
> > +++ b/configs/Mele_A1000_defconfig
> > @@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
> >  CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-a1000"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN4I=y
> > -CONFIG_MACPWR="PH15"
> >  CONFIG_VIDEO_VGA=y
> >  CONFIG_VIDEO_COMPOSITE=y
> >  CONFIG_AHCI=y
> > diff --git a/configs/Orangepi_defconfig b/configs/Orangepi_defconfig
> > index b4d5feff309..5c14e327e39 100644
> > --- a/configs/Orangepi_defconfig
> > +++ b/configs/Orangepi_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-orangepi"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN7I=y
> >  CONFIG_DRAM_CLK=432
> > -CONFIG_MACPWR="PH23"
> >  CONFIG_USB1_VBUS_PIN="PH26"
> >  CONFIG_USB2_VBUS_PIN="PH22"
> >  CONFIG_VIDEO_VGA=y
> > diff --git a/configs/Orangepi_mini_defconfig b/configs/Orangepi_mini_defconfig
> > index 43197381114..fdacf0cd123 100644
> > --- a/configs/Orangepi_mini_defconfig
> > +++ b/configs/Orangepi_mini_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-orangepi-mini"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN7I=y
> >  CONFIG_DRAM_CLK=432
> > -CONFIG_MACPWR="PH23"
> >  CONFIG_MMC0_CD_PIN="PH10"
> >  CONFIG_MMC3_CD_PIN="PH11"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=3
> > diff --git a/configs/bananapi_m1_plus_defconfig b/configs/bananapi_m1_plus_defconfig
> > index 12ea6a3236a..f398c70ce1a 100644
> > --- a/configs/bananapi_m1_plus_defconfig
> > +++ b/configs/bananapi_m1_plus_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-bananapi-m1-plus"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN7I=y
> >  CONFIG_DRAM_CLK=432
> > -CONFIG_MACPWR="PH23"
> >  CONFIG_VIDEO_COMPOSITE=y
> >  CONFIG_GMAC_TX_DELAY=3
> >  CONFIG_AHCI=y
> > diff --git a/configs/bananapi_m2_plus_h3_defconfig b/configs/bananapi_m2_plus_h3_defconfig
> > index 2bd5a70a2d0..ab138a43060 100644
> > --- a/configs/bananapi_m2_plus_h3_defconfig
> > +++ b/configs/bananapi_m2_plus_h3_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-bananapi-m2-plus"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN8I_H3=y
> >  CONFIG_DRAM_CLK=672
> > -CONFIG_MACPWR="PD6"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/configs/bananapi_m2_plus_h5_defconfig b/configs/bananapi_m2_plus_h5_defconfig
> > index 926cf6f5a4d..29200e53585 100644
> > --- a/configs/bananapi_m2_plus_h5_defconfig
> > +++ b/configs/bananapi_m2_plus_h5_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-bananapi-m2-plus"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN50I_H5=y
> >  CONFIG_DRAM_CLK=672
> > -CONFIG_MACPWR="PD6"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/configs/i12-tvbox_defconfig b/configs/i12-tvbox_defconfig
> > index d75a7992a82..11971a8a766 100644
> > --- a/configs/i12-tvbox_defconfig
> > +++ b/configs/i12-tvbox_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-i12-tvbox"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN7I=y
> >  CONFIG_DRAM_CLK=384
> > -CONFIG_MACPWR="PH21"
> >  CONFIG_VIDEO_COMPOSITE=y
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/configs/jesurun_q5_defconfig b/configs/jesurun_q5_defconfig
> > index 2e6b045b549..701d8ecfaa8 100644
> > --- a/configs/jesurun_q5_defconfig
> > +++ b/configs/jesurun_q5_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-jesurun-q5"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN4I=y
> >  CONFIG_DRAM_CLK=312
> > -CONFIG_MACPWR="PH19"
> >  CONFIG_USB0_VBUS_PIN="PB9"
> >  CONFIG_VIDEO_COMPOSITE=y
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> > diff --git a/configs/mixtile_loftq_defconfig b/configs/mixtile_loftq_defconfig
> > index 646594b6e07..cdee80b3566 100644
> > --- a/configs/mixtile_loftq_defconfig
> > +++ b/configs/mixtile_loftq_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-mixtile-loftq"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN6I=y
> >  CONFIG_DRAM_ZQ=251
> > -CONFIG_MACPWR="PA21"  
> 
> This board does not have a regulator in its devicetree.

Yeah, that's an odd one, as the DT only exists in the U-Boot tree. So we
could just add it. I guess given the age and "support status" of this
board no one would care anyways ;-)

> I verified the rest of the boards have an equivalent GPIO-controlled
> fixed regulator in their devicetrees.

Oh, many thanks!

> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  CONFIG_USB1_VBUS_PIN="PH24"
> >  CONFIG_USB2_VBUS_PIN=""
> > diff --git a/configs/nanopi_m1_plus_defconfig b/configs/nanopi_m1_plus_defconfig
> > index 89065f0411a..a3b82de4de6 100644
> > --- a/configs/nanopi_m1_plus_defconfig
> > +++ b/configs/nanopi_m1_plus_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-nanopi-m1-plus"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN8I_H3=y
> >  CONFIG_DRAM_CLK=408
> > -CONFIG_MACPWR="PD6"
> >  CONFIG_MMC0_CD_PIN="PH13"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> > diff --git a/configs/nanopi_neo_plus2_defconfig b/configs/nanopi_neo_plus2_defconfig
> > index d462b63e944..f7e3efdfe5e 100644
> > --- a/configs/nanopi_neo_plus2_defconfig
> > +++ b/configs/nanopi_neo_plus2_defconfig
> > @@ -6,7 +6,6 @@ CONFIG_MACH_SUN50I_H5=y
> >  CONFIG_DRAM_CLK=408
> >  CONFIG_DRAM_ZQ=3881977
> >  # CONFIG_DRAM_ODT_EN is not set
> > -CONFIG_MACPWR="PD6"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/configs/nanopi_r1s_h5_defconfig b/configs/nanopi_r1s_h5_defconfig
> > index 5c332ca5261..760dfe37022 100644
> > --- a/configs/nanopi_r1s_h5_defconfig
> > +++ b/configs/nanopi_r1s_h5_defconfig
> > @@ -6,7 +6,6 @@ CONFIG_MACH_SUN50I_H5=y
> >  CONFIG_DRAM_CLK=672
> >  CONFIG_DRAM_ZQ=3881977
> >  # CONFIG_DRAM_ODT_EN is not set
> > -CONFIG_MACPWR="PD6"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/configs/orangepi_pc2_defconfig b/configs/orangepi_pc2_defconfig
> > index 356ae7ce476..cf75cf4b351 100644
> > --- a/configs/orangepi_pc2_defconfig
> > +++ b/configs/orangepi_pc2_defconfig
> > @@ -5,7 +5,6 @@ CONFIG_SPL=y
> >  CONFIG_MACH_SUN50I_H5=y
> >  CONFIG_DRAM_CLK=672
> >  CONFIG_DRAM_ZQ=3881977
> > -CONFIG_MACPWR="PD6"
> >  CONFIG_SPL_SPI_SUNXI=y
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/configs/orangepi_plus2e_defconfig b/configs/orangepi_plus2e_defconfig
> > index e27b329b0a9..c72adfb3e69 100644
> > --- a/configs/orangepi_plus2e_defconfig
> > +++ b/configs/orangepi_plus2e_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-orangepi-plus2e"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN8I_H3=y
> >  CONFIG_DRAM_CLK=672
> > -CONFIG_MACPWR="PD6"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/configs/orangepi_plus_defconfig b/configs/orangepi_plus_defconfig
> > index f4ce4851d7c..c407af38bcc 100644
> > --- a/configs/orangepi_plus_defconfig
> > +++ b/configs/orangepi_plus_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-orangepi-plus"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN8I_H3=y
> >  CONFIG_DRAM_CLK=672
> > -CONFIG_MACPWR="PD6"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  CONFIG_USB1_VBUS_PIN="PG13"
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> > diff --git a/configs/orangepi_win_defconfig b/configs/orangepi_win_defconfig
> > index 1e26970230f..b803dcd01ef 100644
> > --- a/configs/orangepi_win_defconfig
> > +++ b/configs/orangepi_win_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-orangepi-win"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN50I=y
> >  CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
> > -CONFIG_MACPWR="PD14"
> >  CONFIG_SPL_SPI_SUNXI=y
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/configs/pine_h64_defconfig b/configs/pine_h64_defconfig
> > index 578bd92f6a3..0b482dcea24 100644
> > --- a/configs/pine_h64_defconfig
> > +++ b/configs/pine_h64_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-h6-pine-h64"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN50I_H6=y
> >  CONFIG_SUNXI_DRAM_H6_LPDDR3=y
> > -CONFIG_MACPWR="PC16"
> >  CONFIG_MMC0_CD_PIN="PF6"
> >  CONFIG_MMC_SUNXI_SLOT_EXTRA=2
> >  CONFIG_USB3_VBUS_PIN="PL5"
> > diff --git a/configs/zeropi_defconfig b/configs/zeropi_defconfig
> > index 8365da2c472..7ace1b5cbfd 100644
> > --- a/configs/zeropi_defconfig
> > +++ b/configs/zeropi_defconfig
> > @@ -4,7 +4,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun8i-h3-zeropi"
> >  CONFIG_SPL=y
> >  CONFIG_MACH_SUN8I_H3=y
> >  CONFIG_DRAM_CLK=408
> > -CONFIG_MACPWR="PD6"
> >  # CONFIG_VIDEO_DE2 is not set
> >  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
> >  CONFIG_SYS_MONITOR_LEN=786432
> > diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
> > index 9cca8fa4e0a..c7087b7302d 100644
> > --- a/drivers/net/sun8i_emac.c
> > +++ b/drivers/net/sun8i_emac.c
> > @@ -29,6 +29,7 @@
> >  #include <net.h>
> >  #include <reset.h>
> >  #include <wait_bit.h>
> > +#include <power/regulator.h>
> >  
> >  #define MDIO_CMD_MII_BUSY		BIT(0)
> >  #define MDIO_CMD_MII_WRITE		BIT(1)
> > @@ -169,9 +170,8 @@ struct emac_eth_dev {
> >  	struct clk ephy_clk;
> >  	struct reset_ctl tx_rst;
> >  	struct reset_ctl ephy_rst;
> > -#if CONFIG_IS_ENABLED(DM_GPIO)
> >  	struct gpio_desc reset_gpio;
> > -#endif
> > +	struct udevice *phy_reg;
> >  };
> >  
> >  
> > @@ -738,6 +738,9 @@ static int sun8i_emac_eth_probe(struct udevice *dev)
> >  
> >  	sun8i_emac_set_syscon(sun8i_pdata, priv);
> >  
> > +	if (priv->phy_reg)
> > +		regulator_set_enable(priv->phy_reg, true);
> > +
> >  	sun8i_mdio_init(dev->name, dev);
> >  	priv->bus = miiphy_get_dev_by_name(dev->name);
> >  
> > @@ -844,6 +847,8 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev)
> >  		return -EINVAL;
> >  	}
> >  
> > +	device_get_supply_regulator(dev, "phy-supply", &priv->phy_reg);
> > +
> >  	pdata->phy_interface = -1;
> >  	priv->phyaddr = -1;
> >  	priv->use_internal_phy = false;
> > diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c
> > index 8625e49dae4..ee8b8a1667d 100644
> > --- a/drivers/net/sunxi_emac.c
> > +++ b/drivers/net/sunxi_emac.c
> > @@ -17,6 +17,7 @@
> >  #include <net.h>
> >  #include <asm/io.h>
> >  #include <asm/arch/clock.h>
> > +#include <power/regulator.h>
> >  
> >  /* EMAC register  */
> >  struct emac_regs {
> > @@ -164,9 +165,8 @@ struct emac_eth_dev {
> >  	struct mii_dev *bus;
> >  	struct phy_device *phydev;
> >  	int link_printed;
> > -#ifdef CONFIG_DM_ETH
> >  	uchar rx_buf[EMAC_RX_BUFSIZE];
> > -#endif
> > +	struct udevice *phy_reg;
> >  };
> >  
> >  struct emac_rxhdr {
> > @@ -575,6 +575,9 @@ static int sunxi_emac_eth_probe(struct udevice *dev)
> >  	if (ret)
> >  		return ret;
> >  
> > +	if (priv->phy_reg)
> > +		regulator_set_enable(priv->phy_reg, true);
> > +
> >  	return sunxi_emac_init_phy(priv, dev);
> >  }
> >  
> > @@ -588,9 +591,12 @@ static const struct eth_ops sunxi_emac_eth_ops = {
> >  static int sunxi_emac_eth_of_to_plat(struct udevice *dev)
> >  {
> >  	struct eth_pdata *pdata = dev_get_plat(dev);
> > +	struct emac_eth_dev *priv = dev_get_priv(dev);
> >  
> >  	pdata->iobase = dev_read_addr(dev);
> >  
> > +	device_get_supply_regulator(dev, "phy-supply", &priv->phy_reg);  
> 
> For sun4i-emac, the phy-supply property is actually part of the mdio
> node, not the emac node.

Huh, right. As far as I can tell, this only affects two boards, Mele_A1000
and jesurun_q5, which I don't have.
So can we follow the link to the PHY node, then go to its parent, which
should be the MDIO node? And pick the regulator from there?

Cheers,
Andre

> Regards,
> Samuel
> 
> > +
> >  	return 0;
> >  }
> >    
> 


  reply	other threads:[~2022-12-14 14:23 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06  0:45 [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 01/17] sunxi: remove CONFIG_SATAPWR Andre Przywara
2022-12-14  8:37   ` Samuel Holland
2022-12-14 14:25     ` Andre Przywara
2022-12-14 23:40       ` Samuel Holland
2022-12-06  0:45 ` [RFC PATCH 02/17] sunxi: remove CONFIG_MACPWR Andre Przywara
2022-12-14  9:09   ` Samuel Holland
2022-12-14 14:23     ` Andre Przywara [this message]
2022-12-06  0:45 ` [RFC PATCH 03/17] pinctrl: sunxi: remove struct sunxi_gpio Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 04/17] pinctrl: sunxi: add GPIO in/out wrappers Andre Przywara
2022-12-15  5:59   ` Samuel Holland
2022-12-06  0:45 ` [RFC PATCH 05/17] pinctrl: sunxi: move pinctrl code and remove GPIO_EXTRA_HEADER Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 06/17] pinctrl: sunxi: move PIO_BASE into sunxi_gpio.h Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 07/17] pinctrl: sunxi: add new D1 pinctrl support Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 08/17] sunxi: introduce NCAT2 generation model Andre Przywara
2022-12-06  5:38   ` Icenowy Zheng
2023-05-16  2:32   ` Sam Edwards
2023-05-16 21:08     ` Andre Przywara
2023-05-16 23:53       ` Sam Edwards
2023-05-17  0:43         ` Andre Przywara
2023-05-17  8:56           ` Andre Przywara
2023-05-17 14:04             ` Maxim Kiselev
2023-05-25 18:25               ` Maksim Kiselev
2023-05-26 11:05                 ` Andre Przywara
2023-06-03 18:03   ` Sam Edwards
2022-12-06  0:45 ` [RFC PATCH 09/17] pinctrl: sunxi: add Allwinner D1 pinctrl description Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 10/17] clk: sunxi: Add support for the D1 CCU Andre Przywara
2023-05-22  3:57   ` Sam Edwards
2023-05-24  0:58     ` Andre Przywara
2023-05-26  0:34   ` Sam Edwards
2023-05-26 10:50     ` Andre Przywara
2023-05-26 19:27       ` Maksim Kiselev
2023-05-26 20:22         ` Sam Edwards
2023-05-26 22:07           ` Andre Przywara
2023-05-27  2:15             ` Sam Edwards
2023-05-30  0:58               ` Sam Edwards
2023-05-31 15:19                 ` Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 11/17] sunxi: clock: D1/R528: Enable PLL LDO during PLL1 setup Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 12/17] sunxi: clock: support D1/R528 PLL6 clock Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 13/17] sunxi: add early Allwinner R528/T113 SoC support Andre Przywara
2023-05-16  2:52   ` Sam Edwards
2023-05-16 22:01     ` Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 14/17] sunxi: refactor serial base addresses to avoid asm/arch/cpu.h Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 15/17] riscv: dts: allwinner: Add the D1/D1s SoC devicetree Andre Przywara
2022-12-06  0:45 ` [RFC PATCH 16/17] arm: sunxi: add Allwinner T113s devicetree stub Andre Przywara
2022-12-06  5:55   ` Icenowy Zheng
2023-01-03 17:38     ` Andre Przywara
2023-01-04  5:49       ` Icenowy Zheng
2022-12-06  0:45 ` [RFC PATCH 17/17] sunxi: add preliminary MangoPi MQ-R board support Andre Przywara
2023-06-09 22:16 ` [RFC PATCH 00/17] sunxi: rework pinctrl and add T113s support Sam Edwards
2023-06-12  0:20   ` Andre Przywara
2023-06-12 21:18     ` Sam Edwards
2023-06-15  0:07       ` Andre Przywara
2023-06-18 19:01         ` Sam Edwards
2023-06-20 12:42           ` Andre Przywara
2023-06-20 22:11             ` Sam Edwards
2023-06-21 10:55               ` Andre Przywara
2023-06-21 20:22                 ` Sam Edwards
2023-06-16 15:59       ` Andre Przywara
2023-06-16 16:27         ` Maxim Kiselev
2023-06-16 16:36           ` Andre Przywara
2023-06-17  8:26             ` Maxim Kiselev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221214142303.115f23a1@donnerap.cambridge.arm.com \
    --to=andre.przywara@arm.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=samuel@sholland.org \
    --cc=u-boot@lists.denx.de \
    --cc=uwu@icenowy.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.