From: David Lechner Date: Wed, 14 Jan 2026 22:37:19 +0000 (-0600) Subject: pinctrl: mediatek: fix failing to get syscon X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04413ed0c1bde24bdb4a15e5d75a33f1f3fa8bfa;p=thirdparty%2Fu-boot.git pinctrl: mediatek: fix failing to get syscon Replace uclass_get_device_by_ofnode() with syscon_regmap_lookup_by_phandle() to get the "mediatek,pctl-regmap" syscon device. Depending on probe order, uclass_get_device_by_ofnode() may fail, but syscon_regmap_lookup_by_phandle() has logic in it to handle that case correctly. The previous implementation could read more than one syscon if the "mediatek,pctl-regmap" property had more than one phandle, but the one board with a devicetree that does that is not supported in U-Boot yet, so we can save that for later (it may never be needed). Fixes: 424ceba18bfb ("pinctrl: mediatek: support mediatek,pctl-regmap property") Signed-off-by: David Lechner --- diff --git a/drivers/pinctrl/mediatek/Kconfig b/drivers/pinctrl/mediatek/Kconfig index 4a698568a7e..ed4b02be0dd 100644 --- a/drivers/pinctrl/mediatek/Kconfig +++ b/drivers/pinctrl/mediatek/Kconfig @@ -2,6 +2,8 @@ if ARCH_MEDIATEK config PINCTRL_MTK depends on PINCTRL_GENERIC + select REGMAP + select SYSCON bool config PINCTRL_MT7622 diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index ff7cefcc8de..b1fdcd18027 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -11,6 +11,10 @@ #include #include #include +#include +#include +#include +#include #include "pinctrl-mtk-common.h" @@ -822,32 +826,17 @@ int mtk_pinctrl_common_probe(struct udevice *dev, * for the interrupt controller, so we only use the 1st one currently. */ num_regmaps = dev_count_phandle_with_args(dev, "mediatek,pctl-regmap", NULL, 0); - if (num_regmaps > ARRAY_SIZE(priv->base)) - return -EINVAL; if (num_regmaps > 0) { - for (i = 0; i < num_regmaps; i++) { - struct ofnode_phandle_args args; - struct udevice *syscon_dev; - int ret; - - ret = dev_read_phandle_with_args(dev, "mediatek,pctl-regmap", - NULL, 0, i, &args); - if (ret) - return ret; - - ret = uclass_get_device_by_ofnode(UCLASS_SYSCON, - args.node, - &syscon_dev); - if (ret) - return ret; - - addr = dev_read_addr_index(syscon_dev, 0); - if (addr == FDT_ADDR_T_NONE) - return -EINVAL; - - priv->base[i] = (void __iomem *)addr; - } + struct regmap *regmap; + + regmap = syscon_regmap_lookup_by_phandle(dev, "mediatek,pctl-regmap"); + if (IS_ERR(regmap)) + return log_msg_ret("regmap: ", PTR_ERR(regmap)); + + priv->base[0] = regmap_get_range(regmap, 0); + if (!priv->base[0]) + return log_msg_ret("range: ", -EINVAL); return 0; }