Skip to contentSkip to conversation

Krait clocks + Krait CPUfreq

PATCH In review Sricharan R 5 participants 32 messages Aug 14, 2018 – Oct 24, 2018

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

v12 cover Krait clocks + Krait CPUfreq

[v12]
* Added my signed-off that was missing in some patches.
* Added Bjorn's acked that i missed earlier.

[v11]
* Dropped patch 13 and 14 from v10 and
merged the qcom-cpufreq-krait driver to the existing qcom-cpufreq-kryo.c
* Rebased on top of clk-next
* Fixed a bug while populating the pvs version for krait.

[v10]
* Addressed Stephen's comments to add clocks bindings properties to the newly introduced nodes.
* Added a change to include opp-supported-hw to qcom-cpufreq.c
* Rebased on top of clk-next
* Although there were minor changes to bindings and the driver retained the acked-by tags from Rob and Viresh respectively.

[v9]
* Fixed a rebase issue in Makefile and added Tag from Robh.

[v8]
* Fixed a bug in path#14 pointed out by Viresh and also added tags. No change in any other patch.

[v7]
* Fixed comments from Viresh for cleaning up the error handling in qcom-cpufreq.c. Also changed the init function to lateinit call. This is required because nvmem which gets initialised with module_init needs to go first.
* Fixed Rob's comments for bindings documentation
* Fixed kbuild build issue in clk-lpc32xx.c
* Rebased on top of clk-next

[v6]
* Adrressed comments from Viresh for patch #14 in v5 [5]
* Introduced a new binding operating-points-v2-krait-cpu as per discussion with Rob
* Added Review tags

[v5]
* Addressed comments from Rob for bindings
* Addressed comments from Viresh to use dev_pm_opp_set_prop_name, accordingly dropped patch #12 and corrected patch #11 from previous patch set in [4]
* Converted to use #spdx tags for newly introduced files

Mostly a resend of the v3 posted by Stephen quite some time back [1] except for few changes.
Based on reading some feedback from list,
* Dropped the patch "clk: Add safe switch hook" from v3 [2].
Now this is taken care by patch#10 in this series only for Krait.
* Dropped the path "clk: Avoid sending high rates to downstream clocks during set_rate" from v3 [3].
* Rebased on top of clk-next.
* Dropped the DT update from the series. Will send separately
* Now with cpufreq-dt+opp supporting voltage scaling, registering the krait cpu supplies in DT should be sufficient. But one issue is, the qcom-cpufreq drivers reads the efuse and based on that registers the opp data and then registers the cpufreq-dt device. So when cpufreq-dt driver probes and registers the regulator to the OPP framework, it expects that the opp data for the device should not be registered before the regulator. Will send a RFC patch removing that check, to find out the right way of doing it.

These patches provide cpufreq scaling on devices with Krait CPUs. In Krait CPU designs there's one PLL and two muxes per CPU, allowing us to switch CPU frequencies independently.

				 secondary
	 +-----+                    +
	 | QSB |-------+------------|\
	 +-----+       |            | |-+
		       |    +-------|/  |
		       |    |       +   |
	 +-----+       |    |           |
	 | PLL |----+-------+           |   primary
	 +-----+    |  |                |     +
		    |  |                +-----|\       +------+
	 +-------+  |  |                      | \      |      |
	 | HFPLL |----------+-----------------|  |-----| CPU0 |
	 +-------+  |  |    |                 |  |     |      |
		    |  |    | +-----+         | /      +------+
		    |  |    +-| / 2 |---------|/
		    |  |      +-----+         +
		    |  |         secondary
		    |  |            +
		    |  +------------|\
		    |               | |-+
		    +---------------|/  |   primary
				    +   |     +
					+-----|\       +------+
	 +-------+                            | \      |      |
	 | HFPLL |----------------------------|  |-----| CPU1 |
	 +-------+          |                 |  |     |      |
			    | +-----+         | /      +------+
			    +-| / 2 |---------|/
			      +-----+         +

To support this in the common clock framework we model the muxes, dividers, and PLLs as different clocks. CPUfreq only interacts with the primary mux (farthest right in the diagram). When CPUfreq sets a rate, the mux code finds the best parent that can provide the rate. Due to the design, QSB and the top PLL are always a fixed rate and thus only support one frequency each. These sources provide the lowest frequencies for the CPUs. The HFPLLs are where we can make the CPU go faster (GHz range). Sometimes we need to run the HFPLL twice as fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL because we need to turn off the output of the PLL when changing its frequency. This means we have to switch over to the secondary mux and use one of the fixed sources. This is why we need something like the safe parent patch.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332607.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332615.html
[3] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332608.html
[4] https://lwn.net/Articles/740994/
[5] https://lkml.org/lkml/2017/12/19/537

Sricharan R (3):
clk: qcom: Add safe switch hook for krait mux clocks
cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem
based qcom socs
cpufreq: qcom: Add support for krait based socs

Stephen Boyd (11):
ARM: Add Krait L2 register accessor functions
clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
clk: qcom: Add HFPLL driver
dt-bindings: clock: Document qcom,hfpll
clk: qcom: Add MSM8960/APQ8064's HFPLLs
clk: qcom: Add IPQ806X's HFPLLs
clk: qcom: Add support for Krait clocks
clk: qcom: Add KPSS ACC/GCC driver
dt-bindings: arm: Document qcom,kpss-gcc
clk: qcom: Add Krait clock controller driver
dt-bindings: clock: Document qcom,krait-cc

 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  19 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  44 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt       |  60 ++++
 .../devicetree/bindings/clock/qcom,krait-cc.txt    |  34 ++
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   7 +-
 arch/arm/common/Kconfig                            |   3 +
 arch/arm/common/Makefile                           |   1 +
 arch/arm/common/krait-l2-accessors.c               |  48 +++
 arch/arm/include/asm/krait-l2-accessors.h          |   9 +
 drivers/clk/qcom/Kconfig                           |  28 ++
 drivers/clk/qcom/Makefile                          |   5 +
 drivers/clk/qcom/clk-hfpll.c                       | 244 +++++++++++++
 drivers/clk/qcom/clk-hfpll.h                       |  44 +++
 drivers/clk/qcom/clk-krait.c                       | 126 +++++++
 drivers/clk/qcom/clk-krait.h                       |  40 +++
 drivers/clk/qcom/gcc-ipq806x.c                     |  82 +++++
 drivers/clk/qcom/gcc-msm8960.c                     | 172 +++++++++
 drivers/clk/qcom/hfpll.c                           |  96 +++++
 drivers/clk/qcom/kpss-xcc.c                        |  87 +++++
 drivers/clk/qcom/krait-cc.c                        | 397 +++++++++++++++++++++
 drivers/cpufreq/Kconfig.arm                        |   6 +-
 drivers/cpufreq/Makefile                           |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-kryo.c                | 232 ------------
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 387 ++++++++++++++++++++
 include/dt-bindings/clock/qcom,gcc-msm8960.h       |   2 +
 26 files changed, 1941 insertions(+), 239 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,hfpll.txt
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,krait-cc.txt
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt} (98%)
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
 create mode 100644 drivers/clk/qcom/hfpll.c
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
 create mode 100644 drivers/clk/qcom/krait-cc.c
 delete mode 100644 drivers/cpufreq/qcom-cpufreq-kryo.c
 create mode 100644 drivers/cpufreq/qcom-cpufreq-nvmem.c
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw

PATCH v12 1/14 ARM: Add Krait L2 register accessor functions

From: Stephen Boyd <[email protected]>

Krait CPUs have a handful of L2 cache controller registers that live behind a cp15 based indirection register. First you program the indirection register (l2cpselr) to point the L2 'window' register (l2cpdr) at what you want to read/write. Then you read/write the 'window' register to do what you want. The l2cpselr register is not banked per-cpu so we must lock around accesses to it to prevent other CPUs from re-pointing l2cpdr underneath us.

---
 arch/arm/common/Kconfig                   |  3 ++
 arch/arm/common/Makefile                  |  1 +
 arch/arm/common/krait-l2-accessors.c      | 48 +++++++++++++++++++++++++++++++
 arch/arm/include/asm/krait-l2-accessors.h |  9 ++++++
 4 files changed, 61 insertions(+)
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
arch/arm/common/Kconfig +3 -0
index e5ad070..c8e1986 100644
@@ -7,6 +7,9 @@ config DMABOUNCE
 	bool
 	select ZONE_DMA
 
+config KRAIT_L2_ACCESSORS
+	bool
+
 config SHARP_LOCOMO
 	bool
 
arch/arm/common/Makefile +1 -0
index 3157be4..219a260 100644
@@ -7,6 +7,7 @@ obj-y				+= firmware.o
 
 obj-$(CONFIG_SA1111)		+= sa1111.o
 obj-$(CONFIG_DMABOUNCE)		+= dmabounce.o
+obj-$(CONFIG_KRAIT_L2_ACCESSORS) += krait-l2-accessors.o
 obj-$(CONFIG_SHARP_LOCOMO)	+= locomo.o
 obj-$(CONFIG_SHARP_PARAM)	+= sharpsl_param.o
 obj-$(CONFIG_SHARP_SCOOP)	+= scoop.o
arch/arm/common/krait-l2-accessors.c new file +48 -0

48 lines not on this page · raw message

arch/arm/include/asm/krait-l2-accessors.h new file +9 -0
new file mode 100644
index 0000000..a5f2cdd
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASMARM_KRAIT_L2_ACCESSORS_H
+#define __ASMARM_KRAIT_L2_ACCESSORS_H
+
+extern void krait_set_l2_indirect_reg(u32 addr, u32 val);
+extern u32 krait_get_l2_indirect_reg(u32 addr);
+
+#endif
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw

PATCH v12 2/14 clk: qcom: Add support for High-Frequency PLLs (HFPLLs)

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

HFPLLs are the main frequency source for Krait CPU clocks. Add support for changing the rate of these PLLs.

---
 drivers/clk/qcom/Makefile    |   1 +
 drivers/clk/qcom/clk-hfpll.c | 244 +++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/qcom/clk-hfpll.h |  44 ++++++++
 3 files changed, 289 insertions(+)
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
drivers/clk/qcom/Makefile +1 -0
index 21a4503..7818e6c 100644
@@ -11,6 +11,7 @@ clk-qcom-y += clk-branch.o
 clk-qcom-y += clk-regmap-divider.o
 clk-qcom-y += clk-regmap-mux.o
 clk-qcom-y += clk-regmap-mux-div.o
+clk-qcom-y += clk-hfpll.o
 clk-qcom-y += reset.o
 clk-qcom-$(CONFIG_QCOM_GDSC) += gdsc.o
 
drivers/clk/qcom/clk-hfpll.c new file +244 -0

244 lines not on this page · raw message

drivers/clk/qcom/clk-hfpll.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#3 lore raw

PATCH v12 3/14 clk: qcom: Add HFPLL driver

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

On some devices (MSM8974 for example), the HFPLLs are instantiated within the Krait processor subsystem as separate register regions. Add a driver for these PLLs so that we can provide HFPLL clocks for use by the system.

---
 drivers/clk/qcom/Kconfig  |  8 ++++
 drivers/clk/qcom/Makefile |  1 +
 drivers/clk/qcom/hfpll.c  | 96 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 drivers/clk/qcom/hfpll.c
drivers/clk/qcom/Kconfig +8 -0
index 0647686..21aec10 100644
@@ -272,3 +272,11 @@ config SPMI_PMIC_CLKDIV
 	  Technologies, Inc. SPMI PMIC. It configures the frequency of
 	  clkdiv outputs of the PMIC. These clocks are typically wired
 	  through alternate functions on GPIO pins.
+
+config QCOM_HFPLL
+	tristate "High-Frequency PLL (HFPLL) Clock Controller"
+	depends on COMMON_CLK_QCOM
+	help
+	  Support for the high-frequency PLLs present on Qualcomm devices.
+	  Say Y if you want to support CPU frequency scaling on devices
+	  such as MSM8974, APQ8084, etc.
drivers/clk/qcom/Makefile +1 -0
index 7818e6c..f82eeac 100644
@@ -44,3 +44,4 @@ obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o
 obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
 obj-$(CONFIG_SDM_VIDEOCC_845) += videocc-sdm845.o
 obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
+obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
drivers/clk/qcom/hfpll.c new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw

PATCH v12 4/14 dt-bindings: clock: Document qcom,hfpll

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

Adds bindings document for qcom,hfpll instantiated within the Krait processor subsystem as separate register region.

---
 .../devicetree/bindings/clock/qcom,hfpll.txt       | 60 ++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,hfpll.txt
Documentation/devicetree/bindings/clock/qcom,hfpll.txt new file +60 -0
new file mode 100644
index 0000000..ec02a02
@@ -0,0 +1,60 @@
+High-Frequency PLL (HFPLL)
+
+PROPERTIES
+
+- compatible:
+	Usage: required
+	Value type: <string>:
+		shall contain only one of the following. The generic
+		compatible "qcom,hfpll" should be also included.
+
+                        "qcom,hfpll-ipq8064", "qcom,hfpll"
+                        "qcom,hfpll-apq8064", "qcom,hfpll"
+                        "qcom,hfpll-msm8974", "qcom,hfpll"
+                        "qcom,hfpll-msm8960", "qcom,hfpll"
+
+- reg:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: address and size of HPLL registers. An optional second
+		    element specifies the address and size of the alias
+		    register region.
+
+- clocks:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: reference to the xo clock.
+
+- clock-names:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "xo".
+
+- clock-output-names:
+	Usage: required
+	Value type: <string>
+	Definition: Name of the PLL. Typically hfpllX where X is a CPU number
+		    starting at 0. Otherwise hfpll_Y where Y is more specific
+		    such as "l2".
+
+Example:
+
+1) An HFPLL for the L2 cache.
+
+	clock-controller at f9016000 {
+		compatible = "qcom,hfpll-ipq8064", "qcom,hfpll";
+		reg = <0xf9016000 0x30>;
+		clocks = <&xo_board>;
+		clock-names = "xo";
+		clock-output-names = "hfpll_l2";
+	};
+
+2) An HFPLL for CPU0. This HFPLL has the alias register region.
+
+	clock-controller at f908a000 {
+		compatible = "qcom,hfpll-ipq8064", "qcom,hfpll";
+		reg = <0xf908a000 0x30>, <0xf900a000 0x30>;
+		clocks = <&xo_board>;
+		clock-names = "xo";
+		clock-output-names = "hfpll0";
+	};
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#5 lore raw

PATCH v12 5/14 clk: qcom: Add MSM8960/APQ8064's HFPLLs

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

Describe the HFPLLs present on MSM8960 and APQ8064 devices.

---
 drivers/clk/qcom/gcc-msm8960.c               | 172 +++++++++++++++++++++++++++
 include/dt-bindings/clock/qcom,gcc-msm8960.h |   2 +
 2 files changed, 174 insertions(+)
drivers/clk/qcom/gcc-msm8960.c +172 -0
index fd495e0..3994747 100644
@@ -30,6 +30,7 @@
 #include "clk-pll.h"
 #include "clk-rcg.h"
 #include "clk-branch.h"
+#include "clk-hfpll.h"
 #include "reset.h"
 
 static struct clk_pll pll3 = {
@@ -86,6 +87,164 @@
 	},
 };
 
+static struct hfpll_data hfpll0_data = {
+	.mode_reg = 0x3200,
+	.l_reg = 0x3208,
+	.m_reg = 0x320c,
+	.n_reg = 0x3210,
+	.config_reg = 0x3204,
+	.status_reg = 0x321c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3214,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct clk_hfpll hfpll0 = {
+	.d = &hfpll0_data,
+	.clkr.hw.init = &(struct clk_init_data){
+		.parent_names = (const char *[]){ "pxo" },
+		.num_parents = 1,
+		.name = "hfpll0",
+		.ops = &clk_ops_hfpll,
+		.flags = CLK_IGNORE_UNUSED,
+	},
+	.lock = __SPIN_LOCK_UNLOCKED(hfpll0.lock),
+};
+
+static struct hfpll_data hfpll1_8064_data = {
+	.mode_reg = 0x3240,
+	.l_reg = 0x3248,
+	.m_reg = 0x324c,
+	.n_reg = 0x3250,
+	.config_reg = 0x3244,
+	.status_reg = 0x325c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3254,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct hfpll_data hfpll1_data = {
+	.mode_reg = 0x3300,
+	.l_reg = 0x3308,
+	.m_reg = 0x330c,
+	.n_reg = 0x3310,
+	.config_reg = 0x3304,
+	.status_reg = 0x331c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3314,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct clk_hfpll hfpll1 = {
+	.d = &hfpll1_data,
+	.clkr.hw.init = &(struct clk_init_data){
+		.parent_names = (const char *[]){ "pxo" },
+		.num_parents = 1,
+		.name = "hfpll1",
+		.ops = &clk_ops_hfpll,
+		.flags = CLK_IGNORE_UNUSED,
+	},
+	.lock = __SPIN_LOCK_UNLOCKED(hfpll1.lock),
+};
+
+static struct hfpll_data hfpll2_data = {
+	.mode_reg = 0x3280,
+	.l_reg = 0x3288,
+	.m_reg = 0x328c,
+	.n_reg = 0x3290,
+	.config_reg = 0x3284,
+	.status_reg = 0x329c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3294,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct clk_hfpll hfpll2 = {
+	.d = &hfpll2_data,
+	.clkr.hw.init = &(struct clk_init_data){
+		.parent_names = (const char *[]){ "pxo" },
+		.num_parents = 1,
+		.name = "hfpll2",
+		.ops = &clk_ops_hfpll,
+		.flags = CLK_IGNORE_UNUSED,
+	},
+	.lock = __SPIN_LOCK_UNLOCKED(hfpll2.lock),
+};
+
+static struct hfpll_data hfpll3_data = {
+	.mode_reg = 0x32c0,
+	.l_reg = 0x32c8,
+	.m_reg = 0x32cc,
+	.n_reg = 0x32d0,
+	.config_reg = 0x32c4,
+	.status_reg = 0x32dc,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x32d4,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct clk_hfpll hfpll3 = {
+	.d = &hfpll3_data,
+	.clkr.hw.init = &(struct clk_init_data){
+		.parent_names = (const char *[]){ "pxo" },
+		.num_parents = 1,
+		.name = "hfpll3",
+		.ops = &clk_ops_hfpll,
+		.flags = CLK_IGNORE_UNUSED,
+	},
+	.lock = __SPIN_LOCK_UNLOCKED(hfpll3.lock),
+};
+
+static struct hfpll_data hfpll_l2_8064_data = {
+	.mode_reg = 0x3300,
+	.l_reg = 0x3308,
+	.m_reg = 0x330c,
+	.n_reg = 0x3310,
+	.config_reg = 0x3304,
+	.status_reg = 0x331c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3314,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct hfpll_data hfpll_l2_data = {
+	.mode_reg = 0x3400,
+	.l_reg = 0x3408,
+	.m_reg = 0x340c,
+	.n_reg = 0x3410,
+	.config_reg = 0x3404,
+	.status_reg = 0x341c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3414,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct clk_hfpll hfpll_l2 = {
+	.d = &hfpll_l2_data,
+	.clkr.hw.init = &(struct clk_init_data){
+		.parent_names = (const char *[]){ "pxo" },
+		.num_parents = 1,
+		.name = "hfpll_l2",
+		.ops = &clk_ops_hfpll,
+		.flags = CLK_IGNORE_UNUSED,
+	},
+	.lock = __SPIN_LOCK_UNLOCKED(hfpll_l2.lock),
+};
+
 static struct clk_pll pll14 = {
 	.l_reg = 0x31c4,
 	.m_reg = 0x31c8,
@@ -3107,6 +3266,9 @@ enum {
 	[PMIC_ARB1_H_CLK] = &pmic_arb1_h_clk.clkr,
 	[PMIC_SSBI2_CLK] = &pmic_ssbi2_clk.clkr,
 	[RPM_MSG_RAM_H_CLK] = &rpm_msg_ram_h_clk.clkr,
+	[PLL9] = &hfpll0.clkr,
+	[PLL10] = &hfpll1.clkr,
+	[PLL12] = &hfpll_l2.clkr,
 };
 
 static const struct qcom_reset_map gcc_msm8960_resets[] = {
@@ -3318,6 +3480,11 @@ enum {
 	[PMIC_ARB1_H_CLK] = &pmic_arb1_h_clk.clkr,
 	[PMIC_SSBI2_CLK] = &pmic_ssbi2_clk.clkr,
 	[RPM_MSG_RAM_H_CLK] = &rpm_msg_ram_h_clk.clkr,
+	[PLL9] = &hfpll0.clkr,
+	[PLL10] = &hfpll1.clkr,
+	[PLL12] = &hfpll_l2.clkr,
+	[PLL16] = &hfpll2.clkr,
+	[PLL17] = &hfpll3.clkr,
 };
 
 static const struct qcom_reset_map gcc_apq8064_resets[] = {
@@ -3477,6 +3644,11 @@ static int gcc_msm8960_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	if (match->data == &gcc_apq8064_desc) {
+		hfpll1.d = &hfpll1_8064_data;
+		hfpll_l2.d = &hfpll_l2_8064_data;
+	}
+
 	tsens = platform_device_register_data(&pdev->dev, "qcom-tsens", -1,
 					      NULL, 0);
 	if (IS_ERR(tsens))
include/dt-bindings/clock/qcom,gcc-msm8960.h +2 -0
index 7d20eed..e02742f 100644
@@ -319,5 +319,7 @@
 #define CE3_SRC					303
 #define CE3_CORE_CLK				304
 #define CE3_H_CLK				305
+#define PLL16					306
+#define PLL17					307
 
 #endif
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#6 lore raw

PATCH v12 6/14 clk: qcom: Add IPQ806X's HFPLLs

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

Describe the HFPLLs present on IPQ806X devices.

---
 drivers/clk/qcom/gcc-ipq806x.c | 82 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
drivers/clk/qcom/gcc-ipq806x.c +82 -0
index 5f61225..33d1bc5 100644
@@ -30,6 +30,7 @@
 #include "clk-pll.h"
 #include "clk-rcg.h"
 #include "clk-branch.h"
+#include "clk-hfpll.h"
 #include "reset.h"
 
 static struct clk_pll pll0 = {
@@ -113,6 +114,84 @@
 	},
 };
 
+static struct hfpll_data hfpll0_data = {
+	.mode_reg = 0x3200,
+	.l_reg = 0x3208,
+	.m_reg = 0x320c,
+	.n_reg = 0x3210,
+	.config_reg = 0x3204,
+	.status_reg = 0x321c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3214,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct clk_hfpll hfpll0 = {
+	.d = &hfpll0_data,
+	.clkr.hw.init = &(struct clk_init_data){
+		.parent_names = (const char *[]){ "pxo" },
+		.num_parents = 1,
+		.name = "hfpll0",
+		.ops = &clk_ops_hfpll,
+		.flags = CLK_IGNORE_UNUSED,
+	},
+	.lock = __SPIN_LOCK_UNLOCKED(hfpll0.lock),
+};
+
+static struct hfpll_data hfpll1_data = {
+	.mode_reg = 0x3240,
+	.l_reg = 0x3248,
+	.m_reg = 0x324c,
+	.n_reg = 0x3250,
+	.config_reg = 0x3244,
+	.status_reg = 0x325c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3314,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct clk_hfpll hfpll1 = {
+	.d = &hfpll1_data,
+	.clkr.hw.init = &(struct clk_init_data){
+		.parent_names = (const char *[]){ "pxo" },
+		.num_parents = 1,
+		.name = "hfpll1",
+		.ops = &clk_ops_hfpll,
+		.flags = CLK_IGNORE_UNUSED,
+	},
+	.lock = __SPIN_LOCK_UNLOCKED(hfpll1.lock),
+};
+
+static struct hfpll_data hfpll_l2_data = {
+	.mode_reg = 0x3300,
+	.l_reg = 0x3308,
+	.m_reg = 0x330c,
+	.n_reg = 0x3310,
+	.config_reg = 0x3304,
+	.status_reg = 0x331c,
+	.config_val = 0x7845c665,
+	.droop_reg = 0x3314,
+	.droop_val = 0x0108c000,
+	.min_rate = 600000000UL,
+	.max_rate = 1800000000UL,
+};
+
+static struct clk_hfpll hfpll_l2 = {
+	.d = &hfpll_l2_data,
+	.clkr.hw.init = &(struct clk_init_data){
+		.parent_names = (const char *[]){ "pxo" },
+		.num_parents = 1,
+		.name = "hfpll_l2",
+		.ops = &clk_ops_hfpll,
+		.flags = CLK_IGNORE_UNUSED,
+	},
+	.lock = __SPIN_LOCK_UNLOCKED(hfpll_l2.lock),
+};
+
 static struct clk_pll pll14 = {
 	.l_reg = 0x31c4,
 	.m_reg = 0x31c8,
@@ -2797,6 +2876,9 @@ enum {
 	[UBI32_CORE2_CLK_SRC] = &ubi32_core2_src_clk.clkr,
 	[NSSTCM_CLK_SRC] = &nss_tcm_src.clkr,
 	[NSSTCM_CLK] = &nss_tcm_clk.clkr,
+	[PLL9] = &hfpll0.clkr,
+	[PLL10] = &hfpll1.clkr,
+	[PLL12] = &hfpll_l2.clkr,
 };
 
 static const struct qcom_reset_map gcc_ipq806x_resets[] = {
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#7 lore raw

PATCH v12 7/14 clk: qcom: Add support for Krait clocks

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

The Krait clocks are made up of a series of muxes and a divider that choose between a fixed rate clock and dedicated HFPLLs for each CPU. Instead of using mmio accesses to remux parents, the Krait implementation exposes the remux control via cp15 registers. Support these clocks.

---
 drivers/clk/qcom/Kconfig     |   4 ++
 drivers/clk/qcom/Makefile    |   1 +
 drivers/clk/qcom/clk-krait.c | 124 +++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/qcom/clk-krait.h |  37 +++++++++++++
 4 files changed, 166 insertions(+)
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
drivers/clk/qcom/Kconfig +4 -0
index 21aec10..ada4160 100644
@@ -280,3 +280,7 @@ config QCOM_HFPLL
 	  Support for the high-frequency PLLs present on Qualcomm devices.
 	  Say Y if you want to support CPU frequency scaling on devices
 	  such as MSM8974, APQ8084, etc.
+
+config KRAIT_CLOCKS
+	bool
+	select KRAIT_L2_ACCESSORS
drivers/clk/qcom/Makefile +1 -0
index f82eeac..506c4cf 100644
@@ -11,6 +11,7 @@ clk-qcom-y += clk-branch.o
 clk-qcom-y += clk-regmap-divider.o
 clk-qcom-y += clk-regmap-mux.o
 clk-qcom-y += clk-regmap-mux-div.o
+clk-qcom-$(CONFIG_KRAIT_CLOCKS) += clk-krait.o
 clk-qcom-y += clk-hfpll.o
 clk-qcom-y += reset.o
 clk-qcom-$(CONFIG_QCOM_GDSC) += gdsc.o
drivers/clk/qcom/clk-krait.c new file +124 -0

124 lines not on this page · raw message

drivers/clk/qcom/clk-krait.h new file +37 -0
new file mode 100644
index 0000000..441ba1e
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __QCOM_CLK_KRAIT_H
+#define __QCOM_CLK_KRAIT_H
+
+#include <linux/clk-provider.h>
+
+struct krait_mux_clk {
+	unsigned int	*parent_map;
+	u32		offset;
+	u32		mask;
+	u32		shift;
+	u32		en_mask;
+	bool		lpl;
+
+	struct clk_hw	hw;
+	struct notifier_block   clk_nb;
+};
+
+#define to_krait_mux_clk(_hw) container_of(_hw, struct krait_mux_clk, hw)
+
+extern const struct clk_ops krait_mux_clk_ops;
+
+struct krait_div2_clk {
+	u32		offset;
+	u8		width;
+	u32		shift;
+	bool		lpl;
+
+	struct clk_hw	hw;
+};
+
+#define to_krait_div2_clk(_hw) container_of(_hw, struct krait_div2_clk, hw)
+
+extern const struct clk_ops krait_div2_clk_ops;
+
+#endif
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#8 lore raw

PATCH v12 8/14 clk: qcom: Add KPSS ACC/GCC driver

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

The ACC and GCC regions present in KPSSv1 contain registers to control clocks and power to each Krait CPU and L2. For CPUfreq purposes probe these devices and expose a mux clock that chooses between PXO and PLL8.

---
 drivers/clk/qcom/Kconfig    |  8 +++++
 drivers/clk/qcom/Makefile   |  1 +
 drivers/clk/qcom/kpss-xcc.c | 87 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+)
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
drivers/clk/qcom/Kconfig +8 -0
index ada4160..7a99627 100644
@@ -281,6 +281,14 @@ config QCOM_HFPLL
 	  Say Y if you want to support CPU frequency scaling on devices
 	  such as MSM8974, APQ8084, etc.
 
+config KPSS_XCC
+	tristate "KPSS Clock Controller"
+	depends on COMMON_CLK_QCOM
+	help
+	  Support for the Krait ACC and GCC clock controllers. Say Y
+	  if you want to support CPU frequency scaling on devices such
+	  as MSM8960, APQ8064, etc.
+
 config KRAIT_CLOCKS
 	bool
 	select KRAIT_L2_ACCESSORS
drivers/clk/qcom/Makefile +1 -0
index 506c4cf..92310ee 100644
@@ -45,4 +45,5 @@ obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o
 obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
 obj-$(CONFIG_SDM_VIDEOCC_845) += videocc-sdm845.o
 obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
+obj-$(CONFIG_KPSS_XCC) += kpss-xcc.o
 obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
drivers/clk/qcom/kpss-xcc.c new file +87 -0

87 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#9 lore raw

PATCH v12 9/14 dt-bindings: arm: Document qcom,kpss-gcc

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

The ACC and GCC regions present in KPSSv1 contain registers to control clocks and power to each Krait CPU and L2. Documenting the bindings here.

---
 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  | 19 ++++++++++
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  | 44 ++++++++++++++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
Documentation/devicetree/bindings/arm/msm/qcom,kpss-acc.txt +19 -0
index 1333db9..7f69636 100644
@@ -21,10 +21,29 @@ PROPERTIES
 		    the register region. An optional second element specifies
 		    the base address and size of the alias register region.
 
+- clocks:
+        Usage: required
+        Value type: <prop-encoded-array>
+        Definition: reference to the pll parents.
+
+- clock-names:
+        Usage: required
+        Value type: <stringlist>
+        Definition: must be "pll8_vote", "pxo".
+
+- clock-output-names:
+	Usage: optional
+	Value type: <string>
+	Definition: Name of the output clock. Typically acpuX_aux where X is a
+		    CPU number starting at 0.
+
 Example:
 
 	clock-controller at 2088000 {
 		compatible = "qcom,kpss-acc-v2";
 		reg = <0x02088000 0x1000>,
 		      <0x02008000 0x1000>;
+		clocks = <&gcc PLL8_VOTE>, <&gcc PXO_SRC>;
+		clock-names = "pll8_vote", "pxo";
+		clock-output-names = "acpu0_aux";
 	};
Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#10 lore raw

PATCH v12 10/14 clk: qcom: Add Krait clock controller driver

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

The Krait CPU clocks are made up of a primary mux and secondary mux for each CPU and the L2, controlled via cp15 accessors. For Kraits within KPSSv1 each secondary mux accepts a different aux source, but on KPSSv2 each secondary mux accepts the same aux source.

---
 drivers/clk/qcom/Kconfig     |   8 +
 drivers/clk/qcom/Makefile    |   1 +
 drivers/clk/qcom/clk-krait.c |   4 +-
 drivers/clk/qcom/krait-cc.c  | 341 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 352 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/qcom/krait-cc.c
drivers/clk/qcom/Kconfig +8 -0
index 7a99627..7c7ca65 100644
@@ -289,6 +289,14 @@ config KPSS_XCC
 	  if you want to support CPU frequency scaling on devices such
 	  as MSM8960, APQ8064, etc.
 
+config KRAITCC
+	tristate "Krait Clock Controller"
+	depends on COMMON_CLK_QCOM && ARM
+	select KRAIT_CLOCKS
+	help
+	  Support for the Krait CPU clocks on Qualcomm devices.
+	  Say Y if you want to support CPU frequency scaling.
+
 config KRAIT_CLOCKS
 	bool
 	select KRAIT_L2_ACCESSORS
drivers/clk/qcom/Makefile +1 -0
index 92310ee..949829b 100644
@@ -47,3 +47,4 @@ obj-$(CONFIG_SDM_VIDEOCC_845) += videocc-sdm845.o
 obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
 obj-$(CONFIG_KPSS_XCC) += kpss-xcc.o
 obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
+obj-$(CONFIG_KRAITCC) += krait-cc.o
drivers/clk/qcom/clk-krait.c +2 -2
index 2e41767..7ede744 100644
@@ -44,7 +44,7 @@ static int krait_mux_set_parent(struct clk_hw *hw, u8 index)
 	struct krait_mux_clk *mux = to_krait_mux_clk(hw);
 	u32 sel;
 
-	sel = clk_mux_reindex(index, mux->parent_map, 0);
+	sel = clk_mux_index_to_val(mux->parent_map, 0, index);
 	mux->en_mask = sel;
 	/* Don't touch mux if CPU is off as it won't work */
 	if (__clk_is_enabled(hw->clk))
@@ -63,7 +63,7 @@ static u8 krait_mux_get_parent(struct clk_hw *hw)
 	sel &= mux->mask;
 	mux->en_mask = sel;
 
-	return clk_mux_get_parent(hw, sel, mux->parent_map, 0);
+	return clk_mux_val_to_index(hw, mux->parent_map, 0, sel);
 }
 
 const struct clk_ops krait_mux_clk_ops = {
drivers/clk/qcom/krait-cc.c new file +341 -0

341 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#11 lore raw

PATCH v12 11/14 dt-bindings: clock: Document qcom,krait-cc

In reply to Sricharan R

From: Stephen Boyd <[email protected]>

The Krait clock controller controls the krait CPU and the L2 clocks consisting a primary mux and secondary mux. Add document for that.

---
 .../devicetree/bindings/clock/qcom,krait-cc.txt    | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,krait-cc.txt
Documentation/devicetree/bindings/clock/qcom,krait-cc.txt new file +34 -0
new file mode 100644
index 0000000..030ba60
@@ -0,0 +1,34 @@
+Krait Clock Controller
+
+PROPERTIES
+
+- compatible:
+	Usage: required
+	Value type: <string>
+	Definition: must be one of:
+			"qcom,krait-cc-v1"
+			"qcom,krait-cc-v2"
+
+- #clock-cells:
+	Usage: required
+	Value type: <u32>
+	Definition: must be 1
+
+- clocks:
+	Usage: required
+	Value type: <prop-encoded-array>
+	Definition: reference to the clock parents of hfpll, secondary muxes.
+
+- clock-names:
+	Usage: required
+	Value type: <stringlist>
+	Definition: must be "hfpll0", "hfpll1", "acpu0_aux", "acpu1_aux", "qsb".
+
+Example:
+
+	kraitcc: clock-controller {
+		compatible = "qcom,krait-cc-v1";
+		clocks = <&hfpll0>, <&hfpll1>, <&acpu0_aux>, <&acpu1_aux>, <qsb>;
+		clock-names = "hfpll0", "hfpll1", "acpu0_aux", "acpu1_aux", "qsb";
+		#clock-cells = <1>;
+	};
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#12 lore raw

PATCH v12 12/14 clk: qcom: Add safe switch hook for krait mux clocks

In reply to Sricharan R

When the Hfplls are reprogrammed during the rate change, the primary muxes which are sourced from the same hfpll for higher frequencies, needs to be switched to the 'safe secondary mux' as the parent for that small window. This is done by registering a clk notifier for the muxes and switching to the safe parent in the PRE_RATE_CHANGE notifier and back to the original parent in the POST_RATE_CHANGE notifier.

---
 drivers/clk/qcom/clk-krait.c |  2 ++
 drivers/clk/qcom/clk-krait.h |  3 +++
 drivers/clk/qcom/krait-cc.c  | 56 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
drivers/clk/qcom/clk-krait.c +2 -0
index 7ede744..59f1af4 100644
@@ -50,6 +50,8 @@ static int krait_mux_set_parent(struct clk_hw *hw, u8 index)
 	if (__clk_is_enabled(hw->clk))
 		__krait_mux_set_sel(mux, sel);
 
+	mux->reparent = true;
+
 	return 0;
 }
 
drivers/clk/qcom/clk-krait.h +3 -0
index 441ba1e..9120bd2 100644
@@ -12,6 +12,9 @@ struct krait_mux_clk {
 	u32		shift;
 	u32		en_mask;
 	bool		lpl;
+	u8		safe_sel;
+	u8		old_index;
+	bool		reparent;
 
 	struct clk_hw	hw;
 	struct notifier_block   clk_nb;
drivers/clk/qcom/krait-cc.c +56 -0

98 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#13 lore raw

PATCH v12 13/14 cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem based qcom socs

In reply to Sricharan R

The kryo cpufreq driver reads the nvmem cell and uses that data to populate the opps. There are other qcom cpufreq socs like krait which does similar thing. Except for the interpretation of the read data, rest of the driver is same for both the cases. So pull the common things out for reuse.

---
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   6 +-
 drivers/cpufreq/Kconfig.arm                        |   4 +-
 drivers/cpufreq/Makefile                           |   2 +-
 .../{qcom-cpufreq-kryo.c => qcom-cpufreq-nvmem.c}  | 124 ++++++++++++---------
 4 files changed, 80 insertions(+), 56 deletions(-)
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt} (99%)
 rename drivers/cpufreq/{qcom-cpufreq-kryo.c => qcom-cpufreq-nvmem.c} (65%)
Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt renamed from Documentation/devicetree/bindings/opp/kryo-cpufreq.txt +3 -3
similarity index 99%
rename from Documentation/devicetree/bindings/opp/kryo-cpufreq.txt
rename to Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt
index c2127b9..6dcdfcd 100644
@@ -19,7 +19,7 @@ In 'cpus' nodes:
 
 In 'operating-points-v2' table:
 - compatible: Should be
-	- 'operating-points-v2-kryo-cpu' for apq8096 and msm8996.
+	- 'operating-points-v2-qcom-cpu' for apq8096 and msm8996.
 - nvmem-cells: A phandle pointing to a nvmem-cells node representing the
 		efuse registers that has information about the
 		speedbin that is used to select the right frequency/voltage
@@ -127,7 +127,7 @@ Example 1:
 	};
 
 	cluster0_opp: opp_table0 {
-		compatible = "operating-points-v2-kryo-cpu";
+		compatible = "operating-points-v2-qcom-cpu";
 		nvmem-cells = <&speedbin_efuse>;
 		opp-shared;
 
@@ -338,7 +338,7 @@ Example 1:
 	};
 
 	cluster1_opp: opp_table1 {
-		compatible = "operating-points-v2-kryo-cpu";
+		compatible = "operating-points-v2-qcom-cpu";
 		nvmem-cells = <&speedbin_efuse>;
 		opp-shared;
 
drivers/cpufreq/Kconfig.arm +2 -2
index 52f5f1a..13fbd97 100644
@@ -124,8 +124,8 @@ config ARM_OMAP2PLUS_CPUFREQ
 	depends on ARCH_OMAP2PLUS
 	default ARCH_OMAP2PLUS
 
-config ARM_QCOM_CPUFREQ_KRYO
-	tristate "Qualcomm Kryo based CPUFreq"
+config ARM_QCOM_CPUFREQ_NVMEM
+	tristate "Qualcomm nvmem based CPUFreq"
 	depends on ARM64
 	depends on QCOM_QFPROM
 	depends on QCOM_SMEM
drivers/cpufreq/Makefile +1 -1
index fb4a2ec..5544441 100644
@@ -65,7 +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_KRYO)	+= qcom-cpufreq-kryo.o
+obj-$(CONFIG_ARM_QCOM_CPUFREQ_NVMEM)	+= qcom-cpufreq-nvmem.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
drivers/cpufreq/qcom-cpufreq-nvmem.c renamed from drivers/cpufreq/qcom-cpufreq-kryo.c +74 -50

216 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#16 lore raw

PATCH v12 14/14 cpufreq: qcom: Add support for krait based socs

In reply to Sricharan R

In Certain QCOM SoCs like ipq8064, apq8064, msm8960, msm8974 that has KRAIT processors the voltage/current value of each OPP varies based on the silicon variant in use.

The required OPP related data is determined based on the efuse value. This is similar to the existing code for kryo cores. So adding support for krait cores here.

---
 .../devicetree/bindings/opp/qcom-nvmem-cpufreq.txt |   3 +-
 drivers/cpufreq/Kconfig.arm                        |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 151 +++++++++++++++++++--
 4 files changed, 149 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt +2 -1
index 6dcdfcd..7bc0f1a 100644
@@ -19,7 +19,8 @@ In 'cpus' nodes:
 
 In 'operating-points-v2' table:
 - compatible: Should be
-	- 'operating-points-v2-qcom-cpu' for apq8096 and msm8996.
+	- 'operating-points-v2-qcom-cpu' for apq8096, msm8996, msm8974,
+					     apq8064, msm8960 and ipq8074.
 - nvmem-cells: A phandle pointing to a nvmem-cells node representing the
 		efuse registers that has information about the
 		speedbin that is used to select the right frequency/voltage
drivers/cpufreq/Kconfig.arm +1 -1
index 13fbd97..497ae89 100644
@@ -126,7 +126,7 @@ config ARM_OMAP2PLUS_CPUFREQ
 
 config ARM_QCOM_CPUFREQ_NVMEM
 	tristate "Qualcomm nvmem based CPUFreq"
-	depends on ARM64
+	depends on ARCH_QCOM
 	depends on QCOM_QFPROM
 	depends on QCOM_SMEM
 	select PM_OPP
drivers/cpufreq/cpufreq-dt-platdev.c +5 -0
index fe14c57..917cdc2 100644
@@ -128,6 +128,11 @@
 	{ .compatible = "ti,am43", },
 	{ .compatible = "ti,dra7", },
 
+	{ .compatible = "qcom,ipq8064", },
+	{ .compatible = "qcom,apq8064", },
+	{ .compatible = "qcom,msm8974", },
+	{ .compatible = "qcom,msm8960", },
+
 	{ }
 };
 
drivers/cpufreq/qcom-cpufreq-nvmem.c +141 -10

201 lines not on this page · raw message

Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#20 lore raw
In reply to Sricharan R

Hi Craig,

Quoted 4 lines · Sricharan R

[v12]
* Added my signed-off that was missing in some patches.
* Added Bjorn's acked that i missed earlier.

Can you give this a try on your 8974 device and check if the pvs version reporting, scaling for higher frequencies are fine ? Sorry, i could not get hold of a 8974 device. So in-case if you still have the issues with higher frequencies, can you give a quick debug and report. That would be of great help.

Regards,
Sricharan

Quoted 178 lines

[v11]
* Dropped patch 13 and 14 from v10 and
merged the qcom-cpufreq-krait driver to the existing qcom-cpufreq-kryo.c
* Rebased on top of clk-next
* Fixed a bug while populating the pvs version for krait.

[v10]
* Addressed Stephen's comments to add clocks bindings properties to the newly introduced nodes.
* Added a change to include opp-supported-hw to qcom-cpufreq.c
* Rebased on top of clk-next
* Although there were minor changes to bindings and the driver retained the acked-by tags from Rob and Viresh respectively.

[v9]
* Fixed a rebase issue in Makefile and added Tag from Robh.

[v8]
* Fixed a bug in path#14 pointed out by Viresh and also added tags. No change in any other patch.

[v7]
* Fixed comments from Viresh for cleaning up the error handling in qcom-cpufreq.c. Also changed the init function to lateinit call. This is required because nvmem which gets initialised with module_init needs to go first.
* Fixed Rob's comments for bindings documentation
* Fixed kbuild build issue in clk-lpc32xx.c
* Rebased on top of clk-next

[v6]
* Adrressed comments from Viresh for patch #14 in v5 [5]
* Introduced a new binding operating-points-v2-krait-cpu as per discussion with Rob
* Added Review tags

[v5]
* Addressed comments from Rob for bindings
* Addressed comments from Viresh to use dev_pm_opp_set_prop_name, accordingly dropped patch #12 and corrected patch #11 from previous patch set in [4]
* Converted to use #spdx tags for newly introduced files

Mostly a resend of the v3 posted by Stephen quite some time back [1] except for few changes.
Based on reading some feedback from list,
* Dropped the patch "clk: Add safe switch hook" from v3 [2].
Now this is taken care by patch#10 in this series only for Krait.
* Dropped the path "clk: Avoid sending high rates to downstream clocks during set_rate" from v3 [3].
* Rebased on top of clk-next.
* Dropped the DT update from the series. Will send separately
* Now with cpufreq-dt+opp supporting voltage scaling, registering the krait cpu supplies in DT should be sufficient. But one issue is, the qcom-cpufreq drivers reads the efuse and based on that registers the opp data and then registers the cpufreq-dt device. So when cpufreq-dt driver probes and registers the regulator to the OPP framework, it expects that the opp data for the device should not be registered before the regulator. Will send a RFC patch removing that check, to find out the right way of doing it.

These patches provide cpufreq scaling on devices with Krait CPUs. In Krait CPU designs there's one PLL and two muxes per CPU, allowing us to switch CPU frequencies independently.

				 secondary
	 +-----+                    +
	 | QSB |-------+------------|\
	 +-----+       |            | |-+
		       |    +-------|/  |
		       |    |       +   |
	 +-----+       |    |           |
	 | PLL |----+-------+           |   primary
	 +-----+    |  |                |     +
		    |  |                +-----|\       +------+
	 +-------+  |  |                      | \      |      |
	 | HFPLL |----------+-----------------|  |-----| CPU0 |
	 +-------+  |  |    |                 |  |     |      |
		    |  |    | +-----+         | /      +------+
		    |  |    +-| / 2 |---------|/
		    |  |      +-----+         +
		    |  |         secondary
		    |  |            +
		    |  +------------|\
		    |               | |-+
		    +---------------|/  |   primary
				    +   |     +
					+-----|\       +------+
	 +-------+                            | \      |      |
	 | HFPLL |----------------------------|  |-----| CPU1 |
	 +-------+          |                 |  |     |      |
			    | +-----+         | /      +------+
			    +-| / 2 |---------|/
			      +-----+         +

To support this in the common clock framework we model the muxes, dividers, and PLLs as different clocks. CPUfreq only interacts with the primary mux (farthest right in the diagram). When CPUfreq sets a rate, the mux code finds the best parent that can provide the rate. Due to the design, QSB and the top PLL are always a fixed rate and thus only support one frequency each. These sources provide the lowest frequencies for the CPUs. The HFPLLs are where we can make the CPU go faster (GHz range). Sometimes we need to run the HFPLL twice as fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL because we need to turn off the output of the PLL when changing its frequency. This means we have to switch over to the secondary mux and use one of the fixed sources. This is why we need something like the safe parent patch.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332607.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332615.html
[3] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332608.html
[4] https://lwn.net/Articles/740994/
[5] https://lkml.org/lkml/2017/12/19/537

Sricharan R (3):
clk: qcom: Add safe switch hook for krait mux clocks
cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem
based qcom socs
cpufreq: qcom: Add support for krait based socs

Stephen Boyd (11):
ARM: Add Krait L2 register accessor functions
clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
clk: qcom: Add HFPLL driver
dt-bindings: clock: Document qcom,hfpll
clk: qcom: Add MSM8960/APQ8064's HFPLLs
clk: qcom: Add IPQ806X's HFPLLs
clk: qcom: Add support for Krait clocks
clk: qcom: Add KPSS ACC/GCC driver
dt-bindings: arm: Document qcom,kpss-gcc
clk: qcom: Add Krait clock controller driver
dt-bindings: clock: Document qcom,krait-cc

 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  19 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  44 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt       |  60 ++++
 .../devicetree/bindings/clock/qcom,krait-cc.txt    |  34 ++
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   7 +-
 arch/arm/common/Kconfig                            |   3 +
 arch/arm/common/Makefile                           |   1 +
 arch/arm/common/krait-l2-accessors.c               |  48 +++
 arch/arm/include/asm/krait-l2-accessors.h          |   9 +
 drivers/clk/qcom/Kconfig                           |  28 ++
 drivers/clk/qcom/Makefile                          |   5 +
 drivers/clk/qcom/clk-hfpll.c                       | 244 +++++++++++++
 drivers/clk/qcom/clk-hfpll.h                       |  44 +++
 drivers/clk/qcom/clk-krait.c                       | 126 +++++++
 drivers/clk/qcom/clk-krait.h                       |  40 +++
 drivers/clk/qcom/gcc-ipq806x.c                     |  82 +++++
 drivers/clk/qcom/gcc-msm8960.c                     | 172 +++++++++
 drivers/clk/qcom/hfpll.c                           |  96 +++++
 drivers/clk/qcom/kpss-xcc.c                        |  87 +++++
 drivers/clk/qcom/krait-cc.c                        | 397 +++++++++++++++++++++
 drivers/cpufreq/Kconfig.arm                        |   6 +-
 drivers/cpufreq/Makefile                           |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-kryo.c                | 232 ------------
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 387 ++++++++++++++++++++
 include/dt-bindings/clock/qcom,gcc-msm8960.h       |   2 +
 26 files changed, 1941 insertions(+), 239 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,hfpll.txt
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,krait-cc.txt
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt} (98%)
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
 create mode 100644 drivers/clk/qcom/hfpll.c
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
 create mode 100644 drivers/clk/qcom/krait-cc.c
 delete mode 100644 drivers/cpufreq/qcom-cpufreq-kryo.c
 create mode 100644 drivers/cpufreq/qcom-cpufreq-nvmem.c
Signature · 1 line
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
maintainer
#14 lore raw

Re: [PATCH v12 13/14] cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem based qcom socs

In reply to Sricharan R

Hi, this email is from Rob's (experimental) review bot. I found a couple of common problems with your patch. Please see below.

Quoted 7 lines · Sricharan R

The kryo cpufreq driver reads the nvmem cell and uses that data to populate the opps. There are other qcom cpufreq socs like krait which does similar thing. Except for the interpretation of the read data, rest of the driver is same for both the cases. So pull the common things out for reuse.

The preferred subject prefix is "dt-bindings: <binding dir>: ...".

Quoted 9 lines
---
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   6 +-
 drivers/cpufreq/Kconfig.arm                        |   4 +-
 drivers/cpufreq/Makefile                           |   2 +-
 .../{qcom-cpufreq-kryo.c => qcom-cpufreq-nvmem.c}  | 124 ++++++++++++---------
 4 files changed, 80 insertions(+), 56 deletions(-)
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt} (99%)
 rename drivers/cpufreq/{qcom-cpufreq-kryo.c => qcom-cpufreq-nvmem.c} (65%)

DT bindings (including binding headers) should be a separate patch. See Documentation/devicetree/bindings/submitting-patches.txt.

maintainer
#17 lore raw

Re: [PATCH v12 14/14] cpufreq: qcom: Add support for krait based socs

In reply to Sricharan R

Hi, this email is from Rob's (experimental) review bot. I found a couple of common problems with your patch. Please see below.

Quoted 9 lines · Sricharan R

In Certain QCOM SoCs like ipq8064, apq8064, msm8960, msm8974 that has KRAIT processors the voltage/current value of each OPP varies based on the silicon variant in use.

The required OPP related data is determined based on the efuse value. This is similar to the existing code for kryo cores. So adding support for krait cores here.

The preferred subject prefix is "dt-bindings: <binding dir>: ...".

Quoted 7 lines
---
 .../devicetree/bindings/opp/qcom-nvmem-cpufreq.txt |   3 +-
 drivers/cpufreq/Kconfig.arm                        |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 151 +++++++++++++++++++--
 4 files changed, 149 insertions(+), 12 deletions(-)

DT bindings (including binding headers) should be a separate patch. See Documentation/devicetree/bindings/submitting-patches.txt.

#15 lore raw

Re: [PATCH v12 13/14] cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem based qcom socs

In reply to Rob Herring

Hi Rob,

Quoted 10 lines · Rob Herring

Hi, this email is from Rob's (experimental) review bot. I found a couple of common problems with your patch. Please see below.

Quoted 6 lines · Sricharan R

The kryo cpufreq driver reads the nvmem cell and uses that data to populate the opps. There are other qcom cpufreq socs like krait which does similar thing. Except for the interpretation of the read data, rest of the driver is same for both the cases. So pull the common things out for reuse.

Quoted 4 lines
Quoted 1 line

The preferred subject prefix is "dt-bindings: <binding dir>: ...".

ok, will change and keep the bindings update part out for this and the next patch.

Regards,
Sricharan

Signature · 1 line
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#18 lore raw

Re: [PATCH v12 14/14] cpufreq: qcom: Add support for krait based socs

In reply to Sricharan R
Quoted 21 lines · Sricharan R

In Certain QCOM SoCs like ipq8064, apq8064, msm8960, msm8974 that has KRAIT processors the voltage/current value of each OPP varies based on the silicon variant in use.

The required OPP related data is determined based on the efuse value. This is similar to the existing code for kryo cores. So adding support for krait cores here.

---
 .../devicetree/bindings/opp/qcom-nvmem-cpufreq.txt |   3 +-
 drivers/cpufreq/Kconfig.arm                        |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 151 +++++++++++++++++++--
 4 files changed, 149 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt +0 -0
index 6dcdfcd..7bc0f1a 100644

Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt In 'cpus' nodes: · line 26

Quoted 9 lines
Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt +2 -1
@@ -19,7 +19,8 @@ In 'cpus' nodes:
 
 In 'operating-points-v2' table:
 - compatible: Should be
-	- 'operating-points-v2-qcom-cpu' for apq8096 and msm8996.
+	- 'operating-points-v2-qcom-cpu' for apq8096, msm8996, msm8974,
+					     apq8064, msm8960 and ipq8074.
 - nvmem-cells: A phandle pointing to a nvmem-cells node representing the
 		efuse registers that has information about the
 		speedbin that is used to select the right frequency/voltage

Hello Sricharan,

I see several references to kryo in this file that should probably be removed or renamed.

Also, the documentation for opp-supported-hw lists how the different bitmap values maps to the different compatible HW. It might be good to add a note that the table is only for msm8996, and for orther SoCs, there is a 1:1 speedbin to opp-supported-hw mapping.

Kind regards,
Niklas

Quoted 245 lines
drivers/cpufreq/Kconfig.arm +1 -1
index 13fbd97..497ae89 100644
@@ -126,7 +126,7 @@ config ARM_OMAP2PLUS_CPUFREQ
 
 config ARM_QCOM_CPUFREQ_NVMEM
 	tristate "Qualcomm nvmem based CPUFreq"
-	depends on ARM64
+	depends on ARCH_QCOM
 	depends on QCOM_QFPROM
 	depends on QCOM_SMEM
 	select PM_OPP
drivers/cpufreq/cpufreq-dt-platdev.c +5 -0
index fe14c57..917cdc2 100644
@@ -128,6 +128,11 @@
 	{ .compatible = "ti,am43", },
 	{ .compatible = "ti,dra7", },
 
+	{ .compatible = "qcom,ipq8064", },
+	{ .compatible = "qcom,apq8064", },
+	{ .compatible = "qcom,msm8974", },
+	{ .compatible = "qcom,msm8960", },
+
 	{ }
 };
 
drivers/cpufreq/qcom-cpufreq-nvmem.c +141 -10
index 0ad8e5b..5f2add0 100644
@@ -45,6 +45,82 @@ enum _msm8996_version {
 
 static struct platform_device *cpufreq_dt_pdev, *cpufreq_pdev;
 
+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);
+	pte_efuse &= BIT(21);
+	if (pte_efuse) {
+		pr_info("PVS bin: %d\n", *pvs);
+	} else {
+		pr_warn("PVS bin not set. Defaulting to 0!\n");
+		*pvs = 0;
+	}
+
+	pr_info("PVS version: %d\n", *pvs_ver);
+	kfree(buf);
+}
+
 static enum _msm8996_version __init qcom_cpufreq_get_msm_id(void)
 {
 	size_t len;
@@ -74,6 +150,35 @@ static enum _msm8996_version __init qcom_cpufreq_get_msm_id(void)
 	return version;
 }
 
+static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
+					   struct nvmem_cell *speedbin_nvmem,
+					   char **name,
+					   u32 *versions)
+{
+	int speed = 0, pvs = 0, pvs_ver = 0;
+	u8 *buf;
+	size_t len;
+
+	buf = nvmem_cell_read(speedbin_nvmem, &len);
+	if (len == 4) {
+		get_krait_bin_format_a(&speed, &pvs, &pvs_ver,
+				       speedbin_nvmem, buf);
+	} else if (len == 8) {
+		get_krait_bin_format_b(&speed, &pvs, &pvs_ver,
+				       speedbin_nvmem, buf);
+	} else {
+		dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n");
+		return -ENODEV;
+	}
+
+	snprintf(*name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d",
+		 speed, pvs, pvs_ver);
+
+	*versions = (1 << speed);
+
+	return 0;
+}
+
 static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
 					  struct nvmem_cell *speedbin_nvmem,
 					  char **pvs_name,
@@ -83,6 +188,7 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
 	u8 *speedbin;
 	enum _msm8996_version msm8996_version;
 
+	*pvs_name = NULL;
 	msm8996_version = qcom_cpufreq_get_msm_id();
 	if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
 		dev_err(cpu_dev, "Not Snapdragon 820/821!");
@@ -111,7 +217,7 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
 
 static int qcom_cpufreq_probe(struct platform_device *pdev)
 {
-	struct opp_table *opp_tables[NR_CPUS] = { NULL };
+	struct opp_table *tbl1[NR_CPUS] = { NULL }, *tbl2[NR_CPUS] = { NULL };
 	int (*get_version)(struct device *cpu_dev,
 			   struct nvmem_cell *speedbin_nvmem,
 			   char **name, int *versions);
@@ -120,8 +226,8 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
 	struct device *cpu_dev;
 	unsigned cpu;
 	u32 versions;
-	char *pvs_name = NULL;
 	const struct of_device_id *match;
+	char *pvs_name = "speedXX-pvsXX-vXX";
 	int ret;
 
 	cpu_dev = get_cpu_device(0);
@@ -163,10 +269,19 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
 			goto free_opp;
 		}
 
-		opp_tables[cpu] = dev_pm_opp_set_supported_hw(cpu_dev,
-							      &versions, 1);
-		if (IS_ERR(opp_tables[cpu])) {
-			ret = PTR_ERR(opp_tables[cpu]);
+		if (pvs_name) {
+			tbl1[cpu] = dev_pm_opp_set_prop_name(cpu_dev, pvs_name);
+			if (IS_ERR(tbl1[cpu])) {
+				ret = PTR_ERR(tbl1[cpu]);
+				dev_err(cpu_dev, "Failed to add OPP name %s\n",
+					pvs_name);
+				goto free_opp;
+			}
+		}
+
+		tbl2[cpu] = dev_pm_opp_set_supported_hw(cpu_dev, &versions, 1);
+		if (IS_ERR(tbl2[cpu])) {
+			ret = PTR_ERR(tbl2[cpu]);
 			dev_err(cpu_dev, "Failed to set supported hardware\n");
 			goto free_opp;
 		}
@@ -182,9 +297,15 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
 
 free_opp:
 	for_each_possible_cpu(cpu) {
-		if (IS_ERR_OR_NULL(opp_tables[cpu]))
+		if (IS_ERR_OR_NULL(tbl1[cpu]))
+			break;
+		dev_pm_opp_put_prop_name(tbl1[cpu]);
+	}
+
+	for_each_possible_cpu(cpu) {
+		if (IS_ERR_OR_NULL(tbl2[cpu]))
 			break;
-		dev_pm_opp_put_supported_hw(opp_tables[cpu]);
+		dev_pm_opp_put_supported_hw(tbl2[cpu]);
 	}
 
 	return ret;
@@ -205,8 +326,18 @@ static int qcom_cpufreq_remove(struct platform_device *pdev)
 };
 
 static const struct of_device_id qcom_cpufreq_match_list[] __initconst = {
-	{ .compatible = "qcom,apq8096", .data = qcom_cpufreq_kryo_name_version},
-	{ .compatible = "qcom,msm8996", .data = qcom_cpufreq_kryo_name_version},
+	{ .compatible = "qcom,apq8096",
+	  .data = qcom_cpufreq_kryo_name_version},
+	{ .compatible = "qcom,msm8996",
+	  .data = qcom_cpufreq_kryo_name_version},
+	{ .compatible = "qcom,ipq8064",
+	  .data = qcom_cpufreq_krait_name_version },
+	{ .compatible = "qcom,apq8064",
+	  .data = qcom_cpufreq_krait_name_version },
+	{ .compatible = "qcom,msm8974",
+	  .data = qcom_cpufreq_krait_name_version },
+	{ .compatible = "qcom,msm8960",
+	  .data = qcom_cpufreq_krait_name_version },
 	{},
 };
 
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#19 lore raw

Re: [PATCH v12 14/14] cpufreq: qcom: Add support for krait based socs

In reply to Sricharan R
Quoted 64 lines · Sricharan R

In Certain QCOM SoCs like ipq8064, apq8064, msm8960, msm8974 that has KRAIT processors the voltage/current value of each OPP varies based on the silicon variant in use.

The required OPP related data is determined based on the efuse value. This is similar to the existing code for kryo cores. So adding support for krait cores here.

---
 .../devicetree/bindings/opp/qcom-nvmem-cpufreq.txt |   3 +-
 drivers/cpufreq/Kconfig.arm                        |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 151 +++++++++++++++++++--
 4 files changed, 149 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt +2 -1
index 6dcdfcd..7bc0f1a 100644
@@ -19,7 +19,8 @@ In 'cpus' nodes:
 
 In 'operating-points-v2' table:
 - compatible: Should be
-	- 'operating-points-v2-qcom-cpu' for apq8096 and msm8996.
+	- 'operating-points-v2-qcom-cpu' for apq8096, msm8996, msm8974,
+					     apq8064, msm8960 and ipq8074.
 - nvmem-cells: A phandle pointing to a nvmem-cells node representing the
 		efuse registers that has information about the
 		speedbin that is used to select the right frequency/voltage
drivers/cpufreq/Kconfig.arm +1 -1
index 13fbd97..497ae89 100644
@@ -126,7 +126,7 @@ config ARM_OMAP2PLUS_CPUFREQ
 
 config ARM_QCOM_CPUFREQ_NVMEM
 	tristate "Qualcomm nvmem based CPUFreq"
-	depends on ARM64
+	depends on ARCH_QCOM
 	depends on QCOM_QFPROM
 	depends on QCOM_SMEM
 	select PM_OPP
drivers/cpufreq/cpufreq-dt-platdev.c +5 -0
index fe14c57..917cdc2 100644
@@ -128,6 +128,11 @@
 	{ .compatible = "ti,am43", },
 	{ .compatible = "ti,dra7", },
 
+	{ .compatible = "qcom,ipq8064", },
+	{ .compatible = "qcom,apq8064", },
+	{ .compatible = "qcom,msm8974", },
+	{ .compatible = "qcom,msm8960", },
+
 	{ }
 };
 
drivers/cpufreq/qcom-cpufreq-nvmem.c +0 -0
index 0ad8e5b..5f2add0 100644

drivers/cpufreq/qcom-cpufreq-nvmem.c enum _msm8996_version { · line 49

Quoted 5 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +2 -0
@@ -45,6 +45,82 @@ enum _msm8996_version {
 
 static struct platform_device *cpufreq_dt_pdev, *cpufreq_pdev;
 
+static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver,
+					  struct nvmem_cell *pvs_nvmem, u8 *buf)

Hello Sricharan,

pvs_nvmem seems to be unused both here and in get_krait_bin_format_b().

Kind regards,
Niklas

Quoted 206 lines
drivers/cpufreq/qcom-cpufreq-nvmem.c +139 -10
+{
+	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);
+	pte_efuse &= BIT(21);
+	if (pte_efuse) {
+		pr_info("PVS bin: %d\n", *pvs);
+	} else {
+		pr_warn("PVS bin not set. Defaulting to 0!\n");
+		*pvs = 0;
+	}
+
+	pr_info("PVS version: %d\n", *pvs_ver);
+	kfree(buf);
+}
+
 static enum _msm8996_version __init qcom_cpufreq_get_msm_id(void)
 {
 	size_t len;
@@ -74,6 +150,35 @@ static enum _msm8996_version __init qcom_cpufreq_get_msm_id(void)
 	return version;
 }
 
+static int qcom_cpufreq_krait_name_version(struct device *cpu_dev,
+					   struct nvmem_cell *speedbin_nvmem,
+					   char **name,
+					   u32 *versions)
+{
+	int speed = 0, pvs = 0, pvs_ver = 0;
+	u8 *buf;
+	size_t len;
+
+	buf = nvmem_cell_read(speedbin_nvmem, &len);
+	if (len == 4) {
+		get_krait_bin_format_a(&speed, &pvs, &pvs_ver,
+				       speedbin_nvmem, buf);
+	} else if (len == 8) {
+		get_krait_bin_format_b(&speed, &pvs, &pvs_ver,
+				       speedbin_nvmem, buf);
+	} else {
+		dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n");
+		return -ENODEV;
+	}
+
+	snprintf(*name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d",
+		 speed, pvs, pvs_ver);
+
+	*versions = (1 << speed);
+
+	return 0;
+}
+
 static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
 					  struct nvmem_cell *speedbin_nvmem,
 					  char **pvs_name,
@@ -83,6 +188,7 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
 	u8 *speedbin;
 	enum _msm8996_version msm8996_version;
 
+	*pvs_name = NULL;
 	msm8996_version = qcom_cpufreq_get_msm_id();
 	if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
 		dev_err(cpu_dev, "Not Snapdragon 820/821!");
@@ -111,7 +217,7 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
 
 static int qcom_cpufreq_probe(struct platform_device *pdev)
 {
-	struct opp_table *opp_tables[NR_CPUS] = { NULL };
+	struct opp_table *tbl1[NR_CPUS] = { NULL }, *tbl2[NR_CPUS] = { NULL };
 	int (*get_version)(struct device *cpu_dev,
 			   struct nvmem_cell *speedbin_nvmem,
 			   char **name, int *versions);
@@ -120,8 +226,8 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
 	struct device *cpu_dev;
 	unsigned cpu;
 	u32 versions;
-	char *pvs_name = NULL;
 	const struct of_device_id *match;
+	char *pvs_name = "speedXX-pvsXX-vXX";
 	int ret;
 
 	cpu_dev = get_cpu_device(0);
@@ -163,10 +269,19 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
 			goto free_opp;
 		}
 
-		opp_tables[cpu] = dev_pm_opp_set_supported_hw(cpu_dev,
-							      &versions, 1);
-		if (IS_ERR(opp_tables[cpu])) {
-			ret = PTR_ERR(opp_tables[cpu]);
+		if (pvs_name) {
+			tbl1[cpu] = dev_pm_opp_set_prop_name(cpu_dev, pvs_name);
+			if (IS_ERR(tbl1[cpu])) {
+				ret = PTR_ERR(tbl1[cpu]);
+				dev_err(cpu_dev, "Failed to add OPP name %s\n",
+					pvs_name);
+				goto free_opp;
+			}
+		}
+
+		tbl2[cpu] = dev_pm_opp_set_supported_hw(cpu_dev, &versions, 1);
+		if (IS_ERR(tbl2[cpu])) {
+			ret = PTR_ERR(tbl2[cpu]);
 			dev_err(cpu_dev, "Failed to set supported hardware\n");
 			goto free_opp;
 		}
@@ -182,9 +297,15 @@ static int qcom_cpufreq_probe(struct platform_device *pdev)
 
 free_opp:
 	for_each_possible_cpu(cpu) {
-		if (IS_ERR_OR_NULL(opp_tables[cpu]))
+		if (IS_ERR_OR_NULL(tbl1[cpu]))
+			break;
+		dev_pm_opp_put_prop_name(tbl1[cpu]);
+	}
+
+	for_each_possible_cpu(cpu) {
+		if (IS_ERR_OR_NULL(tbl2[cpu]))
 			break;
-		dev_pm_opp_put_supported_hw(opp_tables[cpu]);
+		dev_pm_opp_put_supported_hw(tbl2[cpu]);
 	}
 
 	return ret;
@@ -205,8 +326,18 @@ static int qcom_cpufreq_remove(struct platform_device *pdev)
 };
 
 static const struct of_device_id qcom_cpufreq_match_list[] __initconst = {
-	{ .compatible = "qcom,apq8096", .data = qcom_cpufreq_kryo_name_version},
-	{ .compatible = "qcom,msm8996", .data = qcom_cpufreq_kryo_name_version},
+	{ .compatible = "qcom,apq8096",
+	  .data = qcom_cpufreq_kryo_name_version},
+	{ .compatible = "qcom,msm8996",
+	  .data = qcom_cpufreq_kryo_name_version},
+	{ .compatible = "qcom,ipq8064",
+	  .data = qcom_cpufreq_krait_name_version },
+	{ .compatible = "qcom,apq8064",
+	  .data = qcom_cpufreq_krait_name_version },
+	{ .compatible = "qcom,msm8974",
+	  .data = qcom_cpufreq_krait_name_version },
+	{ .compatible = "qcom,msm8960",
+	  .data = qcom_cpufreq_krait_name_version },
 	{},
 };
 
Signature · 1 line
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#21 lore raw
In reply to Sricharan R

Hi Craig,

Quoted 11 lines
Quoted 4 lines

[v12]
* Added my signed-off that was missing in some patches.
* Added Bjorn's acked that i missed earlier.

Can you give this a try on your 8974 device and check if the pvs version reporting, scaling for higher frequencies are fine ? Sorry, i could not get hold of a 8974 device. So in-case if you still have the issues with higher frequencies, can you give a quick debug and report. That would be of great help.

Ping on this ..

Regards,
Sricharan

Quoted 183 lines

Regards,
Sricharan

Quoted 178 lines

[v11]
* Dropped patch 13 and 14 from v10 and
merged the qcom-cpufreq-krait driver to the existing qcom-cpufreq-kryo.c
* Rebased on top of clk-next
* Fixed a bug while populating the pvs version for krait.

[v10]
* Addressed Stephen's comments to add clocks bindings properties to the newly introduced nodes.
* Added a change to include opp-supported-hw to qcom-cpufreq.c
* Rebased on top of clk-next
* Although there were minor changes to bindings and the driver retained the acked-by tags from Rob and Viresh respectively.

[v9]
* Fixed a rebase issue in Makefile and added Tag from Robh.

[v8]
* Fixed a bug in path#14 pointed out by Viresh and also added tags. No change in any other patch.

[v7]
* Fixed comments from Viresh for cleaning up the error handling in qcom-cpufreq.c. Also changed the init function to lateinit call. This is required because nvmem which gets initialised with module_init needs to go first.
* Fixed Rob's comments for bindings documentation
* Fixed kbuild build issue in clk-lpc32xx.c
* Rebased on top of clk-next

[v6]
* Adrressed comments from Viresh for patch #14 in v5 [5]
* Introduced a new binding operating-points-v2-krait-cpu as per discussion with Rob
* Added Review tags

[v5]
* Addressed comments from Rob for bindings
* Addressed comments from Viresh to use dev_pm_opp_set_prop_name, accordingly dropped patch #12 and corrected patch #11 from previous patch set in [4]
* Converted to use #spdx tags for newly introduced files

Mostly a resend of the v3 posted by Stephen quite some time back [1] except for few changes.
Based on reading some feedback from list,
* Dropped the patch "clk: Add safe switch hook" from v3 [2].
Now this is taken care by patch#10 in this series only for Krait.
* Dropped the path "clk: Avoid sending high rates to downstream clocks during set_rate" from v3 [3].
* Rebased on top of clk-next.
* Dropped the DT update from the series. Will send separately
* Now with cpufreq-dt+opp supporting voltage scaling, registering the krait cpu supplies in DT should be sufficient. But one issue is, the qcom-cpufreq drivers reads the efuse and based on that registers the opp data and then registers the cpufreq-dt device. So when cpufreq-dt driver probes and registers the regulator to the OPP framework, it expects that the opp data for the device should not be registered before the regulator. Will send a RFC patch removing that check, to find out the right way of doing it.

These patches provide cpufreq scaling on devices with Krait CPUs. In Krait CPU designs there's one PLL and two muxes per CPU, allowing us to switch CPU frequencies independently.

				 secondary
	 +-----+                    +
	 | QSB |-------+------------|\
	 +-----+       |            | |-+
		       |    +-------|/  |
		       |    |       +   |
	 +-----+       |    |           |
	 | PLL |----+-------+           |   primary
	 +-----+    |  |                |     +
		    |  |                +-----|\       +------+
	 +-------+  |  |                      | \      |      |
	 | HFPLL |----------+-----------------|  |-----| CPU0 |
	 +-------+  |  |    |                 |  |     |      |
		    |  |    | +-----+         | /      +------+
		    |  |    +-| / 2 |---------|/
		    |  |      +-----+         +
		    |  |         secondary
		    |  |            +
		    |  +------------|\
		    |               | |-+
		    +---------------|/  |   primary
				    +   |     +
					+-----|\       +------+
	 +-------+                            | \      |      |
	 | HFPLL |----------------------------|  |-----| CPU1 |
	 +-------+          |                 |  |     |      |
			    | +-----+         | /      +------+
			    +-| / 2 |---------|/
			      +-----+         +

To support this in the common clock framework we model the muxes, dividers, and PLLs as different clocks. CPUfreq only interacts with the primary mux (farthest right in the diagram). When CPUfreq sets a rate, the mux code finds the best parent that can provide the rate. Due to the design, QSB and the top PLL are always a fixed rate and thus only support one frequency each. These sources provide the lowest frequencies for the CPUs. The HFPLLs are where we can make the CPU go faster (GHz range). Sometimes we need to run the HFPLL twice as fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL because we need to turn off the output of the PLL when changing its frequency. This means we have to switch over to the secondary mux and use one of the fixed sources. This is why we need something like the safe parent patch.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332607.html
[2] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332615.html
[3] http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332608.html
[4] https://lwn.net/Articles/740994/
[5] https://lkml.org/lkml/2017/12/19/537

Sricharan R (3):
clk: qcom: Add safe switch hook for krait mux clocks
cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem
based qcom socs
cpufreq: qcom: Add support for krait based socs

Stephen Boyd (11):
ARM: Add Krait L2 register accessor functions
clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
clk: qcom: Add HFPLL driver
dt-bindings: clock: Document qcom,hfpll
clk: qcom: Add MSM8960/APQ8064's HFPLLs
clk: qcom: Add IPQ806X's HFPLLs
clk: qcom: Add support for Krait clocks
clk: qcom: Add KPSS ACC/GCC driver
dt-bindings: arm: Document qcom,kpss-gcc
clk: qcom: Add Krait clock controller driver
dt-bindings: clock: Document qcom,krait-cc

 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  19 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  44 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt       |  60 ++++
 .../devicetree/bindings/clock/qcom,krait-cc.txt    |  34 ++
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   7 +-
 arch/arm/common/Kconfig                            |   3 +
 arch/arm/common/Makefile                           |   1 +
 arch/arm/common/krait-l2-accessors.c               |  48 +++
 arch/arm/include/asm/krait-l2-accessors.h          |   9 +
 drivers/clk/qcom/Kconfig                           |  28 ++
 drivers/clk/qcom/Makefile                          |   5 +
 drivers/clk/qcom/clk-hfpll.c                       | 244 +++++++++++++
 drivers/clk/qcom/clk-hfpll.h                       |  44 +++
 drivers/clk/qcom/clk-krait.c                       | 126 +++++++
 drivers/clk/qcom/clk-krait.h                       |  40 +++
 drivers/clk/qcom/gcc-ipq806x.c                     |  82 +++++
 drivers/clk/qcom/gcc-msm8960.c                     | 172 +++++++++
 drivers/clk/qcom/hfpll.c                           |  96 +++++
 drivers/clk/qcom/kpss-xcc.c                        |  87 +++++
 drivers/clk/qcom/krait-cc.c                        | 397 +++++++++++++++++++++
 drivers/cpufreq/Kconfig.arm                        |   6 +-
 drivers/cpufreq/Makefile                           |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-kryo.c                | 232 ------------
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 387 ++++++++++++++++++++
 include/dt-bindings/clock/qcom,gcc-msm8960.h       |   2 +
 26 files changed, 1941 insertions(+), 239 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,hfpll.txt
 create mode 100644 Documentation/devicetree/bindings/clock/qcom,krait-cc.txt
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt} (98%)
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
 create mode 100644 drivers/clk/qcom/hfpll.c
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
 create mode 100644 drivers/clk/qcom/krait-cc.c
 delete mode 100644 drivers/cpufreq/qcom-cpufreq-kryo.c
 create mode 100644 drivers/cpufreq/qcom-cpufreq-nvmem.c
Signature · 1 line
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#22 lore raw
Quoted 8 lines · Sricharan R

Hi Craig,

Quoted 5 lines
Quoted 4 lines

[v12]
* Added my signed-off that was missing in some patches.
* Added Bjorn's acked that i missed earlier.

Quoted 8 lines
Quoted 3 lines

Can you give this a try on your 8974 device and check if the pvs version reporting, scaling for higher frequencies are fine ? Sorry, i could not get hold of a 8974 device. So in-case if you

still

Quoted 3 lines

have the issues with higher frequencies, can you give a quick debug and report. That would be of great help.

Ping on this ..

Hi, didn't see your last message,

Will have a try on mine in the weekend and report back.

Quoted 215 lines

Regards,
Sricharan

Quoted 7 lines

Regards,
Sricharan

Quoted 3 lines

[v11]
* Dropped patch 13 and 14 from v10 and
merged the qcom-cpufreq-krait driver to the existing

qcom-cpufreq-kryo.c

Quoted 11 lines
Quoted 11 lines

* Rebased on top of clk-next
* Fixed a bug while populating the pvs version for krait.

[v10]
* Addressed Stephen's comments to add clocks bindings properties to the newly introduced nodes.
* Added a change to include opp-supported-hw to qcom-cpufreq.c
* Rebased on top of clk-next
* Although there were minor changes to bindings and the driver retained the acked-by tags from Rob and Viresh respectively.

Quoted 5 lines
Quoted 5 lines

[v9]
* Fixed a rebase issue in Makefile and added Tag from Robh.

[v8]
* Fixed a bug in path#14 pointed out by Viresh and also added

tags.

Quoted 17 lines
Quoted 17 lines

No change in any other patch.

[v7]
* Fixed comments from Viresh for cleaning up the error handling in qcom-cpufreq.c. Also changed the init function to lateinit call. This is required because nvmem which gets initialised with module_init needs to go first.
* Fixed Rob's comments for bindings documentation
* Fixed kbuild build issue in clk-lpc32xx.c
* Rebased on top of clk-next

[v6]
* Adrressed comments from Viresh for patch #14 in v5 [5]
* Introduced a new binding operating-points-v2-krait-cpu as per discussion with Rob
* Added Review tags

Quoted 3 lines
Quoted 3 lines

[v5]
* Addressed comments from Rob for bindings
* Addressed comments from Viresh to use dev_pm_opp_set_prop_name,

accordingly

Quoted 1 line
Quoted 1 line

dropped patch #12 and corrected patch #11 from previous patch

set in [4]

Quoted 7 lines
Quoted 7 lines

* Converted to use #spdx tags for newly introduced files

Mostly a resend of the v3 posted by Stephen quite some time back [1] except for few changes.
Based on reading some feedback from list,
* Dropped the patch "clk: Add safe switch hook" from v3 [2]. Now this is taken care by patch#10 in this series only for

Krait.

Quoted 5 lines
Quoted 5 lines

* Dropped the path "clk: Avoid sending high rates to downstream clocks during set_rate" from v3 [3].
* Rebased on top of clk-next.
* Dropped the DT update from the series. Will send separately
* Now with cpufreq-dt+opp supporting voltage scaling, registering

the

Quoted 2 lines
Quoted 2 lines

krait cpu supplies in DT should be sufficient. But one issue is, the qcom-cpufreq drivers reads the efuse and based on that

registers

Quoted 2 lines
Quoted 2 lines

the opp data and then registers the cpufreq-dt device. So when cpufreq-dt driver probes and registers the regulator to the OPP

framework,

Quoted 1 line
Quoted 1 line

it expects that the opp data for the device should not be

registered before

Quoted 1 line
Quoted 1 line

the regulator. Will send a RFC patch removing that check, to

find out the

Quoted 36 lines
Quoted 36 lines

right way of doing it.

These patches provide cpufreq scaling on devices with Krait CPUs. In Krait CPU designs there's one PLL and two muxes per CPU, allowing us to switch CPU frequencies independently.

				 secondary
	 +-----+                    +
	 | QSB |-------+------------|\
	 +-----+       |            | |-+
		       |    +-------|/  |
		       |    |       +   |
	 +-----+       |    |           |
	 | PLL |----+-------+           |   primary
	 +-----+    |  |                |     +
		    |  |                +-----|\       +------+
	 +-------+  |  |                      | \      |      |
	 | HFPLL |----------+-----------------|  |-----| CPU0 |
	 +-------+  |  |    |                 |  |     |      |
		    |  |    | +-----+         | /      +------+
		    |  |    +-| / 2 |---------|/
		    |  |      +-----+         +
		    |  |         secondary
		    |  |            +
		    |  +------------|\
		    |               | |-+
		    +---------------|/  |   primary
				    +   |     +
					+-----|\       +------+
	 +-------+                            | \      |      |
	 | HFPLL |----------------------------|  |-----| CPU1 |
	 +-------+          |                 |  |     |      |
			    | +-----+         | /      +------+
			    +-| / 2 |---------|/
			      +-----+         +
Quoted 4 lines
Quoted 4 lines

To support this in the common clock framework we model the muxes, dividers, and PLLs as different clocks. CPUfreq only interacts with the primary mux (farthest right in the diagram). When CPUfreq sets a rate, the mux code finds the best parent that can provide the

rate.

Quoted 1 line
Quoted 1 line

Due to the design, QSB and the top PLL are always a fixed rate and

thus

Quoted 2 lines
Quoted 2 lines

only support one frequency each. These sources provide the lowest frequencies for the CPUs. The HFPLLs are where we can make the CPU

go

Quoted 4 lines
Quoted 4 lines

faster (GHz range). Sometimes we need to run the HFPLL twice as fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL

because

Quoted 1 line
Quoted 1 line

we need to turn off the output of the PLL when changing its

frequency.

Quoted 1 line
Quoted 1 line

This means we have to switch over to the secondary mux and use one

of the

Quoted 1 line
Quoted 1 line

fixed sources. This is why we need something like the safe parent

patch.

Quoted 2 lines
Quoted 2 lines

[1]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332607.html

Quoted 1 line
Quoted 1 line

[2]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332615.html

Quoted 1 line
Quoted 1 line

[3]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332608.html

Quoted 23 lines
Quoted 23 lines

[4] https://lwn.net/Articles/740994/
[5] https://lkml.org/lkml/2017/12/19/537

Sricharan R (3):
clk: qcom: Add safe switch hook for krait mux clocks
cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem
based qcom socs
cpufreq: qcom: Add support for krait based socs

Stephen Boyd (11):
ARM: Add Krait L2 register accessor functions
clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
clk: qcom: Add HFPLL driver
dt-bindings: clock: Document qcom,hfpll
clk: qcom: Add MSM8960/APQ8064's HFPLLs
clk: qcom: Add IPQ806X's HFPLLs
clk: qcom: Add support for Krait clocks
clk: qcom: Add KPSS ACC/GCC driver
dt-bindings: arm: Document qcom,kpss-gcc
clk: qcom: Add Krait clock controller driver
dt-bindings: clock: Document qcom,krait-cc

Quoted 12 lines
Quoted 4 lines
 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  19 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  44 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt       |  60 ++++
 .../devicetree/bindings/clock/qcom,krait-cc.txt    |  34 ++
Quoted 8 lines
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   7 +-
 arch/arm/common/Kconfig                            |   3 +
 arch/arm/common/Makefile                           |   1 +
 arch/arm/common/krait-l2-accessors.c               |  48 +++
 arch/arm/include/asm/krait-l2-accessors.h          |   9 +
 drivers/clk/qcom/Kconfig                           |  28 ++
 drivers/clk/qcom/Makefile                          |   5 +
 drivers/clk/qcom/clk-hfpll.c                       | 244

+++++++++++++

Quoted 8 lines
Quoted 8 lines
 drivers/clk/qcom/clk-hfpll.h                       |  44 +++
 drivers/clk/qcom/clk-krait.c                       | 126 +++++++
 drivers/clk/qcom/clk-krait.h                       |  40 +++
 drivers/clk/qcom/gcc-ipq806x.c                     |  82 +++++
 drivers/clk/qcom/gcc-msm8960.c                     | 172 +++++++++
 drivers/clk/qcom/hfpll.c                           |  96 +++++
 drivers/clk/qcom/kpss-xcc.c                        |  87 +++++
 drivers/clk/qcom/krait-cc.c                        | 397

+++++++++++++++++++++

Quoted 4 lines
Quoted 4 lines
 drivers/cpufreq/Kconfig.arm                        |   6 +-
 drivers/cpufreq/Makefile                           |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-kryo.c                | 232

------------

Quoted 1 line
Quoted 1 line
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 387

++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
 include/dt-bindings/clock/qcom,gcc-msm8960.h       |   2 +
 26 files changed, 1941 insertions(+), 239 deletions(-)
 create mode 100644

Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,hfpll.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,krait-cc.txt

Quoted 1 line
Quoted 1 line
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt =>

qcom-nvmem-cpufreq.txt} (98%)

Quoted 13 lines
Quoted 12 lines
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
 create mode 100644 drivers/clk/qcom/hfpll.c
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
 create mode 100644 drivers/clk/qcom/krait-cc.c
 delete mode 100644 drivers/cpufreq/qcom-cpufreq-kryo.c
 create mode 100644 drivers/cpufreq/qcom-cpufreq-nvmem.c
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#23 lore raw

Yup, this patch seems to have fixed the higher frequencies from the quick test I did.

Quoted 246 lines · Craig Tatlor
Quoted 8 lines · Sricharan R

Hi Craig,

Quoted 5 lines
Quoted 4 lines

[v12]
* Added my signed-off that was missing in some patches.
* Added Bjorn's acked that i missed earlier.

Quoted 5 lines
Quoted 3 lines

Can you give this a try on your 8974 device and check if the pvs version reporting, scaling for higher frequencies are fine ? Sorry, i could not get hold of a 8974 device. So in-case if you

still

Quoted 1 line

have the issues with higher frequencies, can you give a quick

debug

Quoted 3 lines
Quoted 2 lines

and report. That would be of great help.

Ping on this ..

Hi, didn't see your last message,

Will have a try on mine in the weekend and report back.

Quoted 24 lines

Regards,
Sricharan

Quoted 7 lines

Regards,
Sricharan

Quoted 3 lines

[v11]
* Dropped patch 13 and 14 from v10 and
merged the qcom-cpufreq-krait driver to the existing

qcom-cpufreq-kryo.c

Quoted 12 lines
Quoted 12 lines

* Rebased on top of clk-next
* Fixed a bug while populating the pvs version for krait.

[v10]
* Addressed Stephen's comments to add clocks bindings properties to the newly introduced nodes.
* Added a change to include opp-supported-hw to qcom-cpufreq.c
* Rebased on top of clk-next
* Although there were minor changes to bindings and the driver retained the acked-by tags from Rob and Viresh respectively.

Quoted 12 lines
Quoted 5 lines
Quoted 5 lines

[v9]
* Fixed a rebase issue in Makefile and added Tag from Robh.

[v8]
* Fixed a bug in path#14 pointed out by Viresh and also added

tags.

Quoted 6 lines
Quoted 6 lines

No change in any other patch.

[v7]
* Fixed comments from Viresh for cleaning up the error handling in qcom-cpufreq.c. Also changed the init function to lateinit call. This is required because nvmem which gets initialised

with

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

module_init needs to go first.
* Fixed Rob's comments for bindings documentation
* Fixed kbuild build issue in clk-lpc32xx.c
* Rebased on top of clk-next

[v6]
* Adrressed comments from Viresh for patch #14 in v5 [5]
* Introduced a new binding operating-points-v2-krait-cpu as per discussion with Rob
* Added Review tags

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

[v5]
* Addressed comments from Rob for bindings
* Addressed comments from Viresh to use dev_pm_opp_set_prop_name,

accordingly

Quoted 1 line
Quoted 1 line

dropped patch #12 and corrected patch #11 from previous patch

set in [4]

Quoted 3 lines
Quoted 3 lines

* Converted to use #spdx tags for newly introduced files

Mostly a resend of the v3 posted by Stephen quite some time back

[1]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

except for few changes.
Based on reading some feedback from list,
* Dropped the patch "clk: Add safe switch hook" from v3 [2]. Now this is taken care by patch#10 in this series only for

Quoted 8 lines

Krait.

Quoted 5 lines
Quoted 5 lines

* Dropped the path "clk: Avoid sending high rates to downstream clocks during set_rate" from v3 [3].
* Rebased on top of clk-next.
* Dropped the DT update from the series. Will send separately
* Now with cpufreq-dt+opp supporting voltage scaling, registering

the

Quoted 1 line
Quoted 1 line

krait cpu supplies in DT should be sufficient. But one issue

is,

Quoted 13 lines
Quoted 1 line
Quoted 1 line

the qcom-cpufreq drivers reads the efuse and based on that

registers

Quoted 2 lines
Quoted 2 lines

the opp data and then registers the cpufreq-dt device. So when cpufreq-dt driver probes and registers the regulator to the OPP

framework,

Quoted 1 line
Quoted 1 line

it expects that the opp data for the device should not be

registered before

Quoted 1 line
Quoted 1 line

the regulator. Will send a RFC patch removing that check, to

find out the

Quoted 4 lines
Quoted 4 lines

right way of doing it.

These patches provide cpufreq scaling on devices with Krait CPUs. In Krait CPU designs there's one PLL and two muxes per CPU,

allowing

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

us to switch CPU frequencies independently.

				 secondary
	 +-----+                    +
	 | QSB |-------+------------|\
	 +-----+       |            | |-+
		       |    +-------|/  |
		       |    |       +   |
	 +-----+       |    |           |
	 | PLL |----+-------+           |   primary
	 +-----+    |  |                |     +
		    |  |                +-----|\       +------+
	 +-------+  |  |                      | \      |      |
	 | HFPLL |----------+-----------------|  |-----| CPU0 |
	 +-------+  |  |    |                 |  |     |      |
		    |  |    | +-----+         | /      +------+
		    |  |    +-| / 2 |---------|/
		    |  |      +-----+         +
		    |  |         secondary
		    |  |            +
		    |  +------------|\
		    |               | |-+
		    +---------------|/  |   primary
				    +   |     +
					+-----|\       +------+
	 +-------+                            | \      |      |
	 | HFPLL |----------------------------|  |-----| CPU1 |
	 +-------+          |                 |  |     |      |
			    | +-----+         | /      +------+
			    +-| / 2 |---------|/
			      +-----+         +
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

To support this in the common clock framework we model the muxes, dividers, and PLLs as different clocks. CPUfreq only interacts with the primary mux (farthest right in the diagram). When CPUfreq sets a rate, the mux code finds the best parent that can provide

the

Quoted 99 lines

rate.

Quoted 1 line
Quoted 1 line

Due to the design, QSB and the top PLL are always a fixed rate and

thus

Quoted 2 lines
Quoted 2 lines

only support one frequency each. These sources provide the lowest frequencies for the CPUs. The HFPLLs are where we can make the CPU

go

Quoted 4 lines
Quoted 4 lines

faster (GHz range). Sometimes we need to run the HFPLL twice as fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL

because

Quoted 1 line
Quoted 1 line

we need to turn off the output of the PLL when changing its

frequency.

Quoted 1 line
Quoted 1 line

This means we have to switch over to the secondary mux and use one

of the

Quoted 1 line
Quoted 1 line

fixed sources. This is why we need something like the safe parent

patch.

Quoted 2 lines
Quoted 2 lines

[1]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332607.html

Quoted 1 line
Quoted 1 line

[2]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332615.html

Quoted 1 line
Quoted 1 line

[3]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332608.html

Quoted 23 lines
Quoted 23 lines

[4] https://lwn.net/Articles/740994/
[5] https://lkml.org/lkml/2017/12/19/537

Sricharan R (3):
clk: qcom: Add safe switch hook for krait mux clocks
cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem
based qcom socs
cpufreq: qcom: Add support for krait based socs

Stephen Boyd (11):
ARM: Add Krait L2 register accessor functions
clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
clk: qcom: Add HFPLL driver
dt-bindings: clock: Document qcom,hfpll
clk: qcom: Add MSM8960/APQ8064's HFPLLs
clk: qcom: Add IPQ806X's HFPLLs
clk: qcom: Add support for Krait clocks
clk: qcom: Add KPSS ACC/GCC driver
dt-bindings: arm: Document qcom,kpss-gcc
clk: qcom: Add Krait clock controller driver
dt-bindings: clock: Document qcom,krait-cc

Quoted 12 lines
Quoted 4 lines
 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  19 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  44 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt       |  60 ++++
 .../devicetree/bindings/clock/qcom,krait-cc.txt    |  34 ++
Quoted 8 lines
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   7 +-
 arch/arm/common/Kconfig                            |   3 +
 arch/arm/common/Makefile                           |   1 +
 arch/arm/common/krait-l2-accessors.c               |  48 +++
 arch/arm/include/asm/krait-l2-accessors.h          |   9 +
 drivers/clk/qcom/Kconfig                           |  28 ++
 drivers/clk/qcom/Makefile                          |   5 +
 drivers/clk/qcom/clk-hfpll.c                       | 244

+++++++++++++

Quoted 8 lines
Quoted 8 lines
 drivers/clk/qcom/clk-hfpll.h                       |  44 +++
 drivers/clk/qcom/clk-krait.c                       | 126 +++++++
 drivers/clk/qcom/clk-krait.h                       |  40 +++
 drivers/clk/qcom/gcc-ipq806x.c                     |  82 +++++
 drivers/clk/qcom/gcc-msm8960.c                     | 172 +++++++++
 drivers/clk/qcom/hfpll.c                           |  96 +++++
 drivers/clk/qcom/kpss-xcc.c                        |  87 +++++
 drivers/clk/qcom/krait-cc.c                        | 397

+++++++++++++++++++++

Quoted 4 lines
Quoted 4 lines
 drivers/cpufreq/Kconfig.arm                        |   6 +-
 drivers/cpufreq/Makefile                           |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-kryo.c                | 232

------------

Quoted 1 line
Quoted 1 line
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 387

++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
 include/dt-bindings/clock/qcom,gcc-msm8960.h       |   2 +
 26 files changed, 1941 insertions(+), 239 deletions(-)
 create mode 100644

Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,hfpll.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,krait-cc.txt

Quoted 1 line
Quoted 1 line
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt =>

qcom-nvmem-cpufreq.txt} (98%)

Quoted 13 lines
Quoted 12 lines
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
 create mode 100644 drivers/clk/qcom/hfpll.c
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
 create mode 100644 drivers/clk/qcom/krait-cc.c
 delete mode 100644 drivers/cpufreq/qcom-cpufreq-kryo.c
 create mode 100644 drivers/cpufreq/qcom-cpufreq-nvmem.c
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#24 lore raw
Quoted 2 lines · Craig

Yup, this patch seems to have fixed the higher frequencies from the quick test I did.

Thanks !!. Can i take that as Craig Tatlor <[email protected]> ?

Regards,
Sricharan

tested-by:

Quoted 248 lines · Craig Tatlor
Quoted 246 lines
Quoted 8 lines · Sricharan R

Hi Craig,

Quoted 5 lines
Quoted 4 lines

[v12]
* Added my signed-off that was missing in some patches.
* Added Bjorn's acked that i missed earlier.

Quoted 5 lines
Quoted 3 lines

Can you give this a try on your 8974 device and check if the pvs version reporting, scaling for higher frequencies are fine ? Sorry, i could not get hold of a 8974 device. So in-case if you

still

Quoted 1 line

have the issues with higher frequencies, can you give a quick

debug

Quoted 3 lines
Quoted 2 lines

and report. That would be of great help.

Ping on this ..

Hi, didn't see your last message,

Will have a try on mine in the weekend and report back.

Quoted 24 lines

Regards,
Sricharan

Quoted 7 lines

Regards,
Sricharan

Quoted 3 lines

[v11]
* Dropped patch 13 and 14 from v10 and
merged the qcom-cpufreq-krait driver to the existing

qcom-cpufreq-kryo.c

Quoted 12 lines
Quoted 12 lines

* Rebased on top of clk-next
* Fixed a bug while populating the pvs version for krait.

[v10]
* Addressed Stephen's comments to add clocks bindings properties to the newly introduced nodes.
* Added a change to include opp-supported-hw to qcom-cpufreq.c
* Rebased on top of clk-next
* Although there were minor changes to bindings and the driver retained the acked-by tags from Rob and Viresh respectively.

Quoted 12 lines
Quoted 5 lines
Quoted 5 lines

[v9]
* Fixed a rebase issue in Makefile and added Tag from Robh.

[v8]
* Fixed a bug in path#14 pointed out by Viresh and also added

tags.

Quoted 6 lines
Quoted 6 lines

No change in any other patch.

[v7]
* Fixed comments from Viresh for cleaning up the error handling in qcom-cpufreq.c. Also changed the init function to lateinit call. This is required because nvmem which gets initialised

with

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

module_init needs to go first.
* Fixed Rob's comments for bindings documentation
* Fixed kbuild build issue in clk-lpc32xx.c
* Rebased on top of clk-next

[v6]
* Adrressed comments from Viresh for patch #14 in v5 [5]
* Introduced a new binding operating-points-v2-krait-cpu as per discussion with Rob
* Added Review tags

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

[v5]
* Addressed comments from Rob for bindings
* Addressed comments from Viresh to use dev_pm_opp_set_prop_name,

accordingly

Quoted 1 line
Quoted 1 line

dropped patch #12 and corrected patch #11 from previous patch

set in [4]

Quoted 3 lines
Quoted 3 lines

* Converted to use #spdx tags for newly introduced files

Mostly a resend of the v3 posted by Stephen quite some time back

[1]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

except for few changes.
Based on reading some feedback from list,
* Dropped the patch "clk: Add safe switch hook" from v3 [2]. Now this is taken care by patch#10 in this series only for

Quoted 8 lines

Krait.

Quoted 5 lines
Quoted 5 lines

* Dropped the path "clk: Avoid sending high rates to downstream clocks during set_rate" from v3 [3].
* Rebased on top of clk-next.
* Dropped the DT update from the series. Will send separately
* Now with cpufreq-dt+opp supporting voltage scaling, registering

the

Quoted 1 line
Quoted 1 line

krait cpu supplies in DT should be sufficient. But one issue

is,

Quoted 13 lines
Quoted 1 line
Quoted 1 line

the qcom-cpufreq drivers reads the efuse and based on that

registers

Quoted 2 lines
Quoted 2 lines

the opp data and then registers the cpufreq-dt device. So when cpufreq-dt driver probes and registers the regulator to the OPP

framework,

Quoted 1 line
Quoted 1 line

it expects that the opp data for the device should not be

registered before

Quoted 1 line
Quoted 1 line

the regulator. Will send a RFC patch removing that check, to

find out the

Quoted 4 lines
Quoted 4 lines

right way of doing it.

These patches provide cpufreq scaling on devices with Krait CPUs. In Krait CPU designs there's one PLL and two muxes per CPU,

allowing

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

us to switch CPU frequencies independently.

				 secondary
	 +-----+                    +
	 | QSB |-------+------------|\
	 +-----+       |            | |-+
		       |    +-------|/  |
		       |    |       +   |
	 +-----+       |    |           |
	 | PLL |----+-------+           |   primary
	 +-----+    |  |                |     +
		    |  |                +-----|\       +------+
	 +-------+  |  |                      | \      |      |
	 | HFPLL |----------+-----------------|  |-----| CPU0 |
	 +-------+  |  |    |                 |  |     |      |
		    |  |    | +-----+         | /      +------+
		    |  |    +-| / 2 |---------|/
		    |  |      +-----+         +
		    |  |         secondary
		    |  |            +
		    |  +------------|\
		    |               | |-+
		    +---------------|/  |   primary
				    +   |     +
					+-----|\       +------+
	 +-------+                            | \      |      |
	 | HFPLL |----------------------------|  |-----| CPU1 |
	 +-------+          |                 |  |     |      |
			    | +-----+         | /      +------+
			    +-| / 2 |---------|/
			      +-----+         +
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

To support this in the common clock framework we model the muxes, dividers, and PLLs as different clocks. CPUfreq only interacts with the primary mux (farthest right in the diagram). When CPUfreq sets a rate, the mux code finds the best parent that can provide

the

Quoted 99 lines

rate.

Quoted 1 line
Quoted 1 line

Due to the design, QSB and the top PLL are always a fixed rate and

thus

Quoted 2 lines
Quoted 2 lines

only support one frequency each. These sources provide the lowest frequencies for the CPUs. The HFPLLs are where we can make the CPU

go

Quoted 4 lines
Quoted 4 lines

faster (GHz range). Sometimes we need to run the HFPLL twice as fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL

because

Quoted 1 line
Quoted 1 line

we need to turn off the output of the PLL when changing its

frequency.

Quoted 1 line
Quoted 1 line

This means we have to switch over to the secondary mux and use one

of the

Quoted 1 line
Quoted 1 line

fixed sources. This is why we need something like the safe parent

patch.

Quoted 2 lines
Quoted 2 lines

[1]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332607.html

Quoted 1 line
Quoted 1 line

[2]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332615.html

Quoted 1 line
Quoted 1 line

[3]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332608.html

Quoted 23 lines
Quoted 23 lines

[4] https://lwn.net/Articles/740994/
[5] https://lkml.org/lkml/2017/12/19/537

Sricharan R (3):
clk: qcom: Add safe switch hook for krait mux clocks
cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem
based qcom socs
cpufreq: qcom: Add support for krait based socs

Stephen Boyd (11):
ARM: Add Krait L2 register accessor functions
clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
clk: qcom: Add HFPLL driver
dt-bindings: clock: Document qcom,hfpll
clk: qcom: Add MSM8960/APQ8064's HFPLLs
clk: qcom: Add IPQ806X's HFPLLs
clk: qcom: Add support for Krait clocks
clk: qcom: Add KPSS ACC/GCC driver
dt-bindings: arm: Document qcom,kpss-gcc
clk: qcom: Add Krait clock controller driver
dt-bindings: clock: Document qcom,krait-cc

Quoted 12 lines
Quoted 4 lines
 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  19 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  44 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt       |  60 ++++
 .../devicetree/bindings/clock/qcom,krait-cc.txt    |  34 ++
Quoted 8 lines
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   7 +-
 arch/arm/common/Kconfig                            |   3 +
 arch/arm/common/Makefile                           |   1 +
 arch/arm/common/krait-l2-accessors.c               |  48 +++
 arch/arm/include/asm/krait-l2-accessors.h          |   9 +
 drivers/clk/qcom/Kconfig                           |  28 ++
 drivers/clk/qcom/Makefile                          |   5 +
 drivers/clk/qcom/clk-hfpll.c                       | 244

+++++++++++++

Quoted 8 lines
Quoted 8 lines
 drivers/clk/qcom/clk-hfpll.h                       |  44 +++
 drivers/clk/qcom/clk-krait.c                       | 126 +++++++
 drivers/clk/qcom/clk-krait.h                       |  40 +++
 drivers/clk/qcom/gcc-ipq806x.c                     |  82 +++++
 drivers/clk/qcom/gcc-msm8960.c                     | 172 +++++++++
 drivers/clk/qcom/hfpll.c                           |  96 +++++
 drivers/clk/qcom/kpss-xcc.c                        |  87 +++++
 drivers/clk/qcom/krait-cc.c                        | 397

+++++++++++++++++++++

Quoted 4 lines
Quoted 4 lines
 drivers/cpufreq/Kconfig.arm                        |   6 +-
 drivers/cpufreq/Makefile                           |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-kryo.c                | 232

------------

Quoted 1 line
Quoted 1 line
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 387

++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
 include/dt-bindings/clock/qcom,gcc-msm8960.h       |   2 +
 26 files changed, 1941 insertions(+), 239 deletions(-)
 create mode 100644

Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,hfpll.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,krait-cc.txt

Quoted 1 line
Quoted 1 line
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt =>

qcom-nvmem-cpufreq.txt} (98%)

Quoted 13 lines
Quoted 12 lines
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
 create mode 100644 drivers/clk/qcom/hfpll.c
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
 create mode 100644 drivers/clk/qcom/krait-cc.c
 delete mode 100644 drivers/cpufreq/qcom-cpufreq-kryo.c
 create mode 100644 drivers/cpufreq/qcom-cpufreq-nvmem.c
Signature · 1 line
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
author Tested-by Craig Tatlor
#26 lore raw
In reply to Craig
Quoted 2 lines · Craig

Yup, this patch seems to have fixed the higher frequencies from the quick test I did.

Thanks !!. Can i take that as

Regards,
Sricharan

Quoted 248 lines · Craig Tatlor
Quoted 246 lines
Quoted 8 lines · Sricharan R

Hi Craig,

Quoted 5 lines
Quoted 4 lines

[v12]
* Added my signed-off that was missing in some patches.
* Added Bjorn's acked that i missed earlier.

Quoted 5 lines
Quoted 3 lines

Can you give this a try on your 8974 device and check if the pvs version reporting, scaling for higher frequencies are fine ? Sorry, i could not get hold of a 8974 device. So in-case if you

still

Quoted 1 line

have the issues with higher frequencies, can you give a quick

debug

Quoted 3 lines
Quoted 2 lines

and report. That would be of great help.

Ping on this ..

Hi, didn't see your last message,

Will have a try on mine in the weekend and report back.

Quoted 24 lines

Regards,
Sricharan

Quoted 7 lines

Regards,
Sricharan

Quoted 3 lines

[v11]
* Dropped patch 13 and 14 from v10 and
merged the qcom-cpufreq-krait driver to the existing

qcom-cpufreq-kryo.c

Quoted 12 lines
Quoted 12 lines

* Rebased on top of clk-next
* Fixed a bug while populating the pvs version for krait.

[v10]
* Addressed Stephen's comments to add clocks bindings properties to the newly introduced nodes.
* Added a change to include opp-supported-hw to qcom-cpufreq.c
* Rebased on top of clk-next
* Although there were minor changes to bindings and the driver retained the acked-by tags from Rob and Viresh respectively.

Quoted 12 lines
Quoted 5 lines
Quoted 5 lines

[v9]
* Fixed a rebase issue in Makefile and added Tag from Robh.

[v8]
* Fixed a bug in path#14 pointed out by Viresh and also added

tags.

Quoted 6 lines
Quoted 6 lines

No change in any other patch.

[v7]
* Fixed comments from Viresh for cleaning up the error handling in qcom-cpufreq.c. Also changed the init function to lateinit call. This is required because nvmem which gets initialised

with

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

module_init needs to go first.
* Fixed Rob's comments for bindings documentation
* Fixed kbuild build issue in clk-lpc32xx.c
* Rebased on top of clk-next

[v6]
* Adrressed comments from Viresh for patch #14 in v5 [5]
* Introduced a new binding operating-points-v2-krait-cpu as per discussion with Rob
* Added Review tags

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

[v5]
* Addressed comments from Rob for bindings
* Addressed comments from Viresh to use dev_pm_opp_set_prop_name,

accordingly

Quoted 1 line
Quoted 1 line

dropped patch #12 and corrected patch #11 from previous patch

set in [4]

Quoted 3 lines
Quoted 3 lines

* Converted to use #spdx tags for newly introduced files

Mostly a resend of the v3 posted by Stephen quite some time back

[1]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

except for few changes.
Based on reading some feedback from list,
* Dropped the patch "clk: Add safe switch hook" from v3 [2]. Now this is taken care by patch#10 in this series only for

Quoted 8 lines

Krait.

Quoted 5 lines
Quoted 5 lines

* Dropped the path "clk: Avoid sending high rates to downstream clocks during set_rate" from v3 [3].
* Rebased on top of clk-next.
* Dropped the DT update from the series. Will send separately
* Now with cpufreq-dt+opp supporting voltage scaling, registering

the

Quoted 1 line
Quoted 1 line

krait cpu supplies in DT should be sufficient. But one issue

is,

Quoted 13 lines
Quoted 1 line
Quoted 1 line

the qcom-cpufreq drivers reads the efuse and based on that

registers

Quoted 2 lines
Quoted 2 lines

the opp data and then registers the cpufreq-dt device. So when cpufreq-dt driver probes and registers the regulator to the OPP

framework,

Quoted 1 line
Quoted 1 line

it expects that the opp data for the device should not be

registered before

Quoted 1 line
Quoted 1 line

the regulator. Will send a RFC patch removing that check, to

find out the

Quoted 4 lines
Quoted 4 lines

right way of doing it.

These patches provide cpufreq scaling on devices with Krait CPUs. In Krait CPU designs there's one PLL and two muxes per CPU,

allowing

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

us to switch CPU frequencies independently.

				 secondary
	 +-----+                    +
	 | QSB |-------+------------|\
	 +-----+       |            | |-+
		       |    +-------|/  |
		       |    |       +   |
	 +-----+       |    |           |
	 | PLL |----+-------+           |   primary
	 +-----+    |  |                |     +
		    |  |                +-----|\       +------+
	 +-------+  |  |                      | \      |      |
	 | HFPLL |----------+-----------------|  |-----| CPU0 |
	 +-------+  |  |    |                 |  |     |      |
		    |  |    | +-----+         | /      +------+
		    |  |    +-| / 2 |---------|/
		    |  |      +-----+         +
		    |  |         secondary
		    |  |            +
		    |  +------------|\
		    |               | |-+
		    +---------------|/  |   primary
				    +   |     +
					+-----|\       +------+
	 +-------+                            | \      |      |
	 | HFPLL |----------------------------|  |-----| CPU1 |
	 +-------+          |                 |  |     |      |
			    | +-----+         | /      +------+
			    +-| / 2 |---------|/
			      +-----+         +
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

To support this in the common clock framework we model the muxes, dividers, and PLLs as different clocks. CPUfreq only interacts with the primary mux (farthest right in the diagram). When CPUfreq sets a rate, the mux code finds the best parent that can provide

the

Quoted 99 lines

rate.

Quoted 1 line
Quoted 1 line

Due to the design, QSB and the top PLL are always a fixed rate and

thus

Quoted 2 lines
Quoted 2 lines

only support one frequency each. These sources provide the lowest frequencies for the CPUs. The HFPLLs are where we can make the CPU

go

Quoted 4 lines
Quoted 4 lines

faster (GHz range). Sometimes we need to run the HFPLL twice as fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL

because

Quoted 1 line
Quoted 1 line

we need to turn off the output of the PLL when changing its

frequency.

Quoted 1 line
Quoted 1 line

This means we have to switch over to the secondary mux and use one

of the

Quoted 1 line
Quoted 1 line

fixed sources. This is why we need something like the safe parent

patch.

Quoted 2 lines
Quoted 2 lines

[1]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332607.html

Quoted 1 line
Quoted 1 line

[2]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332615.html

Quoted 1 line
Quoted 1 line

[3]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332608.html

Quoted 23 lines
Quoted 23 lines

[4] https://lwn.net/Articles/740994/
[5] https://lkml.org/lkml/2017/12/19/537

Sricharan R (3):
clk: qcom: Add safe switch hook for krait mux clocks
cpufreq: qcom: Re-organise kryo cpufreq to use it for other nvmem
based qcom socs
cpufreq: qcom: Add support for krait based socs

Stephen Boyd (11):
ARM: Add Krait L2 register accessor functions
clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
clk: qcom: Add HFPLL driver
dt-bindings: clock: Document qcom,hfpll
clk: qcom: Add MSM8960/APQ8064's HFPLLs
clk: qcom: Add IPQ806X's HFPLLs
clk: qcom: Add support for Krait clocks
clk: qcom: Add KPSS ACC/GCC driver
dt-bindings: arm: Document qcom,kpss-gcc
clk: qcom: Add Krait clock controller driver
dt-bindings: clock: Document qcom,krait-cc

Quoted 12 lines
Quoted 4 lines
 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  19 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  44 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt       |  60 ++++
 .../devicetree/bindings/clock/qcom,krait-cc.txt    |  34 ++
Quoted 8 lines
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   7 +-
 arch/arm/common/Kconfig                            |   3 +
 arch/arm/common/Makefile                           |   1 +
 arch/arm/common/krait-l2-accessors.c               |  48 +++
 arch/arm/include/asm/krait-l2-accessors.h          |   9 +
 drivers/clk/qcom/Kconfig                           |  28 ++
 drivers/clk/qcom/Makefile                          |   5 +
 drivers/clk/qcom/clk-hfpll.c                       | 244

+++++++++++++

Quoted 8 lines
Quoted 8 lines
 drivers/clk/qcom/clk-hfpll.h                       |  44 +++
 drivers/clk/qcom/clk-krait.c                       | 126 +++++++
 drivers/clk/qcom/clk-krait.h                       |  40 +++
 drivers/clk/qcom/gcc-ipq806x.c                     |  82 +++++
 drivers/clk/qcom/gcc-msm8960.c                     | 172 +++++++++
 drivers/clk/qcom/hfpll.c                           |  96 +++++
 drivers/clk/qcom/kpss-xcc.c                        |  87 +++++
 drivers/clk/qcom/krait-cc.c                        | 397

+++++++++++++++++++++

Quoted 4 lines
Quoted 4 lines
 drivers/cpufreq/Kconfig.arm                        |   6 +-
 drivers/cpufreq/Makefile                           |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-kryo.c                | 232

------------

Quoted 1 line
Quoted 1 line
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 387

++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
 include/dt-bindings/clock/qcom,gcc-msm8960.h       |   2 +
 26 files changed, 1941 insertions(+), 239 deletions(-)
 create mode 100644

Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,hfpll.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,krait-cc.txt

Quoted 1 line
Quoted 1 line
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt =>

qcom-nvmem-cpufreq.txt} (98%)

Quoted 13 lines
Quoted 12 lines
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
 create mode 100644 drivers/clk/qcom/hfpll.c
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
 create mode 100644 drivers/clk/qcom/krait-cc.c
 delete mode 100644 drivers/cpufreq/qcom-cpufreq-kryo.c
 create mode 100644 drivers/cpufreq/qcom-cpufreq-nvmem.c
Signature · 1 line
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#25 lore raw
In reply to Sricharan R
Quoted 7 lines · Sricharan R
Quoted 1 line · Craig

Yup, this patch seems to have fixed the higher frequencies from the

quick test I did.

Quoted 1 line

Thanks !!. Can i take that as Craig Tatlor <[email protected]> ?

Sure, no problem

Quoted 270 lines

Regards,
Sricharan

tested-by:

Quoted 1 line

On 7 September 2018 15:28:53 BST, Craig Tatlor <[email protected]>

Quoted 36 lines · wrote:
Quoted 36 lines
Quoted 8 lines · Sricharan R

Hi Craig,

Quoted 5 lines
Quoted 4 lines

[v12]
* Added my signed-off that was missing in some patches.
* Added Bjorn's acked that i missed earlier.

Quoted 5 lines
Quoted 3 lines

Can you give this a try on your 8974 device and check if the pvs version reporting, scaling for higher frequencies are fine ? Sorry, i could not get hold of a 8974 device. So in-case if you

still

Quoted 1 line

have the issues with higher frequencies, can you give a quick

debug

Quoted 3 lines
Quoted 2 lines

and report. That would be of great help.

Ping on this ..

Hi, didn't see your last message,

Will have a try on mine in the weekend and report back.

Quoted 11 lines

Regards,
Sricharan

Quoted 7 lines

Regards,
Sricharan

Quoted 3 lines

[v11]
* Dropped patch 13 and 14 from v10 and
merged the qcom-cpufreq-krait driver to the existing

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

qcom-cpufreq-kryo.c

Quoted 5 lines
Quoted 5 lines

* Rebased on top of clk-next
* Fixed a bug while populating the pvs version for krait.

[v10]
* Addressed Stephen's comments to add clocks bindings

properties

Quoted 32 lines
Quoted 32 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

to the newly introduced nodes.
* Added a change to include opp-supported-hw to qcom-cpufreq.c
* Rebased on top of clk-next
* Although there were minor changes to bindings and the driver retained the acked-by tags from Rob and Viresh respectively.

Quoted 12 lines
Quoted 5 lines
Quoted 5 lines

[v9]
* Fixed a rebase issue in Makefile and added Tag from Robh.

[v8]
* Fixed a bug in path#14 pointed out by Viresh and also added

tags.

Quoted 6 lines
Quoted 6 lines

No change in any other patch.

[v7]
* Fixed comments from Viresh for cleaning up the error handling in qcom-cpufreq.c. Also changed the init function to lateinit call. This is required because nvmem which gets initialised

with

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

module_init needs to go first.
* Fixed Rob's comments for bindings documentation
* Fixed kbuild build issue in clk-lpc32xx.c
* Rebased on top of clk-next

[v6]
* Adrressed comments from Viresh for patch #14 in v5 [5]
* Introduced a new binding operating-points-v2-krait-cpu as per discussion with Rob
* Added Review tags

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

[v5]
* Addressed comments from Rob for bindings
* Addressed comments from Viresh to use

dev_pm_opp_set_prop_name,

Quoted 11 lines
Quoted 11 lines
Quoted 6 lines

accordingly

Quoted 1 line
Quoted 1 line

dropped patch #12 and corrected patch #11 from previous patch

set in [4]

Quoted 3 lines
Quoted 3 lines

* Converted to use #spdx tags for newly introduced files

Mostly a resend of the v3 posted by Stephen quite some time back

[1]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

except for few changes.
Based on reading some feedback from list,
* Dropped the patch "clk: Add safe switch hook" from v3 [2]. Now this is taken care by patch#10 in this series only for

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Krait.

Quoted 5 lines
Quoted 5 lines

* Dropped the path "clk: Avoid sending high rates to downstream clocks during set_rate" from v3 [3].
* Rebased on top of clk-next.
* Dropped the DT update from the series. Will send separately
* Now with cpufreq-dt+opp supporting voltage scaling,

registering

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

the

Quoted 1 line
Quoted 1 line

krait cpu supplies in DT should be sufficient. But one issue

is,

Quoted 3 lines
Quoted 1 line
Quoted 1 line

the qcom-cpufreq drivers reads the efuse and based on that

registers

Quoted 1 line
Quoted 1 line

the opp data and then registers the cpufreq-dt device. So

when

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

cpufreq-dt driver probes and registers the regulator to the

OPP

Quoted 42 lines
Quoted 42 lines
Quoted 9 lines

framework,

Quoted 1 line
Quoted 1 line

it expects that the opp data for the device should not be

registered before

Quoted 1 line
Quoted 1 line

the regulator. Will send a RFC patch removing that check, to

find out the

Quoted 4 lines
Quoted 4 lines

right way of doing it.

These patches provide cpufreq scaling on devices with Krait CPUs. In Krait CPU designs there's one PLL and two muxes per CPU,

allowing

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines

us to switch CPU frequencies independently.

				 secondary
	 +-----+                    +
	 | QSB |-------+------------|\
	 +-----+       |            | |-+
		       |    +-------|/  |
		       |    |       +   |
	 +-----+       |    |           |
	 | PLL |----+-------+           |   primary
	 +-----+    |  |                |     +
		    |  |                +-----|\       +------+
	 +-------+  |  |                      | \      |      |
	 | HFPLL |----------+-----------------|  |-----| CPU0 |
	 +-------+  |  |    |                 |  |     |      |
		    |  |    | +-----+         | /      +------+
		    |  |    +-| / 2 |---------|/
		    |  |      +-----+         +
		    |  |         secondary
		    |  |            +
		    |  +------------|\
		    |               | |-+
		    +---------------|/  |   primary
				    +   |     +
					+-----|\       +------+
	 +-------+                            | \      |      |
	 | HFPLL |----------------------------|  |-----| CPU1 |
	 +-------+          |                 |  |     |      |
			    | +-----+         | /      +------+
			    +-| / 2 |---------|/
			      +-----+         +
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

To support this in the common clock framework we model the muxes, dividers, and PLLs as different clocks. CPUfreq only interacts with the primary mux (farthest right in the diagram). When

CPUfreq

Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

sets a rate, the mux code finds the best parent that can provide

the

Quoted 2 lines

rate.

Quoted 1 line
Quoted 1 line

Due to the design, QSB and the top PLL are always a fixed rate

and

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

thus

Quoted 2 lines
Quoted 2 lines

only support one frequency each. These sources provide the lowest frequencies for the CPUs. The HFPLLs are where we can make the

CPU

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

go

Quoted 4 lines
Quoted 4 lines

faster (GHz range). Sometimes we need to run the HFPLL twice as fast and divide it by two to get a particular frequency.

When switching rates we can't leave the CPU clocked by the HFPLL

because

Quoted 1 line
Quoted 1 line

we need to turn off the output of the PLL when changing its

frequency.

Quoted 1 line
Quoted 1 line

This means we have to switch over to the secondary mux and use

one

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

of the

Quoted 1 line
Quoted 1 line

fixed sources. This is why we need something like the safe parent

patch.

Quoted 2 lines
Quoted 2 lines

[1]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332607.html

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

[2]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332615.html

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line

[3]

http://lists.infradead.org/pipermail/linux-arm-kernel/2015-March/332608.html

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

[4] https://lwn.net/Articles/740994/
[5] https://lkml.org/lkml/2017/12/19/537

Sricharan R (3):
clk: qcom: Add safe switch hook for krait mux clocks
cpufreq: qcom: Re-organise kryo cpufreq to use it for other

nvmem

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

based qcom socs
cpufreq: qcom: Add support for krait based socs

Stephen Boyd (11):
ARM: Add Krait L2 register accessor functions
clk: qcom: Add support for High-Frequency PLLs (HFPLLs)
clk: qcom: Add HFPLL driver
dt-bindings: clock: Document qcom,hfpll
clk: qcom: Add MSM8960/APQ8064's HFPLLs
clk: qcom: Add IPQ806X's HFPLLs
clk: qcom: Add support for Krait clocks
clk: qcom: Add KPSS ACC/GCC driver
dt-bindings: arm: Document qcom,kpss-gcc
clk: qcom: Add Krait clock controller driver
dt-bindings: clock: Document qcom,krait-cc

 .../devicetree/bindings/arm/msm/qcom,kpss-acc.txt  |  19 +
 .../devicetree/bindings/arm/msm/qcom,kpss-gcc.txt  |  44 +++
 .../devicetree/bindings/clock/qcom,hfpll.txt       |  60 ++++
 .../devicetree/bindings/clock/qcom,krait-cc.txt    |  34 ++
 .../{kryo-cpufreq.txt => qcom-nvmem-cpufreq.txt}   |   7 +-
 arch/arm/common/Kconfig                            |   3 +
 arch/arm/common/Makefile                           |   1 +
 arch/arm/common/krait-l2-accessors.c               |  48 +++
 arch/arm/include/asm/krait-l2-accessors.h          |   9 +
 drivers/clk/qcom/Kconfig                           |  28 ++
 drivers/clk/qcom/Makefile                          |   5 +
 drivers/clk/qcom/clk-hfpll.c                       | 244
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

+++++++++++++

Quoted 5 lines
Quoted 5 lines
 drivers/clk/qcom/clk-hfpll.h                       |  44 +++
 drivers/clk/qcom/clk-krait.c                       | 126 +++++++
 drivers/clk/qcom/clk-krait.h                       |  40 +++
 drivers/clk/qcom/gcc-ipq806x.c                     |  82 +++++
 drivers/clk/qcom/gcc-msm8960.c                     | 172

+++++++++

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines
Quoted 3 lines
 drivers/clk/qcom/hfpll.c                           |  96 +++++
 drivers/clk/qcom/kpss-xcc.c                        |  87 +++++
 drivers/clk/qcom/krait-cc.c                        | 397

+++++++++++++++++++++

Quoted 4 lines
Quoted 4 lines
 drivers/cpufreq/Kconfig.arm                        |   6 +-
 drivers/cpufreq/Makefile                           |   2 +-
 drivers/cpufreq/cpufreq-dt-platdev.c               |   5 +
 drivers/cpufreq/qcom-cpufreq-kryo.c                | 232

------------

Quoted 1 line
Quoted 1 line
 drivers/cpufreq/qcom-cpufreq-nvmem.c               | 387

++++++++++++++++++++

Quoted 3 lines
Quoted 3 lines
 include/dt-bindings/clock/qcom,gcc-msm8960.h       |   2 +
 26 files changed, 1941 insertions(+), 239 deletions(-)
 create mode 100644
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Documentation/devicetree/bindings/arm/msm/qcom,kpss-gcc.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,hfpll.txt

Quoted 1 line
Quoted 1 line
 create mode 100644

Documentation/devicetree/bindings/clock/qcom,krait-cc.txt

Quoted 1 line
Quoted 1 line
 rename Documentation/devicetree/bindings/opp/{kryo-cpufreq.txt

=>

Quoted 15 lines
Quoted 14 lines
Quoted 14 lines

qcom-nvmem-cpufreq.txt} (98%)

Quoted 13 lines
Quoted 12 lines
 create mode 100644 arch/arm/common/krait-l2-accessors.c
 create mode 100644 arch/arm/include/asm/krait-l2-accessors.h
 create mode 100644 drivers/clk/qcom/clk-hfpll.c
 create mode 100644 drivers/clk/qcom/clk-hfpll.h
 create mode 100644 drivers/clk/qcom/clk-krait.c
 create mode 100644 drivers/clk/qcom/clk-krait.h
 create mode 100644 drivers/clk/qcom/hfpll.c
 create mode 100644 drivers/clk/qcom/kpss-xcc.c
 create mode 100644 drivers/clk/qcom/krait-cc.c
 delete mode 100644 drivers/cpufreq/qcom-cpufreq-kryo.c
 create mode 100644 drivers/cpufreq/qcom-cpufreq-nvmem.c
Signature · 1 line
Please, Don't Panic
maintainer
#28 lore raw

Quoting Stephen Boyd (2018-10-17 08:44:12)

Quoted 12 lines

Quoting Sricharan R (2018-09-20 06:03:31)

Quoted 8 lines · Craig
Quoted 2 lines

Yup, this patch seems to have fixed the higher frequencies from the quick test I did.

Thanks !!. Can i take that as

Is this patch series going to be resent?

Nevermind. Looking at it I think I can apply all the clk ones and we're good to go. If you can send a followup patch series to change the registration and provider APIs to be clk_hw instead of clk based I would appreciate it.

#29 lore raw

Hi Stephen,

Quoted 11 lines · Stephen Boyd

Quoting Stephen Boyd (2018-10-17 08:44:12)

Quoted 10 lines

Quoting Sricharan R (2018-09-20 06:03:31)

Quoted 8 lines · Craig
Quoted 2 lines

Yup, this patch seems to have fixed the higher frequencies from the quick test I did.

Thanks !!. Can i take that as

Quoted 8 lines
Quoted 2 lines

Is this patch series going to be resent?

Nevermind. Looking at it I think I can apply all the clk ones and we're good to go. If you can send a followup patch series to change the registration and provider APIs to be clk_hw instead of clk based I would appreciate it.

Sorry for the late response. Was away.
Only pending thing was separating out the binding documentation for the cpu-freq driver and fixing the text in documentation. That means, yes its fine to merge the clk ones as you said. I will resend that. Also, will send a follow up series for clk_hw to clk change as you mentioned separately.

Regards,
Sricharan

Signature · 1 line
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
#30 lore raw
Quoted 23 lines · Sricharan R

Hi Stephen,

Quoted 11 lines · Stephen Boyd

Quoting Stephen Boyd (2018-10-17 08:44:12)

Quoted 10 lines

Quoting Sricharan R (2018-09-20 06:03:31)

Quoted 8 lines · Craig
Quoted 2 lines

Yup, this patch seems to have fixed the higher frequencies from the quick test I did.

Thanks !!. Can i take that as

Quoted 8 lines
Quoted 2 lines

Is this patch series going to be resent?

Nevermind. Looking at it I think I can apply all the clk ones and we're good to go. If you can send a followup patch series to change the registration and provider APIs to be clk_hw instead of clk based I would appreciate it.

Quoted 5 lines

Sorry for the late response. Was away.
Only pending thing was separating out the binding documentation for the cpu-freq driver and fixing the text in documentation. That means, yes its fine to merge the clk ones as you said. I will resend that. Also, will send a follow up series for clk_hw to clk change as you mentioned separately.

Hello Sricharan,

Great to see that the clk parts has been marged to clk-next!

Are you also planning on sending out a new version of the cpufreq driver consolidation parts?

I'm planning on extending your consilidated cpufreq driver with support for msm8916 (Cortex-A53), where I plan to read PVS/speedbin, in order to set opp_supported_hw(), and also register with cpufreq (since Viresh/Ulf suggested that we shouldn't register with cpufreq in the CPR power-domain driver).

Kind regards,
Niklas

#31 lore raw

Hi Niklas,

Quoted 30 lines · Niklas Cassel
Quoted 23 lines · Sricharan R

Hi Stephen,

Quoted 11 lines · Stephen Boyd

Quoting Stephen Boyd (2018-10-17 08:44:12)

Quoted 10 lines

Quoting Sricharan R (2018-09-20 06:03:31)

Quoted 8 lines · Craig
Quoted 2 lines

Yup, this patch seems to have fixed the higher frequencies from the quick test I did.

Thanks !!. Can i take that as

Quoted 8 lines
Quoted 2 lines

Is this patch series going to be resent?

Nevermind. Looking at it I think I can apply all the clk ones and we're good to go. If you can send a followup patch series to change the registration and provider APIs to be clk_hw instead of clk based I would appreciate it.

Quoted 5 lines

Sorry for the late response. Was away.
Only pending thing was separating out the binding documentation for the cpu-freq driver and fixing the text in documentation. That means, yes its fine to merge the clk ones as you said. I will resend that. Also, will send a follow up series for clk_hw to clk change as you mentioned separately.

Quoted 7 lines

Hello Sricharan,

Great to see that the clk parts has been marged to clk-next!

Are you also planning on sending out a new version of the cpufreq driver consolidation parts?

yeah right, will send a new version, sometime next week.

Quoted 5 lines

I'm planning on extending your consilidated cpufreq driver with support for msm8916 (Cortex-A53), where I plan to read PVS/speedbin, in order to set opp_supported_hw(), and also register with cpufreq (since Viresh/Ulf suggested that we shouldn't register with cpufreq in the CPR power-domain driver).

ok sure.

Regards,
Sricharan

Signature · 1 line
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation