Skip to content

Commit 5d085b2

Browse files
oortcometbroonie
authored andcommitted
ASoC: rt5682: Support the ALC5682I-VE codec
The ALC5682I-VD and ALC5682I-VE use the same I2C codec driver with different calibration settings. This patch aims to handle their differences. Signed-off-by: Derek Fang <derek.fang@realtek.com> Link: https://patch.msgid.link/20241225094307.3678837-1-derek.fang@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent fffe003 commit 5d085b2

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

sound/soc/codecs/rt5682-i2c.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ static int rt5682_i2c_probe(struct i2c_client *i2c)
186186
return -ENODEV;
187187
}
188188

189+
regmap_read(rt5682->regmap, RT5682_INT_DEVICE_ID, &val);
190+
if (val == 0x6956) {
191+
dev_dbg(&i2c->dev, "ALC5682I-VE device\n");
192+
rt5682->ve_ic = true;
193+
}
194+
189195
mutex_init(&rt5682->calibrate_mutex);
190196
rt5682_calibrate(rt5682);
191197

sound/soc/codecs/rt5682.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ bool rt5682_volatile_register(struct device *dev, unsigned int reg)
395395
case RT5682_4BTN_IL_CMD_1:
396396
case RT5682_AJD1_CTRL:
397397
case RT5682_HP_CALIB_CTRL_1:
398+
case RT5682_INT_DEVICE_ID:
398399
case RT5682_DEVICE_ID:
399400
case RT5682_I2C_MODE:
400401
case RT5682_HP_CALIB_CTRL_10:
@@ -419,6 +420,7 @@ bool rt5682_readable_register(struct device *dev, unsigned int reg)
419420
{
420421
switch (reg) {
421422
case RT5682_RESET:
423+
case RT5682_INT_DEVICE_ID:
422424
case RT5682_VERSION_ID:
423425
case RT5682_VENDOR_ID:
424426
case RT5682_DEVICE_ID:
@@ -3139,7 +3141,10 @@ void rt5682_calibrate(struct rt5682_priv *rt5682)
31393141
regmap_write(rt5682->regmap, RT5682_PWR_DIG_1, 0x0100);
31403142
regmap_write(rt5682->regmap, RT5682_HP_IMP_SENS_CTRL_19, 0x3800);
31413143
regmap_write(rt5682->regmap, RT5682_CHOP_DAC, 0x3000);
3142-
regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x7005);
3144+
if (rt5682->ve_ic)
3145+
regmap_write(rt5682->regmap, RT5682_CHOP_ADC, 0x7005);
3146+
else
3147+
regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x7005);
31433148
regmap_write(rt5682->regmap, RT5682_STO1_ADC_MIXER, 0x686c);
31443149
regmap_write(rt5682->regmap, RT5682_CAL_REC, 0x0d0d);
31453150
regmap_write(rt5682->regmap, RT5682_HP_CALIB_CTRL_2, 0x0321);
@@ -3168,7 +3173,10 @@ void rt5682_calibrate(struct rt5682_priv *rt5682)
31683173
regmap_write(rt5682->regmap, RT5682_GLB_CLK, 0x0000);
31693174
regmap_write(rt5682->regmap, RT5682_PWR_DIG_1, 0x0000);
31703175
regmap_write(rt5682->regmap, RT5682_CHOP_DAC, 0x2000);
3171-
regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005);
3176+
if (rt5682->ve_ic)
3177+
regmap_write(rt5682->regmap, RT5682_CHOP_ADC, 0x2005);
3178+
else
3179+
regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005);
31723180
regmap_write(rt5682->regmap, RT5682_STO1_ADC_MIXER, 0xc0c4);
31733181
regmap_write(rt5682->regmap, RT5682_CAL_REC, 0x0c0c);
31743182

sound/soc/codecs/rt5682.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
/* Info */
2424
#define RT5682_RESET 0x0000
25+
#define RT5682_INT_DEVICE_ID 0x00f9
2526
#define RT5682_VERSION_ID 0x00fd
2627
#define RT5682_VENDOR_ID 0x00fe
2728
#define RT5682_DEVICE_ID 0x00ff
@@ -1446,6 +1447,7 @@ struct rt5682_priv {
14461447
bool hw_init;
14471448
bool first_hw_init;
14481449
bool is_sdw;
1450+
bool ve_ic;
14491451

14501452
#ifdef CONFIG_COMMON_CLK
14511453
struct clk_hw dai_clks_hw[RT5682_DAI_NUM_CLKS];

0 commit comments

Comments
 (0)