sound/soc/tegra/tegra20_ac97.c
Source file repositories/reference/linux-study-clean/sound/soc/tegra/tegra20_ac97.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/tegra/tegra20_ac97.c- Extension
.c- Size
- 11694 bytes
- Lines
- 460
- 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/clk.hlinux/delay.hlinux/device.hlinux/gpio/consumer.hlinux/io.hlinux/jiffies.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/reset.hlinux/slab.hsound/core.hsound/pcm.hsound/pcm_params.hsound/soc.hsound/dmaengine_pcm.htegra20_ac97.h
Detected Declarations
function tegra20_ac97_codec_resetfunction tegra20_ac97_codec_warm_resetfunction tegra20_ac97_codec_readfunction tegra20_ac97_codec_writefunction tegra20_ac97_start_playbackfunction tegra20_ac97_stop_playbackfunction tegra20_ac97_start_capturefunction tegra20_ac97_stop_capturefunction tegra20_ac97_triggerfunction tegra20_ac97_probefunction tegra20_ac97_wr_rd_regfunction tegra20_ac97_volatile_regfunction tegra20_ac97_precious_regfunction tegra20_ac97_platform_probefunction tegra20_ac97_platform_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* tegra20_ac97.c - Tegra20 AC97 platform driver
*
* Copyright (c) 2012 Lucas Stach <dev@lynxeye.de>
*
* Partly based on code copyright/by:
*
* Copyright (c) 2011,2012 Toradex Inc.
*/
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/gpio/consumer.h>
#include <linux/io.h>
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/dmaengine_pcm.h>
#include "tegra20_ac97.h"
#define DRV_NAME "tegra20-ac97"
static struct tegra20_ac97 *workdata;
static void tegra20_ac97_codec_reset(struct snd_ac97 *ac97)
{
u32 readback;
unsigned long timeout;
/*
* The reset line is not driven by DAC pad group, have to toggle GPIO.
* The RESET line is active low but this is abstracted by the GPIO
* library.
*/
gpiod_set_value(workdata->reset_gpio, 1);
udelay(2);
gpiod_set_value(workdata->reset_gpio, 0);
udelay(2);
timeout = jiffies + msecs_to_jiffies(100);
do {
regmap_read(workdata->regmap, TEGRA20_AC97_STATUS1, &readback);
if (readback & TEGRA20_AC97_STATUS1_CODEC1_RDY)
break;
usleep_range(1000, 2000);
} while (!time_after(jiffies, timeout));
}
static void tegra20_ac97_codec_warm_reset(struct snd_ac97 *ac97)
{
u32 readback;
unsigned long timeout;
/*
* although sync line is driven by the DAC pad group warm reset using
* the controller cmd is not working, have to toggle sync line
* manually.
*/
gpiod_direction_output(workdata->sync_gpio, 1);
udelay(2);
gpiod_set_value(workdata->sync_gpio, 0);
udelay(2);
timeout = jiffies + msecs_to_jiffies(100);
do {
regmap_read(workdata->regmap, TEGRA20_AC97_STATUS1, &readback);
if (readback & TEGRA20_AC97_STATUS1_CODEC1_RDY)
break;
usleep_range(1000, 2000);
} while (!time_after(jiffies, timeout));
}
static unsigned short tegra20_ac97_codec_read(struct snd_ac97 *ac97_snd,
unsigned short reg)
{
u32 readback;
Annotation
- Immediate include surface: `linux/clk.h`, `linux/delay.h`, `linux/device.h`, `linux/gpio/consumer.h`, `linux/io.h`, `linux/jiffies.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `function tegra20_ac97_codec_reset`, `function tegra20_ac97_codec_warm_reset`, `function tegra20_ac97_codec_read`, `function tegra20_ac97_codec_write`, `function tegra20_ac97_start_playback`, `function tegra20_ac97_stop_playback`, `function tegra20_ac97_start_capture`, `function tegra20_ac97_stop_capture`, `function tegra20_ac97_trigger`, `function tegra20_ac97_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.