From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: linux-sound@vger.kernel.org, vkoul@kernel.org
Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org,
pierre-louis.bossart@linux.intel.com, bard.liao@intel.com
Subject: [PATCH v2 01/14] soundwire: mipi_disco: add MIPI-specific property_read_bool() helpers
Date: Wed, 11 Sep 2024 19:58:14 +0800 [thread overview]
Message-ID: <20240911115827.233171-2-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20240911115827.233171-1-yung-chuan.liao@linux.intel.com>
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
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: https://github.com/thesofproject/linux/issues/5129
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
drivers/soundwire/mipi_disco.c | 50 ++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/drivers/soundwire/mipi_disco.c b/drivers/soundwire/mipi_disco.c
index e5d9df26d4dc..fdab3d4a1379 100644
--- a/drivers/soundwire/mipi_disco.c
+++ b/drivers/soundwire/mipi_disco.c
@@ -23,6 +23,26 @@
#include <linux/soundwire/sdw.h>
#include "bus.h"
+static bool mipi_fwnode_property_read_bool(const struct fwnode_handle *fwnode,
+ const char *propname)
+{
+ int ret;
+ u8 val;
+
+ if (!fwnode_property_present(fwnode, propname))
+ return false;
+ ret = fwnode_property_read_u8_array(fwnode, propname, &val, 1);
+ if (ret < 0)
+ return false;
+ return !!val;
+}
+
+static bool mipi_device_property_read_bool(const struct device *dev,
+ const char *propname)
+{
+ return mipi_fwnode_property_read_bool(dev_fwnode(dev), propname);
+}
+
/**
* sdw_master_read_prop() - Read Master properties
* @bus: SDW bus instance
@@ -48,11 +68,11 @@ int sdw_master_read_prop(struct sdw_bus *bus)
return -EIO;
}
- if (fwnode_property_read_bool(link,
+ if (mipi_fwnode_property_read_bool(link,
"mipi-sdw-clock-stop-mode0-supported"))
prop->clk_stop_modes |= BIT(SDW_CLK_STOP_MODE0);
- if (fwnode_property_read_bool(link,
+ if (mipi_fwnode_property_read_bool(link,
"mipi-sdw-clock-stop-mode1-supported"))
prop->clk_stop_modes |= BIT(SDW_CLK_STOP_MODE1);
@@ -114,7 +134,7 @@ int sdw_master_read_prop(struct sdw_bus *bus)
fwnode_property_read_u32(link, "mipi-sdw-default-frame-col-size",
&prop->default_col);
- prop->dynamic_frame = fwnode_property_read_bool(link,
+ prop->dynamic_frame = mipi_fwnode_property_read_bool(link,
"mipi-sdw-dynamic-frame-shape");
fwnode_property_read_u32(link, "mipi-sdw-command-error-threshold",
@@ -153,13 +173,13 @@ static int sdw_slave_read_dp0(struct sdw_slave *slave,
dp0->words, dp0->num_words);
}
- dp0->BRA_flow_controlled = fwnode_property_read_bool(port,
+ dp0->BRA_flow_controlled = mipi_fwnode_property_read_bool(port,
"mipi-sdw-bra-flow-controlled");
- dp0->simple_ch_prep_sm = fwnode_property_read_bool(port,
+ dp0->simple_ch_prep_sm = mipi_fwnode_property_read_bool(port,
"mipi-sdw-simplified-channel-prepare-sm");
- dp0->imp_def_interrupts = fwnode_property_read_bool(port,
+ dp0->imp_def_interrupts = mipi_fwnode_property_read_bool(port,
"mipi-sdw-imp-def-dp0-interrupts-supported");
return 0;
@@ -220,7 +240,7 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
"mipi-sdw-max-grouping-supported",
&dpn[i].max_grouping);
- dpn[i].simple_ch_prep_sm = fwnode_property_read_bool(node,
+ dpn[i].simple_ch_prep_sm = mipi_fwnode_property_read_bool(node,
"mipi-sdw-simplified-channelprepare-sm");
fwnode_property_read_u32(node,
@@ -278,7 +298,7 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
fwnode_property_read_u32(node, "mipi-sdw-max-async-buffer",
&dpn[i].max_async_buffer);
- dpn[i].block_pack_mode = fwnode_property_read_bool(node,
+ dpn[i].block_pack_mode = mipi_fwnode_property_read_bool(node,
"mipi-sdw-block-packing-mode");
fwnode_property_read_u32(node, "mipi-sdw-port-encoding-type",
@@ -308,19 +328,19 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
device_property_read_u32(dev, "mipi-sdw-sw-interface-revision",
&prop->mipi_revision);
- prop->wake_capable = device_property_read_bool(dev,
+ prop->wake_capable = mipi_device_property_read_bool(dev,
"mipi-sdw-wake-up-unavailable");
prop->wake_capable = !prop->wake_capable;
- prop->test_mode_capable = device_property_read_bool(dev,
+ prop->test_mode_capable = mipi_device_property_read_bool(dev,
"mipi-sdw-test-mode-supported");
prop->clk_stop_mode1 = false;
- if (device_property_read_bool(dev,
+ if (mipi_device_property_read_bool(dev,
"mipi-sdw-clock-stop-mode1-supported"))
prop->clk_stop_mode1 = true;
- prop->simple_clk_stop_capable = device_property_read_bool(dev,
+ prop->simple_clk_stop_capable = mipi_device_property_read_bool(dev,
"mipi-sdw-simplified-clockstopprepare-sm-supported");
device_property_read_u32(dev, "mipi-sdw-clockstopprepare-timeout",
@@ -333,13 +353,13 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
"mipi-sdw-clockstopprepare-hard-reset-behavior",
&prop->reset_behave);
- prop->high_PHY_capable = device_property_read_bool(dev,
+ prop->high_PHY_capable = mipi_device_property_read_bool(dev,
"mipi-sdw-highPHY-capable");
- prop->paging_support = device_property_read_bool(dev,
+ prop->paging_support = mipi_device_property_read_bool(dev,
"mipi-sdw-paging-support");
- prop->bank_delay_support = device_property_read_bool(dev,
+ prop->bank_delay_support = mipi_device_property_read_bool(dev,
"mipi-sdw-bank-delay-support");
device_property_read_u32(dev,
--
2.43.0
next prev parent reply other threads:[~2024-09-11 11:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 11:58 [PATCH v2 00/14] soundwire: mipi-disco: add partial SoundWire Disco 2.1 Bard Liao
2024-09-11 11:58 ` Bard Liao [this message]
2024-09-11 11:58 ` [PATCH v2 02/14] soundwire: optimize sdw_stream_runtime memory layout Bard Liao
2024-09-11 11:58 ` [PATCH v2 03/14] soundwire: optimize sdw_master_prop Bard Liao
2024-09-11 11:58 ` [PATCH v2 04/14] soundwire: optimize sdw_bus structure Bard Liao
2024-09-11 11:58 ` [PATCH v2 05/14] soundwire: optimize sdw_slave_prop Bard Liao
2024-09-11 11:58 ` [PATCH v2 06/14] soundwire: optimize sdw_dp0_prop Bard Liao
2024-09-11 11:58 ` [PATCH v2 07/14] soundwire: optimize sdw_dpn_prop Bard Liao
2024-09-11 11:58 ` [PATCH v2 08/14] soundwire: mipi-disco: remove DPn audio-modes Bard Liao
2024-09-11 11:58 ` [PATCH v2 09/14] soundwire: mipi-disco: add error handling for property array read Bard Liao
2024-09-11 11:58 ` [PATCH v2 10/14] soundwire: mipi_disco: add support for clock-scales property Bard Liao
2024-09-11 11:58 ` [PATCH v2 11/14] soundwire: mipi-disco: add support for peripheral channelprepare timeout Bard Liao
2024-09-11 11:58 ` [PATCH v2 12/14] soundwire: mipi-disco: add comment on DP0-supported property Bard Liao
2024-09-11 11:58 ` [PATCH v2 13/14] soundwire: mipi-disco: add new properties from 2.0 spec Bard Liao
2024-09-11 11:58 ` [PATCH v2 14/14] soundwire: mipi-disco: add support for DP0/DPn 'lane-list' property Bard Liao
2024-09-12 14:41 ` [PATCH v2 00/14] soundwire: mipi-disco: add partial SoundWire Disco 2.1 Charles Keepax
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240911115827.233171-2-yung-chuan.liao@linux.intel.com \
--to=yung-chuan.liao@linux.intel.com \
--cc=bard.liao@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=vinod.koul@linaro.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox