Skip to contentSkip to conversation

dt-bindings: documentation: add clock bindings information for Stratix10

PATCH New Dinh Nguyen 2 participants 6 messages Mar 21, 2018 – Apr 6, 2018

Subsystems (4)
lore
Share & tools
lore

Dinh Nguyen

author maintainer
#0 lore raw

PATCH v7 1/3 dt-bindings: documentation: add clock bindings information for Stratix10

Document that Stratix10 clock bindings, and add the clock header file. The clock header is an enumeration of all the different clocks on the Stratix10 platform.

---
v7:
- remove the PLL from the clock manager dts node v6:
- no changes
v5:
- moved SPDX license header to single line comment v4:
- remove '_' in node names
- remove stray tab
- add clock-frequency property for fixed-clocks
- put SPDX license as the very top line
v3:
- s/intc/intel for correct vendor prefix
- fixup node name to "intel,stratix10-clkmgr"
- document the required fixed-clock for oscillators v2:
- use a single binding for the clock controller

---
 .../devicetree/bindings/clock/intc_stratix10.txt   | 20 ++++++
 include/dt-bindings/clock/stratix10-clock.h        | 84 ++++++++++++++++++++++
 2 files changed, 104 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/intc_stratix10.txt
 create mode 100644 include/dt-bindings/clock/stratix10-clock.h
Documentation/devicetree/bindings/clock/intc_stratix10.txt new file +20 -0
new file mode 100644
index 0000000..9f4ec5c
@@ -0,0 +1,20 @@
+Device Tree Clock bindings for Intel's SoCFPGA Stratix10 platform
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be
+	"intel,stratix10-clkmgr"
+
+- reg : shall be the control register offset from CLOCK_MANAGER's base for the clock.
+
+- #clock-cells : from common clock binding, shall be set to 1.
+
+Example:
+	clkmgr: clock-controller at ffd10000 {
+		compatible = "intel,stratix10-clkmgr";
+		reg = <0xffd10000 0x1000>;
+		#clock-cells = <1>;
+	};
include/dt-bindings/clock/stratix10-clock.h new file +84 -0

84 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#1 lore raw

PATCH v7 2/3 arm64: dts: stratix10: use clock bindings for the Stratix10 platform

Use the clock bindings for the Stratix10 SoC. This includes changing the old binding of "intc,clk-s10-mgr" to "intel,stratix10-clkmgr". The reason that this can be done is that there are currently no clock driver for Stratix10, thus there are no consumers of the old binding. So changing the binding will not break any legacy code.

---
v7:
- move PLL out of clkmgr node and into DT root v6:
- no changes
v5:
- no changes
v4:
- remove '_' in name of clock nodes
- use clock-controller in SoCDK node in dts file v3:
- use the correct vendor prefix
- explain the binding change
v2:
- use a single clock binding for the clock controller

---
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 47 +++++++++++++++++++++-
 .../boot/dts/altera/socfpga_stratix10_socdk.dts    |  8 ++++
 2 files changed, 53 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi +45 -2
index c89d0c30..0e267c8 100644
@@ -17,6 +17,7 @@
 /dts-v1/;
 #include <dt-bindings/reset/altr,rst-mgr-s10.h>
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/clock/stratix10-clock.h>
 
 / {
 	compatible = "altr,socfpga-stratix10";
@@ -92,9 +93,32 @@
 		interrupt-parent = <&intc>;
 		ranges = <0 0 0 0xffffffff>;
 
-		clkmgr at ffd1000 {
-			compatible = "altr,clk-mgr";
+		clkmgr: clock-controller at ffd10000 {
+			compatible = "intel,stratix10-clkmgr";
 			reg = <0xffd10000 0x1000>;
+			#clock-cells = <1>;
+		};
+
+		clocks {
+			cb_intosc_hs_div2_clk: cb-intosc-hs-div2-clk {
+				#clock-cells = <0>;
+				compatible = "fixed-clock";
+			};
+
+			cb_intosc_ls_clk: cb-intosc-ls-clk {
+				#clock-cells = <0>;
+				compatible = "fixed-clock";
+			};
+
+			f2s_free_clk: f2s-free-clk {
+				#clock-cells = <0>;
+				compatible = "fixed-clock";
+			};
+
+			osc1: osc1 {
+				#clock-cells = <0>;
+				compatible = "fixed-clock";
+			};
 		};
 
 		gmac0: ethernet at ff800000 {
@@ -105,6 +129,8 @@
 			mac-address = [00 00 00 00 00 00];
 			resets = <&rst EMAC0_RESET>;
 			reset-names = "stmmaceth";
+			clocks = <&clkmgr STRATIX10_EMAC0_CLK>;
+			clock-names = "stmmaceth";
 			status = "disabled";
 		};
 
@@ -116,6 +142,8 @@
 			mac-address = [00 00 00 00 00 00];
 			resets = <&rst EMAC1_RESET>;
 			reset-names = "stmmaceth";
+			clocks = <&clkmgr STRATIX10_EMAC1_CLK>;
+			clock-names = "stmmaceth";
 			status = "disabled";
 		};
 
@@ -127,6 +155,8 @@
 			mac-address = [00 00 00 00 00 00];
 			resets = <&rst EMAC2_RESET>;
 			reset-names = "stmmaceth";
+			clocks = <&clkmgr STRATIX10_EMAC2_CLK>;
+			clock-names = "stmmaceth";
 			status = "disabled";
 		};
 
@@ -229,6 +259,9 @@
 			fifo-depth = <0x400>;
 			resets = <&rst SDMMC_RESET>;
 			reset-names = "reset";
+			clocks = <&clkmgr STRATIX10_L4_MP_CLK>,
+				 <&clkmgr STRATIX10_SDMMC_CLK>;
+			clock-names = "biu", "ciu";
 			status = "disabled";
 		};
 
@@ -288,24 +321,32 @@
 			compatible = "snps,dw-apb-timer";
 			interrupts = <0 113 4>;
 			reg = <0xffc03000 0x100>;
+			clocks = <&clkmgr STRATIX10_L4_SP_CLK>;
+			clock-names = "timer";
 		};
 
 		timer1: timer1 at ffc03100 {
 			compatible = "snps,dw-apb-timer";
 			interrupts = <0 114 4>;
 			reg = <0xffc03100 0x100>;
+			clocks = <&clkmgr STRATIX10_L4_SP_CLK>;
+			clock-names = "timer";
 		};
 
 		timer2: timer2 at ffd00000 {
 			compatible = "snps,dw-apb-timer";
 			interrupts = <0 115 4>;
 			reg = <0xffd00000 0x100>;
+			clocks = <&clkmgr STRATIX10_L4_SP_CLK>;
+			clock-names = "timer";
 		};
 
 		timer3: timer3 at ffd00100 {
 			compatible = "snps,dw-apb-timer";
 			interrupts = <0 116 4>;
 			reg = <0xffd00100 0x100>;
+			clocks = <&clkmgr STRATIX10_L4_SP_CLK>;
+			clock-names = "timer";
 		};
 
 		uart0: serial0 at ffc02000 {
@@ -315,6 +356,7 @@
 			reg-shift = <2>;
 			reg-io-width = <4>;
 			resets = <&rst UART0_RESET>;
+			clocks = <&clkmgr STRATIX10_L4_SP_CLK>;
 			status = "disabled";
 		};
 
@@ -325,6 +367,7 @@
 			reg-shift = <2>;
 			reg-io-width = <4>;
 			resets = <&rst UART1_RESET>;
+			clocks = <&clkmgr STRATIX10_L4_SP_CLK>;
 			status = "disabled";
 		};
 
arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts +8 -0
index 0007564..8880190 100644
@@ -50,6 +50,14 @@
 		/* We expect the bootloader to fill in the reg */
 		reg = <0 0 0 0>;
 	};
+
+	soc {
+		clocks {
+			osc1 {
+				clock-frequency = <25000000>;
+			};
+		};
+	};
 };
 
 &gpio1 {
Signature · 1 line
2.7.4
maintainer
#2 lore raw

PATCH v7 2/3 arm64: dts: stratix10: use clock bindings for the Stratix10 platform

Quoting Dinh Nguyen (2018-03-21 07:20:11)

Quoted 8 lines

Use the clock bindings for the Stratix10 SoC. This includes changing the old binding of "intc,clk-s10-mgr" to "intel,stratix10-clkmgr". The reason that this can be done is that there are currently no clock driver for Stratix10, thus there are no consumers of the old binding. So changing the binding will not break any legacy code.

---

This should go via arm-soc so I won't be apply this one.

author maintainer
#3 lore raw

PATCH v7 3/3 clk: socfpga: stratix10: add clock driver for Stratix10 platform

In reply to Dinh Nguyen

Add a clock driver for the Stratix10 SoC. The driver is similar to the Cyclone5/Arria10 platforms, with the exception that this driver only uses one single clock binding.

---
v7:
- address review comments from S.Boyd
- convert clock driver to platform device
v6:
- minimize usage of strcmp
- use // as comment limiters for SPDX in c source file v5:
- make SPDX license as a 1st separate first line comment v4:
- move SPDX license first line of all files
v3:
- use fixed binding "intel,stratix10-clkmgr"
- Fix up SPDX license header
v2:
- Use a single clock binding

---
 drivers/clk/Makefile                 |   1 +
 drivers/clk/socfpga/Makefile         |   9 +-
 drivers/clk/socfpga/clk-gate-s10.c   | 124 +++++++++++++
 drivers/clk/socfpga/clk-periph-s10.c | 148 +++++++++++++++
 drivers/clk/socfpga/clk-pll-s10.c    | 145 +++++++++++++++
 drivers/clk/socfpga/clk-s10.c        | 345 +++++++++++++++++++++++++++++++++++
 drivers/clk/socfpga/clk.h            |   4 +
 drivers/clk/socfpga/stratix10-clk.h  |  80 ++++++++
 8 files changed, 851 insertions(+), 5 deletions(-)
 create mode 100644 drivers/clk/socfpga/clk-gate-s10.c
 create mode 100644 drivers/clk/socfpga/clk-periph-s10.c
 create mode 100644 drivers/clk/socfpga/clk-pll-s10.c
 create mode 100644 drivers/clk/socfpga/clk-s10.c
 create mode 100644 drivers/clk/socfpga/stratix10-clk.h
drivers/clk/Makefile +1 -0
index 71ec41e..80ab422 100644
@@ -88,6 +88,7 @@ obj-$(CONFIG_ARCH_SOCFPGA)		+= socfpga/
 obj-$(CONFIG_PLAT_SPEAR)		+= spear/
 obj-$(CONFIG_ARCH_SPRD)			+= sprd/
 obj-$(CONFIG_ARCH_STI)			+= st/
+obj-$(CONFIG_ARCH_STRATIX10)		+= socfpga/
 obj-$(CONFIG_ARCH_SUNXI)		+= sunxi/
 obj-$(CONFIG_ARCH_SUNXI)		+= sunxi-ng/
 obj-$(CONFIG_ARCH_TEGRA)		+= tegra/
drivers/clk/socfpga/Makefile +4 -5
index 9146c20..ce5aa78 100644
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-y += clk.o
-obj-y += clk-gate.o
-obj-y += clk-pll.o
-obj-y += clk-periph.o
-obj-y += clk-pll-a10.o clk-periph-a10.o clk-gate-a10.o
+obj-$(CONFIG_ARCH_SOCFPGA) += clk.o clk-gate.o clk-pll.o clk-periph.o
+obj-$(CONFIG_ARCH_SOCFPGA) += clk-pll-a10.o clk-periph-a10.o clk-gate-a10.o
+obj-$(CONFIG_ARCH_STRATIX10) += clk-s10.o
+obj-$(CONFIG_ARCH_STRATIX10) += clk-pll-s10.o clk-periph-s10.o clk-gate-s10.o
drivers/clk/socfpga/clk-gate-s10.c new file +124 -0

124 lines not on this page · raw message

drivers/clk/socfpga/clk-periph-s10.c new file +148 -0

148 lines not on this page · raw message

drivers/clk/socfpga/clk-pll-s10.c new file +145 -0

145 lines not on this page · raw message

drivers/clk/socfpga/clk-s10.c new file +345 -0

345 lines not on this page · raw message

drivers/clk/socfpga/clk.h +4 -0
index 9cf1230..26c3a26 100644
@@ -54,9 +54,11 @@ struct socfpga_gate_clk {
 	char *parent_name;
 	u32 fixed_div;
 	void __iomem *div_reg;
+	void __iomem *bypass_reg;
 	struct regmap *sys_mgr_base_addr;
 	u32 width;	/* only valid if div_reg != 0 */
 	u32 shift;	/* only valid if div_reg != 0 */
+	u32 bypass_shift;      /* only valid if bypass_reg != 0 */
 	u32 clk_phase[2];
 };
 
@@ -65,8 +67,10 @@ struct socfpga_periph_clk {
 	char *parent_name;
 	u32 fixed_div;
 	void __iomem *div_reg;
+	void __iomem *bypass_reg;
 	u32 width;      /* only valid if div_reg != 0 */
 	u32 shift;      /* only valid if div_reg != 0 */
+	u32 bypass_shift;      /* only valid if bypass_reg != 0 */
 };
 
 #endif /* SOCFPGA_CLK_H */
drivers/clk/socfpga/stratix10-clk.h new file +80 -0

80 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#4 lore raw

PATCH v7 3/3 clk: socfpga: stratix10: add clock driver for Stratix10 platform

Quoting Dinh Nguyen (2018-03-21 07:20:12)

Quoted 6 lines

Add a clock driver for the Stratix10 SoC. The driver is similar to the Cyclone5/Arria10 platforms, with the exception that this driver only uses one single clock binding.

---

Applied to clk-next but I made some fixes. Also, it would be nice if you could follow up with using the platform driver APIs to map memory and also make sure to implement a driver remove path or block it with the suppress attribute.

drivers/clk/socfpga/clk-gate-s10.c +2 -1
index 71ca3c045a42..eee2d48ab656 100644
@@ -4,6 +4,7 @@
  */
 #include <linux/clk-provider.h>
 #include <linux/slab.h>
+#include "stratix10-clk.h"
 #include "clk.h"
 
 #define SOCFPGA_CS_PDBG_CLK	"cs_pdbg_clk"
@@ -63,7 +64,7 @@ static const struct clk_ops dbgclk_ops = {
 	.get_parent = socfpga_gate_get_parent,
 };
 
-struct clk *s10_register_gate(char *name, const char *parent_name,
+struct clk *s10_register_gate(const char *name, const char *parent_name,
 			      const char * const *parent_names,
 			      u8 num_parents, unsigned long flags,
 			      void __iomem *regbase, unsigned long gate_reg,
drivers/clk/socfpga/clk-periph-s10.c +3 -2
index 6021ac1b0667..568f59b58ddf 100644
@@ -5,6 +5,7 @@
 #include <linux/slab.h>
 #include <linux/clk-provider.h>
 
+#include "stratix10-clk.h"
 #include "clk.h"
 
 #define CLK_MGR_FREE_SHIFT		16
@@ -71,7 +72,7 @@ static const struct clk_ops peri_cnt_clk_ops = {
 	.get_parent = clk_periclk_get_parent,
 };
 
-struct clk *s10_register_periph(char *name, const char *parent_name,
+struct clk *s10_register_periph(const char *name, const char *parent_name,
 				const char * const *parent_names,
 				u8 num_parents, unsigned long flags,
 				void __iomem *reg, unsigned long offset)
@@ -103,7 +104,7 @@ struct clk *s10_register_periph(char *name, const char *parent_name,
 	return clk;
 }
 
-struct clk *s10_register_cnt_periph(char *name, const char *parent_name,
+struct clk *s10_register_cnt_periph(const char *name, const char *parent_name,
 				    const char * const *parent_names,
 				    u8 num_parents, unsigned long flags,
 				    void __iomem *regbase, unsigned long offset,
drivers/clk/socfpga/clk-pll-s10.c +1 -0
index ef24ca7a0cc4..2d5d8b43727e 100644
@@ -5,6 +5,7 @@
 #include <linux/slab.h>
 #include <linux/clk-provider.h>
 
+#include "stratix10-clk.h"
 #include "clk.h"
 
 /* Clock Manager offsets */
drivers/clk/socfpga/clk-s10.c +4 -4
index 27a08b3b30e6..3a11c382a663 100644
@@ -48,11 +48,11 @@ static const struct stratix10_pll_clock s10_pll_clks[] = {
 };
 
 static const struct stratix10_perip_c_clock s10_main_perip_c_clks[] = {
-	{ STRATIX10_MAIN_MPU_BASE_CLK, "main_mpu_base_clk", "main_pll", 0, 1, 0, 0x84},
-	{ STRATIX10_MAIN_NOC_BASE_CLK, "main_noc_base_clk", "main_pll", 0, 1, 0, 0x88},
-	{ STRATIX10_PERI_MPU_BASE_CLK, "peri_mpu_base_clk", "periph_pll", 0, 1, 0,
+	{ STRATIX10_MAIN_MPU_BASE_CLK, "main_mpu_base_clk", "main_pll", NULL, 1, 0, 0x84},
+	{ STRATIX10_MAIN_NOC_BASE_CLK, "main_noc_base_clk", "main_pll", NULL, 1, 0, 0x88},
+	{ STRATIX10_PERI_MPU_BASE_CLK, "peri_mpu_base_clk", "periph_pll", NULL, 1, 0,
 	  0xF4},
-	{ STRATIX10_PERI_NOC_BASE_CLK, "peri_noc_base_clk", "periph_pll", 0, 1, 0,
+	{ STRATIX10_PERI_NOC_BASE_CLK, "peri_noc_base_clk", "periph_pll", NULL, 1, 0,
 	  0xF8},
 };
 
drivers/clk/socfpga/stratix10-clk.h +1 -1
index f6c9291ed315..e8e121907952 100644
@@ -76,5 +76,5 @@ struct clk *s10_register_gate(const char *, const char *,
 			      unsigned long, void __iomem *,
 			      unsigned long, unsigned long,
 			      unsigned long, unsigned long, u8,
-			      unsigned long, unsigned long, u8);
+			      unsigned long, u8, u8);
maintainer Applied
#5 lore raw

PATCH v7 1/3 dt-bindings: documentation: add clock bindings information for Stratix10

In reply to Dinh Nguyen

Quoting Dinh Nguyen (2018-03-21 07:20:10)

Quoted 7 lines

Document that Stratix10 clock bindings, and add the clock header file. The clock header is an enumeration of all the different clocks on the Stratix10 platform.

---

Applied to clk-next