* [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs
@ 2024-09-25 4:38 Alexey Klimov
2024-09-25 4:38 ` [PATCH REVIEW 2/2] ASoC: codecs: lpass-rx-macro: add missing CDC_RX_BCL_VBAT_RF_PROC2 to default regs values Alexey Klimov
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Alexey Klimov @ 2024-09-25 4:38 UTC (permalink / raw)
To: srinivas.kandagatla, a39.skl, linux-sound
Cc: lgirdwood, broonie, perex, tiwai, alsa-devel, linux-arm-msm,
linux-kernel, krzysztof.kozlowski, vkoul, klimov.linux
Turns out some registers of pre-2.5 version of rxmacro codecs are not
located at the expected offsets but 0xc further away in memory.
So far the detected registers are CDC_RX_RX2_RX_PATH_SEC7 and
CDC_RX_RX2_RX_PATH_DSM_CTL.
CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) macro incorrectly generates the address
0x540 for RX2 but it should be 0x54C and it also overwrites
CDC_RX_RX2_RX_PATH_SEC7 which is located at 0x540.
The same goes for CDC_RX_RXn_RX_PATH_SEC7(rx, n).
Fix this by introducing additional rxn_reg_stride2 offset. For 2.5 version
and above this offset will be equal to 0.
With such change the corresponding RXn() macros will generate the same
values for 2.5 codec version for all RX paths and the same old values
for pre-2.5 version for RX0 and RX1. However for the latter case with RX2 path
it will also add 2 * rxn_reg_stride2 on top.
Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
---
sound/soc/codecs/lpass-rx-macro.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 71e0d3bffd3f..9288ddb705fe 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -202,12 +202,14 @@
#define CDC_RX_RXn_RX_PATH_SEC3(rx, n) (0x042c + rx->rxn_reg_stride * n)
#define CDC_RX_RX0_RX_PATH_SEC4 (0x0430)
#define CDC_RX_RX0_RX_PATH_SEC7 (0x0434)
-#define CDC_RX_RXn_RX_PATH_SEC7(rx, n) (0x0434 + rx->rxn_reg_stride * n)
+#define CDC_RX_RXn_RX_PATH_SEC7(rx, n) \
+ (0x0434 + rx->rxn_reg_stride * n + n * (n - 1) * rx->rxn_reg_stride2)
#define CDC_RX_DSM_OUT_DELAY_SEL_MASK GENMASK(2, 0)
#define CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE 0x2
#define CDC_RX_RX0_RX_PATH_MIX_SEC0 (0x0438)
#define CDC_RX_RX0_RX_PATH_MIX_SEC1 (0x043C)
-#define CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) (0x0440 + rx->rxn_reg_stride * n)
+#define CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) \
+ (0x0440 + rx->rxn_reg_stride * n + n * (n - 1) * rx->rxn_reg_stride2)
#define CDC_RX_RXn_DSM_CLK_EN_MASK BIT(0)
#define CDC_RX_RX0_RX_PATH_DSM_CTL (0x0440)
#define CDC_RX_RX0_RX_PATH_DSM_DATA1 (0x0444)
@@ -645,6 +647,7 @@ struct rx_macro {
int rx_mclk_cnt;
enum lpass_codec_version codec_version;
int rxn_reg_stride;
+ int rxn_reg_stride2;
bool is_ear_mode_on;
bool hph_pwr_mode;
bool hph_hd2_mode;
@@ -3821,6 +3824,7 @@ static int rx_macro_probe(struct platform_device *pdev)
case LPASS_CODEC_VERSION_2_0:
case LPASS_CODEC_VERSION_2_1:
rx->rxn_reg_stride = 0x80;
+ rx->rxn_reg_stride2 = 0x6;
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_pre_2_5_defaults);
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
if (!reg_defaults)
@@ -3834,6 +3838,7 @@ static int rx_macro_probe(struct platform_device *pdev)
case LPASS_CODEC_VERSION_2_7:
case LPASS_CODEC_VERSION_2_8:
rx->rxn_reg_stride = 0xc0;
+ rx->rxn_reg_stride2 = 0x0;
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults);
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
if (!reg_defaults)
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH REVIEW 2/2] ASoC: codecs: lpass-rx-macro: add missing CDC_RX_BCL_VBAT_RF_PROC2 to default regs values
2024-09-25 4:38 [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs Alexey Klimov
@ 2024-09-25 4:38 ` Alexey Klimov
2024-09-25 8:27 ` [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs Dmitry Baryshkov
2024-09-25 15:09 ` (subset) " Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Alexey Klimov @ 2024-09-25 4:38 UTC (permalink / raw)
To: srinivas.kandagatla, a39.skl, linux-sound
Cc: lgirdwood, broonie, perex, tiwai, alsa-devel, linux-arm-msm,
linux-kernel, krzysztof.kozlowski, vkoul, klimov.linux
CDC_RX_BCL_VBAT_RF_PROC1 is listed twice and its default value
is 0x2a which is overwriten by its next occurence in rx_defaults[].
The second one should be missing CDC_RX_BCL_VBAT_RF_PROC2 instead
and its default value is expected 0x0.
Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
---
sound/soc/codecs/lpass-rx-macro.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 9288ddb705fe..2f6699c0a643 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -961,7 +961,7 @@ static const struct reg_default rx_defaults[] = {
{ CDC_RX_BCL_VBAT_PK_EST2, 0x01 },
{ CDC_RX_BCL_VBAT_PK_EST3, 0x40 },
{ CDC_RX_BCL_VBAT_RF_PROC1, 0x2A },
- { CDC_RX_BCL_VBAT_RF_PROC1, 0x00 },
+ { CDC_RX_BCL_VBAT_RF_PROC2, 0x00 },
{ CDC_RX_BCL_VBAT_TAC1, 0x00 },
{ CDC_RX_BCL_VBAT_TAC2, 0x18 },
{ CDC_RX_BCL_VBAT_TAC3, 0x18 },
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs
2024-09-25 4:38 [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs Alexey Klimov
2024-09-25 4:38 ` [PATCH REVIEW 2/2] ASoC: codecs: lpass-rx-macro: add missing CDC_RX_BCL_VBAT_RF_PROC2 to default regs values Alexey Klimov
@ 2024-09-25 8:27 ` Dmitry Baryshkov
2024-09-25 8:53 ` Mark Brown
2024-09-25 15:09 ` (subset) " Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Dmitry Baryshkov @ 2024-09-25 8:27 UTC (permalink / raw)
To: Alexey Klimov
Cc: srinivas.kandagatla, a39.skl, linux-sound, lgirdwood, broonie,
perex, tiwai, alsa-devel, linux-arm-msm, linux-kernel,
krzysztof.kozlowski, vkoul, klimov.linux
On Wed, Sep 25, 2024 at 05:38:22AM GMT, Alexey Klimov wrote:
> Turns out some registers of pre-2.5 version of rxmacro codecs are not
> located at the expected offsets but 0xc further away in memory.
> So far the detected registers are CDC_RX_RX2_RX_PATH_SEC7 and
> CDC_RX_RX2_RX_PATH_DSM_CTL.
>
> CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) macro incorrectly generates the address
> 0x540 for RX2 but it should be 0x54C and it also overwrites
> CDC_RX_RX2_RX_PATH_SEC7 which is located at 0x540.
> The same goes for CDC_RX_RXn_RX_PATH_SEC7(rx, n).
>
> Fix this by introducing additional rxn_reg_stride2 offset. For 2.5 version
> and above this offset will be equal to 0.
> With such change the corresponding RXn() macros will generate the same
> values for 2.5 codec version for all RX paths and the same old values
> for pre-2.5 version for RX0 and RX1. However for the latter case with RX2 path
> it will also add 2 * rxn_reg_stride2 on top.
>
> Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
> ---
> sound/soc/codecs/lpass-rx-macro.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
> index 71e0d3bffd3f..9288ddb705fe 100644
> --- a/sound/soc/codecs/lpass-rx-macro.c
> +++ b/sound/soc/codecs/lpass-rx-macro.c
> @@ -202,12 +202,14 @@
> #define CDC_RX_RXn_RX_PATH_SEC3(rx, n) (0x042c + rx->rxn_reg_stride * n)
> #define CDC_RX_RX0_RX_PATH_SEC4 (0x0430)
> #define CDC_RX_RX0_RX_PATH_SEC7 (0x0434)
> -#define CDC_RX_RXn_RX_PATH_SEC7(rx, n) (0x0434 + rx->rxn_reg_stride * n)
> +#define CDC_RX_RXn_RX_PATH_SEC7(rx, n) \
> + (0x0434 + rx->rxn_reg_stride * n + n * (n - 1) * rx->rxn_reg_stride2)
This is a nice hack to rule out n=0 and n=1, but maybe we can be more
obvious here:
(0x0434 + stride * n + (n > 2) ? stride2 : 0)
> #define CDC_RX_DSM_OUT_DELAY_SEL_MASK GENMASK(2, 0)
> #define CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE 0x2
> #define CDC_RX_RX0_RX_PATH_MIX_SEC0 (0x0438)
> #define CDC_RX_RX0_RX_PATH_MIX_SEC1 (0x043C)
> -#define CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) (0x0440 + rx->rxn_reg_stride * n)
> +#define CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) \
> + (0x0440 + rx->rxn_reg_stride * n + n * (n - 1) * rx->rxn_reg_stride2)
> #define CDC_RX_RXn_DSM_CLK_EN_MASK BIT(0)
> #define CDC_RX_RX0_RX_PATH_DSM_CTL (0x0440)
> #define CDC_RX_RX0_RX_PATH_DSM_DATA1 (0x0444)
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs
2024-09-25 8:27 ` [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs Dmitry Baryshkov
@ 2024-09-25 8:53 ` Mark Brown
2024-09-25 12:41 ` Alexey Klimov
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2024-09-25 8:53 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: Alexey Klimov, srinivas.kandagatla, a39.skl, linux-sound,
lgirdwood, perex, tiwai, alsa-devel, linux-arm-msm, linux-kernel,
krzysztof.kozlowski, vkoul, klimov.linux
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
On Wed, Sep 25, 2024 at 11:27:54AM +0300, Dmitry Baryshkov wrote:
> On Wed, Sep 25, 2024 at 05:38:22AM GMT, Alexey Klimov wrote:
> > +#define CDC_RX_RXn_RX_PATH_SEC7(rx, n) \
> > + (0x0434 + rx->rxn_reg_stride * n + n * (n - 1) * rx->rxn_reg_stride2)
> This is a nice hack to rule out n=0 and n=1, but maybe we can be more
> obvious here:
> (0x0434 + stride * n + (n > 2) ? stride2 : 0)
Yes. We could also use some brackets to make the + and * precedence
obvious.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs
2024-09-25 8:53 ` Mark Brown
@ 2024-09-25 12:41 ` Alexey Klimov
0 siblings, 0 replies; 6+ messages in thread
From: Alexey Klimov @ 2024-09-25 12:41 UTC (permalink / raw)
To: Mark Brown, Dmitry Baryshkov
Cc: srinivas.kandagatla, a39.skl, linux-sound, lgirdwood, perex,
tiwai, alsa-devel, linux-arm-msm, linux-kernel,
krzysztof.kozlowski, vkoul, klimov.linux
On Wed Sep 25, 2024 at 9:53 AM BST, Mark Brown wrote:
> On Wed, Sep 25, 2024 at 11:27:54AM +0300, Dmitry Baryshkov wrote:
> > On Wed, Sep 25, 2024 at 05:38:22AM GMT, Alexey Klimov wrote:
>
> > > +#define CDC_RX_RXn_RX_PATH_SEC7(rx, n) \
> > > + (0x0434 + rx->rxn_reg_stride * n + n * (n - 1) * rx->rxn_reg_stride2)
>
> > This is a nice hack to rule out n=0 and n=1, but maybe we can be more
> > obvious here:
>
> > (0x0434 + stride * n + (n > 2) ? stride2 : 0)
>
> Yes. We could also use some brackets to make the + and * precedence
> obvious.
Yeah, sure. If this approach with stride2 works then I can update to:
(0x0434 + (rx->rxn_reg_stride * n) + ((n > 1) ? rx->rxn_reg_stride2 : 0))
and update stride2 to 0xc.
Looks like I can also remove:
if (j == INTERP_AUX)
dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, 2);
from rx_macro_digital_mute() since INTERP_AUX = 2 and this if-check was there
to handle special offset of DSM_CTL for RX2. If RXn() will generate correct
addresses then this no longer needed. Or such kind of clean-up should go
into separate patch.
BR,
Alexey
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: (subset) [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs
2024-09-25 4:38 [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs Alexey Klimov
2024-09-25 4:38 ` [PATCH REVIEW 2/2] ASoC: codecs: lpass-rx-macro: add missing CDC_RX_BCL_VBAT_RF_PROC2 to default regs values Alexey Klimov
2024-09-25 8:27 ` [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs Dmitry Baryshkov
@ 2024-09-25 15:09 ` Mark Brown
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2024-09-25 15:09 UTC (permalink / raw)
To: srinivas.kandagatla, a39.skl, linux-sound, Alexey Klimov
Cc: lgirdwood, perex, tiwai, alsa-devel, linux-arm-msm, linux-kernel,
krzysztof.kozlowski, vkoul, klimov.linux
On Wed, 25 Sep 2024 05:38:22 +0100, Alexey Klimov wrote:
> Turns out some registers of pre-2.5 version of rxmacro codecs are not
> located at the expected offsets but 0xc further away in memory.
> So far the detected registers are CDC_RX_RX2_RX_PATH_SEC7 and
> CDC_RX_RX2_RX_PATH_DSM_CTL.
>
> CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) macro incorrectly generates the address
> 0x540 for RX2 but it should be 0x54C and it also overwrites
> CDC_RX_RX2_RX_PATH_SEC7 which is located at 0x540.
> The same goes for CDC_RX_RXn_RX_PATH_SEC7(rx, n).
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[2/2] ASoC: codecs: lpass-rx-macro: add missing CDC_RX_BCL_VBAT_RF_PROC2 to default regs values
commit: e249786b2188107a7c50e7174d35f955a60988a1
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-09-25 15:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 4:38 [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs Alexey Klimov
2024-09-25 4:38 ` [PATCH REVIEW 2/2] ASoC: codecs: lpass-rx-macro: add missing CDC_RX_BCL_VBAT_RF_PROC2 to default regs values Alexey Klimov
2024-09-25 8:27 ` [PATCH REVIEW 1/2] ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs Dmitry Baryshkov
2024-09-25 8:53 ` Mark Brown
2024-09-25 12:41 ` Alexey Klimov
2024-09-25 15:09 ` (subset) " Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox