sound/soc/codecs/max98363.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/max98363.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/max98363.c
Extension
.c
Size
12316 bytes
Lines
457
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

// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2022, Analog Devices Inc.

#include <linux/module.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw_type.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/tlv.h>

#include "max98363.h"

static const struct reg_default max98363_reg[] = {
	{MAX98363_R2021_ERR_MON_CTRL, 0x0},
	{MAX98363_R2022_SPK_MON_THRESH, 0x0},
	{MAX98363_R2023_SPK_MON_DURATION, 0x0},
	{MAX98363_R2030_TONE_GEN_CFG, 0x0},
	{MAX98363_R203F_TONE_GEN_EN, 0x0},
	{MAX98363_R2040_AMP_VOL, 0x0},
	{MAX98363_R2041_AMP_GAIN, 0x5},
	{MAX98363_R2042_DSP_CFG, 0x0},
};

static bool max98363_readable_register(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case MAX98363_R2001_INTR_RAW:
	case MAX98363_R2003_INTR_STATE:
	case MAX98363_R2005_INTR_FALG:
	case MAX98363_R2007_INTR_EN:
	case MAX98363_R2009_INTR_CLR:
	case MAX98363_R2021_ERR_MON_CTRL ... MAX98363_R2023_SPK_MON_DURATION:
	case MAX98363_R2030_TONE_GEN_CFG:
	case MAX98363_R203F_TONE_GEN_EN:
	case MAX98363_R2040_AMP_VOL:
	case MAX98363_R2041_AMP_GAIN:
	case MAX98363_R2042_DSP_CFG:
	case MAX98363_R21FF_REV_ID:
		return true;
	default:
		return false;
	}
};

static bool max98363_volatile_reg(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case MAX98363_R2001_INTR_RAW:
	case MAX98363_R2003_INTR_STATE:
	case MAX98363_R2005_INTR_FALG:
	case MAX98363_R2007_INTR_EN:
	case MAX98363_R2009_INTR_CLR:
	case MAX98363_R21FF_REV_ID:
		return true;
	default:
		return false;
	}
}

static const struct regmap_config max98363_sdw_regmap = {
	.reg_bits = 32,
	.val_bits = 8,
	.max_register = MAX98363_R21FF_REV_ID,
	.reg_defaults  = max98363_reg,
	.num_reg_defaults = ARRAY_SIZE(max98363_reg),
	.readable_reg = max98363_readable_register,
	.volatile_reg = max98363_volatile_reg,
	.cache_type = REGCACHE_RBTREE,
	.use_single_read = true,
	.use_single_write = true,
};

static int max98363_suspend(struct device *dev)
{
	struct max98363_priv *max98363 = dev_get_drvdata(dev);

	regcache_cache_only(max98363->regmap, true);
	regcache_mark_dirty(max98363->regmap);

	return 0;
}

#define MAX98363_PROBE_TIMEOUT 5000

static int max98363_resume(struct device *dev)
{

Annotation

Implementation Notes