From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: broonie@kernel.org, tiwai@suse.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: [PATCH 01/11] ASoC: cs35l56: Read silicon ID during initialization and save it
Date: Thu, 16 Oct 2025 11:42:32 +0100 [thread overview]
Message-ID: <20251016104242.157325-2-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20251016104242.157325-1-rf@opensource.cirrus.com>
Read the silicon ID from the amp during one-time cs35l56_hw_init()
and store it in struct cs35l56_base, instead of reading it from
registers every time it is needed.
Note that marking it non-volatile without a default in regmap isn't
a suitable alternative because this causes regcache_sync() to always
write the cached value out to the registers. This could trigger a bus
fault interrupt inside the amp, which we want to avoid.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
include/sound/cs35l56.h | 1 +
sound/soc/codecs/cs35l56-shared.c | 53 +++++++++++++++----------------
2 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/include/sound/cs35l56.h b/include/sound/cs35l56.h
index ab044ce2aa8b..ec9b1072d6be 100644
--- a/include/sound/cs35l56.h
+++ b/include/sound/cs35l56.h
@@ -309,6 +309,7 @@ struct cs35l56_base {
struct cs35l56_spi_payload *spi_payload_buf;
const struct cs35l56_fw_reg *fw_reg;
const struct cirrus_amp_cal_controls *calibration_controls;
+ u64 silicon_uid;
};
static inline bool cs35l56_is_otp_register(unsigned int reg)
diff --git a/sound/soc/codecs/cs35l56-shared.c b/sound/soc/codecs/cs35l56-shared.c
index 9e6b9ca2f354..1ecfc38d8eb4 100644
--- a/sound/soc/codecs/cs35l56-shared.c
+++ b/sound/soc/codecs/cs35l56-shared.c
@@ -853,7 +853,7 @@ struct cs35l56_pte {
} __packed;
static_assert((sizeof(struct cs35l56_pte) % sizeof(u32)) == 0);
-static int cs35l56_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid)
+static int cs35l56_read_silicon_uid(struct cs35l56_base *cs35l56_base)
{
struct cs35l56_pte pte;
u64 unique_id;
@@ -870,14 +870,15 @@ 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);
- *uid = unique_id;
+ cs35l56_base->silicon_uid = unique_id;
return 0;
}
-static int cs35l63_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid)
+static int cs35l63_read_silicon_uid(struct cs35l56_base *cs35l56_base)
{
u32 tmp[2];
+ u64 unique_id;
int ret;
ret = regmap_bulk_read(cs35l56_base->regmap, CS35L56_DIE_STS1, tmp, ARRAY_SIZE(tmp));
@@ -886,9 +887,11 @@ static int cs35l63_read_silicon_uid(struct cs35l56_base *cs35l56_base, u64 *uid)
return ret;
}
- *uid = tmp[1];
- *uid <<= 32;
- *uid |= tmp[0];
+ unique_id = tmp[1];
+ unique_id <<= 32;
+ unique_id |= tmp[0];
+
+ cs35l56_base->silicon_uid = unique_id;
return 0;
}
@@ -915,33 +918,14 @@ static const struct cirrus_amp_cal_controls cs35l63_calibration_controls = {
int cs35l56_get_calibration(struct cs35l56_base *cs35l56_base)
{
- u64 silicon_uid = 0;
int ret;
/* Driver can't apply calibration to a secured part, so skip */
if (cs35l56_base->secured)
return 0;
- 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,
+ ret = cs_amp_get_efi_calibration_data(cs35l56_base->dev,
+ cs35l56_base->silicon_uid,
cs35l56_base->cal_index,
&cs35l56_base->cal_data);
@@ -1111,6 +1095,21 @@ int cs35l56_hw_init(struct cs35l56_base *cs35l56_base)
CS35L56_TEMP_ERR_EINT1_MASK,
0);
+ switch (cs35l56_base->type) {
+ case 0x54:
+ case 0x56:
+ case 0x57:
+ ret = cs35l56_read_silicon_uid(cs35l56_base);
+ break;
+ default:
+ ret = cs35l63_read_silicon_uid(cs35l56_base);
+ break;
+ }
+ if (ret)
+ return ret;
+
+ dev_dbg(cs35l56_base->dev, "SiliconID = %#llx\n", cs35l56_base->silicon_uid);
+
return 0;
}
EXPORT_SYMBOL_NS_GPL(cs35l56_hw_init, "SND_SOC_CS35L56_SHARED");
--
2.47.3
next prev parent reply other threads:[~2025-10-16 10:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 10:42 [PATCH 00/11] ALSA: cs35l56: Add support for factory calibration Richard Fitzgerald
2025-10-16 10:42 ` Richard Fitzgerald [this message]
2025-10-16 10:42 ` [PATCH 02/11] ASoC: cs-amp-lib: Add helpers " Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 03/11] ASoC: cs35l56: Add common code " Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 04/11] ASoC: cs35l56: Create sysfs files " Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 05/11] ALSA: hda/cs35l56: " Richard Fitzgerald
2025-10-16 11:01 ` Takashi Iwai
2025-10-16 11:27 ` Mark Brown
2025-10-16 11:58 ` Richard Fitzgerald
2025-10-16 12:13 ` Mark Brown
2025-10-16 12:45 ` Takashi Iwai
2025-10-16 10:42 ` [PATCH 06/11] ASoC: cs-amp-lib-test: Add cases for factory calibration helpers Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 07/11] ASoC: cs-amp-lib: Return attributes from cs_amp_get_efi_variable() Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 08/11] ASoC: cs-amp-lib: Add function to write calibration to EFI Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 09/11] ASoC: cs35l56: Add calibration command to store into UEFI Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 10/11] ALSA: hda/cs35l56: Set cal_index to the amp index Richard Fitzgerald
2025-10-16 10:42 ` [PATCH 11/11] ASoC: cs-amp-lib-test: Add test cases for cs_amp_set_efi_calibration_data() Richard Fitzgerald
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251016104242.157325-2-rf@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox