ASoC: cs35l56: Read Silicon ID from DIE_STS registers for CS35L63
authorStefan Binding <sbinding@opensource.cirrus.com>
Mon, 7 Apr 2025 15:16:44 +0000 (16:16 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 5 May 2025 23:49:20 +0000 (08:49 +0900)
On CS35L63 the DIE_STS registers are populated by the Firmware from
OTP, so the driver can read these registers directly, rather than
obtaining them from OTP.

Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com>
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20250407151842.143393-6-sbinding@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/cs35l56.h
sound/soc/codecs/cs35l56-shared.c

index e16e1a94c8a18ea2830d3d11be4d955cec5e29f7..63f2c63f7c59c641bc99d9e5b880c4b8075a5404 100644 (file)
@@ -71,6 +71,8 @@
 #define CS35L56_DSP_VIRTUAL1_MBOX_6                    0x0011034
 #define CS35L56_DSP_VIRTUAL1_MBOX_7                    0x0011038
 #define CS35L56_DSP_VIRTUAL1_MBOX_8                    0x001103C
+#define CS35L56_DIE_STS1                               0x0017040
+#define CS35L56_DIE_STS2                               0x0017044
 #define CS35L56_DSP_RESTRICT_STS1                      0x00190F0
 #define CS35L56_DSP1_XMEM_PACKED_0                     0x2000000
 #define CS35L56_DSP1_XMEM_PACKED_6143                  0x2005FFC
index 76ddb1cf6889e065989cf4d9f38053a52d006b91..7f768718b69bcd4908544f1987f673c9f73df48d 100644 (file)
@@ -214,6 +214,8 @@ static bool cs35l56_readable_reg(struct device *dev, unsigned int reg)
        case CS35L56_DSP_VIRTUAL1_MBOX_6:
        case CS35L56_DSP_VIRTUAL1_MBOX_7:
        case CS35L56_DSP_VIRTUAL1_MBOX_8:
+       case CS35L56_DIE_STS1:
+       case CS35L56_DIE_STS2:
        case CS35L56_DSP_RESTRICT_STS1:
        case CS35L56_DSP1_SYS_INFO_ID ... CS35L56_DSP1_SYS_INFO_END:
        case CS35L56_DSP1_AHBM_WINDOW_DEBUG_0:
@@ -802,13 +804,29 @@ static int cs35l56_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid)
        unique_id |= (u32)pte.x | ((u32)pte.y << 8) | ((u32)pte.wafer_id << 16) |
                     ((u32)pte.dvs << 24);
 
-       dev_dbg(cs35l56_base->dev, "UniqueID = %#llx\n", unique_id);
-
        *uid = unique_id;
 
        return 0;
 }
 
+static int cs35l63_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid)
+{
+       u32 tmp[2];
+       int ret;
+
+       ret = regmap_bulk_read(cs35l56_base->regmap, CS35L56_DIE_STS1, tmp, ARRAY_SIZE(tmp));
+       if (ret) {
+               dev_err(cs35l56_base->dev, "Cannot obtain CS35L56_DIE_STS: %d\n", ret);
+               return ret;
+       }
+
+       *uid = tmp[1];
+       *uid <<= 32;
+       *uid |= tmp[0];
+
+       return 0;
+}
+
 /* Firmware calibration controls */
 const struct cirrus_amp_cal_controls cs35l56_calibration_controls = {
        .alg_id =       0x9f210,
@@ -829,10 +847,25 @@ int cs35l56_get_calibration(struct cs35l56_base *cs35l56_base)
        if (cs35l56_base->secured)
                return 0;
 
-       ret = cs35l56_read_silicon_uid(cs35l56_base, &silicon_uid);
+       switch (cs35l56_base->type) {
+       case 0x54:
+       case 0x56:
+       case 0x57:
+               ret = cs35l56_read_silicon_uid(cs35l56_base, &silicon_uid);
+               break;
+       case 0x63:
+               ret = cs35l63_read_silicon_uid(cs35l56_base, &silicon_uid);
+               break;
+       default:
+               ret = -ENODEV;
+               break;
+       }
+
        if (ret < 0)
                return ret;
 
+       dev_dbg(cs35l56_base->dev, "UniqueID = %#llx\n", silicon_uid);
+
        ret = cs_amp_get_efi_calibration_data(cs35l56_base->dev, silicon_uid,
                                              cs35l56_base->cal_index,
                                              &cs35l56_base->cal_data);