devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add software clock gating requirement check
@ 2022-06-08 14:02 Srinivasa Rao Mandadapu
  2022-06-08 14:02 ` [PATCH v3 1/2] soundwire: qcom: Add flag for software clock gating check Srinivasa Rao Mandadapu
  2022-06-08 14:02 ` [PATCH v3 2/2] ASoC: qcom: soundwire: Add software clock gating requirement check Srinivasa Rao Mandadapu
  0 siblings, 2 replies; 7+ messages in thread
From: Srinivasa Rao Mandadapu @ 2022-06-08 14:02 UTC (permalink / raw)
  To: agross, bjorn.andersson, lgirdwood, broonie, robh+dt, quic_plai,
	bgoswami, perex, tiwai, srinivas.kandagatla, quic_rohkumar,
	linux-arm-msm, alsa-devel, devicetree, linux-kernel, swboyd,
	judyhsiao, vkoul
  Cc: Srinivasa Rao Mandadapu

This patch set is to add software clock gating requirement check

Changes Since V1:
	-- Use boolean flag for bool variable initialization
	   instead of hard coding.
Changes Since V1:
	-- Fix if check before reset control call
	
Srinivasa Rao Mandadapu (2):
  soundwire: qcom: Add flag for software clock gating check
  ASoC: qcom: soundwire: Add software clock gating requirement check

 drivers/soundwire/qcom.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/2] soundwire: qcom: Add flag for software clock gating check
  2022-06-08 14:02 [PATCH v3 0/2] Add software clock gating requirement check Srinivasa Rao Mandadapu
@ 2022-06-08 14:02 ` Srinivasa Rao Mandadapu
  2022-06-08 15:39   ` Pierre-Louis Bossart
  2022-06-08 14:02 ` [PATCH v3 2/2] ASoC: qcom: soundwire: Add software clock gating requirement check Srinivasa Rao Mandadapu
  1 sibling, 1 reply; 7+ messages in thread
From: Srinivasa Rao Mandadapu @ 2022-06-08 14:02 UTC (permalink / raw)
  To: agross, bjorn.andersson, lgirdwood, broonie, robh+dt, quic_plai,
	bgoswami, perex, tiwai, srinivas.kandagatla, quic_rohkumar,
	linux-arm-msm, alsa-devel, devicetree, linux-kernel, swboyd,
	judyhsiao, vkoul
  Cc: Srinivasa Rao Mandadapu

Add flag in qcom_swrm_data private data structure for validating
software colck gating control requirement.

Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/soundwire/qcom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index a3fccf0..38c3bf5 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -181,6 +181,7 @@ struct qcom_swrm_ctrl {
 struct qcom_swrm_data {
 	u32 default_cols;
 	u32 default_rows;
+	bool sw_clk_gate_required;
 };
 
 static const struct qcom_swrm_data swrm_v1_3_data = {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v3 2/2] ASoC: qcom: soundwire: Add software clock gating requirement check
  2022-06-08 14:02 [PATCH v3 0/2] Add software clock gating requirement check Srinivasa Rao Mandadapu
  2022-06-08 14:02 ` [PATCH v3 1/2] soundwire: qcom: Add flag for software clock gating check Srinivasa Rao Mandadapu
@ 2022-06-08 14:02 ` Srinivasa Rao Mandadapu
  2022-06-08 19:29   ` Stephen Boyd
  1 sibling, 1 reply; 7+ messages in thread
From: Srinivasa Rao Mandadapu @ 2022-06-08 14:02 UTC (permalink / raw)
  To: agross, bjorn.andersson, lgirdwood, broonie, robh+dt, quic_plai,
	bgoswami, perex, tiwai, srinivas.kandagatla, quic_rohkumar,
	linux-arm-msm, alsa-devel, devicetree, linux-kernel, swboyd,
	judyhsiao, vkoul
  Cc: Srinivasa Rao Mandadapu

Validate software clock gating required or not and do software
clock gating on hclk if soundwire is operational and keep it
running by adding flag in private dat structure.
This is to avoid conflict between older architectures,
where software clock gating is not required and on latest
architectues, where software clock gating is mandatory.

Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/soundwire/qcom.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 38c3bf5..ebd7479 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -194,6 +194,12 @@ static const struct qcom_swrm_data swrm_v1_5_data = {
 	.default_cols = 16,
 };
 
+static const struct qcom_swrm_data swrm_v1_6_data = {
+	.default_rows = 50,
+	.default_cols = 16,
+	.sw_clk_gate_required = true,
+};
+
 #define to_qcom_sdw(b)	container_of(b, struct qcom_swrm_ctrl, bus)
 
 static int qcom_swrm_ahb_reg_read(struct qcom_swrm_ctrl *ctrl, int reg,
@@ -659,7 +665,8 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
 	val = FIELD_PREP(SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_BMSK, ctrl->rows_index);
 	val |= FIELD_PREP(SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK, ctrl->cols_index);
 
-	reset_control_reset(ctrl->audio_cgcr);
+	if (ctrl->audio_cgcr)
+		reset_control_reset(ctrl->audio_cgcr);
 
 	ctrl->reg_write(ctrl, SWRM_MCP_FRAME_CTRL_BANK_ADDR(0), val);
 
@@ -1312,6 +1319,15 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 			return PTR_ERR(ctrl->mmio);
 	}
 
+	if (data->sw_clk_gate_required) {
+		ctrl->audio_cgcr = devm_reset_control_get_exclusive(dev, "swr_audio_cgcr");
+		if (IS_ERR(ctrl->audio_cgcr)) {
+			dev_err(dev, "Failed to get cgcr reset ctrl required for SW gating\n");
+			ret = PTR_ERR(ctrl->audio_cgcr);
+			goto err_init;
+		}
+	}
+
 	ctrl->irq = of_irq_get(dev->of_node, 0);
 	if (ctrl->irq < 0) {
 		ret = ctrl->irq;
@@ -1337,10 +1353,6 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 	ctrl->bus.compute_params = &qcom_swrm_compute_params;
 	ctrl->bus.clk_stop_timeout = 300;
 
-	ctrl->audio_cgcr = devm_reset_control_get_exclusive(dev, "swr_audio_cgcr");
-	if (IS_ERR(ctrl->audio_cgcr))
-		dev_err(dev, "Failed to get audio_cgcr reset required for soundwire-v1.6.0\n");
-
 	ret = qcom_swrm_get_port_config(ctrl);
 	if (ret)
 		goto err_clk;
@@ -1494,7 +1506,8 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
 		qcom_swrm_get_device_status(ctrl);
 		sdw_handle_slave_status(&ctrl->bus, ctrl->status);
 	} else {
-		reset_control_reset(ctrl->audio_cgcr);
+		if (ctrl->audio_cgcr)
+			reset_control_reset(ctrl->audio_cgcr);
 
 		ctrl->reg_write(ctrl, SWRM_MCP_BUS_CTRL, SWRM_MCP_BUS_CLK_START);
 		ctrl->reg_write(ctrl, SWRM_INTERRUPT_CLEAR,
@@ -1559,7 +1572,7 @@ static const struct dev_pm_ops swrm_dev_pm_ops = {
 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_5_data },
+	{ .compatible = "qcom,soundwire-v1.6.0", .data = &swrm_v1_6_data },
 	{/* sentinel */},
 };
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/2] soundwire: qcom: Add flag for software clock gating check
  2022-06-08 14:02 ` [PATCH v3 1/2] soundwire: qcom: Add flag for software clock gating check Srinivasa Rao Mandadapu
@ 2022-06-08 15:39   ` Pierre-Louis Bossart
  2022-06-09  4:34     ` Srinivasa Rao Mandadapu
  0 siblings, 1 reply; 7+ messages in thread
From: Pierre-Louis Bossart @ 2022-06-08 15:39 UTC (permalink / raw)
  To: Srinivasa Rao Mandadapu, agross, bjorn.andersson, lgirdwood,
	broonie, robh+dt, quic_plai, bgoswami, perex, tiwai,
	srinivas.kandagatla, quic_rohkumar, linux-arm-msm, alsa-devel,
	devicetree, linux-kernel, swboyd, judyhsiao, vkoul



On 6/8/22 09:02, Srinivasa Rao Mandadapu wrote:
> Add flag in qcom_swrm_data private data structure for validating
> software colck gating control requirement.

typo: clock

> 
> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/soundwire/qcom.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index a3fccf0..38c3bf5 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -181,6 +181,7 @@ struct qcom_swrm_ctrl {
>  struct qcom_swrm_data {
>  	u32 default_cols;
>  	u32 default_rows;
> +	bool sw_clk_gate_required;

I would have used a different split between patches, where the flag and
functionality is introduced, and a second patch where this flag would be
set for a specific platform.

>  };
>  
>  static const struct qcom_swrm_data swrm_v1_3_data = {

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/2] ASoC: qcom: soundwire: Add software clock gating requirement check
  2022-06-08 14:02 ` [PATCH v3 2/2] ASoC: qcom: soundwire: Add software clock gating requirement check Srinivasa Rao Mandadapu
@ 2022-06-08 19:29   ` Stephen Boyd
  2022-06-09  5:14     ` Srinivasa Rao Mandadapu
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Boyd @ 2022-06-08 19:29 UTC (permalink / raw)
  To: Srinivasa Rao Mandadapu, agross, alsa-devel, bgoswami,
	bjorn.andersson, broonie, devicetree, judyhsiao, lgirdwood,
	linux-arm-msm, linux-kernel, perex, quic_plai, quic_rohkumar,
	robh+dt, srinivas.kandagatla, tiwai, vkoul

Quoting Srinivasa Rao Mandadapu (2022-06-08 07:02:09)
> Validate software clock gating required or not and do software
> clock gating on hclk if soundwire is operational and keep it
> running by adding flag in private dat structure.
> This is to avoid conflict between older architectures,
> where software clock gating is not required and on latest
> architectues, where software clock gating is mandatory.

This talks about software clock gating but the code is getting a reset
and asserting it. Is that because the power on reset value of the clock
gating is to have hardware clock gating disabled, but some earlier code
is enabling hardware clock gating?

>
> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/soundwire/qcom.c | 27 ++++++++++++++++++++-------
>  1 file changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index 38c3bf5..ebd7479 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -659,7 +665,8 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
>         val = FIELD_PREP(SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_BMSK, ctrl->rows_index);
>         val |= FIELD_PREP(SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK, ctrl->cols_index);
>
> -       reset_control_reset(ctrl->audio_cgcr);
> +       if (ctrl->audio_cgcr)
> +               reset_control_reset(ctrl->audio_cgcr);
>
>         ctrl->reg_write(ctrl, SWRM_MCP_FRAME_CTRL_BANK_ADDR(0), val);
>
> @@ -1494,7 +1506,8 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
>                 qcom_swrm_get_device_status(ctrl);
>                 sdw_handle_slave_status(&ctrl->bus, ctrl->status);
>         } else {
> -               reset_control_reset(ctrl->audio_cgcr);
> +               if (ctrl->audio_cgcr)
> +                       reset_control_reset(ctrl->audio_cgcr);

reset_control_reset() is a no-op if the pointer is NULL so the if
condition is not necessary in the above two statements.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/2] soundwire: qcom: Add flag for software clock gating check
  2022-06-08 15:39   ` Pierre-Louis Bossart
@ 2022-06-09  4:34     ` Srinivasa Rao Mandadapu
  0 siblings, 0 replies; 7+ messages in thread
From: Srinivasa Rao Mandadapu @ 2022-06-09  4:34 UTC (permalink / raw)
  To: Pierre-Louis Bossart, agross, bjorn.andersson, lgirdwood,
	broonie, robh+dt, quic_plai, bgoswami, perex, tiwai,
	srinivas.kandagatla, quic_rohkumar, linux-arm-msm, alsa-devel,
	devicetree, linux-kernel, swboyd, judyhsiao, vkoul


On 6/8/2022 9:09 PM, Pierre-Louis Bossart wrote:
Thanks for Your time  Pierre-Louis!!!
>
> On 6/8/22 09:02, Srinivasa Rao Mandadapu wrote:
>> Add flag in qcom_swrm_data private data structure for validating
>> software colck gating control requirement.
> typo: clock
Okay. Will fix.
>
>> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
>> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>   drivers/soundwire/qcom.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
>> index a3fccf0..38c3bf5 100644
>> --- a/drivers/soundwire/qcom.c
>> +++ b/drivers/soundwire/qcom.c
>> @@ -181,6 +181,7 @@ struct qcom_swrm_ctrl {
>>   struct qcom_swrm_data {
>>   	u32 default_cols;
>>   	u32 default_rows;
>> +	bool sw_clk_gate_required;
> I would have used a different split between patches, where the flag and
> functionality is introduced, and a second patch where this flag would be
> set for a specific platform.
Okay. Will split accordingly!
>
>>   };
>>   
>>   static const struct qcom_swrm_data swrm_v1_3_data = {

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/2] ASoC: qcom: soundwire: Add software clock gating requirement check
  2022-06-08 19:29   ` Stephen Boyd
@ 2022-06-09  5:14     ` Srinivasa Rao Mandadapu
  0 siblings, 0 replies; 7+ messages in thread
From: Srinivasa Rao Mandadapu @ 2022-06-09  5:14 UTC (permalink / raw)
  To: Stephen Boyd, agross, alsa-devel, bgoswami, bjorn.andersson,
	broonie, devicetree, judyhsiao, lgirdwood, linux-arm-msm,
	linux-kernel, perex, quic_plai, quic_rohkumar, robh+dt,
	srinivas.kandagatla, tiwai, vkoul


On 6/9/2022 12:59 AM, Stephen Boyd wrote:
Thanks for Your time Stephen!!!
> Quoting Srinivasa Rao Mandadapu (2022-06-08 07:02:09)
>> Validate software clock gating required or not and do software
>> clock gating on hclk if soundwire is operational and keep it
>> running by adding flag in private dat structure.
>> This is to avoid conflict between older architectures,
>> where software clock gating is not required and on latest
>> architectues, where software clock gating is mandatory.
> This talks about software clock gating but the code is getting a reset
> and asserting it. Is that because the power on reset value of the clock
> gating is to have hardware clock gating disabled, but some earlier code
> is enabling hardware clock gating?

Yes Stephen. By Default this resets to HW controlled. As such there is 
no specific code

for enabling hardware clock gating, as these CGCR registers default 
setting is HW control.

>
>> Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
>> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>   drivers/soundwire/qcom.c | 27 ++++++++++++++++++++-------
>>   1 file changed, 20 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
>> index 38c3bf5..ebd7479 100644
>> --- a/drivers/soundwire/qcom.c
>> +++ b/drivers/soundwire/qcom.c
>> @@ -659,7 +665,8 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
>>          val = FIELD_PREP(SWRM_MCP_FRAME_CTRL_BANK_ROW_CTRL_BMSK, ctrl->rows_index);
>>          val |= FIELD_PREP(SWRM_MCP_FRAME_CTRL_BANK_COL_CTRL_BMSK, ctrl->cols_index);
>>
>> -       reset_control_reset(ctrl->audio_cgcr);
>> +       if (ctrl->audio_cgcr)
>> +               reset_control_reset(ctrl->audio_cgcr);
>>
>>          ctrl->reg_write(ctrl, SWRM_MCP_FRAME_CTRL_BANK_ADDR(0), val);
>>
>> @@ -1494,7 +1506,8 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
>>                  qcom_swrm_get_device_status(ctrl);
>>                  sdw_handle_slave_status(&ctrl->bus, ctrl->status);
>>          } else {
>> -               reset_control_reset(ctrl->audio_cgcr);
>> +               if (ctrl->audio_cgcr)
>> +                       reset_control_reset(ctrl->audio_cgcr);
> reset_control_reset() is a no-op if the pointer is NULL so the if
> condition is not necessary in the above two statements.
Okay. revert this NULL check here.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-06-09  5:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 14:02 [PATCH v3 0/2] Add software clock gating requirement check Srinivasa Rao Mandadapu
2022-06-08 14:02 ` [PATCH v3 1/2] soundwire: qcom: Add flag for software clock gating check Srinivasa Rao Mandadapu
2022-06-08 15:39   ` Pierre-Louis Bossart
2022-06-09  4:34     ` Srinivasa Rao Mandadapu
2022-06-08 14:02 ` [PATCH v3 2/2] ASoC: qcom: soundwire: Add software clock gating requirement check Srinivasa Rao Mandadapu
2022-06-08 19:29   ` Stephen Boyd
2022-06-09  5:14     ` Srinivasa Rao Mandadapu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).