sound/soc/sof/mediatek/mt8186/mt8186.c
Source file repositories/reference/linux-study-clean/sound/soc/sof/mediatek/mt8186/mt8186.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/sof/mediatek/mt8186/mt8186.c- Extension
.c- Size
- 14091 bytes
- Lines
- 571
- 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.
- 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/delay.hlinux/firmware.hlinux/io.hlinux/of_irq.hlinux/of_platform.hlinux/of_reserved_mem.hlinux/module.hsound/sof.hsound/sof/xtensa.h../../ops.h../../sof-of-dev.h../adsp_helper.h../mtk-adsp-common.hmt8186.hmt8186-clk.h
Detected Declarations
function mt8186_get_mailbox_offsetfunction mt8186_get_window_offsetfunction platform_parse_resourcefunction adsp_sram_power_onfunction adsp_sram_power_offfunction adsp_memory_remap_initfunction mt8186_runfunction mt8186_dsp_probefunction mt8186_dsp_removefunction mt8186_dsp_shutdownfunction mt8186_dsp_suspendfunction mt8186_dsp_resumefunction mt8186_adsp_dumpfunction sof_mt8188_ops_init
Annotated Snippet
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
//
// Copyright(c) 2022 Mediatek Inc. All rights reserved.
//
// Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
// Tinghan Shen <tinghan.shen@mediatek.com>
/*
* Hardware interface for audio DSP on mt8186
*/
#include <linux/delay.h>
#include <linux/firmware.h>
#include <linux/io.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/of_reserved_mem.h>
#include <linux/module.h>
#include <sound/sof.h>
#include <sound/sof/xtensa.h>
#include "../../ops.h"
#include "../../sof-of-dev.h"
#include "../adsp_helper.h"
#include "../mtk-adsp-common.h"
#include "mt8186.h"
#include "mt8186-clk.h"
static int mt8186_get_mailbox_offset(struct snd_sof_dev *sdev)
{
return MBOX_OFFSET;
}
static int mt8186_get_window_offset(struct snd_sof_dev *sdev, u32 id)
{
return MBOX_OFFSET;
}
static const struct mtk_adsp_ipc_ops dsp_ops = {
.handle_reply = mtk_adsp_handle_reply,
.handle_request = mtk_adsp_handle_request,
};
static int platform_parse_resource(struct platform_device *pdev, void *data)
{
struct resource *mmio;
struct resource res;
struct device *dev = &pdev->dev;
struct mtk_adsp_chip_info *adsp = data;
int ret;
ret = of_reserved_mem_device_init(dev);
if (ret) {
dev_err(dev, "of_reserved_mem_device_init failed\n");
return ret;
}
ret = of_reserved_mem_region_to_resource(dev->of_node, 1, &res);
if (ret) {
dev_err(dev, "of_address_to_resource sysmem failed\n");
return ret;
}
adsp->pa_dram = (phys_addr_t)res.start;
if (adsp->pa_dram & DRAM_REMAP_MASK) {
dev_err(dev, "adsp memory(%#x) is not 4K-aligned\n",
(u32)adsp->pa_dram);
return -EINVAL;
}
adsp->dramsize = resource_size(&res);
if (adsp->dramsize < TOTAL_SIZE_SHARED_DRAM_FROM_TAIL) {
dev_err(dev, "adsp memory(%#x) is not enough for share\n",
adsp->dramsize);
return -EINVAL;
}
dev_dbg(dev, "dram pbase=%pa size=%#x\n", &adsp->pa_dram, adsp->dramsize);
mmio = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg");
if (!mmio) {
dev_err(dev, "no ADSP-CFG register resource\n");
return -ENXIO;
}
adsp->va_cfgreg = devm_ioremap_resource(dev, mmio);
if (IS_ERR(adsp->va_cfgreg))
return PTR_ERR(adsp->va_cfgreg);
adsp->pa_cfgreg = (phys_addr_t)mmio->start;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/firmware.h`, `linux/io.h`, `linux/of_irq.h`, `linux/of_platform.h`, `linux/of_reserved_mem.h`, `linux/module.h`, `sound/sof.h`.
- Detected declarations: `function mt8186_get_mailbox_offset`, `function mt8186_get_window_offset`, `function platform_parse_resource`, `function adsp_sram_power_on`, `function adsp_sram_power_off`, `function adsp_memory_remap_init`, `function mt8186_run`, `function mt8186_dsp_probe`, `function mt8186_dsp_remove`, `function mt8186_dsp_shutdown`.
- 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.