diff options
| author | Bard Liao <yung-chuan.liao@linux.intel.com> | 2024-12-18 16:01:48 +0800 |
|---|---|---|
| committer | Vinod Koul <vkoul@kernel.org> | 2024-12-23 12:00:33 +0530 |
| commit | 645291cfe5e52cce9571d73542476bec1d79ce26 (patch) | |
| tree | c69001d4de4c38ea5905caa882705fd95cb000e2 /drivers/soundwire/stream.c | |
| parent | 8f4e3343eda8cdedaf711bf3d8ef2d6ed571f420 (diff) | |
Soundwire: stream: program BUSCLOCK_SCALE
We need to program bus clock scale to adjust the bus clock if current
bus clock doesn't fit the bandwidth.
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20241218080155.102405-8-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/soundwire/stream.c')
| -rw-r--r-- | drivers/soundwire/stream.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index 795017c8081a..bf04b941012c 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -629,8 +629,44 @@ static int sdw_notify_config(struct sdw_master_runtime *m_rt) static int sdw_program_params(struct sdw_bus *bus, bool prepare) { struct sdw_master_runtime *m_rt; + struct sdw_slave *slave; int ret = 0; + u32 addr1; + + /* Check if all Peripherals comply with SDCA */ + list_for_each_entry(slave, &bus->slaves, node) { + if (!slave->dev_num_sticky) + continue; + if (!is_clock_scaling_supported_by_slave(slave)) { + dev_dbg(&slave->dev, "The Peripheral doesn't comply with SDCA\n"); + goto manager_runtime; + } + } + + if (bus->params.next_bank) + addr1 = SDW_SCP_BUSCLOCK_SCALE_B1; + else + addr1 = SDW_SCP_BUSCLOCK_SCALE_B0; + + /* Program SDW_SCP_BUSCLOCK_SCALE if all Peripherals comply with SDCA */ + list_for_each_entry(slave, &bus->slaves, node) { + int scale_index; + u8 base; + + if (!slave->dev_num_sticky) + continue; + scale_index = sdw_slave_get_scale_index(slave, &base); + if (scale_index < 0) + return scale_index; + + ret = sdw_write_no_pm(slave, addr1, scale_index); + if (ret < 0) { + dev_err(&slave->dev, "SDW_SCP_BUSCLOCK_SCALE register write failed\n"); + return ret; + } + } +manager_runtime: list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { /* |
