[PATCH 03/12] power: domain: mediatek: remove enum scp_domain_type
Julien Stephan
jstephan at baylibre.com
Wed Jul 8 15:07:09 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 | 38 ++++-----------------------------
1 file changed, 4 insertions(+), 34 deletions(-)
diff --git a/drivers/power/domain/mtk-power-domain.c b/drivers/power/domain/mtk-power-domain.c
index 24dd540897d..16a97094303 100644
--- a/drivers/power/domain/mtk-power-domain.c
+++ b/drivers/power/domain/mtk-power-domain.c
@@ -61,12 +61,6 @@
#define DCM_TOP_EN BIT(0)
-enum scp_domain_type {
- SCPSYS_MT7622,
- SCPSYS_MT7623,
- SCPSYS_MT7629,
-};
-
struct scp_domain;
struct scp_domain_data {
@@ -81,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;
};
@@ -316,27 +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_MT7623:
- scpd->data = scp_domain_mt7623;
- break;
- case SCPSYS_MT7622:
- case SCPSYS_MT7629:
- scpd->data = scp_domain_mt7629;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
static int mtk_power_domain_probe(struct udevice *dev)
{
struct ofnode_phandle_args args;
@@ -349,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);
@@ -379,15 +349,15 @@ static int mtk_power_domain_probe(struct udevice *dev)
static const struct udevice_id mtk_power_domain_ids[] = {
{
.compatible = "mediatek,mt7622-scpsys",
- .data = SCPSYS_MT7622,
+ .data = (ulong)&scp_domain_mt7629,
},
{
.compatible = "mediatek,mt7623-scpsys",
- .data = SCPSYS_MT7623,
+ .data = (ulong)&scp_domain_mt7623,
},
{
.compatible = "mediatek,mt7629-scpsys",
- .data = SCPSYS_MT7629,
+ .data = (ulong)&scp_domain_mt7629,
},
{ /* sentinel */ }
};
--
2.54.0
More information about the U-Boot
mailing list