Skip to content

Commit a00b799

Browse files
committed
SoundWire: Allow Prepare command for Simplified_CP_SM
As defined in the MIPI SoundWire specification v1-2 for Simplified Channel Prepare State Machine (Simplified_CP_SM): * Figure 141 for the Simplified_CP_SM in the specification shows the "Ready" state (NF=0, P=1) that can be reached via "Prepare0 OR Prepare1" transitions. * Table 115 (Stimulus to the Channel Prepare State Machine) indicates that Prepare0 and Prepare1 are read-only/"write-ignored" bits for Simplified_CP_SM. In TI device implementations, we've found that some devices with Simplified_CP_SM still benefit from receiving the Prepare command. This patch modifies the code to: 1. Send the Prepare command to all devices, including those with Simplified_CP_SM 2. Ignore errors returned by devices with Simplified_CP_SM that might not support this command This approach maintains compatibility with all devices while ensuring proper functionality of dataport operations for devices that can make use of the Prepare command despite using Simplified_CP_SM. Signed-off-by: Niranjan H Y <niranjan.hy@ti.com>
1 parent 65fd664 commit a00b799

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

drivers/soundwire/stream.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -512,14 +512,19 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
512512
sdw_do_port_prep(s_rt, prep_ch, prep ? SDW_OPS_PORT_PRE_PREP : SDW_OPS_PORT_PRE_DEPREP);
513513

514514
/* Prepare Slave port implementing CP_SM */
515-
if (!simple_ch_prep_sm) {
516-
addr = SDW_DPN_PREPARECTRL(p_rt->num);
517-
518-
if (prep)
519-
ret = sdw_write_no_pm(s_rt->slave, addr, p_rt->ch_mask);
520-
else
521-
ret = sdw_write_no_pm(s_rt->slave, addr, 0x0);
515+
/* For Simplified_CP_SM, MIPI SoundWire specification v1-2 indicates
516+
* Prepare bits are "write-ignored" - this means devices may ignore the command.
517+
* Some devices still benefit from receiving this command even when using
518+
* Simplified_CP_SM, so we send it to all devices and ignore errors from those
519+
* that don't support it.
520+
*/
521+
addr = SDW_DPN_PREPARECTRL(p_rt->num);
522+
if (prep)
523+
ret = sdw_write_no_pm(s_rt->slave, addr, p_rt->ch_mask);
524+
else
525+
ret = sdw_write_no_pm(s_rt->slave, addr, 0x0);
522526

527+
if (!simple_ch_prep_sm) {
523528
if (ret < 0) {
524529
dev_err(&s_rt->slave->dev,
525530
"Slave prep_ctrl reg write failed\n");
@@ -538,6 +543,11 @@ static int sdw_prep_deprep_slave_ports(struct sdw_bus *bus,
538543
"Chn prep failed for port %d: %d\n", prep_ch.num, ret);
539544
return ret;
540545
}
546+
} else {
547+
/* Some device return error for the prepare command,
548+
* ignore the error for Simplified CP_SM
549+
*/
550+
ret = 0;
541551
}
542552

543553
/* Inform slaves about ports prepared */

0 commit comments

Comments
 (0)