drivers/soundwire/cadence_master.c
Source file repositories/reference/linux-study-clean/drivers/soundwire/cadence_master.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soundwire/cadence_master.c- Extension
.c- Size
- 73119 bytes
- Lines
- 2728
- Domain
- Driver Families
- Bucket
- drivers/soundwire
- 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.
- 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/cleanup.hlinux/crc8.hlinux/delay.hlinux/device.hlinux/debugfs.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/mod_devicetable.hlinux/pm_runtime.hlinux/soundwire/sdw_registers.hlinux/soundwire/sdw.hsound/pcm_params.hsound/soc.hlinux/workqueue.hbus.hcadence_master.h
Detected Declarations
function cdns_readlfunction cdns_writelfunction cdns_ip_readlfunction cdns_ip_writelfunction cdns_updatelfunction cdns_ip_updatelfunction cdns_set_waitfunction cdns_clear_bitfunction cdns_config_updatefunction sdw_cdns_config_updatefunction sdw_cdns_config_update_set_waitfunction cdns_sprintffunction cdns_reg_showfunction cdns_hw_resetfunction cdns_parity_error_injectionfunction cdns_set_pdi_loopback_sourcefunction cdns_set_pdi_loopback_targetfunction sdw_cdns_debugfs_initfunction cdns_fill_msg_respfunction cdns_read_responsefunction _cdns_xfer_msgfunction cdns_program_scp_addrfunction cdns_prep_msgfunction cdns_xfer_msgfunction cdns_xfer_msg_deferfunction cdns_read_ping_statusfunction cdns_update_slave_statusfunction sdw_cdns_irqfunction cdns_check_attached_status_dworkfunction cdns_update_slave_status_workfunction sdw_cdns_check_self_clearing_bitsfunction sdw_cdns_exit_resetfunction cdns_enable_slave_interruptsfunction sdw_cdns_enable_interruptfunction cdns_allocate_pdifunction sdw_cdns_pdi_initfunction cdns_set_initial_frame_shapefunction cdns_init_clock_ctrlfunction sdw_cdns_soft_resetfunction sdw_cdns_initfunction cdns_bus_conffunction cdns_port_paramsfunction cdns_transport_paramsfunction cdns_port_enablefunction sdw_cdns_is_clock_stopfunction sdw_cdns_clock_stopfunction list_for_each_entryfunction sdw_cdns_clock_restart
Annotated Snippet
if (!(cdns->response_buf[i] & CDNS_MCP_RESP_ACK)) {
no_ack = 1;
dev_vdbg(cdns->dev, "Msg Ack not received, cmd %d\n", i);
}
if (cdns->response_buf[i] & CDNS_MCP_RESP_NACK) {
nack = 1;
dev_err_ratelimited(cdns->dev, "Msg NACK received, cmd %d\n", i);
}
}
if (nack) {
dev_err_ratelimited(cdns->dev, "Msg NACKed for Slave %d\n", msg->dev_num);
return SDW_CMD_FAIL;
}
if (no_ack) {
dev_dbg_ratelimited(cdns->dev, "Msg ignored for Slave %d\n", msg->dev_num);
return SDW_CMD_IGNORED;
}
if (msg->flags == SDW_MSG_FLAG_READ) {
/* fill response */
for (i = 0; i < count; i++)
msg->buf[i + offset] = FIELD_GET(CDNS_MCP_RESP_RDATA,
cdns->response_buf[i]);
}
return SDW_CMD_OK;
}
static void cdns_read_response(struct sdw_cdns *cdns)
{
u32 num_resp, cmd_base;
int i;
/* RX_FIFO_AVAIL can be 2 entries more than the FIFO size */
BUILD_BUG_ON(ARRAY_SIZE(cdns->response_buf) < CDNS_MCP_CMD_LEN + 2);
num_resp = cdns_readl(cdns, CDNS_MCP_FIFOSTAT);
num_resp &= CDNS_MCP_RX_FIFO_AVAIL;
if (num_resp > ARRAY_SIZE(cdns->response_buf)) {
dev_warn(cdns->dev, "RX AVAIL %d too long\n", num_resp);
num_resp = ARRAY_SIZE(cdns->response_buf);
}
cmd_base = CDNS_IP_MCP_CMD_BASE;
for (i = 0; i < num_resp; i++) {
cdns->response_buf[i] = cdns_ip_readl(cdns, cmd_base);
cmd_base += CDNS_MCP_CMD_WORD_LEN;
}
}
static enum sdw_command_response
_cdns_xfer_msg(struct sdw_cdns *cdns, struct sdw_msg *msg, int cmd,
int offset, int count, bool defer)
{
unsigned long time;
u32 base, i, data;
u16 addr;
/* Program the watermark level for RX FIFO */
if (cdns->msg_count != count) {
cdns_writel(cdns, CDNS_MCP_FIFOLEVEL, count);
cdns->msg_count = count;
}
base = CDNS_IP_MCP_CMD_BASE;
addr = msg->addr + offset;
for (i = 0; i < count; i++) {
data = FIELD_PREP(CDNS_MCP_CMD_DEV_ADDR, msg->dev_num);
data |= FIELD_PREP(CDNS_MCP_CMD_COMMAND, cmd);
data |= FIELD_PREP(CDNS_MCP_CMD_REG_ADDR, addr);
addr++;
if (msg->flags == SDW_MSG_FLAG_WRITE)
data |= msg->buf[i + offset];
data |= FIELD_PREP(CDNS_MCP_CMD_SSP_TAG, msg->ssp_sync);
cdns_ip_writel(cdns, base, data);
base += CDNS_MCP_CMD_WORD_LEN;
}
if (defer)
return SDW_CMD_OK;
/* wait for timeout or response */
time = wait_for_completion_timeout(&cdns->tx_complete,
msecs_to_jiffies(CDNS_TX_TIMEOUT));
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/crc8.h`, `linux/delay.h`, `linux/device.h`, `linux/debugfs.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `function cdns_readl`, `function cdns_writel`, `function cdns_ip_readl`, `function cdns_ip_writel`, `function cdns_updatel`, `function cdns_ip_updatel`, `function cdns_set_wait`, `function cdns_clear_bit`, `function cdns_config_update`, `function sdw_cdns_config_update`.
- Atlas domain: Driver Families / drivers/soundwire.
- 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.