power: domain: mediatek: wrap domain tables in struct scp_soc_data
The per-SoC match data currently points directly at the array of mtk_scp_domain_data. Wrap it in a new struct mtk_scp_soc_data that carries the table pointer together with its size, and add a MTK_SCP_SOC_DATA() helper that fills both from a single table definition via ARRAY_SIZE(). The num_domains field is not used yet; it is added here so that upcoming SoC support can validate the domain index coming from the device tree against the size of the table. No functional change intended. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20260709-mt8188-add-power-domain-v2-9-589ace7d30e2@baylibre.com Signed-off-by: David Lechner <dlechner@baylibre.com>
This commit is contained in:
committed by
David Lechner
parent
04175690d6
commit
5543aafa39
@@ -65,14 +65,16 @@ static const struct mtk_scp_domain_data mt2701_scp_domain[] = {
|
||||
},
|
||||
};
|
||||
|
||||
MTK_SCP_SOC_DATA(mt2701, mt2701_scp_domain);
|
||||
|
||||
static const struct udevice_id mt2701_power_domain_ids[] = {
|
||||
{
|
||||
.compatible = "mediatek,mt2701-scpsys",
|
||||
.data = (ulong)&mt2701_scp_domain,
|
||||
.data = (ulong)&mt2701_scp_soc_data,
|
||||
},
|
||||
{
|
||||
.compatible = "mediatek,mt7623-scpsys",
|
||||
.data = (ulong)&mt2701_scp_domain,
|
||||
.data = (ulong)&mt2701_scp_soc_data,
|
||||
},
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
@@ -36,10 +36,12 @@ static const struct mtk_scp_domain_data mt7622_scp_domain[] = {
|
||||
},
|
||||
};
|
||||
|
||||
MTK_SCP_SOC_DATA(mt7622, mt7622_scp_domain);
|
||||
|
||||
static const struct udevice_id mt7622_power_domain_ids[] = {
|
||||
{
|
||||
.compatible = "mediatek,mt7622-scpsys",
|
||||
.data = (ulong)&mt7622_scp_domain,
|
||||
.data = (ulong)&mt7622_scp_soc_data,
|
||||
},
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
@@ -44,7 +44,7 @@ static int mtk_infracfg_clear_bus_protection(void __iomem *infracfg,
|
||||
static int mtk_scpsys_domain_is_on(struct power_domain *power_domain)
|
||||
{
|
||||
struct mtk_scp_domain *scpd = dev_get_priv(power_domain->dev);
|
||||
const struct mtk_scp_domain_data *data = &scpd->data[power_domain->id];
|
||||
const struct mtk_scp_domain_data *data = &scpd->soc_data->data[power_domain->id];
|
||||
u32 sta = readl(scpd->base + SPM_PWR_STATUS) &
|
||||
data->sta_mask;
|
||||
u32 sta2 = readl(scpd->base + SPM_PWR_STATUS_2ND) &
|
||||
@@ -65,7 +65,7 @@ static int mtk_scpsys_domain_is_on(struct power_domain *power_domain)
|
||||
static int mtk_scpsys_power_on(struct power_domain *power_domain)
|
||||
{
|
||||
struct mtk_scp_domain *scpd = dev_get_priv(power_domain->dev);
|
||||
const struct mtk_scp_domain_data *data = &scpd->data[power_domain->id];
|
||||
const struct mtk_scp_domain_data *data = &scpd->soc_data->data[power_domain->id];
|
||||
void __iomem *ctl_addr = scpd->base + data->ctl_offs;
|
||||
u32 pdn_ack = data->sram_pdn_ack_bits;
|
||||
u32 val;
|
||||
@@ -114,7 +114,7 @@ static int mtk_scpsys_power_on(struct power_domain *power_domain)
|
||||
static int mtk_scpsys_power_off(struct power_domain *power_domain)
|
||||
{
|
||||
struct mtk_scp_domain *scpd = dev_get_priv(power_domain->dev);
|
||||
const struct mtk_scp_domain_data *data = &scpd->data[power_domain->id];
|
||||
const struct mtk_scp_domain_data *data = &scpd->soc_data->data[power_domain->id];
|
||||
void __iomem *ctl_addr = scpd->base + data->ctl_offs;
|
||||
u32 pdn_ack = data->sram_pdn_ack_bits;
|
||||
u32 val;
|
||||
@@ -170,7 +170,7 @@ int mtk_power_domain_probe(struct udevice *dev)
|
||||
if (!scpd->base)
|
||||
return -ENOENT;
|
||||
|
||||
scpd->data = (const struct mtk_scp_domain_data *)dev_get_driver_data(dev);
|
||||
scpd->soc_data = (const struct mtk_scp_soc_data *)dev_get_driver_data(dev);
|
||||
|
||||
/* get corresponding syscon phandle */
|
||||
err = dev_read_phandle_with_args(dev, "infracfg", NULL, 0, 0, &args);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <power-domain-uclass.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
struct udevice;
|
||||
@@ -68,10 +69,21 @@ struct mtk_scp_domain_data {
|
||||
u32 bus_prot_mask;
|
||||
};
|
||||
|
||||
struct mtk_scp_soc_data {
|
||||
const struct mtk_scp_domain_data *data;
|
||||
int num_domains;
|
||||
};
|
||||
|
||||
#define MTK_SCP_SOC_DATA(_name, _domains) \
|
||||
static const struct mtk_scp_soc_data _name##_scp_soc_data = { \
|
||||
.data = _domains, \
|
||||
.num_domains = ARRAY_SIZE(_domains), \
|
||||
}
|
||||
|
||||
struct mtk_scp_domain {
|
||||
void __iomem *base;
|
||||
void __iomem *infracfg;
|
||||
const struct mtk_scp_domain_data *data;
|
||||
const struct mtk_scp_soc_data *soc_data;
|
||||
};
|
||||
|
||||
int mtk_power_domain_probe(struct udevice *dev);
|
||||
|
||||
Reference in New Issue
Block a user