sound/soc/tegra/tegra210_amx.c
Source file repositories/reference/linux-study-clean/sound/soc/tegra/tegra210_amx.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/tegra/tegra210_amx.c- Extension
.c- Size
- 23920 bytes
- Lines
- 809
- 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/bits.hlinux/clk.hlinux/device.hlinux/io.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.htegra210_amx.htegra_cif.h
Detected Declarations
function tegra210_amx_write_map_ramfunction tegra210_amx_startupfunction tegra210_amx_runtime_suspendfunction tegra210_amx_runtime_resumefunction tegra210_amx_set_audio_ciffunction tegra210_amx_in_hw_paramsfunction tegra210_amx_out_hw_paramsfunction tegra210_amx_get_byte_mapfunction tegra210_amx_put_byte_mapfunction tegra210_amx_component_probefunction tegra210_amx_wr_regfunction tegra194_amx_wr_regfunction tegra264_amx_wr_regfunction tegra210_amx_rd_regfunction tegra194_amx_rd_regfunction tegra264_amx_rd_regfunction tegra210_amx_volatile_regfunction tegra264_amx_volatile_regfunction tegra210_amx_platform_probefunction tegra210_amx_platform_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES.
// All rights reserved.
//
// tegra210_amx.c - Tegra210 AMX driver
#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include "tegra210_amx.h"
#include "tegra_cif.h"
/*
* The counter is in terms of AHUB clock cycles. If a frame is not
* received within these clock cycles, the AMX input channel gets
* automatically disabled. For now the counter is calculated as a
* function of sample rate (8 kHz) and AHUB clock (49.152 MHz).
* If later an accurate number is needed, the counter needs to be
* calculated at runtime.
*
* count = ahub_clk / sample_rate
*/
#define TEGRA194_MAX_FRAME_IDLE_COUNT 0x1800
#define AMX_CH_REG(id, reg) ((reg) + ((id) * TEGRA210_AMX_AUDIOCIF_CH_STRIDE))
static const struct reg_default tegra210_amx_reg_defaults[] = {
{ TEGRA210_AMX_RX_INT_MASK, 0x0000000f},
{ TEGRA210_AMX_RX1_CIF_CTRL, 0x00007000},
{ TEGRA210_AMX_RX2_CIF_CTRL, 0x00007000},
{ TEGRA210_AMX_RX3_CIF_CTRL, 0x00007000},
{ TEGRA210_AMX_RX4_CIF_CTRL, 0x00007000},
{ TEGRA210_AMX_TX_INT_MASK, 0x00000001},
{ TEGRA210_AMX_TX_CIF_CTRL, 0x00007000},
{ TEGRA210_AMX_CG, 0x1},
{ TEGRA210_AMX_CFG_RAM_CTRL, 0x00004000},
};
static const struct reg_default tegra264_amx_reg_defaults[] = {
{ TEGRA210_AMX_RX_INT_MASK, 0x0000000f},
{ TEGRA210_AMX_RX1_CIF_CTRL, 0x00003800},
{ TEGRA210_AMX_RX2_CIF_CTRL, 0x00003800},
{ TEGRA210_AMX_RX3_CIF_CTRL, 0x00003800},
{ TEGRA210_AMX_RX4_CIF_CTRL, 0x00003800},
{ TEGRA210_AMX_TX_INT_MASK, 0x00000001},
{ TEGRA210_AMX_TX_CIF_CTRL, 0x00003800},
{ TEGRA210_AMX_CG, 0x1},
{ TEGRA264_AMX_CFG_RAM_CTRL, 0x00004000},
};
static void tegra210_amx_write_map_ram(struct tegra210_amx *amx)
{
const unsigned int bits_per_mask = BITS_PER_TYPE(*amx->byte_mask);
int i;
memset(amx->byte_mask, 0,
amx->soc_data->byte_mask_size * sizeof(*amx->byte_mask));
regmap_write(amx->regmap, TEGRA210_AMX_CFG_RAM_CTRL + amx->soc_data->reg_offset,
TEGRA210_AMX_CFG_RAM_CTRL_SEQ_ACCESS_EN |
TEGRA210_AMX_CFG_RAM_CTRL_ADDR_INIT_EN |
TEGRA210_AMX_CFG_RAM_CTRL_RW_WRITE);
for (i = 0; i < amx->soc_data->ram_depth; i++) {
u32 word = 0;
int b;
for (b = 0; b < TEGRA_AMX_SLOTS_PER_WORD; b++) {
unsigned int slot = i * TEGRA_AMX_SLOTS_PER_WORD + b;
u16 val = amx->map[slot];
if (val >= 256)
continue;
word |= (u32)val << (b * BITS_PER_BYTE);
amx->byte_mask[slot / bits_per_mask] |=
1U << (slot % bits_per_mask);
}
regmap_write(amx->regmap, TEGRA210_AMX_CFG_RAM_DATA + amx->soc_data->reg_offset,
Annotation
- Immediate include surface: `linux/bits.h`, `linux/clk.h`, `linux/device.h`, `linux/io.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`, `linux/pm_runtime.h`.
- Detected declarations: `function tegra210_amx_write_map_ram`, `function tegra210_amx_startup`, `function tegra210_amx_runtime_suspend`, `function tegra210_amx_runtime_resume`, `function tegra210_amx_set_audio_cif`, `function tegra210_amx_in_hw_params`, `function tegra210_amx_out_hw_params`, `function tegra210_amx_get_byte_map`, `function tegra210_amx_put_byte_map`, `function tegra210_amx_component_probe`.
- 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.