[PATCH v2 05/14] power: domain: mediatek: remove enum scp_domain_type

Julien Stephan jstephan at baylibre.com
Thu Jul 9 14:58:11 CEST 2026


The driver mapped each compatible to an enum scp_domain_type via the
match data, then used mtk_power_domain_hook() to switch on that enum
and select the per-SoC domain table. This forces every new SoC to add
an enum value and a switch case in shared code.

Store a pointer to the per-SoC table directly in the match data and
drop the enum, the type field, and mtk_power_domain_hook(). This keeps
per-SoC information in the match data where it belongs, making it
possible to later split the SoC-specific tables into standalone drivers.

No functional change intended.

Signed-off-by: Julien Stephan <jstephan at baylibre.com>
---
 drivers/power/domain/mtk-power-domain.c | 36 ++++-----------------------------
 1 file changed, 4 insertions(+), 32 deletions(-)

diff --git a/drivers/power/domain/mtk-power-domain.c b/drivers/power/domain/mtk-power-domain.c
index 9888d00421c..dc326cd8c94 100644
--- a/drivers/power/domain/mtk-power-domain.c
+++ b/drivers/power/domain/mtk-power-domain.c
@@ -61,11 +61,6 @@
 
 #define DCM_TOP_EN		BIT(0)
 
-enum scp_domain_type {
-	SCPSYS_MT2701,
-	SCPSYS_MT7622,
-};
-
 struct scp_domain;
 
 struct scp_domain_data {
@@ -80,7 +75,6 @@ struct scp_domain_data {
 struct scp_domain {
 	void __iomem *base;
 	void __iomem *infracfg;
-	enum scp_domain_type type;
 	struct scp_domain_data *data;
 };
 
@@ -315,26 +309,6 @@ static int scpsys_power_request(struct power_domain *power_domain)
 	return 0;
 }
 
-static int mtk_power_domain_hook(struct udevice *dev)
-{
-	struct scp_domain *scpd = dev_get_priv(dev);
-
-	scpd->type = (enum scp_domain_type)dev_get_driver_data(dev);
-
-	switch (scpd->type) {
-	case SCPSYS_MT2701:
-		scpd->data = scp_domain_mt2701;
-		break;
-	case SCPSYS_MT7622:
-		scpd->data = scp_domain_mt7622;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
 static int mtk_power_domain_probe(struct udevice *dev)
 {
 	struct ofnode_phandle_args args;
@@ -347,9 +321,7 @@ static int mtk_power_domain_probe(struct udevice *dev)
 	if (!scpd->base)
 		return -ENOENT;
 
-	err = mtk_power_domain_hook(dev);
-	if (err)
-		return err;
+	scpd->data = (struct scp_domain_data *)dev_get_driver_data(dev);
 
 	/* get corresponding syscon phandle */
 	err = dev_read_phandle_with_args(dev, "infracfg", NULL, 0, 0, &args);
@@ -377,15 +349,15 @@ static int mtk_power_domain_probe(struct udevice *dev)
 static const struct udevice_id mtk_power_domain_ids[] = {
 	{
 		.compatible = "mediatek,mt2701-scpsys",
-		.data = SCPSYS_MT2701,
+		.data = (ulong)&scp_domain_mt2701,
 	},
 	{
 		.compatible = "mediatek,mt7622-scpsys",
-		.data = SCPSYS_MT7622,
+		.data = (ulong)&scp_domain_mt7622,
 	},
 	{
 		.compatible = "mediatek,mt7623-scpsys",
-		.data = SCPSYS_MT2701,
+		.data = (ulong)&scp_domain_mt2701,
 	},
 	{ /* sentinel */ }
 };

-- 
2.54.0



More information about the U-Boot mailing list