From a206d4061f1cc2c5cd17ee45c53a0ba711e48e6d Mon Sep 17 00:00:00 2001
From: Ansuel Smith <ansuelsmth@gmail.com>
Date: Sun, 7 Feb 2021 16:42:52 +0100
Subject: [PATCH 3/3] drivers: cpufreq: qcom-cpufreq-nvmem: support specific
 cpufreq driver

Add support for specific cpufreq driver for qcom-cpufreq-nvmem driver.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
---
 drivers/cpufreq/qcom-cpufreq-nvmem.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -52,6 +52,7 @@ struct qcom_cpufreq_match_data {
 			   char **pvs_name,
 			   struct qcom_cpufreq_drv *drv);
 	const char **genpd_names;
+	const char *cpufreq_driver;
 };
 
 struct qcom_cpufreq_drv {
@@ -250,6 +251,7 @@ static const struct qcom_cpufreq_match_d
 
 static const struct qcom_cpufreq_match_data match_data_krait = {
 	.get_version = qcom_cpufreq_krait_name_version,
+	.cpufreq_driver = "krait-cpufreq",
 };
 
 static const char *qcs404_genpd_names[] = { "cpr", NULL };
@@ -385,6 +387,19 @@ static int qcom_cpufreq_probe(struct pla
 		}
 	}
 
+	if (drv->data->cpufreq_driver) {
+		cpufreq_dt_pdev = platform_device_register_simple(
+			drv->data->cpufreq_driver, -1, NULL, 0);
+		if (!IS_ERR(cpufreq_dt_pdev)) {
+			platform_set_drvdata(pdev, drv);
+			return 0;
+		} else {
+			dev_err(cpu_dev,
+				"Failed to register dedicated %s cpufreq\n",
+				drv->data->cpufreq_driver);
+		}
+	}
+
 	cpufreq_dt_pdev = platform_device_register_simple("cpufreq-dt", -1,
 							  NULL, 0);
 	if (!IS_ERR(cpufreq_dt_pdev)) {
