Skip to content

Commit 7d0f03d

Browse files
robimarkoandersson
authored andcommitted
cpufreq: qcom-nvmem: use helper to get SMEM SoC ID
Now that SMEM exports a helper to get the SMEM SoC ID lets utilize it. Currently qcom_cpufreq_get_msm_id() is encoding the returned SMEM SoC ID into an enum, however there is no reason to do so and we can just match directly on the SMEM SoC ID as returned by qcom_smem_get_soc_id(). Signed-off-by: Robert Marko <robimarko@gmail.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Signed-off-by: Bjorn Andersson <andersson@kernel.org> Link: https://lore.kernel.org/r/20230526204802.3081168-5-robimarko@gmail.com
1 parent 865d7e7 commit 7d0f03d

1 file changed

Lines changed: 10 additions & 46 deletions

File tree

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,8 @@
2929
#include <linux/slab.h>
3030
#include <linux/soc/qcom/smem.h>
3131

32-
#define MSM_ID_SMEM 137
33-
3432
#include <dt-bindings/arm/qcom,ids.h>
3533

36-
enum _msm8996_version {
37-
MSM8996_V3,
38-
MSM8996_SG,
39-
NUM_OF_MSM8996_VERSIONS,
40-
};
41-
4234
struct qcom_cpufreq_drv;
4335

4436
struct qcom_cpufreq_match_data {
@@ -135,60 +127,32 @@ static void get_krait_bin_format_b(struct device *cpu_dev,
135127
dev_dbg(cpu_dev, "PVS version: %d\n", *pvs_ver);
136128
}
137129

138-
static enum _msm8996_version qcom_cpufreq_get_msm_id(void)
139-
{
140-
size_t len;
141-
u32 *msm_id;
142-
enum _msm8996_version version;
143-
144-
msm_id = qcom_smem_get(QCOM_SMEM_HOST_ANY, MSM_ID_SMEM, &len);
145-
if (IS_ERR(msm_id))
146-
return NUM_OF_MSM8996_VERSIONS;
147-
148-
/* The first 4 bytes are format, next to them is the actual msm-id */
149-
msm_id++;
150-
151-
switch ((enum _msm_id)*msm_id) {
152-
case QCOM_ID_MSM8996:
153-
case QCOM_ID_APQ8096:
154-
version = MSM8996_V3;
155-
break;
156-
case QCOM_ID_MSM8996SG:
157-
case QCOM_ID_APQ8096SG:
158-
version = MSM8996_SG;
159-
break;
160-
default:
161-
version = NUM_OF_MSM8996_VERSIONS;
162-
}
163-
164-
return version;
165-
}
166-
167130
static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
168131
struct nvmem_cell *speedbin_nvmem,
169132
char **pvs_name,
170133
struct qcom_cpufreq_drv *drv)
171134
{
172135
size_t len;
136+
u32 msm_id;
173137
u8 *speedbin;
174-
enum _msm8996_version msm8996_version;
138+
int ret;
175139
*pvs_name = NULL;
176140

177-
msm8996_version = qcom_cpufreq_get_msm_id();
178-
if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
179-
dev_err(cpu_dev, "Not Snapdragon 820/821!");
180-
return -ENODEV;
181-
}
141+
ret = qcom_smem_get_soc_id(&msm_id);
142+
if (ret)
143+
return ret;
182144

183145
speedbin = nvmem_cell_read(speedbin_nvmem, &len);
184146
if (IS_ERR(speedbin))
185147
return PTR_ERR(speedbin);
186148

187-
switch (msm8996_version) {
188-
case MSM8996_V3:
149+
switch (msm_id) {
150+
case QCOM_ID_MSM8996:
151+
case QCOM_ID_APQ8096:
189152
drv->versions = 1 << (unsigned int)(*speedbin);
190153
break;
191-
case MSM8996_SG:
154+
case QCOM_ID_MSM8996SG:
155+
case QCOM_ID_APQ8096SG:
192156
drv->versions = 1 << ((unsigned int)(*speedbin) + 4);
193157
break;
194158
default:

0 commit comments

Comments
 (0)