Skip to content

Commit 3f8ffb1

Browse files
committed
Merge branch 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm
Pull ARM cpufreq updates for v5.8 from Viresh Kumar: "- Build OMAP cpufreq driver by default for ARCH_OMAP2PLUS platform (Anders Roxell). - Fix compatible bindings for qcom cpufreq driver (Ansuel Smith). - Update qoriq cpufreq driver to automatically loaded when built as module and related changes (Mian Yousaf Kaukab and Geert Uytterhoeven). - Add support for r8a7742 to cpufreq-dt platform driver (Lad Prabhakar). - Add support for i.MX7ULP to imx cpufreq driver (Peng Fan)." * 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: 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
2 parents 9795a0d + 1f1755a commit 3f8ffb1

File tree

7 files changed

+144
-54
lines changed

7 files changed

+144
-54
lines changed

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/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/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;

drivers/cpufreq/qoriq-cpufreq.c

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/of.h>
1919
#include <linux/slab.h>
2020
#include <linux/smp.h>
21+
#include <linux/platform_device.h>
2122

2223
/**
2324
* struct cpu_data
@@ -29,12 +30,6 @@ struct cpu_data {
2930
struct cpufreq_frequency_table *table;
3031
};
3132

32-
/*
33-
* Don't use cpufreq on this SoC -- used when the SoC would have otherwise
34-
* matched a more generic compatible.
35-
*/
36-
#define SOC_BLACKLIST 1
37-
3833
/**
3934
* struct soc_data - SoC specific data
4035
* @flags: SOC_xxx
@@ -264,64 +259,51 @@ static struct cpufreq_driver qoriq_cpufreq_driver = {
264259
.attr = cpufreq_generic_attr,
265260
};
266261

267-
static const struct soc_data blacklist = {
268-
.flags = SOC_BLACKLIST,
269-
};
270-
271-
static const struct of_device_id node_matches[] __initconst = {
262+
static const struct of_device_id qoriq_cpufreq_blacklist[] = {
272263
/* e6500 cannot use cpufreq due to erratum A-008083 */
273-
{ .compatible = "fsl,b4420-clockgen", &blacklist },
274-
{ .compatible = "fsl,b4860-clockgen", &blacklist },
275-
{ .compatible = "fsl,t2080-clockgen", &blacklist },
276-
{ .compatible = "fsl,t4240-clockgen", &blacklist },
277-
278-
{ .compatible = "fsl,ls1012a-clockgen", },
279-
{ .compatible = "fsl,ls1021a-clockgen", },
280-
{ .compatible = "fsl,ls1028a-clockgen", },
281-
{ .compatible = "fsl,ls1043a-clockgen", },
282-
{ .compatible = "fsl,ls1046a-clockgen", },
283-
{ .compatible = "fsl,ls1088a-clockgen", },
284-
{ .compatible = "fsl,ls2080a-clockgen", },
285-
{ .compatible = "fsl,lx2160a-clockgen", },
286-
{ .compatible = "fsl,p4080-clockgen", },
287-
{ .compatible = "fsl,qoriq-clockgen-1.0", },
288-
{ .compatible = "fsl,qoriq-clockgen-2.0", },
264+
{ .compatible = "fsl,b4420-clockgen", },
265+
{ .compatible = "fsl,b4860-clockgen", },
266+
{ .compatible = "fsl,t2080-clockgen", },
267+
{ .compatible = "fsl,t4240-clockgen", },
289268
{}
290269
};
291270

292-
static int __init qoriq_cpufreq_init(void)
271+
static int qoriq_cpufreq_probe(struct platform_device *pdev)
293272
{
294273
int ret;
295-
struct device_node *np;
296-
const struct of_device_id *match;
297-
const struct soc_data *data;
298-
299-
np = of_find_matching_node(NULL, node_matches);
300-
if (!np)
301-
return -ENODEV;
302-
303-
match = of_match_node(node_matches, np);
304-
data = match->data;
305-
306-
of_node_put(np);
274+
struct device_node *np;
307275

308-
if (data && data->flags & SOC_BLACKLIST)
276+
np = of_find_matching_node(NULL, qoriq_cpufreq_blacklist);
277+
if (np) {
278+
dev_info(&pdev->dev, "Disabling due to erratum A-008083");
309279
return -ENODEV;
280+
}
310281

311282
ret = cpufreq_register_driver(&qoriq_cpufreq_driver);
312-
if (!ret)
313-
pr_info("Freescale QorIQ CPU frequency scaling driver\n");
283+
if (ret)
284+
return ret;
314285

315-
return ret;
286+
dev_info(&pdev->dev, "Freescale QorIQ CPU frequency scaling driver\n");
287+
return 0;
316288
}
317-
module_init(qoriq_cpufreq_init);
318289

319-
static void __exit qoriq_cpufreq_exit(void)
290+
static int qoriq_cpufreq_remove(struct platform_device *pdev)
320291
{
321292
cpufreq_unregister_driver(&qoriq_cpufreq_driver);
293+
294+
return 0;
322295
}
323-
module_exit(qoriq_cpufreq_exit);
324296

297+
static struct platform_driver qoriq_cpufreq_platform_driver = {
298+
.driver = {
299+
.name = "qoriq-cpufreq",
300+
},
301+
.probe = qoriq_cpufreq_probe,
302+
.remove = qoriq_cpufreq_remove,
303+
};
304+
module_platform_driver(qoriq_cpufreq_platform_driver);
305+
306+
MODULE_ALIAS("platform:qoriq-cpufreq");
325307
MODULE_LICENSE("GPL");
326308
MODULE_AUTHOR("Tang Yuantian <[email protected]>");
327309
MODULE_DESCRIPTION("cpufreq driver for Freescale QorIQ series SoCs");

0 commit comments

Comments
 (0)