Skip to content

Commit 47e161a

Browse files
robimarkovireshk
authored andcommitted
cpufreq: qcom-nvmem: add support for IPQ6018
IPQ6018 SoC series comes in multiple SKU-s, and not all of them support high frequency OPP points. SoC itself does however have a single bit in QFPROM to indicate the CPU speed-bin. That bit is used to indicate frequency limit of 1.5GHz, but that alone is not enough as IPQ6000 only goes up to 1.2GHz, but SMEM ID can be used to limit it further. IPQ6018 compatible is blacklisted from DT platdev as the cpufreq device will get created by NVMEM CPUFreq driver. Signed-off-by: Robert Marko <[email protected]> [ Viresh: Fixed rebase conflict. ] Signed-off-by: Viresh Kumar <[email protected]>
1 parent 4b55159 commit 47e161a

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

drivers/cpufreq/cpufreq-dt-platdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ static const struct of_device_id blocklist[] __initconst = {
180180
{ .compatible = "ti,am62a7", },
181181
{ .compatible = "ti,am62p5", },
182182

183+
{ .compatible = "qcom,ipq6018", },
183184
{ .compatible = "qcom,ipq8064", },
184185
{ .compatible = "qcom,apq8064", },
185186
{ .compatible = "qcom,msm8974", },

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
#include <dt-bindings/arm/qcom,ids.h>
3232

33+
#define IPQ6000_VERSION BIT(2)
34+
3335
struct qcom_cpufreq_drv;
3436

3537
struct qcom_cpufreq_match_data {
@@ -225,6 +227,57 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
225227
return ret;
226228
}
227229

230+
static int qcom_cpufreq_ipq6018_name_version(struct device *cpu_dev,
231+
struct nvmem_cell *speedbin_nvmem,
232+
char **pvs_name,
233+
struct qcom_cpufreq_drv *drv)
234+
{
235+
u32 msm_id;
236+
int ret;
237+
u8 *speedbin;
238+
*pvs_name = NULL;
239+
240+
ret = qcom_smem_get_soc_id(&msm_id);
241+
if (ret)
242+
return ret;
243+
244+
speedbin = nvmem_cell_read(speedbin_nvmem, NULL);
245+
if (IS_ERR(speedbin))
246+
return PTR_ERR(speedbin);
247+
248+
switch (msm_id) {
249+
case QCOM_ID_IPQ6005:
250+
case QCOM_ID_IPQ6010:
251+
case QCOM_ID_IPQ6018:
252+
case QCOM_ID_IPQ6028:
253+
/* Fuse Value Freq BIT to set
254+
* ---------------------------------
255+
* 2’b0 No Limit BIT(0)
256+
* 2’b1 1.5 GHz BIT(1)
257+
*/
258+
drv->versions = 1 << (unsigned int)(*speedbin);
259+
break;
260+
case QCOM_ID_IPQ6000:
261+
/*
262+
* IPQ6018 family only has one bit to advertise the CPU
263+
* speed-bin, but that is not enough for IPQ6000 which
264+
* is only rated up to 1.2GHz.
265+
* So for IPQ6000 manually set BIT(2) based on SMEM ID.
266+
*/
267+
drv->versions = IPQ6000_VERSION;
268+
break;
269+
default:
270+
dev_err(cpu_dev,
271+
"SoC ID %u is not part of IPQ6018 family, limiting to 1.2GHz!\n",
272+
msm_id);
273+
drv->versions = IPQ6000_VERSION;
274+
break;
275+
}
276+
277+
kfree(speedbin);
278+
return 0;
279+
}
280+
228281
static const char *generic_genpd_names[] = { "perf", NULL };
229282

230283
static const struct qcom_cpufreq_match_data match_data_kryo = {
@@ -246,6 +299,10 @@ static const struct qcom_cpufreq_match_data match_data_qcs404 = {
246299
.genpd_names = qcs404_genpd_names,
247300
};
248301

302+
static const struct qcom_cpufreq_match_data match_data_ipq6018 = {
303+
.get_version = qcom_cpufreq_ipq6018_name_version,
304+
};
305+
249306
static int qcom_cpufreq_probe(struct platform_device *pdev)
250307
{
251308
struct qcom_cpufreq_drv *drv;
@@ -372,6 +429,7 @@ static const struct of_device_id qcom_cpufreq_match_list[] __initconst = {
372429
{ .compatible = "qcom,msm8909", .data = &match_data_msm8909 },
373430
{ .compatible = "qcom,msm8996", .data = &match_data_kryo },
374431
{ .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
432+
{ .compatible = "qcom,ipq6018", .data = &match_data_ipq6018 },
375433
{ .compatible = "qcom,ipq8064", .data = &match_data_krait },
376434
{ .compatible = "qcom,apq8064", .data = &match_data_krait },
377435
{ .compatible = "qcom,msm8974", .data = &match_data_krait },

0 commit comments

Comments
 (0)