Skip to content

Commit 093227b

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: mipi_disco: add MIPI-specific property_read_bool() helpers
The existing device/fwnode_property_read_bool() helpers only check if the property is present. The MIPI DisCo for SoundWire specification allows properties to be exposed with a value of 'false'. Using the standard helpers to retrieve the MIPI-defined properties causes all kinds of logical inversions leading to loss of functionality - such as jack detection in clock-stop mode broken when the device properties are read in Realtek codec drivers. This patch adds new MIPI/SoundWire helpers which first check if the property is present, and then return the actual value extracted from platform firmware. Modifying the default property handling was considered as a possible solution, but it could lead to other types of logical inversions breaking 'working' setups. Andy Shevchenko also pointed out that DT keeps values in the BE32 format, it's probably best to avoid endianness complications. The path of least resistance was chosen, with MIPI-specific helpers which can be tested and with no side effects outside of the SoundWire subsystem. Closes: thesofproject#5129 Signed-off-by: Pierre-Louis Bossart <[email protected]> Signed-off-by: Bard Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent a54dc8c commit 093227b

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

drivers/soundwire/mipi_disco.c

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,26 @@
2323
#include <linux/soundwire/sdw.h>
2424
#include "bus.h"
2525

26+
static bool mipi_fwnode_property_read_bool(const struct fwnode_handle *fwnode,
27+
const char *propname)
28+
{
29+
int ret;
30+
u8 val;
31+
32+
if (!fwnode_property_present(fwnode, propname))
33+
return false;
34+
ret = fwnode_property_read_u8_array(fwnode, propname, &val, 1);
35+
if (ret < 0)
36+
return false;
37+
return !!val;
38+
}
39+
40+
static bool mipi_device_property_read_bool(const struct device *dev,
41+
const char *propname)
42+
{
43+
return mipi_fwnode_property_read_bool(dev_fwnode(dev), propname);
44+
}
45+
2646
/**
2747
* sdw_master_read_prop() - Read Master properties
2848
* @bus: SDW bus instance
@@ -48,11 +68,11 @@ int sdw_master_read_prop(struct sdw_bus *bus)
4868
return -EIO;
4969
}
5070

51-
if (fwnode_property_read_bool(link,
71+
if (mipi_fwnode_property_read_bool(link,
5272
"mipi-sdw-clock-stop-mode0-supported"))
5373
prop->clk_stop_modes |= BIT(SDW_CLK_STOP_MODE0);
5474

55-
if (fwnode_property_read_bool(link,
75+
if (mipi_fwnode_property_read_bool(link,
5676
"mipi-sdw-clock-stop-mode1-supported"))
5777
prop->clk_stop_modes |= BIT(SDW_CLK_STOP_MODE1);
5878

@@ -114,7 +134,7 @@ int sdw_master_read_prop(struct sdw_bus *bus)
114134
fwnode_property_read_u32(link, "mipi-sdw-default-frame-col-size",
115135
&prop->default_col);
116136

117-
prop->dynamic_frame = fwnode_property_read_bool(link,
137+
prop->dynamic_frame = mipi_fwnode_property_read_bool(link,
118138
"mipi-sdw-dynamic-frame-shape");
119139

120140
fwnode_property_read_u32(link, "mipi-sdw-command-error-threshold",
@@ -153,13 +173,13 @@ static int sdw_slave_read_dp0(struct sdw_slave *slave,
153173
dp0->words, dp0->num_words);
154174
}
155175

156-
dp0->BRA_flow_controlled = fwnode_property_read_bool(port,
176+
dp0->BRA_flow_controlled = mipi_fwnode_property_read_bool(port,
157177
"mipi-sdw-bra-flow-controlled");
158178

159-
dp0->simple_ch_prep_sm = fwnode_property_read_bool(port,
179+
dp0->simple_ch_prep_sm = mipi_fwnode_property_read_bool(port,
160180
"mipi-sdw-simplified-channel-prepare-sm");
161181

162-
dp0->imp_def_interrupts = fwnode_property_read_bool(port,
182+
dp0->imp_def_interrupts = mipi_fwnode_property_read_bool(port,
163183
"mipi-sdw-imp-def-dp0-interrupts-supported");
164184

165185
return 0;
@@ -220,7 +240,7 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
220240
"mipi-sdw-max-grouping-supported",
221241
&dpn[i].max_grouping);
222242

223-
dpn[i].simple_ch_prep_sm = fwnode_property_read_bool(node,
243+
dpn[i].simple_ch_prep_sm = mipi_fwnode_property_read_bool(node,
224244
"mipi-sdw-simplified-channelprepare-sm");
225245

226246
fwnode_property_read_u32(node,
@@ -278,7 +298,7 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
278298
fwnode_property_read_u32(node, "mipi-sdw-max-async-buffer",
279299
&dpn[i].max_async_buffer);
280300

281-
dpn[i].block_pack_mode = fwnode_property_read_bool(node,
301+
dpn[i].block_pack_mode = mipi_fwnode_property_read_bool(node,
282302
"mipi-sdw-block-packing-mode");
283303

284304
fwnode_property_read_u32(node, "mipi-sdw-port-encoding-type",
@@ -308,19 +328,19 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
308328
device_property_read_u32(dev, "mipi-sdw-sw-interface-revision",
309329
&prop->mipi_revision);
310330

311-
prop->wake_capable = device_property_read_bool(dev,
331+
prop->wake_capable = mipi_device_property_read_bool(dev,
312332
"mipi-sdw-wake-up-unavailable");
313333
prop->wake_capable = !prop->wake_capable;
314334

315-
prop->test_mode_capable = device_property_read_bool(dev,
335+
prop->test_mode_capable = mipi_device_property_read_bool(dev,
316336
"mipi-sdw-test-mode-supported");
317337

318338
prop->clk_stop_mode1 = false;
319-
if (device_property_read_bool(dev,
339+
if (mipi_device_property_read_bool(dev,
320340
"mipi-sdw-clock-stop-mode1-supported"))
321341
prop->clk_stop_mode1 = true;
322342

323-
prop->simple_clk_stop_capable = device_property_read_bool(dev,
343+
prop->simple_clk_stop_capable = mipi_device_property_read_bool(dev,
324344
"mipi-sdw-simplified-clockstopprepare-sm-supported");
325345

326346
device_property_read_u32(dev, "mipi-sdw-clockstopprepare-timeout",
@@ -333,13 +353,13 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
333353
"mipi-sdw-clockstopprepare-hard-reset-behavior",
334354
&prop->reset_behave);
335355

336-
prop->high_PHY_capable = device_property_read_bool(dev,
356+
prop->high_PHY_capable = mipi_device_property_read_bool(dev,
337357
"mipi-sdw-highPHY-capable");
338358

339-
prop->paging_support = device_property_read_bool(dev,
359+
prop->paging_support = mipi_device_property_read_bool(dev,
340360
"mipi-sdw-paging-support");
341361

342-
prop->bank_delay_support = device_property_read_bool(dev,
362+
prop->bank_delay_support = mipi_device_property_read_bool(dev,
343363
"mipi-sdw-bank-delay-support");
344364

345365
device_property_read_u32(dev,

0 commit comments

Comments
 (0)