sound/soc/codecs/cs35l56-sdw.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/cs35l56-sdw.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/cs35l56-sdw.c- Extension
.c- Size
- 14596 bytes
- Lines
- 536
- 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/delay.hlinux/device.hlinux/err.hlinux/module.hlinux/pm_runtime.hlinux/regmap.hlinux/soundwire/sdw.hlinux/soundwire/sdw_registers.hlinux/soundwire/sdw_type.hlinux/string_choices.hlinux/swab.hlinux/types.hlinux/unaligned.hlinux/workqueue.hcs35l56.h
Detected Declarations
function cs35l56_sdw_poll_mem_statusfunction cs35l56_sdw_slow_readfunction cs35l56_sdw_readfunction cs35l56_swab_copyfunction cs35l56_sdw_gather_writefunction cs35l56_sdw_writefunction cs35l56_sdw_get_unique_idfunction cs35l56_sdw_initfunction cs35l56_sdw_interruptfunction cs35l56_sdw_irq_workfunction cs35l56_sdw_read_propfunction cs35l56_sdw_update_statusfunction cs35l56_sdw_handle_unattachfunction cs35l56_sdw_runtime_suspendfunction cs35l56_sdw_runtime_resumefunction cs35l56_sdw_system_suspendfunction cs35l56_sdw_system_resumefunction cs35l56_sdw_probefunction cs35l56_sdw_remove
Annotated Snippet
if (ret < 0) {
dev_err(&peripheral->dev, "!CMD_IN_PROGRESS fail: %d\n", ret);
return ret;
}
/* Reading LSByte triggers read of register to holding buffer */
sdw_read_no_pm(peripheral, reg + i);
/* Wait for data available */
ret = cs35l56_sdw_poll_mem_status(peripheral,
CS35L56_SDW_RDATA_RDY,
CS35L56_SDW_RDATA_RDY);
if (ret < 0) {
dev_err(&peripheral->dev, "RDATA_RDY fail: %d\n", ret);
return ret;
}
/* Read data from buffer */
ret = sdw_nread_no_pm(peripheral, CS35L56_SDW_MEM_READ_DATA,
sizeof(u32), &buf[i]);
if (ret) {
dev_err(&peripheral->dev, "Late read @%#x failed: %d\n", reg + i, ret);
return ret;
}
swab32s((u32 *)&buf[i]);
}
return 0;
}
static int cs35l56_sdw_read(void *context, const void *reg_buf,
const size_t reg_size, void *val_buf,
size_t val_size)
{
struct sdw_slave *peripheral = context;
struct cs35l56_private *cs35l56 = dev_get_drvdata(&peripheral->dev);
unsigned int reg_addr = get_unaligned_le32(reg_buf);
int ret;
if (cs35l56_is_otp_register(reg_addr - CS35L56_SDW_ADDR_OFFSET))
return cs35l56_sdw_slow_read(peripheral, reg_addr, (u8 *)val_buf, val_size);
ret = regmap_raw_read(cs35l56->sdw_bus_regmap, reg_addr, val_buf, val_size);
if (ret)
return ret;
swab32_array((u32 *)val_buf, val_size / sizeof(u32));
return 0;
}
static inline void cs35l56_swab_copy(void *dest, const void *src, size_t nbytes)
{
u32 *dest32 = dest;
const u32 *src32 = src;
for (; nbytes > 0; nbytes -= 4)
*dest32++ = swab32(*src32++);
}
static int cs35l56_sdw_gather_write(void *context,
const void *reg_buf, size_t reg_size,
const void *val_buf, size_t val_size)
{
struct sdw_slave *peripheral = context;
struct cs35l56_private *cs35l56 = dev_get_drvdata(&peripheral->dev);
unsigned int reg_addr = get_unaligned_le32(reg_buf);
u32 swab_buf[64]; /* Define u32 so it is 32-bit aligned */
int ret;
while (val_size > sizeof(swab_buf)) {
cs35l56_swab_copy(swab_buf, val_buf, sizeof(swab_buf));
ret = regmap_raw_write(cs35l56->sdw_bus_regmap, reg_addr,
swab_buf, sizeof(swab_buf));
if (ret)
return ret;
val_size -= sizeof(swab_buf);
reg_addr += sizeof(swab_buf);
val_buf += sizeof(swab_buf);
}
if (val_size == 0)
return 0;
cs35l56_swab_copy(swab_buf, val_buf, val_size);
return regmap_raw_write(cs35l56->sdw_bus_regmap, reg_addr, swab_buf, val_size);
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/module.h`, `linux/pm_runtime.h`, `linux/regmap.h`, `linux/soundwire/sdw.h`, `linux/soundwire/sdw_registers.h`.
- Detected declarations: `function cs35l56_sdw_poll_mem_status`, `function cs35l56_sdw_slow_read`, `function cs35l56_sdw_read`, `function cs35l56_swab_copy`, `function cs35l56_sdw_gather_write`, `function cs35l56_sdw_write`, `function cs35l56_sdw_get_unique_id`, `function cs35l56_sdw_init`, `function cs35l56_sdw_interrupt`, `function cs35l56_sdw_irq_work`.
- 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.