4f37d672ba6e0056c691019c79b13194ad222bc4
[openwrt/staging/neocturne.git] /
1 From e7992615acacc27baeec310197108143afc77337 Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Fri, 26 May 2023 22:48:02 +0200
4 Subject: [PATCH] cpufreq: qcom-nvmem: use helper to get SMEM SoC ID
5
6 Now that SMEM exports a helper to get the SMEM SoC ID lets utilize it.
7 Currently qcom_cpufreq_get_msm_id() is encoding the returned SMEM SoC ID
8 into an enum, however there is no reason to do so and we can just match
9 directly on the SMEM SoC ID as returned by qcom_smem_get_soc_id().
10
11 Signed-off-by: Robert Marko <robimarko@gmail.com>
12 Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
13 Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
14 Signed-off-by: Bjorn Andersson <andersson@kernel.org>
15 Link: https://lore.kernel.org/r/20230526204802.3081168-5-robimarko@gmail.com
16 ---
17 drivers/cpufreq/qcom-cpufreq-nvmem.c | 56 +++++-----------------------
18 1 file changed, 10 insertions(+), 46 deletions(-)
19
20 --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
21 +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
22 @@ -29,16 +29,8 @@
23 #include <linux/slab.h>
24 #include <linux/soc/qcom/smem.h>
25
26 -#define MSM_ID_SMEM 137
27 -
28 #include <dt-bindings/arm/qcom,ids.h>
29
30 -enum _msm8996_version {
31 - MSM8996_V3,
32 - MSM8996_SG,
33 - NUM_OF_MSM8996_VERSIONS,
34 -};
35 -
36 struct qcom_cpufreq_drv;
37
38 struct qcom_cpufreq_match_data {
39 @@ -135,60 +127,32 @@ static void get_krait_bin_format_b(struc
40 dev_dbg(cpu_dev, "PVS version: %d\n", *pvs_ver);
41 }
42
43 -static enum _msm8996_version qcom_cpufreq_get_msm_id(void)
44 -{
45 - size_t len;
46 - u32 *msm_id;
47 - enum _msm8996_version version;
48 -
49 - msm_id = qcom_smem_get(QCOM_SMEM_HOST_ANY, MSM_ID_SMEM, &len);
50 - if (IS_ERR(msm_id))
51 - return NUM_OF_MSM8996_VERSIONS;
52 -
53 - /* The first 4 bytes are format, next to them is the actual msm-id */
54 - msm_id++;
55 -
56 - switch ((enum _msm_id)*msm_id) {
57 - case QCOM_ID_MSM8996:
58 - case QCOM_ID_APQ8096:
59 - version = MSM8996_V3;
60 - break;
61 - case QCOM_ID_MSM8996SG:
62 - case QCOM_ID_APQ8096SG:
63 - version = MSM8996_SG;
64 - break;
65 - default:
66 - version = NUM_OF_MSM8996_VERSIONS;
67 - }
68 -
69 - return version;
70 -}
71 -
72 static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
73 struct nvmem_cell *speedbin_nvmem,
74 char **pvs_name,
75 struct qcom_cpufreq_drv *drv)
76 {
77 size_t len;
78 + u32 msm_id;
79 u8 *speedbin;
80 - enum _msm8996_version msm8996_version;
81 + int ret;
82 *pvs_name = NULL;
83
84 - msm8996_version = qcom_cpufreq_get_msm_id();
85 - if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
86 - dev_err(cpu_dev, "Not Snapdragon 820/821!");
87 - return -ENODEV;
88 - }
89 + ret = qcom_smem_get_soc_id(&msm_id);
90 + if (ret)
91 + return ret;
92
93 speedbin = nvmem_cell_read(speedbin_nvmem, &len);
94 if (IS_ERR(speedbin))
95 return PTR_ERR(speedbin);
96
97 - switch (msm8996_version) {
98 - case MSM8996_V3:
99 + switch (msm_id) {
100 + case QCOM_ID_MSM8996:
101 + case QCOM_ID_APQ8096:
102 drv->versions = 1 << (unsigned int)(*speedbin);
103 break;
104 - case MSM8996_SG:
105 + case QCOM_ID_MSM8996SG:
106 + case QCOM_ID_APQ8096SG:
107 drv->versions = 1 << ((unsigned int)(*speedbin) + 4);
108 break;
109 default: