sound/soc/codecs/arizona.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/arizona.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/arizona.c- Extension
.c- Size
- 71912 bytes
- Lines
- 2858
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/gcd.hlinux/module.hlinux/of.hlinux/pm_runtime.hsound/pcm.hsound/pcm_params.hsound/tlv.hlinux/mfd/arizona/core.hlinux/mfd/arizona/registers.harizona.h
Detected Declarations
struct arizona_fll_cfgfunction arizona_spk_evfunction arizona_thermal_warnfunction arizona_thermal_shutdownfunction arizona_init_spkfunction arizona_init_spk_irqsfunction arizona_free_spk_irqsfunction arizona_init_monofunction arizona_init_gpiofunction arizona_init_commonfunction arizona_init_vol_limitfunction arizona_in_set_vufunction arizona_input_analogfunction arizona_in_evfunction arizona_out_evfunction arizona_hp_evfunction arizona_dvfs_enablefunction arizona_dvfs_disablefunction arizona_dvfs_upfunction arizona_dvfs_downfunction arizona_dvfs_sysclk_evfunction arizona_init_dvfsfunction arizona_anc_evfunction arizona_set_opclkfunction arizona_clk_evfunction arizona_set_sysclkfunction arizona_set_fmtfunction arizona_startupfunction arizona_wm5102_set_dac_compfunction arizona_hw_params_ratefunction arizona_aif_cfg_changedfunction arizona_hw_paramsfunction arizona_dai_set_sysclkfunction arizona_set_tristatefunction arizona_set_channels_to_maskfunction arizona_set_tdm_slotfunction arizona_init_daifunction arizona_validate_fllfunction arizona_find_fratiofunction arizona_calc_fratiofunction arizona_calc_fllfunction arizona_apply_fllfunction arizona_is_enabled_fllfunction arizona_set_fll_clksfunction arizona_enable_fllfunction arizona_disable_fllfunction arizona_set_fll_refclkfunction arizona_set_fll
Annotated Snippet
struct arizona_fll_cfg {
int n;
unsigned int theta;
unsigned int lambda;
int refdiv;
int outdiv;
int fratio;
int gain;
};
static int arizona_validate_fll(struct arizona_fll *fll,
unsigned int Fref,
unsigned int Fout)
{
unsigned int Fvco_min;
if (fll->fout && Fout != fll->fout) {
arizona_fll_err(fll,
"Can't change output on active FLL\n");
return -EINVAL;
}
if (Fref / ARIZONA_FLL_MAX_REFDIV > ARIZONA_FLL_MAX_FREF) {
arizona_fll_err(fll,
"Can't scale %dMHz in to <=13.5MHz\n",
Fref);
return -EINVAL;
}
Fvco_min = ARIZONA_FLL_MIN_FVCO * fll->vco_mult;
if (Fout * ARIZONA_FLL_MAX_OUTDIV < Fvco_min) {
arizona_fll_err(fll, "No FLL_OUTDIV for Fout=%uHz\n",
Fout);
return -EINVAL;
}
return 0;
}
static int arizona_find_fratio(unsigned int Fref, int *fratio)
{
int i;
/* Find an appropriate FLL_FRATIO */
for (i = 0; i < ARRAY_SIZE(fll_fratios); i++) {
if (fll_fratios[i].min <= Fref && Fref <= fll_fratios[i].max) {
if (fratio)
*fratio = fll_fratios[i].fratio;
return fll_fratios[i].ratio;
}
}
return -EINVAL;
}
static int arizona_calc_fratio(struct arizona_fll *fll,
struct arizona_fll_cfg *cfg,
unsigned int target,
unsigned int Fref, bool sync)
{
int init_ratio, ratio;
int refdiv, div;
/* Fref must be <=13.5MHz, find initial refdiv */
div = 1;
cfg->refdiv = 0;
while (Fref > ARIZONA_FLL_MAX_FREF) {
div *= 2;
Fref /= 2;
cfg->refdiv++;
if (div > ARIZONA_FLL_MAX_REFDIV)
return -EINVAL;
}
/* Find an appropriate FLL_FRATIO */
init_ratio = arizona_find_fratio(Fref, &cfg->fratio);
if (init_ratio < 0) {
arizona_fll_err(fll, "Unable to find FRATIO for Fref=%uHz\n",
Fref);
return init_ratio;
}
switch (fll->arizona->type) {
case WM5102:
case WM8997:
return init_ratio;
case WM5110:
case WM8280:
if (fll->arizona->rev < 3 || sync)
Annotation
- Immediate include surface: `linux/delay.h`, `linux/gcd.h`, `linux/module.h`, `linux/of.h`, `linux/pm_runtime.h`, `sound/pcm.h`, `sound/pcm_params.h`, `sound/tlv.h`.
- Detected declarations: `struct arizona_fll_cfg`, `function arizona_spk_ev`, `function arizona_thermal_warn`, `function arizona_thermal_shutdown`, `function arizona_init_spk`, `function arizona_init_spk_irqs`, `function arizona_free_spk_irqs`, `function arizona_init_mono`, `function arizona_init_gpio`, `function arizona_init_common`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.