Skip to contentSkip to conversation

clk: meson: drop clk-audio-divider

PATCH In review Jerome Brunet 2 participants 6 messages Jun 20, 2018 – Jun 26, 2018

Subsystems (3)
lore
Share & tools
lore

Jerome Brunet

author maintainer
#0 lore raw

cover clk: meson: drop clk-audio-divider

As explained in the commit descriptions, clk-audio-divider was a poor solution to make sure PLL rates would be high enough while using CCF rate propagation to determine audio clock rates.

Stopping rate propagation before the PLLs is actually simpler and provides better results. It also allow to get rid of clk-audio-divider.

Off tree sound cards using these clocks should add the following to the sound card DT to properly setup the PLLs:

	assigned-clocks = <&clkc CLKID_MPLL2>,
	                  <&clkc CLKID_MPLL0>,
	                  <&clkc CLKID_MPLL1>;
	assigned-clock-parents = <0>, <0>, <0>;
	assigned-clock-rates = <294912000>,
	                       <270950400>,
	                       <393216000>;

* MPLL2: 294912000Hz: 192Khz * 32 * 24 * 2
used 24, 48, 96, 192Khz

* MPLL0: 270950400Hz: 176.4Khz * 32 * 24 * 2 used for 5.512, 10.025, 20.05, 44.1, 88.2 and 176,4Khz

* MPLL1: 393216000Hz: 64Khz * 32 * 24 * 8
used for 8, 16, 32 and 64Khz

Jerome Brunet (2):
clk: meson: stop rate propagation for audio clocks
clk: meson: remove unused clk-audio-divider driver

 drivers/clk/meson/Makefile            |   2 +-
 drivers/clk/meson/clk-audio-divider.c | 110 ----------------------------------
 drivers/clk/meson/clkc.h              |   7 ---
 drivers/clk/meson/gxbb.c              |  16 +++--
 4 files changed, 8 insertions(+), 127 deletions(-)
 delete mode 100644 drivers/clk/meson/clk-audio-divider.c
Signature · 1 line
2.14.3
author maintainer
#1 lore raw

PATCH 1/2 clk: meson: stop rate propagation for audio clocks

It is actually a lot easier to setup the PLL with carefully chosen rates than relying on CCF clock propagation for this audio use case. This way, we can make sure we will always be able to provide the common audio clock rates, while having the PLL in the optimal operating range.

For this, we stop the rate propagation at the mux picking the PLL and let it round to the closest matching PLL.

Doing so, we can use the generic divider for the i2s clock. clk-audio-divider is no longer required. It was a (poor) attempt to use CCF rate propagation while making sure the PLL rate would be high enough to work with audio use cases.

---
 drivers/clk/meson/gxbb.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/clk/meson/gxbb.c +7 -9
index 297ebc391475..894a6adaa17a 100644
@@ -970,28 +970,26 @@ static struct clk_regmap gxbb_cts_amclk_sel = {
 		.mask = 0x3,
 		.shift = 9,
 		.table = (u32[]){ 1, 2, 3 },
+		.flags = CLK_MUX_ROUND_CLOSEST,
 	},
 	.hw.init = &(struct clk_init_data){
 		.name = "cts_amclk_sel",
 		.ops = &clk_regmap_mux_ops,
 		.parent_names = (const char *[]){ "mpll0", "mpll1", "mpll2" },
 		.num_parents = 3,
-		.flags = CLK_SET_RATE_PARENT,
 	},
 };
 
 static struct clk_regmap gxbb_cts_amclk_div = {
-	.data = &(struct meson_clk_audio_div_data){
-		.div = {
-			.reg_off = HHI_AUD_CLK_CNTL,
-			.shift   = 0,
-			.width   = 8,
-		},
+	.data = &(struct clk_regmap_div_data) {
+		.offset = HHI_AUD_CLK_CNTL,
+		.shift = 0,
+		.width = 8,
 		.flags = CLK_DIVIDER_ROUND_CLOSEST,
 	},
 	.hw.init = &(struct clk_init_data){
 		.name = "cts_amclk_div",
-		.ops = &meson_clk_audio_divider_ops,
+		.ops = &clk_regmap_divider_ops,
 		.parent_names = (const char *[]){ "cts_amclk_sel" },
 		.num_parents = 1,
 		.flags = CLK_SET_RATE_PARENT,
@@ -1018,13 +1016,13 @@ static struct clk_regmap gxbb_cts_mclk_i958_sel = {
 		.mask = 0x3,
 		.shift = 25,
 		.table = (u32[]){ 1, 2, 3 },
+		.flags = CLK_MUX_ROUND_CLOSEST,
 	},
 	.hw.init = &(struct clk_init_data) {
 		.name = "cts_mclk_i958_sel",
 		.ops = &clk_regmap_mux_ops,
 		.parent_names = (const char *[]){ "mpll0", "mpll1", "mpll2" },
 		.num_parents = 3,
-		.flags = CLK_SET_RATE_PARENT,
 	},
 };
 
Signature · 1 line
2.14.3
author maintainer
#3 lore raw

PATCH 2/2 clk: meson: remove unused clk-audio-divider driver

In reply to Jerome Brunet

clk-audio-divider is no longer used, we can remove it.

---
 drivers/clk/meson/Makefile            |   2 +-
 drivers/clk/meson/clk-audio-divider.c | 110 ----------------------------------
 drivers/clk/meson/clkc.h              |   7 ---
 3 files changed, 1 insertion(+), 118 deletions(-)
 delete mode 100644 drivers/clk/meson/clk-audio-divider.c
drivers/clk/meson/Makefile +1 -1
index d0d13aeb369a..e40fea96069b 100644
@@ -2,7 +2,7 @@
 # Makefile for Meson specific clk
 #
 
-obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-mpll.o clk-audio-divider.o
+obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-mpll.o
 obj-$(CONFIG_COMMON_CLK_MESON_AO) += meson-aoclk.o
 obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
 obj-$(CONFIG_COMMON_CLK_GXBB)	 += gxbb.o gxbb-aoclk.o gxbb-aoclk-32k.o
drivers/clk/meson/clk-audio-divider.c deleted +0 -110

110 lines not on this page · raw message

drivers/clk/meson/clkc.h +0 -7
index 2fb084330ee9..48db02424f02 100644
@@ -91,11 +91,6 @@ struct meson_clk_mpll_data {
 
 #define CLK_MESON_MPLL_ROUND_CLOSEST	BIT(0)
 
-struct meson_clk_audio_div_data {
-	struct parm div;
-	u8 flags;
-};
-
 #define MESON_GATE(_name, _reg, _bit)					\
 struct clk_regmap _name = {						\
 	.data = &(struct clk_regmap_gate_data){				\
@@ -117,7 +112,5 @@ extern const struct clk_ops meson_clk_pll_ops;
 extern const struct clk_ops meson_clk_cpu_ops;
 extern const struct clk_ops meson_clk_mpll_ro_ops;
 extern const struct clk_ops meson_clk_mpll_ops;
-extern const struct clk_ops meson_clk_audio_divider_ro_ops;
-extern const struct clk_ops meson_clk_audio_divider_ops;
 
 #endif /* __CLKC_H */
Signature · 1 line
2.14.3
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] clk: meson: stop rate propagation for audio clocks

In reply to Jerome Brunet
Quoted 13 lines · Jerome Brunet

It is actually a lot easier to setup the PLL with carefully chosen rates than relying on CCF clock propagation for this audio use case. This way, we can make sure we will always be able to provide the common audio clock rates, while having the PLL in the optimal operating range.

For this, we stop the rate propagation at the mux picking the PLL and let it round to the closest matching PLL.

Doing so, we can use the generic divider for the i2s clock. clk-audio-divider is no longer required. It was a (poor) attempt to use CCF rate propagation while making sure the PLL rate would be high enough to work with audio use cases.

Quoted 5 lines
---
 drivers/clk/meson/gxbb.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] clk: meson: remove unused clk-audio-divider driver

In reply to Jerome Brunet
Quoted 10 lines · Jerome Brunet

clk-audio-divider is no longer used, we can remove it.

---
 drivers/clk/meson/Makefile            |   2 +-
 drivers/clk/meson/clk-audio-divider.c | 110 ----------------------------------
 drivers/clk/meson/clkc.h              |   7 ---
 3 files changed, 1 insertion(+), 118 deletions(-)
 delete mode 100644 drivers/clk/meson/clk-audio-divider.c
author maintainer
#5 lore raw
In reply to Jerome Brunet
Quoted 31 lines · Jerome Brunet

As explained in the commit descriptions, clk-audio-divider was a poor solution to make sure PLL rates would be high enough while using CCF rate propagation to determine audio clock rates.

Stopping rate propagation before the PLLs is actually simpler and provides better results. It also allow to get rid of clk-audio-divider.

Off tree sound cards using these clocks should add the following to the sound card DT to properly setup the PLLs:

	assigned-clocks = <&clkc CLKID_MPLL2>,
	                  <&clkc CLKID_MPLL0>,
	                  <&clkc CLKID_MPLL1>;
	assigned-clock-parents = <0>, <0>, <0>;
	assigned-clock-rates = <294912000>,
	                       <270950400>,
	                       <393216000>;

* MPLL2: 294912000Hz: 192Khz * 32 * 24 * 2
used 24, 48, 96, 192Khz

* MPLL0: 270950400Hz: 176.4Khz * 32 * 24 * 2 used for 5.512, 10.025, 20.05, 44.1, 88.2 and 176,4Khz

* MPLL1: 393216000Hz: 64Khz * 32 * 24 * 8
used for 8, 16, 32 and 64Khz

Jerome Brunet (2):
clk: meson: stop rate propagation for audio clocks
clk: meson: remove unused clk-audio-divider driver

Quoted 7 lines
 drivers/clk/meson/Makefile            |   2 +-
 drivers/clk/meson/clk-audio-divider.c | 110 ----------------------------------
 drivers/clk/meson/clkc.h              |   7 ---
 drivers/clk/meson/gxbb.c              |  16 +++--
 4 files changed, 8 insertions(+), 127 deletions(-)
 delete mode 100644 drivers/clk/meson/clk-audio-divider.c

Rebased and applied with Neil's ack.