Skip to content

Commit ab91835

Browse files
rfvirgiltiwai
authored andcommitted
ASoC: cs35l56: Set fw_regs table after getting REVID
Defer setting the cs35l56_base.fw_regs pointer until after the REVID has been read in cs35l56_hw_init(). Also make the corresponding change to the cs35l56_hda drivers to prevent a build break. This is preparing for firmware registers that change address between revisions of the same device. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 9cf5b8b commit ab91835

File tree

8 files changed

+41
-36
lines changed

8 files changed

+41
-36
lines changed

include/sound/cs35l56.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,6 @@ extern const struct regmap_config cs35l56_regmap_sdw;
337337
extern const struct regmap_config cs35l63_regmap_i2c;
338338
extern const struct regmap_config cs35l63_regmap_sdw;
339339

340-
extern const struct cs35l56_fw_reg cs35l56_fw_reg;
341-
extern const struct cs35l56_fw_reg cs35l63_fw_reg;
342-
343340
extern const struct cirrus_amp_cal_controls cs35l56_calibration_controls;
344341

345342
extern const char * const cs35l56_tx_input_texts[CS35L56_NUM_INPUT_SRC];

sound/hda/codecs/side-codecs/cs35l56_hda.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,7 @@ int cs35l56_hda_common_probe(struct cs35l56_hda *cs35l56, int hid, int id)
10491049
goto err;
10501050
}
10511051

1052+
cs35l56->base.type = hid & 0xff;
10521053
cs35l56->base.cal_index = -1;
10531054

10541055
cs35l56_init_cs_dsp(&cs35l56->base, &cs35l56->cs_dsp);

sound/hda/codecs/side-codecs/cs35l56_hda_i2c.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ static int cs35l56_hda_i2c_probe(struct i2c_client *clt)
2727
cs35l56->base.can_hibernate = true;
2828
#endif
2929

30-
cs35l56->base.fw_reg = &cs35l56_fw_reg;
31-
3230
cs35l56->base.regmap = devm_regmap_init_i2c(clt, &cs35l56_regmap_i2c);
3331
if (IS_ERR(cs35l56->base.regmap)) {
3432
ret = PTR_ERR(cs35l56->base.regmap);

sound/hda/codecs/side-codecs/cs35l56_hda_spi.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ static int cs35l56_hda_spi_probe(struct spi_device *spi)
3030
cs35l56->base.can_hibernate = true;
3131
#endif
3232

33-
cs35l56->base.fw_reg = &cs35l56_fw_reg;
34-
3533
cs35l56->base.regmap = devm_regmap_init_spi(spi, &cs35l56_regmap_spi);
3634
if (IS_ERR(cs35l56->base.regmap)) {
3735
ret = PTR_ERR(cs35l56->base.regmap);

sound/soc/codecs/cs35l56-i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ static int cs35l56_i2c_probe(struct i2c_client *client)
3535
switch (id) {
3636
case 0x3556:
3737
regmap_config = &cs35l56_regmap_i2c;
38-
cs35l56->base.fw_reg = &cs35l56_fw_reg;
38+
cs35l56->base.type = 0x56;
3939
break;
4040
case 0x3563:
4141
regmap_config = &cs35l63_regmap_i2c;
42-
cs35l56->base.fw_reg = &cs35l63_fw_reg;
42+
cs35l56->base.type = 0x63;
4343
break;
4444
default:
4545
return -ENODEV;

sound/soc/codecs/cs35l56-sdw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,16 +527,16 @@ static int cs35l56_sdw_probe(struct sdw_slave *peripheral, const struct sdw_devi
527527
case 0x3556:
528528
case 0x3557:
529529
regmap_config = &cs35l56_regmap_sdw;
530-
cs35l56->base.fw_reg = &cs35l56_fw_reg;
531530
break;
532531
case 0x3563:
533532
regmap_config = &cs35l63_regmap_sdw;
534-
cs35l56->base.fw_reg = &cs35l63_fw_reg;
535533
break;
536534
default:
537535
return -ENODEV;
538536
}
539537

538+
cs35l56->base.type = ((unsigned int)id->driver_data) & 0xff;
539+
540540
cs35l56->base.regmap = devm_regmap_init(dev, &cs35l56_regmap_bus_sdw,
541541
peripheral, regmap_config);
542542
if (IS_ERR(cs35l56->base.regmap)) {

sound/soc/codecs/cs35l56-shared.c

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,40 @@ static bool cs35l63_volatile_reg(struct device *dev, unsigned int reg)
309309
}
310310
}
311311

312+
static const struct cs35l56_fw_reg cs35l56_fw_reg = {
313+
.fw_ver = CS35L56_DSP1_FW_VER,
314+
.halo_state = CS35L56_DSP1_HALO_STATE,
315+
.pm_cur_stat = CS35L56_DSP1_PM_CUR_STATE,
316+
.prot_sts = CS35L56_PROTECTION_STATUS,
317+
.transducer_actual_ps = CS35L56_TRANSDUCER_ACTUAL_PS,
318+
.user_mute = CS35L56_MAIN_RENDER_USER_MUTE,
319+
.user_volume = CS35L56_MAIN_RENDER_USER_VOLUME,
320+
.posture_number = CS35L56_MAIN_POSTURE_NUMBER,
321+
};
322+
323+
static const struct cs35l56_fw_reg cs35l63_fw_reg = {
324+
.fw_ver = CS35L63_DSP1_FW_VER,
325+
.halo_state = CS35L63_DSP1_HALO_STATE,
326+
.pm_cur_stat = CS35L63_DSP1_PM_CUR_STATE,
327+
.prot_sts = CS35L63_PROTECTION_STATUS,
328+
.transducer_actual_ps = CS35L63_TRANSDUCER_ACTUAL_PS,
329+
.user_mute = CS35L63_MAIN_RENDER_USER_MUTE,
330+
.user_volume = CS35L63_MAIN_RENDER_USER_VOLUME,
331+
.posture_number = CS35L63_MAIN_POSTURE_NUMBER,
332+
};
333+
334+
static void cs35l56_set_fw_reg_table(struct cs35l56_base *cs35l56_base)
335+
{
336+
switch (cs35l56_base->type) {
337+
default:
338+
cs35l56_base->fw_reg = &cs35l56_fw_reg;
339+
break;
340+
case 0x63:
341+
cs35l56_base->fw_reg = &cs35l63_fw_reg;
342+
break;
343+
}
344+
}
345+
312346
int cs35l56_mbox_send(struct cs35l56_base *cs35l56_base, unsigned int command)
313347
{
314348
unsigned int val;
@@ -979,6 +1013,7 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base)
9791013
return ret;
9801014
}
9811015
cs35l56_base->rev = revid & (CS35L56_AREVID_MASK | CS35L56_MTLREVID_MASK);
1016+
cs35l56_set_fw_reg_table(cs35l56_base);
9821017

9831018
ret = cs35l56_wait_for_firmware_boot(cs35l56_base);
9841019
if (ret)
@@ -1280,30 +1315,6 @@ const struct regmap_config cs35l63_regmap_sdw = {
12801315
};
12811316
EXPORT_SYMBOL_NS_GPL(cs35l63_regmap_sdw, "SND_SOC_CS35L56_SHARED");
12821317

1283-
const struct cs35l56_fw_reg cs35l56_fw_reg = {
1284-
.fw_ver = CS35L56_DSP1_FW_VER,
1285-
.halo_state = CS35L56_DSP1_HALO_STATE,
1286-
.pm_cur_stat = CS35L56_DSP1_PM_CUR_STATE,
1287-
.prot_sts = CS35L56_PROTECTION_STATUS,
1288-
.transducer_actual_ps = CS35L56_TRANSDUCER_ACTUAL_PS,
1289-
.user_mute = CS35L56_MAIN_RENDER_USER_MUTE,
1290-
.user_volume = CS35L56_MAIN_RENDER_USER_VOLUME,
1291-
.posture_number = CS35L56_MAIN_POSTURE_NUMBER,
1292-
};
1293-
EXPORT_SYMBOL_NS_GPL(cs35l56_fw_reg, "SND_SOC_CS35L56_SHARED");
1294-
1295-
const struct cs35l56_fw_reg cs35l63_fw_reg = {
1296-
.fw_ver = CS35L63_DSP1_FW_VER,
1297-
.halo_state = CS35L63_DSP1_HALO_STATE,
1298-
.pm_cur_stat = CS35L63_DSP1_PM_CUR_STATE,
1299-
.prot_sts = CS35L63_PROTECTION_STATUS,
1300-
.transducer_actual_ps = CS35L63_TRANSDUCER_ACTUAL_PS,
1301-
.user_mute = CS35L63_MAIN_RENDER_USER_MUTE,
1302-
.user_volume = CS35L63_MAIN_RENDER_USER_VOLUME,
1303-
.posture_number = CS35L63_MAIN_POSTURE_NUMBER,
1304-
};
1305-
EXPORT_SYMBOL_NS_GPL(cs35l63_fw_reg, "SND_SOC_CS35L56_SHARED");
1306-
13071318
MODULE_DESCRIPTION("ASoC CS35L56 Shared");
13081319
MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.cirrus.com>");
13091320
MODULE_AUTHOR("Simon Trimmer <simont@opensource.cirrus.com>");

sound/soc/codecs/cs35l56-spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int cs35l56_spi_probe(struct spi_device *spi)
2626

2727
spi_set_drvdata(spi, cs35l56);
2828

29-
cs35l56->base.fw_reg = &cs35l56_fw_reg;
29+
cs35l56->base.type = 0x56;
3030

3131
cs35l56->base.regmap = devm_regmap_init_spi(spi, regmap_config);
3232
if (IS_ERR(cs35l56->base.regmap)) {

0 commit comments

Comments
 (0)