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.

Dependency Surface

Detected Declarations

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

Implementation Notes