drivers/soundwire/bus.c
Source file repositories/reference/linux-study-clean/drivers/soundwire/bus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soundwire/bus.c- Extension
.c- Size
- 52581 bytes
- Lines
- 2129
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/delay.hlinux/mod_devicetable.hlinux/pm_runtime.hlinux/soundwire/sdw_registers.hlinux/soundwire/sdw.hlinux/soundwire/sdw_type.hlinux/string_choices.hbus.hirq.hsysfs_local.h
Detected Declarations
function sdw_get_idfunction sdw_bus_master_addfunction sdw_delete_slavefunction sdw_bus_master_deletefunction find_response_codefunction do_transferfunction do_transfer_deferfunction sdw_transfer_unlockedfunction sdw_transferfunction sdw_show_ping_statusfunction sdw_transfer_deferfunction sdw_fill_msgfunction sdw_ntransfer_no_pmfunction sdw_nread_no_pmfunction sdw_nwrite_no_pmfunction sdw_write_no_pmfunction sdw_bread_no_pmfunction sdw_bwrite_no_pmfunction sdw_bread_no_pm_unlockedfunction sdw_bwrite_no_pm_unlockedfunction sdw_read_no_pmfunction sdw_update_no_pmfunction sdw_updatefunction sdw_nreadfunction sdw_nwritefunction sdw_readfunction sdw_writefunction list_for_each_entryfunction sdw_compare_devidfunction sdw_get_device_numfunction sdw_assign_device_numfunction sdw_extract_slave_idfunction is_clock_scaling_supported_by_slavefunction sdw_program_device_numfunction list_for_each_entry_safefunction sdw_modify_slave_statusfunction sdw_slave_clk_stop_callbackfunction sdw_slave_clk_stop_preparefunction sdw_bus_wait_for_clk_prep_deprepfunction sdw_bus_prep_clk_stopfunction Slavefunction sdw_bus_clk_stopfunction sdw_bus_exit_clk_stopfunction Slavefunction list_for_each_entryfunction sdw_configure_dpn_intrfunction sdw_slave_get_scale_indexfunction sdw_slave_get_current_bank
Annotated Snippet
if (ret < 0) {
dev_err(bus->dev,
"Bus read properties failed:%d\n", ret);
return ret;
}
}
sdw_bus_debugfs_init(bus);
/*
* Device numbers in SoundWire are 0 through 15. Enumeration device
* number (0), Broadcast device number (15), Group numbers (12 and
* 13) and Master device number (14) are not used for assignment so
* mask these and other higher bits.
*/
/* Set higher order bits */
*bus->assigned = ~GENMASK(SDW_BROADCAST_DEV_NUM, SDW_ENUM_DEV_NUM);
/* Set enumeration device number and broadcast device number */
set_bit(SDW_ENUM_DEV_NUM, bus->assigned);
set_bit(SDW_BROADCAST_DEV_NUM, bus->assigned);
/* Set group device numbers and master device number */
set_bit(SDW_GROUP12_DEV_NUM, bus->assigned);
set_bit(SDW_GROUP13_DEV_NUM, bus->assigned);
set_bit(SDW_MASTER_DEV_NUM, bus->assigned);
ret = sdw_irq_create(bus, fwnode);
if (ret)
return ret;
/*
* SDW is an enumerable bus, but devices can be powered off. So,
* they won't be able to report as present.
*
* Create Slave devices based on Slaves described in
* the respective firmware (ACPI/DT)
*/
if (IS_ENABLED(CONFIG_ACPI) && ACPI_HANDLE(bus->dev))
ret = sdw_acpi_find_slaves(bus);
else if (IS_ENABLED(CONFIG_OF) && bus->dev->of_node)
ret = sdw_of_find_slaves(bus);
else
ret = -ENOTSUPP; /* No ACPI/DT so error out */
if (ret < 0) {
dev_err(bus->dev, "Finding slaves failed:%d\n", ret);
sdw_irq_delete(bus);
return ret;
}
/*
* Initialize clock values based on Master properties. The max
* frequency is read from max_clk_freq property. Current assumption
* is that the bus will start at highest clock frequency when
* powered on.
*
* Default active bank will be 0 as out of reset the Slaves have
* to start with bank 0 (Table 40 of Spec)
*/
prop = &bus->prop;
bus->params.max_dr_freq = prop->max_clk_freq * SDW_DOUBLE_RATE_FACTOR;
bus->params.curr_dr_freq = bus->params.max_dr_freq;
bus->params.curr_bank = SDW_BANK0;
bus->params.next_bank = SDW_BANK1;
return 0;
}
EXPORT_SYMBOL(sdw_bus_master_add);
static int sdw_delete_slave(struct device *dev, void *data)
{
struct sdw_slave *slave = dev_to_sdw_dev(dev);
struct sdw_bus *bus = slave->bus;
pm_runtime_disable(dev);
sdw_slave_debugfs_exit(slave);
mutex_lock(&bus->bus_lock);
if (slave->dev_num) { /* clear dev_num if assigned */
clear_bit(slave->dev_num, bus->assigned);
if (bus->ops && bus->ops->put_device_num)
bus->ops->put_device_num(bus, slave);
}
list_del_init(&slave->node);
mutex_unlock(&bus->bus_lock);
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/delay.h`, `linux/mod_devicetable.h`, `linux/pm_runtime.h`, `linux/soundwire/sdw_registers.h`, `linux/soundwire/sdw.h`, `linux/soundwire/sdw_type.h`, `linux/string_choices.h`.
- Detected declarations: `function sdw_get_id`, `function sdw_bus_master_add`, `function sdw_delete_slave`, `function sdw_bus_master_delete`, `function find_response_code`, `function do_transfer`, `function do_transfer_defer`, `function sdw_transfer_unlocked`, `function sdw_transfer`, `function sdw_show_ping_status`.
- 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.
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.