Skip to content

Commit 9fc9ef0

Browse files
laklimovbroonie
authored andcommitted
ASoC: codecs: lpass-rx-macro: fix RXn(rx,n) macro for DSM_CTL and SEC7 regs
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 rxn_reg_stride2 on top. While at this, also remove specific if-check for INTERP_AUX from rx_macro_digital_mute() and rx_macro_enable_interp_clk(). These if-check was used to handle such special offset for AUX interpolator but since CDC_RX_RXn_RX_PATH_SEC7(rx, n) and CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) macros will generate the correst addresses of dsm register, they are no longer needed. Cc: Srinivas Kandagatla <[email protected]> Cc: Krzysztof Kozlowski <[email protected]> Signed-off-by: Alexey Klimov <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 740883f commit 9fc9ef0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

sound/soc/codecs/lpass-rx-macro.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,14 @@
202202
#define CDC_RX_RXn_RX_PATH_SEC3(rx, n) (0x042c + rx->rxn_reg_stride * n)
203203
#define CDC_RX_RX0_RX_PATH_SEC4 (0x0430)
204204
#define CDC_RX_RX0_RX_PATH_SEC7 (0x0434)
205-
#define CDC_RX_RXn_RX_PATH_SEC7(rx, n) (0x0434 + rx->rxn_reg_stride * n)
205+
#define CDC_RX_RXn_RX_PATH_SEC7(rx, n) \
206+
(0x0434 + (rx->rxn_reg_stride * n) + ((n > 1) ? rx->rxn_reg_stride2 : 0))
206207
#define CDC_RX_DSM_OUT_DELAY_SEL_MASK GENMASK(2, 0)
207208
#define CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE 0x2
208209
#define CDC_RX_RX0_RX_PATH_MIX_SEC0 (0x0438)
209210
#define CDC_RX_RX0_RX_PATH_MIX_SEC1 (0x043C)
210-
#define CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) (0x0440 + rx->rxn_reg_stride * n)
211+
#define CDC_RX_RXn_RX_PATH_DSM_CTL(rx, n) \
212+
(0x0440 + (rx->rxn_reg_stride * n) + ((n > 1) ? rx->rxn_reg_stride2 : 0))
211213
#define CDC_RX_RXn_DSM_CLK_EN_MASK BIT(0)
212214
#define CDC_RX_RX0_RX_PATH_DSM_CTL (0x0440)
213215
#define CDC_RX_RX0_RX_PATH_DSM_DATA1 (0x0444)
@@ -645,6 +647,7 @@ struct rx_macro {
645647
int rx_mclk_cnt;
646648
enum lpass_codec_version codec_version;
647649
int rxn_reg_stride;
650+
int rxn_reg_stride2;
648651
bool is_ear_mode_on;
649652
bool hph_pwr_mode;
650653
bool hph_hd2_mode;
@@ -1929,9 +1932,6 @@ static int rx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
19291932
CDC_RX_PATH_PGA_MUTE_MASK, 0x0);
19301933
}
19311934

1932-
if (j == INTERP_AUX)
1933-
dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, 2);
1934-
19351935
int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + j * 8;
19361936
int_mux_cfg1 = int_mux_cfg0 + 4;
19371937
int_mux_cfg0_val = snd_soc_component_read(component, int_mux_cfg0);
@@ -2702,9 +2702,6 @@ static int rx_macro_enable_interp_clk(struct snd_soc_component *component,
27022702

27032703
main_reg = CDC_RX_RXn_RX_PATH_CTL(rx, interp_idx);
27042704
dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, interp_idx);
2705-
if (interp_idx == INTERP_AUX)
2706-
dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(rx, 2);
2707-
27082705
rx_cfg2_reg = CDC_RX_RXn_RX_PATH_CFG2(rx, interp_idx);
27092706

27102707
if (SND_SOC_DAPM_EVENT_ON(event)) {
@@ -3821,6 +3818,7 @@ static int rx_macro_probe(struct platform_device *pdev)
38213818
case LPASS_CODEC_VERSION_2_0:
38223819
case LPASS_CODEC_VERSION_2_1:
38233820
rx->rxn_reg_stride = 0x80;
3821+
rx->rxn_reg_stride2 = 0xc;
38243822
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_pre_2_5_defaults);
38253823
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
38263824
if (!reg_defaults)
@@ -3834,6 +3832,7 @@ static int rx_macro_probe(struct platform_device *pdev)
38343832
case LPASS_CODEC_VERSION_2_7:
38353833
case LPASS_CODEC_VERSION_2_8:
38363834
rx->rxn_reg_stride = 0xc0;
3835+
rx->rxn_reg_stride2 = 0x0;
38373836
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults);
38383837
reg_defaults = kmalloc_array(def_count, sizeof(struct reg_default), GFP_KERNEL);
38393838
if (!reg_defaults)

0 commit comments

Comments
 (0)