sound/soc/mediatek/mt8365/mt8365-afe-clk.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8365/mt8365-afe-clk.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8365/mt8365-afe-clk.c- Extension
.c- Size
- 10995 bytes
- Lines
- 405
- Domain
- Driver Families
- Bucket
- sound/soc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
mt8365-afe-clk.hmt8365-afe-common.hmt8365-reg.h../common/mtk-base-afe.hlinux/device.hlinux/mfd/syscon.h
Detected Declarations
function mt8365_afe_init_audio_clkfunction mt8365_afe_disable_clkfunction mt8365_afe_set_clk_ratefunction mt8365_afe_set_clk_parentfunction get_top_cg_regfunction get_top_cg_maskfunction get_top_cg_on_valfunction get_top_cg_off_valfunction mt8365_afe_enable_top_cgfunction mt8365_afe_disable_top_cgfunction mt8365_afe_enable_main_clkfunction mt8365_afe_disable_main_clkfunction mt8365_afe_emi_clk_onfunction mt8365_afe_emi_clk_offfunction mt8365_afe_enable_afe_onfunction mt8365_afe_disable_afe_onfunction mt8365_afe_hd_engen_enablefunction mt8365_afe_hd_engen_disablefunction mt8365_afe_enable_apll_tuner_cfgfunction mt8365_afe_disable_apll_tuner_cfgfunction mt8365_afe_enable_apll_associated_cfgfunction mt8365_afe_disable_apll_associated_cfg
Annotated Snippet
if (IS_ERR(afe_priv->clocks[i])) {
dev_err(afe->dev, "%s devm_clk_get %s fail\n",
__func__, aud_clks[i]);
return PTR_ERR(afe_priv->clocks[i]);
}
}
return 0;
}
void mt8365_afe_disable_clk(struct mtk_base_afe *afe, struct clk *clk)
{
clk_disable_unprepare(clk);
}
int mt8365_afe_set_clk_rate(struct mtk_base_afe *afe, struct clk *clk,
unsigned int rate)
{
int ret;
if (clk) {
ret = clk_set_rate(clk, rate);
if (ret) {
dev_err(afe->dev, "Failed to set rate\n");
return ret;
}
}
return 0;
}
int mt8365_afe_set_clk_parent(struct mtk_base_afe *afe, struct clk *clk,
struct clk *parent)
{
int ret;
if (clk && parent) {
ret = clk_set_parent(clk, parent);
if (ret) {
dev_err(afe->dev, "Failed to set parent\n");
return ret;
}
}
return 0;
}
static unsigned int get_top_cg_reg(unsigned int cg_type)
{
switch (cg_type) {
case MT8365_TOP_CG_AFE:
case MT8365_TOP_CG_I2S_IN:
case MT8365_TOP_CG_22M:
case MT8365_TOP_CG_24M:
case MT8365_TOP_CG_INTDIR_CK:
case MT8365_TOP_CG_APLL2_TUNER:
case MT8365_TOP_CG_APLL_TUNER:
case MT8365_TOP_CG_SPDIF:
case MT8365_TOP_CG_TDM_OUT:
case MT8365_TOP_CG_TDM_IN:
case MT8365_TOP_CG_ADC:
case MT8365_TOP_CG_DAC:
case MT8365_TOP_CG_DAC_PREDIS:
case MT8365_TOP_CG_TML:
return AUDIO_TOP_CON0;
case MT8365_TOP_CG_I2S1_BCLK:
case MT8365_TOP_CG_I2S2_BCLK:
case MT8365_TOP_CG_I2S3_BCLK:
case MT8365_TOP_CG_I2S4_BCLK:
case MT8365_TOP_CG_DMIC0_ADC:
case MT8365_TOP_CG_DMIC1_ADC:
case MT8365_TOP_CG_DMIC2_ADC:
case MT8365_TOP_CG_DMIC3_ADC:
case MT8365_TOP_CG_CONNSYS_I2S_ASRC:
case MT8365_TOP_CG_GENERAL1_ASRC:
case MT8365_TOP_CG_GENERAL2_ASRC:
case MT8365_TOP_CG_TDM_ASRC:
return AUDIO_TOP_CON1;
default:
return 0;
}
}
static unsigned int get_top_cg_mask(unsigned int cg_type)
{
switch (cg_type) {
case MT8365_TOP_CG_AFE:
return AUD_TCON0_PDN_AFE;
case MT8365_TOP_CG_I2S_IN:
return AUD_TCON0_PDN_I2S_IN;
case MT8365_TOP_CG_22M:
return AUD_TCON0_PDN_22M;
case MT8365_TOP_CG_24M:
Annotation
- Immediate include surface: `mt8365-afe-clk.h`, `mt8365-afe-common.h`, `mt8365-reg.h`, `../common/mtk-base-afe.h`, `linux/device.h`, `linux/mfd/syscon.h`.
- Detected declarations: `function mt8365_afe_init_audio_clk`, `function mt8365_afe_disable_clk`, `function mt8365_afe_set_clk_rate`, `function mt8365_afe_set_clk_parent`, `function get_top_cg_reg`, `function get_top_cg_mask`, `function get_top_cg_on_val`, `function get_top_cg_off_val`, `function mt8365_afe_enable_top_cg`, `function mt8365_afe_disable_top_cg`.
- Atlas domain: Driver Families / sound/soc.
- 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.