drivers/soundwire/amd_manager.c
Source file repositories/reference/linux-study-clean/drivers/soundwire/amd_manager.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soundwire/amd_manager.c- Extension
.c- Size
- 45529 bytes
- Lines
- 1463
- Domain
- Driver Families
- Bucket
- drivers/soundwire
- 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.
- 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/completion.hlinux/cleanup.hlinux/device.hlinux/io.hlinux/jiffies.hlinux/kernel.hlinux/module.hlinux/slab.hlinux/soundwire/sdw.hlinux/soundwire/sdw_registers.hlinux/pm_runtime.hlinux/wait.hsound/pcm_params.hsound/soc.hbus.hamd_init.hamd_manager.h
Detected Declarations
function amd_sdw_clk_init_ctrlfunction amd_init_sdw_managerfunction amd_enable_sdw_managerfunction amd_disable_sdw_managerfunction amd_enable_sdw_interruptsfunction amd_disable_sdw_interruptsfunction amd_deinit_sdw_managerfunction amd_sdw_set_frameshapefunction amd_sdw_wake_enablefunction amd_sdw_set_device_statefunction amd_sdw_host_wake_enablefunction amd_sdw_ctl_word_prepfunction amd_sdw_send_cmd_get_respfunction amd_program_scp_addrfunction amd_prep_msgfunction amd_sdw_fill_msg_respfunction _amd_sdw_xfer_msgfunction amd_sdw_xfer_msgfunction amd_sdw_fill_slave_statusfunction amd_sdw_process_ping_statusfunction amd_sdw_read_and_process_ping_statusfunction amd_sdw_read_ping_statusfunction amd_sdw_compute_paramsfunction list_for_each_entryfunction list_for_each_entryfunction amd_sdw_port_paramsfunction amd_sdw_transport_paramsfunction amd_sdw_port_enablefunction sdw_master_read_amd_propfunction amd_prop_readfunction amd_sdw_hw_paramsfunction amd_sdw_hw_freefunction amd_set_sdw_streamfunction amd_pcm_set_sdw_streamfunction amd_sdw_register_daisfunction amd_sdw_update_slave_status_workfunction amd_sdw_update_slave_statusfunction amd_sdw_process_wake_eventfunction amd_sdw_irq_threadfunction amd_sdw_manager_startfunction amd_sdw_manager_probefunction amd_sdw_manager_removefunction amd_sdw_clock_stopfunction amd_sdw_clock_stop_exitfunction amd_resume_child_devicefunction amd_pm_preparefunction amd_suspendfunction amd_suspend_runtime
Annotated Snippet
if (response_buf[index] == -ETIMEDOUT) {
dev_err_ratelimited(amd_manager->dev,
"SCP_addrpage command timeout for Slave %d\n",
msg->dev_num);
return SDW_CMD_TIMEOUT;
} else if (!(response_buf[index] & AMD_SDW_MCP_RESP_ACK)) {
if (response_buf[index] & AMD_SDW_MCP_RESP_NACK) {
dev_err_ratelimited(amd_manager->dev,
"SCP_addrpage NACKed for Slave %d\n",
msg->dev_num);
return SDW_CMD_FAIL;
}
dev_dbg_ratelimited(amd_manager->dev, "SCP_addrpage ignored for Slave %d\n",
msg->dev_num);
return SDW_CMD_IGNORED;
}
}
return SDW_CMD_OK;
}
static int amd_prep_msg(struct amd_sdw_manager *amd_manager, struct sdw_msg *msg)
{
int ret;
if (msg->page) {
ret = amd_program_scp_addr(amd_manager, msg);
if (ret) {
msg->len = 0;
return ret;
}
}
switch (msg->flags) {
case SDW_MSG_FLAG_READ:
case SDW_MSG_FLAG_WRITE:
break;
default:
dev_err(amd_manager->dev, "Invalid msg cmd: %d\n", msg->flags);
return -EINVAL;
}
return 0;
}
static enum sdw_command_response amd_sdw_fill_msg_resp(struct amd_sdw_manager *amd_manager,
struct sdw_msg *msg, u64 response,
int offset)
{
if (response & AMD_SDW_MCP_RESP_ACK) {
if (msg->flags == SDW_MSG_FLAG_READ)
msg->buf[offset] = FIELD_GET(AMD_SDW_MCP_RESP_RDATA, response);
} else {
if (response == -ETIMEDOUT) {
dev_err_ratelimited(amd_manager->dev, "command timeout for Slave %d\n",
msg->dev_num);
return SDW_CMD_TIMEOUT;
} else if (response & AMD_SDW_MCP_RESP_NACK) {
dev_err_ratelimited(amd_manager->dev,
"command response NACK received for Slave %d\n",
msg->dev_num);
return SDW_CMD_FAIL;
}
dev_dbg_ratelimited(amd_manager->dev, "command is ignored for Slave %d\n",
msg->dev_num);
return SDW_CMD_IGNORED;
}
return SDW_CMD_OK;
}
static unsigned int _amd_sdw_xfer_msg(struct amd_sdw_manager *amd_manager, struct sdw_msg *msg,
int cmd_offset)
{
u64 response;
u32 upper_data = 0, lower_data = 0;
amd_sdw_ctl_word_prep(&lower_data, &upper_data, msg, cmd_offset);
response = amd_sdw_send_cmd_get_resp(amd_manager, lower_data, upper_data);
return amd_sdw_fill_msg_resp(amd_manager, msg, response, cmd_offset);
}
static enum sdw_command_response amd_sdw_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg)
{
struct amd_sdw_manager *amd_manager = to_amd_sdw(bus);
int ret, i;
ret = amd_prep_msg(amd_manager, msg);
if (ret)
return SDW_CMD_FAIL_OTHER;
for (i = 0; i < msg->len; i++) {
ret = _amd_sdw_xfer_msg(amd_manager, msg, i);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/completion.h`, `linux/cleanup.h`, `linux/device.h`, `linux/io.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/module.h`, `linux/slab.h`.
- Detected declarations: `function amd_sdw_clk_init_ctrl`, `function amd_init_sdw_manager`, `function amd_enable_sdw_manager`, `function amd_disable_sdw_manager`, `function amd_enable_sdw_interrupts`, `function amd_disable_sdw_interrupts`, `function amd_deinit_sdw_manager`, `function amd_sdw_set_frameshape`, `function amd_sdw_wake_enable`, `function amd_sdw_set_device_state`.
- Atlas domain: Driver Families / drivers/soundwire.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.