]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ASoC: cs35l56: Handle new algorithms IDs for CS35L63
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Wed, 20 Aug 2025 14:22:01 +0000 (15:22 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 20 Aug 2025 14:27:01 +0000 (15:27 +0100)
CS35L63 uses different algorithm IDs from CS35L56.
Add a new mechanism to handle different alg IDs between parts in the
CS35L56 driver.

Fixes: 978858791ced ("ASoC: cs35l56: Add initial support for CS35L63 for I2C and SoundWire")
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Link: https://patch.msgid.link/20250820142209.127575-3-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/cs35l56.h
sound/soc/codecs/cs35l56-shared.c
sound/soc/codecs/cs35l56.c

index f44aabde805eb78e3133bd29feae80e894d3ca53..7c8bbe8ad1e2dee76391e4e0cad151e44a74a975 100644 (file)
@@ -306,6 +306,7 @@ struct cs35l56_base {
        struct gpio_desc *reset_gpio;
        struct cs35l56_spi_payload *spi_payload_buf;
        const struct cs35l56_fw_reg *fw_reg;
+       const struct cirrus_amp_cal_controls *calibration_controls;
 };
 
 static inline bool cs35l56_is_otp_register(unsigned int reg)
index ba653f6ccfaefe7401db95c2999e71f7672ddd2a..850fcf38599681dc3ac0fcd5bd511cbc89c92686 100644 (file)
@@ -838,6 +838,15 @@ const struct cirrus_amp_cal_controls cs35l56_calibration_controls = {
 };
 EXPORT_SYMBOL_NS_GPL(cs35l56_calibration_controls, "SND_SOC_CS35L56_SHARED");
 
+static const struct cirrus_amp_cal_controls cs35l63_calibration_controls = {
+       .alg_id =       0xbf210,
+       .mem_region =   WMFW_ADSP2_YM,
+       .ambient =      "CAL_AMBIENT",
+       .calr =         "CAL_R",
+       .status =       "CAL_STATUS",
+       .checksum =     "CAL_CHECKSUM",
+};
+
 int cs35l56_get_calibration(struct cs35l56_base *cs35l56_base)
 {
        u64 silicon_uid = 0;
@@ -912,19 +921,31 @@ EXPORT_SYMBOL_NS_GPL(cs35l56_read_prot_status, "SND_SOC_CS35L56_SHARED");
 void cs35l56_log_tuning(struct cs35l56_base *cs35l56_base, struct cs_dsp *cs_dsp)
 {
        __be32 pid, sid, tid;
+       unsigned int alg_id;
        int ret;
 
+       switch (cs35l56_base->type) {
+       case 0x54:
+       case 0x56:
+       case 0x57:
+               alg_id = 0x9f212;
+               break;
+       default:
+               alg_id = 0xbf212;
+               break;
+       }
+
        scoped_guard(mutex, &cs_dsp->pwr_lock) {
                ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(cs_dsp, "AS_PRJCT_ID",
-                                                           WMFW_ADSP2_XM, 0x9f212),
+                                                           WMFW_ADSP2_XM, alg_id),
                                             0, &pid, sizeof(pid));
                if (!ret)
                        ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(cs_dsp, "AS_CHNNL_ID",
-                                                                   WMFW_ADSP2_XM, 0x9f212),
+                                                                   WMFW_ADSP2_XM, alg_id),
                                                     0, &sid, sizeof(sid));
                if (!ret)
                        ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(cs_dsp, "AS_SNPSHT_ID",
-                                                                   WMFW_ADSP2_XM, 0x9f212),
+                                                                   WMFW_ADSP2_XM, alg_id),
                                                     0, &tid, sizeof(tid));
        }
 
@@ -974,8 +995,10 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base)
        case 0x35A54:
        case 0x35A56:
        case 0x35A57:
+               cs35l56_base->calibration_controls = &cs35l56_calibration_controls;
                break;
        case 0x35A630:
+               cs35l56_base->calibration_controls = &cs35l63_calibration_controls;
                devid = devid >> 4;
                break;
        default:
index b1c65d8331e7d9b4354ded74ed0fdc0d270f86f9..2c1edbd636efc0cdcb94e21953e95e0e5f535cd7 100644 (file)
@@ -695,7 +695,7 @@ static int cs35l56_write_cal(struct cs35l56_private *cs35l56)
                return ret;
 
        ret = cs_amp_write_cal_coeffs(&cs35l56->dsp.cs_dsp,
-                                     &cs35l56_calibration_controls,
+                                     cs35l56->base.calibration_controls,
                                      &cs35l56->base.cal_data);
 
        wm_adsp_stop(&cs35l56->dsp);