From: Chris Webb Date: Wed, 31 Jul 2024 10:01:31 +0000 (+0100) Subject: pinctrl: mediatek: Bind gpio while binding pinctrl X-Git-Url: http://git.dujemihanovic.xyz/login.html?a=commitdiff_plain;h=f4df9f53b7a97e29afb06e466a9ebab1a201b63d;p=u-boot.git pinctrl: mediatek: Bind gpio while binding pinctrl Mediatek pinctrl drivers call mtk_gpiochip_register() to bind the child gpio controller as part of mtk_pinctrl_common_probe(). This breaks gpiohog support because the gpio controller is bound too late for DM_FLAG_PROBE_AFTER_BIND (set while binding hogs) to work. Move the mtk_gpiochip_register() to mtk_pinctrl_common_bind() and call this as the .bind method of each of the mediatek pinctrl drivers. Signed-off-by: Chris Webb --- diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c index 114f2602b2..46a5b6637c 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c @@ -749,6 +749,7 @@ U_BOOT_DRIVER(mt7622_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt7622_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt7622_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7623.c b/drivers/pinctrl/mediatek/pinctrl-mt7623.c index 2703e6f754..55e49a790e 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7623.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7623.c @@ -1410,6 +1410,7 @@ U_BOOT_DRIVER(mt7623_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt7623_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt7623_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7629.c b/drivers/pinctrl/mediatek/pinctrl-mt7629.c index 45d4def316..3b82423c14 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7629.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7629.c @@ -413,6 +413,7 @@ U_BOOT_DRIVER(mt7629_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt7629_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt7629_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7981.c b/drivers/pinctrl/mediatek/pinctrl-mt7981.c index 4bc4abe651..047e37bc9c 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7981.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7981.c @@ -1048,6 +1048,7 @@ U_BOOT_DRIVER(mt7981_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt7981_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt7981_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), .flags = DM_FLAG_PRE_RELOC, diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7986.c b/drivers/pinctrl/mediatek/pinctrl-mt7986.c index 819d64488f..bf8cd03753 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7986.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7986.c @@ -773,6 +773,7 @@ U_BOOT_DRIVER(mt7986_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt7986_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt7986_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7988.c b/drivers/pinctrl/mediatek/pinctrl-mt7988.c index 03a38e83df..1f384e86f4 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7988.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7988.c @@ -1269,6 +1269,7 @@ U_BOOT_DRIVER(mt7988_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt7988_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt7988_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8512.c b/drivers/pinctrl/mediatek/pinctrl-mt8512.c index bc5fb83ac6..5a8dd4ddd4 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8512.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8512.c @@ -382,6 +382,7 @@ U_BOOT_DRIVER(mt8512_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt8512_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt8512_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8516.c b/drivers/pinctrl/mediatek/pinctrl-mt8516.c index 7487d6f060..9c25066fc2 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8516.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8516.c @@ -388,6 +388,7 @@ U_BOOT_DRIVER(mt8516_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt8516_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt8516_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8518.c b/drivers/pinctrl/mediatek/pinctrl-mt8518.c index 66fcfdff14..333184a6bb 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt8518.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt8518.c @@ -408,6 +408,7 @@ U_BOOT_DRIVER(mt8518_pinctrl) = { .id = UCLASS_PINCTRL, .of_match = mt8518_pctrl_match, .ops = &mtk_pinctrl_ops, + .bind = mtk_pinctrl_common_bind, .probe = mtk_pinctrl_mt8518_probe, .priv_auto = sizeof(struct mtk_pinctrl_priv), }; diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c index ede3959c94..a3662d46bd 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c @@ -791,11 +791,20 @@ bind: } #endif +int mtk_pinctrl_common_bind(struct udevice *dev) +{ +#if CONFIG_IS_ENABLED(DM_GPIO) || \ + (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO)) + return mtk_gpiochip_register(dev); +#else + return 0; +#endif +} + int mtk_pinctrl_common_probe(struct udevice *dev, const struct mtk_pinctrl_soc *soc) { struct mtk_pinctrl_priv *priv = dev_get_priv(dev); - int ret = 0; u32 i = 0; fdt_addr_t addr; u32 base_calc = soc->base_calc; @@ -813,10 +822,5 @@ int mtk_pinctrl_common_probe(struct udevice *dev, priv->base[i] = (void __iomem *)addr; } -#if CONFIG_IS_ENABLED(DM_GPIO) || \ - (defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_GPIO)) - ret = mtk_gpiochip_register(dev); -#endif - - return ret; + return 0; } diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h index c948b80843..15ab3c1bf0 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h @@ -241,6 +241,7 @@ extern const struct pinctrl_ops mtk_pinctrl_ops; /* A common read-modify-write helper for MediaTek chips */ void mtk_rmw(struct udevice *dev, u32 reg, u32 mask, u32 set); void mtk_i_rmw(struct udevice *dev, u8 i, u32 reg, u32 mask, u32 set); +int mtk_pinctrl_common_bind(struct udevice *dev); int mtk_pinctrl_common_probe(struct udevice *dev, const struct mtk_pinctrl_soc *soc);