Skip to content

Commit 406fbc4

Browse files
Stefan Bindingbroonie
authored andcommitted
ASoC: cs35l56: Read Silicon ID from DIE_STS registers for CS35L63
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 <[email protected]> Reviewed-by: Richard Fitzgerald <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 9788587 commit 406fbc4

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

include/sound/cs35l56.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
#define CS35L56_DSP_VIRTUAL1_MBOX_6 0x0011034
7272
#define CS35L56_DSP_VIRTUAL1_MBOX_7 0x0011038
7373
#define CS35L56_DSP_VIRTUAL1_MBOX_8 0x001103C
74+
#define CS35L56_DIE_STS1 0x0017040
75+
#define CS35L56_DIE_STS2 0x0017044
7476
#define CS35L56_DSP_RESTRICT_STS1 0x00190F0
7577
#define CS35L56_DSP1_XMEM_PACKED_0 0x2000000
7678
#define CS35L56_DSP1_XMEM_PACKED_6143 0x2005FFC

sound/soc/codecs/cs35l56-shared.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ static bool cs35l56_readable_reg(struct device *dev, unsigned int reg)
214214
case CS35L56_DSP_VIRTUAL1_MBOX_6:
215215
case CS35L56_DSP_VIRTUAL1_MBOX_7:
216216
case CS35L56_DSP_VIRTUAL1_MBOX_8:
217+
case CS35L56_DIE_STS1:
218+
case CS35L56_DIE_STS2:
217219
case CS35L56_DSP_RESTRICT_STS1:
218220
case CS35L56_DSP1_SYS_INFO_ID ... CS35L56_DSP1_SYS_INFO_END:
219221
case CS35L56_DSP1_AHBM_WINDOW_DEBUG_0:
@@ -802,13 +804,29 @@ static int cs35l56_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid)
802804
unique_id |= (u32)pte.x | ((u32)pte.y << 8) | ((u32)pte.wafer_id << 16) |
803805
((u32)pte.dvs << 24);
804806

805-
dev_dbg(cs35l56_base->dev, "UniqueID = %#llx\n", unique_id);
806-
807807
*uid = unique_id;
808808

809809
return 0;
810810
}
811811

812+
static int cs35l63_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid)
813+
{
814+
u32 tmp[2];
815+
int ret;
816+
817+
ret = regmap_bulk_read(cs35l56_base->regmap, CS35L56_DIE_STS1, tmp, ARRAY_SIZE(tmp));
818+
if (ret) {
819+
dev_err(cs35l56_base->dev, "Cannot obtain CS35L56_DIE_STS: %d\n", ret);
820+
return ret;
821+
}
822+
823+
*uid = tmp[1];
824+
*uid <<= 32;
825+
*uid |= tmp[0];
826+
827+
return 0;
828+
}
829+
812830
/* Firmware calibration controls */
813831
const struct cirrus_amp_cal_controls cs35l56_calibration_controls = {
814832
.alg_id = 0x9f210,
@@ -829,10 +847,25 @@ int cs35l56_get_calibration(struct cs35l56_base *cs35l56_base)
829847
if (cs35l56_base->secured)
830848
return 0;
831849

832-
ret = cs35l56_read_silicon_uid(cs35l56_base, &silicon_uid);
850+
switch (cs35l56_base->type) {
851+
case 0x54:
852+
case 0x56:
853+
case 0x57:
854+
ret = cs35l56_read_silicon_uid(cs35l56_base, &silicon_uid);
855+
break;
856+
case 0x63:
857+
ret = cs35l63_read_silicon_uid(cs35l56_base, &silicon_uid);
858+
break;
859+
default:
860+
ret = -ENODEV;
861+
break;
862+
}
863+
833864
if (ret < 0)
834865
return ret;
835866

867+
dev_dbg(cs35l56_base->dev, "UniqueID = %#llx\n", silicon_uid);
868+
836869
ret = cs_amp_get_efi_calibration_data(cs35l56_base->dev, silicon_uid,
837870
cs35l56_base->cal_index,
838871
&cs35l56_base->cal_data);

0 commit comments

Comments
 (0)