[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3a67496b-dbff-4940-b640-7dbd140e52d7@opensource.cirrus.com>
Date: Mon, 28 Apr 2025 18:39:50 +0100
From: Richard Fitzgerald <rf@...nsource.cirrus.com>
To: Stefan Binding <sbinding@...nsource.cirrus.com>,
Mark Brown <broonie@...nel.org>
Cc: linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org,
patches@...nsource.cirrus.com
Subject: Re: [PATCH v1 5/5] ASoC: cs35l56: Read Silicon ID from DIE_STS
registers for CS35L63
On 7/4/25 16:16, Stefan Binding wrote:
> 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@...nsource.cirrus.com>
> ---
> include/sound/cs35l56.h | 2 ++
> sound/soc/codecs/cs35l56-shared.c | 39 ++++++++++++++++++++++++++++---
> 2 files changed, 38 insertions(+), 3 deletions(-)
>
> diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h
> index e16e1a94c8a1..63f2c63f7c59 100644
> --- a/include/sound/cs35l56.h
> +++ b/include/sound/cs35l56.h
> @@ -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
> diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c
> index 76ddb1cf6889..7f768718b69b 100644
> --- a/sound/soc/codecs/cs35l56-shared.c
> +++ b/sound/soc/codecs/cs35l56-shared.c
> @@ -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);
Reviewed-by: Richard Fitzgerald <rf@...nsource.cirrus.com>
Powered by blists - more mailing lists