Re: [PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-20 Thread sricharan

Hi Sudeep,



Register a cpufreq-generic device whenever we detect that a
"qcom,krait" compatible CPU is present in DT.



Just curious to know how different is this from qcom kryo driver
that was added recently. IIRC even that gets the speedbin from nvmem.
Can they be merged ? I don't see need to have different driver for 
Krait

and Kryo CPUs when the code is not even remotely related to CPU type.

Sorry if I have missed anything from previous versions, I just happen
to open and looked at this series first time today.


 Correct, having these two merged was pointed out earlier as well by 
Viresh.
 Now that kryo is merged, i will check once and see if they can be 
nicely

 merged.

Regards,
 Sricharan


Re: [PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-20 Thread sricharan

Hi Sudeep,



Register a cpufreq-generic device whenever we detect that a
"qcom,krait" compatible CPU is present in DT.



Just curious to know how different is this from qcom kryo driver
that was added recently. IIRC even that gets the speedbin from nvmem.
Can they be merged ? I don't see need to have different driver for 
Krait

and Kryo CPUs when the code is not even remotely related to CPU type.

Sorry if I have missed anything from previous versions, I just happen
to open and looked at this series first time today.


 Correct, having these two merged was pointed out earlier as well by 
Viresh.
 Now that kryo is merged, i will check once and see if they can be 
nicely

 merged.

Regards,
 Sricharan


Re: [PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-20 Thread sricharan

On 2018-06-19 20:59, Craig Tatlor wrote:

The pvs refuse check is incorrect... With downstream it says it isn't
blown and that it is 11, which also happens on upstream if I import 
it's

efuse reading code from an older revision, or comment out the check.



 ok, atleast on my ipq8064, it works the same. let me check once.


Also, I'm still getting my issue about clocks above 2,147,483,647hz
however I think this may be related to the division in the hfpll driver
so I'll have a debug around there.



  hmm, atleast on ipq8064, it goes till the max frequency. As you said
  it might be to do with the hfpll driver that runs on 8974. I will try 
to test

  on that hardware.

  That said, just realized that i missed a minor comment from Bjorn.
  Will anyway update it.

Regards,
 Sricharan




On Tue, Jun 19, 2018 at 07:15:24PM +0530, Sricharan R wrote:

From: Stephen Boyd 

Register a cpufreq-generic device whenever we detect that a
"qcom,krait" compatible CPU is present in DT.

Acked-by: Viresh Kumar 
[Sricharan: updated to use dev_pm_opp_set_prop_name and
nvmem apis]
Signed-off-by: Sricharan R 
[Thierry Escande: update to add support for opp-supported-hw]
Signed-off-by: Thierry Escande 
Signed-off-by: Stephen Boyd 
Acked-by: Viresh Kumar 
---
 [v10] updated to add support for opp-supported-hw given by
   Thierry Escande 

 drivers/cpufreq/Kconfig.arm  |  10 ++
 drivers/cpufreq/Makefile |   1 +
 drivers/cpufreq/cpufreq-dt-platdev.c |   5 +
 drivers/cpufreq/qcom-cpufreq.c   | 201 
+++

 4 files changed, 217 insertions(+)
 create mode 100644 drivers/cpufreq/qcom-cpufreq.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 7f56fe5..87e5d8d 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -134,6 +134,16 @@ config ARM_OMAP2PLUS_CPUFREQ
depends on ARCH_OMAP2PLUS
default ARCH_OMAP2PLUS

+config ARM_QCOM_CPUFREQ
+   bool "CPUfreq driver for the QCOM SoCs with KRAIT processors"
+   depends on ARCH_QCOM
+   select PM_OPP
+   help
+ This enables the CPUFreq driver for Qualcomm SoCs with
+ KRAIT processors.
+
+ If in doubt, say N.
+
 config ARM_S3C_CPUFREQ
bool
help
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 8d24ade..c591e1e 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_MACH_MVEBU_V7)   += mvebu-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)+= omap-cpufreq.o
 obj-$(CONFIG_ARM_PXA2xx_CPUFREQ)   += pxa2xx-cpufreq.o
 obj-$(CONFIG_PXA3xx)   += pxa3xx-cpufreq.o
+obj-$(CONFIG_ARM_QCOM_CPUFREQ) += qcom-cpufreq.o
 obj-$(CONFIG_ARM_S3C2410_CPUFREQ)  += s3c2410-cpufreq.o
 obj-$(CONFIG_ARM_S3C2412_CPUFREQ)  += s3c2412-cpufreq.o
 obj-$(CONFIG_ARM_S3C2416_CPUFREQ)  += s3c2416-cpufreq.o
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
b/drivers/cpufreq/cpufreq-dt-platdev.c

index 3b585e4..e2e9a99 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -127,6 +127,11 @@
{ .compatible = "ti,am43", },
{ .compatible = "ti,dra7", },

+   { .compatible = "qcom,ipq8064", },
+   { .compatible = "qcom,apq8064", },
+   { .compatible = "qcom,msm8974", },
+   { .compatible = "qcom,msm8960", },
+
{ }
 };

diff --git a/drivers/cpufreq/qcom-cpufreq.c 
b/drivers/cpufreq/qcom-cpufreq.c

new file mode 100644
index 000..1d4ab54
--- /dev/null
+++ b/drivers/cpufreq/qcom-cpufreq.c
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static void __init get_krait_bin_format_a(int *speed, int *pvs, int 
*pvs_ver,

+ struct nvmem_cell *pvs_nvmem, u8 *buf)
+{
+   u32 pte_efuse;
+
+   pte_efuse = *((u32 *)buf);
+
+   *speed = pte_efuse & 0xf;
+   if (*speed == 0xf)
+   *speed = (pte_efuse >> 4) & 0xf;
+
+   if (*speed == 0xf) {
+   *speed = 0;
+   pr_warn("Speed bin: Defaulting to %d\n", *speed);
+   } else {
+   pr_info("Speed bin: %d\n", *speed);
+   }
+
+   *pvs = (pte_efuse >> 10) & 0x7;
+   if (*pvs == 0x7)
+   *pvs = (pte_efuse >> 13) & 0x7;
+
+   if (*pvs == 0x7) {
+   *pvs = 0;
+   pr_warn("PVS bin: Defaulting to %d\n", *pvs);
+   } else {
+   pr_info("PVS bin: %d\n", *pvs);
+   }
+
+   kfree(buf);
+}
+
+static void __init get_krait_bin_format_b(int *speed, int *pvs, int 
*pvs_ver,

+ struct nvmem_cell *pvs_nvmem, u8 *buf)
+{
+   u32 pte_efuse, redundant_sel;
+
+   pte_efuse = *((u32 *)buf);
+   redundant_sel = (pte_efuse >> 24) & 0x7;
+   *speed = 

Re: [PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-20 Thread sricharan

On 2018-06-19 20:59, Craig Tatlor wrote:

The pvs refuse check is incorrect... With downstream it says it isn't
blown and that it is 11, which also happens on upstream if I import 
it's

efuse reading code from an older revision, or comment out the check.



 ok, atleast on my ipq8064, it works the same. let me check once.


Also, I'm still getting my issue about clocks above 2,147,483,647hz
however I think this may be related to the division in the hfpll driver
so I'll have a debug around there.



  hmm, atleast on ipq8064, it goes till the max frequency. As you said
  it might be to do with the hfpll driver that runs on 8974. I will try 
to test

  on that hardware.

  That said, just realized that i missed a minor comment from Bjorn.
  Will anyway update it.

Regards,
 Sricharan




On Tue, Jun 19, 2018 at 07:15:24PM +0530, Sricharan R wrote:

From: Stephen Boyd 

Register a cpufreq-generic device whenever we detect that a
"qcom,krait" compatible CPU is present in DT.

Acked-by: Viresh Kumar 
[Sricharan: updated to use dev_pm_opp_set_prop_name and
nvmem apis]
Signed-off-by: Sricharan R 
[Thierry Escande: update to add support for opp-supported-hw]
Signed-off-by: Thierry Escande 
Signed-off-by: Stephen Boyd 
Acked-by: Viresh Kumar 
---
 [v10] updated to add support for opp-supported-hw given by
   Thierry Escande 

 drivers/cpufreq/Kconfig.arm  |  10 ++
 drivers/cpufreq/Makefile |   1 +
 drivers/cpufreq/cpufreq-dt-platdev.c |   5 +
 drivers/cpufreq/qcom-cpufreq.c   | 201 
+++

 4 files changed, 217 insertions(+)
 create mode 100644 drivers/cpufreq/qcom-cpufreq.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 7f56fe5..87e5d8d 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -134,6 +134,16 @@ config ARM_OMAP2PLUS_CPUFREQ
depends on ARCH_OMAP2PLUS
default ARCH_OMAP2PLUS

+config ARM_QCOM_CPUFREQ
+   bool "CPUfreq driver for the QCOM SoCs with KRAIT processors"
+   depends on ARCH_QCOM
+   select PM_OPP
+   help
+ This enables the CPUFreq driver for Qualcomm SoCs with
+ KRAIT processors.
+
+ If in doubt, say N.
+
 config ARM_S3C_CPUFREQ
bool
help
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 8d24ade..c591e1e 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_MACH_MVEBU_V7)   += mvebu-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)+= omap-cpufreq.o
 obj-$(CONFIG_ARM_PXA2xx_CPUFREQ)   += pxa2xx-cpufreq.o
 obj-$(CONFIG_PXA3xx)   += pxa3xx-cpufreq.o
+obj-$(CONFIG_ARM_QCOM_CPUFREQ) += qcom-cpufreq.o
 obj-$(CONFIG_ARM_S3C2410_CPUFREQ)  += s3c2410-cpufreq.o
 obj-$(CONFIG_ARM_S3C2412_CPUFREQ)  += s3c2412-cpufreq.o
 obj-$(CONFIG_ARM_S3C2416_CPUFREQ)  += s3c2416-cpufreq.o
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
b/drivers/cpufreq/cpufreq-dt-platdev.c

index 3b585e4..e2e9a99 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -127,6 +127,11 @@
{ .compatible = "ti,am43", },
{ .compatible = "ti,dra7", },

+   { .compatible = "qcom,ipq8064", },
+   { .compatible = "qcom,apq8064", },
+   { .compatible = "qcom,msm8974", },
+   { .compatible = "qcom,msm8960", },
+
{ }
 };

diff --git a/drivers/cpufreq/qcom-cpufreq.c 
b/drivers/cpufreq/qcom-cpufreq.c

new file mode 100644
index 000..1d4ab54
--- /dev/null
+++ b/drivers/cpufreq/qcom-cpufreq.c
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static void __init get_krait_bin_format_a(int *speed, int *pvs, int 
*pvs_ver,

+ struct nvmem_cell *pvs_nvmem, u8 *buf)
+{
+   u32 pte_efuse;
+
+   pte_efuse = *((u32 *)buf);
+
+   *speed = pte_efuse & 0xf;
+   if (*speed == 0xf)
+   *speed = (pte_efuse >> 4) & 0xf;
+
+   if (*speed == 0xf) {
+   *speed = 0;
+   pr_warn("Speed bin: Defaulting to %d\n", *speed);
+   } else {
+   pr_info("Speed bin: %d\n", *speed);
+   }
+
+   *pvs = (pte_efuse >> 10) & 0x7;
+   if (*pvs == 0x7)
+   *pvs = (pte_efuse >> 13) & 0x7;
+
+   if (*pvs == 0x7) {
+   *pvs = 0;
+   pr_warn("PVS bin: Defaulting to %d\n", *pvs);
+   } else {
+   pr_info("PVS bin: %d\n", *pvs);
+   }
+
+   kfree(buf);
+}
+
+static void __init get_krait_bin_format_b(int *speed, int *pvs, int 
*pvs_ver,

+ struct nvmem_cell *pvs_nvmem, u8 *buf)
+{
+   u32 pte_efuse, redundant_sel;
+
+   pte_efuse = *((u32 *)buf);
+   redundant_sel = (pte_efuse >> 24) & 0x7;
+   *speed = 

Re: [PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-19 Thread Craig Tatlor
The pvs refuse check is incorrect... With downstream it says it isn't
blown and that it is 11, which also happens on upstream if I import it's
efuse reading code from an older revision, or comment out the check.

Also, I'm still getting my issue about clocks above 2,147,483,647hz
however I think this may be related to the division in the hfpll driver
so I'll have a debug around there.

On Tue, Jun 19, 2018 at 07:15:24PM +0530, Sricharan R wrote:
> From: Stephen Boyd 
> 
> Register a cpufreq-generic device whenever we detect that a
> "qcom,krait" compatible CPU is present in DT.
> 
> Acked-by: Viresh Kumar 
> [Sricharan: updated to use dev_pm_opp_set_prop_name and
>   nvmem apis]
> Signed-off-by: Sricharan R 
> [Thierry Escande: update to add support for opp-supported-hw]
> Signed-off-by: Thierry Escande 
> Signed-off-by: Stephen Boyd 
> Acked-by: Viresh Kumar 
> ---
>  [v10] updated to add support for opp-supported-hw given by
>Thierry Escande 
> 
>  drivers/cpufreq/Kconfig.arm  |  10 ++
>  drivers/cpufreq/Makefile |   1 +
>  drivers/cpufreq/cpufreq-dt-platdev.c |   5 +
>  drivers/cpufreq/qcom-cpufreq.c   | 201 
> +++
>  4 files changed, 217 insertions(+)
>  create mode 100644 drivers/cpufreq/qcom-cpufreq.c
> 
> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
> index 7f56fe5..87e5d8d 100644
> --- a/drivers/cpufreq/Kconfig.arm
> +++ b/drivers/cpufreq/Kconfig.arm
> @@ -134,6 +134,16 @@ config ARM_OMAP2PLUS_CPUFREQ
>   depends on ARCH_OMAP2PLUS
>   default ARCH_OMAP2PLUS
>  
> +config ARM_QCOM_CPUFREQ
> + bool "CPUfreq driver for the QCOM SoCs with KRAIT processors"
> + depends on ARCH_QCOM
> + select PM_OPP
> + help
> +   This enables the CPUFreq driver for Qualcomm SoCs with
> +   KRAIT processors.
> +
> +   If in doubt, say N.
> +
>  config ARM_S3C_CPUFREQ
>   bool
>   help
> diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
> index 8d24ade..c591e1e 100644
> --- a/drivers/cpufreq/Makefile
> +++ b/drivers/cpufreq/Makefile
> @@ -65,6 +65,7 @@ obj-$(CONFIG_MACH_MVEBU_V7) += mvebu-cpufreq.o
>  obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)  += omap-cpufreq.o
>  obj-$(CONFIG_ARM_PXA2xx_CPUFREQ) += pxa2xx-cpufreq.o
>  obj-$(CONFIG_PXA3xx) += pxa3xx-cpufreq.o
> +obj-$(CONFIG_ARM_QCOM_CPUFREQ)   += qcom-cpufreq.o
>  obj-$(CONFIG_ARM_S3C2410_CPUFREQ)+= s3c2410-cpufreq.o
>  obj-$(CONFIG_ARM_S3C2412_CPUFREQ)+= s3c2412-cpufreq.o
>  obj-$(CONFIG_ARM_S3C2416_CPUFREQ)+= s3c2416-cpufreq.o
> diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
> b/drivers/cpufreq/cpufreq-dt-platdev.c
> index 3b585e4..e2e9a99 100644
> --- a/drivers/cpufreq/cpufreq-dt-platdev.c
> +++ b/drivers/cpufreq/cpufreq-dt-platdev.c
> @@ -127,6 +127,11 @@
>   { .compatible = "ti,am43", },
>   { .compatible = "ti,dra7", },
>  
> + { .compatible = "qcom,ipq8064", },
> + { .compatible = "qcom,apq8064", },
> + { .compatible = "qcom,msm8974", },
> + { .compatible = "qcom,msm8960", },
> +
>   { }
>  };
>  
> diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c
> new file mode 100644
> index 000..1d4ab54
> --- /dev/null
> +++ b/drivers/cpufreq/qcom-cpufreq.c
> @@ -0,0 +1,201 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2018, The Linux Foundation. All rights reserved.
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver,
> +   struct nvmem_cell *pvs_nvmem, u8 *buf)
> +{
> + u32 pte_efuse;
> +
> + pte_efuse = *((u32 *)buf);
> +
> + *speed = pte_efuse & 0xf;
> + if (*speed == 0xf)
> + *speed = (pte_efuse >> 4) & 0xf;
> +
> + if (*speed == 0xf) {
> + *speed = 0;
> + pr_warn("Speed bin: Defaulting to %d\n", *speed);
> + } else {
> + pr_info("Speed bin: %d\n", *speed);
> + }
> +
> + *pvs = (pte_efuse >> 10) & 0x7;
> + if (*pvs == 0x7)
> + *pvs = (pte_efuse >> 13) & 0x7;
> +
> + if (*pvs == 0x7) {
> + *pvs = 0;
> + pr_warn("PVS bin: Defaulting to %d\n", *pvs);
> + } else {
> + pr_info("PVS bin: %d\n", *pvs);
> + }
> +
> + kfree(buf);
> +}
> +
> +static void __init get_krait_bin_format_b(int *speed, int *pvs, int *pvs_ver,
> +   struct nvmem_cell *pvs_nvmem, u8 *buf)
> +{
> + u32 pte_efuse, redundant_sel;
> +
> + pte_efuse = *((u32 *)buf);
> + redundant_sel = (pte_efuse >> 24) & 0x7;
> + *speed = pte_efuse & 0x7;
> +
> + /* 4 bits of PVS are in efuse register bits 31, 8-6. */
> + *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
> + *pvs_ver = (pte_efuse >> 4) & 0x3;
> +
> + switch (redundant_sel) {
> + case 1:
> +  

Re: [PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-19 Thread Craig Tatlor
The pvs refuse check is incorrect... With downstream it says it isn't
blown and that it is 11, which also happens on upstream if I import it's
efuse reading code from an older revision, or comment out the check.

Also, I'm still getting my issue about clocks above 2,147,483,647hz
however I think this may be related to the division in the hfpll driver
so I'll have a debug around there.

On Tue, Jun 19, 2018 at 07:15:24PM +0530, Sricharan R wrote:
> From: Stephen Boyd 
> 
> Register a cpufreq-generic device whenever we detect that a
> "qcom,krait" compatible CPU is present in DT.
> 
> Acked-by: Viresh Kumar 
> [Sricharan: updated to use dev_pm_opp_set_prop_name and
>   nvmem apis]
> Signed-off-by: Sricharan R 
> [Thierry Escande: update to add support for opp-supported-hw]
> Signed-off-by: Thierry Escande 
> Signed-off-by: Stephen Boyd 
> Acked-by: Viresh Kumar 
> ---
>  [v10] updated to add support for opp-supported-hw given by
>Thierry Escande 
> 
>  drivers/cpufreq/Kconfig.arm  |  10 ++
>  drivers/cpufreq/Makefile |   1 +
>  drivers/cpufreq/cpufreq-dt-platdev.c |   5 +
>  drivers/cpufreq/qcom-cpufreq.c   | 201 
> +++
>  4 files changed, 217 insertions(+)
>  create mode 100644 drivers/cpufreq/qcom-cpufreq.c
> 
> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
> index 7f56fe5..87e5d8d 100644
> --- a/drivers/cpufreq/Kconfig.arm
> +++ b/drivers/cpufreq/Kconfig.arm
> @@ -134,6 +134,16 @@ config ARM_OMAP2PLUS_CPUFREQ
>   depends on ARCH_OMAP2PLUS
>   default ARCH_OMAP2PLUS
>  
> +config ARM_QCOM_CPUFREQ
> + bool "CPUfreq driver for the QCOM SoCs with KRAIT processors"
> + depends on ARCH_QCOM
> + select PM_OPP
> + help
> +   This enables the CPUFreq driver for Qualcomm SoCs with
> +   KRAIT processors.
> +
> +   If in doubt, say N.
> +
>  config ARM_S3C_CPUFREQ
>   bool
>   help
> diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
> index 8d24ade..c591e1e 100644
> --- a/drivers/cpufreq/Makefile
> +++ b/drivers/cpufreq/Makefile
> @@ -65,6 +65,7 @@ obj-$(CONFIG_MACH_MVEBU_V7) += mvebu-cpufreq.o
>  obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)  += omap-cpufreq.o
>  obj-$(CONFIG_ARM_PXA2xx_CPUFREQ) += pxa2xx-cpufreq.o
>  obj-$(CONFIG_PXA3xx) += pxa3xx-cpufreq.o
> +obj-$(CONFIG_ARM_QCOM_CPUFREQ)   += qcom-cpufreq.o
>  obj-$(CONFIG_ARM_S3C2410_CPUFREQ)+= s3c2410-cpufreq.o
>  obj-$(CONFIG_ARM_S3C2412_CPUFREQ)+= s3c2412-cpufreq.o
>  obj-$(CONFIG_ARM_S3C2416_CPUFREQ)+= s3c2416-cpufreq.o
> diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
> b/drivers/cpufreq/cpufreq-dt-platdev.c
> index 3b585e4..e2e9a99 100644
> --- a/drivers/cpufreq/cpufreq-dt-platdev.c
> +++ b/drivers/cpufreq/cpufreq-dt-platdev.c
> @@ -127,6 +127,11 @@
>   { .compatible = "ti,am43", },
>   { .compatible = "ti,dra7", },
>  
> + { .compatible = "qcom,ipq8064", },
> + { .compatible = "qcom,apq8064", },
> + { .compatible = "qcom,msm8974", },
> + { .compatible = "qcom,msm8960", },
> +
>   { }
>  };
>  
> diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c
> new file mode 100644
> index 000..1d4ab54
> --- /dev/null
> +++ b/drivers/cpufreq/qcom-cpufreq.c
> @@ -0,0 +1,201 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) 2018, The Linux Foundation. All rights reserved.
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver,
> +   struct nvmem_cell *pvs_nvmem, u8 *buf)
> +{
> + u32 pte_efuse;
> +
> + pte_efuse = *((u32 *)buf);
> +
> + *speed = pte_efuse & 0xf;
> + if (*speed == 0xf)
> + *speed = (pte_efuse >> 4) & 0xf;
> +
> + if (*speed == 0xf) {
> + *speed = 0;
> + pr_warn("Speed bin: Defaulting to %d\n", *speed);
> + } else {
> + pr_info("Speed bin: %d\n", *speed);
> + }
> +
> + *pvs = (pte_efuse >> 10) & 0x7;
> + if (*pvs == 0x7)
> + *pvs = (pte_efuse >> 13) & 0x7;
> +
> + if (*pvs == 0x7) {
> + *pvs = 0;
> + pr_warn("PVS bin: Defaulting to %d\n", *pvs);
> + } else {
> + pr_info("PVS bin: %d\n", *pvs);
> + }
> +
> + kfree(buf);
> +}
> +
> +static void __init get_krait_bin_format_b(int *speed, int *pvs, int *pvs_ver,
> +   struct nvmem_cell *pvs_nvmem, u8 *buf)
> +{
> + u32 pte_efuse, redundant_sel;
> +
> + pte_efuse = *((u32 *)buf);
> + redundant_sel = (pte_efuse >> 24) & 0x7;
> + *speed = pte_efuse & 0x7;
> +
> + /* 4 bits of PVS are in efuse register bits 31, 8-6. */
> + *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
> + *pvs_ver = (pte_efuse >> 4) & 0x3;
> +
> + switch (redundant_sel) {
> + case 1:
> +  

Re: [PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-19 Thread Sudeep Holla



On 19/06/18 14:45, Sricharan R wrote:
> From: Stephen Boyd 
> 
> Register a cpufreq-generic device whenever we detect that a
> "qcom,krait" compatible CPU is present in DT.
> 

Just curious to know how different is this from qcom kryo driver
that was added recently. IIRC even that gets the speedbin from nvmem.
Can they be merged ? I don't see need to have different driver for Krait
and Kryo CPUs when the code is not even remotely related to CPU type.

Sorry if I have missed anything from previous versions, I just happen
to open and looked at this series first time today.

-- 
Regards,
Sudeep


Re: [PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-19 Thread Sudeep Holla



On 19/06/18 14:45, Sricharan R wrote:
> From: Stephen Boyd 
> 
> Register a cpufreq-generic device whenever we detect that a
> "qcom,krait" compatible CPU is present in DT.
> 

Just curious to know how different is this from qcom kryo driver
that was added recently. IIRC even that gets the speedbin from nvmem.
Can they be merged ? I don't see need to have different driver for Krait
and Kryo CPUs when the code is not even remotely related to CPU type.

Sorry if I have missed anything from previous versions, I just happen
to open and looked at this series first time today.

-- 
Regards,
Sudeep


[PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-19 Thread Sricharan R
From: Stephen Boyd 

Register a cpufreq-generic device whenever we detect that a
"qcom,krait" compatible CPU is present in DT.

Acked-by: Viresh Kumar 
[Sricharan: updated to use dev_pm_opp_set_prop_name and
nvmem apis]
Signed-off-by: Sricharan R 
[Thierry Escande: update to add support for opp-supported-hw]
Signed-off-by: Thierry Escande 
Signed-off-by: Stephen Boyd 
Acked-by: Viresh Kumar 
---
 [v10] updated to add support for opp-supported-hw given by
   Thierry Escande 

 drivers/cpufreq/Kconfig.arm  |  10 ++
 drivers/cpufreq/Makefile |   1 +
 drivers/cpufreq/cpufreq-dt-platdev.c |   5 +
 drivers/cpufreq/qcom-cpufreq.c   | 201 +++
 4 files changed, 217 insertions(+)
 create mode 100644 drivers/cpufreq/qcom-cpufreq.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 7f56fe5..87e5d8d 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -134,6 +134,16 @@ config ARM_OMAP2PLUS_CPUFREQ
depends on ARCH_OMAP2PLUS
default ARCH_OMAP2PLUS
 
+config ARM_QCOM_CPUFREQ
+   bool "CPUfreq driver for the QCOM SoCs with KRAIT processors"
+   depends on ARCH_QCOM
+   select PM_OPP
+   help
+ This enables the CPUFreq driver for Qualcomm SoCs with
+ KRAIT processors.
+
+ If in doubt, say N.
+
 config ARM_S3C_CPUFREQ
bool
help
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 8d24ade..c591e1e 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_MACH_MVEBU_V7)   += mvebu-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)+= omap-cpufreq.o
 obj-$(CONFIG_ARM_PXA2xx_CPUFREQ)   += pxa2xx-cpufreq.o
 obj-$(CONFIG_PXA3xx)   += pxa3xx-cpufreq.o
+obj-$(CONFIG_ARM_QCOM_CPUFREQ) += qcom-cpufreq.o
 obj-$(CONFIG_ARM_S3C2410_CPUFREQ)  += s3c2410-cpufreq.o
 obj-$(CONFIG_ARM_S3C2412_CPUFREQ)  += s3c2412-cpufreq.o
 obj-$(CONFIG_ARM_S3C2416_CPUFREQ)  += s3c2416-cpufreq.o
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
b/drivers/cpufreq/cpufreq-dt-platdev.c
index 3b585e4..e2e9a99 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -127,6 +127,11 @@
{ .compatible = "ti,am43", },
{ .compatible = "ti,dra7", },
 
+   { .compatible = "qcom,ipq8064", },
+   { .compatible = "qcom,apq8064", },
+   { .compatible = "qcom,msm8974", },
+   { .compatible = "qcom,msm8960", },
+
{ }
 };
 
diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c
new file mode 100644
index 000..1d4ab54
--- /dev/null
+++ b/drivers/cpufreq/qcom-cpufreq.c
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver,
+ struct nvmem_cell *pvs_nvmem, u8 *buf)
+{
+   u32 pte_efuse;
+
+   pte_efuse = *((u32 *)buf);
+
+   *speed = pte_efuse & 0xf;
+   if (*speed == 0xf)
+   *speed = (pte_efuse >> 4) & 0xf;
+
+   if (*speed == 0xf) {
+   *speed = 0;
+   pr_warn("Speed bin: Defaulting to %d\n", *speed);
+   } else {
+   pr_info("Speed bin: %d\n", *speed);
+   }
+
+   *pvs = (pte_efuse >> 10) & 0x7;
+   if (*pvs == 0x7)
+   *pvs = (pte_efuse >> 13) & 0x7;
+
+   if (*pvs == 0x7) {
+   *pvs = 0;
+   pr_warn("PVS bin: Defaulting to %d\n", *pvs);
+   } else {
+   pr_info("PVS bin: %d\n", *pvs);
+   }
+
+   kfree(buf);
+}
+
+static void __init get_krait_bin_format_b(int *speed, int *pvs, int *pvs_ver,
+ struct nvmem_cell *pvs_nvmem, u8 *buf)
+{
+   u32 pte_efuse, redundant_sel;
+
+   pte_efuse = *((u32 *)buf);
+   redundant_sel = (pte_efuse >> 24) & 0x7;
+   *speed = pte_efuse & 0x7;
+
+   /* 4 bits of PVS are in efuse register bits 31, 8-6. */
+   *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
+   *pvs_ver = (pte_efuse >> 4) & 0x3;
+
+   switch (redundant_sel) {
+   case 1:
+   *speed = (pte_efuse >> 27) & 0xf;
+   break;
+   case 2:
+   *pvs = (pte_efuse >> 27) & 0xf;
+   break;
+   }
+
+   /* Check SPEED_BIN_BLOW_STATUS */
+   if (pte_efuse & BIT(3)) {
+   pr_info("Speed bin: %d\n", *speed);
+   } else {
+   pr_warn("Speed bin not set. Defaulting to 0!\n");
+   *speed = 0;
+   }
+
+   /* Check PVS_BLOW_STATUS */
+   pte_efuse = *(((u32 *)buf) + 4);
+   if (pte_efuse) {
+   pr_info("PVS bin: %d\n", *pvs);
+   } else {
+   pr_warn("PVS bin not 

[PATCH v10 13/14] cpufreq: Add module to register cpufreq on Krait CPUs

2018-06-19 Thread Sricharan R
From: Stephen Boyd 

Register a cpufreq-generic device whenever we detect that a
"qcom,krait" compatible CPU is present in DT.

Acked-by: Viresh Kumar 
[Sricharan: updated to use dev_pm_opp_set_prop_name and
nvmem apis]
Signed-off-by: Sricharan R 
[Thierry Escande: update to add support for opp-supported-hw]
Signed-off-by: Thierry Escande 
Signed-off-by: Stephen Boyd 
Acked-by: Viresh Kumar 
---
 [v10] updated to add support for opp-supported-hw given by
   Thierry Escande 

 drivers/cpufreq/Kconfig.arm  |  10 ++
 drivers/cpufreq/Makefile |   1 +
 drivers/cpufreq/cpufreq-dt-platdev.c |   5 +
 drivers/cpufreq/qcom-cpufreq.c   | 201 +++
 4 files changed, 217 insertions(+)
 create mode 100644 drivers/cpufreq/qcom-cpufreq.c

diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
index 7f56fe5..87e5d8d 100644
--- a/drivers/cpufreq/Kconfig.arm
+++ b/drivers/cpufreq/Kconfig.arm
@@ -134,6 +134,16 @@ config ARM_OMAP2PLUS_CPUFREQ
depends on ARCH_OMAP2PLUS
default ARCH_OMAP2PLUS
 
+config ARM_QCOM_CPUFREQ
+   bool "CPUfreq driver for the QCOM SoCs with KRAIT processors"
+   depends on ARCH_QCOM
+   select PM_OPP
+   help
+ This enables the CPUFreq driver for Qualcomm SoCs with
+ KRAIT processors.
+
+ If in doubt, say N.
+
 config ARM_S3C_CPUFREQ
bool
help
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index 8d24ade..c591e1e 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_MACH_MVEBU_V7)   += mvebu-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)+= omap-cpufreq.o
 obj-$(CONFIG_ARM_PXA2xx_CPUFREQ)   += pxa2xx-cpufreq.o
 obj-$(CONFIG_PXA3xx)   += pxa3xx-cpufreq.o
+obj-$(CONFIG_ARM_QCOM_CPUFREQ) += qcom-cpufreq.o
 obj-$(CONFIG_ARM_S3C2410_CPUFREQ)  += s3c2410-cpufreq.o
 obj-$(CONFIG_ARM_S3C2412_CPUFREQ)  += s3c2412-cpufreq.o
 obj-$(CONFIG_ARM_S3C2416_CPUFREQ)  += s3c2416-cpufreq.o
diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c 
b/drivers/cpufreq/cpufreq-dt-platdev.c
index 3b585e4..e2e9a99 100644
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -127,6 +127,11 @@
{ .compatible = "ti,am43", },
{ .compatible = "ti,dra7", },
 
+   { .compatible = "qcom,ipq8064", },
+   { .compatible = "qcom,apq8064", },
+   { .compatible = "qcom,msm8974", },
+   { .compatible = "qcom,msm8960", },
+
{ }
 };
 
diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c
new file mode 100644
index 000..1d4ab54
--- /dev/null
+++ b/drivers/cpufreq/qcom-cpufreq.c
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver,
+ struct nvmem_cell *pvs_nvmem, u8 *buf)
+{
+   u32 pte_efuse;
+
+   pte_efuse = *((u32 *)buf);
+
+   *speed = pte_efuse & 0xf;
+   if (*speed == 0xf)
+   *speed = (pte_efuse >> 4) & 0xf;
+
+   if (*speed == 0xf) {
+   *speed = 0;
+   pr_warn("Speed bin: Defaulting to %d\n", *speed);
+   } else {
+   pr_info("Speed bin: %d\n", *speed);
+   }
+
+   *pvs = (pte_efuse >> 10) & 0x7;
+   if (*pvs == 0x7)
+   *pvs = (pte_efuse >> 13) & 0x7;
+
+   if (*pvs == 0x7) {
+   *pvs = 0;
+   pr_warn("PVS bin: Defaulting to %d\n", *pvs);
+   } else {
+   pr_info("PVS bin: %d\n", *pvs);
+   }
+
+   kfree(buf);
+}
+
+static void __init get_krait_bin_format_b(int *speed, int *pvs, int *pvs_ver,
+ struct nvmem_cell *pvs_nvmem, u8 *buf)
+{
+   u32 pte_efuse, redundant_sel;
+
+   pte_efuse = *((u32 *)buf);
+   redundant_sel = (pte_efuse >> 24) & 0x7;
+   *speed = pte_efuse & 0x7;
+
+   /* 4 bits of PVS are in efuse register bits 31, 8-6. */
+   *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7);
+   *pvs_ver = (pte_efuse >> 4) & 0x3;
+
+   switch (redundant_sel) {
+   case 1:
+   *speed = (pte_efuse >> 27) & 0xf;
+   break;
+   case 2:
+   *pvs = (pte_efuse >> 27) & 0xf;
+   break;
+   }
+
+   /* Check SPEED_BIN_BLOW_STATUS */
+   if (pte_efuse & BIT(3)) {
+   pr_info("Speed bin: %d\n", *speed);
+   } else {
+   pr_warn("Speed bin not set. Defaulting to 0!\n");
+   *speed = 0;
+   }
+
+   /* Check PVS_BLOW_STATUS */
+   pte_efuse = *(((u32 *)buf) + 4);
+   if (pte_efuse) {
+   pr_info("PVS bin: %d\n", *pvs);
+   } else {
+   pr_warn("PVS bin not