cpufreq: dt: disable unsupported OPPs
Subsystems (7)
PATCH v2 1/6 cpufreq: dt: disable unsupported OPPs
If the regulator connected to the CPU voltage plane doesn't support an OPP specified voltage with the acceptable tolerance it's better to just disable the OPP instead of constantly failing the voltage scaling later on.
---
v2:
- rebase on top of pm/linux-next
--- drivers/cpufreq/cpufreq-dt.c | 66 +++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 26 deletions(-)
drivers/cpufreq/cpufreq-dt.c +40 -26
@@ -185,6 +185,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)struct device *cpu_dev;struct regulator *cpu_reg;struct clk *cpu_clk; +unsigned long min_uV = ~0 , max_uV =0 ;unsigned int transition_latency;int ret;
@@ -204,16 +205,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)/* OPPs might be populated at runtime, don't check for error here */ of_init_opp_table (cpu_dev); - ret =dev_pm_opp_init_cpufreq_table (cpu_dev, &freq_table); -if (ret) { -dev_err (cpu_dev,"failed to init cpufreq table: %d\n" , ret); - goto out_put_node; - } - priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (!priv) { ret = -ENOMEM ; - goto out_free_table; + goto out_put_node; }of_property_read_u32 (np,"voltage-tolerance" , &priv->voltage_tolerance);
@@ -222,30 +217,49 @@ static int cpufreq_init(struct cpufreq_policy *policy) transition_latency =CPUFREQ_ETERNAL ;if (!IS_ERR (cpu_reg)) { -struct dev_pm_opp *opp; -unsigned long min_uV, max_uV; -int i; -/* -* OPP is maintained in order of increasing frequency, and -* freq_table initialised from OPP is therefore sorted in the -* same order. +* Disable any OPPs where the connected regulator isn't able to +* provide the specified voltage and record minimum and maximum +* voltage levels. */ -for (i =0 ; freq_table[i].frequency !=CPUFREQ_TABLE_END ; i++) - ; -rcu_read_lock (); - opp =dev_pm_opp_find_freq_exact (cpu_dev, - freq_table[0 ].frequency *1000 , true); - min_uV =dev_pm_opp_get_voltage (opp); - opp =dev_pm_opp_find_freq_exact (cpu_dev, - freq_table[i-1 ].frequency *1000 , true); - max_uV =dev_pm_opp_get_voltage (opp); -rcu_read_unlock (); +while (1 ) { +struct dev_pm_opp *opp; +unsigned long opp_freq =0 , opp_uV, tol_uV; + +rcu_read_lock (); + opp =dev_pm_opp_find_freq_ceil (cpu_dev, &opp_freq); +if (IS_ERR (opp)) { +rcu_read_unlock (); +break ; + } + opp_uV =dev_pm_opp_get_voltage (opp); +rcu_read_unlock (); + + tol_uV = opp_uV * priv->voltage_tolerance /100 ; +if (regulator_is_supported_voltage (cpu_reg, opp_uV, + opp_uV + tol_uV)) { +if (opp_uV < min_uV) + min_uV = opp_uV; +if (opp_uV > max_uV) + max_uV = opp_uV; + }else { +dev_pm_opp_disable (cpu_dev, opp_freq); + } + + opp_freq++; + } + ret =regulator_set_voltage_time (cpu_reg, min_uV, max_uV);if (ret >0 ) transition_latency += ret *1000 ; } + ret =dev_pm_opp_init_cpufreq_table (cpu_dev, &freq_table); +if (ret) { +pr_err ("failed to init cpufreq table: %d\n" , ret); + goto out_free_priv; + } +/* * For now, just loading the cooling device; * thermal DT code takes care of matching them.
@@ -275,9 +289,9 @@ static int cpufreq_init(struct cpufreq_policy *policy) out_cooling_unregister:cpufreq_cooling_unregister (priv->cdev); -kfree (priv); -out_free_table:dev_pm_opp_free_cpufreq_table (cpu_dev, &freq_table); +out_free_priv: +kfree (priv); out_put_node:of_node_put (np); out_put_reg_clk:
Signature · 1 line
2.1.0
PATCH v2 2/6 clk: imx5: add step clock, used when reprogramming PLL1
This is the bypass clock used to feed the ARM partition while we reprogram PLL1 to another rate.
--- arch/arm/mach-imx/clk-imx51-imx53.c | 9 ++++++++- include/dt-bindings/clock/imx5-clock.h | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-)
arch/arm/mach-imx/clk-imx51-imx53.c +8 -1
@@ -125,6 +125,8 @@ static const char *mx53_spdif_xtal_sel[] = { "osc", "ckih", "ckih2", "pll4_sw",static const char *spdif_sel[] = {"pll1_sw" ,"pll2_sw" ,"pll3_sw" ,"spdif_xtal_sel" , };static const char *spdif0_com_sel[] = {"spdif0_podf" ,"ssi1_root_gate" , };static const char *mx51_spdif1_com_sel[] = {"spdif1_podf" ,"ssi2_root_gate" , }; +static const char *step_sels[] = {"lp_apm" , }; +static const char *cpu_podf_sels[] = {"pll1_sw" ,"step_sel" };static struct clk *clk[IMX5_CLK_END ];static struct clk_onecell_data clk_data;
@@ -193,7 +195,9 @@ static void __init mx5_clocks_common_init(void __iomem *ccm_base) clk[IMX5_CLK_USB_PHY_PODF ] =imx_clk_divider ("usb_phy_podf" ,"usb_phy_pred" ,MXC_CCM_CDCDR ,0 ,3 ); clk[IMX5_CLK_USB_PHY_SEL ] =imx_clk_mux ("usb_phy_sel" ,MXC_CCM_CSCMR1 ,26 ,1 , usb_phy_sel_str,ARRAY_SIZE (usb_phy_sel_str)); - clk[IMX5_CLK_CPU_PODF ] =imx_clk_divider ("cpu_podf" ,"pll1_sw" ,MXC_CCM_CACRR ,0 ,3 ); + clk[IMX5_CLK_STEP_SEL ] =imx_clk_mux ("step_sel" ,MXC_CCM_CCSR ,7 ,2 , step_sels,ARRAY_SIZE (step_sels)); + clk[IMX5_CLK_CPU_PODF_SEL ] =imx_clk_mux ("cpu_podf_sel" ,MXC_CCM_CCSR ,2 ,1 , cpu_podf_sels,ARRAY_SIZE (cpu_podf_sels)); + clk[IMX5_CLK_CPU_PODF ] =imx_clk_divider ("cpu_podf" ,"cpu_podf_sel" ,MXC_CCM_CACRR ,0 ,3 ); clk[IMX5_CLK_DI_PRED ] =imx_clk_divider ("di_pred" ,"pll3_sw" ,MXC_CCM_CDCDR ,6 ,3 ); clk[IMX5_CLK_IIM_GATE ] =imx_clk_gate2 ("iim_gate" ,"ipg" ,MXC_CCM_CCGR0 ,30 ); clk[IMX5_CLK_UART1_IPG_GATE ] =imx_clk_gate2 ("uart1_ipg_gate" ,"ipg" ,MXC_CCM_CCGR1 ,6 );
@@ -551,6 +555,9 @@ static void __init mx53_clocks_init(struct device_node *np)/* move can bus clk to 24MHz */ clk_set_parent (clk[IMX5_CLK_CAN_SEL ], clk[IMX5_CLK_LP_APM ]); +/* make sure step clock is running from 24MHz */ +clk_set_parent (clk[IMX5_CLK_STEP_SEL ], clk[IMX5_CLK_LP_APM ]); +clk_prepare_enable (clk[IMX5_CLK_IIM_GATE ]);imx_print_silicon_rev ("i.MX53" ,mx53_revision ());clk_disable_unprepare (clk[IMX5_CLK_IIM_GATE ]);
include/dt-bindings/clock/imx5-clock.h +3 -1
@@ -198,6 +198,8 @@#define IMX5_CLK_OCRAM 186#define IMX5_CLK_SAHARA_IPG_GATE 187#define IMX5_CLK_SATA_REF 188 -#define IMX5_CLK_END 189 +#define IMX5_CLK_STEP_SEL 189 +#define IMX5_CLK_CPU_PODF_SEL 190 +#define IMX5_CLK_END 191#endif /* __DT_BINDINGS_CLOCK_IMX5_H */
Signature · 1 line
2.1.0
PATCH v2 2/6 clk: imx5: add step clock, used when reprogramming PLL1
Quoted 7 lines · Lucas Stach
This is the bypass clock used to feed the ARM partition while we reprogram PLL1 to another rate.
Signed-off-by Philipp Zabel <[email protected]>Signed-off-by Lucas Stach <[email protected]>--- arch/arm/mach-imx/clk-imx51-imx53.c | 9 ++++++++-
This is a patch touching arch/arm/ file, so should be prefixed with "ARM". I fixed those prefix up and applied patch 2-5.
Shawn
Quoted 2 lines
include/dt-bindings/clock/imx5-clock.h | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-)
PATCH v2 3/6 clk: imx: add CPU clock type
In reply to Lucas StachThis implements a virtual clock used to abstract away all the steps needed in order to change the ARM clock, so we don't have to push all this clock handling into the cpufreq driver.
While it will be used for i.MX53 at first it is generic enough to be used on i.MX6 later on.
---
v2:
- split clk into multiple line
- fix my email address
--- arch/arm/mach-imx/Makefile | 2 +- arch/arm/mach-imx/clk-cpu.c | 107 ++++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-imx/clk.h | 4 ++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-imx/clk-cpu.c
arch/arm/mach-imx/Makefile +1 -1
@@ -12,7 +12,7 @@ obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci- obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clk-imx35.o ehci-imx35.o pm-imx3.o imx5-pm-$(CONFIG_PM) += pm-imx5.o -obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o clk-imx51-imx53.o $(imx5-pm-y) +obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o clk-imx51-imx53.o clk-cpu.o $(imx5-pm-y) obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o \ clk-pfd.o clk-busy.o clk.o \
arch/arm/mach-imx/clk-cpu.c new file +107 -0
107 lines not on this page · raw message
arch/arm/mach-imx/clk.h +4 -0
@@ -128,4 +128,8 @@ static inline struct clk *imx_clk_fixed_factor(const char *name, CLK_SET_RATE_PARENT, mult, div); } +struct clk *imx_clk_cpu (const char *name,const char *parent_name, +struct clk *div,struct clk *mux,struct clk *pll, +struct clk *step); +#endif
Signature · 1 line
2.1.0
PATCH v2 4/6 arm: imx53: clk: add ARM clock
In reply to Lucas StachThe ARM clock is a virtual clock feeding the ARM partition of the SoC. It controls multiple other clocks to ensure the right sequencing when cpufreq changes the CPU clock rate.
--- arch/arm/mach-imx/clk-imx51-imx53.c | 5 +++++ include/dt-bindings/clock/imx5-clock.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-)
arch/arm/mach-imx/clk-imx51-imx53.c +5 -0
@@ -541,6 +541,11 @@ static void __init mx53_clocks_init(struct device_node *np) clk[IMX5_CLK_CKO2 ] =imx_clk_gate2 ("cko2" ,"cko2_podf" ,MXC_CCM_CCOSR ,24 ); clk[IMX5_CLK_SPDIF_XTAL_SEL ] =imx_clk_mux ("spdif_xtal_sel" ,MXC_CCM_CSCMR1 ,2 ,2 , mx53_spdif_xtal_sel,ARRAY_SIZE (mx53_spdif_xtal_sel)); + clk[IMX5_CLK_ARM ] =imx_clk_cpu ("arm" ,"cpu_podf" , + clk[IMX5_CLK_CPU_PODF ], + clk[IMX5_CLK_CPU_PODF_SEL ], + clk[IMX5_CLK_PLL1_SW ], + clk[IMX5_CLK_STEP_SEL ]);imx_check_clocks (clk,ARRAY_SIZE (clk));
include/dt-bindings/clock/imx5-clock.h +2 -1
@@ -200,6 +200,7 @@#define IMX5_CLK_SATA_REF 188#define IMX5_CLK_STEP_SEL 189#define IMX5_CLK_CPU_PODF_SEL 190 -#define IMX5_CLK_END 191 +#define IMX5_CLK_ARM 191 +#define IMX5_CLK_END 192#endif /* __DT_BINDINGS_CLOCK_IMX5_H */
Signature · 1 line
2.1.0
PATCH v2 5/6 ARM: dts: imx53: add cpufreq-dt support
In reply to Lucas StachAdd all required properties for the cpufreq-dt driver.
---
v2:
- split out device instantiation
--- arch/arm/boot/dts/imx53.dtsi | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
arch/arm/boot/dts/imx53.dtsi +12 -1
@@ -46,10 +46,21 @@ cpus { #address-cells = <1>; #size-cells = <0>; - cpu at 0 { + cpu0: cpu at 0 { device_type = "cpu"; compatible = "arm,cortex-a8"; reg = <0x0>; + clocks = <&clks IMX5_CLK_ARM>; + clock-latency = <61036>; + voltage-tolerance = <5>; + operating-points = < + /* kHz */ + 166666 850000 + 400000 900000 + 800000 1050000 + 1000000 1200000 + 1200000 1300000 + >; }; };
Signature · 1 line
2.1.0
PATCH v2 5/6 ARM: dts: imx53: add cpufreq-dt support
Hi Lucas,
i know the patch is already applied, but ...
Quoted 23 lines
Lucas Stach <[email protected]> hat am 26. September 2014 um 15:41 geschrieben:
Add all required properties for the cpufreq-dt driver.
Signed-off-by Lucas Stach <[email protected]>---
v2:
- split out device instantiation
---arch/arm/boot/dts/imx53.dtsi| 13 ++++++++++++-1 file changed, 12 insertions(+), 1 deletion(-)arch/arm/boot/dts/imx53.dtsi +0
-1@@ -46,10 +46,21 @@ cpus { #address-cells = <1>; #size-cells = <0>; - cpu at 0 {
arch/arm/boot/dts/imx53.dtsi line 58
Quoted 10 lines
arch/arm/boot/dts/imx53.dtsi +7
-0+ cpu0: cpu at 0 { device_type = "cpu"; compatible = "arm,cortex-a8"; reg = <0x0>; + clocks = <&clks IMX5_CLK_ARM>; + clock-latency = <61036>; + voltage-tolerance = <5>; + operating-points = < + /* kHz */ + 166666 850000
shouldn't it be "166667 850000"?
I ran into the same issue on i.MX28. If i round down the frequencies the voltage of the next higher OPP will be set.
Best regards
Stefan
Quoted 16 lines
arch/arm/boot/dts/imx53.dtsi +5
-1+ 400000 900000 + 800000 1050000 + 1000000 1200000 + 1200000 1300000 + >; }; }; --2.1.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 6/6 ARM: imx53: add cpufreq support
In reply to Lucas StachInstanciate device for the generic cpufreq-dt driver.
---
v2:
- new patch, split out from DTS changes and rebased with new name for cpufreq driver
--- arch/arm/mach-imx/mach-imx53.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-imx/mach-imx53.c +2 -0
@@ -41,6 +41,8 @@ static void __init imx53_dt_init(void)static void __init imx53_init_late (void ) {imx53_pm_init (); + +platform_device_register_simple ("cpufreq-dt" ,-1 ,NULL ,0 ); }static const char *const imx53_dt_board_compat[]__initconst = {
Signature · 1 line
2.1.0
PATCH v2 6/6 ARM: imx53: add cpufreq support
Quoted 3 lines · Lucas Stach
Instanciate device for the generic cpufreq-dt driver.
Signed-off-by Lucas Stach <[email protected]>
I assume that I should only apply this patch after the cpufreq-dt change gets merged and shows up on my base.
Shawn
Quoted 24 lines
---
v2:
- new patch, split out from DTS changes and rebased with new name for cpufreq driver--- arch/arm/mach-imx/mach-imx53.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-imx/mach-imx53.c +2
-0@@ -41,6 +41,8 @@ static void __init imx53_dt_init(void)static void __init imx53_init_late (void ) {imx53_pm_init (); + +platform_device_register_simple ("cpufreq-dt" ,-1 ,NULL ,0 ); }static const char *const imx53_dt_board_compat[]__initconst = {Signature · 1 line
2.1.0
PATCH v2 6/6 ARM: imx53: add cpufreq support
Am Sonntag, den 28.09.2014, 12:15 +0800 schrieb Shawn Guo:
Quoted 10 lines · Lucas Stach
Quoted 3 lines
Instanciate device for the generic cpufreq-dt driver.
Signed-off-by Lucas Stach <[email protected]>I assume that I should only apply this patch after the cpufreq-dt change gets merged and shows up on my base.
Shawn
I would think its safe to merge this patch. The cpufreq-dt change will be merged with 3.18. Until then the worst that could happen is that the cpufreq driver doesn't bind to the mx5 cpu device.
Quoted 28 lines
Quoted 24 lines
---
v2:
- new patch, split out from DTS changes and rebased with new name for cpufreq driver--- arch/arm/mach-imx/mach-imx53.c | 2 ++ 1 file changed, 2 insertions(+)arch/arm/mach-imx/mach-imx53.c +2
-0@@ -41,6 +41,8 @@ static void __init imx53_dt_init(void)static void __init imx53_init_late (void ) {imx53_pm_init (); + +platform_device_register_simple ("cpufreq-dt" ,-1 ,NULL ,0 ); }static const char *const imx53_dt_board_compat[]__initconst = {Signature · 1 line
2.1.0--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ |
Shawn Guo
AppliedPATCH v2 6/6 ARM: imx53: add cpufreq support
Quoted 6 lines · Lucas Stach
Am Sonntag, den 28.09.2014, 12:15 +0800 schrieb Shawn Guo:
Quoted 5 lines · Lucas Stach
Quoted 3 lines
Instanciate device for the generic cpufreq-dt driver.
Signed-off-by Lucas Stach <[email protected]>
Quoted 8 lines
Quoted 5 lines
I assume that I should only apply this patch after the cpufreq-dt change gets merged and shows up on my base.
Shawn
I would think its safe to merge this patch. The cpufreq-dt change will be merged with 3.18. Until then the worst that could happen is that the cpufreq driver doesn't bind to the mx5 cpu device.
Ah, right. The device will not bind on my tree, so it's safe to apply it right away.
Applied, thanks.
PATCH v2 1/6 cpufreq: dt: disable unsupported OPPs
In reply to Lucas StachQuoted 6 lines · Lucas Stach
If the regulator connected to the CPU voltage plane doesn't support an OPP specified voltage with the acceptable tolerance it's better to just disable the OPP instead of constantly failing the voltage scaling later on.
Signed-off-by Lucas Stach <[email protected]>
Why do you need this to be part of the whole series? Is there any hard dependency on it?
Quoted 117 lines
---
v2:
- rebase on top of pm/linux-next--- drivers/cpufreq/cpufreq-dt.c | 66 +++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 26 deletions(-)drivers/cpufreq/cpufreq-dt.c +40
-26@@ -185,6 +185,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)struct device *cpu_dev;struct regulator *cpu_reg;struct clk *cpu_clk; +unsigned long min_uV = ~0 , max_uV =0 ;unsigned int transition_latency;int ret;@@ -204,16 +205,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)/* OPPs might be populated at runtime, don't check for error here */ of_init_opp_table (cpu_dev); - ret =dev_pm_opp_init_cpufreq_table (cpu_dev, &freq_table); -if (ret) { -dev_err (cpu_dev,"failed to init cpufreq table: %d\n" , ret); - goto out_put_node; - } - priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (!priv) { ret = -ENOMEM ; - goto out_free_table; + goto out_put_node; }of_property_read_u32 (np,"voltage-tolerance" , &priv->voltage_tolerance);@@ -222,30 +217,49 @@ static int cpufreq_init(struct cpufreq_policy *policy) transition_latency =CPUFREQ_ETERNAL ;if (!IS_ERR (cpu_reg)) { -struct dev_pm_opp *opp; -unsigned long min_uV, max_uV; -int i; -/* -* OPP is maintained in order of increasing frequency, and -* freq_table initialised from OPP is therefore sorted in the -* same order. +* Disable any OPPs where the connected regulator isn't able to +* provide the specified voltage and record minimum and maximum +* voltage levels. */ -for (i =0 ; freq_table[i].frequency !=CPUFREQ_TABLE_END ; i++) - ; -rcu_read_lock (); - opp =dev_pm_opp_find_freq_exact (cpu_dev, - freq_table[0 ].frequency *1000 , true); - min_uV =dev_pm_opp_get_voltage (opp); - opp =dev_pm_opp_find_freq_exact (cpu_dev, - freq_table[i-1 ].frequency *1000 , true); - max_uV =dev_pm_opp_get_voltage (opp); -rcu_read_unlock (); +while (1 ) { +struct dev_pm_opp *opp; +unsigned long opp_freq =0 , opp_uV, tol_uV; + +rcu_read_lock (); + opp =dev_pm_opp_find_freq_ceil (cpu_dev, &opp_freq); +if (IS_ERR (opp)) { +rcu_read_unlock (); +break ; + } + opp_uV =dev_pm_opp_get_voltage (opp); +rcu_read_unlock (); + + tol_uV = opp_uV * priv->voltage_tolerance /100 ; +if (regulator_is_supported_voltage (cpu_reg, opp_uV, + opp_uV + tol_uV)) { +if (opp_uV < min_uV) + min_uV = opp_uV; +if (opp_uV > max_uV) + max_uV = opp_uV; + }else { +dev_pm_opp_disable (cpu_dev, opp_freq); + } + + opp_freq++; + } + ret =regulator_set_voltage_time (cpu_reg, min_uV, max_uV);if (ret >0 ) transition_latency += ret *1000 ; } + ret =dev_pm_opp_init_cpufreq_table (cpu_dev, &freq_table); +if (ret) { +pr_err ("failed to init cpufreq table: %d\n" , ret); + goto out_free_priv; + } +/* * For now, just loading the cooling device; * thermal DT code takes care of matching them. @@ -275,9 +289,9 @@ static int cpufreq_init(struct cpufreq_policy *policy) out_cooling_unregister:cpufreq_cooling_unregister (priv->cdev); -kfree (priv); -out_free_table:dev_pm_opp_free_cpufreq_table (cpu_dev, &freq_table); +out_free_priv: +kfree (priv); out_put_node:of_node_put (np); out_put_reg_clk:
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
PATCH v2 1/6 cpufreq: dt: disable unsupported OPPs
Am Freitag, den 26.09.2014, 23:55 +0200 schrieb Rafael J. Wysocki:
Quoted 11 lines · Lucas Stach
Quoted 6 lines
If the regulator connected to the CPU voltage plane doesn't support an OPP specified voltage with the acceptable tolerance it's better to just disable the OPP instead of constantly failing the voltage scaling later on.
Signed-off-by Lucas Stach <[email protected]>Why do you need this to be part of the whole series? Is there any hard dependency on it?
No there isn't any hard dependency. It's just that one of the boards I was testing this series with needs this to properly disable one invalid OPP.
So it's no problem to rip this one out of the series. Sorry for the confusion.
Quoted 118 lines
Quoted 117 lines
---
v2:
- rebase on top of pm/linux-next--- drivers/cpufreq/cpufreq-dt.c | 66 +++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 26 deletions(-)drivers/cpufreq/cpufreq-dt.c +40
-26@@ -185,6 +185,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)struct device *cpu_dev;struct regulator *cpu_reg;struct clk *cpu_clk; +unsigned long min_uV = ~0 , max_uV =0 ;unsigned int transition_latency;int ret;@@ -204,16 +205,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)/* OPPs might be populated at runtime, don't check for error here */ of_init_opp_table (cpu_dev); - ret =dev_pm_opp_init_cpufreq_table (cpu_dev, &freq_table); -if (ret) { -dev_err (cpu_dev,"failed to init cpufreq table: %d\n" , ret); - goto out_put_node; - } - priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (!priv) { ret = -ENOMEM ; - goto out_free_table; + goto out_put_node; }of_property_read_u32 (np,"voltage-tolerance" , &priv->voltage_tolerance);@@ -222,30 +217,49 @@ static int cpufreq_init(struct cpufreq_policy *policy) transition_latency =CPUFREQ_ETERNAL ;if (!IS_ERR (cpu_reg)) { -struct dev_pm_opp *opp; -unsigned long min_uV, max_uV; -int i; -/* -* OPP is maintained in order of increasing frequency, and -* freq_table initialised from OPP is therefore sorted in the -* same order. +* Disable any OPPs where the connected regulator isn't able to +* provide the specified voltage and record minimum and maximum +* voltage levels. */ -for (i =0 ; freq_table[i].frequency !=CPUFREQ_TABLE_END ; i++) - ; -rcu_read_lock (); - opp =dev_pm_opp_find_freq_exact (cpu_dev, - freq_table[0 ].frequency *1000 , true); - min_uV =dev_pm_opp_get_voltage (opp); - opp =dev_pm_opp_find_freq_exact (cpu_dev, - freq_table[i-1 ].frequency *1000 , true); - max_uV =dev_pm_opp_get_voltage (opp); -rcu_read_unlock (); +while (1 ) { +struct dev_pm_opp *opp; +unsigned long opp_freq =0 , opp_uV, tol_uV; + +rcu_read_lock (); + opp =dev_pm_opp_find_freq_ceil (cpu_dev, &opp_freq); +if (IS_ERR (opp)) { +rcu_read_unlock (); +break ; + } + opp_uV =dev_pm_opp_get_voltage (opp); +rcu_read_unlock (); + + tol_uV = opp_uV * priv->voltage_tolerance /100 ; +if (regulator_is_supported_voltage (cpu_reg, opp_uV, + opp_uV + tol_uV)) { +if (opp_uV < min_uV) + min_uV = opp_uV; +if (opp_uV > max_uV) + max_uV = opp_uV; + }else { +dev_pm_opp_disable (cpu_dev, opp_freq); + } + + opp_freq++; + } + ret =regulator_set_voltage_time (cpu_reg, min_uV, max_uV);if (ret >0 ) transition_latency += ret *1000 ; } + ret =dev_pm_opp_init_cpufreq_table (cpu_dev, &freq_table); +if (ret) { +pr_err ("failed to init cpufreq table: %d\n" , ret); + goto out_free_priv; + } +/* * For now, just loading the cooling device; * thermal DT code takes care of matching them. @@ -275,9 +289,9 @@ static int cpufreq_init(struct cpufreq_policy *policy) out_cooling_unregister:cpufreq_cooling_unregister (priv->cdev); -kfree (priv); -out_free_table:dev_pm_opp_free_cpufreq_table (cpu_dev, &freq_table); +out_free_priv: +kfree (priv); out_put_node:of_node_put (np); out_put_reg_clk:
Signature · 2 lines
Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ |
PATCH v2 1/6 cpufreq: dt: disable unsupported OPPs
Quoted 12 lines · Lucas Stach
Am Freitag, den 26.09.2014, 23:55 +0200 schrieb Rafael J. Wysocki:
Quoted 11 lines · Lucas Stach
Quoted 6 lines
If the regulator connected to the CPU voltage plane doesn't support an OPP specified voltage with the acceptable tolerance it's better to just disable the OPP instead of constantly failing the voltage scaling later on.
Signed-off-by Lucas Stach <[email protected]>Why do you need this to be part of the whole series? Is there any hard dependency on it?
Quoted 6 lines
No there isn't any hard dependency. It's just that one of the boards I was testing this series with needs this to properly disable one invalid OPP.
So it's no problem to rip this one out of the series. Sorry for the confusion.
OK
Please resend it as a separate fix, then.
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.