Skip to contentSkip to conversation

Add clocks for Unisoc's SC9863A

PATCH Superseded Chunyan Zhang 3 participants 12 messages Dec 16, 2019 – Jan 5, 2020

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Chunyan Zhang

author reviewer
#0 lore raw

v2 cover Add clocks for Unisoc's SC9863A

Add SC9863A specific clock driver and devicetree bindings for it.

Also this patchset added support gate clock for pll which need to wait a certain time for stable after being switched on.

Changes from v1:
* Address comments:
- Remove redefine things;
- Switch DT bindings to yaml schema;
- Add macros for the new way of specifying clk parents;
- Switch to use the new way of specifying clk parents;
- Clean CLK_IGNORE_UNUSED flags for some SC9863A clocks;
- Drop the module alias;
- Use device_get_match_data() instead of of_match_node();

* Add Rob's reviewed-by on patch 2.

Chunyan Zhang (5):
dt-bindings: clk: sprd: rename the common file name sprd.txt to SoC
specific
dt-bindings: clk: sprd: add bindings for sc9863a clock controller
clk: sprd: Add dt-bindings include file for SC9863A
clk: sprd: Add macros for referencing parents without strings
clk: sprd: add clocks support for SC9863A

Xiaolong Zhang (1):
clk: sprd: add gate for pll clocks

 .../clock/{sprd.txt => sprd,sc9860-clk.txt}   |    2 +-
 .../bindings/clock/sprd,sc9863a-clk.yaml      |   77 +
 drivers/clk/sprd/Kconfig                      |    8 +
 drivers/clk/sprd/Makefile                     |    1 +
 drivers/clk/sprd/composite.h                  |   39 +-
 drivers/clk/sprd/div.h                        |   20 +-
 drivers/clk/sprd/gate.c                       |   17 +
 drivers/clk/sprd/gate.h                       |  120 +-
 drivers/clk/sprd/mux.h                        |   28 +-
 drivers/clk/sprd/pll.h                        |   55 +-
 drivers/clk/sprd/sc9863a-clk.c                | 1835 +++++++++++++++++
 include/dt-bindings/clock/sprd,sc9863a-clk.h  |  345 ++++
 12 files changed, 2494 insertions(+), 53 deletions(-)
 rename Documentation/devicetree/bindings/clock/{sprd.txt => sprd,sc9860-clk.txt} (98%)
 create mode 100644 Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
 create mode 100644 drivers/clk/sprd/sc9863a-clk.c
 create mode 100644 include/dt-bindings/clock/sprd,sc9863a-clk.h
Signature · 1 line
2.20.1
author reviewer
#1 lore raw

PATCH v2 1/6 clk: sprd: add gate for pll clocks

From: Xiaolong Zhang <[email protected]>

Some sprd's gate clocks are used to the switch of pll, which need to wait a certain time for stable after being enabled.

---
 drivers/clk/sprd/gate.c | 17 +++++++++++++++++
 drivers/clk/sprd/gate.h | 21 +++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)
drivers/clk/sprd/gate.c +17 -0
index f59d1936b412..574cfc116bbc 100644
@@ -79,6 +79,17 @@ static int sprd_sc_gate_enable(struct clk_hw *hw)
 
 	return 0;
 }
+
+static int sprd_pll_sc_gate_prepare(struct clk_hw *hw)
+{
+	struct sprd_gate *sg = hw_to_sprd_gate(hw);
+
+	clk_sc_gate_toggle(sg, true);
+	udelay(sg->udelay);
+
+	return 0;
+}
+
 static int sprd_gate_is_enabled(struct clk_hw *hw)
 {
 	struct sprd_gate *sg = hw_to_sprd_gate(hw);
@@ -109,3 +120,9 @@ const struct clk_ops sprd_sc_gate_ops = {
 };
 EXPORT_SYMBOL_GPL(sprd_sc_gate_ops);
 
+const struct clk_ops sprd_pll_sc_gate_ops = {
+	.unprepare	= sprd_sc_gate_disable,
+	.prepare	= sprd_pll_sc_gate_prepare,
+	.is_enabled	= sprd_gate_is_enabled,
+};
+EXPORT_SYMBOL_GPL(sprd_pll_sc_gate_ops);
drivers/clk/sprd/gate.h +19 -2
index dc352ea55e1f..d380d77b8dce 100644
@@ -14,16 +14,19 @@ struct sprd_gate {
 	u32			enable_mask;
 	u16			flags;
 	u16			sc_offset;
+	u16			udelay;
 
 	struct sprd_clk_common	common;
 };
 
-#define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset,	\
-			     _enable_mask, _flags, _gate_flags, _ops)	\
+#define SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg,	\
+				    _sc_offset, _enable_mask, _flags,	\
+				    _gate_flags, _udelay, _ops)		\
 	struct sprd_gate _struct = {					\
 		.enable_mask	= _enable_mask,				\
 		.sc_offset	= _sc_offset,				\
 		.flags		= _gate_flags,				\
+		.udelay		= _udelay,				\
 		.common	= {						\
 			.regmap		= NULL,				\
 			.reg		= _reg,				\
@@ -34,6 +37,12 @@ struct sprd_gate {
 		}							\
 	}
 
+#define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset,	\
+			     _enable_mask, _flags, _gate_flags, _ops)	\
+	SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg,	\
+				    _sc_offset, _enable_mask, _flags,	\
+				    _gate_flags, 0, _ops)
+
 #define SPRD_GATE_CLK(_struct, _name, _parent, _reg,			\
 		      _enable_mask, _flags, _gate_flags)		\
 	SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, 0,		\
@@ -46,6 +55,13 @@ struct sprd_gate {
 			     _enable_mask, _flags, _gate_flags,		\
 			     &sprd_sc_gate_ops)
 
+#define SPRD_PLL_SC_GATE_CLK(_struct, _name, _parent, _reg, _sc_offset,	\
+			    _enable_mask, _flags, _gate_flags, _udelay)	\
+	SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg,	\
+				    _sc_offset,	_enable_mask, _flags,	\
+				    _gate_flags, _udelay,		\
+				    &sprd_pll_sc_gate_ops)
+
 static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw)
 {
 	struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
@@ -55,5 +71,6 @@ static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw)
 
 extern const struct clk_ops sprd_gate_ops;
 extern const struct clk_ops sprd_sc_gate_ops;
+extern const struct clk_ops sprd_pll_sc_gate_ops;
 
 #endif /* _SPRD_GATE_H_ */
Signature · 1 line
2.20.1
author reviewer
#2 lore raw

PATCH v2 2/6 dt-bindings: clk: sprd: rename the common file name sprd.txt to SoC specific

In reply to Chunyan Zhang

From: Chunyan Zhang <[email protected]>

Only SC9860 clocks were described in sprd.txt, rename it with a SoC specific name, so that we can add more SoC support.

---
 .../devicetree/bindings/clock/{sprd.txt => sprd,sc9860-clk.txt} | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 rename Documentation/devicetree/bindings/clock/{sprd.txt => sprd,sc9860-clk.txt} (98%)
Documentation/devicetree/bindings/clock/sprd,sc9860-clk.txt renamed from Documentation/devicetree/bindings/clock/sprd.txt +1 -1
similarity index 98%
rename from Documentation/devicetree/bindings/clock/sprd.txt
rename to Documentation/devicetree/bindings/clock/sprd,sc9860-clk.txt
index e9d179e882d9..aaaf02ca2a6a 100644
@@ -1,4 +1,4 @@
-Spreadtrum Clock Binding
+Spreadtrum SC9860 Clock Binding
 ------------------------
 
 Required properties:
Signature · 1 line
2.20.1
author reviewer
#3 lore raw

PATCH v2 3/6 dt-bindings: clk: sprd: add bindings for sc9863a clock controller

In reply to Chunyan Zhang

From: Chunyan Zhang <[email protected]>

add a new bindings to describe sc9863a clock compatible string.

---
 .../bindings/clock/sprd,sc9863a-clk.yaml      | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +77 -0
new file mode 100644
index 000000000000..881f0a0287e5
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2019 Unisoc Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/clock/sprd,sc9863a-clk.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: SC9863A Clock Control Unit Device Tree Bindings
+
+maintainers:
+  - Orson Zhai <[email protected]>
+  - Baolin Wang <[email protected]>
+  - Chunyan Zhang <[email protected]>
+
+properties:
+  "#clock-cells":
+    const: 1
+
+  compatible :
+    enum:
+      - sprd,sc9863a-ap-clk
+      - sprd,sc9863a-pmu-gate
+      - sprd,sc9863a-pll
+      - sprd,sc9863a-mpll
+      - sprd,sc9863a-rpll
+      - sprd,sc9863a-dpll
+      - sprd,sc9863a-aon-clk
+      - sprd,sc9863a-apahb-gate
+      - sprd,sc9863a-aonapb-gate
+      - sprd,sc9863a-mm-gate
+      - sprd,sc9863a-mm-clk
+      - sprd,sc9863a-vspahb-gate
+      - sprd,sc9863a-apapb-gate
+
+  clocks:
+    description: |
+      The input parent clock(s) phandle for this clock, only list fixed
+      clocks which are decleared in devicetree.
+
+  clock-names:
+    description: |
+      Clock name strings used for driver to reference.
+
+  reg:
+    description: |
+      Contain the registers base address and length. It must be configured
+      only if no 'sprd,syscon' under the node.
+
+  sprd,syscon:
+    $ref: '/schemas/types.yaml#/definitions/phandle'
+    description: |
+      The phandle to the syscon which is in the same address area with
+      the clock, and so we can get regmap for the clocks from the
+      syscon device.
+
+required:
+  - compatible
+  - '#clock-cells'
+
+examples:
+  - |
+    ap_clk: clock-controller@21500000 {
+      compatible = "sprd,sc9863a-ap-clk";
+      reg = <0 0x21500000 0 0x1000>;
+      clocks = <&ext_32k>, <&ext_26m>;
+      clock-names = "ext-32k", "ext-26m";
+      #clock-cells = <1>;
+    };
+
+  - |
+    apahb_gate: apahb-gate {
+      compatible = "sprd,sc9863a-apahb-gate";
+      sprd,syscon = <&ap_ahb_regs>;
+      #clock-cells = <1>;
+    };
+
+...
Signature · 1 line
2.20.1
author reviewer
#7 lore raw

PATCH v2 4/6 clk: sprd: Add dt-bindings include file for SC9863A

In reply to Chunyan Zhang

From: Chunyan Zhang <[email protected]>

This file defines all SC9863A clock indexes, it should be included in the device tree in which there's device using the clocks.

---
 include/dt-bindings/clock/sprd,sc9863a-clk.h | 345 +++++++++++++++++++
 1 file changed, 345 insertions(+)
 create mode 100644 include/dt-bindings/clock/sprd,sc9863a-clk.h
include/dt-bindings/clock/sprd,sc9863a-clk.h new file +345 -0
new file mode 100644
index 000000000000..cc7977ebbf76
@@ -0,0 +1,345 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Unisoc SC9863A platform clocks
+ *
+ * Copyright (C) 2019, Unisoc Communications Inc.
+ */
+
+#ifndef _DT_BINDINGS_CLK_SC9863A_H_
+#define _DT_BINDINGS_CLK_SC9863A_H_
+
+#define CLK_MPLL0_GATE		0
+#define CLK_DPLL0_GATE		1
+#define CLK_LPLL_GATE		2
+#define CLK_GPLL_GATE		3
+#define CLK_DPLL1_GATE		4
+#define CLK_MPLL1_GATE		5
+#define CLK_MPLL2_GATE		6
+#define CLK_ISPPLL_GATE		7
+#define CLK_PMU_APB_NUM		(CLK_ISPPLL_GATE + 1)
+
+#define CLK_AUDIO_GATE		0
+#define CLK_RPLL		1
+#define CLK_RPLL_390M		2
+#define CLK_RPLL_260M		3
+#define CLK_RPLL_195M		4
+#define CLK_RPLL_26M		5
+#define CLK_ANLG_PHY_G5_NUM	(CLK_RPLL_26M + 1)
+
+#define CLK_TWPLL		0
+#define CLK_TWPLL_768M		1
+#define CLK_TWPLL_384M		2
+#define CLK_TWPLL_192M		3
+#define CLK_TWPLL_96M		4
+#define CLK_TWPLL_48M		5
+#define CLK_TWPLL_24M		6
+#define CLK_TWPLL_12M		7
+#define CLK_TWPLL_512M		8
+#define CLK_TWPLL_256M		9
+#define CLK_TWPLL_128M		10
+#define CLK_TWPLL_64M		11
+#define CLK_TWPLL_307M2		12
+#define CLK_TWPLL_219M4		13
+#define CLK_TWPLL_170M6		14
+#define CLK_TWPLL_153M6		15
+#define CLK_TWPLL_76M8		16
+#define CLK_TWPLL_51M2		17
+#define CLK_TWPLL_38M4		18
+#define CLK_TWPLL_19M2		19
+#define CLK_LPLL		20
+#define CLK_LPLL_409M6		21
+#define CLK_LPLL_245M76		22
+#define CLK_GPLL		23
+#define CLK_ISPPLL		24
+#define CLK_ISPPLL_468M		25
+#define CLK_ANLG_PHY_G1_NUM	(CLK_ISPPLL_468M + 1)
+
+#define CLK_DPLL0		0
+#define CLK_DPLL1		1
+#define CLK_DPLL0_933M		2
+#define CLK_DPLL0_622M3		3
+#define CLK_DPLL0_400M		4
+#define CLK_DPLL0_266M7		5
+#define CLK_DPLL0_123M1		6
+#define CLK_DPLL0_50M		7
+#define CLK_ANLG_PHY_G7_NUM	(CLK_DPLL0_50M + 1)
+
+#define CLK_MPLL0		0
+#define CLK_MPLL1		1
+#define CLK_MPLL2		2
+#define CLK_MPLL2_675M		3
+#define CLK_ANLG_PHY_G4_NUM	(CLK_MPLL2_675M + 1)
+
+#define CLK_AP_APB		0
+#define CLK_AP_CE		1
+#define CLK_NANDC_ECC		2
+#define CLK_NANDC_26M		3
+#define CLK_EMMC_32K		4
+#define CLK_SDIO0_32K		5
+#define CLK_SDIO1_32K		6
+#define CLK_SDIO2_32K		7
+#define CLK_OTG_UTMI		8
+#define CLK_AP_UART0		9
+#define CLK_AP_UART1		10
+#define CLK_AP_UART2		11
+#define CLK_AP_UART3		12
+#define CLK_AP_UART4		13
+#define CLK_AP_I2C0		14
+#define CLK_AP_I2C1		15
+#define CLK_AP_I2C2		16
+#define CLK_AP_I2C3		17
+#define CLK_AP_I2C4		18
+#define CLK_AP_I2C5		19
+#define CLK_AP_I2C6		20
+#define CLK_AP_SPI0		21
+#define CLK_AP_SPI1		22
+#define CLK_AP_SPI2		23
+#define CLK_AP_SPI3		24
+#define CLK_AP_IIS0		25
+#define CLK_AP_IIS1		26
+#define CLK_AP_IIS2		27
+#define CLK_SIM0		28
+#define CLK_SIM0_32K		29
+#define CLK_AP_CLK_NUM		(CLK_SIM0_32K + 1)
+
+#define CLK_13M			0
+#define CLK_6M5			1
+#define CLK_4M3			2
+#define CLK_2M			3
+#define CLK_250K		4
+#define CLK_RCO_25M		5
+#define CLK_RCO_4M		6
+#define CLK_RCO_2M		7
+#define CLK_EMC			8
+#define CLK_AON_APB		9
+#define CLK_ADI			10
+#define CLK_AUX0		11
+#define CLK_AUX1		12
+#define CLK_AUX2		13
+#define CLK_PROBE		14
+#define CLK_PWM0		15
+#define CLK_PWM1		16
+#define CLK_PWM2		17
+#define CLK_AON_THM		18
+#define CLK_AUDIF		19
+#define CLK_CPU_DAP		20
+#define CLK_CPU_TS		21
+#define CLK_DJTAG_TCK		22
+#define CLK_EMC_REF		23
+#define CLK_CSSYS		24
+#define CLK_AON_PMU		25
+#define CLK_PMU_26M		26
+#define CLK_AON_TMR		27
+#define CLK_POWER_CPU		28
+#define CLK_AP_AXI		29
+#define CLK_SDIO0_2X		30
+#define CLK_SDIO1_2X		31
+#define CLK_SDIO2_2X		32
+#define CLK_EMMC_2X		33
+#define CLK_DPU			34
+#define CLK_DPU_DPI		35
+#define CLK_OTG_REF		36
+#define CLK_SDPHY_APB		37
+#define CLK_ALG_IO_APB		38
+#define CLK_GPU_CORE		39
+#define CLK_GPU_SOC		40
+#define CLK_MM_EMC		41
+#define CLK_MM_AHB		42
+#define CLK_BPC			43
+#define CLK_DCAM_IF		44
+#define CLK_ISP			45
+#define CLK_JPG			46
+#define CLK_CPP			47
+#define CLK_SENSOR0		48
+#define CLK_SENSOR1		49
+#define CLK_SENSOR2		50
+#define CLK_MM_VEMC		51
+#define CLK_MM_VAHB		52
+#define CLK_VSP			53
+#define CLK_CORE0		54
+#define CLK_CORE1		55
+#define CLK_CORE2		56
+#define CLK_CORE3		57
+#define CLK_CORE4		58
+#define CLK_CORE5		59
+#define CLK_CORE6		60
+#define CLK_CORE7		61
+#define CLK_SCU			62
+#define CLK_ACE			63
+#define CLK_AXI_PERIPH		64
+#define CLK_AXI_ACP		65
+#define CLK_ATB			66
+#define CLK_DEBUG_APB		67
+#define CLK_GIC			68
+#define CLK_PERIPH		69
+#define CLK_AON_CLK_NUM		(CLK_VSP + 1)
+
+#define CLK_OTG_EB		0
+#define CLK_DMA_EB		1
+#define CLK_CE_EB		2
+#define CLK_NANDC_EB		3
+#define CLK_SDIO0_EB		4
+#define CLK_SDIO1_EB		5
+#define CLK_SDIO2_EB		6
+#define CLK_EMMC_EB		7
+#define CLK_EMMC_32K_EB		8
+#define CLK_SDIO0_32K_EB	9
+#define CLK_SDIO1_32K_EB	10
+#define CLK_SDIO2_32K_EB	11
+#define CLK_NANDC_26M_EB	12
+#define CLK_DMA_EB2		13
+#define CLK_CE_EB2		14
+#define CLK_AP_AHB_GATE_NUM	(CLK_CE_EB2 + 1)
+
+#define CLK_GPIO_EB		0
+#define CLK_PWM0_EB		1
+#define CLK_PWM1_EB		2
+#define CLK_PWM2_EB		3
+#define CLK_PWM3_EB		4
+#define CLK_KPD_EB		5
+#define CLK_AON_SYST_EB		6
+#define CLK_AP_SYST_EB		7
+#define CLK_AON_TMR_EB		8
+#define CLK_EFUSE_EB		9
+#define CLK_EIC_EB		10
+#define CLK_INTC_EB		11
+#define CLK_ADI_EB		12
+#define CLK_AUDIF_EB		13
+#define CLK_AUD_EB		14
+#define CLK_VBC_EB		15
+#define CLK_PIN_EB		16
+#define CLK_AP_WDG_EB		17
+#define CLK_MM_EB		18
+#define CLK_AON_APB_CKG_EB	19
+#define CLK_CA53_TS0_EB		20
+#define CLK_CA53_TS1_EB		21
+#define CLK_CS53_DAP_EB		22
+#define CLK_PMU_EB		23
+#define CLK_THM_EB		24
+#define CLK_AUX0_EB		25
+#define CLK_AUX1_EB		26
+#define CLK_AUX2_EB		27
+#define CLK_PROBE_EB		28
+#define CLK_EMC_REF_EB		29
+#define CLK_CA53_WDG_EB		30
+#define CLK_AP_TMR1_EB		31
+#define CLK_AP_TMR2_EB		32
+#define CLK_DISP_EMC_EB		33
+#define CLK_ZIP_EMC_EB		34
+#define CLK_GSP_EMC_EB		35
+#define CLK_MM_VSP_EB		36
+#define CLK_MDAR_EB		37
+#define CLK_RTC4M0_CAL_EB	38
+#define CLK_RTC4M1_CAL_EB	39
+#define CLK_DJTAG_EB		40
+#define CLK_MBOX_EB		41
+#define CLK_AON_DMA_EB		42
+#define CLK_AON_APB_DEF_EB	43
+#define CLK_CA5_TS0_EB		44
+#define CLK_DBG_EB		45
+#define CLK_DBG_EMC_EB		46
+#define CLK_CROSS_TRIG_EB	47
+#define CLK_SERDES_DPHY_EB	48
+#define CLK_ARCH_RTC_EB		49
+#define CLK_KPD_RTC_EB		50
+#define CLK_AON_SYST_RTC_EB	51
+#define CLK_AP_SYST_RTC_EB	52
+#define CLK_AON_TMR_RTC_EB	53
+#define CLK_AP_TMR0_RTC_EB	54
+#define CLK_EIC_RTC_EB		55
+#define CLK_EIC_RTCDV5_EB	56
+#define CLK_AP_WDG_RTC_EB	57
+#define CLK_CA53_WDG_RTC_EB	58
+#define CLK_THM_RTC_EB		59
+#define CLK_ATHMA_RTC_EB	60
+#define CLK_GTHMA_RTC_EB	61
+#define CLK_ATHMA_RTC_A_EB	62
+#define CLK_GTHMA_RTC_A_EB	63
+#define CLK_AP_TMR1_RTC_EB	64
+#define CLK_AP_TMR2_RTC_EB	65
+#define CLK_DXCO_LC_RTC_EB	66
+#define CLK_BB_CAL_RTC_EB	67
+#define CLK_GNU_EB		68
+#define CLK_DISP_EB		69
+#define CLK_MM_EMC_EB		70
+#define CLK_POWER_CPU_EB	71
+#define CLK_HW_I2C_EB		72
+#define CLK_MM_VSP_EMC_EB	73
+#define CLK_VSP_EB		74
+#define CLK_CSSYS_EB		75
+#define CLK_DMC_EB		76
+#define CLK_ROSC_EB		77
+#define CLK_S_D_CFG_EB		78
+#define CLK_S_D_REF_EB		79
+#define CLK_B_DMA_EB		80
+#define CLK_ANLG_EB		81
+#define CLK_ANLG_APB_EB		82
+#define CLK_BSMTMR_EB		83
+#define CLK_AP_AXI_EB		84
+#define CLK_AP_INTC0_EB		85
+#define CLK_AP_INTC1_EB		86
+#define CLK_AP_INTC2_EB		87
+#define CLK_AP_INTC3_EB		88
+#define CLK_AP_INTC4_EB		89
+#define CLK_AP_INTC5_EB		90
+#define CLK_SCC_EB		91
+#define CLK_DPHY_CFG_EB		92
+#define CLK_DPHY_REF_EB		93
+#define CLK_CPHY_CFG_EB		94
+#define CLK_OTG_REF_EB		95
+#define CLK_SERDES_EB		96
+#define CLK_AON_AP_EMC_EB	97
+#define CLK_AON_APB_GATE_NUM	(CLK_AON_AP_EMC_EB + 1)
+
+#define CLK_MAHB_CKG_EB		0
+#define CLK_MDCAM_EB		1
+#define CLK_MISP_EB		2
+#define CLK_MAHBCSI_EB		3
+#define CLK_MCSI_S_EB		4
+#define CLK_MCSI_T_EB		5
+#define CLK_DCAM_AXI_EB		6
+#define CLK_ISP_AXI_EB		7
+#define CLK_MCSI_EB		8
+#define CLK_MCSI_S_CKG_EB	9
+#define CLK_MCSI_T_CKG_EB	10
+#define CLK_SENSOR0_EB		11
+#define CLK_SENSOR1_EB		12
+#define CLK_SENSOR2_EB		13
+#define CLK_MCPHY_CFG_EB	14
+#define CLK_MM_GATE_NUM		(CLK_MCPHY_CFG_EB + 1)
+
+#define CLK_MIPI_CSI		0
+#define CLK_MIPI_CSI_S		1
+#define CLK_MIPI_CSI_M		2
+#define CLK_MM_CLK_NUM		(CLK_MIPI_CSI_M + 1)
+
+#define CLK_VCKG_EB		0
+#define CLK_VVSP_EB		1
+#define CLK_VJPG_EB		2
+#define CLK_VCPP_EB		3
+#define CLK_VSP_AHB_GATE_NUM	(CLK_VCPP_EB + 1)
+
+#define CLK_SIM0_EB		0
+#define CLK_IIS0_EB		1
+#define CLK_IIS1_EB		2
+#define CLK_IIS2_EB		3
+#define CLK_SPI0_EB		4
+#define CLK_SPI1_EB		5
+#define CLK_SPI2_EB		6
+#define CLK_I2C0_EB		7
+#define CLK_I2C1_EB		8
+#define CLK_I2C2_EB		9
+#define CLK_I2C3_EB		10
+#define CLK_I2C4_EB		11
+#define CLK_UART0_EB		12
+#define CLK_UART1_EB		13
+#define CLK_UART2_EB		14
+#define CLK_UART3_EB		15
+#define CLK_UART4_EB		16
+#define CLK_SIM0_32K_EB		17
+#define CLK_SPI3_EB		18
+#define CLK_I2C5_EB		19
+#define CLK_I2C6_EB		20
+#define CLK_AP_APB_GATE_NUM	(CLK_I2C6_EB + 1)
+
+#endif /* _DT_BINDINGS_CLK_SC9863A_H_ */
Signature · 1 line
2.20.1
author reviewer
#9 lore raw

PATCH v2 5/6 clk: sprd: Add macros for referencing parents without strings

In reply to Chunyan Zhang

From: Chunyan Zhang <[email protected]>

With the new clk parenting code, clk_init_data was expanded to include .parent_hws and .parent_data, for clk drivers to specify parents without name strings of clocks.

Also some macros were added for using these two items to reference clock parents. Based on that, this patch expands macros for sprd clocks:

- SPRD_*_DATA, take an array of struct clk_parent_data * as its parents which should be a combination of .fw_name (devicetree clock-names), .hw (pointers to a local struct clk_hw).

- SPRD_*_HW, take a local struct clk_hw pointer, instead of a string, as its parent.

- SPRD_*_FW_NAME, take a string of clock-names decleared in the device tree as the clock parent.

---
 drivers/clk/sprd/composite.h |  39 +++++++++----
 drivers/clk/sprd/div.h       |  20 +++++--
 drivers/clk/sprd/gate.h      | 109 ++++++++++++++++++++++++++++++-----
 drivers/clk/sprd/mux.h       |  28 ++++++---
 drivers/clk/sprd/pll.h       |  55 ++++++++++++------
 5 files changed, 196 insertions(+), 55 deletions(-)
drivers/clk/sprd/composite.h +28 -11
index 04ab3f587ee2..adbabbe596b7 100644
@@ -18,26 +18,43 @@ struct sprd_comp {
 	struct sprd_clk_common	common;
 };
 
-#define SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, _table,	\
-			_mshift, _mwidth, _dshift, _dwidth, _flags)	\
+#define SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table,	\
+				 _mshift, _mwidth, _dshift, _dwidth,	\
+				 _flags, _fn)				\
 	struct sprd_comp _struct = {					\
 		.mux	= _SPRD_MUX_CLK(_mshift, _mwidth, _table),	\
 		.div	= _SPRD_DIV_CLK(_dshift, _dwidth),		\
 		.common = {						\
 			.regmap		= NULL,				\
 			.reg		= _reg,				\
-			.hw.init = CLK_HW_INIT_PARENTS(_name,		\
-						       _parent,		\
-						       &sprd_comp_ops,	\
-						       _flags),		\
+			.hw.init = _fn(_name, _parent,			\
+				       &sprd_comp_ops, _flags),		\
 			 }						\
 	}
 
-#define SPRD_COMP_CLK(_struct, _name, _parent, _reg, _mshift,	\
-			_mwidth, _dshift, _dwidth, _flags)	\
-	SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg,	\
-			    NULL, _mshift, _mwidth,		\
-			    _dshift, _dwidth, _flags)
+#define SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, _table,	\
+			    _mshift, _mwidth, _dshift, _dwidth, _flags)	\
+	SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table,	\
+				 _mshift, _mwidth, _dshift, _dwidth,	\
+				 _flags, CLK_HW_INIT_PARENTS)
+
+#define SPRD_COMP_CLK(_struct, _name, _parent, _reg, _mshift,		\
+		      _mwidth, _dshift, _dwidth, _flags)		\
+	SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, NULL,	\
+			    _mshift, _mwidth, _dshift, _dwidth, _flags)
+
+#define SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, _table,	\
+				 _mshift, _mwidth, _dshift,		\
+				 _dwidth, _flags)			\
+	SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table,	\
+				 _mshift, _mwidth, _dshift, _dwidth,	\
+				 _flags, CLK_HW_INIT_PARENTS_DATA)
+
+#define SPRD_COMP_CLK_DATA(_struct, _name, _parent, _reg, _mshift,	\
+			   _mwidth, _dshift, _dwidth, _flags)		\
+	SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg,	NULL,	\
+				 _mshift, _mwidth, _dshift, _dwidth,	\
+				 _flags)
 
 static inline struct sprd_comp *hw_to_sprd_comp(const struct clk_hw *hw)
 {
drivers/clk/sprd/div.h +14 -6
index 87510e3d0e14..6acfe6b179fc 100644
@@ -35,20 +35,28 @@ struct sprd_div {
 	struct sprd_clk_common	common;
 };
 
-#define SPRD_DIV_CLK(_struct, _name, _parent, _reg,			\
-			_shift, _width, _flags)				\
+#define SPRD_DIV_CLK_HW_INIT_FN(_struct, _name, _parent, _reg,		\
+				_shift, _width, _flags, _fn)		\
 	struct sprd_div _struct = {					\
 		.div	= _SPRD_DIV_CLK(_shift, _width),		\
 		.common	= {						\
 			.regmap		= NULL,				\
 			.reg		= _reg,				\
-			.hw.init	= CLK_HW_INIT(_name,		\
-						      _parent,		\
-						      &sprd_div_ops,	\
-						      _flags),		\
+			.hw.init	= _fn(_name, _parent,		\
+					      &sprd_div_ops, _flags),	\
 		}							\
 	}
 
+#define SPRD_DIV_CLK(_struct, _name, _parent, _reg,			\
+		     _shift, _width, _flags)				\
+	SPRD_DIV_CLK_HW_INIT_FN(_struct, _name, _parent, _reg,		\
+				_shift, _width, _flags, CLK_HW_INIT)
+
+#define SPRD_DIV_CLK_HW(_struct, _name, _parent, _reg,			\
+			_shift, _width, _flags)				\
+	SPRD_DIV_CLK_HW_INIT_FN(_struct, _name, _parent, _reg,		\
+				_shift, _width, _flags, CLK_HW_INIT_HW)
+
 static inline struct sprd_div *hw_to_sprd_div(const struct clk_hw *hw)
 {
 	struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
drivers/clk/sprd/gate.h +96 -13

143 lines not on this page · raw message

drivers/clk/sprd/mux.h +21 -7
index 892e4191cc7f..f3cc31dae06f 100644
@@ -36,26 +36,40 @@ struct sprd_mux {
 		.table	= _table,			\
 	}
 
-#define SPRD_MUX_CLK_TABLE(_struct, _name, _parents, _table,		\
-				     _reg, _shift, _width,		\
-				     _flags)				\
+#define SPRD_MUX_CLK_HW_INIT_FN(_struct, _name, _parents, _table,	\
+				_reg, _shift, _width, _flags, _fn)	\
 	struct sprd_mux _struct = {					\
 		.mux	= _SPRD_MUX_CLK(_shift, _width, _table),	\
 		.common	= {						\
 			.regmap		= NULL,				\
 			.reg		= _reg,				\
-			.hw.init = CLK_HW_INIT_PARENTS(_name,		\
-						       _parents,	\
-						       &sprd_mux_ops,	\
-						       _flags),		\
+			.hw.init = _fn(_name, _parents,			\
+				       &sprd_mux_ops, _flags),		\
 		}							\
 	}
 
+#define SPRD_MUX_CLK_TABLE(_struct, _name, _parents, _table,		\
+			   _reg, _shift, _width, _flags)		\
+	SPRD_MUX_CLK_HW_INIT_FN(_struct, _name, _parents, _table,	\
+				_reg, _shift, _width, _flags,		\
+				CLK_HW_INIT_PARENTS)
+
 #define SPRD_MUX_CLK(_struct, _name, _parents, _reg,		\
 		     _shift, _width, _flags)			\
 	SPRD_MUX_CLK_TABLE(_struct, _name, _parents, NULL,	\
 			   _reg, _shift, _width, _flags)
 
+#define SPRD_MUX_CLK_DATA_TABLE(_struct, _name, _parents, _table,	\
+				_reg, _shift, _width, _flags)		\
+	SPRD_MUX_CLK_HW_INIT_FN(_struct, _name, _parents, _table,	\
+				_reg, _shift, _width, _flags,		\
+				CLK_HW_INIT_PARENTS_DATA)
+
+#define SPRD_MUX_CLK_DATA(_struct, _name, _parents, _reg,		\
+			  _shift, _width, _flags)			\
+	SPRD_MUX_CLK_DATA_TABLE(_struct, _name, _parents, NULL,		\
+				_reg, _shift, _width, _flags)
+
 static inline struct sprd_mux *hw_to_sprd_mux(const struct clk_hw *hw)
 {
 	struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
drivers/clk/sprd/pll.h +37 -18

70 lines not on this page · raw message

Signature · 1 line
2.20.1
author reviewer
#10 lore raw

PATCH v2 6/6 clk: sprd: add clocks support for SC9863A

In reply to Chunyan Zhang

From: Chunyan Zhang <[email protected]>

Add the list of clocks for the Unisoc SC9863A, along with clock initialization.

---
 drivers/clk/sprd/Kconfig       |    8 +
 drivers/clk/sprd/Makefile      |    1 +
 drivers/clk/sprd/sc9863a-clk.c | 1835 ++++++++++++++++++++++++++++++++
 3 files changed, 1844 insertions(+)
 create mode 100644 drivers/clk/sprd/sc9863a-clk.c
drivers/clk/sprd/Kconfig +8 -0
index 3c219af25100..e18c80fbe804 100644
@@ -13,4 +13,12 @@ config SPRD_SC9860_CLK
 	tristate "Support for the Spreadtrum SC9860 clocks"
 	depends on (ARM64 && ARCH_SPRD) || COMPILE_TEST
 	default ARM64 && ARCH_SPRD
+
+config SPRD_SC9863A_CLK
+	tristate "Support for the Unisoc SC9863A clocks"
+	depends on (ARM64 && ARCH_SPRD) || COMPILE_TEST
+	default ARM64 && ARCH_SPRD
+	help
+	  Support for the global clock controller on sc9863a devices.
+	  Say Y if you want to use peripheral devices on sc9863a SoC.
 endif
drivers/clk/sprd/Makefile +1 -0
index d4c00788d53c..41d90e0d7863 100644
@@ -10,3 +10,4 @@ clk-sprd-y	+= pll.o
 
 ## SoC support
 obj-$(CONFIG_SPRD_SC9860_CLK)	+= sc9860-clk.o
+obj-$(CONFIG_SPRD_SC9863A_CLK)	+= sc9863a-clk.o
drivers/clk/sprd/sc9863a-clk.c new file +1835 -0

1,835 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer
#4 lore raw

Re: [PATCH V2 3/6] dt-bindings: clk: sprd: add bindings for sc9863a clock controller

In reply to Chunyan Zhang
Quoted 39 lines · Chunyan Zhang

From: Chunyan Zhang <[email protected]>

add a new bindings to describe sc9863a clock compatible string.

---
 .../bindings/clock/sprd,sc9863a-clk.yaml      | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +23 -0
new file mode 100644
index 000000000000..881f0a0287e5
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2019 Unisoc Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/clock/sprd,sc9863a-clk.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: SC9863A Clock Control Unit Device Tree Bindings
+
+maintainers:
+  - Orson Zhai <[email protected]>
+  - Baolin Wang <[email protected]>
+  - Chunyan Zhang <[email protected]>
+
+properties:
+  "#clock-cells":
+    const: 1
+
+  compatible :
+    enum:
+      - sprd,sc9863a-ap-clk
+      - sprd,sc9863a-pmu-gate
+      - sprd,sc9863a-pll

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 33

Quoted 10 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +10 -0
+      - sprd,sc9863a-mpll
+      - sprd,sc9863a-rpll
+      - sprd,sc9863a-dpll
+      - sprd,sc9863a-aon-clk
+      - sprd,sc9863a-apahb-gate
+      - sprd,sc9863a-aonapb-gate
+      - sprd,sc9863a-mm-gate
+      - sprd,sc9863a-mm-clk
+      - sprd,sc9863a-vspahb-gate
+      - sprd,sc9863a-apapb-gate

These will probably need to be split to separate schemas for the reasons below...

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 38

Quoted 5 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +5 -0
+
+  clocks:
+    description: |
+      The input parent clock(s) phandle for this clock, only list fixed
+      clocks which are decleared in devicetree.

typo.

You need to define how many clocks.

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 42

Quoted 4 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +4 -0
+
+  clock-names:
+    description: |
+      Clock name strings used for driver to reference.

You need to list out the names.

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 54

Quoted 12 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +12 -0
+
+  reg:
+    description: |
+      Contain the registers base address and length. It must be configured
+      only if no 'sprd,syscon' under the node.
+
+  sprd,syscon:
+    $ref: '/schemas/types.yaml#/definitions/phandle'
+    description: |
+      The phandle to the syscon which is in the same address area with
+      the clock, and so we can get regmap for the clocks from the
+      syscon device.

It is preferred to make the clock node a child of the syscon and then you don't need this property.

Quoted 26 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +23 -0
+
+required:
+  - compatible
+  - '#clock-cells'
+
+examples:
+  - |
+    ap_clk: clock-controller@21500000 {
+      compatible = "sprd,sc9863a-ap-clk";
+      reg = <0 0x21500000 0 0x1000>;
+      clocks = <&ext_32k>, <&ext_26m>;
+      clock-names = "ext-32k", "ext-26m";
+      #clock-cells = <1>;
+    };
+
+  - |
+    apahb_gate: apahb-gate {
+      compatible = "sprd,sc9863a-apahb-gate";
+      sprd,syscon = <&ap_ahb_regs>;
+      #clock-cells = <1>;
+    };
+
+...
Signature · 1 line
2.20.1
maintainer Reviewed-by on v2 4/6
#8 lore raw

Re: [PATCH V2 4/6] clk: sprd: Add dt-bindings include file for SC9863A

In reply to Chunyan Zhang
Quoted 11 lines · Chunyan Zhang

From: Chunyan Zhang <[email protected]>

This file defines all SC9863A clock indexes, it should be included in the device tree in which there's device using the clocks.

---
 include/dt-bindings/clock/sprd,sc9863a-clk.h | 345 +++++++++++++++++++
 1 file changed, 345 insertions(+)
 create mode 100644 include/dt-bindings/clock/sprd,sc9863a-clk.h
author reviewer
#5 lore raw

Re: [PATCH V2 3/6] dt-bindings: clk: sprd: add bindings for sc9863a clock controller

In reply to Rob Herring
Quoted 61 lines · Rob Herring
Quoted 39 lines · Chunyan Zhang

From: Chunyan Zhang <[email protected]>

add a new bindings to describe sc9863a clock compatible string.

---
 .../bindings/clock/sprd,sc9863a-clk.yaml      | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +23 -0
new file mode 100644
index 000000000000..881f0a0287e5
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2019 Unisoc Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/clock/sprd,sc9863a-clk.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: SC9863A Clock Control Unit Device Tree Bindings
+
+maintainers:
+  - Orson Zhai <[email protected]>
+  - Baolin Wang <[email protected]>
+  - Chunyan Zhang <[email protected]>
+
+properties:
+  "#clock-cells":
+    const: 1
+
+  compatible :
+    enum:
+      - sprd,sc9863a-ap-clk
+      - sprd,sc9863a-pmu-gate
+      - sprd,sc9863a-pll

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 33

Quoted 10 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +10 -0
+      - sprd,sc9863a-mpll
+      - sprd,sc9863a-rpll
+      - sprd,sc9863a-dpll
+      - sprd,sc9863a-aon-clk
+      - sprd,sc9863a-apahb-gate
+      - sprd,sc9863a-aonapb-gate
+      - sprd,sc9863a-mm-gate
+      - sprd,sc9863a-mm-clk
+      - sprd,sc9863a-vspahb-gate
+      - sprd,sc9863a-apapb-gate

These will probably need to be split to separate schemas for the reasons below...

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 38

Quoted 5 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +5 -0
+
+  clocks:
+    description: |
+      The input parent clock(s) phandle for this clock, only list fixed
+      clocks which are decleared in devicetree.
Quoted 3 lines

typo.

You need to define how many clocks.

Ok, will add a define of maxItems.

Quoted 8 lines

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 42

Quoted 5 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +4 -0
+
+  clock-names:
+    description: |
+      Clock name strings used for driver to reference.

You need to list out the names.

Quoted 15 lines

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 54

Quoted 12 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +12 -0
+
+  reg:
+    description: |
+      Contain the registers base address and length. It must be configured
+      only if no 'sprd,syscon' under the node.
+
+  sprd,syscon:
+    $ref: '/schemas/types.yaml#/definitions/phandle'
+    description: |
+      The phandle to the syscon which is in the same address area with
+      the clock, and so we can get regmap for the clocks from the
+      syscon device.

It is preferred to make the clock node a child of the syscon and then you don't need this property.

According to the hardware topology, any clocks are not belonged to syscon, like described here, this phandle is only used to get virtual map address for clocks which have the same phsical address base with one syscon.

In the past, clocks were defined like below:

    apahb_gate: apahb-gate {
      compatible = "sprd,sc9863a-apahb-gate";
      reg = <0 0x20e00000 0 0x1000>;
      #clock-cells = <1>;
    };

And there was also a syscon which had the same base address like below:
ap_ahb_regs: syscon@20e00000 {
compatible = "sprd,sc9863a-glbregs", "syscon";
reg = <0 0x20e00000 0 0x4000>;
};

To avoid one phsical address was remapped more than one time, I think using the mapped address by syscon directly would be better. Any other suggestions are very appreciated.

Thanks,
Chunyan

Quoted 27 lines
Quoted 27 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +23 -1
+
+required:
+  - compatible
+  - '#clock-cells'
+
+examples:
+  - |
+    ap_clk: clock-controller@21500000 {
+      compatible = "sprd,sc9863a-ap-clk";
+      reg = <0 0x21500000 0 0x1000>;
+      clocks = <&ext_32k>, <&ext_26m>;
+      clock-names = "ext-32k", "ext-26m";
+      #clock-cells = <1>;
+    };
+
+  - |
+    apahb_gate: apahb-gate {
+      compatible = "sprd,sc9863a-apahb-gate";
+      sprd,syscon = <&ap_ahb_regs>;
+      #clock-cells = <1>;
+    };
+
+...
--

2.20.1

maintainer
#6 lore raw

Re: [PATCH V2 3/6] dt-bindings: clk: sprd: add bindings for sc9863a clock controller

Quoted 111 lines · Chunyan Zhang
Quoted 61 lines · Rob Herring
Quoted 39 lines · Chunyan Zhang

From: Chunyan Zhang <[email protected]>

add a new bindings to describe sc9863a clock compatible string.

---
 .../bindings/clock/sprd,sc9863a-clk.yaml      | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +23 -0
new file mode 100644
index 000000000000..881f0a0287e5
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2019 Unisoc Inc.
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/clock/sprd,sc9863a-clk.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: SC9863A Clock Control Unit Device Tree Bindings
+
+maintainers:
+  - Orson Zhai <[email protected]>
+  - Baolin Wang <[email protected]>
+  - Chunyan Zhang <[email protected]>
+
+properties:
+  "#clock-cells":
+    const: 1
+
+  compatible :
+    enum:
+      - sprd,sc9863a-ap-clk
+      - sprd,sc9863a-pmu-gate
+      - sprd,sc9863a-pll

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 33

Quoted 10 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +10 -0
+      - sprd,sc9863a-mpll
+      - sprd,sc9863a-rpll
+      - sprd,sc9863a-dpll
+      - sprd,sc9863a-aon-clk
+      - sprd,sc9863a-apahb-gate
+      - sprd,sc9863a-aonapb-gate
+      - sprd,sc9863a-mm-gate
+      - sprd,sc9863a-mm-clk
+      - sprd,sc9863a-vspahb-gate
+      - sprd,sc9863a-apapb-gate

These will probably need to be split to separate schemas for the reasons below...

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 38

Quoted 5 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +5 -0
+
+  clocks:
+    description: |
+      The input parent clock(s) phandle for this clock, only list fixed
+      clocks which are decleared in devicetree.
Quoted 3 lines

typo.

You need to define how many clocks.

Ok, will add a define of maxItems.

Quoted 8 lines

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 42

Quoted 5 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +4 -0
+
+  clock-names:
+    description: |
+      Clock name strings used for driver to reference.

You need to list out the names.

Quoted 15 lines

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml line 54

Quoted 12 lines
Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml new file +12 -0
+
+  reg:
+    description: |
+      Contain the registers base address and length. It must be configured
+      only if no 'sprd,syscon' under the node.
+
+  sprd,syscon:
+    $ref: '/schemas/types.yaml#/definitions/phandle'
+    description: |
+      The phandle to the syscon which is in the same address area with
+      the clock, and so we can get regmap for the clocks from the
+      syscon device.

It is preferred to make the clock node a child of the syscon and then you don't need this property.

According to the hardware topology, any clocks are not belonged to syscon, like described here, this phandle is only used to get virtual map address for clocks which have the same phsical address base with one syscon.

In the past, clocks were defined like below:

    apahb_gate: apahb-gate {
      compatible = "sprd,sc9863a-apahb-gate";
      reg = <0 0x20e00000 0 0x1000>;
      #clock-cells = <1>;
    };

And there was also a syscon which had the same base address like below:
ap_ahb_regs: syscon@20e00000 {
compatible = "sprd,sc9863a-glbregs", "syscon";
reg = <0 0x20e00000 0 0x4000>;
};

Quoted 3 lines

To avoid one phsical address was remapped more than one time, I think using the mapped address by syscon directly would be better. Any other suggestions are very appreciated.

I'm only suggesting you change the location of the node and get the syscon by getting the parent node. IOW, do this:

ap_ahb_regs: syscon@20e00000 {
    compatible = "sprd,sc9863a-glbregs", "syscon";
    reg = <0 0x20e00000 0 0x4000>;

    apahb_gate: apahb-gate {
        compatible = "sprd,sc9863a-apahb-gate";
        #clock-cells = <1>;
    };
};

Now, if there is a sub range of registers for the clocks that are contiguous, then apahb-gate should have a 'reg' property too (and ranges in the parent). Linux will not use that, but it's a more complete description of the h/w.

Rob

maintainer
#11 lore raw

Re: [PATCH V2 6/6] clk: sprd: add clocks support for SC9863A

In reply to Chunyan Zhang

Quoting Chunyan Zhang (2019-12-16 04:19:32)

Quoted 9 lines
drivers/clk/sprd/sc9863a-clk.c new file +3 -0
new file mode 100644
index 000000000000..145bb0a78740
@@ -0,0 +1,1835 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Unisoc SC9863A clock driver

drivers/clk/sprd/sc9863a-clk.c line 13

Quoted 10 lines
drivers/clk/sprd/sc9863a-clk.c new file +10 -0
+ *
+ * Copyright (C) 2019 Unisoc, Inc.
+ * Author: Chunyan Zhang <[email protected]>
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of_device.h>

Is this include used?

Quoted 12 lines
drivers/clk/sprd/sc9863a-clk.c new file +12 -0
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <dt-bindings/clock/sprd,sc9863a-clk.h>
+
+#include "common.h"
+#include "composite.h"
+#include "div.h"
+#include "gate.h"
+#include "mux.h"
+#include "pll.h"
+

[...]

drivers/clk/sprd/sc9863a-clk.c line 1705

Quoted 3 lines
drivers/clk/sprd/sc9863a-clk.c new file +3 -0
+                               0x1000, BIT(12), 0, 0);
+static SPRD_SC_GATE_CLK_FW_NAME(uart0_eb,      "uart0-eb",     "ext-26m", 0x0,
+                               0x1000, BIT(13), CLK_IGNORE_UNUSED, 0);

Why are we CLK_IGNORE_UNUSED marking these clks? Please add a comment to explain why this should stay instead of being marked as critical.

Quoted 17 lines
drivers/clk/sprd/sc9863a-clk.c new file +17 -0
+static SPRD_SC_GATE_CLK_FW_NAME(uart1_eb,      "uart1-eb",     "ext-26m", 0x0,
+                               0x1000, BIT(14), CLK_IGNORE_UNUSED, 0);
+static SPRD_SC_GATE_CLK_FW_NAME(uart2_eb,      "uart2-eb",     "ext-26m", 0x0,
+                               0x1000, BIT(15), CLK_IGNORE_UNUSED, 0);
+static SPRD_SC_GATE_CLK_FW_NAME(uart3_eb,      "uart3-eb",     "ext-26m", 0x0,
+                               0x1000, BIT(16), CLK_IGNORE_UNUSED, 0);
+static SPRD_SC_GATE_CLK_FW_NAME(uart4_eb,      "uart4-eb",     "ext-26m", 0x0,
+                               0x1000, BIT(17), CLK_IGNORE_UNUSED, 0);
+static SPRD_SC_GATE_CLK_FW_NAME(sim0_32k_eb,   "sim0_32k-eb",  "ext-26m", 0x0,
+                               0x1000, BIT(18), 0, 0);
+static SPRD_SC_GATE_CLK_FW_NAME(spi3_eb,       "spi3-eb",      "ext-26m", 0x0,
+                               0x1000, BIT(19), 0, 0);
+static SPRD_SC_GATE_CLK_FW_NAME(i2c5_eb,       "i2c5-eb",      "ext-26m", 0x0,
+                               0x1000, BIT(20), 0, 0);
+static SPRD_SC_GATE_CLK_FW_NAME(i2c6_eb,       "i2c6-eb",      "ext-26m", 0x0,
+                               0x1000, BIT(21), 0, 0);
+

drivers/clk/sprd/sc9863a-clk.c line 1820

Quoted 10 lines
drivers/clk/sprd/sc9863a-clk.c new file +10 -0
+
+static int sc9863a_clk_probe(struct platform_device *pdev)
+{
+       const struct sprd_clk_desc *desc;
+
+       desc = device_get_match_data(&pdev->dev);
+       if (!desc)
+               return -ENODEV;
+
+       sprd_clk_regmap_init(pdev, desc);

Can this fail?

Quoted 4 lines
drivers/clk/sprd/sc9863a-clk.c new file +4 -0
+
+       return sprd_clk_probe(&pdev->dev, desc->hw_clks);
+}
+