Skip to content

Commit 71b405b

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: mipi-disco: add support for DP0/DPn 'lane-list' property
The SoundWire specification did not clearly require that ports could use all Lanes. Some SoundWire/SDCA peripheral adopters added restrictions on which lanes can be used by what port, and the DisCo for SoundWire 2.1 specification added a 'lane-list' property to model this hardware limitation. When not specified, the ports can use all Lanes. Otherwise, the 'lane-list' indicates which Lanes can be used, sorted by order of preference (most-preferred-first). This patch only reads the properties, the use of this property will come at a later time with multi-lane support. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20241003070650.62787-15-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 543bd28 commit 71b405b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

drivers/soundwire/mipi_disco.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,22 @@ static int sdw_slave_read_dp0(struct sdw_slave *slave,
197197
dp0->imp_def_interrupts = mipi_fwnode_property_read_bool(port,
198198
"mipi-sdw-imp-def-dp0-interrupts-supported");
199199

200+
nval = fwnode_property_count_u32(port, "mipi-sdw-lane-list");
201+
if (nval > 0) {
202+
dp0->num_lanes = nval;
203+
dp0->lane_list = devm_kcalloc(&slave->dev,
204+
dp0->num_lanes, sizeof(*dp0->lane_list),
205+
GFP_KERNEL);
206+
if (!dp0->lane_list)
207+
return -ENOMEM;
208+
209+
ret = fwnode_property_read_u32_array(port,
210+
"mipi-sdw-lane-list",
211+
dp0->lane_list, dp0->num_lanes);
212+
if (ret < 0)
213+
return ret;
214+
}
215+
200216
return 0;
201217
}
202218

@@ -326,6 +342,22 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
326342
fwnode_property_read_u32(node, "mipi-sdw-port-encoding-type",
327343
&dpn[i].port_encoding);
328344

345+
nval = fwnode_property_count_u32(node, "mipi-sdw-lane-list");
346+
if (nval > 0) {
347+
dpn[i].num_lanes = nval;
348+
dpn[i].lane_list = devm_kcalloc(&slave->dev,
349+
dpn[i].num_lanes, sizeof(*dpn[i].lane_list),
350+
GFP_KERNEL);
351+
if (!dpn[i].lane_list)
352+
return -ENOMEM;
353+
354+
ret = fwnode_property_read_u32_array(node,
355+
"mipi-sdw-lane-list",
356+
dpn[i].lane_list, dpn[i].num_lanes);
357+
if (ret < 0)
358+
return ret;
359+
}
360+
329361
fwnode_handle_put(node);
330362

331363
i++;

include/linux/soundwire/sdw.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ enum sdw_clk_stop_mode {
238238
* @simple_ch_prep_sm: If channel prepare sequence is required
239239
* @imp_def_interrupts: If set, each bit corresponds to support for
240240
* implementation-defined interrupts
241+
* @num_lanes: array size of @lane_list
242+
* @lane_list: indicates which Lanes can be used by DP0
241243
*
242244
* The wordlengths are specified by Spec as max, min AND number of
243245
* discrete values, implementation can define based on the wordlengths they
@@ -252,6 +254,8 @@ struct sdw_dp0_prop {
252254
bool BRA_flow_controlled;
253255
bool simple_ch_prep_sm;
254256
bool imp_def_interrupts;
257+
int num_lanes;
258+
u32 *lane_list;
255259
};
256260

257261
/**
@@ -275,6 +279,8 @@ struct sdw_dp0_prop {
275279
* @num_ch_combinations: Number of channel combinations supported
276280
* @channels: Discrete channels supported
277281
* @ch_combinations: Channel combinations supported
282+
* @lane_list: indicates which Lanes can be used by DPn
283+
* @num_lanes: array size of @lane_list
278284
* @modes: SDW mode supported
279285
* @max_async_buffer: Number of samples that this port can buffer in
280286
* asynchronous modes
@@ -300,6 +306,8 @@ struct sdw_dpn_prop {
300306
u32 num_ch_combinations;
301307
u32 *channels;
302308
u32 *ch_combinations;
309+
u32 *lane_list;
310+
int num_lanes;
303311
u32 modes;
304312
u32 max_async_buffer;
305313
u32 port_encoding;

0 commit comments

Comments
 (0)