drivers/pmdomain/mediatek/mtk-scpsys.c
Source file repositories/reference/linux-study-clean/drivers/pmdomain/mediatek/mtk-scpsys.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pmdomain/mediatek/mtk-scpsys.c- Extension
.c- Size
- 29139 bytes
- Lines
- 1155
- Domain
- Driver Families
- Bucket
- drivers/pmdomain
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/init.hlinux/io.hlinux/iopoll.hlinux/mfd/syscon.hlinux/of.hlinux/platform_device.hlinux/pm_domain.hlinux/regulator/consumer.hlinux/soc/mediatek/infracfg.hdt-bindings/power/mt2701-power.hdt-bindings/power/mt2712-power.hdt-bindings/power/mt6797-power.hdt-bindings/power/mt7622-power.hdt-bindings/power/mt7623a-power.hdt-bindings/power/mt8173-power.h
Detected Declarations
struct scp_domain_datastruct scpstruct scp_domainstruct scp_ctrl_regstruct scpstruct scp_subdomainstruct scp_soc_dataenum clk_idfunction scpsys_domain_is_onfunction scpsys_regulator_enablefunction scpsys_regulator_disablefunction scpsys_clk_disablefunction scpsys_clk_enablefunction scpsys_sram_enablefunction scpsys_sram_disablefunction scpsys_bus_protect_enablefunction scpsys_bus_protect_disablefunction scpsys_power_onfunction scpsys_power_offfunction init_clksfunction mtk_register_power_domainsfunction scpsys_probe
Annotated Snippet
struct scp_domain_data {
const char *name;
u32 sta_mask;
int ctl_offs;
u32 sram_pdn_bits;
u32 sram_pdn_ack_bits;
u32 bus_prot_mask;
enum clk_id clk_id[MAX_CLKS];
u8 caps;
};
struct scp;
struct scp_domain {
struct generic_pm_domain genpd;
struct scp *scp;
struct clk *clk[MAX_CLKS];
const struct scp_domain_data *data;
struct regulator *supply;
};
struct scp_ctrl_reg {
int pwr_sta_offs;
int pwr_sta2nd_offs;
};
struct scp {
struct scp_domain *domains;
struct genpd_onecell_data pd_data;
struct device *dev;
void __iomem *base;
struct regmap *infracfg;
struct scp_ctrl_reg ctrl_reg;
bool bus_prot_reg_update;
};
struct scp_subdomain {
int origin;
int subdomain;
};
struct scp_soc_data {
const struct scp_domain_data *domains;
int num_domains;
const struct scp_subdomain *subdomains;
int num_subdomains;
const struct scp_ctrl_reg regs;
bool bus_prot_reg_update;
};
static int scpsys_domain_is_on(struct scp_domain *scpd)
{
struct scp *scp = scpd->scp;
u32 status = readl(scp->base + scp->ctrl_reg.pwr_sta_offs) &
scpd->data->sta_mask;
u32 status2 = readl(scp->base + scp->ctrl_reg.pwr_sta2nd_offs) &
scpd->data->sta_mask;
/*
* A domain is on when both status bits are set. If only one is set
* return an error. This happens while powering up a domain
*/
if (status && status2)
return true;
if (!status && !status2)
return false;
return -EINVAL;
}
static int scpsys_regulator_enable(struct scp_domain *scpd)
{
if (!scpd->supply)
return 0;
return regulator_enable(scpd->supply);
}
static int scpsys_regulator_disable(struct scp_domain *scpd)
{
if (!scpd->supply)
return 0;
return regulator_disable(scpd->supply);
}
static void scpsys_clk_disable(struct clk *clk[], int max_num)
{
Annotation
- Immediate include surface: `linux/clk.h`, `linux/init.h`, `linux/io.h`, `linux/iopoll.h`, `linux/mfd/syscon.h`, `linux/of.h`, `linux/platform_device.h`, `linux/pm_domain.h`.
- Detected declarations: `struct scp_domain_data`, `struct scp`, `struct scp_domain`, `struct scp_ctrl_reg`, `struct scp`, `struct scp_subdomain`, `struct scp_soc_data`, `enum clk_id`, `function scpsys_domain_is_on`, `function scpsys_regulator_enable`.
- Atlas domain: Driver Families / drivers/pmdomain.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.