mbox series

[00/13] Support CPU frequency scaling on QCS404

Message ID 1545039990-19984-1-git-send-email-jorge.ramirez-ortiz@linaro.org
Headers show
Series Support CPU frequency scaling on QCS404 | expand

Message

Jorge Ramirez-Ortiz Dec. 17, 2018, 9:46 a.m. UTC
The following patchset enables CPU frequency scaling support on the
QCS404.

Patch 8 "clk: qcom: hfpll: CLK_IGNORE_UNUSED" is a bit controversial;
in this platform, this PLL provides the clock signal to a CPU
core. But in others it might not.

I opted for the minimal ammount of changes without affecting the
default functionality: simply bypassing the COMMON_CLK_DISABLE_UNUSED
framework and letting the firwmare chose whether to enable or disable
the clock at boot. However maybe a DT property and marking the clock
as critical would be more appropriate for this PLL. I'd appreciate the
maintainer's input on this topic.

Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>
Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>


Jorge Ramirez-Ortiz (13):
  clk: qcom: gcc: limit GPLL0_AO_OUT operating frequency
  mbox: qcom: add APCS child device for QCS404
  mbox: qcom: replace integer with valid macro
  dt-bindings: mailbox: qcom: Add clock-name optional property
  clk: qcom: apcs-msm8916: get parent clock names from DT
  clk: qcom: hfpll: get parent clock names from DT
  clk: qcom: hfpll: register as clock provider
  clk: qcom: hfpll: CLK_IGNORE_UNUSED
  arm64: dts: qcom: qcs404: Add OPP table
  arm64: dts: qcom: qcs404: Add HFPLL node
  arm64: dts: qcom: qcs404: Add the clocks for APCS mux/divider
  arm64: dts: qcom: qcs404: Add cpufreq support
  arm64: defconfig: Enable HFPLL

 .../bindings/mailbox/qcom,apcs-kpss-global.txt     | 21 +++++++++++++
 arch/arm64/boot/dts/qcom/qcs404.dtsi               | 35 ++++++++++++++++++++++
 arch/arm64/configs/defconfig                       |  1 +
 drivers/clk/qcom/apcs-msm8916.c                    | 33 ++++++++++++++------
 drivers/clk/qcom/gcc-qcs404.c                      |  6 ++++
 drivers/clk/qcom/hfpll.c                           | 19 +++++++++++-
 drivers/mailbox/qcom-apcs-ipc-mailbox.c            | 21 ++++++++-----
 7 files changed, 118 insertions(+), 18 deletions(-)

-- 
2.7.4

Comments

Stephen Boyd Dec. 17, 2018, 7:39 p.m. UTC | #1
Quoting Jorge Ramirez-Ortiz (2018-12-17 01:46:27)
> The high frequency pll functionality is required to enable CPU

> frequency scaling operation.

> 

> Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

> ---

>  arch/arm64/boot/dts/qcom/qcs404.dtsi | 9 +++++++++

>  1 file changed, 9 insertions(+)

> 

> diff --git a/arch/arm64/boot/dts/qcom/qcs404.dtsi b/arch/arm64/boot/dts/qcom/qcs404.dtsi

> index 4594fea7..ec3f6c7 100644

> --- a/arch/arm64/boot/dts/qcom/qcs404.dtsi

> +++ b/arch/arm64/boot/dts/qcom/qcs404.dtsi

> @@ -375,6 +375,15 @@

>                         #mbox-cells = <1>;

>                 };

>  

> +               apcs_hfpll: clock-controller@0b016000 {


Drop leading 0 on unit address please.

> +                       compatible = "qcom,hfpll";

> +                       reg = <0x0b016000 0x30>;


Wow that is small!

> +                       #clock-cells = <0>;

> +                       clock-output-names = "apcs_hfpll";

> +                       clocks = <&xo_board>;

> +                       clock-names = "xo";

> +               };

> +
Taniya Das Dec. 21, 2018, 11:19 a.m. UTC | #2
On 12/17/2018 3:16 PM, Jorge Ramirez-Ortiz wrote:
> Limit the GPLL0_AO_OUT_MAIN operating frequency as per its hardware

> specifications.

> 

> Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

> ---

>   drivers/clk/qcom/gcc-qcs404.c | 6 ++++++

>   1 file changed, 6 insertions(+)

> 

> diff --git a/drivers/clk/qcom/gcc-qcs404.c b/drivers/clk/qcom/gcc-qcs404.c

> index 64da032..833436a 100644

> --- a/drivers/clk/qcom/gcc-qcs404.c

> +++ b/drivers/clk/qcom/gcc-qcs404.c

> @@ -304,10 +304,16 @@ static struct clk_alpha_pll gpll0_out_main = {

>   	},

>   };

>   

> +static const struct pll_vco gpll0_ao_out_vco[] = {

> +	{ 800000000, 800000000, 0 },

> +};

> +

>   static struct clk_alpha_pll gpll0_ao_out_main = {

>   	.offset = 0x21000,

>   	.regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT],

>   	.flags = SUPPORTS_FSM_MODE,

> +	.vco_table = gpll0_ao_out_vco,

> +	.num_vco = ARRAY_SIZE(gpll0_ao_out_vco),


Could you please help as to why this is required? This is a fixed PLL 
and we do not require a VCO table for it.

>   	.clkr = {

>   		.enable_reg = 0x45000,

>   		.enable_mask = BIT(0),

> 


-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.

--
Taniya Das Dec. 21, 2018, 5:58 p.m. UTC | #3
Hello,

On 12/21/2018 6:06 PM, Jorge Ramirez wrote:
> On 12/21/18 12:19, Taniya Das wrote:

>>

>>

>> On 12/17/2018 3:16 PM, Jorge Ramirez-Ortiz wrote:

>>> Limit the GPLL0_AO_OUT_MAIN operating frequency as per its hardware

>>> specifications.

>>>

>>> Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>

>>> Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

>>> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

>>> ---

>>>   drivers/clk/qcom/gcc-qcs404.c | 6 ++++++

>>>   1 file changed, 6 insertions(+)

>>>

>>> diff --git a/drivers/clk/qcom/gcc-qcs404.c 

>>> b/drivers/clk/qcom/gcc-qcs404.c

>>> index 64da032..833436a 100644

>>> --- a/drivers/clk/qcom/gcc-qcs404.c

>>> +++ b/drivers/clk/qcom/gcc-qcs404.c

>>> @@ -304,10 +304,16 @@ static struct clk_alpha_pll gpll0_out_main = {

>>>       },

>>>   };

>>>   +static const struct pll_vco gpll0_ao_out_vco[] = {

>>> +    { 800000000, 800000000, 0 },

>>> +};

>>> +

>>>   static struct clk_alpha_pll gpll0_ao_out_main = {

>>>       .offset = 0x21000,

>>>       .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT],

>>>       .flags = SUPPORTS_FSM_MODE,

>>> +    .vco_table = gpll0_ao_out_vco,

>>> +    .num_vco = ARRAY_SIZE(gpll0_ao_out_vco),

>>

>> Could you please help as to why this is required? This is a fixed PLL 

>> and we do not require a VCO table for it.

> 

> Hi Taniya,

> 

> this patch - the additional information that it provides about the 

> hardware - helps to select the right parent clock for a given frequency.

> 

> On the qcs404 this clock is one of the two parent clocks of the apcs 

> clock controller (the other one being the high frequency pll)

> When cpufreq sets a target frequency, there is an iteration through the 

> list of parents to select the one that delivers the best match.

> 

> When attempting to set the clock for an alpha_pll, the operation does a 

> sanity check to validate that the requested frequency is in fact 

> reachable using the vco range: trying to set a value that is not in 

> range will fail.

> 

> This patch makes sure that its range is explicitly defined.

> 

> It also helps making sure there are no rounding issues when setting its 

> value: without it the clock was being read at 799MHz

> 

> 


If the PLL is being read as 799MHz it would because not all the 40 bits 
of the ALPHA_VAL being programmed by the bootloaders(which are the 
original owners of this PLL). So we should go with the way they are 
being set by bootloaders and read by HLOS driver.

And a VCO range you have considered is wrong from a PLL perspective. As 
these are fixed PLLs and VCO range really does not matter here, so 
please drop this change.

>>

>>>       .clkr = {

>>>           .enable_reg = 0x45000,

>>>           .enable_mask = BIT(0),

>>>

>>

> 


-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation.

--
Jorge Ramirez-Ortiz Dec. 21, 2018, 7:45 p.m. UTC | #4
On 12/21/18 20:28, Bjorn Andersson wrote:
> On Fri 21 Dec 09:58 PST 2018, Taniya Das wrote:

>

>> Hello,

>>

>> On 12/21/2018 6:06 PM, Jorge Ramirez wrote:

>>> On 12/21/18 12:19, Taniya Das wrote:

>>>>

>>>> On 12/17/2018 3:16 PM, Jorge Ramirez-Ortiz wrote:

>>>>> Limit the GPLL0_AO_OUT_MAIN operating frequency as per its hardware

>>>>> specifications.

>>>>>

>>>>> Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>

>>>>> Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

>>>>> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

>>>>> ---

>>>>>    drivers/clk/qcom/gcc-qcs404.c | 6 ++++++

>>>>>    1 file changed, 6 insertions(+)

>>>>>

>>>>> diff --git a/drivers/clk/qcom/gcc-qcs404.c

>>>>> b/drivers/clk/qcom/gcc-qcs404.c

>>>>> index 64da032..833436a 100644

>>>>> --- a/drivers/clk/qcom/gcc-qcs404.c

>>>>> +++ b/drivers/clk/qcom/gcc-qcs404.c

>>>>> @@ -304,10 +304,16 @@ static struct clk_alpha_pll gpll0_out_main = {

>>>>>        },

>>>>>    };

>>>>>    +static const struct pll_vco gpll0_ao_out_vco[] = {

>>>>> +    { 800000000, 800000000, 0 },

>>>>> +};

>>>>> +

>>>>>    static struct clk_alpha_pll gpll0_ao_out_main = {

>>>>>        .offset = 0x21000,

>>>>>        .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT],

>>>>>        .flags = SUPPORTS_FSM_MODE,

>>>>> +    .vco_table = gpll0_ao_out_vco,

>>>>> +    .num_vco = ARRAY_SIZE(gpll0_ao_out_vco),

>>>> Could you please help as to why this is required? This is a fixed

>>>> PLL and we do not require a VCO table for it.

>>> Hi Taniya,

>>>

>>> this patch - the additional information that it provides about the

>>> hardware - helps to select the right parent clock for a given frequency.

>>>

>>> On the qcs404 this clock is one of the two parent clocks of the apcs

>>> clock controller (the other one being the high frequency pll)

>>> When cpufreq sets a target frequency, there is an iteration through the

>>> list of parents to select the one that delivers the best match.

>>>

>>> When attempting to set the clock for an alpha_pll, the operation does a

>>> sanity check to validate that the requested frequency is in fact

>>> reachable using the vco range: trying to set a value that is not in

>>> range will fail.

>>>

>>> This patch makes sure that its range is explicitly defined.

>>>

>>> It also helps making sure there are no rounding issues when setting its

>>> value: without it the clock was being read at 799MHz

>>>

>>>

>> If the PLL is being read as 799MHz it would because not all the 40 bits of

>> the ALPHA_VAL being programmed by the bootloaders(which are the original

>> owners of this PLL). So we should go with the way they are being set by

>> bootloaders and read by HLOS driver.

>>

>> And a VCO range you have considered is wrong from a PLL perspective. As

>> these are fixed PLLs and VCO range really does not matter here, so please

>> drop this change.

>>

> The problem here is that the PLL should be fixed at 800MHz, but the

> alpha PLL is defined such that it can change. So when the mux-div is

> looking for a suitable parent and divider for our CPU clock it concludes

> that the best way to reach certain frequencies is to change the rate of

> GPLL0.

>

> Adding the vco_table limits the available frequencies for GPLL0 in

> QCS404, without modifying the implementation of the alpha PLL.

>

> Perhaps there's a better way to define that this particular clock

> hardware can change rate, but in this implementation it must not?


the initialization for this particular PLL on this particular platform 
is wrong
as the interface does not apply to the platform needs even though it is an
alpha_pll

if the VCO is not an option -even though it reflects the platform 
constrains-
I would suggest nullifying the alpha_pll_ops that do not apply to this 
platform:
ie: set_rate, round_rate set to null in the probe.

allowing the interface calls (ops) to go through to later on make them fail
based on some setting would be fundamentally wrong IMO












>

> Regards,

> Bjorn

>
Stephen Boyd Dec. 21, 2018, 9:40 p.m. UTC | #5
Quoting Jorge Ramirez (2018-12-21 11:45:28)
> On 12/21/18 20:28, Bjorn Andersson wrote:

> >

> > Perhaps there's a better way to define that this particular clock

> > hardware can change rate, but in this implementation it must not?

> 

> the initialization for this particular PLL on this particular platform 

> is wrong

> as the interface does not apply to the platform needs even though it is an

> alpha_pll

> 

> if the VCO is not an option -even though it reflects the platform 

> constrains-

> I would suggest nullifying the alpha_pll_ops that do not apply to this 

> platform:

> ie: set_rate, round_rate set to null in the probe.

> 

> allowing the interface calls (ops) to go through to later on make them fail

> based on some setting would be fundamentally wrong IMO

> 


We have clk_alpha_pll_postdiv_ro_ops so maybe just add another set of
those for the alpha_pll itself?
Jorge Ramirez-Ortiz Dec. 21, 2018, 9:45 p.m. UTC | #6
On 12/21/18 22:40, Stephen Boyd wrote:
> Quoting Jorge Ramirez (2018-12-21 11:45:28)

>> On 12/21/18 20:28, Bjorn Andersson wrote:

>>> Perhaps there's a better way to define that this particular clock

>>> hardware can change rate, but in this implementation it must not?

>> the initialization for this particular PLL on this particular platform

>> is wrong

>> as the interface does not apply to the platform needs even though it is an

>> alpha_pll

>>

>> if the VCO is not an option -even though it reflects the platform

>> constrains-

>> I would suggest nullifying the alpha_pll_ops that do not apply to this

>> platform:

>> ie: set_rate, round_rate set to null in the probe.

>>

>> allowing the interface calls (ops) to go through to later on make them fail

>> based on some setting would be fundamentally wrong IMO

>>

> We have clk_alpha_pll_postdiv_ro_ops so maybe just add another set of

> those for the alpha_pll itself?

>

>


something like 
clk_alpha_pll_fixed_ops?
Stephen Boyd Dec. 21, 2018, 9:51 p.m. UTC | #7
Quoting Jorge Ramirez (2018-12-21 13:45:41)
> On 12/21/18 22:40, Stephen Boyd wrote:

> > Quoting Jorge Ramirez (2018-12-21 11:45:28)

> >> On 12/21/18 20:28, Bjorn Andersson wrote:

> >>> Perhaps there's a better way to define that this particular clock

> >>> hardware can change rate, but in this implementation it must not?

> >> the initialization for this particular PLL on this particular platform

> >> is wrong

> >> as the interface does not apply to the platform needs even though it is an

> >> alpha_pll

> >>

> >> if the VCO is not an option -even though it reflects the platform

> >> constrains-

> >> I would suggest nullifying the alpha_pll_ops that do not apply to this

> >> platform:

> >> ie: set_rate, round_rate set to null in the probe.

> >>

> >> allowing the interface calls (ops) to go through to later on make them fail

> >> based on some setting would be fundamentally wrong IMO

> >>

> > We have clk_alpha_pll_postdiv_ro_ops so maybe just add another set of

> > those for the alpha_pll itself?

> >

> >

> 

> something like 

> clk_alpha_pll_fixed_ops?


Either way works. We're not consistent in naming now that we have
clk_alpha_pll_fixed_fabia_ops.
Bjorn Andersson Jan. 17, 2019, 6:25 a.m. UTC | #8
On Mon 17 Dec 01:46 PST 2018, Jorge Ramirez-Ortiz wrote:

> There is clock controller functionality in the APCS hardware block of

> qcs404 devices similar to msm8916.

> 


Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>


> Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

> ---

>  drivers/mailbox/qcom-apcs-ipc-mailbox.c | 21 +++++++++++++--------

>  1 file changed, 13 insertions(+), 8 deletions(-)

> 

> diff --git a/drivers/mailbox/qcom-apcs-ipc-mailbox.c b/drivers/mailbox/qcom-apcs-ipc-mailbox.c

> index aed23ac..dc8fdab1 100644

> --- a/drivers/mailbox/qcom-apcs-ipc-mailbox.c

> +++ b/drivers/mailbox/qcom-apcs-ipc-mailbox.c

> @@ -97,16 +97,21 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)

>  		return ret;

>  	}

>  

> -	if (of_device_is_compatible(np, "qcom,msm8916-apcs-kpss-global")) {

> -		apcs->clk = platform_device_register_data(&pdev->dev,

> -							  "qcom-apcs-msm8916-clk",

> -							  -1, NULL, 0);

> -		if (IS_ERR(apcs->clk))

> -			dev_err(&pdev->dev, "failed to register APCS clk\n");

> -	}

> -

>  	platform_set_drvdata(pdev, apcs);

>  

> +	if (of_device_is_compatible(np, "qcom,msm8916-apcs-kpss-global") ||

> +	    of_device_is_compatible(np, "qcom,qcs404-apcs-apps-global"))

> +		goto register_clk;

> +

> +	return 0;

> +

> +register_clk:

> +	apcs->clk = platform_device_register_data(&pdev->dev,

> +						  "qcom-apcs-msm8916-clk",

> +						  -1, NULL, 0);

> +	if (IS_ERR(apcs->clk))

> +		dev_err(&pdev->dev, "failed to register APCS clk\n");

> +

>  	return 0;

>  }

>  

> -- 

> 2.7.4

>
Bjorn Andersson Jan. 17, 2019, 6:25 a.m. UTC | #9
On Mon 17 Dec 01:46 PST 2018, Jorge Ramirez-Ortiz wrote:

> Use the correct macro when registering the platform device.

> 


Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>


> Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

> Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

> ---

>  drivers/mailbox/qcom-apcs-ipc-mailbox.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/drivers/mailbox/qcom-apcs-ipc-mailbox.c b/drivers/mailbox/qcom-apcs-ipc-mailbox.c

> index dc8fdab1..b782173 100644

> --- a/drivers/mailbox/qcom-apcs-ipc-mailbox.c

> +++ b/drivers/mailbox/qcom-apcs-ipc-mailbox.c

> @@ -108,7 +108,7 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)

>  register_clk:

>  	apcs->clk = platform_device_register_data(&pdev->dev,

>  						  "qcom-apcs-msm8916-clk",

> -						  -1, NULL, 0);

> +						  PLATFORM_DEVID_NONE, NULL, 0);

>  	if (IS_ERR(apcs->clk))

>  		dev_err(&pdev->dev, "failed to register APCS clk\n");

>  

> -- 

> 2.7.4

>
Bjorn Andersson Jan. 17, 2019, 6:38 a.m. UTC | #10
On Mon 17 Dec 11:39 PST 2018, Stephen Boyd wrote:

> Quoting Jorge Ramirez-Ortiz (2018-12-17 01:46:27)

> > The high frequency pll functionality is required to enable CPU

> > frequency scaling operation.

> > 

> > Co-developed-by: Niklas Cassel <niklas.cassel@linaro.org>

> > Signed-off-by: Niklas Cassel <niklas.cassel@linaro.org>

> > Signed-off-by: Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org>

> > ---

> >  arch/arm64/boot/dts/qcom/qcs404.dtsi | 9 +++++++++

> >  1 file changed, 9 insertions(+)

> > 

> > diff --git a/arch/arm64/boot/dts/qcom/qcs404.dtsi b/arch/arm64/boot/dts/qcom/qcs404.dtsi

> > index 4594fea7..ec3f6c7 100644

> > --- a/arch/arm64/boot/dts/qcom/qcs404.dtsi

> > +++ b/arch/arm64/boot/dts/qcom/qcs404.dtsi

> > @@ -375,6 +375,15 @@

> >                         #mbox-cells = <1>;

> >                 };

> >  

> > +               apcs_hfpll: clock-controller@0b016000 {

> 

> Drop leading 0 on unit address please.

> 

> > +                       compatible = "qcom,hfpll";

> > +                       reg = <0x0b016000 0x30>;

> 

> Wow that is small!

> 


I double checked and it's actually 0x34, but the last register is
protected.

Regards,
Bjorn

> > +                       #clock-cells = <0>;

> > +                       clock-output-names = "apcs_hfpll";

> > +                       clocks = <&xo_board>;

> > +                       clock-names = "xo";

> > +               };

> > +