From 86a0798c1fb7424eec47ee7d8e06b215d7e3b6c6 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Wed, 28 Aug 2024 20:42:05 +0800 Subject: [PATCH] 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 --- drivers/soundwire/stream.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index 935499f11a7829..109326a12e80d2 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -637,8 +637,32 @@ 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; + list_for_each_entry(slave, &bus->slaves, node) { + u32 scale_index; + u32 addr1; + u8 base; + + scale_index = sdw_slave_get_scale_index(slave, &base); + if (scale_index < 0) + return scale_index; + + if (bus->params.next_bank) { + addr1 = SDW_SCP_BUSCLOCK_SCALE_B1; + } else { + addr1 = SDW_SCP_BUSCLOCK_SCALE_B0; + } + /* Program SDW_SCP_BUSCLOCK_SCALE */ + ret = sdw_write_no_pm(slave, addr1, scale_index); + if (ret < 0) { + dev_err(bus->dev, "SDW_SCP_BUSCLOCK_SCALE register write failed\n"); + return ret; + } + } + + list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { /*