Skip to contentSkip to conversation

clk: hisilicon: support stub clock

PATCH Applied Leo Yan 3 participants 11 messages Aug 4, 2015 – Aug 12, 2015

Subsystems (3)
lore
Share & tools
lore

Leo Yan

author
#0 lore raw

v4 cover clk: hisilicon: support stub clock

This series adds support for hisilicon stub clock driver. On hi6220, the bootloader needs load the firmware image and set info for OPPs; after run into kernel, the stub clock driver is used to communicate w/t firmware for cpu dynamic frequency scaling.

In patch series v1/v2, the stub clock driver simply writes request in sram and send ipc to firmware; For patch series v3, the firmware has been upgraded to use mailbox, so stub clock driver will call standard mailbox APIs to request mailbox channel and send message to firmware.

Patch 4 adds stub clock node into dts and it references mailbox with phandle, so patch 4 will depend on mailbox driver's patch series [1]. These patches have been tested on 96board hikey and is used by cpufreq driver.

Changes from v3:
* Patch "clk: hisi: refine parameter checking for init" [2] has been applied to clk-next, so skip it in v4
* According to Stephen Boyd's review, fix and refine stub clock driver
* The stub clock driver depends on mailbox channel's initialization, so mailbox init firstly with core_initcall() and use subsys_initcall() for stub clock driver

Changes from v2:
* Use platform_device's probe for clock's initialization
* Use mailbox channel for clock frequency change

Changes from v1:
* Refine parameter checking for init flow
* Remove unnecessary debugging info
* Modify to check spinlock pointer when register clocks

[1] http://archive.arm.linux.org.uk/lurker/message/20150803.011307.1062b247.en.html
[2] http://archive.arm.linux.org.uk/lurker/message/20150803.011334.4b6f2fc7.en.html

Leo Yan (4):
dt-bindings: arm: Hi6220: add doc for SRAM controller
dt-bindings: clk: Hi6220: Document stub clock driver
clk: Hi6220: add stub clock driver
arm64: dts: add Hi6220's stub clock node

 .../bindings/arm/hisilicon/hisilicon.txt           |  18 ++
 .../devicetree/bindings/clock/hi6220-clock.txt     |  19 +-
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi          |  23 ++
 drivers/clk/hisilicon/Kconfig                      |   2 +-
 drivers/clk/hisilicon/Makefile                     |   2 +-
 drivers/clk/hisilicon/clk-hi6220-stub.c            | 276 +++++++++++++++++++++
 6 files changed, 337 insertions(+), 3 deletions(-)
 create mode 100644 drivers/clk/hisilicon/clk-hi6220-stub.c
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v4 1/4 dt-bindings: arm: Hi6220: add doc for SRAM controller

Document "hisilicon,hi6220-sramctrl" for SRAM controller.

---
 .../devicetree/bindings/arm/hisilicon/hisilicon.txt    | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt +18 -0
index c431c67..c733e28 100644
@@ -127,6 +127,24 @@ Example:
 		#clock-cells = <1>;
 	};
 
+
+Hisilicon Hi6220 SRAM controller
+
+Required properties:
+- compatible : "hisilicon,hi6220-sramctrl", "syscon"
+- reg : Register address and size
+
+Hisilicon's SoCs use sram for multiple purpose; on Hi6220 there have several
+SRAM banks for power management, modem, security, etc. Further, use "syscon"
+managing the common sram which can be shared by multiple modules.
+
+Example:
+	/*for Hi6220*/
+	sram: sram at fff80000 {
+		compatible = "hisilicon,hi6220-sramctrl", "syscon";
+		reg = <0x0 0xfff80000 0x0 0x12000>;
+	};
+
 -----------------------------------------------------------------------
 Hisilicon HiP01 system controller
 
Signature · 1 line
1.9.1
Applied
#2 lore raw

Re: [PATCH v4 1/4] dt-bindings: arm: Hi6220: add doc for SRAM controller

Quoted 4 lines · Leo Yan

Document "hisilicon,hi6220-sramctrl" for SRAM controller.

---

Applied to clk-next

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#3 lore raw

PATCH v4 2/4 dt-bindings: clk: Hi6220: Document stub clock driver

In reply to Leo Yan

Document the new compatible for stub clock driver which is used for CPU and DDR's dynamic frequency scaling.

---
 .../devicetree/bindings/clock/hi6220-clock.txt        | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/hi6220-clock.txt +18 -1
index 259e30a..e4d5fea 100644
@@ -15,19 +15,36 @@ Required Properties:
 	- "hisilicon,hi6220-sysctrl"
 	- "hisilicon,hi6220-mediactrl"
 	- "hisilicon,hi6220-pmctrl"
+	- "hisilicon,hi6220-stub-clk"
 
 - reg: physical base address of the controller and length of memory mapped
   region.
 
 - #clock-cells: should be 1.
 
-For example:
+Optional Properties:
+
+- hisilicon,hi6220-clk-sram: phandle to the syscon managing the SoC internal sram;
+  the driver need use the sram to pass parameters for frequency change.
+
+- mboxes: use the label reference for the mailbox as the first parameter, the
+  second parameter is the channel number.
+
+Example 1:
 	sys_ctrl: sys_ctrl at f7030000 {
 		compatible = "hisilicon,hi6220-sysctrl", "syscon";
 		reg = <0x0 0xf7030000 0x0 0x2000>;
 		#clock-cells = <1>;
 	};
 
+Example 2:
+	stub_clock: stub_clock {
+		compatible = "hisilicon,hi6220-stub-clk";
+		hisilicon,hi6220-clk-sram = <&sram>;
+		#clock-cells = <1>;
+		mboxes = <&mailbox 1>;
+	};
+
 Each clock is assigned an identifier and client nodes use this identifier
 to specify the clock which they consume.
 
Signature · 1 line
1.9.1
Applied
#4 lore raw

Re: [PATCH v4 2/4] dt-bindings: clk: Hi6220: Document stub clock driver

Quoted 5 lines · Leo Yan

Document the new compatible for stub clock driver which is used for CPU and DDR's dynamic frequency scaling.

---

Applied to clk-next

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#5 lore raw

PATCH v4 3/4 clk: Hi6220: add stub clock driver

In reply to Leo Yan

On Hi6220, there have some clocks which can use mailbox channel to send messages to power controller to change frequency; this includes CPU, GPU and DDR clocks.

For dynamic frequency scaling, firstly need write the frequency value to SRAM region, and then send message to mailbox to trigger power controller to handle this requirement. This driver will use syscon APIs to pass SRAM memory region and use common mailbox APIs for channels accessing.

This init driver will support cpu frequency change firstly.

---
 drivers/clk/hisilicon/Kconfig           |   2 +-
 drivers/clk/hisilicon/Makefile          |   2 +-
 drivers/clk/hisilicon/clk-hi6220-stub.c | 276 ++++++++++++++++++++++++++++++++
 3 files changed, 278 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/hisilicon/clk-hi6220-stub.c
drivers/clk/hisilicon/Kconfig +1 -1
index b4165ba..2c16807 100644
@@ -1,6 +1,6 @@
 config COMMON_CLK_HI6220
 	bool "Hi6220 Clock Driver"
-	depends on ARCH_HISI || COMPILE_TEST
+	depends on (ARCH_HISI || COMPILE_TEST) && MAILBOX
 	default ARCH_HISI
 	help
 	  Build the Hisilicon Hi6220 clock driver based on the common clock framework.
drivers/clk/hisilicon/Makefile +1 -1
index 48f0116..4a1001a 100644
@@ -7,4 +7,4 @@ obj-y	+= clk.o clkgate-separated.o clkdivider-hi6220.o
 obj-$(CONFIG_ARCH_HI3xxx)	+= clk-hi3620.o
 obj-$(CONFIG_ARCH_HIP04)	+= clk-hip04.o
 obj-$(CONFIG_ARCH_HIX5HD2)	+= clk-hix5hd2.o
-obj-$(CONFIG_COMMON_CLK_HI6220)	+= clk-hi6220.o
+obj-$(CONFIG_COMMON_CLK_HI6220)	+= clk-hi6220.o clk-hi6220-stub.o
drivers/clk/hisilicon/clk-hi6220-stub.c new file +276 -0

276 lines not on this page · raw message

Signature · 1 line
1.9.1
Applied
#6 lore raw

Re: [PATCH v4 3/4] clk: Hi6220: add stub clock driver

Quoted 9 lines · Leo Yan

On Hi6220, there have some clocks which can use mailbox channel to send messages to power controller to change frequency; this includes CPU, GPU and DDR clocks.

For dynamic frequency scaling, firstly need write the frequency value to SRAM region, and then send message to mailbox to trigger power controller to handle this requirement. This driver will use syscon APIs to pass SRAM memory region and use common mailbox APIs for channels accessing.

Quoted 4 lines

This init driver will support cpu frequency change firstly.

---

Applied to clk-next

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#7 lore raw

PATCH v4 4/4 arm64: dts: add Hi6220's stub clock node

In reply to Leo Yan

Enable SRAM node and stub clock node for Hi6220; furthermore add the CPU's clock so it will be used by cpufreq-dt driver.

---
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/arm64/boot/dts/hisilicon/hi6220.dtsi +23 -0
index b42a9b7..94b8310 100644
@@ -57,6 +57,17 @@
 			device_type = "cpu";
 			reg = <0x0 0x0>;
 			enable-method = "psci";
+			clocks = <&stub_clock 0>;
+			clock-latency = <0>;
+			operating-points = <
+				/* kHz */
+				1200000  0
+				960000   0
+				729000   0
+				432000   0
+				208000   0
+			>;
+			#cooling-cells = <2>; /* min followed by max */
 		};
 
 		cpu1: cpu at 1 {
@@ -136,6 +147,11 @@
 		#size-cells = <2>;
 		ranges;
 
+		sram: sram at fff80000 {
+			compatible = "hisilicon,hi6220-sramctrl", "syscon";
+			reg = <0x0 0xfff80000 0x0 0x12000>;
+		};
+
 		ao_ctrl: ao_ctrl at f7800000 {
 			compatible = "hisilicon,hi6220-aoctrl", "syscon";
 			reg = <0x0 0xf7800000 0x0 0x2000>;
@@ -160,6 +176,13 @@
 			#clock-cells = <1>;
 		};
 
+		stub_clock: stub_clock {
+			compatible = "hisilicon,hi6220-stub-clk";
+			hisilicon,hi6220-clk-sram = <&sram>;
+			#clock-cells = <1>;
+			mboxes = <&mailbox 1>;
+		};
+
 		uart0: uart at f8015000 {	/* console */
 			compatible = "arm,pl011", "arm,primecell";
 			reg = <0x0 0xf8015000 0x0 0x1000>;
Signature · 1 line
1.9.1
#8 lore raw
In reply to Leo Yan
Quoted 10 lines · Leo Yan

This series adds support for hisilicon stub clock driver. On hi6220, the bootloader needs load the firmware image and set info for OPPs; after run into kernel, the stub clock driver is used to communicate w/t firmware for cpu dynamic frequency scaling.

In patch series v1/v2, the stub clock driver simply writes request in sram and send ipc to firmware; For patch series v3, the firmware has been upgraded to use mailbox, so stub clock driver will call standard mailbox APIs to request mailbox channel and send message to firmware.

Quoted 4 lines

Patch 4 adds stub clock node into dts and it references mailbox with phandle, so patch 4 will depend on mailbox driver's patch series [1]. These patches have been tested on 96board hikey and is used by cpufreq driver.

The To: list is everyone, so I'm not sure who is supposed to apply these patches. I'd like to take patches 1, 2, and 3 through the clk tree though.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#9 lore raw

Hi Stephen,

Quoted 11 lines · Stephen Boyd
Quoted 10 lines · Leo Yan

This series adds support for hisilicon stub clock driver. On hi6220, the bootloader needs load the firmware image and set info for OPPs; after run into kernel, the stub clock driver is used to communicate w/t firmware for cpu dynamic frequency scaling.

In patch series v1/v2, the stub clock driver simply writes request in sram and send ipc to firmware; For patch series v3, the firmware has been upgraded to use mailbox, so stub clock driver will call standard mailbox APIs to request mailbox channel and send message to firmware.

Quoted 8 lines
Quoted 4 lines

Patch 4 adds stub clock node into dts and it references mailbox with phandle, so patch 4 will depend on mailbox driver's patch series [1]. These patches have been tested on 96board hikey and is used by cpufreq driver.

The To: list is everyone, so I'm not sure who is supposed to apply these patches. I'd like to take patches 1, 2, and 3 through the clk tree though.

Thanks, you could take first three patches. For patch 4, i will re-send it after mailbox driver's patches have been merged.

Wei Xu, is this okay for you?

Thanks,
Leo Yan

maintainer
#10 lore raw
Quoted 19 lines · Leo Yan

Hi Stephen,

Quoted 16 lines · Stephen Boyd
Quoted 14 lines · Leo Yan

This series adds support for hisilicon stub clock driver. On hi6220, the bootloader needs load the firmware image and set info for OPPs; after run into kernel, the stub clock driver is used to communicate w/t firmware for cpu dynamic frequency scaling.

In patch series v1/v2, the stub clock driver simply writes request in sram and send ipc to firmware; For patch series v3, the firmware has been upgraded to use mailbox, so stub clock driver will call standard mailbox APIs to request mailbox channel and send message to firmware.

Patch 4 adds stub clock node into dts and it references mailbox with phandle, so patch 4 will depend on mailbox driver's patch series [1]. These patches have been tested on 96board hikey and is used by cpufreq driver.

Quoted 6 lines
Quoted 3 lines

The To: list is everyone, so I'm not sure who is supposed to apply these patches. I'd like to take patches 1, 2, and 3 through the clk tree though.

Thanks, you could take first three patches. For patch 4, i will re-send it after mailbox driver's patches have been merged.

Hi Leo,

Quoted 1 line

Wei Xu, is this okay for you?

OK :)

Best Regards,
Wei

Quoted 6 lines

Thanks,
Leo Yan

.