cpufreq: according efuse info to use different tables [1/2]
authorHong Guo <hong.guo@amlogic.com>
Tue, 5 Nov 2019 08:20:45 +0000 (16:20 +0800)
committerTellen Yu <tellen.yu@amlogic.com>
Fri, 29 Nov 2019 03:34:36 +0000 (11:34 +0800)
PD#SWPL-15870

Problem:
according efuse info to use different tables

Solution:
according efuse info to use different tables

Verify:
test pass on sm1_ac200

Change-Id: Iac842dea13e75c9b0cb81a9b18d002930bf0d513
Signed-off-by: Hong Guo <hong.guo@amlogic.com>
arch/arm/boot/dts/amlogic/g12a_s905d2_u200.dts
arch/arm/boot/dts/amlogic/sm1_s905d3_ac200.dts
arch/arm64/boot/dts/amlogic/g12a_s905d2_u200.dts
arch/arm64/boot/dts/amlogic/sm1_s905d3_ac200.dts
drivers/amlogic/cpufreq/meson-cpufreq.c
drivers/amlogic/cpufreq/meson-cpufreq.h

index 1b2db6780670e0a2440c10b6c9b61b9b89c5b24b..3aef11f123c54c46c55cb9d70bd7f3c1783a7711 100755 (executable)
 }; /* end of / */
 
 &CPU0 {
-       /*set differents table cpufreq max*/
-       diff_tables_supply;
-       hispeed_cpufreq_max = <2100>;
-       medspeed_cpufreq_max = <1908>;
-       lospeed_cpufreq_max = <1800>;
+       /*set multi table cpufreq max*/
+       multi_tables_available;
        operating-points-v2 = <&cpu_opp_table0>,
                        <&cpu_opp_table1>,
                        <&cpu_opp_table2>;
 };
 
 &CPU1 {
-       /*set differents table cpufreq max*/
-       diff_tables_supply;
-       hispeed_cpufreq_max = <2100>;
-       medspeed_cpufreq_max = <1908>;
-       lospeed_cpufreq_max = <1800>;
+       /*set multi table cpufreq max*/
+       multi_tables_available;
        operating-points-v2 = <&cpu_opp_table0>,
                        <&cpu_opp_table1>,
                        <&cpu_opp_table2>;
 };
 
 &CPU2 {
-       /*set differents table cpufreq max*/
-       diff_tables_supply;
-       hispeed_cpufreq_max = <2100>;
-       medspeed_cpufreq_max = <1908>;
-       lospeed_cpufreq_max = <1800>;
+       /*set multi table cpufreq max*/
+       multi_tables_available;
        operating-points-v2 = <&cpu_opp_table0>,
                        <&cpu_opp_table1>,
                        <&cpu_opp_table2>;
 };
 
 &CPU3 {
-       /*set differents table cpufreq max*/
-       diff_tables_supply;
-       hispeed_cpufreq_max = <2100>;
-       medspeed_cpufreq_max = <1908>;
-       lospeed_cpufreq_max = <1800>;
+       /*set multi table cpufreq max*/
+       multi_tables_available;
        operating-points-v2 = <&cpu_opp_table0>,
                        <&cpu_opp_table1>,
                        <&cpu_opp_table2>;
index 8926afa68fa2f805512548a41aba77be2bebce7a..a027aaddaf730a1692da707c5a93af06446808e2 100644 (file)
                };
                opp11 {
                        opp-hz = /bits/ 64 <1908000000>;
-                       opp-microvolt = <1000000>;
+                       opp-microvolt = <970000>;
+               };
+       };
+
+       cpu_opp_table1: cpu_opp_table1 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp00 {
+                       opp-hz = /bits/ 64 <100000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp01 {
+                       opp-hz = /bits/ 64 <250000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp02 {
+                       opp-hz = /bits/ 64 <500000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp03 {
+                       opp-hz = /bits/ 64 <667000000>;
+                       opp-microvolt = <780000>;
+               };
+               opp04 {
+                       opp-hz = /bits/ 64 <1000000000>;
+                       opp-microvolt = <800000>;
+               };
+               opp05 {
+                       opp-hz = /bits/ 64 <1200000000>;
+                       opp-microvolt = <810000>;
+               };
+               opp06 {
+                       opp-hz = /bits/ 64 <1404000000>;
+                       opp-microvolt = <820000>;
+               };
+               opp07 {
+                       opp-hz = /bits/ 64 <1500000000>;
+                       opp-microvolt = <830000>;
+               };
+               opp08 {
+                       opp-hz = /bits/ 64 <1608000000>;
+                       opp-microvolt = <860000>;
+               };
+               opp09 {
+                       opp-hz = /bits/ 64 <1704000000>;
+                       opp-microvolt = <900000>;
+               };
+               opp10 {
+                       opp-hz = /bits/ 64 <1800000000>;
+                       opp-microvolt = <910000>;
+               };
+               opp11 {
+                       opp-hz = /bits/ 64 <1908000000>;
+                       opp-microvolt = <910000>;
+               };
+       };
+
+       cpu_opp_table2: cpu_opp_table2 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp00 {
+                       opp-hz = /bits/ 64 <100000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp01 {
+                       opp-hz = /bits/ 64 <250000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp02 {
+                       opp-hz = /bits/ 64 <500000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp03 {
+                       opp-hz = /bits/ 64 <667000000>;
+                       opp-microvolt = <780000>;
+               };
+               opp04 {
+                       opp-hz = /bits/ 64 <1000000000>;
+                       opp-microvolt = <800000>;
+               };
+               opp05 {
+                       opp-hz = /bits/ 64 <1200000000>;
+                       opp-microvolt = <810000>;
+               };
+               opp06 {
+                       opp-hz = /bits/ 64 <1404000000>;
+                       opp-microvolt = <820000>;
+               };
+               opp07 {
+                       opp-hz = /bits/ 64 <1500000000>;
+                       opp-microvolt = <830000>;
+               };
+               opp08 {
+                       opp-hz = /bits/ 64 <1608000000>;
+                       opp-microvolt = <860000>;
+               };
+               opp09 {
+                       opp-hz = /bits/ 64 <1704000000>;
+                       opp-microvolt = <860000>;
+               };
+               opp10 {
+                       opp-hz = /bits/ 64 <1800000000>;
+                       opp-microvolt = <860000>;
+               };
+               opp11 {
+                       opp-hz = /bits/ 64 <1908000000>;
+                       opp-microvolt = <860000>;
                };
        };
 
 
 }; /* end of / */
 
+&CPU0 {
+       /*set differents table cpufreq max*/
+       multi_tables_available;
+       operating-points-v2 = <&cpu_opp_table0>,
+                       <&cpu_opp_table1>,
+                       <&cpu_opp_table2>;
+};
+
+&CPU1 {
+       /*set differents table cpufreq max*/
+       multi_tables_available;
+       operating-points-v2 = <&cpu_opp_table0>,
+                       <&cpu_opp_table1>,
+                       <&cpu_opp_table2>;
+};
+
+&CPU2 {
+       /*set differents table cpufreq max*/
+       multi_tables_available;
+       operating-points-v2 = <&cpu_opp_table0>,
+                       <&cpu_opp_table1>,
+                       <&cpu_opp_table2>;
+};
+
+&CPU3 {
+       /*set differents table cpufreq max*/
+       multi_tables_available;
+       operating-points-v2 = <&cpu_opp_table0>,
+                       <&cpu_opp_table1>,
+                       <&cpu_opp_table2>;
+};
+
 &meson_fb {
        status = "okay";
        display_size_default = <1920 1080 1920 2160 32>;
index f4ef12ce1cfc3fc1fedaf1daa3ea0f5dc95889a1..4f264bee19bbc16e966a3e60d080dd5d55f42bae 100644 (file)
 }; /* end of / */
 
 &CPU0 {
-       /*set differents table cpufreq max*/
-       diff_tables_supply;
-       hispeed_cpufreq_max = <2100>;
-       medspeed_cpufreq_max = <1908>;
-       lospeed_cpufreq_max = <1800>;
+       /*set multi table cpufreq max*/
+       multi_tables_available;
        operating-points-v2 = <&cpu_opp_table0>,
                        <&cpu_opp_table1>,
                        <&cpu_opp_table2>;
 };
 
 &CPU1 {
-       /*set differents table cpufreq max*/
-       diff_tables_supply;
-       hispeed_cpufreq_max = <2100>;
-       medspeed_cpufreq_max = <1908>;
-       lospeed_cpufreq_max = <1800>;
+       /*set multi table cpufreq max*/
+       multi_tables_available;
        operating-points-v2 = <&cpu_opp_table0>,
                        <&cpu_opp_table1>,
                        <&cpu_opp_table2>;
 };
 
 &CPU2 {
-       /*set differents table cpufreq max*/
-       diff_tables_supply;
-       hispeed_cpufreq_max = <2100>;
-       medspeed_cpufreq_max = <1908>;
-       lospeed_cpufreq_max = <1800>;
+       /*set multi table cpufreq max*/
+       multi_tables_available;
        operating-points-v2 = <&cpu_opp_table0>,
                        <&cpu_opp_table1>,
                        <&cpu_opp_table2>;
 };
 
 &CPU3 {
-       /*set differents table cpufreq max*/
-       diff_tables_supply;
-       hispeed_cpufreq_max = <2100>;
-       medspeed_cpufreq_max = <1908>;
-       lospeed_cpufreq_max = <1800>;
+       /*set multi table cpufreq max*/
+       multi_tables_available;
        operating-points-v2 = <&cpu_opp_table0>,
                        <&cpu_opp_table1>,
                        <&cpu_opp_table2>;
index 3322c284d5dbcb9a1e1bf657e0880e6f4cdacbde..0f047de815c551e8d35ee9f90780ace06b738b0e 100644 (file)
                };
                opp11 {
                        opp-hz = /bits/ 64 <1908000000>;
-                       opp-microvolt = <1000000>;
+                       opp-microvolt = <970000>;
+               };
+       };
+
+       cpu_opp_table1: cpu_opp_table1 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp00 {
+                       opp-hz = /bits/ 64 <100000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp01 {
+                       opp-hz = /bits/ 64 <250000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp02 {
+                       opp-hz = /bits/ 64 <500000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp03 {
+                       opp-hz = /bits/ 64 <667000000>;
+                       opp-microvolt = <780000>;
+               };
+               opp04 {
+                       opp-hz = /bits/ 64 <1000000000>;
+                       opp-microvolt = <800000>;
+               };
+               opp05 {
+                       opp-hz = /bits/ 64 <1200000000>;
+                       opp-microvolt = <810000>;
+               };
+               opp06 {
+                       opp-hz = /bits/ 64 <1404000000>;
+                       opp-microvolt = <820000>;
+               };
+               opp07 {
+                       opp-hz = /bits/ 64 <1500000000>;
+                       opp-microvolt = <830000>;
+               };
+               opp08 {
+                       opp-hz = /bits/ 64 <1608000000>;
+                       opp-microvolt = <860000>;
+               };
+               opp09 {
+                       opp-hz = /bits/ 64 <1704000000>;
+                       opp-microvolt = <900000>;
+               };
+               opp10 {
+                       opp-hz = /bits/ 64 <1800000000>;
+                       opp-microvolt = <910000>;
+               };
+               opp11 {
+                       opp-hz = /bits/ 64 <1908000000>;
+                       opp-microvolt = <910000>;
+               };
+       };
+
+       cpu_opp_table2: cpu_opp_table2 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp00 {
+                       opp-hz = /bits/ 64 <100000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp01 {
+                       opp-hz = /bits/ 64 <250000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp02 {
+                       opp-hz = /bits/ 64 <500000000>;
+                       opp-microvolt = <760000>;
+               };
+               opp03 {
+                       opp-hz = /bits/ 64 <667000000>;
+                       opp-microvolt = <780000>;
+               };
+               opp04 {
+                       opp-hz = /bits/ 64 <1000000000>;
+                       opp-microvolt = <800000>;
+               };
+               opp05 {
+                       opp-hz = /bits/ 64 <1200000000>;
+                       opp-microvolt = <810000>;
+               };
+               opp06 {
+                       opp-hz = /bits/ 64 <1404000000>;
+                       opp-microvolt = <820000>;
+               };
+               opp07 {
+                       opp-hz = /bits/ 64 <1500000000>;
+                       opp-microvolt = <830000>;
+               };
+               opp08 {
+                       opp-hz = /bits/ 64 <1608000000>;
+                       opp-microvolt = <860000>;
+               };
+               opp09 {
+                       opp-hz = /bits/ 64 <1704000000>;
+                       opp-microvolt = <860000>;
+               };
+               opp10 {
+                       opp-hz = /bits/ 64 <1800000000>;
+                       opp-microvolt = <860000>;
+               };
+               opp11 {
+                       opp-hz = /bits/ 64 <1908000000>;
+                       opp-microvolt = <860000>;
                };
        };
 
 
 }; /* end of / */
 
+&CPU0 {
+       /*set multi table cpufreq max*/
+       multi_tables_available;
+       operating-points-v2 = <&cpu_opp_table0>,
+                       <&cpu_opp_table1>,
+                       <&cpu_opp_table2>;
+};
+
+&CPU1 {
+       /*set multi table cpufreq max*/
+       multi_tables_available;
+       operating-points-v2 = <&cpu_opp_table0>,
+                       <&cpu_opp_table1>,
+                       <&cpu_opp_table2>;
+};
+
+&CPU2 {
+       /*set multi table cpufreq max*/
+       multi_tables_available;
+       operating-points-v2 = <&cpu_opp_table0>,
+                       <&cpu_opp_table1>,
+                       <&cpu_opp_table2>;
+};
+
+&CPU3 {
+       /*set multi table cpufreq max*/
+       multi_tables_available;
+       operating-points-v2 = <&cpu_opp_table0>,
+                       <&cpu_opp_table1>,
+                       <&cpu_opp_table2>;
+};
+
 &meson_fb {
        status = "okay";
        display_size_default = <1920 1080 1920 2160 32>;
index 339362800be5c1cecace6c11cdb40c6b2202f3f2..700c0fc13d68a6b3470c8c3823c21bf9bc0fa671 100644 (file)
 #include <linux/amlogic/scpi_protocol.h>
 #include "../../base/power/opp/opp.h"
 #include "meson-cpufreq.h"
+#include <linux/arm-smccc.h>
+
+static unsigned int get_cpufreq_table_index(u64 function_id,
+                                           u64 arg0, u64 arg1, u64 arg2)
+{
+       struct arm_smccc_res res;
+
+       arm_smccc_smc((unsigned long)function_id,
+                     (unsigned long)arg0,
+                     (unsigned long)arg1,
+                     (unsigned long)arg2,
+                     0, 0, 0, 0, &res);
+       return res.a0;
+}
 
 static unsigned int meson_cpufreq_get_rate(unsigned int cpu)
 {
@@ -316,66 +330,17 @@ static inline u32 get_table_max(struct cpufreq_frequency_table *table)
        return max_freq;
 }
 
-int get_cpufreq_tables_efuse(u32 cur_cluster)
-{
-       int ret, efuse_info;
-       u32 freq, vol;
-
-       efuse_info = scpi_get_cpuinfo(cur_cluster, &freq, &vol);
-       if (efuse_info)
-               pr_err("%s,get invalid efuse_info = %d by mailbox!\n",
-                       __func__, efuse_info);
-
-       pr_info("%s:efuse info for cpufreq =  %u\n", __func__, freq);
-       BUG_ON(freq && freq < EFUSE_CPUFREQ_MIN);
-       freq = DIV_ROUND_UP(freq, CLK_DIV) * CLK_DIV;
-       pr_info("%s:efuse adjust cpufreq =  %u\n", __func__, freq);
-       if (freq >= hispeed_cpufreq_max)
-               ret = HISPEED_INDEX;
-       else if (freq >= medspeed_cpufreq_max && freq < hispeed_cpufreq_max)
-               ret = MEDSPEED_INDEX;
-       else
-               ret = LOSPEED_INDEX;
-
-       return ret;
-}
-
 int choose_cpufreq_tables_index(const struct device_node *np, u32 cur_cluster)
 {
        int ret = 0;
 
-       cpufreq_tables_supply = of_property_read_bool(np, "diff_tables_supply");
+       cpufreq_tables_supply = of_property_read_bool(np,
+                                                     "multi_tables_available");
        if (cpufreq_tables_supply) {
                /*choose appropriate cpufreq tables according efuse info*/
-               if (of_property_read_u32(np, "hispeed_cpufreq_max",
-                                       &hispeed_cpufreq_max)) {
-                       pr_err("%s:don't find the node <dynamic_cpufreq_max>\n",
-                                       __func__);
-                       hispeed_cpufreq_max = 0;
-                       return ret;
-               }
-
-               if (of_property_read_u32(np, "medspeed_cpufreq_max",
-                       &medspeed_cpufreq_max)) {
-                       pr_err("%s:don't find the node <medspeed_cpufreq_max>\n",
-                               __func__);
-                       medspeed_cpufreq_max = 0;
-                       return ret;
-               }
-
-               if (of_property_read_u32(np, "lospeed_cpufreq_max",
-                       &lospeed_cpufreq_max)) {
-                       pr_err("%s:don't find the node <lospeed_cpufreq_max>\n",
-                               __func__);
-                       lospeed_cpufreq_max = 0;
-                       return ret;
-               }
-
-               ret = get_cpufreq_tables_efuse(cur_cluster);
-               pr_info("%s:hispeed_max %u,medspeed_max %u,lospeed_max %u,tables_index %u\n",
-                               __func__, hispeed_cpufreq_max,
-                               medspeed_cpufreq_max, lospeed_cpufreq_max, ret);
-
+               ret = get_cpufreq_table_index(GET_DVFS_TABLE_INDEX,
+                                             cur_cluster, 0, 0);
+               pr_info("%s:tables_index %u\n", __func__, ret);
        }
 
        return ret;
index 836074e1f6edd2cfbd39097c718a6fed8001ec20..222ecdf012a4233f0931564651b221db848edde0 100644 (file)
@@ -59,14 +59,7 @@ static unsigned int gap_rate = (10 * 1000 * 1000);
 unsigned int gp1_clk_target;
 /*whether use different tables or not*/
 bool cpufreq_tables_supply;
-static unsigned int hispeed_cpufreq_max;
-static unsigned int medspeed_cpufreq_max;
-static unsigned int lospeed_cpufreq_max;
-enum cpufreq_index {
-       LOSPEED_INDEX,
-       MEDSPEED_INDEX,
-       HISPEED_INDEX
-};
+#define GET_DVFS_TABLE_INDEX           0x82000088
 
 struct meson_cpufreq_driver_data {
        struct device *cpu_dev;
@@ -87,6 +80,5 @@ static unsigned int meson_cpufreq_set_rate(struct cpufreq_policy *policy,
                                           u32 cur_cluster, u32 rate);
 static int meson_regulator_set_volate(struct regulator *regulator, int old_uv,
                                      int new_uv, int tol_uv);
-int get_cpufreq_tables_efuse(u32 cur_cluster);
 int choose_cpufreq_tables_index(const struct device_node *np, u32 cur_cluster);
 #endif /* __MESON_CPUFREQ_H */