MLK-16710 cpufreq: imx8mq: avoid duplicated OPP table initialization
authorAnson Huang <Anson.Huang@nxp.com>
Fri, 27 Oct 2017 15:40:15 +0000 (23:40 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:39:02 +0000 (15:39 -0500)
On i.MX8MQ, since the OPP table is initialized in cpu-freq platform
device register according to chip type, so no need to redo the OPP
table initialization in cpu-freq driver, this patch adds check for
OPP table initialization to avoid below warning during boot up:

[    1.468378] cpu cpu0: _opp_add: duplicate OPPs detected. Existing: freq: 1501
[    1.468388] cpu cpu0: _opp_add: duplicate OPPs detected. Existing: freq: 1301
[    1.468417] cpu cpu0: _of_add_opp_table_v1: Failed to add OPP 1300000000
[    1.468425] cpu cpu0: _opp_add: duplicate OPPs detected. Existing: freq: 1001
[    1.468434] cpu cpu0: _opp_add: duplicate OPPs detected. Existing: freq: 8001
[    1.468443] cpu cpu0: _of_add_opp_table_v1: Failed to add OPP 800000000

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Reviewed-by: Bai Ping <ping.bai@nxp.com>
drivers/cpufreq/imx8mq-cpufreq.c

index 16feb3f..ee3725d 100644 (file)
@@ -150,7 +150,7 @@ static struct cpufreq_driver imx8mq_cpufreq_driver = {
 static int imx8mq_cpufreq_probe(struct platform_device *pdev)
 {
        struct device_node *np;
-       int ret;
+       int ret, num;
 
        cpu_dev = get_cpu_device(0);
        if (!cpu_dev) {
@@ -179,10 +179,18 @@ static int imx8mq_cpufreq_probe(struct platform_device *pdev)
 
        dc_reg = regulator_get_optional(cpu_dev, "dc");
 
-       ret = dev_pm_opp_of_add_table(cpu_dev);
-       if (ret < 0) {
-               dev_err(cpu_dev, "failed to init OPP table: %d\n", ret);
-               goto put_clk;
+       /*
+        * We expect an OPP table supplied by platform.
+        * Just, incase the platform did not supply the OPP
+        * table, it will try to get it.
+        */
+       num = dev_pm_opp_get_opp_count(cpu_dev);
+       if (num < 0) {
+               ret = dev_pm_opp_of_add_table(cpu_dev);
+               if (ret < 0) {
+                       dev_err(cpu_dev, "failed to init OPP table: %d\n", ret);
+                       goto put_clk;
+               }
        }
 
        ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);