Skip to content

Commit 4d99175

Browse files
committed
Merge branch 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm
Pull ARM cpufreq drivers updates for v5.7 from Viresh Kumar: "This pull request contains: - update to imx cpufreq drivers to improve their support (Anson Huang, Christoph Niedermaier, and Peng Fan). - Update to qcom cpufreq to support other krait based SoCs (Ansuel Smith). - Update ti cpufreq driver to support OPP_PLUS (Lokesh Vutla). - Update cpufreq-dt driver to allow platfoem specific intermediate callbacks (Peng Fan)." * 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: cpufreq: qcom: Add support for krait based socs cpufreq: imx6q-cpufreq: Improve the logic of -EPROBE_DEFER handling cpufreq: dt: Allow platform specific intermediate callbacks cpufreq: imx-cpufreq-dt: Correct i.MX8MP's market segment fuse location cpufreq: imx6q: read OCOTP through nvmem for imx6q cpufreq: imx6q: fix error handling cpufreq: imx-cpufreq-dt: Add "cpu-supply" property check cpufreq: ti-cpufreq: Add support for OPP_PLUS cpufreq: imx6q: Fixes unwanted cpu overclocking on i.MX6ULL
2 parents 3c0897c + a8811ec commit 4d99175

File tree

9 files changed

+251
-49
lines changed

9 files changed

+251
-49
lines changed

Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ In 'cpu' nodes:
1919

2020
In 'operating-points-v2' table:
2121
- compatible: Should be
22-
- 'operating-points-v2-kryo-cpu' for apq8096 and msm8996.
22+
- 'operating-points-v2-kryo-cpu' for apq8096, msm8996, msm8974,
23+
apq8064, ipq8064, msm8960 and ipq8074.
2324

2425
Optional properties:
2526
--------------------

drivers/cpufreq/Kconfig.arm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ config ARM_OMAP2PLUS_CPUFREQ
128128

129129
config ARM_QCOM_CPUFREQ_NVMEM
130130
tristate "Qualcomm nvmem based CPUFreq"
131-
depends on ARM64
131+
depends on ARCH_QCOM
132132
depends on QCOM_QFPROM
133133
depends on QCOM_SMEM
134134
select PM_OPP

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ static const struct of_device_id blacklist[] __initconst = {
141141
{ .compatible = "ti,dra7", },
142142
{ .compatible = "ti,omap3", },
143143

144+
{ .compatible = "qcom,ipq8064", },
145+
{ .compatible = "qcom,apq8064", },
146+
{ .compatible = "qcom,msm8974", },
147+
{ .compatible = "qcom,msm8960", },
148+
144149
{ }
145150
};
146151

drivers/cpufreq/cpufreq-dt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ static int dt_cpufreq_probe(struct platform_device *pdev)
363363
dt_cpufreq_driver.resume = data->resume;
364364
if (data->suspend)
365365
dt_cpufreq_driver.suspend = data->suspend;
366+
if (data->get_intermediate) {
367+
dt_cpufreq_driver.target_intermediate = data->target_intermediate;
368+
dt_cpufreq_driver.get_intermediate = data->get_intermediate;
369+
}
366370
}
367371

368372
ret = cpufreq_register_driver(&dt_cpufreq_driver);

drivers/cpufreq/cpufreq-dt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ struct cpufreq_policy;
1414
struct cpufreq_dt_platform_data {
1515
bool have_governor_per_policy;
1616

17+
unsigned int (*get_intermediate)(struct cpufreq_policy *policy,
18+
unsigned int index);
19+
int (*target_intermediate)(struct cpufreq_policy *policy,
20+
unsigned int index);
1721
int (*suspend)(struct cpufreq_policy *policy);
1822
int (*resume)(struct cpufreq_policy *policy);
1923
};

drivers/cpufreq/imx-cpufreq-dt.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#define IMX8MN_OCOTP_CFG3_SPEED_GRADE_MASK (0xf << 8)
2020
#define OCOTP_CFG3_MKT_SEGMENT_SHIFT 6
2121
#define OCOTP_CFG3_MKT_SEGMENT_MASK (0x3 << 6)
22+
#define IMX8MP_OCOTP_CFG3_MKT_SEGMENT_SHIFT 5
23+
#define IMX8MP_OCOTP_CFG3_MKT_SEGMENT_MASK (0x3 << 5)
2224

2325
/* cpufreq-dt device registered by imx-cpufreq-dt */
2426
static struct platform_device *cpufreq_dt_pdev;
@@ -31,6 +33,9 @@ static int imx_cpufreq_dt_probe(struct platform_device *pdev)
3133
int speed_grade, mkt_segment;
3234
int ret;
3335

36+
if (!of_find_property(cpu_dev->of_node, "cpu-supply", NULL))
37+
return -ENODEV;
38+
3439
ret = nvmem_cell_read_u32(cpu_dev, "speed_grade", &cell_value);
3540
if (ret)
3641
return ret;
@@ -42,7 +47,13 @@ static int imx_cpufreq_dt_probe(struct platform_device *pdev)
4247
else
4348
speed_grade = (cell_value & OCOTP_CFG3_SPEED_GRADE_MASK)
4449
>> OCOTP_CFG3_SPEED_GRADE_SHIFT;
45-
mkt_segment = (cell_value & OCOTP_CFG3_MKT_SEGMENT_MASK) >> OCOTP_CFG3_MKT_SEGMENT_SHIFT;
50+
51+
if (of_machine_is_compatible("fsl,imx8mp"))
52+
mkt_segment = (cell_value & IMX8MP_OCOTP_CFG3_MKT_SEGMENT_MASK)
53+
>> IMX8MP_OCOTP_CFG3_MKT_SEGMENT_SHIFT;
54+
else
55+
mkt_segment = (cell_value & OCOTP_CFG3_MKT_SEGMENT_MASK)
56+
>> OCOTP_CFG3_MKT_SEGMENT_SHIFT;
4657

4758
/*
4859
* Early samples without fuses written report "0 0" which may NOT

drivers/cpufreq/imx6q-cpufreq.c

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -216,31 +216,41 @@ static struct cpufreq_driver imx6q_cpufreq_driver = {
216216
#define OCOTP_CFG3_SPEED_996MHZ 0x2
217217
#define OCOTP_CFG3_SPEED_852MHZ 0x1
218218

219-
static void imx6q_opp_check_speed_grading(struct device *dev)
219+
static int imx6q_opp_check_speed_grading(struct device *dev)
220220
{
221221
struct device_node *np;
222222
void __iomem *base;
223223
u32 val;
224+
int ret;
224225

225-
np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp");
226-
if (!np)
227-
return;
226+
if (of_find_property(dev->of_node, "nvmem-cells", NULL)) {
227+
ret = nvmem_cell_read_u32(dev, "speed_grade", &val);
228+
if (ret)
229+
return ret;
230+
} else {
231+
np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ocotp");
232+
if (!np)
233+
return -ENOENT;
228234

229-
base = of_iomap(np, 0);
230-
if (!base) {
231-
dev_err(dev, "failed to map ocotp\n");
232-
goto put_node;
235+
base = of_iomap(np, 0);
236+
of_node_put(np);
237+
if (!base) {
238+
dev_err(dev, "failed to map ocotp\n");
239+
return -EFAULT;
240+
}
241+
242+
/*
243+
* SPEED_GRADING[1:0] defines the max speed of ARM:
244+
* 2b'11: 1200000000Hz;
245+
* 2b'10: 996000000Hz;
246+
* 2b'01: 852000000Hz; -- i.MX6Q Only, exclusive with 996MHz.
247+
* 2b'00: 792000000Hz;
248+
* We need to set the max speed of ARM according to fuse map.
249+
*/
250+
val = readl_relaxed(base + OCOTP_CFG3);
251+
iounmap(base);
233252
}
234253

235-
/*
236-
* SPEED_GRADING[1:0] defines the max speed of ARM:
237-
* 2b'11: 1200000000Hz;
238-
* 2b'10: 996000000Hz;
239-
* 2b'01: 852000000Hz; -- i.MX6Q Only, exclusive with 996MHz.
240-
* 2b'00: 792000000Hz;
241-
* We need to set the max speed of ARM according to fuse map.
242-
*/
243-
val = readl_relaxed(base + OCOTP_CFG3);
244254
val >>= OCOTP_CFG3_SPEED_SHIFT;
245255
val &= 0x3;
246256

@@ -257,9 +267,8 @@ static void imx6q_opp_check_speed_grading(struct device *dev)
257267
if (dev_pm_opp_disable(dev, 1200000000))
258268
dev_warn(dev, "failed to disable 1.2GHz OPP\n");
259269
}
260-
iounmap(base);
261-
put_node:
262-
of_node_put(np);
270+
271+
return 0;
263272
}
264273

265274
#define OCOTP_CFG3_6UL_SPEED_696MHZ 0x2
@@ -280,6 +289,9 @@ static int imx6ul_opp_check_speed_grading(struct device *dev)
280289
void __iomem *base;
281290

282291
np = of_find_compatible_node(NULL, NULL, "fsl,imx6ul-ocotp");
292+
if (!np)
293+
np = of_find_compatible_node(NULL, NULL,
294+
"fsl,imx6ull-ocotp");
283295
if (!np)
284296
return -ENOENT;
285297

@@ -378,23 +390,22 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
378390
goto put_reg;
379391
}
380392

393+
/* Because we have added the OPPs here, we must free them */
394+
free_opp = true;
395+
381396
if (of_machine_is_compatible("fsl,imx6ul") ||
382397
of_machine_is_compatible("fsl,imx6ull")) {
383398
ret = imx6ul_opp_check_speed_grading(cpu_dev);
384-
if (ret) {
385-
if (ret == -EPROBE_DEFER)
386-
goto put_node;
387-
399+
} else {
400+
ret = imx6q_opp_check_speed_grading(cpu_dev);
401+
}
402+
if (ret) {
403+
if (ret != -EPROBE_DEFER)
388404
dev_err(cpu_dev, "failed to read ocotp: %d\n",
389405
ret);
390-
goto put_node;
391-
}
392-
} else {
393-
imx6q_opp_check_speed_grading(cpu_dev);
406+
goto out_free_opp;
394407
}
395408

396-
/* Because we have added the OPPs here, we must free them */
397-
free_opp = true;
398409
num = dev_pm_opp_get_opp_count(cpu_dev);
399410
if (num < 0) {
400411
ret = num;

0 commit comments

Comments
 (0)