[6/6] soundwire: qcom: add support for v1.7 Soundwire Controller

Message ID 20221026110210.6575-7-srinivas.kandagatla@linaro.org
State New
Headers
Series soundwire: qcom: fixes and support for v1.7 |

Commit Message

Srinivas Kandagatla Oct. 26, 2022, 11:02 a.m. UTC
  This patch add support for v1.7 SoundWire Controller which has
support for Multi-EE (Execution Environment), resulting in a
new register and extending field in BUS_CTRL register.

With these updates v1.7.0 is fully supported.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/soundwire/qcom.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
  

Comments

Pierre-Louis Bossart Oct. 26, 2022, 8:14 p.m. UTC | #1
> @@ -1582,6 +1597,7 @@ static const struct of_device_id qcom_swrm_of_match[] = {
>  	{ .compatible = "qcom,soundwire-v1.3.0", .data = &swrm_v1_3_data },
>  	{ .compatible = "qcom,soundwire-v1.5.1", .data = &swrm_v1_5_data },
>  	{ .compatible = "qcom,soundwire-v1.6.0", .data = &swrm_v1_6_data },
> +	{ .compatible = "qcom,soundwire-v1.7.0", .data = &swrm_v1_5_data },

is this line intentional, it looks odd that 1.7 is compatible with 1.5,
but 1.6 isn't?
  
Srinivas Kandagatla Oct. 27, 2022, 10:19 a.m. UTC | #2
Hi Pierre,

On 26/10/2022 21:14, Pierre-Louis Bossart wrote:
> 
>> @@ -1582,6 +1597,7 @@ static const struct of_device_id qcom_swrm_of_match[] = {
>>   	{ .compatible = "qcom,soundwire-v1.3.0", .data = &swrm_v1_3_data },
>>   	{ .compatible = "qcom,soundwire-v1.5.1", .data = &swrm_v1_5_data },
>>   	{ .compatible = "qcom,soundwire-v1.6.0", .data = &swrm_v1_6_data },
>> +	{ .compatible = "qcom,soundwire-v1.7.0", .data = &swrm_v1_5_data },
> 
> is this line intentional, it looks odd that 1.7 is compatible with 1.5,
> but 1.6 isn't?
This is more around the data rather than compatible, 1.6 data is marked 
with sw_clk_gate_required = true which is not the case with 1.7.

from 1.5 we use same frame shape info for 1.6, 1.7, except that 1.6 had 
this sw_clk_gate_required flag set.

--srini

>
  
Pierre-Louis Bossart Oct. 27, 2022, 12:45 p.m. UTC | #3
>>> @@ -1582,6 +1597,7 @@ static const struct of_device_id
>>> qcom_swrm_of_match[] = {
>>>       { .compatible = "qcom,soundwire-v1.3.0", .data =
>>> &swrm_v1_3_data },
>>>       { .compatible = "qcom,soundwire-v1.5.1", .data =
>>> &swrm_v1_5_data },
>>>       { .compatible = "qcom,soundwire-v1.6.0", .data =
>>> &swrm_v1_6_data },
>>> +    { .compatible = "qcom,soundwire-v1.7.0", .data = &swrm_v1_5_data },
>>
>> is this line intentional, it looks odd that 1.7 is compatible with 1.5,
>> but 1.6 isn't?
> This is more around the data rather than compatible, 1.6 data is marked
> with sw_clk_gate_required = true which is not the case with 1.7.
> 
> from 1.5 we use same frame shape info for 1.6, 1.7, except that 1.6 had
> this sw_clk_gate_required flag set.

probably worthy of a comment to show intent and explain the differences?
  

Patch

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 54d370f4b291..335424870290 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -25,6 +25,8 @@ 
 
 #define SWRM_COMP_SW_RESET					0x008
 #define SWRM_COMP_STATUS					0x014
+#define SWRM_LINK_MANAGER_EE					0x018
+#define SWRM_EE_CPU						1
 #define SWRM_FRM_GEN_ENABLED					BIT(0)
 #define SWRM_COMP_HW_VERSION					0x00
 #define SWRM_COMP_CFG_ADDR					0x04
@@ -693,7 +695,14 @@  static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
 	u32p_replace_bits(&val, SWRM_DEF_CMD_NO_PINGS, SWRM_MCP_CFG_MAX_NUM_OF_CMD_NO_PINGS_BMSK);
 	ctrl->reg_write(ctrl, SWRM_MCP_CFG_ADDR, val);
 
-	ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
+	if (ctrl->version >= 0x01070000) {
+		ctrl->reg_write(ctrl, SWRM_LINK_MANAGER_EE, SWRM_EE_CPU);
+		ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL,
+				SWRM_MCP_BUS_CLK_START << SWRM_EE_CPU);
+	} else {
+		ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
+	}
+
 	/* Configure number of retries of a read/write cmd */
 	if (ctrl->version > 0x01050001) {
 		/* Only for versions >= 1.5.1 */
@@ -1518,7 +1527,13 @@  static int __maybe_unused swrm_runtime_resume(struct device *dev)
 	} else {
 		reset_control_reset(ctrl->audio_cgcr);
 
-		ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
+		if (ctrl->version >= 0x01070000) {
+			ctrl->reg_write(ctrl, SWRM_LINK_MANAGER_EE, SWRM_EE_CPU);
+			ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL,
+					SWRM_MCP_BUS_CLK_START << SWRM_EE_CPU);
+		} else {
+			ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
+		}
 		ctrl->reg_write(ctrl, SWRM_INTERRUPT_CLEAR,
 			SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET);
 
@@ -1582,6 +1597,7 @@  static const struct of_device_id qcom_swrm_of_match[] = {
 	{ .compatible = "qcom,soundwire-v1.3.0", .data = &swrm_v1_3_data },
 	{ .compatible = "qcom,soundwire-v1.5.1", .data = &swrm_v1_5_data },
 	{ .compatible = "qcom,soundwire-v1.6.0", .data = &swrm_v1_6_data },
+	{ .compatible = "qcom,soundwire-v1.7.0", .data = &swrm_v1_5_data },
 	{/* sentinel */},
 };