diff options
| author | David Lechner <[email protected]> | 2026-01-14 16:37:19 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-01-21 13:30:55 -0600 |
| commit | 04413ed0c1bde24bdb4a15e5d75a33f1f3fa8bfa (patch) | |
| tree | 39d125b92010089841d27b2c0eb8c9f0082f4288 /drivers/pinctrl | |
| parent | c196b0a6882929bf0b6504eae963f24289ee5d85 (diff) | |
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 <[email protected]>
Diffstat (limited to 'drivers/pinctrl')
| -rw-r--r-- | drivers/pinctrl/mediatek/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 37 |
2 files changed, 15 insertions, 24 deletions
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 <asm/io.h> #include <asm-generic/gpio.h> #include <linux/bitops.h> +#include <linux/err.h> +#include <log.h> +#include <regmap.h> +#include <syscon.h> #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; } |
