Skip to contentSkip to conversation

arm64,hi6220: Enable Hisilicon Hi6220 SoC

PATCH Superseded Bintian Wang 6 participants 23 messages Apr 13, 2015 – Apr 21, 2015

Subsystems (5)

v2 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v2 cover arm64,hi6220: Enable Hisilicon Hi6220 SoC

Hi6220 is one mobile solution of Hisilicon, this patchset contains initial support for Hi6220 SoC and HiKey development board, which supports octal ARM Cortex A53 cores. Initial support is minimal and includes just the arch configuration, clock driver, device tree configuration.

PSCI is enabled in device tree and there is no problem to boot all the octal cores, but the CPU hotplug is still under development, you can download and compile the latest firmware based on the following link to run this patch set:
https://github.com/96boards/documentation/wiki/UEFI

Changes v2:
* Split the DT bindings documents into earlier patches
* Change SMP enable method from spin-table to PSCI in device tree
* Remove "clock-frequency" from armv8-timer device node in device tree
* Add more description about Hisilicon designed system controllers in DT bindings document
* Enable high speed clock on UART1 mux
* Other changes based on the discussion in the mailing list:
https://lkml.org/lkml/2015/2/5/147

Bintian Wang (6):
arm64: Enable Hisilicon ARMv8 SoC family in Kconfig and defconfig
arm64: hi6220: Document devicetree bindings for Hisilicon hi6220 SoC
clk: hi6220: Document devicetree bindings for hi6220 clock
clk: hi6220: Clock driver support for Hisilicon hi6220 SoC
arm64: Kconfig: Add clock support to ARCH_HISI
arm64: dts: Add dts files for Hisilicon Hi6220 SoC

 .../bindings/arm/hisilicon/hisilicon.txt           |  73 ++++++
 .../devicetree/bindings/clock/hi6220-clock.txt     |  34 +++
 arch/arm64/Kconfig                                 |   6 +
 arch/arm64/boot/dts/Makefile                       |   1 +
 arch/arm64/boot/dts/hisilicon/Makefile             |   5 +
 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts     |  28 ++
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi          | 171 ++++++++++++
 arch/arm64/configs/defconfig                       |   1 +
 drivers/clk/Kconfig                                |   2 +
 drivers/clk/Makefile                               |   4 +-
 drivers/clk/hisilicon/Kconfig                      |   5 +
 drivers/clk/hisilicon/Makefile                     |   3 +-
 drivers/clk/hisilicon/clk-hi6220.c                 | 292 +++++++++++++++++++++
 drivers/clk/hisilicon/clk.c                        |  29 ++
 drivers/clk/hisilicon/clk.h                        |  17 ++
 drivers/clk/hisilicon/clkdivider-hi6220.c          | 273 +++++++++++++++++++
 include/dt-bindings/clock/hi6220-clock.h           | 173 ++++++++++++
 17 files changed, 1113 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/hi6220-clock.txt
 create mode 100644 arch/arm64/boot/dts/hisilicon/Makefile
 create mode 100644 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
 create mode 100644 arch/arm64/boot/dts/hisilicon/hi6220.dtsi
 create mode 100644 drivers/clk/hisilicon/Kconfig
 create mode 100644 drivers/clk/hisilicon/clk-hi6220.c
 create mode 100644 drivers/clk/hisilicon/clkdivider-hi6220.c
 create mode 100644 include/dt-bindings/clock/hi6220-clock.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/6 arm64: Enable Hisilicon ARMv8 SoC family in Kconfig and defconfig

This patch introduces ARCH_HISI to enable Hisilicon SoC family in Kconfig and defconfig.

---
 arch/arm64/Kconfig           | 5 +++++
 arch/arm64/configs/defconfig | 1 +
 2 files changed, 6 insertions(+)
arch/arm64/Kconfig +5 -0
index 1b8e973..64d4d6d 100644
@@ -228,6 +228,11 @@ config ARCH_XGENE
 	help
 	  This enables support for AppliedMicro X-Gene SOC Family
 
+config ARCH_HISI
+	bool "Hisilicon SoC Family"
+	help
+	  This enables support for Hisilicon ARMv8 SoC family
+
 endmenu
 
 menu "Bus support"
arch/arm64/configs/defconfig +1 -0
index be1f12a..36ebd9b 100644
@@ -36,6 +36,7 @@ CONFIG_ARCH_MEDIATEK=y
 CONFIG_ARCH_THUNDER=y
 CONFIG_ARCH_VEXPRESS=y
 CONFIG_ARCH_XGENE=y
+CONFIG_ARCH_HISI=y
 CONFIG_PCI=y
 CONFIG_PCI_MSI=y
 CONFIG_PCI_XGENE=y
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v2 1/6] arm64: Enable Hisilicon ARMv8 SoC family in Kconfig and defconfig

Quoted 6 lines · Bintian Wang

This patch introduces ARCH_HISI to enable Hisilicon SoC family in Kconfig and defconfig.

[...]

arch/arm64/configs/defconfig CONFIG_ARCH_MEDIATEK=y · line 39

Quoted 9 lines
arch/arm64/configs/defconfig +1 -0
index be1f12a..36ebd9b 100644
@@ -36,6 +36,7 @@ CONFIG_ARCH_MEDIATEK=y
 CONFIG_ARCH_THUNDER=y
 CONFIG_ARCH_VEXPRESS=y
 CONFIG_ARCH_XGENE=y
+CONFIG_ARCH_HISI=y

nit: please keep CONFIG_ARCH_* sorted alphabetically.

Thanks,

Kevin

author
#3 lore raw

Re: [PATCH v2 1/6] arm64: Enable Hisilicon ARMv8 SoC family in Kconfig and defconfig

Hello Kevin,

Quoted 11 lines · Kevin Hilman
Quoted 6 lines · Bintian Wang

This patch introduces ARCH_HISI to enable Hisilicon SoC family in Kconfig and defconfig.

[...]

Quoted 11 lines

arch/arm64/configs/defconfig CONFIG_ARCH_MEDIATEK=y · line 39

Quoted 9 lines
arch/arm64/configs/defconfig +1 -0
index be1f12a..36ebd9b 100644
@@ -36,6 +36,7 @@ CONFIG_ARCH_MEDIATEK=y
  CONFIG_ARCH_THUNDER=y
  CONFIG_ARCH_VEXPRESS=y
  CONFIG_ARCH_XGENE=y
+CONFIG_ARCH_HISI=y

nit: please keep CONFIG_ARCH_* sorted alphabetically.

Will fix in next version, thanks for helping review.

BR,

Bintian

Quoted 7 lines

Thanks,

Kevin

.

#4 lore raw

PATCH v2 2/6 arm64: hi6220: Document devicetree bindings for Hisilicon hi6220 SoC

In reply to Bintian Wang

This patch adds documentation for the devicetree bindings used by the DT files of Hisilicon hi6220 SoC mobile platform.

---
 .../bindings/arm/hisilicon/hisilicon.txt           | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)
Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt +73 -0
index 35b1bd4..66ad65d 100644
@@ -13,6 +13,9 @@ HiP01 ca9x2 Board
 Required root node properties:
 	- compatible = "hisilicon,hip01-ca9x2";
 
+HiKey Board
+Required root node properties:
+	- compatible = "hisilicon,hi6220-hikey";
 
 Hisilicon system controller
 
@@ -29,6 +32,10 @@ Optional properties:
 - resume-offset : offset in sysctrl for notifying cpu0 when resume
 - reboot-offset : offset in sysctrl for system reboot
 
+For some SoCs(e.g. Hi6220), many clock registers are defined under this
+controller, so "#clock-cells" is a required property for these SoCs and
+it should be set to 1.
+
 Example:
 
 	/* for Hi3620 */
@@ -40,6 +47,72 @@ Example:
 		reboot-offset = <0x4>;
 	};
 
+
+Hisilicon Power Always ON domain controller
+
+Hisilicon designs this system controller to control the power always
+on domain for mobile platform.
+
+Required properties:
+- compatible : "hisilicon,aoctrl"
+- reg : Register address and size
+
+For some SoCs(e.g. Hi6220), many clock registers are defined under this
+controller, so "#clock-cells" is a required property for these SoCs and
+it should be set to 1.
+
+Example:
+	/*for Hi6220*/
+	ao_ctrl: ao_ctrl {
+		compatible = "hisilicon,aoctrl", "syscon";
+		reg = <0x0 0xf7800000 0x0 0x2000>;
+		#clock-cells = <1>;
+	};
+
+
+Hisilicon Media domain controller
+
+Hisilicon designs this system controller to control the multimedia
+domain(e.g. codec, G3D ...) for mobile platform.
+
+Required properties:
+- compatible : "hisilicon,mediactrl"
+- reg : Register address and size
+
+For some SoCs(e.g. Hi6220), many clock registers are defined under this
+controller, so "#clock-cells" is a required property for these SoCs and
+it should be set to 1.
+
+Example:
+	/*for Hi6220*/
+	media_ctrl: media_ctrl {
+		compatible = "hisilicon,mediactrl", "syscon";
+		reg = <0x0 0xf4410000 0x0 0x1000>;
+		#clock-cells = <1>;
+	};
+
+
+Hisilicon Power Management domain controller
+
+Hisilicon designs this system controller to control the power management
+domain for mobile platform.
+
+Required properties:
+- compatible : "hisilicon,pmctrl"
+- reg : Register address and size
+
+For some SoCs (e.g. Hi6220), many clock registers are defined under this
+controller, so "#clock-cells" is a required property for these SoCs and
+it should be set to 1.
+
+Example:
+	/*for Hi6220*/
+	pm_ctrl: pm_ctrl {
+		compatible = "hisilicon,pmctrl", "syscon";
+		reg = <0x0 0xf7032000 0x0 0x1000>;
+		#clock-cells = <1>;
+	};
+
 -----------------------------------------------------------------------
 Hisilicon HiP01 system controller
 
Signature · 1 line
1.9.1
#5 lore raw

PATCH v2 3/6 clk: hi6220: Document devicetree bindings for hi6220 clock

In reply to Bintian Wang

Document DT files bindings for Hisilicon hi6220 clock.

---
 .../devicetree/bindings/clock/hi6220-clock.txt     | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/hi6220-clock.txt
Documentation/devicetree/bindings/clock/hi6220-clock.txt new file +34 -0
new file mode 100644
index 0000000..83cc7c7
@@ -0,0 +1,34 @@
+* Hisilicon Hi6220 Clock Controller
+
+Clock control registers reside in different Hi6220 system controllers,
+please refer the following document to know more about the binding rules
+for these system controllers:
+
+Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
+
+Required Properties:
+
+- compatible: the compatible should be one of the following strings to
+	indicate the clock controller functionality.
+
+	- "hisilicon,aoctrl"
+	- "hisilicon,sysctrl"
+	- "hisilicon,mediactrl"
+	- "hisilicon,pmctrl"
+
+- reg: physical base address of the controller and length of memory mapped
+  region.
+
+- #clock-cells: should be 1.
+
+For example:
+	sys_ctrl: sys_ctrl {
+		compatible = "hisilicon,sysctrl", "syscon";
+		reg = <0x0 0xf7030000 0x0 0x2000>;
+		#clock-cells = <1>;
+	};
+
+Each clock is assigned an identifier and client nodes use this identifier
+to specify the clock which they consume.
+
+All these identifier could be found in <dt-bindings/clock/hi6220-clock.h>.
Signature · 1 line
1.9.1
maintainer
#6 lore raw

Re: [PATCH v2 3/6] clk: hi6220: Document devicetree bindings for hi6220 clock

Documentation/devicetree/bindings/clock/hi6220-clock.txt line 18

Quoted 9 lines · On Monday 13 April 2015 17:17:37 Bintian Wang wrote:

+- compatible: the compatible should be one of the following strings to

Documentation/devicetree/bindings/clock/hi6220-clock.txt new file +7 -0
+       indicate the clock controller functionality.
+
+       - "hisilicon,aoctrl"
+       - "hisilicon,sysctrl"
+       - "hisilicon,mediactrl"
+       - "hisilicon,pmctrl"
+

These ones already have bindings, you can't reuse the strings. Please work with someone in hisilicon to set up a registry of device names so you can avoid conflicts in the future.

Arnd

author
#7 lore raw

Re: [PATCH v2 3/6] clk: hi6220: Document devicetree bindings for hi6220 clock

Hello Arnd,

Quoted 14 lines · Arnd Bergmann

Documentation/devicetree/bindings/clock/hi6220-clock.txt line 18

Quoted 9 lines · On Monday 13 April 2015 17:17:37 Bintian Wang wrote:

+- compatible: the compatible should be one of the following strings to

Documentation/devicetree/bindings/clock/hi6220-clock.txt new file +7 -0
+       indicate the clock controller functionality.
+
+       - "hisilicon,aoctrl"
+       - "hisilicon,sysctrl"
+       - "hisilicon,mediactrl"
+       - "hisilicon,pmctrl"
+

These ones already have bindings, you can't reuse the strings. Please work with someone in hisilicon to set up a registry of device names so you can avoid conflicts in the future.

All the clock registers are under above four system controllers, discussed with Mark and Haojian two months ago, I think using above same four binding strings is enough for clk module.
On second thoughts, there really some problems for future hisilicon code upstream, how about change back to the first version of this patch set, just like following:
+ sys_ctrl: sys_ctrl {
+ compatible = "hisilicon,sysctrl", "syscon";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ reg = <0x0 0xf7030000 0x0 0x2000>;
+ ranges = <0 0x0 0xf7030000 0x2000>;
+
+ clock_sys: clock1 at 0 {
+ compatible = "hisilicon,hi6220-clock-sys";
+ reg = <0 0x1000>;
+ #clock-cells = <1>;
+ };
+ };

Thanks,

Bintian

Quoted 5 lines

Arnd

.

maintainer
#8 lore raw

Re: [PATCH v2 3/6] clk: hi6220: Document devicetree bindings for hi6220 clock

Quoted 26 lines · On Tuesday 14 April 2015 11:35:26 Bintian wrote:

Hello Arnd,

Quoted 14 lines · Arnd Bergmann

Documentation/devicetree/bindings/clock/hi6220-clock.txt line 18

Quoted 9 lines · On Monday 13 April 2015 17:17:37 Bintian Wang wrote:

+- compatible: the compatible should be one of the following strings to

Documentation/devicetree/bindings/clock/hi6220-clock.txt new file +7 -0
+       indicate the clock controller functionality.
+
+       - "hisilicon,aoctrl"
+       - "hisilicon,sysctrl"
+       - "hisilicon,mediactrl"
+       - "hisilicon,pmctrl"
+

These ones already have bindings, you can't reuse the strings. Please work with someone in hisilicon to set up a registry of device names so you can avoid conflicts in the future.

All the clock registers are under above four system controllers, discussed with Mark and Haojian two months ago, I think using above same four binding strings is enough for clk module.
On second thoughts, there really some problems for future hisilicon code upstream, how about change back to the first version of this patch set, just like following:

(quoted diff) +3 -0
+		sys_ctrl: sys_ctrl {
+			compatible = "hisilicon,sysctrl", "syscon";
+			#address-cells = <1>;

Review

Quoted 10 lines
(quoted diff) +10 -0
+			#size-cells = <1>;
+			reg = <0x0 0xf7030000 0x0 0x2000>;
+			ranges = <0 0x0 0xf7030000 0x2000>;
+
+			clock_sys: clock1 at 0 {
+				compatible = "hisilicon,hi6220-clock-sys";
+				reg = <0 0x1000>;
+				#clock-cells = <1>;
+			};
+		};

Sub-nodes are fine, but you also can't have a device node that is just 'compatible = "hisilicon,sysctrl", "syscon";' when hisilicon,sysctrl can refer to multiple mutually incompatible controllers.

The minimum fix would be to mandate the string to be compatible = "hisilicon,hi6220-sysctrl", "hisilicon,sysctrl", "syscon"; for this model, and use respective compatible strings for the other chips.

For the documentation, I think it would make sense to move that description to "hisilicon,sysctrl" and list all the variants of that component and the respective compatible strings there, rather than have one document per chip and list multiple components in it.

Arnd

author
#9 lore raw

Re: [PATCH v2 3/6] clk: hi6220: Document devicetree bindings for hi6220 clock

Hello Arnd,

Quoted 43 lines · Arnd Bergmann
Quoted 26 lines · On Tuesday 14 April 2015 11:35:26 Bintian wrote:

Hello Arnd,

Quoted 14 lines · Arnd Bergmann

Documentation/devicetree/bindings/clock/hi6220-clock.txt line 18

Quoted 9 lines · On Monday 13 April 2015 17:17:37 Bintian Wang wrote:

+- compatible: the compatible should be one of the following strings to

Documentation/devicetree/bindings/clock/hi6220-clock.txt new file +7 -0
+       indicate the clock controller functionality.
+
+       - "hisilicon,aoctrl"
+       - "hisilicon,sysctrl"
+       - "hisilicon,mediactrl"
+       - "hisilicon,pmctrl"
+

These ones already have bindings, you can't reuse the strings. Please work with someone in hisilicon to set up a registry of device names so you can avoid conflicts in the future.

All the clock registers are under above four system controllers, discussed with Mark and Haojian two months ago, I think using above same four binding strings is enough for clk module.
On second thoughts, there really some problems for future hisilicon code upstream, how about change back to the first version of this patch set, just like following:

(quoted diff) +3 -0
+		sys_ctrl: sys_ctrl {
+			compatible = "hisilicon,sysctrl", "syscon";
+			#address-cells = <1>;

Review

Quoted 10 lines
(quoted diff) +10 -0
+			#size-cells = <1>;
+			reg = <0x0 0xf7030000 0x0 0x2000>;
+			ranges = <0 0x0 0xf7030000 0x2000>;
+
+			clock_sys: clock1 at 0 {
+				compatible = "hisilicon,hi6220-clock-sys";
+				reg = <0 0x1000>;
+				#clock-cells = <1>;
+			};
+		};

Sub-nodes are fine, but you also can't have a device node that is just 'compatible = "hisilicon,sysctrl", "syscon";' when hisilicon,sysctrl can refer to multiple mutually incompatible controllers.

Quoted 4 lines

The minimum fix would be to mandate the string to be compatible = "hisilicon,hi6220-sysctrl", "hisilicon,sysctrl", "syscon"; for this model, and use respective compatible strings for the other chips.

It's really a smart fix!

For the four system controllers, how about change the following strings:

+       - "hisilicon,aoctrl"
+       - "hisilicon,sysctrl"
+       - "hisilicon,mediactrl"
+       - "hisilicon,pmctrl"

to

+       - "hisilicon,hi6220-aoctrl"
+       - "hisilicon,hi6220-sysctrl"
+       - "hisilicon,hi6220-mediactrl"
+       - "hisilicon,hi6220-pmctrl"

?

and I also use "hisilicon,hi6220-xxxx" for hi6220 clk driver directly ?

Quoted 5 lines

For the documentation, I think it would make sense to move that description to "hisilicon,sysctrl" and list all the variants of that component and the respective compatible strings there, rather than have one document per chip and list multiple components in it.

Sure,

Thanks,

Bintian

Quoted 5 lines

Arnd

.

maintainer
#10 lore raw

Re: [PATCH v2 3/6] clk: hi6220: Document devicetree bindings for hi6220 clock

Review

Quoted 13 lines · On Tuesday 14 April 2015 20:37:11 Bintian wrote:

It's really a smart fix!

For the four system controllers, how about change the following strings:

Documentation/devicetree/bindings/clock/hi6220-clock.txt new file +4 -0
+       - "hisilicon,aoctrl"
+       - "hisilicon,sysctrl"
+       - "hisilicon,mediactrl"
+       - "hisilicon,pmctrl"

to

(quoted diff) +4 -0
+       - "hisilicon,hi6220-aoctrl"
+       - "hisilicon,hi6220-sysctrl"
+       - "hisilicon,hi6220-mediactrl"
+       - "hisilicon,hi6220-pmctrl"

Yes, that works.

Quoted 1 line

and I also use "hisilicon,hi6220-xxxx" for hi6220 clk driver directly ?

Seems fine to me, though I'd have to look at the bigger picture to see any potential problems. At the moment, I don't see any.

Arnd

#11 lore raw

Re: [PATCH v2 3/6] clk: hi6220: Document devicetree bindings for hi6220 clock

Hello Arnd,

2015-04-14 21:20 GMT+08:00 Arnd Bergmann <[email protected]>:

Quoted 9 lines · On Tuesday 14 April 2015 20:37:11 Bintian wrote:
Quoted 8 lines

It's really a smart fix!

For the four system controllers, how about change the following strings:

Documentation/devicetree/bindings/clock/hi6220-clock.txt new file +4 -0
+       - "hisilicon,aoctrl"
+       - "hisilicon,sysctrl"
+       - "hisilicon,mediactrl"
+       - "hisilicon,pmctrl"
Quoted 7 lines

Review

Quoted 5 lines

to

(quoted diff) +4 -0
+       - "hisilicon,hi6220-aoctrl"
+       - "hisilicon,hi6220-sysctrl"
+       - "hisilicon,hi6220-mediactrl"
+       - "hisilicon,hi6220-pmctrl"

Yes, that works.

Thanks, will fix in next version.

Quoted 5 lines
Quoted 2 lines

and I also use "hisilicon,hi6220-xxxx" for hi6220 clk driver directly ?

Seems fine to me, though I'd have to look at the bigger picture to see any potential problems. At the moment, I don't see any.

Sure, please also help to review the 6/6 patch of this patch set, many thanks!

BR,

Bintian

Quoted 7 lines

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#12 lore raw

PATCH v2 4/6 clk: hi6220: Clock driver support for Hisilicon hi6220 SoC

In reply to Bintian Wang

Add clock drivers for hi6220 SoC, this driver controls the SoC registers to supply different clocks to different IPs in the SoC.

We add one divider clock for hi6220 because the divider in hi6220 also has a mask bit but it doesnot obey the rule defined by flag "CLK_DIVIDER_HIWORD_MASK", we can not get index of the mask bit by left shift fixed bits (e.g. 16 bits), so we add this divider clock to handle it.

---
 drivers/clk/Kconfig                       |   2 +
 drivers/clk/Makefile                      |   4 +-
 drivers/clk/hisilicon/Kconfig             |   5 +
 drivers/clk/hisilicon/Makefile            |   3 +-
 drivers/clk/hisilicon/clk-hi6220.c        | 292 ++++++++++++++++++++++++++++++
 drivers/clk/hisilicon/clk.c               |  29 +++
 drivers/clk/hisilicon/clk.h               |  17 ++
 drivers/clk/hisilicon/clkdivider-hi6220.c | 273 ++++++++++++++++++++++++++++
 include/dt-bindings/clock/hi6220-clock.h  | 173 ++++++++++++++++++
 9 files changed, 794 insertions(+), 4 deletions(-)
 create mode 100644 drivers/clk/hisilicon/Kconfig
 create mode 100644 drivers/clk/hisilicon/clk-hi6220.c
 create mode 100644 drivers/clk/hisilicon/clkdivider-hi6220.c
 create mode 100644 include/dt-bindings/clock/hi6220-clock.h
drivers/clk/Kconfig +2 -0
index 0b474a0..415fc31 100644
@@ -145,6 +145,8 @@ config COMMON_CLK_CDCE706
 
 source "drivers/clk/qcom/Kconfig"
 
+source "drivers/clk/hisilicon/Kconfig"
+
 endmenu
 
 source "drivers/clk/bcm/Kconfig"
drivers/clk/Makefile +1 -3
index d478ceb..45fa028 100644
@@ -45,9 +45,7 @@ obj-$(CONFIG_COMMON_CLK_XGENE)		+= clk-xgene.o
 obj-$(CONFIG_COMMON_CLK_AT91)		+= at91/
 obj-$(CONFIG_ARCH_BCM_MOBILE)		+= bcm/
 obj-$(CONFIG_ARCH_BERLIN)		+= berlin/
-obj-$(CONFIG_ARCH_HI3xxx)		+= hisilicon/
-obj-$(CONFIG_ARCH_HIP04)		+= hisilicon/
-obj-$(CONFIG_ARCH_HIX5HD2)		+= hisilicon/
+obj-$(CONFIG_ARCH_HISI)			+= hisilicon/
 obj-$(CONFIG_COMMON_CLK_KEYSTONE)	+= keystone/
 ifeq ($(CONFIG_COMMON_CLK), y)
 obj-$(CONFIG_ARCH_MMP)			+= mmp/
drivers/clk/hisilicon/Kconfig new file +5 -0
new file mode 100644
index 0000000..e3ead46
@@ -0,0 +1,5 @@
+config COMMON_CLK_HI6220
+	tristate "Hi6220 Clock Driver"
+	depends on OF && ARCH_HISI
+	help
+	  Build the Hisilicon Hi6220 clock driver based on the common clock framework.
drivers/clk/hisilicon/Makefile +2 -1
index 038c02f..48f0116 100644
@@ -2,8 +2,9 @@
 # Hisilicon Clock specific Makefile
 #
 
-obj-y	+= clk.o clkgate-separated.o
+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
drivers/clk/hisilicon/clk-hi6220.c new file +292 -0

292 lines not on this page · raw message

drivers/clk/hisilicon/clk.c +29 -0
index a078e84..5d2305c 100644
@@ -232,3 +232,32 @@ void __init hisi_clk_register_gate_sep(struct hisi_gate_clock *clks,
 		data->clk_data.clks[clks[i].id] = clk;
 	}
 }
+
+void __init hi6220_clk_register_divider(struct hi6220_divider_clock *clks,
+					  int nums, struct hisi_clock_data *data)
+{
+	struct clk *clk;
+	void __iomem *base = data->base;
+	int i;
+
+	for (i = 0; i < nums; i++) {
+		clk = hi6220_register_clkdiv(NULL, clks[i].name,
+						clks[i].parent_name,
+						clks[i].flags,
+						base + clks[i].offset,
+						clks[i].shift,
+						clks[i].width,
+						clks[i].mask_bit,
+						&hisi_clk_lock);
+		if (IS_ERR(clk)) {
+			pr_err("%s: failed to register clock %s\n",
+			       __func__, clks[i].name);
+			continue;
+		}
+
+		if (clks[i].alias)
+			clk_register_clkdev(clk, clks[i].alias, NULL);
+
+		data->clk_data.clks[clks[i].id] = clk;
+	}
+}
drivers/clk/hisilicon/clk.h +17 -0
index 31083ff..462a570 100644
@@ -79,6 +79,18 @@ struct hisi_divider_clock {
 	const char		*alias;
 };
 
+struct hi6220_divider_clock {
+	unsigned int		id;
+	const char		*name;
+	const char		*parent_name;
+	unsigned long		flags;
+	unsigned long		offset;
+	u8			shift;
+	u8			width;
+	u32			mask_bit;
+	const char		*alias;
+};
+
 struct hisi_gate_clock {
 	unsigned int		id;
 	const char		*name;
@@ -94,6 +106,9 @@ struct clk *hisi_register_clkgate_sep(struct device *, const char *,
 				const char *, unsigned long,
 				void __iomem *, u8,
 				u8, spinlock_t *);
+struct clk *hi6220_register_clkdiv(struct device *dev, const char *name,
+	const char *parent_name, unsigned long flags, void __iomem *reg,
+	u8 shift, u8 width, u32 mask_bit, spinlock_t *lock);
 
 struct hisi_clock_data __init *hisi_clk_init(struct device_node *, int);
 void __init hisi_clk_register_fixed_rate(struct hisi_fixed_rate_clock *,
@@ -108,4 +123,6 @@ void __init hisi_clk_register_gate(struct hisi_gate_clock *,
 					int, struct hisi_clock_data *);
 void __init hisi_clk_register_gate_sep(struct hisi_gate_clock *,
 					int, struct hisi_clock_data *);
+void __init hi6220_clk_register_divider(struct hi6220_divider_clock *,
+					int, struct hisi_clock_data *);
 #endif	/* __HISI_CLK_H */
drivers/clk/hisilicon/clkdivider-hi6220.c new file +273 -0

273 lines not on this page · raw message

include/dt-bindings/clock/hi6220-clock.h new file +173 -0

173 lines not on this page · raw message

Signature · 1 line
1.9.1
#13 lore raw

Re: [PATCH v2 4/6] clk: hi6220: Clock driver support for Hisilicon hi6220 SoC

drivers/clk/hisilicon/Kconfig line 5

Quoted 8 lines · Bintian Wang
drivers/clk/hisilicon/Kconfig new file +5 -0
@@ -0,0 +1,5 @@
+config COMMON_CLK_HI6220
+	tristate "Hi6220 Clock Driver"
+	depends on OF && ARCH_HISI
+	help
+	  Build the Hisilicon Hi6220 clock driver based on the common clock framework.

In 5/6 you make arm64's ARCH_HISI (a bool) select COMMON_CLK_HI6220. So for arm64 this driver will always be built-in.

For arm's ARCH_HISI it's possible to set COMMON_CLK_HI6220 to 'm'.

drivers/clk/hisilicon/Makefile line 5

Quoted 8 lines
drivers/clk/hisilicon/Makefile +1 -1
@@ -2,8 +2,9 @@
 # Hisilicon Clock specific Makefile
 #
 
-obj-y	+= clk.o clkgate-separated.o
+obj-y	+= clk.o clkgate-separated.o clkdivider-hi6220.o

These objects will always be built-in, right?

drivers/clk/hisilicon/Makefile line 10

Quoted 4 lines
drivers/clk/hisilicon/Makefile +1 -0
 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

If CONFIG_COMMON_CLK_HI6220 is 'm' this will build a module named clk-hi6220.ko. If I try to do that I get:

    $ make -C ../../.. ARCH=arm CROSS_COMPILE=arm-linux-gnu- M=$PWD clk-hi6220.ko
    make: Entering directory `[...]'
      CC [M]  [...]/drivers/clk/hisilicon/clk-hi6220.o
      MODPOST 1 modules
    WARNING: "hisi_clk_register_gate" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
    WARNING: "hi6220_clk_register_divider" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
    WARNING: "hisi_clk_register_mux" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
    WARNING: "hisi_clk_register_gate_sep" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
    WARNING: "hisi_clk_register_fixed_factor" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
    WARNING: "hisi_clk_register_fixed_rate" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
    WARNING: "hisi_clk_init" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
      CC      [...]/drivers/clk/hisilicon/clk-hi6220.mod.o
      LDFINAL [M]  [...]/drivers/clk/hisilicon/clk-hi6220.ko
    make: Leaving directory `[...]'

That is, I think, because nothing exports these symbols.

Quoted 285 lines
drivers/clk/hisilicon/clk-hi6220.c new file +282 -0
@@ -0,0 +1,292 @@
+/*
+ * Hisilicon Hi6220 clock driver
+ *
+ * Copyright (c) 2015 Hisilicon Limited.
+ *
+ * Author: Bintian Wang <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/slab.h>
+#include <linux/clk.h>
+
+#include <dt-bindings/clock/hi6220-clock.h>
+
+#include "clk.h"
+
+
+/* clocks in AO (always on) controller */
+static struct hisi_fixed_rate_clock hi6220_fixed_rate_clks[] __initdata = {
+	{ HI6220_REF32K,	"ref32k",	NULL, CLK_IS_ROOT, 32764,     },
+	{ HI6220_CLK_TCXO,	"clk_tcxo",	NULL, CLK_IS_ROOT, 19200000,  },
+	{ HI6220_MMC1_PAD,	"mmc1_pad",	NULL, CLK_IS_ROOT, 100000000, },
+	{ HI6220_MMC2_PAD,	"mmc2_pad",	NULL, CLK_IS_ROOT, 100000000, },
+	{ HI6220_MMC0_PAD,	"mmc0_pad",	NULL, CLK_IS_ROOT, 200000000, },
+	{ HI6220_PLL_BBP,	"bbppll0",	NULL, CLK_IS_ROOT, 245760000, },
+	{ HI6220_PLL_GPU,	"gpupll",	NULL, CLK_IS_ROOT, 1000000000,},
+	{ HI6220_PLL1_DDR,	"ddrpll1",	NULL, CLK_IS_ROOT, 1066000000,},
+	{ HI6220_PLL_SYS,	"syspll",	NULL, CLK_IS_ROOT, 1200000000,},
+	{ HI6220_PLL_SYS_MEDIA,	"media_syspll",	NULL, CLK_IS_ROOT, 1200000000,},
+	{ HI6220_DDR_SRC,	"ddr_sel_src",  NULL, CLK_IS_ROOT, 1200000000,},
+	{ HI6220_PLL_MEDIA,	"media_pll",    NULL, CLK_IS_ROOT, 1440000000,},
+	{ HI6220_PLL_DDR,	"ddrpll0",      NULL, CLK_IS_ROOT, 1600000000,},
+};
+
+static struct hisi_fixed_factor_clock hi6220_fixed_factor_clks[] __initdata = {
+	{ HI6220_300M,         "clk_300m",    "syspll",          1, 4, 0, },
+	{ HI6220_150M,         "clk_150m",    "clk_300m",        1, 2, 0, },
+	{ HI6220_PICOPHY_SRC,  "picophy_src", "clk_150m",        1, 4, 0, },
+	{ HI6220_MMC0_SRC_SEL, "mmc0srcsel",  "mmc0_sel",        1, 8, 0, },
+	{ HI6220_MMC1_SRC_SEL, "mmc1srcsel",  "mmc1_sel",        1, 8, 0, },
+	{ HI6220_MMC2_SRC_SEL, "mmc2srcsel",  "mmc2_sel",        1, 8, 0, },
+	{ HI6220_VPU_CODEC,    "vpucodec",    "codec_jpeg_aclk", 1, 2, 0, },
+	{ HI6220_MMC0_SMP,     "mmc0_sample", "mmc0_sel",        1, 8, 0, },
+	{ HI6220_MMC1_SMP,     "mmc1_sample", "mmc1_sel",        1, 8, 0, },
+	{ HI6220_MMC2_SMP,     "mmc2_sample", "mmc2_sel",        1, 8, 0, },
+};
+
+static struct hisi_gate_clock hi6220_separated_gate_clks_ao[] __initdata = {
+	{ HI6220_WDT0_PCLK,   "wdt0_pclk",   "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 12, 0, },
+	{ HI6220_WDT1_PCLK,   "wdt1_pclk",   "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 13, 0, },
+	{ HI6220_WDT2_PCLK,   "wdt2_pclk",   "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 14, 0, },
+	{ HI6220_TIMER0_PCLK, "timer0_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 15, 0, },
+	{ HI6220_TIMER1_PCLK, "timer1_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 16, 0, },
+	{ HI6220_TIMER2_PCLK, "timer2_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 17, 0, },
+	{ HI6220_TIMER3_PCLK, "timer3_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 18, 0, },
+	{ HI6220_TIMER4_PCLK, "timer4_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 19, 0, },
+	{ HI6220_TIMER5_PCLK, "timer5_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 20, 0, },
+	{ HI6220_TIMER6_PCLK, "timer6_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 21, 0, },
+	{ HI6220_TIMER7_PCLK, "timer7_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 22, 0, },
+	{ HI6220_TIMER8_PCLK, "timer8_pclk", "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 23, 0, },
+	{ HI6220_UART0_PCLK,  "uart0_pclk",  "clk_tcxo", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x630, 24, 0, },
+};
+
+static struct hisi_clock_data *clk_data_ao;
+
+static void __init hi6220_clk_ao_init(struct device_node *np)
+{
+	clk_data_ao = hisi_clk_init(np, HI6220_AO_NR_CLKS);
+	if (!clk_data_ao)
+		return;
+
+	hisi_clk_register_fixed_rate(hi6220_fixed_rate_clks,
+				ARRAY_SIZE(hi6220_fixed_rate_clks), clk_data_ao);
+
+	hisi_clk_register_fixed_factor(hi6220_fixed_factor_clks,
+				ARRAY_SIZE(hi6220_fixed_factor_clks), clk_data_ao);
+
+	hisi_clk_register_gate_sep(hi6220_separated_gate_clks_ao,
+				ARRAY_SIZE(hi6220_separated_gate_clks_ao), clk_data_ao);
+}
+CLK_OF_DECLARE(hi6220_clk_ao, "hisilicon,aoctrl", hi6220_clk_ao_init);
+
+
+/* clocks in sysctrl */
+static const char *mmc0_mux0_p[] __initconst = { "pll_ddr_gate", "syspll", };
+static const char *mmc0_mux1_p[] __initconst = { "mmc0_mux0", "pll_media_gate", };
+static const char *mmc0_src_p[] __initconst = { "mmc0srcsel", "mmc0_div", };
+static const char *mmc1_mux0_p[] __initconst = { "pll_ddr_gate", "syspll", };
+static const char *mmc1_mux1_p[] __initconst = { "mmc1_mux0", "pll_media_gate", };
+static const char *mmc1_src_p[]  __initconst = { "mmc1srcsel", "mmc1_div", };
+static const char *mmc2_mux0_p[] __initconst = { "pll_ddr_gate", "syspll", };
+static const char *mmc2_mux1_p[] __initconst = { "mmc2_mux0", "pll_media_gate", };
+static const char *mmc2_src_p[]  __initconst = { "mmc2srcsel", "mmc2_div", };
+static const char *mmc0_sample_in[] __initconst = { "mmc0_sample", "mmc0_pad", };
+static const char *mmc1_sample_in[] __initconst = { "mmc1_sample", "mmc1_pad", };
+static const char *mmc2_sample_in[] __initconst = { "mmc2_sample", "mmc2_pad", };
+static const char *uart1_src[] __initconst = { "clk_tcxo", "clk_150m", };
+static const char *uart2_src[] __initconst = { "clk_tcxo", "clk_150m", };
+static const char *uart3_src[] __initconst = { "clk_tcxo", "clk_150m", };
+static const char *uart4_src[] __initconst = { "clk_tcxo", "clk_150m", };
+static const char *hifi_src[] __initconst = { "syspll", "pll_media_gate", };
+
+static struct hisi_gate_clock hi6220_separated_gate_clks_sys[] __initdata = {
+	{ HI6220_MMC0_CLK,      "mmc0_clk",      "mmc0_src",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 0,  0, },
+	{ HI6220_MMC0_CIUCLK,   "mmc0_ciuclk",   "mmc0_smp_in",    CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 0,  0, },
+	{ HI6220_MMC1_CLK,      "mmc1_clk",      "mmc1_src",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 1,  0, },
+	{ HI6220_MMC1_CIUCLK,   "mmc1_ciuclk",   "mmc1_smp_in",    CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 1,  0, },
+	{ HI6220_MMC2_CLK,      "mmc2_clk",      "mmc2_src",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 2,  0, },
+	{ HI6220_MMC2_CIUCLK,   "mmc2_ciuclk",   "mmc2_smp_in",    CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 2,  0, },
+	{ HI6220_USBOTG_HCLK,   "usbotg_hclk",   "clk_bus",        CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 4,  0, },
+	{ HI6220_CLK_PICOPHY,   "clk_picophy",   "cs_dapb",        CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x200, 5,  0, },
+	{ HI6220_HIFI,          "hifi_clk",      "hifi_div",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x210, 0,  0, },
+	{ HI6220_DACODEC_PCLK,  "dacodec_pclk",  "clk_bus",        CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x210, 5,  0, },
+	{ HI6220_EDMAC_ACLK,    "edmac_aclk",    "clk_bus",        CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x220, 2,  0, },
+	{ HI6220_CS_ATB,        "cs_atb",        "cs_atb_div",     CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 0,  0, },
+	{ HI6220_I2C0_CLK,      "i2c0_clk",      "clk_150m",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 1,  0, },
+	{ HI6220_I2C1_CLK,      "i2c1_clk",      "clk_150m",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 2,  0, },
+	{ HI6220_I2C2_CLK,      "i2c2_clk",      "clk_150m",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 3,  0, },
+	{ HI6220_I2C3_CLK,      "i2c3_clk",      "clk_150m",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 4,  0, },
+	{ HI6220_UART1_PCLK,    "uart1_pclk",    "uart1_src",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 5,  0, },
+	{ HI6220_UART2_PCLK,    "uart2_pclk",    "uart2_src",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 6,  0, },
+	{ HI6220_UART3_PCLK,    "uart3_pclk",    "uart3_src",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 7,  0, },
+	{ HI6220_UART4_PCLK,    "uart4_pclk",    "uart4_src",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 8,  0, },
+	{ HI6220_SPI_CLK,       "spi_clk",       "clk_150m",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 9,  0, },
+	{ HI6220_TSENSOR_CLK,   "tsensor_clk",   "clk_bus",        CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x230, 12, 0, },
+	{ HI6220_MMU_CLK,       "mmu_clk",       "ddrc_axi1",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x240, 11, 0, },
+	{ HI6220_HIFI_SEL,      "hifi_sel",      "hifi_src",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 0,  0, },
+	{ HI6220_MMC0_SYSPLL,   "mmc0_syspll",   "syspll",         CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 1,  0, },
+	{ HI6220_MMC1_SYSPLL,   "mmc1_syspll",   "syspll",         CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 2,  0, },
+	{ HI6220_MMC2_SYSPLL,   "mmc2_syspll",   "syspll",         CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 3,  0, },
+	{ HI6220_MMC0_SEL,      "mmc0_sel",      "mmc0_mux1",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 6,  0, },
+	{ HI6220_MMC1_SEL,      "mmc1_sel",      "mmc1_mux1",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 7,  0, },
+	{ HI6220_BBPPLL_SEL,    "bbppll_sel",    "pll0_bbp_gate",  CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 9,  0, },
+	{ HI6220_MEDIA_PLL_SRC, "media_pll_src", "pll_media_gate", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 10, 0, },
+	{ HI6220_MMC2_SEL,      "mmc2_sel",      "mmc2_mux1",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 11, 0, },
+	{ HI6220_CS_ATB_SYSPLL, "cs_atb_syspll", "syspll",         CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x270, 12, 0, },
+};
+
+static struct hisi_mux_clock hi6220_mux_clks_sys[] __initdata = {
+	{ HI6220_MMC0_SRC,    "mmc0_src",    mmc0_src_p,     ARRAY_SIZE(mmc0_src_p),     CLK_SET_RATE_PARENT, 0x4,   0,  1, 0, },
+	{ HI6220_MMC0_SMP_IN, "mmc0_smp_in", mmc0_sample_in, ARRAY_SIZE(mmc0_sample_in), CLK_SET_RATE_PARENT, 0x4,   0,  1, 0, },
+	{ HI6220_MMC1_SRC,    "mmc1_src",    mmc1_src_p,     ARRAY_SIZE(mmc1_src_p),     CLK_SET_RATE_PARENT, 0x4,   2,  1, 0, },
+	{ HI6220_MMC1_SMP_IN, "mmc1_smp_in", mmc1_sample_in, ARRAY_SIZE(mmc1_sample_in), CLK_SET_RATE_PARENT, 0x4,   2,  1, 0, },
+	{ HI6220_MMC2_SRC,    "mmc2_src",    mmc2_src_p,     ARRAY_SIZE(mmc2_src_p),     CLK_SET_RATE_PARENT, 0x4,   4,  1, 0, },
+	{ HI6220_MMC2_SMP_IN, "mmc2_smp_in", mmc2_sample_in, ARRAY_SIZE(mmc2_sample_in), CLK_SET_RATE_PARENT, 0x4,   4,  1, 0, },
+	{ HI6220_HIFI_SRC,    "hifi_src",    hifi_src,       ARRAY_SIZE(hifi_src),       CLK_SET_RATE_PARENT, 0x400, 0,  1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_UART1_SRC,   "uart1_src",   uart1_src,      ARRAY_SIZE(uart1_src),      CLK_SET_RATE_PARENT, 0x400, 1,  1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_UART2_SRC,   "uart2_src",   uart2_src,      ARRAY_SIZE(uart2_src),      CLK_SET_RATE_PARENT, 0x400, 2,  1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_UART3_SRC,   "uart3_src",   uart3_src,      ARRAY_SIZE(uart3_src),      CLK_SET_RATE_PARENT, 0x400, 3,  1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_UART4_SRC,   "uart4_src",   uart4_src,      ARRAY_SIZE(uart4_src),      CLK_SET_RATE_PARENT, 0x400, 4,  1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_MMC0_MUX0,   "mmc0_mux0",   mmc0_mux0_p,    ARRAY_SIZE(mmc0_mux0_p),    CLK_SET_RATE_PARENT, 0x400, 5,  1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_MMC1_MUX0,   "mmc1_mux0",   mmc1_mux0_p,    ARRAY_SIZE(mmc1_mux0_p),    CLK_SET_RATE_PARENT, 0x400, 11, 1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_MMC2_MUX0,   "mmc2_mux0",   mmc2_mux0_p,    ARRAY_SIZE(mmc2_mux0_p),    CLK_SET_RATE_PARENT, 0x400, 12, 1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_MMC0_MUX1,   "mmc0_mux1",   mmc0_mux1_p,    ARRAY_SIZE(mmc0_mux1_p),    CLK_SET_RATE_PARENT, 0x400, 13, 1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_MMC1_MUX1,   "mmc1_mux1",   mmc1_mux1_p,    ARRAY_SIZE(mmc1_mux1_p),    CLK_SET_RATE_PARENT, 0x400, 14, 1, CLK_MUX_HIWORD_MASK,},
+	{ HI6220_MMC2_MUX1,   "mmc2_mux1",   mmc2_mux1_p,    ARRAY_SIZE(mmc2_mux1_p),    CLK_SET_RATE_PARENT, 0x400, 15, 1, CLK_MUX_HIWORD_MASK,},
+};
+
+static struct hi6220_divider_clock hi6220_div_clks_sys[] __initdata = {
+	{ HI6220_CLK_BUS,     "clk_bus",     "clk_300m",      CLK_SET_RATE_PARENT, 0x490, 0,  4, 7, },
+	{ HI6220_MMC0_DIV,    "mmc0_div",    "mmc0_syspll",   CLK_SET_RATE_PARENT, 0x494, 0,  6, 7, },
+	{ HI6220_MMC1_DIV,    "mmc1_div",    "mmc1_syspll",   CLK_SET_RATE_PARENT, 0x498, 0,  6, 7, },
+	{ HI6220_MMC2_DIV,    "mmc2_div",    "mmc2_syspll",   CLK_SET_RATE_PARENT, 0x49c, 0,  6, 7, },
+	{ HI6220_HIFI_DIV,    "hifi_div",    "hifi_sel",      CLK_SET_RATE_PARENT, 0x4a0, 0,  4, 7, },
+	{ HI6220_BBPPLL0_DIV, "bbppll0_div", "bbppll_sel",    CLK_SET_RATE_PARENT, 0x4a0, 8,  6, 15,},
+	{ HI6220_CS_DAPB,     "cs_dapb",     "picophy_src",   CLK_SET_RATE_PARENT, 0x4a0, 24, 2, 31,},
+	{ HI6220_CS_ATB_DIV,  "cs_atb_div",  "cs_atb_syspll", CLK_SET_RATE_PARENT, 0x4a4, 0,  4, 7, },
+};
+
+static void __init hi6220_clk_sys_init(struct device_node *np)
+{
+	struct hisi_clock_data *clk_data;
+
+	clk_data = hisi_clk_init(np, HI6220_SYS_NR_CLKS);
+	if (!clk_data)
+		return;
+
+	hisi_clk_register_gate_sep(hi6220_separated_gate_clks_sys,
+			ARRAY_SIZE(hi6220_separated_gate_clks_sys), clk_data);
+
+	hisi_clk_register_mux(hi6220_mux_clks_sys,
+			ARRAY_SIZE(hi6220_mux_clks_sys), clk_data);
+
+	hi6220_clk_register_divider(hi6220_div_clks_sys,
+			ARRAY_SIZE(hi6220_div_clks_sys), clk_data);
+
+	if (!clk_data_ao)
+		return;
+
+	/* enable high speed clock on UART1 mux */
+	clk_set_parent(clk_data->clk_data.clks[HI6220_UART1_SRC],
+			clk_data_ao->clk_data.clks[HI6220_150M]);
+}
+CLK_OF_DECLARE(hi6220_clk_sys, "hisilicon,sysctrl", hi6220_clk_sys_init);
+
+
+/* clocks in media controller */
+static const char *clk_1000_1200_src[] __initconst = { "pll_gpu_gate", "media_syspll_src", };
+static const char *clk_1440_1200_src[] __initconst = { "media_syspll_src", "media_pll_src", };
+static const char *clk_1000_1440_src[] __initconst = { "pll_gpu_gate", "media_pll_src", };
+
+static struct hisi_gate_clock hi6220_separated_gate_clks_media[] __initdata = {
+	{ HI6220_DSI_PCLK,       "dsi_pclk",         "vpucodec",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 0,  0, },
+	{ HI6220_G3D_PCLK,       "g3d_pclk",         "vpucodec",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 1,  0, },
+	{ HI6220_ACLK_CODEC_VPU, "aclk_codec_vpu",   "ade_core_src",  CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 3,  0, },
+	{ HI6220_ISP_SCLK,       "isp_sclk",         "isp_sclk_src",  CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 5,  0, },
+	{ HI6220_ADE_CORE,	 "ade_core",	     "ade_core_src",  CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 6,  0, },
+	{ HI6220_MED_MMU,        "media_mmu",        "mmu_clk",       CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 8,  0, },
+	{ HI6220_CFG_CSI4PHY,    "cfg_csi4phy",      "clk_tcxo",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 9,  0, },
+	{ HI6220_CFG_CSI2PHY,    "cfg_csi2phy",      "clk_tcxo",      CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 10, 0, },
+	{ HI6220_ISP_SCLK_GATE,  "isp_sclk_gate",    "media_pll_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 11, 0, },
+	{ HI6220_ISP_SCLK_GATE1, "isp_sclk_gate1",   "media_pll_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 12, 0, },
+	{ HI6220_ADE_CORE_GATE,  "ade_core_gate",    "media_pll_src", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 14, 0, },
+	{ HI6220_CODEC_VPU_GATE, "codec_vpu_gate",   "clk_1000_1440", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 15, 0, },
+	{ HI6220_MED_SYSPLL,     "media_syspll_src", "media_syspll",  CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x520, 17, 0, },
+};
+
+static struct hisi_mux_clock hi6220_mux_clks_media[] __initdata = {
+	{ HI6220_1440_1200, "clk_1440_1200", clk_1440_1200_src, ARRAY_SIZE(clk_1440_1200_src), CLK_SET_RATE_PARENT, 0x51c, 0, 1, 0, },
+	{ HI6220_1000_1200, "clk_1000_1200", clk_1000_1200_src, ARRAY_SIZE(clk_1000_1200_src), CLK_SET_RATE_PARENT, 0x51c, 1, 1, 0, },
+	{ HI6220_1000_1440, "clk_1000_1440", clk_1000_1440_src, ARRAY_SIZE(clk_1000_1440_src), CLK_SET_RATE_PARENT, 0x51c, 6, 1, 0, },
+};
+
+static struct hi6220_divider_clock hi6220_div_clks_media[] __initdata = {
+	{ HI6220_CODEC_JPEG,    "codec_jpeg_aclk", "media_pll_src",  CLK_SET_RATE_PARENT, 0xcbc, 0,  4, 23, },
+	{ HI6220_ISP_SCLK_SRC,  "isp_sclk_src",    "isp_sclk_gate",  CLK_SET_RATE_PARENT, 0xcbc, 8,  4, 15, },
+	{ HI6220_ISP_SCLK1,     "isp_sclk1",       "isp_sclk_gate1", CLK_SET_RATE_PARENT, 0xcbc, 24, 4, 31, },
+	{ HI6220_ADE_CORE_SRC,  "ade_core_src",    "ade_core_gate",  CLK_SET_RATE_PARENT, 0xcc0, 16, 3, 23, },
+	{ HI6220_ADE_PIX_SRC,   "ade_pix_src",     "clk_1440_1200",  CLK_SET_RATE_PARENT, 0xcc0, 24, 6, 31, },
+	{ HI6220_G3D_CLK,       "g3d_clk",         "clk_1000_1200",  CLK_SET_RATE_PARENT, 0xcc4, 8,  4, 15, },
+	{ HI6220_CODEC_VPU_SRC, "codec_vpu_src",   "codec_vpu_gate", CLK_SET_RATE_PARENT, 0xcc4, 24, 6, 31, },
+};
+
+static void __init hi6220_clk_media_init(struct device_node *np)
+{
+	struct hisi_clock_data *clk_data;
+
+	clk_data = hisi_clk_init(np, HI6220_MEDIA_NR_CLKS);
+	if (!clk_data)
+		return;
+
+	hisi_clk_register_gate_sep(hi6220_separated_gate_clks_media,
+				ARRAY_SIZE(hi6220_separated_gate_clks_media), clk_data);
+
+	hisi_clk_register_mux(hi6220_mux_clks_media,
+				ARRAY_SIZE(hi6220_mux_clks_media), clk_data);
+
+	hi6220_clk_register_divider(hi6220_div_clks_media,
+				ARRAY_SIZE(hi6220_div_clks_media), clk_data);
+}
+CLK_OF_DECLARE(hi6220_clk_media, "hisilicon,mediactrl", hi6220_clk_media_init);
+
+
+/* clocks in pmctrl */
+static struct hisi_gate_clock hi6220_gate_clks_power[] __initdata = {
+	{ HI6220_PLL_GPU_GATE,   "pll_gpu_gate",   "gpupll",    CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x8,  0,  0, },
+	{ HI6220_PLL1_DDR_GATE,  "pll1_ddr_gate",  "ddrpll1",   CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x10, 0,  0, },
+	{ HI6220_PLL_DDR_GATE,   "pll_ddr_gate",   "ddrpll0",   CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x18, 0,  0, },
+	{ HI6220_PLL_MEDIA_GATE, "pll_media_gate", "media_pll", CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x38, 0,  0, },
+	{ HI6220_PLL0_BBP_GATE,  "pll0_bbp_gate",  "bbppll0",   CLK_SET_RATE_PARENT|CLK_IGNORE_UNUSED, 0x48, 0,  0, },
+};
+
+static struct hi6220_divider_clock hi6220_div_clks_power[] __initdata = {
+	{ HI6220_DDRC_SRC,  "ddrc_src",  "ddr_sel_src", CLK_SET_RATE_PARENT, 0x5a8, 0, 4, 0, },
+	{ HI6220_DDRC_AXI1, "ddrc_axi1", "ddrc_src",    CLK_SET_RATE_PARENT, 0x5a8, 8, 2, 0, },
+};
+
+static void __init hi6220_clk_power_init(struct device_node *np)
+{
+	struct hisi_clock_data *clk_data;
+
+	clk_data = hisi_clk_init(np, HI6220_POWER_NR_CLKS);

drivers/clk/hisilicon/clk-hi6220.c line 292

Quoted 10 lines
drivers/clk/hisilicon/clk-hi6220.c new file +10 -0
+	if (!clk_data)
+		return;
+
+	hisi_clk_register_gate(hi6220_gate_clks_power,
+				ARRAY_SIZE(hi6220_gate_clks_power), clk_data);
+
+	hi6220_clk_register_divider(hi6220_div_clks_power,
+				ARRAY_SIZE(hi6220_div_clks_power), clk_data);
+}
+CLK_OF_DECLARE(hi6220_clk_power, "hisilicon,pmctrl", hi6220_clk_power_init);

There's nothing module specific in this file. And the lack of a MODULE_LICENSE() macro is also telling. If this was built as a module loading that module - ignoring the undefined symbols - would taint the kernel.

It seems to me that COMMON_CLK_HI6220 is meant to be a bool symbol.

Paul Bolle

I wonder what checkpatch had to say about the length of the lines seen in this patch.

author
#14 lore raw

Re: [PATCH v2 4/6] clk: hi6220: Clock driver support for Hisilicon hi6220 SoC

Hello Paul,

Thank you very much for code review and testing on arm!

Quoted 13 lines · Paul Bolle

drivers/clk/hisilicon/Kconfig line 5

Quoted 8 lines · Bintian Wang
drivers/clk/hisilicon/Kconfig new file +5 -0
@@ -0,0 +1,5 @@
+config COMMON_CLK_HI6220
+	tristate "Hi6220 Clock Driver"
+	depends on OF && ARCH_HISI
+	help
+	  Build the Hisilicon Hi6220 clock driver based on the common clock framework.

In 5/6 you make arm64's ARCH_HISI (a bool) select COMMON_CLK_HI6220. So for arm64 this driver will always be built-in.

Quoted 1 line

For arm's ARCH_HISI it's possible to set COMMON_CLK_HI6220 to 'm'.

Setting COMMON_CLK_HI6220 to a bool symbol is a good solution based on current code base, I will fix it in next version.

Quoted 35 lines

drivers/clk/hisilicon/Makefile line 5

Quoted 9 lines
drivers/clk/hisilicon/Makefile +1 -1
@@ -2,8 +2,9 @@
  # Hisilicon Clock specific Makefile
  #
 
-obj-y	+= clk.o clkgate-separated.o
+obj-y	+= clk.o clkgate-separated.o clkdivider-hi6220.o

These objects will always be built-in, right?

drivers/clk/hisilicon/Makefile line 10

Quoted 4 lines
drivers/clk/hisilicon/Makefile +1 -0
  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

If CONFIG_COMMON_CLK_HI6220 is 'm' this will build a module named clk-hi6220.ko. If I try to do that I get:

     $ make -C ../../.. ARCH=arm CROSS_COMPILE=arm-linux-gnu- M=$PWD clk-hi6220.ko
     make: Entering directory `[...]'
       CC [M]  [...]/drivers/clk/hisilicon/clk-hi6220.o
       MODPOST 1 modules
     WARNING: "hisi_clk_register_gate" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
     WARNING: "hi6220_clk_register_divider" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
     WARNING: "hisi_clk_register_mux" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
     WARNING: "hisi_clk_register_gate_sep" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
     WARNING: "hisi_clk_register_fixed_factor" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
     WARNING: "hisi_clk_register_fixed_rate" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
     WARNING: "hisi_clk_init" [[...]/drivers/clk/hisilicon/clk-hi6220.ko] undefined!
       CC      [...]/drivers/clk/hisilicon/clk-hi6220.mod.o
       LDFINAL [M]  [...]/drivers/clk/hisilicon/clk-hi6220.ko
     make: Leaving directory `[...]'

That is, I think, because nothing exports these symbols.

[...]

Quoted 6 lines

There's nothing module specific in this file. And the lack of a MODULE_LICENSE() macro is also telling. If this was built as a module loading that module - ignoring the undefined symbols - would taint the kernel.

It seems to me that COMMON_CLK_HI6220 is meant to be a bool symbol.

You are right.

Quoted 6 lines

Paul Bolle

I wonder what checkpatch had to say about the length of the lines seen in this patch.

Yes, I ran this script before sending out this patch set, it reports warnings about "line over 80 characters ", but I find it's easier to read than shrinking one line to several lines, so just keep it, do I need to fix it?

Thanks,

Bintian

Quoted 3 lines

.

#15 lore raw

Re: [PATCH v2 4/6] clk: hi6220: Clock driver support for Hisilicon hi6220 SoC

Quoted 1 line · Bintian

Thank you very much for code review and testing on arm!

s/testing/crosscompiling for/

Quoted 8 lines · Paul Bolle
Quoted 2 lines

I wonder what checkpatch had to say about the length of the lines seen in this patch.

Yes, I ran this script before sending out this patch set, it reports warnings about "line over 80 characters ", but I find it's easier to read than shrinking one line to several lines, so just keep it, do I need to fix it?

I'll leave that to the maintainers of drivers/clk/. (I don't care deeply. So on second thought I should not have made that remark.)

Thanks,

Paul Bolle

maintainer
#16 lore raw

Re: [PATCH v2 4/6] clk: hi6220: Clock driver support for Hisilicon hi6220 SoC

In reply to Bintian Wang
Quoted 7 lines · On Monday 13 April 2015 17:17:38 Bintian Wang wrote:
include/dt-bindings/clock/hi6220-clock.h new file +6 -0
+#define HI6220_CFG_CSI2PHY     8
+#define HI6220_ISP_SCLK_GATE   9
+#define HI6220_ISP_SCLK_GATE1  10
+#define HI6220_ADE_CORE_GATE   11
+#define HI6220_CODEC_VPU_GATE  12
+#define HI6220_MED_SYSPLL      13

include/dt-bindings/clock/hi6220-clock.h line 152

Quoted 10 lines
include/dt-bindings/clock/hi6220-clock.h new file +10 -0
+
+/* mux clocks */
+#define HI6220_1440_1200       20
+#define HI6220_1000_1200       21
+#define HI6220_1000_1440       22
+
+/* divider clocks */
+#define HI6220_CODEC_JPEG      30
+#define HI6220_ISP_SCLK_SRC    31
+#define HI6220_ISP_SCLK1       32

The numbers seem rather arbitrary, and you have both holes as well as duplicate numbers here. I would suggest you do one of two things instead:

a) have a separate header file per clock driver and make all the numbers unique and consecutive within that header

b) use the same numbers as the hardware registers so you can put the numbers directly into the dts and don't need a header to create an artificial ABI between the clock driver and the boot loader.

Arnd

author
#17 lore raw

Re: [PATCH v2 4/6] clk: hi6220: Clock driver support for Hisilicon hi6220 SoC

Hello Arnd,

Thanks for your code review.

Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · On Monday 13 April 2015 17:17:38 Bintian Wang wrote:
include/dt-bindings/clock/hi6220-clock.h new file +12 -0
+#define HI6220_CFG_CSI2PHY     8
+#define HI6220_ISP_SCLK_GATE   9
+#define HI6220_ISP_SCLK_GATE1  10
+#define HI6220_ADE_CORE_GATE   11
+#define HI6220_CODEC_VPU_GATE  12
+#define HI6220_MED_SYSPLL      13
+
+/* mux clocks */
+#define HI6220_1440_1200       20
+#define HI6220_1000_1200       21
+#define HI6220_1000_1440       22
+
Quoted 8 lines

include/dt-bindings/clock/hi6220-clock.h line 152

Quoted 5 lines
include/dt-bindings/clock/hi6220-clock.h new file +4 -0
+/* divider clocks */
+#define HI6220_CODEC_JPEG      30
+#define HI6220_ISP_SCLK_SRC    31
+#define HI6220_ISP_SCLK1       32

The numbers seem rather arbitrary, and you have both holes as well as duplicate numbers here. I would suggest you do one of two things instead:

I just worry about some special clocks may be added later so keep some holes for them;

The duplicate numbers means clocks belong to different system control domains.

Quoted 7 lines

a) have a separate header file per clock driver and make all the numbers unique and consecutive within that header

b) use the same numbers as the hardware registers so you can put the numbers directly into the dts and don't need a header to create an artificial ABI between the clock driver and the boot loader.

This header file will be used by device tree (I like using the clock name instead "magic number" in dts :) ), so how about keep them in one header file and let dts just include one header file (not four files), but remove the holes?

Thank you Arnd.

BR,

Bintian

Quoted 5 lines

Arnd

.

maintainer
#18 lore raw

Re: [PATCH v2 4/6] clk: hi6220: Clock driver support for Hisilicon hi6220 SoC

Quoted 27 lines · On Monday 13 April 2015 21:57:46 Bintian wrote:

Hello Arnd,

Thanks for your code review.

Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · On Monday 13 April 2015 17:17:38 Bintian Wang wrote:
include/dt-bindings/clock/hi6220-clock.h new file +12 -0
+#define HI6220_CFG_CSI2PHY     8
+#define HI6220_ISP_SCLK_GATE   9
+#define HI6220_ISP_SCLK_GATE1  10
+#define HI6220_ADE_CORE_GATE   11
+#define HI6220_CODEC_VPU_GATE  12
+#define HI6220_MED_SYSPLL      13
+
+/* mux clocks */
+#define HI6220_1440_1200       20
+#define HI6220_1000_1200       21
+#define HI6220_1000_1440       22
+
Quoted 8 lines

include/dt-bindings/clock/hi6220-clock.h line 152

Quoted 5 lines
include/dt-bindings/clock/hi6220-clock.h new file +4 -0
+/* divider clocks */
+#define HI6220_CODEC_JPEG      30
+#define HI6220_ISP_SCLK_SRC    31
+#define HI6220_ISP_SCLK1       32

The numbers seem rather arbitrary, and you have both holes as well as duplicate numbers here. I would suggest you do one of two things instead:

Quoted 5 lines

I just worry about some special clocks may be added later so keep some holes for them;

The duplicate numbers means clocks belong to different system control domains.

I don't understand. How would there be additional clocks added later? Wouldn't that be a new chip?

If you have separate system control domains, doesn't that mean that you also have separate DT bindings?

Quoted 8 lines
Quoted 6 lines

a) have a separate header file per clock driver and make all the numbers unique and consecutive within that header

b) use the same numbers as the hardware registers so you can put the numbers directly into the dts and don't need a header to create an artificial ABI between the clock driver and the boot loader.

This header file will be used by device tree (I like using the clock name instead "magic number" in dts :) )

That's not how it works though: The dts file is the place to define the hardware numbers, we do that for all sorts of numbers: interrupts, gpios, register ranges etc are all defined in dts to avoid putting magic numbers in external header files.

There are some cases where it gets too ugly for clock controllers that are highly irregular, but yours doesn't seem to be that kind.

E.g. all the fixed rate clocks should just be separate device nodes, which lets you remove the binding for that node.

Quoted 2 lines

so how about keep them in one header file and let dts just include one header file (not four files), but remove the holes?

The header files constantly cause problems with merge dependencies, and we have some other companies that keep releasing new chips that each time require a new header file. If hisilicon plans to make more chips like this one, please consider coming up with more generic bindings to avoid this.

Arnd

#19 lore raw

Re: [PATCH v2 4/6] clk: hi6220: Clock driver support for Hisilicon hi6220 SoC

? 2015/4/13 23:34, Arnd Bergmann ??:

Quoted 28 lines · On Monday 13 April 2015 21:57:46 Bintian wrote:
Quoted 26 lines

Hello Arnd,

Thanks for your code review.

Quoted 21 lines · Arnd Bergmann
Quoted 7 lines · On Monday 13 April 2015 17:17:38 Bintian Wang wrote:
include/dt-bindings/clock/hi6220-clock.h new file +6 -0
+#define HI6220_CFG_CSI2PHY     8
+#define HI6220_ISP_SCLK_GATE   9
+#define HI6220_ISP_SCLK_GATE1  10
+#define HI6220_ADE_CORE_GATE   11
+#define HI6220_CODEC_VPU_GATE  12
+#define HI6220_MED_SYSPLL      13

include/dt-bindings/clock/hi6220-clock.h line 152

Quoted 10 lines
include/dt-bindings/clock/hi6220-clock.h new file +10 -0
+
+/* mux clocks */
+#define HI6220_1440_1200       20
+#define HI6220_1000_1200       21
+#define HI6220_1000_1440       22
+
+/* divider clocks */
+#define HI6220_CODEC_JPEG      30
+#define HI6220_ISP_SCLK_SRC    31
+#define HI6220_ISP_SCLK1       32

The numbers seem rather arbitrary, and you have both holes as well as duplicate numbers here. I would suggest you do one of two things instead:

Quoted 8 lines
Quoted 5 lines

I just worry about some special clocks may be added later so keep some holes for them;

The duplicate numbers means clocks belong to different system control domains.

I don't understand. How would there be additional clocks added later? Wouldn't that be a new chip?

There are some clocks not used in linux system. e.g, some clocks are
used in base band processor. So, some numbers are not defined here.

Quoted 36 lines

If you have separate system control domains, doesn't that mean that you also have separate DT bindings?

Quoted 8 lines
Quoted 6 lines

a) have a separate header file per clock driver and make all the numbers unique and consecutive within that header

b) use the same numbers as the hardware registers so you can put the numbers directly into the dts and don't need a header to create an artificial ABI between the clock driver and the boot loader.

This header file will be used by device tree (I like using the clock name instead "magic number" in dts :) )

That's not how it works though: The dts file is the place to define the hardware numbers, we do that for all sorts of numbers: interrupts, gpios, register ranges etc are all defined in dts to avoid putting magic numbers in external header files.

There are some cases where it gets too ugly for clock controllers that are highly irregular, but yours doesn't seem to be that kind.

E.g. all the fixed rate clocks should just be separate device nodes, which lets you remove the binding for that node.

Quoted 2 lines

so how about keep them in one header file and let dts just include one header file (not four files), but remove the holes?

The header files constantly cause problems with merge dependencies, and we have some other companies that keep releasing new chips that each time require a new header file. If hisilicon plans to make more chips like this one, please consider coming up with more generic bindings to avoid this.

Arnd

.

#20 lore raw

PATCH v2 5/6 arm64: Kconfig: Add clock support to ARCH_HISI

In reply to Bintian Wang

Select hi6220 clock driver for ARCH_HISI.

---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
index 64d4d6d..75c55fe 100644
@@ -230,6 +230,7 @@ config ARCH_XGENE
 
 config ARCH_HISI
 	bool "Hisilicon SoC Family"
+	select COMMON_CLK_HI6220
 	help
 	  This enables support for Hisilicon ARMv8 SoC family
 
Signature · 1 line
1.9.1
#21 lore raw

PATCH v2 6/6 arm64: dts: Add dts files for Hisilicon Hi6220 SoC

In reply to Bintian Wang

Add initial dtsi file to support Hisilicon Hi6220 SoC with support of Octal core CPUs in two clusters and each cluster has quard Cortex-A53.

Also add dts file to support HiKey development board which based on Hi6220 SoC.

---
 arch/arm64/boot/dts/Makefile                   |   1 +
 arch/arm64/boot/dts/hisilicon/Makefile         |   5 +
 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts |  28 ++++
 arch/arm64/boot/dts/hisilicon/hi6220.dtsi      | 171 +++++++++++++++++++++++++
 4 files changed, 205 insertions(+)
 create mode 100644 arch/arm64/boot/dts/hisilicon/Makefile
 create mode 100644 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts
 create mode 100644 arch/arm64/boot/dts/hisilicon/hi6220.dtsi
arch/arm64/boot/dts/Makefile +1 -0
index e0350ca..3c1c4cf 100644
@@ -5,5 +5,6 @@ dts-dirs += cavium
 dts-dirs += exynos
 dts-dirs += freescale
 dts-dirs += mediatek
+dts-dirs += hisilicon
 
 subdir-y	:= $(dts-dirs)
arch/arm64/boot/dts/hisilicon/Makefile new file +5 -0
new file mode 100644
index 0000000..fa81a6e
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_HISI) += hi6220-hikey.dtb
+
+always		:= $(dtb-y)
+subdir-y	:= $(dts-dirs)
+clean-files	:= *.dtb
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts new file +28 -0
new file mode 100644
index 0000000..c4b3ed8
@@ -0,0 +1,28 @@
+/*
+ * dts file for Hisilicon HiKey Development Board
+ *
+ * Copyright (C) 2015, Hisilicon Ltd.
+ *
+ */
+
+/dts-v1/;
+
+#include "hi6220.dtsi"
+
+/ {
+	model = "HiKey Development Board";
+	compatible = "hisilicon,hi6220-hikey";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		linux,stdout-path = &uart0;
+	};
+
+	memory at 0 {
+		device_type = "memory";
+		reg = <0x0 0x0 0x0 0x40000000>;
+	};
+};
arch/arm64/boot/dts/hisilicon/hi6220.dtsi new file +171 -0

171 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#22 lore raw

Re: [PATCH v2 6/6] arm64: dts: Add dts files for Hisilicon Hi6220 SoC

arch/arm64/boot/dts/hisilicon/hi6220.dtsi line 137

Quoted 6 lines · On Monday 13 April 2015 17:17:40 Bintian Wang wrote:
arch/arm64/boot/dts/hisilicon/hi6220.dtsi new file +6 -0
+
+       soc {
+               compatible = "simple-bus";
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;

Just one comment here: on a 64-bit system, the bus nodes must have "dma-ranges" properties that describe the width of the bus. By default, we assume that the bus is only 32-bit wide, which means that if you install memory over the 4GB address boundary, devices will not be able to do DMA there, even if the devices themselves are 64-bit DMA capable.

Quoted 20 lines
arch/arm64/boot/dts/hisilicon/hi6220.dtsi new file +20 -0
+               ao_ctrl: ao_ctrl {
+                       compatible = "hisilicon,aoctrl", "syscon";
+                       reg = <0x0 0xf7800000 0x0 0x2000>;
+                       #clock-cells = <1>;
+               };
+
+               sys_ctrl: sys_ctrl {
+                       compatible = "hisilicon,sysctrl", "syscon";
+                       reg = <0x0 0xf7030000 0x0 0x2000>;
+                       #clock-cells = <1>;
+               };
+
+               media_ctrl: media_ctrl {
+                       compatible = "hisilicon,mediactrl", "syscon";
+                       reg = <0x0 0xf4410000 0x0 0x1000>;
+                       #clock-cells = <1>;
+               };
+
+               pm_ctrl: pm_ctrl {
+                       compatible = "hisilicon,pmctrl", "syscon";

arch/arm64/boot/dts/hisilicon/hi6220.dtsi line 168

Quoted 10 lines
arch/arm64/boot/dts/hisilicon/hi6220.dtsi new file +10 -0
+                       reg = <0x0 0xf7032000 0x0 0x1000>;
+                       #clock-cells = <1>;
+               };
+
+               uart0: uart at f8015000 {  /* console */
+                       compatible = "arm,pl011", "arm,primecell";
+                       reg = <0x0 0xf8015000 0x0 0x1000>;
+                       interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&ao_ctrl HI6220_UART0_PCLK>, <&ao_ctrl HI6220_UART0_PCLK>;
+                       clock-names = "uartclk", "apb_pclk";

So far, none of hte devices you list are DMA masters, so there is no effect, but please check what DMA masters you have in the system, and whether they are capable of doing 64-bit DMA.

Arnd