Skip to content

Commit 7533d0d

Browse files
bardliaovinodkoul
authored andcommitted
soundwire: mipi_disco: read lane mapping properties from ACPI
The DisCo for SoundWire 2.0 added support for the 'mipi-sdw-lane-<n>-mapping' property. Co-developed-by: Chao Song <chao.song@linux.intel.com> Signed-off-by: Chao Song <chao.song@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20241218080155.102405-3-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 6bba2d3 commit 7533d0d

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

drivers/soundwire/mipi_disco.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,44 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
366366
return 0;
367367
}
368368

369+
/*
370+
* In MIPI DisCo spec for SoundWire, lane mapping for a slave device is done with
371+
* mipi-sdw-lane-x-mapping properties, where x is 1..7, and the values for those
372+
* properties are mipi-sdw-manager-lane-x or mipi-sdw-peripheral-link-y, where x
373+
* is an integer between 1 to 7 if the lane is connected to a manager lane, y is a
374+
* character between A to E if the lane is connected to another peripheral lane.
375+
*/
376+
int sdw_slave_read_lane_mapping(struct sdw_slave *slave)
377+
{
378+
struct sdw_slave_prop *prop = &slave->prop;
379+
struct device *dev = &slave->dev;
380+
char prop_name[30];
381+
const char *prop_val;
382+
size_t len;
383+
int ret, i;
384+
u8 lane;
385+
386+
for (i = 0; i < SDW_MAX_LANES; i++) {
387+
snprintf(prop_name, sizeof(prop_name), "mipi-sdw-lane-%d-mapping", i);
388+
ret = device_property_read_string(dev, prop_name, &prop_val);
389+
if (ret)
390+
continue;
391+
392+
len = strlen(prop_val);
393+
if (len < 1)
394+
return -EINVAL;
395+
396+
/* The last character is enough to identify the connection */
397+
ret = kstrtou8(&prop_val[len - 1], 10, &lane);
398+
if (ret)
399+
return ret;
400+
if (in_range(lane, 1, SDW_MAX_LANES - 1))
401+
prop->lane_maps[i] = lane;
402+
}
403+
return 0;
404+
}
405+
EXPORT_SYMBOL(sdw_slave_read_lane_mapping);
406+
369407
/**
370408
* sdw_slave_read_prop() - Read Slave properties
371409
* @slave: SDW Slave
@@ -486,6 +524,6 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
486524
sdw_slave_read_dpn(slave, prop->sink_dpn_prop, nval,
487525
prop->sink_ports, "sink");
488526

489-
return 0;
527+
return sdw_slave_read_lane_mapping(slave);
490528
}
491529
EXPORT_SYMBOL(sdw_slave_read_prop);

include/linux/soundwire/sdw.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ struct sdw_slave;
5454
#define SDW_MAX_PORTS 15
5555
#define SDW_VALID_PORT_RANGE(n) ((n) < SDW_MAX_PORTS && (n) >= 1)
5656

57+
#define SDW_MAX_LANES 8
58+
5759
enum {
5860
SDW_PORT_DIRN_SINK = 0,
5961
SDW_PORT_DIRN_SOURCE,
@@ -356,6 +358,7 @@ struct sdw_dpn_prop {
356358
* and masks are supported
357359
* @commit_register_supported: is PCP_Commit register supported
358360
* @scp_int1_mask: SCP_INT1_MASK desired settings
361+
* @lane_maps: Lane mapping for the slave, only valid if lane_control_support is set
359362
* @clock_reg_supported: the Peripheral implements the clock base and scale
360363
* registers introduced with the SoundWire 1.2 specification. SDCA devices
361364
* do not need to set this boolean property as the registers are required.
@@ -385,6 +388,7 @@ struct sdw_slave_prop {
385388
u32 sdca_interrupt_register_list;
386389
u8 commit_register_supported;
387390
u8 scp_int1_mask;
391+
u8 lane_maps[SDW_MAX_LANES];
388392
bool clock_reg_supported;
389393
bool use_domain_irq;
390394
};
@@ -450,6 +454,7 @@ struct sdw_master_prop {
450454

451455
int sdw_master_read_prop(struct sdw_bus *bus);
452456
int sdw_slave_read_prop(struct sdw_slave *slave);
457+
int sdw_slave_read_lane_mapping(struct sdw_slave *slave);
453458

454459
/*
455460
* SDW Slave Structures and APIs

0 commit comments

Comments
 (0)