sound/soc/sof/mediatek/mt8186/mt8186-clk.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/mediatek/mt8186/mt8186-clk.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/mediatek/mt8186/mt8186-clk.c- Extension
.c- Size
- 2410 bytes
- Lines
- 101
- 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/io.h../../sof-audio.h../../ops.h../adsp_helper.hmt8186.hmt8186-clk.h
Detected Declarations
function mt8186_adsp_init_clockfunction adsp_enable_all_clockfunction adsp_disable_all_clockfunction mt8186_adsp_clock_onfunction mt8186_adsp_clock_off
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
//
// Copyright(c) 2022 Mediatek Corporation. All rights reserved.
//
// Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
// Tinghan Shen <tinghan.shen@mediatek.com>
//
// Hardware interface for mt8186 DSP clock
#include <linux/clk.h>
#include <linux/io.h>
#include "../../sof-audio.h"
#include "../../ops.h"
#include "../adsp_helper.h"
#include "mt8186.h"
#include "mt8186-clk.h"
static const char *adsp_clks[ADSP_CLK_MAX] = {
[CLK_TOP_AUDIODSP] = "audiodsp",
[CLK_TOP_ADSP_BUS] = "adsp_bus",
};
int mt8186_adsp_init_clock(struct snd_sof_dev *sdev)
{
struct adsp_priv *priv = sdev->pdata->hw_pdata;
struct device *dev = sdev->dev;
int i;
priv->clk = devm_kcalloc(dev, ADSP_CLK_MAX, sizeof(*priv->clk), GFP_KERNEL);
if (!priv->clk)
return -ENOMEM;
for (i = 0; i < ADSP_CLK_MAX; i++) {
priv->clk[i] = devm_clk_get(dev, adsp_clks[i]);
if (IS_ERR(priv->clk[i]))
return PTR_ERR(priv->clk[i]);
}
return 0;
}
static int adsp_enable_all_clock(struct snd_sof_dev *sdev)
{
struct adsp_priv *priv = sdev->pdata->hw_pdata;
struct device *dev = sdev->dev;
int ret;
ret = clk_prepare_enable(priv->clk[CLK_TOP_AUDIODSP]);
if (ret) {
dev_err(dev, "%s clk_prepare_enable(audiodsp) fail %d\n",
__func__, ret);
return ret;
}
ret = clk_prepare_enable(priv->clk[CLK_TOP_ADSP_BUS]);
if (ret) {
dev_err(dev, "%s clk_prepare_enable(adsp_bus) fail %d\n",
__func__, ret);
clk_disable_unprepare(priv->clk[CLK_TOP_AUDIODSP]);
return ret;
}
return 0;
}
static void adsp_disable_all_clock(struct snd_sof_dev *sdev)
{
struct adsp_priv *priv = sdev->pdata->hw_pdata;
clk_disable_unprepare(priv->clk[CLK_TOP_ADSP_BUS]);
clk_disable_unprepare(priv->clk[CLK_TOP_AUDIODSP]);
}
int mt8186_adsp_clock_on(struct snd_sof_dev *sdev)
{
struct device *dev = sdev->dev;
int ret;
ret = adsp_enable_all_clock(sdev);
if (ret) {
dev_err(dev, "failed to adsp_enable_clock: %d\n", ret);
return ret;
}
snd_sof_dsp_write(sdev, DSP_REG_BAR, ADSP_CK_EN,
UART_EN | DMA_EN | TIMER_EN | COREDBG_EN | CORE_CLK_EN);
snd_sof_dsp_write(sdev, DSP_REG_BAR, ADSP_UART_CTRL,
UART_BCLK_CG | UART_RSTN);
Annotation
- Immediate include surface: `linux/clk.h`, `linux/io.h`, `../../sof-audio.h`, `../../ops.h`, `../adsp_helper.h`, `mt8186.h`, `mt8186-clk.h`.
- Detected declarations: `function mt8186_adsp_init_clock`, `function adsp_enable_all_clock`, `function adsp_disable_all_clock`, `function mt8186_adsp_clock_on`, `function mt8186_adsp_clock_off`.
- 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.