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.dev, bard.liao@intel.com
Subject: [PATCH v3 02/14] soundwire: mipi_disco: read lane mapping properties from ACPI
Date: Wed, 18 Dec 2024 16:01:43 +0800 [thread overview]
Message-ID: <20241218080155.102405-3-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20241218080155.102405-1-yung-chuan.liao@linux.intel.com>
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>
---
drivers/soundwire/mipi_disco.c | 40 +++++++++++++++++++++++++++++++++-
include/linux/soundwire/sdw.h | 5 +++++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/drivers/soundwire/mipi_disco.c b/drivers/soundwire/mipi_disco.c
index 9d59f486edbe..65afb28ef8fa 100644
--- a/drivers/soundwire/mipi_disco.c
+++ b/drivers/soundwire/mipi_disco.c
@@ -366,6 +366,44 @@ static int sdw_slave_read_dpn(struct sdw_slave *slave,
return 0;
}
+/*
+ * In MIPI DisCo spec for SoundWire, lane mapping for a slave device is done with
+ * mipi-sdw-lane-x-mapping properties, where x is 1..7, and the values for those
+ * properties are mipi-sdw-manager-lane-x or mipi-sdw-peripheral-link-y, where x
+ * is an integer between 1 to 7 if the lane is connected to a manager lane, y is a
+ * character between A to E if the lane is connected to another peripheral lane.
+ */
+int sdw_slave_read_lane_mapping(struct sdw_slave *slave)
+{
+ struct sdw_slave_prop *prop = &slave->prop;
+ struct device *dev = &slave->dev;
+ char prop_name[30];
+ const char *prop_val;
+ size_t len;
+ int ret, i;
+ u8 lane;
+
+ for (i = 0; i < SDW_MAX_LANES; i++) {
+ snprintf(prop_name, sizeof(prop_name), "mipi-sdw-lane-%d-mapping", i);
+ ret = device_property_read_string(dev, prop_name, &prop_val);
+ if (ret)
+ continue;
+
+ len = strlen(prop_val);
+ if (len < 1)
+ return -EINVAL;
+
+ /* The last character is enough to identify the connection */
+ ret = kstrtou8(&prop_val[len - 1], 10, &lane);
+ if (ret)
+ return ret;
+ if (in_range(lane, 1, SDW_MAX_LANES - 1))
+ prop->lane_maps[i] = lane;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(sdw_slave_read_lane_mapping);
+
/**
* sdw_slave_read_prop() - Read Slave properties
* @slave: SDW Slave
@@ -486,6 +524,6 @@ int sdw_slave_read_prop(struct sdw_slave *slave)
sdw_slave_read_dpn(slave, prop->sink_dpn_prop, nval,
prop->sink_ports, "sink");
- return 0;
+ return sdw_slave_read_lane_mapping(slave);
}
EXPORT_SYMBOL(sdw_slave_read_prop);
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index bd9836690da6..bb4e33a4db17 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -54,6 +54,8 @@ struct sdw_slave;
#define SDW_MAX_PORTS 15
#define SDW_VALID_PORT_RANGE(n) ((n) < SDW_MAX_PORTS && (n) >= 1)
+#define SDW_MAX_LANES 8
+
enum {
SDW_PORT_DIRN_SINK = 0,
SDW_PORT_DIRN_SOURCE,
@@ -356,6 +358,7 @@ struct sdw_dpn_prop {
* and masks are supported
* @commit_register_supported: is PCP_Commit register supported
* @scp_int1_mask: SCP_INT1_MASK desired settings
+ * @lane_maps: Lane mapping for the slave, only valid if lane_control_support is set
* @clock_reg_supported: the Peripheral implements the clock base and scale
* registers introduced with the SoundWire 1.2 specification. SDCA devices
* do not need to set this boolean property as the registers are required.
@@ -385,6 +388,7 @@ struct sdw_slave_prop {
u32 sdca_interrupt_register_list;
u8 commit_register_supported;
u8 scp_int1_mask;
+ u8 lane_maps[SDW_MAX_LANES];
bool clock_reg_supported;
bool use_domain_irq;
};
@@ -450,6 +454,7 @@ struct sdw_master_prop {
int sdw_master_read_prop(struct sdw_bus *bus);
int sdw_slave_read_prop(struct sdw_slave *slave);
+int sdw_slave_read_lane_mapping(struct sdw_slave *slave);
/*
* SDW Slave Structures and APIs
--
2.43.0
next prev parent reply other threads:[~2024-12-18 8:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 8:01 [PATCH v3 00/14] soundwire: add multi-lane support Bard Liao
2024-12-18 8:01 ` [PATCH v3 01/14] soundwire: add lane field in sdw_port_runtime Bard Liao
2024-12-18 8:01 ` Bard Liao [this message]
2024-12-18 8:01 ` [PATCH v3 03/14] soundwire: add lane_used_bandwidth in struct sdw_bus Bard Liao
2024-12-18 8:01 ` [PATCH v3 04/14] soundwire: stream: set DEPREPARED state earlier Bard Liao
2024-12-18 8:01 ` [PATCH v3 05/14] soundwire: generic_bandwidth_allocation: skip DEPREPARED streams Bard Liao
2024-12-18 8:01 ` [PATCH v3 06/14] Soundwire: add sdw_slave_get_scale_index helper Bard Liao
2024-12-18 8:01 ` [PATCH v3 07/14] Soundwire: stream: program BUSCLOCK_SCALE Bard Liao
2024-12-18 8:01 ` [PATCH v3 08/14] Soundwire: generic_bandwidth_allocation: set frame shape on fly Bard Liao
2024-12-18 8:01 ` [PATCH v3 09/14] soundwire: generic_bandwidth_allocation: correct clk_freq check in sdw_select_row_col Bard Liao
2024-12-18 8:01 ` [PATCH v3 10/14] soundwire: generic_bandwidth_allocation: check required freq accurately Bard Liao
2024-12-18 8:01 ` [PATCH v3 11/14] soundwire: generic_bandwidth_allocation: select data lane Bard Liao
2024-12-18 8:01 ` [PATCH v3 12/14] soundwire: generic_bandwidth_allocation: add lane in sdw_group_params Bard Liao
2024-12-18 8:01 ` [PATCH v3 13/14] SoundWire: pass stream to compute_params() Bard Liao
2024-12-18 8:01 ` [PATCH v3 14/14] soundwire: generic_bandwidth_allocation: count the bandwidth of active streams only Bard Liao
2024-12-23 9:12 ` [PATCH v3 00/14] soundwire: add multi-lane support Vinod Koul
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=20241218080155.102405-3-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.dev \
--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
all inboxes | Powered by JetHome®