Files
LibreELEC.tv/projects/Allwinner/patches/linux/0074-net-stmmac-sun8i-Use-devm_regulator_get-for-PHY-regu.patch
Rudi Heitbaum 2c1d9eb04c linux (Allwinner): rebase and drop upstreamed patches in 6.9 - 6.14
- 3ce7384048
- The following changes were introduced in 6.11-rc1 and 6.11-rc7
  only pass 3 variables to
  - of: remove internal arguments from of_property_for_each_u32()
  - 9722c3b66e
  6.11-rc7 has refactored drm 9da7ec9b19
  resulting in the following compile error.
  build.LibreELEC-H6.aarch64-13.0-devel/toolchain/bin/aarch64-libreelec-linux-gnu-ld: drivers/gpu/drm/sun4i/sun8i_dw_hdmi.o: in function `sun8i_dw_hdmi_bind':
  build.LibreELEC-H6.aarch64-13.0-devel/build/linux-6.11-rc7/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c:394:(.text+0x73c): undefined reference to `drm_bridge_connector_init'
- db300ab0e9
- allwinner: OrangePi PC also needs SW CEC hack
  CEC stopped working after updating from LE10 to LE11 as the former enabled
  the SW CEC hack for all H3 boards and the latter only for specific boards.
  Add OrangePi PC to that list of specific boards.
- Use old OrangePi 3 net patches
- Switch PMIC connection to I2C

Co-authored-by: Jernej Skrabec <jernej.skrabec@gmail.com>
2025-07-21 07:51:52 +00:00

76 lines
2.6 KiB
Diff

From 1877122b4d0fef204f7076f4c28761cae9fcd807 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megous@megous.com>
Date: Sat, 15 Mar 2025 17:38:35 +0100
Subject: [PATCH 1/3] net: stmmac: sun8i: Use devm_regulator_get for PHY
regulator
Use devm_regulator_get instead of devm_regulator_get_optional and rely
on dummy supply. This avoids NULL checks before regulator_enable/disable
calls.
This path also improves error reporting, because we now report both
use of dummy supply and error during registration with more detail,
instead of generic info level message "No regulator found" that
was reported previously on errors and lack of regulator property in DT.
Finally, we'll be adding further optional regulators, and the overall
code will be simpler.
Signed-off-by: Ondrej Jirman <megous@megous.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 23 ++++++++-----------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 4b7b2582a120..94a4898260b0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -588,12 +588,10 @@ static int sun8i_dwmac_init(struct platform_device *pdev, void *priv)
struct sunxi_priv_data *gmac = priv;
int ret;
- if (gmac->regulator) {
- ret = regulator_enable(gmac->regulator);
- if (ret) {
- dev_err(&pdev->dev, "Fail to enable regulator\n");
- return ret;
- }
+ ret = regulator_enable(gmac->regulator);
+ if (ret) {
+ dev_err(&pdev->dev, "Fail to enable regulator\n");
+ return ret;
}
if (gmac->use_internal_phy) {
@@ -1051,8 +1049,7 @@ static void sun8i_dwmac_exit(struct platform_device *pdev, void *priv)
if (gmac->variant->soc_has_internal_phy)
sun8i_dwmac_unpower_internal_phy(gmac);
- if (gmac->regulator)
- regulator_disable(gmac->regulator);
+ regulator_disable(gmac->regulator);
}
static void sun8i_dwmac_set_mac_loopback(void __iomem *ioaddr, bool enable)
@@ -1176,12 +1173,12 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
}
/* Optional regulator for PHY */
- gmac->regulator = devm_regulator_get_optional(dev, "phy");
+ gmac->regulator = devm_regulator_get(dev, "phy");
if (IS_ERR(gmac->regulator)) {
- if (PTR_ERR(gmac->regulator) == -EPROBE_DEFER)
- return -EPROBE_DEFER;
- dev_info(dev, "No regulator found\n");
- gmac->regulator = NULL;
+ ret = PTR_ERR(gmac->regulator);
+ if (ret != -EPROBE_DEFER)
+ dev_err(dev, "Failed to get PHY regulator (%d)\n", ret);
+ return ret;
}
/* The "GMAC clock control" register might be located in the
--
2.48.1