Skip to content

Commit 58f5d39

Browse files
Ansuelvireshk
authored andcommitted
cpufreq: qcom-nvmem: add compatible fallback for ipq806x for no SMEM
On some IPQ806x SoC SMEM might be not initialized by SBL. This is the case for some Google devices (the OnHub family) that can't make use of SMEM to detect the SoC ID (and socinfo can't be used either as it does depends on SMEM presence). To handle these specific case, check if the SMEM is not initialized (by checking if the qcom_smem_get_soc_id returns -ENODEV) and fallback to OF machine compatible checking to identify the SoC variant. Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 1971b18 commit 58f5d39

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,22 @@ static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
256256
return ret;
257257
}
258258

259+
static const struct of_device_id qcom_cpufreq_ipq806x_match_list[] = {
260+
{ .compatible = "qcom,ipq8062", .data = (const void *)QCOM_ID_IPQ8062 },
261+
{ .compatible = "qcom,ipq8064", .data = (const void *)QCOM_ID_IPQ8064 },
262+
{ .compatible = "qcom,ipq8065", .data = (const void *)QCOM_ID_IPQ8065 },
263+
{ .compatible = "qcom,ipq8066", .data = (const void *)QCOM_ID_IPQ8066 },
264+
{ .compatible = "qcom,ipq8068", .data = (const void *)QCOM_ID_IPQ8068 },
265+
{ .compatible = "qcom,ipq8069", .data = (const void *)QCOM_ID_IPQ8069 },
266+
};
267+
259268
static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
260269
struct nvmem_cell *speedbin_nvmem,
261270
char **pvs_name,
262271
struct qcom_cpufreq_drv *drv)
263272
{
273+
int msm_id = -1, ret = 0;
264274
int speed = 0, pvs = 0;
265-
int msm_id, ret = 0;
266275
u8 *speedbin;
267276
size_t len;
268277

@@ -279,8 +288,30 @@ static int qcom_cpufreq_ipq8064_name_version(struct device *cpu_dev,
279288
get_krait_bin_format_a(cpu_dev, &speed, &pvs, speedbin);
280289

281290
ret = qcom_smem_get_soc_id(&msm_id);
282-
if (ret)
291+
if (ret == -ENODEV) {
292+
const struct of_device_id *match;
293+
struct device_node *root;
294+
295+
root = of_find_node_by_path("/");
296+
if (!root) {
297+
ret = -ENODEV;
298+
goto exit;
299+
}
300+
301+
/* Fallback to compatible match with no SMEM initialized */
302+
match = of_match_node(qcom_cpufreq_ipq806x_match_list, root);
303+
of_node_put(root);
304+
if (!match) {
305+
ret = -ENODEV;
306+
goto exit;
307+
}
308+
309+
/* We found a matching device, get the msm_id from the data entry */
310+
msm_id = (int)(uintptr_t)match->data;
311+
ret = 0;
312+
} else if (ret) {
283313
goto exit;
314+
}
284315

285316
switch (msm_id) {
286317
case QCOM_ID_IPQ8062:

0 commit comments

Comments
 (0)