|
Takashi Iwai |
482353 |
From ff54938dd190d85f740b9bf9dde59b550936b621 Mon Sep 17 00:00:00 2001
|
|
Takashi Iwai |
482353 |
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
|
|
Takashi Iwai |
482353 |
Date: Sun, 31 Oct 2021 14:50:06 +0100
|
|
Takashi Iwai |
482353 |
Subject: [PATCH] clk: meson: gxbb: Fix the SDM_EN bit for MPLL0 on GXBB
|
|
Takashi Iwai |
482353 |
Git-commit: ff54938dd190d85f740b9bf9dde59b550936b621
|
|
Takashi Iwai |
482353 |
Patch-mainline: v5.17-rc1
|
|
Takashi Iwai |
482353 |
References: git-fixes
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
There are reports that 48kHz audio does not work on the WeTek Play 2
|
|
Takashi Iwai |
482353 |
(which uses a GXBB SoC), while 44.1kHz audio works fine on the same
|
|
Takashi Iwai |
482353 |
board. There are also reports of 48kHz audio working fine on GXL and
|
|
Takashi Iwai |
482353 |
GXM SoCs, which are using an (almost) identical AIU (audio controller).
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
Experimenting has shown that MPLL0 is causing this problem. In the .dts
|
|
Takashi Iwai |
482353 |
we have by default:
|
|
Takashi Iwai |
482353 |
assigned-clocks = <&clkc CLKID_MPLL0>,
|
|
Takashi Iwai |
482353 |
<&clkc CLKID_MPLL1>,
|
|
Takashi Iwai |
482353 |
<&clkc CLKID_MPLL2>;
|
|
Takashi Iwai |
482353 |
assigned-clock-rates = <294912000>,
|
|
Takashi Iwai |
482353 |
<270950400>,
|
|
Takashi Iwai |
482353 |
<393216000>;
|
|
Takashi Iwai |
482353 |
The MPLL0 rate is divisible by 48kHz without remainder and the MPLL1
|
|
Takashi Iwai |
482353 |
rate is divisible by 44.1kHz without remainder. Swapping these two clock
|
|
Takashi Iwai |
482353 |
rates "fixes" 48kHz audio but breaks 44.1kHz audio.
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
Everything looks normal when looking at the info provided by the common
|
|
Takashi Iwai |
482353 |
clock framework while playing 48kHz audio (via I2S with mclk-fs = 256):
|
|
Takashi Iwai |
482353 |
mpll_prediv 1 1 0 2000000000
|
|
Takashi Iwai |
482353 |
mpll0_div 1 1 0 294909641
|
|
Takashi Iwai |
482353 |
mpll0 1 1 0 294909641
|
|
Takashi Iwai |
482353 |
cts_amclk_sel 1 1 0 294909641
|
|
Takashi Iwai |
482353 |
cts_amclk_div 1 1 0 12287902
|
|
Takashi Iwai |
482353 |
cts_amclk 1 1 0 12287902
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
meson-clk-msr however shows that the actual MPLL0 clock is off by more
|
|
Takashi Iwai |
482353 |
than 38MHz:
|
|
Takashi Iwai |
482353 |
mp0_out 333322917 +/-10416Hz
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
The rate seen by meson-clk-msr is very close to what we would get when
|
|
Takashi Iwai |
482353 |
SDM (the fractional part) was ignored:
|
|
Takashi Iwai |
482353 |
(2000000000Hz * 16384) / ((16384 * 6) = 333.33MHz
|
|
Takashi Iwai |
482353 |
If SDM was considered the we should get close to:
|
|
Takashi Iwai |
482353 |
(2000000000Hz * 16384) / ((16384 * 6) + 12808) = 294.9MHz
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
Further experimenting shows that HHI_MPLL_CNTL7[15] does not have any
|
|
Takashi Iwai |
482353 |
effect on the rate of MPLL0 as seen my meson-clk-msr (regardless of
|
|
Takashi Iwai |
482353 |
whether that bit is zero or one the rate is always the same according to
|
|
Takashi Iwai |
482353 |
meson-clk-msr). Using HHI_MPLL_CNTL[25] on the other hand as SDM_EN
|
|
Takashi Iwai |
482353 |
results in SDM being considered for the rate output by the hardware. The
|
|
Takashi Iwai |
482353 |
rate - as seen by meson-clk-msr - matches with what we expect when
|
|
Takashi Iwai |
482353 |
SDM_EN is enabled (fractional part is being considered, resulting in a
|
|
Takashi Iwai |
482353 |
294.9MHz output) or disable (fractional part being ignored, resulting in
|
|
Takashi Iwai |
482353 |
a 333.33MHz output).
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
Reported-by: Christian Hewitt <christianshewitt@gmail.com>
|
|
Takashi Iwai |
482353 |
Tested-by: Christian Hewitt <christianshewitt@gmail.com>
|
|
Takashi Iwai |
482353 |
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
|
|
Takashi Iwai |
482353 |
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
|
|
Takashi Iwai |
482353 |
Link: https://lore.kernel.org/r/20211031135006.1508796-1-martin.blumenstingl@googlemail.com
|
|
Takashi Iwai |
482353 |
Acked-by: Takashi Iwai <tiwai@suse.de>
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
---
|
|
Takashi Iwai |
482353 |
drivers/clk/meson/gxbb.c | 44 +++++++++++++++++++++++++++++++++++++---
|
|
Takashi Iwai |
482353 |
1 file changed, 41 insertions(+), 3 deletions(-)
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
diff --git a/drivers/clk/meson/gxbb.c b/drivers/clk/meson/gxbb.c
|
|
Takashi Iwai |
482353 |
index d6eed760327d..608e0e8ca49a 100644
|
|
Takashi Iwai |
482353 |
--- a/drivers/clk/meson/gxbb.c
|
|
Takashi Iwai |
482353 |
+++ b/drivers/clk/meson/gxbb.c
|
|
Takashi Iwai |
482353 |
@@ -713,6 +713,35 @@ static struct clk_regmap gxbb_mpll_prediv = {
|
|
Takashi Iwai |
482353 |
};
|
|
Takashi Iwai |
482353 |
|
|
Takashi Iwai |
482353 |
static struct clk_regmap gxbb_mpll0_div = {
|
|
Takashi Iwai |
482353 |
+ .data = &(struct meson_clk_mpll_data){
|
|
Takashi Iwai |
482353 |
+ .sdm = {
|
|
Takashi Iwai |
482353 |
+ .reg_off = HHI_MPLL_CNTL7,
|
|
Takashi Iwai |
482353 |
+ .shift = 0,
|
|
Takashi Iwai |
482353 |
+ .width = 14,
|
|
Takashi Iwai |
482353 |
+ },
|
|
Takashi Iwai |
482353 |
+ .sdm_en = {
|
|
Takashi Iwai |
482353 |
+ .reg_off = HHI_MPLL_CNTL,
|
|
Takashi Iwai |
482353 |
+ .shift = 25,
|
|
Takashi Iwai |
482353 |
+ .width = 1,
|
|
Takashi Iwai |
482353 |
+ },
|
|
Takashi Iwai |
482353 |
+ .n2 = {
|
|
Takashi Iwai |
482353 |
+ .reg_off = HHI_MPLL_CNTL7,
|
|
Takashi Iwai |
482353 |
+ .shift = 16,
|
|
Takashi Iwai |
482353 |
+ .width = 9,
|
|
Takashi Iwai |
482353 |
+ },
|
|
Takashi Iwai |
482353 |
+ .lock = &meson_clk_lock,
|
|
Takashi Iwai |
482353 |
+ },
|
|
Takashi Iwai |
482353 |
+ .hw.init = &(struct clk_init_data){
|
|
Takashi Iwai |
482353 |
+ .name = "mpll0_div",
|
|
Takashi Iwai |
482353 |
+ .ops = &meson_clk_mpll_ops,
|
|
Takashi Iwai |
482353 |
+ .parent_hws = (const struct clk_hw *[]) {
|
|
Takashi Iwai |
482353 |
+ &gxbb_mpll_prediv.hw
|
|
Takashi Iwai |
482353 |
+ },
|
|
Takashi Iwai |
482353 |
+ .num_parents = 1,
|
|
Takashi Iwai |
482353 |
+ },
|
|
Takashi Iwai |
482353 |
+};
|
|
Takashi Iwai |
482353 |
+
|
|
Takashi Iwai |
482353 |
+static struct clk_regmap gxl_mpll0_div = {
|
|
Takashi Iwai |
482353 |
.data = &(struct meson_clk_mpll_data){
|
|
Takashi Iwai |
482353 |
.sdm = {
|
|
Takashi Iwai |
482353 |
.reg_off = HHI_MPLL_CNTL7,
|
|
Takashi Iwai |
482353 |
@@ -749,7 +778,16 @@ static struct clk_regmap gxbb_mpll0 = {
|
|
Takashi Iwai |
482353 |
.hw.init = &(struct clk_init_data){
|
|
Takashi Iwai |
482353 |
.name = "mpll0",
|
|
Takashi Iwai |
482353 |
.ops = &clk_regmap_gate_ops,
|
|
Takashi Iwai |
482353 |
- .parent_hws = (const struct clk_hw *[]) { &gxbb_mpll0_div.hw },
|
|
Takashi Iwai |
482353 |
+ .parent_data = &(const struct clk_parent_data) {
|
|
Takashi Iwai |
482353 |
+ /*
|
|
Takashi Iwai |
482353 |
+ * Note:
|
|
Takashi Iwai |
482353 |
+ * GXL and GXBB have different SDM_EN registers. We
|
|
Takashi Iwai |
482353 |
+ * fallback to the global naming string mechanism so
|
|
Takashi Iwai |
482353 |
+ * mpll0_div picks up the appropriate one.
|
|
Takashi Iwai |
482353 |
+ */
|
|
Takashi Iwai |
482353 |
+ .name = "mpll0_div",
|
|
Takashi Iwai |
482353 |
+ .index = -1,
|
|
Takashi Iwai |
482353 |
+ },
|
|
Takashi Iwai |
482353 |
.num_parents = 1,
|
|
Takashi Iwai |
482353 |
.flags = CLK_SET_RATE_PARENT,
|
|
Takashi Iwai |
482353 |
},
|
|
Takashi Iwai |
482353 |
@@ -3044,7 +3082,7 @@ static struct clk_hw_onecell_data gxl_hw_onecell_data = {
|
|
Takashi Iwai |
482353 |
[CLKID_VAPB_1] = &gxbb_vapb_1.hw,
|
|
Takashi Iwai |
482353 |
[CLKID_VAPB_SEL] = &gxbb_vapb_sel.hw,
|
|
Takashi Iwai |
482353 |
[CLKID_VAPB] = &gxbb_vapb.hw,
|
|
Takashi Iwai |
482353 |
- [CLKID_MPLL0_DIV] = &gxbb_mpll0_div.hw,
|
|
Takashi Iwai |
482353 |
+ [CLKID_MPLL0_DIV] = &gxl_mpll0_div.hw,
|
|
Takashi Iwai |
482353 |
[CLKID_MPLL1_DIV] = &gxbb_mpll1_div.hw,
|
|
Takashi Iwai |
482353 |
[CLKID_MPLL2_DIV] = &gxbb_mpll2_div.hw,
|
|
Takashi Iwai |
482353 |
[CLKID_MPLL_PREDIV] = &gxbb_mpll_prediv.hw,
|
|
Takashi Iwai |
482353 |
@@ -3439,7 +3477,7 @@ static struct clk_regmap *const gxl_clk_regmaps[] = {
|
|
Takashi Iwai |
482353 |
&gxbb_mpll0,
|
|
Takashi Iwai |
482353 |
&gxbb_mpll1,
|
|
Takashi Iwai |
482353 |
&gxbb_mpll2,
|
|
Takashi Iwai |
482353 |
- &gxbb_mpll0_div,
|
|
Takashi Iwai |
482353 |
+ &gxl_mpll0_div,
|
|
Takashi Iwai |
482353 |
&gxbb_mpll1_div,
|
|
Takashi Iwai |
482353 |
&gxbb_mpll2_div,
|
|
Takashi Iwai |
482353 |
&gxbb_cts_amclk_div,
|
|
Takashi Iwai |
482353 |
--
|
|
Takashi Iwai |
482353 |
2.31.1
|
|
Takashi Iwai |
482353 |
|