sound/soc/codecs/cs35l41-lib.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs35l41-lib.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs35l41-lib.c- Extension
.c- Size
- 50464 bytes
- Lines
- 1593
- 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.
- 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/dev_printk.hlinux/module.hlinux/regmap.hlinux/regulator/consumer.hlinux/slab.hlinux/firmware/cirrus/wmfw.hsound/cs35l41.h
Detected Declarations
function cs35l41_readable_regfunction cs35l41_precious_regfunction cs35l41_volatile_regfunction cs35l41_test_key_unlockfunction cs35l41_test_key_lockfunction cs35l41_otp_unpackfunction cs35l41_register_errata_patchfunction cs35l41_set_channelsfunction cs35l41_boost_configfunction cs35l41_init_boostfunction cs35l41_safe_resetfunction cs35l41_mdsync_upfunction cs35l41_global_enablefunction cs35l41_gpio_configfunction cs35l41_configure_cs_dspfunction cs35l41_check_cspl_mbox_stsfunction cs35l41_set_cspl_mbox_cmdfunction cs35l41_write_fs_erratafunction cs35l41_enter_hibernatefunction cs35l41_wait_for_pwrmgt_stsfunction cs35l41_exit_hibernateexport cs35l41_regmap_i2cexport cs35l41_regmap_spiexport cs35l41_test_key_unlockexport cs35l41_test_key_lockexport cs35l41_otp_unpackexport cs35l41_register_errata_patchexport cs35l41_set_channelsexport cs35l41_init_boostexport cs35l41_safe_resetexport cs35l41_global_enableexport cs35l41_mdsync_upexport cs35l41_gpio_configexport cs35l41_configure_cs_dspexport cs35l41_set_cspl_mbox_cmdexport cs35l41_write_fs_errataexport cs35l41_enter_hibernateexport cs35l41_exit_hibernate
Annotated Snippet
if (bit_offset + otp_map[i].size - 1 >= 32) {
otp_val = (otp_mem[word_offset] &
GENMASK(31, bit_offset)) >> bit_offset;
otp_val |= (otp_mem[++word_offset] &
GENMASK(bit_offset + otp_map[i].size - 33, 0)) <<
(32 - bit_offset);
bit_offset += otp_map[i].size - 32;
} else if (bit_offset + otp_map[i].size - 1 >= 0) {
otp_val = (otp_mem[word_offset] &
GENMASK(bit_offset + otp_map[i].size - 1, bit_offset)
) >> bit_offset;
bit_offset += otp_map[i].size;
} else /* both bit_offset and otp_map[i].size are 0 */
otp_val = 0;
bit_sum += otp_map[i].size;
if (bit_offset == 32) {
bit_offset = 0;
word_offset++;
}
if (otp_map[i].reg != 0) {
ret = regmap_update_bits(regmap, otp_map[i].reg,
GENMASK(otp_map[i].shift + otp_map[i].size - 1,
otp_map[i].shift),
otp_val << otp_map[i].shift);
if (ret < 0) {
dev_err(dev, "Write OTP val failed: %d\n", ret);
goto err_otp_unpack;
}
}
}
ret = 0;
err_otp_unpack:
kfree(otp_mem);
return ret;
}
EXPORT_SYMBOL_GPL(cs35l41_otp_unpack);
/* Must be called with the TEST_KEY unlocked */
int cs35l41_register_errata_patch(struct device *dev, struct regmap *reg, unsigned int reg_revid)
{
char *rev;
int ret;
switch (reg_revid) {
case CS35L41_REVID_A0:
ret = regmap_register_patch(reg, cs35l41_reva0_errata_patch,
ARRAY_SIZE(cs35l41_reva0_errata_patch));
rev = "A0";
break;
case CS35L41_REVID_B0:
ret = regmap_register_patch(reg, cs35l41_revb0_errata_patch,
ARRAY_SIZE(cs35l41_revb0_errata_patch));
rev = "B0";
break;
case CS35L41_REVID_B2:
ret = regmap_register_patch(reg, cs35l41_revb2_errata_patch,
ARRAY_SIZE(cs35l41_revb2_errata_patch));
rev = "B2";
break;
default:
ret = -EINVAL;
rev = "XX";
break;
}
if (ret)
dev_err(dev, "Failed to apply %s errata patch: %d\n", rev, ret);
ret = regmap_write(reg, CS35L41_DSP1_CCM_CORE_CTRL, 0);
if (ret < 0)
dev_err(dev, "Write CCM_CORE_CTRL failed: %d\n", ret);
return ret;
}
EXPORT_SYMBOL_GPL(cs35l41_register_errata_patch);
int cs35l41_set_channels(struct device *dev, struct regmap *reg,
unsigned int tx_num, const unsigned int *tx_slot,
unsigned int rx_num, const unsigned int *rx_slot)
{
unsigned int val, mask;
int i;
if (tx_num > 4 || rx_num > 2)
Annotation
- Immediate include surface: `linux/dev_printk.h`, `linux/module.h`, `linux/regmap.h`, `linux/regulator/consumer.h`, `linux/slab.h`, `linux/firmware/cirrus/wmfw.h`, `sound/cs35l41.h`.
- Detected declarations: `function cs35l41_readable_reg`, `function cs35l41_precious_reg`, `function cs35l41_volatile_reg`, `function cs35l41_test_key_unlock`, `function cs35l41_test_key_lock`, `function cs35l41_otp_unpack`, `function cs35l41_register_errata_patch`, `function cs35l41_set_channels`, `function cs35l41_boost_config`, `function cs35l41_init_boost`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: integration 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.