sound/soc/mediatek/mt8186/mt8186-afe-clk.c
Source file repositories/reference/linux-study-clean/sound/soc/mediatek/mt8186/mt8186-afe-clk.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/mediatek/mt8186/mt8186-afe-clk.c- Extension
.c- Size
- 16987 bytes
- Lines
- 590
- 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
linux/clk.hlinux/regmap.hlinux/mfd/syscon.hmt8186-afe-common.hmt8186-afe-clk.hmt8186-audsys-clk.h
Detected Declarations
struct mt8186_mck_divfunction mt8186_set_audio_int_bus_parentfunction apll1_mux_settingfunction apll2_mux_settingfunction mt8186_afe_enable_cgsfunction mt8186_afe_disable_cgsfunction mt8186_afe_enable_clockfunction mt8186_afe_disable_clockfunction mt8186_apll1_enablefunction mt8186_apll1_disablefunction mt8186_apll2_enablefunction mt8186_apll2_disablefunction mt8186_get_apll_ratefunction mt8186_get_apll_by_ratefunction mt8186_get_apll_by_namefunction mt8186_mck_enablefunction mt8186_mck_disablefunction mt8186_init_clock
Annotated Snippet
struct mt8186_mck_div {
u32 m_sel_id;
u32 div_clk_id;
};
static const struct mt8186_mck_div mck_div[MT8186_MCK_NUM] = {
[MT8186_I2S0_MCK] = {
.m_sel_id = CLK_TOP_I2S0_M_SEL,
.div_clk_id = CLK_TOP_APLL12_DIV0,
},
[MT8186_I2S1_MCK] = {
.m_sel_id = CLK_TOP_I2S1_M_SEL,
.div_clk_id = CLK_TOP_APLL12_DIV1,
},
[MT8186_I2S2_MCK] = {
.m_sel_id = CLK_TOP_I2S2_M_SEL,
.div_clk_id = CLK_TOP_APLL12_DIV2,
},
[MT8186_I2S4_MCK] = {
.m_sel_id = CLK_TOP_I2S4_M_SEL,
.div_clk_id = CLK_TOP_APLL12_DIV4,
},
[MT8186_TDM_MCK] = {
.m_sel_id = CLK_TOP_TDM_M_SEL,
.div_clk_id = CLK_TOP_APLL12_DIV_TDM,
},
};
int mt8186_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)
{
struct mt8186_afe_private *afe_priv = afe->platform_priv;
int apll = mt8186_get_apll_by_rate(afe, rate);
int apll_clk_id = apll == MT8186_APLL1 ?
CLK_TOP_MUX_AUD_1 : CLK_TOP_MUX_AUD_2;
int m_sel_id = mck_div[mck_id].m_sel_id;
int div_clk_id = mck_div[mck_id].div_clk_id;
int ret;
/* select apll */
if (m_sel_id >= 0) {
ret = clk_prepare_enable(afe_priv->clk[m_sel_id]);
if (ret) {
dev_err(afe->dev, "%s(), clk_prepare_enable %s fail %d\n",
__func__, aud_clks[m_sel_id], ret);
return ret;
}
ret = clk_set_parent(afe_priv->clk[m_sel_id],
afe_priv->clk[apll_clk_id]);
if (ret) {
dev_err(afe->dev, "%s(), clk_set_parent %s-%s fail %d\n",
__func__, aud_clks[m_sel_id],
aud_clks[apll_clk_id], ret);
return ret;
}
}
/* enable div, set rate */
ret = clk_prepare_enable(afe_priv->clk[div_clk_id]);
if (ret) {
dev_err(afe->dev, "%s(), clk_prepare_enable %s fail %d\n",
__func__, aud_clks[div_clk_id], ret);
return ret;
}
ret = clk_set_rate(afe_priv->clk[div_clk_id], rate);
if (ret) {
dev_err(afe->dev, "%s(), clk_set_rate %s, rate %d, fail %d\n",
__func__, aud_clks[div_clk_id], rate, ret);
return ret;
}
return 0;
}
void mt8186_mck_disable(struct mtk_base_afe *afe, int mck_id)
{
struct mt8186_afe_private *afe_priv = afe->platform_priv;
int m_sel_id = mck_div[mck_id].m_sel_id;
int div_clk_id = mck_div[mck_id].div_clk_id;
clk_disable_unprepare(afe_priv->clk[div_clk_id]);
if (m_sel_id >= 0)
clk_disable_unprepare(afe_priv->clk[m_sel_id]);
}
int mt8186_init_clock(struct mtk_base_afe *afe)
{
struct mt8186_afe_private *afe_priv = afe->platform_priv;
struct device_node *of_node = afe->dev->of_node;
int i = 0;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/regmap.h`, `linux/mfd/syscon.h`, `mt8186-afe-common.h`, `mt8186-afe-clk.h`, `mt8186-audsys-clk.h`.
- Detected declarations: `struct mt8186_mck_div`, `function mt8186_set_audio_int_bus_parent`, `function apll1_mux_setting`, `function apll2_mux_setting`, `function mt8186_afe_enable_cgs`, `function mt8186_afe_disable_cgs`, `function mt8186_afe_enable_clock`, `function mt8186_afe_disable_clock`, `function mt8186_apll1_enable`, `function mt8186_apll1_disable`.
- 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.