Skip to contentSkip to conversation

clk: meson: add gen_clk

PATCH Applied Jerome Brunet 2 participants 6 messages Jul 4, 2018 – Jul 9, 2018

Subsystems (4)
lore
Share & tools
lore

Jerome Brunet

author maintainer
#0 lore raw

cover clk: meson: add gen_clk

This patch adds GEN_CLK, which a very useful clock for debugging. It allows to output most of the SoC plls through one of the SoC pad.

In the future, we could even use clk_measure with it to access the vast majority of the SoC clocks.

Jerome Brunet (3):
clk: meson: gxbb: remove HHI_GEN_CLK_CTNL duplicate definition
clk: meson: expose GEN_CLK clkid
clk: meson: add gen_clk

 drivers/clk/meson/axg.c               | 64 ++++++++++++++++++++++++++++++++-
 drivers/clk/meson/axg.h               |  4 ++-
 drivers/clk/meson/gxbb.c              | 66 +++++++++++++++++++++++++++++++++++
 drivers/clk/meson/gxbb.h              |  5 +--
 include/dt-bindings/clock/axg-clkc.h  |  1 +
 include/dt-bindings/clock/gxbb-clkc.h |  1 +
 6 files changed, 137 insertions(+), 4 deletions(-)
Signature · 1 line
2.14.4
author maintainer
#1 lore raw

PATCH 1/3 clk: meson: gxbb: remove HHI_GEN_CLK_CTNL duplicate definition

HHI_GEN_CLK_CTNL is defined twice, just remove the duplicate definition

Fixes 738f66d3211d ("clk: gxbb: add AmLogic GXBB clk controller driver")
---
 drivers/clk/meson/gxbb.h | 1 -
 1 file changed, 1 deletion(-)
drivers/clk/meson/gxbb.h +0 -1
index ec1a812bf1fd..df6c21d368c6 100644
@@ -66,7 +66,6 @@
 #define HHI_USB_CLK_CNTL		0x220 /* 0x88 offset in data sheet */
 #define HHI_32K_CLK_CNTL		0x224 /* 0x89 offset in data sheet */
 #define HHI_GEN_CLK_CNTL		0x228 /* 0x8a offset in data sheet */
-#define HHI_GEN_CLK_CNTL		0x228 /* 0x8a offset in data sheet */
 
 #define HHI_PCM_CLK_CNTL		0x258 /* 0x96 offset in data sheet */
 #define HHI_NAND_CLK_CNTL		0x25C /* 0x97 offset in data sheet */
Signature · 1 line
2.14.4
author maintainer
#3 lore raw

PATCH 2/3 clk: meson: expose GEN_CLK clkid

In reply to Jerome Brunet

Expose GEN_CLK clock id

---
 include/dt-bindings/clock/axg-clkc.h  | 1 +
 include/dt-bindings/clock/gxbb-clkc.h | 1 +
 2 files changed, 2 insertions(+)
include/dt-bindings/clock/axg-clkc.h +1 -0
index 70371228b7e0..fd1f938c38d1 100644
@@ -71,5 +71,6 @@
 #define CLKID_PCIE_CML_EN0			79
 #define CLKID_PCIE_CML_EN1			80
 #define CLKID_MIPI_ENABLE			81
+#define CLKID_GEN_CLK				84
 
 #endif /* __AXG_CLKC_H */
include/dt-bindings/clock/gxbb-clkc.h +1 -0
index 7a892be90549..3979d48c025f 100644
@@ -127,5 +127,6 @@
 #define CLKID_VAPB		140
 #define CLKID_VDEC_1		153
 #define CLKID_VDEC_HEVC		156
+#define CLKID_GEN_CLK		159
 
 #endif /* __GXBB_CLKC_H */
Signature · 1 line
2.14.4
author maintainer
#4 lore raw

PATCH 3/3 clk: meson: add gen_clk

In reply to Jerome Brunet

GEN_CLK is able to route several internal clocks to one of the SoC pads. In the future, even more clocks could be made accessible using cts_msr_clk - the clock measure block.

---
 drivers/clk/meson/axg.c  | 64 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/clk/meson/axg.h  |  4 ++-
 drivers/clk/meson/gxbb.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/meson/gxbb.h |  4 ++-
 4 files changed, 135 insertions(+), 3 deletions(-)
drivers/clk/meson/axg.c +63 -1
index 2d458092884a..00ce62ad6416 100644
@@ -909,6 +909,63 @@ static struct clk_regmap axg_sd_emmc_c_clk0 = {
 	},
 };
 
+static u32 mux_table_gen_clk[]	= { 0, 4, 5, 6, 7, 8,
+				    9, 10, 11, 13, 14, };
+static const char * const gen_clk_parent_names[] = {
+	"xtal", "hifi_pll", "mpll0", "mpll1", "mpll2", "mpll3",
+	"fclk_div4", "fclk_div3", "fclk_div5", "fclk_div7", "gp0_pll",
+};
+
+static struct clk_regmap axg_gen_clk_sel = {
+	.data = &(struct clk_regmap_mux_data){
+		.offset = HHI_GEN_CLK_CNTL,
+		.mask = 0xf,
+		.shift = 12,
+		.table = mux_table_gen_clk,
+	},
+	.hw.init = &(struct clk_init_data){
+		.name = "gen_clk_sel",
+		.ops = &clk_regmap_mux_ops,
+		/*
+		 * bits 15:12 selects from 14 possible parents:
+		 * xtal, [rtc_oscin_i], [sys_cpu_div16], [ddr_dpll_pt],
+		 * hifi_pll, mpll0, mpll1, mpll2, mpll3, fdiv4,
+		 * fdiv3, fdiv5, [cts_msr_clk], fdiv7, gp0_pll
+		 */
+		.parent_names = gen_clk_parent_names,
+		.num_parents = ARRAY_SIZE(gen_clk_parent_names),
+	},
+};
+
+static struct clk_regmap axg_gen_clk_div = {
+	.data = &(struct clk_regmap_div_data){
+		.offset = HHI_GEN_CLK_CNTL,
+		.shift = 0,
+		.width = 11,
+	},
+	.hw.init = &(struct clk_init_data){
+		.name = "gen_clk_div",
+		.ops = &clk_regmap_divider_ops,
+		.parent_names = (const char *[]){ "gen_clk_sel" },
+		.num_parents = 1,
+		.flags = CLK_SET_RATE_PARENT,
+	},
+};
+
+static struct clk_regmap axg_gen_clk = {
+	.data = &(struct clk_regmap_gate_data){
+		.offset = HHI_GEN_CLK_CNTL,
+		.bit_idx = 7,
+	},
+	.hw.init = &(struct clk_init_data){
+		.name = "gen_clk",
+		.ops = &clk_regmap_gate_ops,
+		.parent_names = (const char *[]){ "gen_clk_div" },
+		.num_parents = 1,
+		.flags = CLK_SET_RATE_PARENT,
+	},
+};
+
 /* Everything Else (EE) domain gates */
 static MESON_GATE(axg_ddr, HHI_GCLK_MPEG0, 0);
 static MESON_GATE(axg_audio_locker, HHI_GCLK_MPEG0, 2);
@@ -1047,7 +1104,9 @@ static struct clk_hw_onecell_data axg_hw_onecell_data = {
 		[CLKID_PCIE_CML_EN0]		= &axg_pcie_cml_en0.hw,
 		[CLKID_PCIE_CML_EN1]		= &axg_pcie_cml_en1.hw,
 		[CLKID_MIPI_ENABLE]		= &axg_mipi_enable.hw,
-
+		[CLKID_GEN_CLK_SEL]		= &axg_gen_clk_sel.hw,
+		[CLKID_GEN_CLK_DIV]		= &axg_gen_clk_div.hw,
+		[CLKID_GEN_CLK]			= &axg_gen_clk.hw,
 		[NR_CLKS]			= NULL,
 	},
 	.num = NR_CLKS,
@@ -1132,6 +1191,9 @@ static struct clk_regmap *const axg_clk_regmaps[] = {
 	&axg_pcie_cml_en0,
 	&axg_pcie_cml_en1,
 	&axg_mipi_enable,
+	&axg_gen_clk_sel,
+	&axg_gen_clk_div,
+	&axg_gen_clk,
 };
 
 static const struct of_device_id clkc_match_table[] = {
drivers/clk/meson/axg.h +3 -1
index 6e55ebd6c77d..1d04144a1b2c 100644
@@ -131,8 +131,10 @@
 #define CLKID_PCIE_PLL				76
 #define CLKID_PCIE_MUX				77
 #define CLKID_PCIE_REF				78
+#define CLKID_GEN_CLK_SEL			82
+#define CLKID_GEN_CLK_DIV			83
 
-#define NR_CLKS					82
+#define NR_CLKS					85
 
 /* include the CLKIDs that have been made part of the DT binding */
 #include <dt-bindings/clock/axg-clkc.h>
drivers/clk/meson/gxbb.c +66 -0

90 lines not on this page · raw message

drivers/clk/meson/gxbb.h +3 -1
index df6c21d368c6..20dfb1daf5b8 100644
@@ -157,8 +157,10 @@
 #define CLKID_VDEC_1_DIV	  152
 #define CLKID_VDEC_HEVC_SEL	  154
 #define CLKID_VDEC_HEVC_DIV	  155
+#define CLKID_GEN_CLK_SEL	  157
+#define CLKID_GEN_CLK_DIV	  158
 
-#define NR_CLKS			  157
+#define NR_CLKS			  160
 
 /* include the CLKIDs that have been made part of the DT binding */
 #include <dt-bindings/clock/gxbb-clkc.h>
Signature · 1 line
2.14.4
author maintainer Applied
#5 lore raw
In reply to Jerome Brunet
Quoted 4 lines · Jerome Brunet

Jerome Brunet (3):
clk: meson: gxbb: remove HHI_GEN_CLK_CTNL duplicate definition
clk: meson: expose GEN_CLK clkid
clk: meson: add gen_clk

Applied