Skip to content

Commit ac7ccfc

Browse files
committed
Merge branch 'pm-cpufreq'
* pm-cpufreq: cpufreq: Fix up cpufreq_boost_set_sw() cpufreq: fix minor typo in struct cpufreq_driver doc comment cpufreq: qoriq: Add platform dependencies clk: qoriq: add cpufreq platform device cpufreq: qoriq: convert to a platform driver cpufreq: qcom: fix wrong compatible binding cpufreq: imx-cpufreq-dt: support i.MX7ULP cpufreq: dt: Add support for r8a7742 cpufreq: Add i.MX7ULP to cpufreq-dt-platdev blacklist cpufreq: omap: Build driver by default for ARCH_OMAP2PLUS cpufreq: intel_pstate: Use passive mode by default without HWP
2 parents f1ecbf7 + 552abb8 commit ac7ccfc

File tree

11 files changed

+172
-74
lines changed

11 files changed

+172
-74
lines changed

Documentation/admin-guide/pm/intel_pstate.rst

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ on the capabilities of the processor.
6262
Active Mode
6363
-----------
6464

65-
This is the default operation mode of ``intel_pstate``. If it works in this
66-
mode, the ``scaling_driver`` policy attribute in ``sysfs`` for all ``CPUFreq``
67-
policies contains the string "intel_pstate".
65+
This is the default operation mode of ``intel_pstate`` for processors with
66+
hardware-managed P-states (HWP) support. If it works in this mode, the
67+
``scaling_driver`` policy attribute in ``sysfs`` for all ``CPUFreq`` policies
68+
contains the string "intel_pstate".
6869

6970
In this mode the driver bypasses the scaling governors layer of ``CPUFreq`` and
7071
provides its own scaling algorithms for P-state selection. Those algorithms
@@ -138,12 +139,13 @@ internal P-state selection logic to be less performance-focused.
138139
Active Mode Without HWP
139140
~~~~~~~~~~~~~~~~~~~~~~~
140141

141-
This is the default operation mode for processors that do not support the HWP
142-
feature. It also is used by default with the ``intel_pstate=no_hwp`` argument
143-
in the kernel command line. However, in this mode ``intel_pstate`` may refuse
144-
to work with the given processor if it does not recognize it. [Note that
145-
``intel_pstate`` will never refuse to work with any processor with the HWP
146-
feature enabled.]
142+
This operation mode is optional for processors that do not support the HWP
143+
feature or when the ``intel_pstate=no_hwp`` argument is passed to the kernel in
144+
the command line. The active mode is used in those cases if the
145+
``intel_pstate=active`` argument is passed to the kernel in the command line.
146+
In this mode ``intel_pstate`` may refuse to work with processors that are not
147+
recognized by it. [Note that ``intel_pstate`` will never refuse to work with
148+
any processor with the HWP feature enabled.]
147149

148150
In this mode ``intel_pstate`` registers utilization update callbacks with the
149151
CPU scheduler in order to run a P-state selection algorithm, either
@@ -188,10 +190,14 @@ is not set.
188190
Passive Mode
189191
------------
190192

191-
This mode is used if the ``intel_pstate=passive`` argument is passed to the
192-
kernel in the command line (it implies the ``intel_pstate=no_hwp`` setting too).
193-
Like in the active mode without HWP support, in this mode ``intel_pstate`` may
194-
refuse to work with the given processor if it does not recognize it.
193+
This is the default operation mode of ``intel_pstate`` for processors without
194+
hardware-managed P-states (HWP) support. It is always used if the
195+
``intel_pstate=passive`` argument is passed to the kernel in the command line
196+
regardless of whether or not the given processor supports HWP. [Note that the
197+
``intel_pstate=no_hwp`` setting implies ``intel_pstate=passive`` if it is used
198+
without ``intel_pstate=active``.] Like in the active mode without HWP support,
199+
in this mode ``intel_pstate`` may refuse to work with processors that are not
200+
recognized by it.
195201

196202
If the driver works in this mode, the ``scaling_driver`` policy attribute in
197203
``sysfs`` for all ``CPUFreq`` policies contains the string "intel_cpufreq".

drivers/clk/clk-qoriq.c

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ struct clockgen {
9595
};
9696

9797
static struct clockgen clockgen;
98+
static bool add_cpufreq_dev __initdata;
9899

99100
static void cg_out(struct clockgen *cg, u32 val, u32 __iomem *reg)
100101
{
@@ -1019,7 +1020,7 @@ static void __init create_muxes(struct clockgen *cg)
10191020
}
10201021
}
10211022

1022-
static void __init clockgen_init(struct device_node *np);
1023+
static void __init _clockgen_init(struct device_node *np, bool legacy);
10231024

10241025
/*
10251026
* Legacy nodes may get probed before the parent clockgen node.
@@ -1030,7 +1031,7 @@ static void __init clockgen_init(struct device_node *np);
10301031
static void __init legacy_init_clockgen(struct device_node *np)
10311032
{
10321033
if (!clockgen.node)
1033-
clockgen_init(of_get_parent(np));
1034+
_clockgen_init(of_get_parent(np), true);
10341035
}
10351036

10361037
/* Legacy node */
@@ -1447,7 +1448,7 @@ static bool __init has_erratum_a4510(void)
14471448
}
14481449
#endif
14491450

1450-
static void __init clockgen_init(struct device_node *np)
1451+
static void __init _clockgen_init(struct device_node *np, bool legacy)
14511452
{
14521453
int i, ret;
14531454
bool is_old_ls1021a = false;
@@ -1516,12 +1517,35 @@ static void __init clockgen_init(struct device_node *np)
15161517
__func__, np, ret);
15171518
}
15181519

1520+
/* Don't create cpufreq device for legacy clockgen blocks */
1521+
add_cpufreq_dev = !legacy;
1522+
15191523
return;
15201524
err:
15211525
iounmap(clockgen.regs);
15221526
clockgen.regs = NULL;
15231527
}
15241528

1529+
static void __init clockgen_init(struct device_node *np)
1530+
{
1531+
_clockgen_init(np, false);
1532+
}
1533+
1534+
static int __init clockgen_cpufreq_init(void)
1535+
{
1536+
struct platform_device *pdev;
1537+
1538+
if (add_cpufreq_dev) {
1539+
pdev = platform_device_register_simple("qoriq-cpufreq", -1,
1540+
NULL, 0);
1541+
if (IS_ERR(pdev))
1542+
pr_err("Couldn't register qoriq-cpufreq err=%ld\n",
1543+
PTR_ERR(pdev));
1544+
}
1545+
return 0;
1546+
}
1547+
device_initcall(clockgen_cpufreq_init);
1548+
15251549
CLK_OF_DECLARE(qoriq_clockgen_1, "fsl,qoriq-clockgen-1.0", clockgen_init);
15261550
CLK_OF_DECLARE(qoriq_clockgen_2, "fsl,qoriq-clockgen-2.0", clockgen_init);
15271551
CLK_OF_DECLARE(qoriq_clockgen_b4420, "fsl,b4420-clockgen", clockgen_init);

drivers/cpufreq/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ endif
323323

324324
config QORIQ_CPUFREQ
325325
tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
326-
depends on OF && COMMON_CLK && (PPC_E500MC || ARM || ARM64)
326+
depends on OF && COMMON_CLK
327+
depends on PPC_E500MC || SOC_LS1021A || ARCH_LAYERSCAPE || COMPILE_TEST
327328
select CLK_QORIQ
328329
help
329330
This adds the CPUFreq driver support for Freescale QorIQ SoCs

drivers/cpufreq/Kconfig.arm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ config ARM_TEGRA186_CPUFREQ
317317
config ARM_TI_CPUFREQ
318318
bool "Texas Instruments CPUFreq support"
319319
depends on ARCH_OMAP2PLUS
320+
default ARCH_OMAP2PLUS
320321
help
321322
This driver enables valid OPPs on the running platform based on
322323
values contained within the SoC in use. Enable this in order to

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static const struct of_device_id whitelist[] __initconst = {
5353
{ .compatible = "renesas,r7s72100", },
5454
{ .compatible = "renesas,r8a73a4", },
5555
{ .compatible = "renesas,r8a7740", },
56+
{ .compatible = "renesas,r8a7742", },
5657
{ .compatible = "renesas,r8a7743", },
5758
{ .compatible = "renesas,r8a7744", },
5859
{ .compatible = "renesas,r8a7745", },
@@ -105,6 +106,7 @@ static const struct of_device_id blacklist[] __initconst = {
105106
{ .compatible = "calxeda,highbank", },
106107
{ .compatible = "calxeda,ecx-2000", },
107108

109+
{ .compatible = "fsl,imx7ulp", },
108110
{ .compatible = "fsl,imx7d", },
109111
{ .compatible = "fsl,imx8mq", },
110112
{ .compatible = "fsl,imx8mm", },

drivers/cpufreq/cpufreq.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,26 +2535,27 @@ EXPORT_SYMBOL_GPL(cpufreq_update_limits);
25352535
static int cpufreq_boost_set_sw(int state)
25362536
{
25372537
struct cpufreq_policy *policy;
2538-
int ret = -EINVAL;
25392538

25402539
for_each_active_policy(policy) {
2540+
int ret;
2541+
25412542
if (!policy->freq_table)
2542-
continue;
2543+
return -ENXIO;
25432544

25442545
ret = cpufreq_frequency_table_cpuinfo(policy,
25452546
policy->freq_table);
25462547
if (ret) {
25472548
pr_err("%s: Policy frequency update failed\n",
25482549
__func__);
2549-
break;
2550+
return ret;
25502551
}
25512552

25522553
ret = freq_qos_update_request(policy->max_freq_req, policy->max);
25532554
if (ret < 0)
2554-
break;
2555+
return ret;
25552556
}
25562557

2557-
return ret;
2558+
return 0;
25582559
}
25592560

25602561
int cpufreq_boost_trigger_state(int state)

drivers/cpufreq/imx-cpufreq-dt.c

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
* Copyright 2019 NXP
44
*/
55

6+
#include <linux/clk.h>
67
#include <linux/cpu.h>
8+
#include <linux/cpufreq.h>
79
#include <linux/err.h>
810
#include <linux/init.h>
911
#include <linux/kernel.h>
@@ -12,8 +14,11 @@
1214
#include <linux/of.h>
1315
#include <linux/platform_device.h>
1416
#include <linux/pm_opp.h>
17+
#include <linux/regulator/consumer.h>
1518
#include <linux/slab.h>
1619

20+
#include "cpufreq-dt.h"
21+
1722
#define OCOTP_CFG3_SPEED_GRADE_SHIFT 8
1823
#define OCOTP_CFG3_SPEED_GRADE_MASK (0x3 << 8)
1924
#define IMX8MN_OCOTP_CFG3_SPEED_GRADE_MASK (0xf << 8)
@@ -22,20 +27,92 @@
2227
#define IMX8MP_OCOTP_CFG3_MKT_SEGMENT_SHIFT 5
2328
#define IMX8MP_OCOTP_CFG3_MKT_SEGMENT_MASK (0x3 << 5)
2429

30+
#define IMX7ULP_MAX_RUN_FREQ 528000
31+
2532
/* cpufreq-dt device registered by imx-cpufreq-dt */
2633
static struct platform_device *cpufreq_dt_pdev;
2734
static struct opp_table *cpufreq_opp_table;
35+
static struct device *cpu_dev;
36+
37+
enum IMX7ULP_CPUFREQ_CLKS {
38+
ARM,
39+
CORE,
40+
SCS_SEL,
41+
HSRUN_CORE,
42+
HSRUN_SCS_SEL,
43+
FIRC,
44+
};
45+
46+
static struct clk_bulk_data imx7ulp_clks[] = {
47+
{ .id = "arm" },
48+
{ .id = "core" },
49+
{ .id = "scs_sel" },
50+
{ .id = "hsrun_core" },
51+
{ .id = "hsrun_scs_sel" },
52+
{ .id = "firc" },
53+
};
54+
55+
static unsigned int imx7ulp_get_intermediate(struct cpufreq_policy *policy,
56+
unsigned int index)
57+
{
58+
return clk_get_rate(imx7ulp_clks[FIRC].clk);
59+
}
60+
61+
static int imx7ulp_target_intermediate(struct cpufreq_policy *policy,
62+
unsigned int index)
63+
{
64+
unsigned int newfreq = policy->freq_table[index].frequency;
65+
66+
clk_set_parent(imx7ulp_clks[SCS_SEL].clk, imx7ulp_clks[FIRC].clk);
67+
clk_set_parent(imx7ulp_clks[HSRUN_SCS_SEL].clk, imx7ulp_clks[FIRC].clk);
68+
69+
if (newfreq > IMX7ULP_MAX_RUN_FREQ)
70+
clk_set_parent(imx7ulp_clks[ARM].clk,
71+
imx7ulp_clks[HSRUN_CORE].clk);
72+
else
73+
clk_set_parent(imx7ulp_clks[ARM].clk, imx7ulp_clks[CORE].clk);
74+
75+
return 0;
76+
}
77+
78+
static struct cpufreq_dt_platform_data imx7ulp_data = {
79+
.target_intermediate = imx7ulp_target_intermediate,
80+
.get_intermediate = imx7ulp_get_intermediate,
81+
};
2882

2983
static int imx_cpufreq_dt_probe(struct platform_device *pdev)
3084
{
31-
struct device *cpu_dev = get_cpu_device(0);
85+
struct platform_device *dt_pdev;
3286
u32 cell_value, supported_hw[2];
3387
int speed_grade, mkt_segment;
3488
int ret;
3589

90+
cpu_dev = get_cpu_device(0);
91+
3692
if (!of_find_property(cpu_dev->of_node, "cpu-supply", NULL))
3793
return -ENODEV;
3894

95+
if (of_machine_is_compatible("fsl,imx7ulp")) {
96+
ret = clk_bulk_get(cpu_dev, ARRAY_SIZE(imx7ulp_clks),
97+
imx7ulp_clks);
98+
if (ret)
99+
return ret;
100+
101+
dt_pdev = platform_device_register_data(NULL, "cpufreq-dt",
102+
-1, &imx7ulp_data,
103+
sizeof(imx7ulp_data));
104+
if (IS_ERR(dt_pdev)) {
105+
clk_bulk_put(ARRAY_SIZE(imx7ulp_clks), imx7ulp_clks);
106+
ret = PTR_ERR(dt_pdev);
107+
dev_err(&pdev->dev, "Failed to register cpufreq-dt: %d\n", ret);
108+
return ret;
109+
}
110+
111+
cpufreq_dt_pdev = dt_pdev;
112+
113+
return 0;
114+
}
115+
39116
ret = nvmem_cell_read_u32(cpu_dev, "speed_grade", &cell_value);
40117
if (ret)
41118
return ret;
@@ -98,7 +175,10 @@ static int imx_cpufreq_dt_probe(struct platform_device *pdev)
98175
static int imx_cpufreq_dt_remove(struct platform_device *pdev)
99176
{
100177
platform_device_unregister(cpufreq_dt_pdev);
101-
dev_pm_opp_put_supported_hw(cpufreq_opp_table);
178+
if (!of_machine_is_compatible("fsl,imx7ulp"))
179+
dev_pm_opp_put_supported_hw(cpufreq_opp_table);
180+
else
181+
clk_bulk_put(ARRAY_SIZE(imx7ulp_clks), imx7ulp_clks);
102182

103183
return 0;
104184
}

drivers/cpufreq/intel_pstate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2771,6 +2771,8 @@ static int __init intel_pstate_init(void)
27712771
pr_info("Invalid MSRs\n");
27722772
return -ENODEV;
27732773
}
2774+
/* Without HWP start in the passive mode. */
2775+
default_driver = &intel_cpufreq;
27742776

27752777
hwp_cpu_matched:
27762778
/*
@@ -2816,7 +2818,6 @@ static int __init intel_pstate_setup(char *str)
28162818
if (!strcmp(str, "disable")) {
28172819
no_load = 1;
28182820
} else if (!strcmp(str, "passive")) {
2819-
pr_info("Passive mode enabled\n");
28202821
default_driver = &intel_cpufreq;
28212822
no_hwp = 1;
28222823
}

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
277277
if (!np)
278278
return -ENOENT;
279279

280-
ret = of_device_is_compatible(np, "operating-points-v2-qcom-cpu");
280+
ret = of_device_is_compatible(np, "operating-points-v2-kryo-cpu");
281281
if (!ret) {
282282
of_node_put(np);
283283
return -ENOENT;

0 commit comments

Comments
 (0)