linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] remoteproc: Add support for xo clock
@ 2016-10-25 20:57 Sarangdhar Joshi
  2016-10-25 21:03 ` Sarangdhar Joshi
  2016-11-01  0:05 ` Bjorn Andersson
  0 siblings, 2 replies; 7+ messages in thread
From: Sarangdhar Joshi @ 2016-10-25 20:57 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: Sarangdhar Joshi, linux-remoteproc, linux-kernel, linux-arm-msm,
	Stephen Boyd, Trilok Soni

Add xo clock support required to boot up Qualcomm ADSP processor.
The ADSP remoteproc driver keeps xo clock enabled until the
driver receives "handover" irq, in order to allow ADSP processor
to vote for xo clock with rpm.

Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
---
 drivers/remoteproc/qcom_adsp_pil.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c
index 9141633..5bb25d1 100644
--- a/drivers/remoteproc/qcom_adsp_pil.c
+++ b/drivers/remoteproc/qcom_adsp_pil.c
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/clk.h>
 #include <linux/firmware.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
@@ -48,6 +49,8 @@ struct qcom_adsp {
 	struct qcom_smem_state *state;
 	unsigned stop_bit;
 
+	struct clk *xo;
+
 	struct regulator *cx_supply;
 
 	struct completion start_done;
@@ -102,10 +105,14 @@ static int adsp_start(struct rproc *rproc)
 	struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
 	int ret;
 
-	ret = regulator_enable(adsp->cx_supply);
+	ret = clk_prepare_enable(adsp->xo);
 	if (ret)
 		return ret;
 
+	ret = regulator_enable(adsp->cx_supply);
+	if (ret)
+		goto disable_clocks;
+
 	ret = qcom_scm_pas_auth_and_reset(ADSP_PAS_ID);
 	if (ret) {
 		dev_err(adsp->dev,
@@ -126,6 +133,8 @@ static int adsp_start(struct rproc *rproc)
 
 disable_regulators:
 	regulator_disable(adsp->cx_supply);
+disable_clocks:
+	clk_disable_unprepare(adsp->xo);
 
 	return ret;
 }
@@ -223,6 +232,21 @@ static irqreturn_t adsp_stop_ack_interrupt(int irq, void *dev)
 	return IRQ_HANDLED;
 }
 
+static int adsp_init_clock(struct qcom_adsp *adsp)
+{
+	int ret;
+
+	adsp->xo = devm_clk_get(adsp->dev, "xo");
+	if (IS_ERR(adsp->xo)) {
+		ret = PTR_ERR(adsp->xo);
+		if (ret != -EPROBE_DEFER)
+			dev_err(adsp->dev, "failed to get xo clock");
+		return ret;
+	}
+
+	return 0;
+}
+
 static int adsp_init_regulator(struct qcom_adsp *adsp)
 {
 	adsp->cx_supply = devm_regulator_get(adsp->dev, "cx");
@@ -320,6 +344,10 @@ static int adsp_probe(struct platform_device *pdev)
 	if (ret)
 		goto free_rproc;
 
+	ret = adsp_init_clock(adsp);
+	if (ret)
+		goto free_rproc;
+
 	ret = adsp_init_regulator(adsp);
 	if (ret)
 		goto free_rproc;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH v2 1/1] remoteproc: Add support for xo clock
  2016-10-25 20:57 [PATCH v2 1/1] remoteproc: Add support for xo clock Sarangdhar Joshi
@ 2016-10-25 21:03 ` Sarangdhar Joshi
  2016-11-01  0:05 ` Bjorn Andersson
  1 sibling, 0 replies; 7+ messages in thread
From: Sarangdhar Joshi @ 2016-10-25 21:03 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: linux-remoteproc, linux-kernel, linux-arm-msm, Stephen Boyd, Trilok Soni

On 10/25/2016 01:57 PM, Sarangdhar Joshi wrote:
> Add xo clock support required to boot up Qualcomm ADSP processor.
> The ADSP remoteproc driver keeps xo clock enabled until the
> driver receives "handover" irq, in order to allow ADSP processor
> to vote for xo clock with rpm.
>
> Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
> ---

Changes since v1:
  - Avoid logging error for probe deferral case (Stephen)
  - Update commit text (Stephen)

>  drivers/remoteproc/qcom_adsp_pil.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c
> index 9141633..5bb25d1 100644
> --- a/drivers/remoteproc/qcom_adsp_pil.c
> +++ b/drivers/remoteproc/qcom_adsp_pil.c
> @@ -15,6 +15,7 @@
>   * GNU General Public License for more details.
>   */
>
> +#include <linux/clk.h>
>  #include <linux/firmware.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> @@ -48,6 +49,8 @@ struct qcom_adsp {
>  	struct qcom_smem_state *state;
>  	unsigned stop_bit;
>
> +	struct clk *xo;
> +
>  	struct regulator *cx_supply;
>
>  	struct completion start_done;
> @@ -102,10 +105,14 @@ static int adsp_start(struct rproc *rproc)
>  	struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
>  	int ret;
>
> -	ret = regulator_enable(adsp->cx_supply);
> +	ret = clk_prepare_enable(adsp->xo);
>  	if (ret)
>  		return ret;
>
> +	ret = regulator_enable(adsp->cx_supply);
> +	if (ret)
> +		goto disable_clocks;
> +
>  	ret = qcom_scm_pas_auth_and_reset(ADSP_PAS_ID);
>  	if (ret) {
>  		dev_err(adsp->dev,
> @@ -126,6 +133,8 @@ static int adsp_start(struct rproc *rproc)
>
>  disable_regulators:
>  	regulator_disable(adsp->cx_supply);
> +disable_clocks:
> +	clk_disable_unprepare(adsp->xo);
>
>  	return ret;
>  }
> @@ -223,6 +232,21 @@ static irqreturn_t adsp_stop_ack_interrupt(int irq, void *dev)
>  	return IRQ_HANDLED;
>  }
>
> +static int adsp_init_clock(struct qcom_adsp *adsp)
> +{
> +	int ret;
> +
> +	adsp->xo = devm_clk_get(adsp->dev, "xo");
> +	if (IS_ERR(adsp->xo)) {
> +		ret = PTR_ERR(adsp->xo);
> +		if (ret != -EPROBE_DEFER)
> +			dev_err(adsp->dev, "failed to get xo clock");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int adsp_init_regulator(struct qcom_adsp *adsp)
>  {
>  	adsp->cx_supply = devm_regulator_get(adsp->dev, "cx");
> @@ -320,6 +344,10 @@ static int adsp_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto free_rproc;
>
> +	ret = adsp_init_clock(adsp);
> +	if (ret)
> +		goto free_rproc;
> +
>  	ret = adsp_init_regulator(adsp);
>  	if (ret)
>  		goto free_rproc;
>


-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH v2 1/1] remoteproc: Add support for xo clock
  2016-10-25 20:57 [PATCH v2 1/1] remoteproc: Add support for xo clock Sarangdhar Joshi
  2016-10-25 21:03 ` Sarangdhar Joshi
@ 2016-11-01  0:05 ` Bjorn Andersson
  2016-11-01 17:41   ` Stephen Boyd
  2016-11-02 18:58   ` Sarangdhar Joshi
  1 sibling, 2 replies; 7+ messages in thread
From: Bjorn Andersson @ 2016-11-01  0:05 UTC (permalink / raw)
  To: Sarangdhar Joshi
  Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel, linux-arm-msm,
	Stephen Boyd, Trilok Soni

On Tue 25 Oct 13:57 PDT 2016, Sarangdhar Joshi wrote:

> Add xo clock support required to boot up Qualcomm ADSP processor.
> The ADSP remoteproc driver keeps xo clock enabled until the
> driver receives "handover" irq, in order to allow ADSP processor
> to vote for xo clock with rpm.

Looks good, thanks.

We have to add the clock to the DT binding and run that by Rob again,
before merging the driver and this patch.

Regards,
Bjorn

> 
> Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
> ---
>  drivers/remoteproc/qcom_adsp_pil.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c
> index 9141633..5bb25d1 100644
> --- a/drivers/remoteproc/qcom_adsp_pil.c
> +++ b/drivers/remoteproc/qcom_adsp_pil.c
> @@ -15,6 +15,7 @@
>   * GNU General Public License for more details.
>   */
>  
> +#include <linux/clk.h>
>  #include <linux/firmware.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> @@ -48,6 +49,8 @@ struct qcom_adsp {
>  	struct qcom_smem_state *state;
>  	unsigned stop_bit;
>  
> +	struct clk *xo;
> +
>  	struct regulator *cx_supply;
>  
>  	struct completion start_done;
> @@ -102,10 +105,14 @@ static int adsp_start(struct rproc *rproc)
>  	struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
>  	int ret;
>  
> -	ret = regulator_enable(adsp->cx_supply);
> +	ret = clk_prepare_enable(adsp->xo);
>  	if (ret)
>  		return ret;
>  
> +	ret = regulator_enable(adsp->cx_supply);
> +	if (ret)
> +		goto disable_clocks;
> +
>  	ret = qcom_scm_pas_auth_and_reset(ADSP_PAS_ID);
>  	if (ret) {
>  		dev_err(adsp->dev,
> @@ -126,6 +133,8 @@ static int adsp_start(struct rproc *rproc)
>  
>  disable_regulators:
>  	regulator_disable(adsp->cx_supply);
> +disable_clocks:
> +	clk_disable_unprepare(adsp->xo);
>  
>  	return ret;
>  }
> @@ -223,6 +232,21 @@ static irqreturn_t adsp_stop_ack_interrupt(int irq, void *dev)
>  	return IRQ_HANDLED;
>  }
>  
> +static int adsp_init_clock(struct qcom_adsp *adsp)
> +{
> +	int ret;
> +
> +	adsp->xo = devm_clk_get(adsp->dev, "xo");
> +	if (IS_ERR(adsp->xo)) {
> +		ret = PTR_ERR(adsp->xo);
> +		if (ret != -EPROBE_DEFER)
> +			dev_err(adsp->dev, "failed to get xo clock");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int adsp_init_regulator(struct qcom_adsp *adsp)
>  {
>  	adsp->cx_supply = devm_regulator_get(adsp->dev, "cx");
> @@ -320,6 +344,10 @@ static int adsp_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto free_rproc;
>  
> +	ret = adsp_init_clock(adsp);
> +	if (ret)
> +		goto free_rproc;
> +
>  	ret = adsp_init_regulator(adsp);
>  	if (ret)
>  		goto free_rproc;
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

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

* Re: [PATCH v2 1/1] remoteproc: Add support for xo clock
  2016-11-01  0:05 ` Bjorn Andersson
@ 2016-11-01 17:41   ` Stephen Boyd
  2016-11-01 17:46     ` Bjorn Andersson
  2016-11-02 18:58   ` Sarangdhar Joshi
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Boyd @ 2016-11-01 17:41 UTC (permalink / raw)
  To: Bjorn Andersson, Sarangdhar Joshi
  Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel, linux-arm-msm,
	Trilok Soni

On 10/31/2016 05:05 PM, Bjorn Andersson wrote:
> On Tue 25 Oct 13:57 PDT 2016, Sarangdhar Joshi wrote:
>
>> Add xo clock support required to boot up Qualcomm ADSP processor.
>> The ADSP remoteproc driver keeps xo clock enabled until the
>> driver receives "handover" irq, in order to allow ADSP processor
>> to vote for xo clock with rpm.
> Looks good, thanks.
>
> We have to add the clock to the DT binding and run that by Rob again,
> before merging the driver and this patch.
>

Maybe we should make the xo clock required. We always have a clock for
it somewhere, either RPM controlled or as a fixed rate clock so it
should work just as well.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH v2 1/1] remoteproc: Add support for xo clock
  2016-11-01 17:41   ` Stephen Boyd
@ 2016-11-01 17:46     ` Bjorn Andersson
  2016-11-01 17:52       ` Stephen Boyd
  0 siblings, 1 reply; 7+ messages in thread
From: Bjorn Andersson @ 2016-11-01 17:46 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Sarangdhar Joshi, Ohad Ben-Cohen, linux-remoteproc, lkml,
	linux-arm-msm, Trilok Soni

On Tue, Nov 1, 2016 at 10:41 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 10/31/2016 05:05 PM, Bjorn Andersson wrote:
>> On Tue 25 Oct 13:57 PDT 2016, Sarangdhar Joshi wrote:
>>
>>> Add xo clock support required to boot up Qualcomm ADSP processor.
>>> The ADSP remoteproc driver keeps xo clock enabled until the
>>> driver receives "handover" irq, in order to allow ADSP processor
>>> to vote for xo clock with rpm.
>> Looks good, thanks.
>>
>> We have to add the clock to the DT binding and run that by Rob again,
>> before merging the driver and this patch.
>>
>
> Maybe we should make the xo clock required. We always have a clock for
> it somewhere, either RPM controlled or as a fixed rate clock so it
> should work just as well.
>

As far as I can see it is required, after Sarangdhar's patch - so this
is what I meant we need to add to the DT binding before merging that.
And as you say, we can always make it reference "xo_board" for now.

Regards,
Bjorn

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

* Re: [PATCH v2 1/1] remoteproc: Add support for xo clock
  2016-11-01 17:46     ` Bjorn Andersson
@ 2016-11-01 17:52       ` Stephen Boyd
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Boyd @ 2016-11-01 17:52 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Sarangdhar Joshi, Ohad Ben-Cohen, linux-remoteproc, lkml,
	linux-arm-msm, Trilok Soni

On 11/01/2016 10:46 AM, Bjorn Andersson wrote:
> On Tue, Nov 1, 2016 at 10:41 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
>> On 10/31/2016 05:05 PM, Bjorn Andersson wrote:
>>> On Tue 25 Oct 13:57 PDT 2016, Sarangdhar Joshi wrote:
>>>
>>>> Add xo clock support required to boot up Qualcomm ADSP processor.
>>>> The ADSP remoteproc driver keeps xo clock enabled until the
>>>> driver receives "handover" irq, in order to allow ADSP processor
>>>> to vote for xo clock with rpm.
>>> Looks good, thanks.
>>>
>>> We have to add the clock to the DT binding and run that by Rob again,
>>> before merging the driver and this patch.
>>>
>> Maybe we should make the xo clock required. We always have a clock for
>> it somewhere, either RPM controlled or as a fixed rate clock so it
>> should work just as well.
>>
> As far as I can see it is required, after Sarangdhar's patch - so this
> is what I meant we need to add to the DT binding before merging that.
> And as you say, we can always make it reference "xo_board" for now.
>

Ah good then. Brain must have misread the patch.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH v2 1/1] remoteproc: Add support for xo clock
  2016-11-01  0:05 ` Bjorn Andersson
  2016-11-01 17:41   ` Stephen Boyd
@ 2016-11-02 18:58   ` Sarangdhar Joshi
  1 sibling, 0 replies; 7+ messages in thread
From: Sarangdhar Joshi @ 2016-11-02 18:58 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Ohad Ben-Cohen, linux-remoteproc, linux-kernel, linux-arm-msm,
	Stephen Boyd, Trilok Soni

On 10/31/2016 05:05 PM, Bjorn Andersson wrote:
> On Tue 25 Oct 13:57 PDT 2016, Sarangdhar Joshi wrote:
>
>> Add xo clock support required to boot up Qualcomm ADSP processor.
>> The ADSP remoteproc driver keeps xo clock enabled until the
>> driver receives "handover" irq, in order to allow ADSP processor
>> to vote for xo clock with rpm.
>
> Looks good, thanks.
>
> We have to add the clock to the DT binding and run that by Rob again,
> before merging the driver and this patch.
>
> Regards,
> Bjorn

Sure, will add it to the DT bindings. Thanks for reviewing.

Regards,
Sarang

>
>>
>> Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
>> ---
>>  drivers/remoteproc/qcom_adsp_pil.c | 30 +++++++++++++++++++++++++++++-
>>  1 file changed, 29 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/remoteproc/qcom_adsp_pil.c b/drivers/remoteproc/qcom_adsp_pil.c
>> index 9141633..5bb25d1 100644
>> --- a/drivers/remoteproc/qcom_adsp_pil.c
>> +++ b/drivers/remoteproc/qcom_adsp_pil.c
>> @@ -15,6 +15,7 @@
>>   * GNU General Public License for more details.
>>   */
>>
>> +#include <linux/clk.h>
>>  #include <linux/firmware.h>
>>  #include <linux/interrupt.h>
>>  #include <linux/kernel.h>
>> @@ -48,6 +49,8 @@ struct qcom_adsp {
>>  	struct qcom_smem_state *state;
>>  	unsigned stop_bit;
>>
>> +	struct clk *xo;
>> +
>>  	struct regulator *cx_supply;
>>
>>  	struct completion start_done;
>> @@ -102,10 +105,14 @@ static int adsp_start(struct rproc *rproc)
>>  	struct qcom_adsp *adsp = (struct qcom_adsp *)rproc->priv;
>>  	int ret;
>>
>> -	ret = regulator_enable(adsp->cx_supply);
>> +	ret = clk_prepare_enable(adsp->xo);
>>  	if (ret)
>>  		return ret;
>>
>> +	ret = regulator_enable(adsp->cx_supply);
>> +	if (ret)
>> +		goto disable_clocks;
>> +
>>  	ret = qcom_scm_pas_auth_and_reset(ADSP_PAS_ID);
>>  	if (ret) {
>>  		dev_err(adsp->dev,
>> @@ -126,6 +133,8 @@ static int adsp_start(struct rproc *rproc)
>>
>>  disable_regulators:
>>  	regulator_disable(adsp->cx_supply);
>> +disable_clocks:
>> +	clk_disable_unprepare(adsp->xo);
>>
>>  	return ret;
>>  }
>> @@ -223,6 +232,21 @@ static irqreturn_t adsp_stop_ack_interrupt(int irq, void *dev)
>>  	return IRQ_HANDLED;
>>  }
>>
>> +static int adsp_init_clock(struct qcom_adsp *adsp)
>> +{
>> +	int ret;
>> +
>> +	adsp->xo = devm_clk_get(adsp->dev, "xo");
>> +	if (IS_ERR(adsp->xo)) {
>> +		ret = PTR_ERR(adsp->xo);
>> +		if (ret != -EPROBE_DEFER)
>> +			dev_err(adsp->dev, "failed to get xo clock");
>> +		return ret;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>  static int adsp_init_regulator(struct qcom_adsp *adsp)
>>  {
>>  	adsp->cx_supply = devm_regulator_get(adsp->dev, "cx");
>> @@ -320,6 +344,10 @@ static int adsp_probe(struct platform_device *pdev)
>>  	if (ret)
>>  		goto free_rproc;
>>
>> +	ret = adsp_init_clock(adsp);
>> +	if (ret)
>> +		goto free_rproc;
>> +
>>  	ret = adsp_init_regulator(adsp);
>>  	if (ret)
>>  		goto free_rproc;
>> --
>> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
>> a Linux Foundation Collaborative Project
>>


-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

end of thread, other threads:[~2016-11-02 18:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 20:57 [PATCH v2 1/1] remoteproc: Add support for xo clock Sarangdhar Joshi
2016-10-25 21:03 ` Sarangdhar Joshi
2016-11-01  0:05 ` Bjorn Andersson
2016-11-01 17:41   ` Stephen Boyd
2016-11-01 17:46     ` Bjorn Andersson
2016-11-01 17:52       ` Stephen Boyd
2016-11-02 18:58   ` Sarangdhar Joshi

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).