Skip to contentSkip to conversation

add clk-hi3660

PATCH New Zhangfei Gao 3 participants 7 messages Dec 29, 2016 – Jan 10, 2017

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

v2 cover add clk-hi3660

Address comments from Rob and Stephen.
Rebase to 4.10-rc1

Zhangfei Gao (2):
dt-bindings: Document the hi3660 clock bindings
clk: hisilicon: Add clock driver for hi3660 SoC

 .../devicetree/bindings/clock/hi3660-clock.txt     |  42 ++
 drivers/clk/hisilicon/Kconfig                      |   7 +
 drivers/clk/hisilicon/Makefile                     |   1 +
 drivers/clk/hisilicon/clk-hi3660.c                 | 592 +++++++++++++++++++++
 include/dt-bindings/clock/hi3660-clock.h           | 194 +++++++
 5 files changed, 836 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/hi3660-clock.txt
 create mode 100644 drivers/clk/hisilicon/clk-hi3660.c
 create mode 100644 include/dt-bindings/clock/hi3660-clock.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 dt-bindings: Document the hi3660 clock bindings

Add DT bindings documentation for hi3660 SoC clock.

---
 .../devicetree/bindings/clock/hi3660-clock.txt     | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/hi3660-clock.txt
Documentation/devicetree/bindings/clock/hi3660-clock.txt new file +42 -0
new file mode 100644
index 0000000..cc9b86c
@@ -0,0 +1,42 @@
+* Hisilicon Hi3660 Clock Controller
+
+The Hi3660 clock controller generates and supplies clock to various
+controllers within the Hi3660 SoC.
+
+Required Properties:
+
+- compatible: the compatible should be one of the following strings to
+	indicate the clock controller functionality.
+
+	- "hisilicon,hi3660-crgctrl"
+	- "hisilicon,hi3660-pctrl"
+	- "hisilicon,hi3660-pmuctrl"
+	- "hisilicon,hi3660-sctrl"
+	- "hisilicon,hi3660-iomcu"
+
+- reg: physical base address of the controller and length of memory mapped
+  region.
+
+- #clock-cells: should be 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/hi3660-clock.h>.
+
+Examples:
+	crg_ctrl: clock-controller at fff35000 {
+		compatible = "hisilicon,hi3660-crgctrl", "syscon";
+		reg = <0x0 0xfff35000 0x0 0x1000>;
+		#clock-cells = <1>;
+	};
+
+	uart0: serial at fdf02000 {
+		compatible = "arm,pl011", "arm,primecell";
+		reg = <0x0 0xfdf02000 0x0 0x1000>;
+		interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&crg_ctrl HI3660_CLK_MUX_UART0>,
+			 <&crg_ctrl HI3660_PCLK>;
+		clock-names = "uartclk", "apb_pclk";
+		status = "disabled";
+	};
Signature · 1 line
2.7.4
maintainer
#2 lore raw

PATCH v2 1/2 dt-bindings: Document the hi3660 clock bindings

Quoted 7 lines · Zhangfei Gao

Add DT bindings documentation for hi3660 SoC clock.

---
 .../devicetree/bindings/clock/hi3660-clock.txt     | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/hi3660-clock.txt
Applied
#3 lore raw

PATCH v2 1/2 dt-bindings: Document the hi3660 clock bindings

In reply to Zhangfei Gao
Quoted 4 lines · Zhangfei Gao

Add DT bindings documentation for hi3660 SoC clock.

---

Applied to clk-hi3660 and merged into clk-next

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

PATCH v2 2/2 clk: hisilicon: Add clock driver for hi3660 SoC

In reply to Zhangfei Gao

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

---
 drivers/clk/hisilicon/Kconfig            |   7 +
 drivers/clk/hisilicon/Makefile           |   1 +
 drivers/clk/hisilicon/clk-hi3660.c       | 592 +++++++++++++++++++++++++++++++
 include/dt-bindings/clock/hi3660-clock.h | 194 ++++++++++
 4 files changed, 794 insertions(+)
 create mode 100644 drivers/clk/hisilicon/clk-hi3660.c
 create mode 100644 include/dt-bindings/clock/hi3660-clock.h
drivers/clk/hisilicon/Kconfig +7 -0
index cbed660..7098bfd 100644
@@ -14,6 +14,13 @@ config COMMON_CLK_HI3519
 	help
 	  Build the clock driver for hi3519.
 
+config COMMON_CLK_HI3660
+	bool "Hi3660 Clock Driver"
+	depends on ARCH_HISI || COMPILE_TEST
+	default ARCH_HISI
+	help
+	  Build the clock driver for hi3660.
+
 config COMMON_CLK_HI3798CV200
 	tristate "Hi3798CV200 Clock Driver"
 	depends on ARCH_HISI || COMPILE_TEST
drivers/clk/hisilicon/Makefile +1 -0
index 4eec5e5..1e4c3dd 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_ARCH_HIP04)	+= clk-hip04.o
 obj-$(CONFIG_ARCH_HIX5HD2)	+= clk-hix5hd2.o
 obj-$(CONFIG_COMMON_CLK_HI3516CV300)	+= crg-hi3516cv300.o
 obj-$(CONFIG_COMMON_CLK_HI3519)	+= clk-hi3519.o
+obj-$(CONFIG_COMMON_CLK_HI3660) += clk-hi3660.o
 obj-$(CONFIG_COMMON_CLK_HI3798CV200)	+= crg-hi3798cv200.o
 obj-$(CONFIG_COMMON_CLK_HI6220)	+= clk-hi6220.o
 obj-$(CONFIG_RESET_HISI)	+= reset.o
drivers/clk/hisilicon/clk-hi3660.c new file +592 -0

592 lines not on this page · raw message

include/dt-bindings/clock/hi3660-clock.h new file +194 -0

194 lines not on this page · raw message

Signature · 1 line
2.7.4
Applied
#5 lore raw

PATCH v2 2/2 clk: hisilicon: Add clock driver for hi3660 SoC

Quoted 5 lines · Zhangfei Gao

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

---

Applied to clk-hi3660 and merged into clk-next. I took the liberty of using a function pointer in probe though so we don't need the enum anymore.

---8<---

drivers/clk/hisilicon/clk-hi3660.c +10 -35
index 4e752c632378..96a9697b06cf 100644
@@ -14,14 +14,6 @@
 #include <linux/platform_device.h>
 #include "clk.h"
 
-enum hi3660_clk_type {
-	HI3660_CRGCTRL = 1,
-	HI3660_PCTRL,
-	HI3660_PMUCTRL,
-	HI3660_SCTRL,
-	HI3660_IOMCU,
-};
-
 static const struct hisi_fixed_rate_clock hi3660_fixed_rate_clks[] = {
 	{ HI3660_CLKIN_SYS, "clkin_sys", NULL, 0, 19200000, },
 	{ HI3660_CLKIN_REF, "clkin_ref", NULL, 0, 32764, },
@@ -533,15 +525,15 @@ static void hi3660_clk_crgctrl_init(struct device_node *np)
 
 static const struct of_device_id hi3660_clk_match_table[] = {
 	{ .compatible = "hisilicon,hi3660-crgctrl",
-	  .data = (void *)HI3660_CRGCTRL },
+	  .data = hi3660_clk_crgctrl_init },
 	{ .compatible = "hisilicon,hi3660-pctrl",
-	  .data = (void *)HI3660_PCTRL },
+	  .data = hi3660_clk_pctrl_init },
 	{ .compatible = "hisilicon,hi3660-pmuctrl",
-	  .data = (void *)HI3660_PMUCTRL },
+	  .data = hi3660_clk_pmuctrl_init },
 	{ .compatible = "hisilicon,hi3660-sctrl",
-	  .data = (void *)HI3660_SCTRL },
+	  .data = hi3660_clk_sctrl_init },
 	{ .compatible = "hisilicon,hi3660-iomcu",
-	  .data = (void *)HI3660_IOMCU },
+	  .data = hi3660_clk_iomcu_init },
 	{ }
 };
 
@@ -549,31 +541,14 @@ static int hi3660_clk_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct device_node *np = pdev->dev.of_node;
-	enum hi3660_clk_type type;
+	void (*init_func)(struct device_node *np);
 
-	type = (enum hi3660_clk_type)of_device_get_match_data(dev);
-	if (!type)
+	init_func = of_device_get_match_data(dev);
+	if (!init_func)
 		return -ENODEV;
 
-	switch (type) {
-	case HI3660_CRGCTRL:
-		hi3660_clk_crgctrl_init(np);
-		break;
-	case HI3660_PCTRL:
-		hi3660_clk_pctrl_init(np);
-		break;
-	case HI3660_PMUCTRL:
-		hi3660_clk_pmuctrl_init(np);
-		break;
-	case HI3660_SCTRL:
-		hi3660_clk_sctrl_init(np);
-		break;
-	case HI3660_IOMCU:
-		hi3660_clk_iomcu_init(np);
-		break;
-	default:
-		break;
-	}
+	init_func(np);
+
 	return 0;
 }
 
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#6 lore raw

PATCH v2 2/2 clk: hisilicon: Add clock driver for hi3660 SoC

Quoted 9 lines · Stephen Boyd
Quoted 5 lines · Zhangfei Gao

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

---

Applied to clk-hi3660 and merged into clk-next. I took the liberty of using a function pointer in probe though so we don't need the enum anymore.

Good idea. It is simplified a lot.
Have verified on hikey960.

Thanks Stephen for the help.