Skip to content

Commit 4d5d604

Browse files
committed
Merge tag 'soundwire-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire
Pull soundwire updates from Vinod Koul: - Core: add concept of controller_id to deal with clear Controller / Manager hierarchy - bunch of qcom driver refactoring for qcom_swrm_stream_alloc_ports(), qcom_swrm_stream_alloc_ports() and setting controller id to hw master id * tag 'soundwire-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire: soundwire: amd: drop bus freq calculation and set 'max_clk_freq' soundwire: generic_bandwidth_allocation use bus->params.max_dr_freq soundwire: qcom: set controller id to hw master id soundwire: fix initializing sysfs for same devices on different buses soundwire: bus: introduce controller_id soundwire: stream: constify sdw_port_config when adding devices soundwire: qcom: move sconfig in qcom_swrm_stream_alloc_ports() out of critical section soundwire: qcom: drop unneeded qcom_swrm_stream_alloc_ports() cleanup
2 parents 3455135 + becfce5 commit 4d5d604

File tree

11 files changed

+62
-44
lines changed

11 files changed

+62
-44
lines changed

drivers/soundwire/amd_manager.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,14 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
927927
amd_manager->bus.clk_stop_timeout = 200;
928928
amd_manager->bus.link_id = amd_manager->instance;
929929

930+
/*
931+
* Due to BIOS compatibility, the two links are exposed within
932+
* the scope of a single controller. If this changes, the
933+
* controller_id will have to be updated with drv_data
934+
* information.
935+
*/
936+
amd_manager->bus.controller_id = 0;
937+
930938
switch (amd_manager->instance) {
931939
case ACP_SDW0:
932940
amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS;
@@ -942,13 +950,13 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
942950

943951
amd_manager->reg_mask = &sdw_manager_reg_mask_array[amd_manager->instance];
944952
params = &amd_manager->bus.params;
945-
params->max_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2;
946-
params->curr_dr_freq = AMD_SDW_DEFAULT_CLK_FREQ * 2;
953+
947954
params->col = AMD_SDW_DEFAULT_COLUMNS;
948955
params->row = AMD_SDW_DEFAULT_ROWS;
949956
prop = &amd_manager->bus.prop;
950957
prop->clk_freq = &amd_sdw_freq_tbl[0];
951958
prop->mclk_freq = AMD_SDW_BUS_BASE_FREQ;
959+
prop->max_clk_freq = AMD_SDW_DEFAULT_CLK_FREQ;
952960

953961
ret = sdw_bus_master_add(&amd_manager->bus, dev, dev->fwnode);
954962
if (ret) {

drivers/soundwire/bus.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ static int sdw_get_id(struct sdw_bus *bus)
2222
return rc;
2323

2424
bus->id = rc;
25+
26+
if (bus->controller_id == -1)
27+
bus->controller_id = rc;
28+
2529
return 0;
2630
}
2731

drivers/soundwire/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void sdw_bus_debugfs_init(struct sdw_bus *bus)
2020
return;
2121

2222
/* create the debugfs master-N */
23-
snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id);
23+
snprintf(name, sizeof(name), "master-%d-%d", bus->controller_id, bus->link_id);
2424
bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root);
2525
}
2626

drivers/soundwire/generic_bandwidth_allocation.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static int sdw_select_row_col(struct sdw_bus *bus, int clk_freq)
333333
*/
334334
static int sdw_compute_bus_params(struct sdw_bus *bus)
335335
{
336-
unsigned int max_dr_freq, curr_dr_freq = 0;
336+
unsigned int curr_dr_freq = 0;
337337
struct sdw_master_prop *mstr_prop = &bus->prop;
338338
int i, clk_values, ret;
339339
bool is_gear = false;
@@ -351,14 +351,12 @@ static int sdw_compute_bus_params(struct sdw_bus *bus)
351351
clk_buf = NULL;
352352
}
353353

354-
max_dr_freq = mstr_prop->max_clk_freq * SDW_DOUBLE_RATE_FACTOR;
355-
356354
for (i = 0; i < clk_values; i++) {
357355
if (!clk_buf)
358-
curr_dr_freq = max_dr_freq;
356+
curr_dr_freq = bus->params.max_dr_freq;
359357
else
360358
curr_dr_freq = (is_gear) ?
361-
(max_dr_freq >> clk_buf[i]) :
359+
(bus->params.max_dr_freq >> clk_buf[i]) :
362360
clk_buf[i] * SDW_DOUBLE_RATE_FACTOR;
363361

364362
if (curr_dr_freq <= bus->params.bandwidth)

drivers/soundwire/intel_auxdevice.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
234234
cdns->instance = sdw->instance;
235235
cdns->msg_count = 0;
236236

237+
/* single controller for all SoundWire links */
238+
bus->controller_id = 0;
239+
237240
bus->link_id = auxdev->id;
238241
bus->clk_stop_timeout = 1;
239242

drivers/soundwire/master.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
145145
md->dev.fwnode = fwnode;
146146
md->dev.dma_mask = parent->dma_mask;
147147

148-
dev_set_name(&md->dev, "sdw-master-%d", bus->id);
148+
dev_set_name(&md->dev, "sdw-master-%d-%d", bus->controller_id, bus->link_id);
149149

150150
ret = device_register(&md->dev);
151151
if (ret) {

drivers/soundwire/qcom.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,9 +1157,20 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
11571157
struct sdw_port_runtime *p_rt;
11581158
struct sdw_slave *slave;
11591159
unsigned long *port_mask;
1160-
int i, maxport, pn, nports = 0, ret = 0;
1160+
int maxport, pn, nports = 0, ret = 0;
11611161
unsigned int m_port;
11621162

1163+
if (direction == SNDRV_PCM_STREAM_CAPTURE)
1164+
sconfig.direction = SDW_DATA_DIR_TX;
1165+
else
1166+
sconfig.direction = SDW_DATA_DIR_RX;
1167+
1168+
/* hw parameters wil be ignored as we only support PDM */
1169+
sconfig.ch_count = 1;
1170+
sconfig.frame_rate = params_rate(params);
1171+
sconfig.type = stream->type;
1172+
sconfig.bps = 1;
1173+
11631174
mutex_lock(&ctrl->port_lock);
11641175
list_for_each_entry(m_rt, &stream->master_list, stream_node) {
11651176
if (m_rt->direction == SDW_DATA_DIR_RX) {
@@ -1183,7 +1194,7 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
11831194
if (pn > maxport) {
11841195
dev_err(ctrl->dev, "All ports busy\n");
11851196
ret = -EBUSY;
1186-
goto err;
1197+
goto out;
11871198
}
11881199
set_bit(pn, port_mask);
11891200
pconfig[nports].num = pn;
@@ -1193,24 +1204,9 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
11931204
}
11941205
}
11951206

1196-
if (direction == SNDRV_PCM_STREAM_CAPTURE)
1197-
sconfig.direction = SDW_DATA_DIR_TX;
1198-
else
1199-
sconfig.direction = SDW_DATA_DIR_RX;
1200-
1201-
/* hw parameters wil be ignored as we only support PDM */
1202-
sconfig.ch_count = 1;
1203-
sconfig.frame_rate = params_rate(params);
1204-
sconfig.type = stream->type;
1205-
sconfig.bps = 1;
12061207
sdw_stream_add_master(&ctrl->bus, &sconfig, pconfig,
12071208
nports, stream);
1208-
err:
1209-
if (ret) {
1210-
for (i = 0; i < nports; i++)
1211-
clear_bit(pconfig[i].num, port_mask);
1212-
}
1213-
1209+
out:
12141210
mutex_unlock(&ctrl->port_lock);
12151211

12161212
return ret;
@@ -1593,6 +1589,13 @@ static int qcom_swrm_probe(struct platform_device *pdev)
15931589
}
15941590
}
15951591

1592+
ctrl->bus.controller_id = -1;
1593+
1594+
if (ctrl->version > SWRM_VERSION_1_3_0) {
1595+
ctrl->reg_read(ctrl, SWRM_COMP_MASTER_ID, &val);
1596+
ctrl->bus.controller_id = val;
1597+
}
1598+
15961599
ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode);
15971600
if (ret) {
15981601
dev_err(dev, "Failed to register Soundwire controller (%d)\n",

drivers/soundwire/slave.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ int sdw_slave_add(struct sdw_bus *bus,
3939
slave->dev.fwnode = fwnode;
4040

4141
if (id->unique_id == SDW_IGNORED_UNIQUE_ID) {
42-
/* name shall be sdw:link:mfg:part:class */
43-
dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x",
44-
bus->link_id, id->mfg_id, id->part_id,
42+
/* name shall be sdw:ctrl:link:mfg:part:class */
43+
dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x",
44+
bus->controller_id, bus->link_id, id->mfg_id, id->part_id,
4545
id->class_id);
4646
} else {
47-
/* name shall be sdw:link:mfg:part:class:unique */
48-
dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x:%01x",
49-
bus->link_id, id->mfg_id, id->part_id,
47+
/* name shall be sdw:ctrl:link:mfg:part:class:unique */
48+
dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x:%01x",
49+
bus->controller_id, bus->link_id, id->mfg_id, id->part_id,
5050
id->class_id, id->unique_id);
5151
}
5252

drivers/soundwire/stream.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ static struct sdw_port_runtime *sdw_port_alloc(struct list_head *port_list)
898898
}
899899

900900
static int sdw_port_config(struct sdw_port_runtime *p_rt,
901-
struct sdw_port_config *port_config,
901+
const struct sdw_port_config *port_config,
902902
int port_index)
903903
{
904904
p_rt->ch_mask = port_config[port_index].ch_mask;
@@ -971,7 +971,7 @@ static int sdw_slave_port_is_valid_range(struct device *dev, int num)
971971

972972
static int sdw_slave_port_config(struct sdw_slave *slave,
973973
struct sdw_slave_runtime *s_rt,
974-
struct sdw_port_config *port_config)
974+
const struct sdw_port_config *port_config)
975975
{
976976
struct sdw_port_runtime *p_rt;
977977
int ret;
@@ -1027,7 +1027,7 @@ static int sdw_master_port_alloc(struct sdw_master_runtime *m_rt,
10271027
}
10281028

10291029
static int sdw_master_port_config(struct sdw_master_runtime *m_rt,
1030-
struct sdw_port_config *port_config)
1030+
const struct sdw_port_config *port_config)
10311031
{
10321032
struct sdw_port_runtime *p_rt;
10331033
int ret;
@@ -1862,7 +1862,7 @@ EXPORT_SYMBOL(sdw_release_stream);
18621862
*/
18631863
int sdw_stream_add_master(struct sdw_bus *bus,
18641864
struct sdw_stream_config *stream_config,
1865-
struct sdw_port_config *port_config,
1865+
const struct sdw_port_config *port_config,
18661866
unsigned int num_ports,
18671867
struct sdw_stream_runtime *stream)
18681868
{
@@ -1982,7 +1982,7 @@ EXPORT_SYMBOL(sdw_stream_remove_master);
19821982
*/
19831983
int sdw_stream_add_slave(struct sdw_slave *slave,
19841984
struct sdw_stream_config *stream_config,
1985-
struct sdw_port_config *port_config,
1985+
const struct sdw_port_config *port_config,
19861986
unsigned int num_ports,
19871987
struct sdw_stream_runtime *stream)
19881988
{

include/linux/soundwire/sdw.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,8 @@ struct sdw_master_ops {
886886
* struct sdw_bus - SoundWire bus
887887
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
888888
* @md: Master device
889-
* @link_id: Link id number, can be 0 to N, unique for each Master
889+
* @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
890+
* @link_id: Link id number, can be 0 to N, unique for each Controller
890891
* @id: bus system-wide unique id
891892
* @slaves: list of Slaves on this bus
892893
* @assigned: Bitmap for Slave device numbers.
@@ -918,6 +919,7 @@ struct sdw_master_ops {
918919
struct sdw_bus {
919920
struct device *dev;
920921
struct sdw_master_device *md;
922+
int controller_id;
921923
unsigned int link_id;
922924
int id;
923925
struct list_head slaves;
@@ -1040,7 +1042,7 @@ int sdw_compute_params(struct sdw_bus *bus);
10401042

10411043
int sdw_stream_add_master(struct sdw_bus *bus,
10421044
struct sdw_stream_config *stream_config,
1043-
struct sdw_port_config *port_config,
1045+
const struct sdw_port_config *port_config,
10441046
unsigned int num_ports,
10451047
struct sdw_stream_runtime *stream);
10461048
int sdw_stream_remove_master(struct sdw_bus *bus,
@@ -1062,7 +1064,7 @@ void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id
10621064

10631065
int sdw_stream_add_slave(struct sdw_slave *slave,
10641066
struct sdw_stream_config *stream_config,
1065-
struct sdw_port_config *port_config,
1067+
const struct sdw_port_config *port_config,
10661068
unsigned int num_ports,
10671069
struct sdw_stream_runtime *stream);
10681070
int sdw_stream_remove_slave(struct sdw_slave *slave,
@@ -1084,7 +1086,7 @@ int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u8 val);
10841086

10851087
static inline int sdw_stream_add_slave(struct sdw_slave *slave,
10861088
struct sdw_stream_config *stream_config,
1087-
struct sdw_port_config *port_config,
1089+
const struct sdw_port_config *port_config,
10881090
unsigned int num_ports,
10891091
struct sdw_stream_runtime *stream)
10901092
{

0 commit comments

Comments
 (0)