2023-06-07 11:12:26 +00:00
|
|
|
From e7992615acacc27baeec310197108143afc77337 Mon Sep 17 00:00:00 2001
|
2023-05-22 21:13:08 +00:00
|
|
|
From: Robert Marko <robimarko@gmail.com>
|
2023-06-07 11:12:26 +00:00
|
|
|
Date: Fri, 26 May 2023 22:48:02 +0200
|
|
|
|
Subject: [PATCH] cpufreq: qcom-nvmem: use helper to get SMEM SoC ID
|
2023-05-22 21:13:08 +00:00
|
|
|
|
2023-06-07 11:12:26 +00:00
|
|
|
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().
|
2023-05-22 21:13:08 +00:00
|
|
|
|
|
|
|
Signed-off-by: Robert Marko <robimarko@gmail.com>
|
2023-06-07 11:12:26 +00:00
|
|
|
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
|
2023-05-22 21:13:08 +00:00
|
|
|
---
|
2023-06-07 11:12:26 +00:00
|
|
|
drivers/cpufreq/qcom-cpufreq-nvmem.c | 56 +++++-----------------------
|
|
|
|
1 file changed, 10 insertions(+), 46 deletions(-)
|
2023-05-22 21:13:08 +00:00
|
|
|
|
|
|
|
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
|
|
|
|
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
|
2023-06-07 11:12:26 +00:00
|
|
|
@@ -29,16 +29,8 @@
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/soc/qcom/smem.h>
|
2023-05-22 21:13:08 +00:00
|
|
|
|
2023-06-07 11:12:26 +00:00
|
|
|
-#define MSM_ID_SMEM 137
|
|
|
|
-
|
2023-05-22 21:13:08 +00:00
|
|
|
#include <dt-bindings/arm/qcom,ids.h>
|
|
|
|
|
|
|
|
-enum _msm8996_version {
|
|
|
|
- MSM8996_V3,
|
|
|
|
- MSM8996_SG,
|
|
|
|
- NUM_OF_MSM8996_VERSIONS,
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
struct qcom_cpufreq_drv;
|
|
|
|
|
|
|
|
struct qcom_cpufreq_match_data {
|
2023-06-07 11:12:26 +00:00
|
|
|
@@ -135,60 +127,32 @@ static void get_krait_bin_format_b(struc
|
2023-05-22 21:13:08 +00:00
|
|
|
dev_dbg(cpu_dev, "PVS version: %d\n", *pvs_ver);
|
|
|
|
}
|
|
|
|
|
|
|
|
-static enum _msm8996_version qcom_cpufreq_get_msm_id(void)
|
2023-06-07 11:12:26 +00:00
|
|
|
-{
|
|
|
|
- size_t len;
|
|
|
|
- u32 *msm_id;
|
2023-05-22 21:13:08 +00:00
|
|
|
- enum _msm8996_version version;
|
2023-06-07 11:12:26 +00:00
|
|
|
-
|
|
|
|
- msm_id = qcom_smem_get(QCOM_SMEM_HOST_ANY, MSM_ID_SMEM, &len);
|
|
|
|
- if (IS_ERR(msm_id))
|
2023-05-22 21:13:08 +00:00
|
|
|
- return NUM_OF_MSM8996_VERSIONS;
|
|
|
|
-
|
2023-06-07 11:12:26 +00:00
|
|
|
- /* The first 4 bytes are format, next to them is the actual msm-id */
|
|
|
|
- msm_id++;
|
|
|
|
-
|
|
|
|
- switch ((enum _msm_id)*msm_id) {
|
2023-05-22 21:13:08 +00:00
|
|
|
- case QCOM_ID_MSM8996:
|
|
|
|
- case QCOM_ID_APQ8096:
|
|
|
|
- version = MSM8996_V3;
|
|
|
|
- break;
|
|
|
|
- case QCOM_ID_MSM8996SG:
|
|
|
|
- case QCOM_ID_APQ8096SG:
|
|
|
|
- version = MSM8996_SG;
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- version = NUM_OF_MSM8996_VERSIONS;
|
|
|
|
- }
|
2023-06-07 11:12:26 +00:00
|
|
|
-
|
2023-05-22 21:13:08 +00:00
|
|
|
- return version;
|
2023-06-07 11:12:26 +00:00
|
|
|
-}
|
|
|
|
-
|
2023-05-22 21:13:08 +00:00
|
|
|
static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
|
2023-06-07 11:12:26 +00:00
|
|
|
struct nvmem_cell *speedbin_nvmem,
|
|
|
|
char **pvs_name,
|
2023-05-22 21:13:08 +00:00
|
|
|
struct qcom_cpufreq_drv *drv)
|
|
|
|
{
|
|
|
|
size_t len;
|
2023-06-07 11:12:26 +00:00
|
|
|
+ u32 msm_id;
|
2023-05-22 21:13:08 +00:00
|
|
|
u8 *speedbin;
|
|
|
|
- enum _msm8996_version msm8996_version;
|
2023-06-07 11:12:26 +00:00
|
|
|
+ int ret;
|
2023-05-22 21:13:08 +00:00
|
|
|
*pvs_name = NULL;
|
|
|
|
|
|
|
|
- msm8996_version = qcom_cpufreq_get_msm_id();
|
|
|
|
- if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
|
|
|
|
- dev_err(cpu_dev, "Not Snapdragon 820/821!");
|
|
|
|
- return -ENODEV;
|
|
|
|
- }
|
2023-06-07 11:12:26 +00:00
|
|
|
+ ret = qcom_smem_get_soc_id(&msm_id);
|
|
|
|
+ if (ret)
|
|
|
|
+ return ret;
|
2023-05-22 21:13:08 +00:00
|
|
|
|
|
|
|
speedbin = nvmem_cell_read(speedbin_nvmem, &len);
|
|
|
|
if (IS_ERR(speedbin))
|
|
|
|
return PTR_ERR(speedbin);
|
|
|
|
|
|
|
|
- switch (msm8996_version) {
|
|
|
|
- case MSM8996_V3:
|
|
|
|
+ switch (msm_id) {
|
|
|
|
+ case QCOM_ID_MSM8996:
|
|
|
|
+ case QCOM_ID_APQ8096:
|
|
|
|
drv->versions = 1 << (unsigned int)(*speedbin);
|
|
|
|
break;
|
|
|
|
- case MSM8996_SG:
|
|
|
|
+ case QCOM_ID_MSM8996SG:
|
|
|
|
+ case QCOM_ID_APQ8096SG:
|
|
|
|
drv->versions = 1 << ((unsigned int)(*speedbin) + 4);
|
|
|
|
break;
|
|
|
|
default:
|