Skip to content

Commit d67b302

Browse files
committed
ASoC: qcom: lpass-macro: Add LPASS codec v4.0 support for Shikra
Shikra (QCM2290) carries a Bolero v4.0 LPASS codec that extends the existing VA and RX macro hardware in several ways. Wire up the new platform while keeping all changes strictly gated so that no existing platform is affected. VA macro changes: - Add LPASS_CODEC_VERSION_4_0 to the version enum and version-string helper in lpass-macro-common.h. - Introduce a dedicated shikra_va_data match-data struct that pre-sets codec version to 4.0 and marks bypass_fs_control, avoiding the need to read the version from hardware registers before clocks are up. - Add new register definitions for v4.0-only hardware blocks: * SWR GP-IN/GP-OUT channel registers (0x00E0-0x00FC) * Extended ADC MUX4-7 CFG0/1 (0x0120-0x013C) for 8-DMIC support * ADC MUXx CFG2 extension for all 8 muxes (0x0140-0x015C) * SWR INTR_CTRL registers (0x0340-0x03D0) * TX PATH CFG2 per decimator (0x0430/0x04B0/0x0530/0x05B0) * Adaptive filter blocks ADPT0-3 (0x0800-0x09A4) * ALT TOP configuration registers (0x1000-0x1140) - Split register defaults: common defaults stay in va_defaults[]; all v4.0-only defaults move to a new va_4_0_defaults[] array. The probe function builds the regmap config dynamically (mirroring rx-macro), merging va_4_0_defaults only for v4.0 and setting max_register to VA_MAX_OFFSET (0x1240) vs VA_MAX_OFFSET_PRE_4_0 (0x07A8) accordingly. - Guard va_is_rw_register() and va_is_volatile_register() so the new INTR_CTRL, MUX4-7, CFG2, TX_PATH_CFG2, ADPT, and ALT_TOP cases are only reachable when the codec version is 4.0. - Add bypass_fs_control bool to va_macro_data and va_macro structs. Gate the FS counter bit[7] toggle in va_clk_rsc_fs_gen_request() behind va->bypass_fs_control instead of a version comparison. - Add fsgen_gate_ops_4_0 clk_ops with recalc_rate (parent/2) used only for v4.0; the base fsgen_gate_ops is unchanged for all other platforms. - Fix a pre-existing bug where the TX1 and TX3 reg_default entries for TX_PATH_CFG2 incorrectly referenced CDC_VA_TX0_TX_PATH_CFG2 (0x0430) instead of their own addresses (0x04B0 and 0x05B0 respectively). RX macro changes: - Add LPASS_CODEC_VERSION_4_0 fall-through to the v2.5 register-set, control, widget, and probe stride/defaults selection paths, since the RX macro register layout is compatible with the 2.5 variant. - Add bypass_fs_control bool to rx_macro struct; set it from the new LPASS_MACRO_FLAG_BYPASS_FS_CONTROL flag in rx_macro_probe(). - Gate the FS counter bit[7] toggle in rx_macro_mclk_enable() behind rx->bypass_fs_control instead of a version comparison. - Add qcom,shikra-lpass-rx-macro DT match entry with both LPASS_MACRO_FLAG_HAS_NPL_CLOCK and LPASS_MACRO_FLAG_BYPASS_FS_CONTROL. Common header changes: - Add LPASS_MACRO_FLAG_BYPASS_FS_CONTROL BIT(2) to lpass-macro-common.h to signal that the FS counter control bit[7] must be toggled during mclk enable. This is a platform capability flag, not a version check, so it can be set independently of codec version in future platforms. Signed-off-by: Mohammad Rafi Shaik <mohs@qti.qualcomm.com>
1 parent 1e7c606 commit d67b302

3 files changed

Lines changed: 366 additions & 11 deletions

File tree

sound/soc/codecs/lpass-macro-common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#define LPASS_MACRO_FLAG_HAS_NPL_CLOCK BIT(0)
1111
/* The soundwire block should be internally reset at probe */
1212
#define LPASS_MACRO_FLAG_RESET_SWR BIT(1)
13+
/* FS counter control bit[7] must be toggled (Shikra / v4.0) */
14+
#define LPASS_MACRO_FLAG_BYPASS_FS_CONTROL BIT(2)
1315

1416
enum lpass_version {
1517
LPASS_VER_9_0_0,
@@ -30,6 +32,7 @@ enum lpass_codec_version {
3032
LPASS_CODEC_VERSION_2_7,
3133
LPASS_CODEC_VERSION_2_8,
3234
LPASS_CODEC_VERSION_2_9,
35+
LPASS_CODEC_VERSION_4_0,
3336
};
3437

3538
struct lpass_macro {
@@ -68,6 +71,8 @@ static inline const char *lpass_macro_get_codec_version_string(int version)
6871
return "v2.7";
6972
case LPASS_CODEC_VERSION_2_8:
7073
return "v2.8";
74+
case LPASS_CODEC_VERSION_4_0:
75+
return "v4.0";
7176
default:
7277
break;
7378
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ struct rx_macro {
646646
int clsh_users;
647647
int rx_mclk_cnt;
648648
enum lpass_codec_version codec_version;
649+
bool bypass_fs_control;
649650
int rxn_reg_stride;
650651
int rxn_reg_stride2;
651652
bool is_ear_mode_on;
@@ -1612,6 +1613,7 @@ static bool rx_is_rw_register(struct device *dev, unsigned int reg)
16121613
case LPASS_CODEC_VERSION_2_6:
16131614
case LPASS_CODEC_VERSION_2_7:
16141615
case LPASS_CODEC_VERSION_2_8:
1616+
case LPASS_CODEC_VERSION_4_0:
16151617
return rx_2_5_is_rw_register(dev, reg);
16161618
default:
16171619
break;
@@ -2043,6 +2045,11 @@ static void rx_macro_mclk_enable(struct rx_macro *rx, bool mclk_enable)
20432045
CDC_RX_CLK_MCLK2_ENABLE);
20442046
regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
20452047
CDC_RX_FS_MCLK_CNT_CLR_MASK, 0x00);
2048+
2049+
if (rx->bypass_fs_control)
2050+
regmap_update_bits(regmap,
2051+
CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
2052+
0x80, 0x80);
20462053
regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
20472054
CDC_RX_FS_MCLK_CNT_EN_MASK,
20482055
CDC_RX_FS_MCLK_CNT_ENABLE);
@@ -3648,6 +3655,7 @@ static int rx_macro_component_probe(struct snd_soc_component *component)
36483655
case LPASS_CODEC_VERSION_2_6:
36493656
case LPASS_CODEC_VERSION_2_7:
36503657
case LPASS_CODEC_VERSION_2_8:
3658+
case LPASS_CODEC_VERSION_4_0:
36513659
controls = rx_macro_2_5_snd_controls;
36523660
num_controls = ARRAY_SIZE(rx_macro_2_5_snd_controls);
36533661
widgets = rx_macro_2_5_dapm_widgets;
@@ -3809,6 +3817,7 @@ static int rx_macro_probe(struct platform_device *pdev)
38093817
return PTR_ERR(base);
38103818

38113819
rx->codec_version = lpass_macro_get_codec_version();
3820+
rx->bypass_fs_control = !!(flags & LPASS_MACRO_FLAG_BYPASS_FS_CONTROL);
38123821
struct reg_default *reg_defaults __free(kfree) = NULL;
38133822

38143823
switch (rx->codec_version) {
@@ -3831,6 +3840,7 @@ static int rx_macro_probe(struct platform_device *pdev)
38313840
case LPASS_CODEC_VERSION_2_6:
38323841
case LPASS_CODEC_VERSION_2_7:
38333842
case LPASS_CODEC_VERSION_2_8:
3843+
case LPASS_CODEC_VERSION_4_0:
38343844
rx->rxn_reg_stride = 0xc0;
38353845
rx->rxn_reg_stride2 = 0x0;
38363846
def_count = ARRAY_SIZE(rx_defaults) + ARRAY_SIZE(rx_2_5_defaults);
@@ -3961,6 +3971,10 @@ static const struct of_device_id rx_macro_dt_match[] = {
39613971
}, {
39623972
.compatible = "qcom,sc8280xp-lpass-rx-macro",
39633973
.data = (void *)LPASS_MACRO_FLAG_HAS_NPL_CLOCK,
3974+
}, {
3975+
.compatible = "qcom,shikra-lpass-rx-macro",
3976+
.data = (void *)(LPASS_MACRO_FLAG_HAS_NPL_CLOCK |
3977+
LPASS_MACRO_FLAG_BYPASS_FS_CONTROL),
39643978
},
39653979
{ }
39663980
};

0 commit comments

Comments
 (0)