drivers/pmdomain/mediatek/airoha-cpu-pmdomain.c
Source file repositories/reference/linux-study-clean/drivers/pmdomain/mediatek/airoha-cpu-pmdomain.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pmdomain/mediatek/airoha-cpu-pmdomain.c- Extension
.c- Size
- 3759 bytes
- Lines
- 145
- 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/arm-smccc.hlinux/bitfield.hlinux/clk-provider.hlinux/module.hlinux/platform_device.hlinux/pm_domain.hlinux/slab.h
Detected Declarations
struct airoha_cpu_pmdomain_privfunction airoha_cpu_pmdomain_clk_determine_ratefunction airoha_cpu_pmdomain_clk_getfunction airoha_cpu_pmdomain_clk_is_enabledfunction airoha_cpu_pmdomain_set_performance_statefunction airoha_cpu_pmdomain_probefunction airoha_cpu_pmdomain_remove
Annotated Snippet
struct airoha_cpu_pmdomain_priv {
struct clk_hw hw;
struct generic_pm_domain pd;
};
static int airoha_cpu_pmdomain_clk_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
return 0;
}
static unsigned long airoha_cpu_pmdomain_clk_get(struct clk_hw *hw,
unsigned long parent_rate)
{
struct arm_smccc_res res;
arm_smccc_1_1_invoke(AIROHA_SIP_AVS_HANDLE, AIROHA_AVS_OP_GET_FREQ,
0, 0, 0, 0, 0, 0, &res);
/* SMCCC returns freq in MHz */
return (int)(res.a0 * 1000 * 1000);
}
/* Airoha CPU clk SMCC is always enabled */
static int airoha_cpu_pmdomain_clk_is_enabled(struct clk_hw *hw)
{
return true;
}
static const struct clk_ops airoha_cpu_pmdomain_clk_ops = {
.recalc_rate = airoha_cpu_pmdomain_clk_get,
.is_enabled = airoha_cpu_pmdomain_clk_is_enabled,
.determine_rate = airoha_cpu_pmdomain_clk_determine_rate,
};
static int airoha_cpu_pmdomain_set_performance_state(struct generic_pm_domain *domain,
unsigned int state)
{
struct arm_smccc_res res;
arm_smccc_1_1_invoke(AIROHA_SIP_AVS_HANDLE, AIROHA_AVS_OP_FREQ_DYN_ADJ,
0, state, 0, 0, 0, 0, &res);
/* SMC signal correct apply by unsetting BIT 0 */
return res.a0 & BIT(0) ? -EINVAL : 0;
}
static int airoha_cpu_pmdomain_probe(struct platform_device *pdev)
{
struct airoha_cpu_pmdomain_priv *priv;
struct device *dev = &pdev->dev;
const struct clk_init_data init = {
.name = "cpu",
.ops = &airoha_cpu_pmdomain_clk_ops,
/* Clock with no set_rate, can't cache */
.flags = CLK_GET_RATE_NOCACHE,
};
struct generic_pm_domain *pd;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
/* Init and register a get-only clk for Cpufreq */
priv->hw.init = &init;
ret = devm_clk_hw_register(dev, &priv->hw);
if (ret)
return ret;
ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
&priv->hw);
if (ret)
return ret;
/* Init and register a PD for CPU */
pd = &priv->pd;
pd->name = "cpu_pd";
pd->flags = GENPD_FLAG_ALWAYS_ON;
pd->set_performance_state = airoha_cpu_pmdomain_set_performance_state;
ret = pm_genpd_init(pd, NULL, false);
if (ret)
return ret;
ret = of_genpd_add_provider_simple(dev->of_node, pd);
if (ret)
goto err_add_provider;
platform_set_drvdata(pdev, priv);
Annotation
- Immediate include surface: `linux/arm-smccc.h`, `linux/bitfield.h`, `linux/clk-provider.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_domain.h`, `linux/slab.h`.
- Detected declarations: `struct airoha_cpu_pmdomain_priv`, `function airoha_cpu_pmdomain_clk_determine_rate`, `function airoha_cpu_pmdomain_clk_get`, `function airoha_cpu_pmdomain_clk_is_enabled`, `function airoha_cpu_pmdomain_set_performance_state`, `function airoha_cpu_pmdomain_probe`, `function airoha_cpu_pmdomain_remove`.
- 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.