sound/soc/codecs/cs42l43.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs42l43.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs42l43.c- Extension
.c- Size
- 99282 bytes
- Lines
- 2967
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bitops.hlinux/bits.hlinux/build_bug.hlinux/clk.hlinux/device.hlinux/err.hlinux/errno.hlinux/bitmap.hlinux/gcd.hlinux/irq.hlinux/irqdomain.hlinux/jiffies.hlinux/mfd/cs42l43.hlinux/mfd/cs42l43-regs.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/string.hlinux/workqueue.hsound/control.hsound/cs42l43.hsound/pcm.hsound/pcm_params.hsound/soc-component.hsound/soc-dapm.hsound/soc-dai.hsound/soc.hsound/tlv.hcs42l43.h
Detected Declarations
struct cs42l43_pll_configstruct cs42l43_irqfunction cs42l43_hp_ilimit_clear_workfunction cs42l43_hp_ilimitfunction cs42l43_mic_shutterfunction cs42l43_spk_shutterfunction cs42l43_startupfunction cs42l43_convert_sample_ratefunction cs42l43_set_sample_ratefunction cs42l43_asp_hw_paramsfunction cs42l43_asp_set_fmtfunction cs42l43_mask_to_slotsfunction for_each_set_bitfunction cs42l43_asp_set_tdm_slotfunction cs42l43_dai_probefunction cs42l43_dai_removefunction cs42l43_sdw_hw_paramsfunction cs42l43_dapm_get_volswfunction cs42l43_dapm_put_volswfunction cs42l43_dapm_get_enumfunction cs42l43_dapm_put_enumfunction cs42l43_eq_getfunction cs42l43_eq_putfunction cs42l43_spk_vu_syncfunction cs42l43_shutter_getfunction cs42l43_decim_getfunction cs42l43_spk_getfunction cs42l43_spk_putfunction cs42l43_eq_evfunction cs42l43_set_pllfunction cs42l43_enable_pllfunction cs42l43_disable_pllfunction cs42l43_pll_evfunction cs42l43_dapm_wait_completionfunction cs42l43_spkr_evfunction cs42l43_spkl_evfunction cs42l43_hp_evfunction cs42l43_mic_evfunction cs42l43_adc_evfunction cs42l43_set_sysclkfunction cs42l43_component_probefunction cs42l43_component_removefunction cs42l43_request_irqfunction cs42l43_disable_irqfunction cs42l43_enable_irqfunction cs42l43_shutter_irqfunction cs42l43_codec_probefunction cs42l43_codec_remove
Annotated Snippet
struct cs42l43_pll_config {
unsigned int freq;
unsigned int div;
unsigned int mode;
unsigned int cal;
};
static const struct cs42l43_pll_config cs42l43_pll_configs[] = {
{ 2400000, 0x50000000, 0x1, 0xA4 },
{ 3000000, 0x40000000, 0x1, 0x83 },
{ 3072000, 0x40000000, 0x3, 0x80 },
};
static int cs42l43_set_pll(struct cs42l43_codec *priv, unsigned int src,
unsigned int freq)
{
struct cs42l43 *cs42l43 = priv->core;
lockdep_assert_held(&cs42l43->pll_lock);
if (priv->refclk_src == src && priv->refclk_freq == freq)
return 0;
if (regmap_test_bits(cs42l43->regmap, CS42L43_CTRL_REG, CS42L43_PLL_EN_MASK)) {
dev_err(priv->dev, "PLL active, can't change configuration\n");
return -EBUSY;
}
switch (src) {
case CS42L43_SYSCLK_MCLK:
case CS42L43_SYSCLK_SDW:
dev_dbg(priv->dev, "Source PLL from %s at %uHz\n",
src ? "SoundWire" : "MCLK", freq);
priv->refclk_src = src;
priv->refclk_freq = freq;
return 0;
default:
dev_err(priv->dev, "Invalid PLL source: 0x%x\n", src);
return -EINVAL;
}
}
static int cs42l43_enable_pll(struct cs42l43_codec *priv)
{
static const struct reg_sequence enable_seq[] = {
{ CS42L43_OSC_DIV_SEL, 0x0, },
{ CS42L43_MCLK_SRC_SEL, CS42L43_OSC_PLL_MCLK_SEL_MASK, 5, },
};
struct cs42l43 *cs42l43 = priv->core;
const struct cs42l43_pll_config *config = NULL;
unsigned int div = 0;
unsigned int freq = priv->refclk_freq;
unsigned long time_left;
lockdep_assert_held(&cs42l43->pll_lock);
if (priv->refclk_src == CS42L43_SYSCLK_SDW) {
if (!freq)
freq = cs42l43->sdw_freq;
else if (!cs42l43->sdw_freq)
cs42l43->sdw_freq = freq;
}
dev_dbg(priv->dev, "Enabling PLL at %uHz\n", freq);
div = fls(freq) -
fls(cs42l43_pll_configs[ARRAY_SIZE(cs42l43_pll_configs) - 1].freq);
freq >>= div;
if (div <= CS42L43_PLL_REFCLK_DIV_MASK) {
int i;
for (i = 0; i < ARRAY_SIZE(cs42l43_pll_configs); i++) {
if (freq == cs42l43_pll_configs[i].freq) {
config = &cs42l43_pll_configs[i];
break;
}
}
}
if (!config) {
dev_err(priv->dev, "No suitable PLL config: 0x%x, %uHz\n", div, freq);
return -EINVAL;
}
regmap_update_bits(cs42l43->regmap, CS42L43_PLL_CONTROL,
CS42L43_PLL_REFCLK_DIV_MASK | CS42L43_PLL_REFCLK_SRC_MASK,
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bits.h`, `linux/build_bug.h`, `linux/clk.h`, `linux/device.h`, `linux/err.h`, `linux/errno.h`, `linux/bitmap.h`.
- Detected declarations: `struct cs42l43_pll_config`, `struct cs42l43_irq`, `function cs42l43_hp_ilimit_clear_work`, `function cs42l43_hp_ilimit`, `function cs42l43_mic_shutter`, `function cs42l43_spk_shutter`, `function cs42l43_startup`, `function cs42l43_convert_sample_rate`, `function cs42l43_set_sample_rate`, `function cs42l43_asp_hw_params`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.