* [PATCH] nvmem: k3: add regulator support
@ 2026-01-29 11:40 Sascha Hauer
2026-02-03 11:08 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2026-01-29 11:40 UTC (permalink / raw)
To: Barebox List
K3 SoCs need an extra vpp for writing fuses. For boards which have that
controllable add regulator support to the K3 OTP driver. The regulator
is turned on before writing and turned off after writing.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/nvmem/k3-fuse.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/nvmem/k3-fuse.c b/drivers/nvmem/k3-fuse.c
index 214239f2cd..6ee5e78920 100644
--- a/drivers/nvmem/k3-fuse.c
+++ b/drivers/nvmem/k3-fuse.c
@@ -11,6 +11,7 @@
#include <linux/nvmem-provider.h>
#include <linux/arm-smccc.h>
#include <linux/bitmap.h>
+#include <regulator.h>
/*
* These SIP calls are currently only supported in the TI downstream
@@ -27,6 +28,7 @@ struct ti_k3_otp_driver_data {
struct ti_k3_otp {
struct device *dev;
+ struct regulator *regulator_fuse;
uint32_t *map;
const struct ti_k3_otp_driver_data *data;
};
@@ -132,20 +134,29 @@ static int ti_k3_otp_write(void *ctx, unsigned int offset, unsigned int val)
unsigned int bank = 0;
unsigned int word = offset >> 2;
unsigned int mask = val;
+ int ret;
+
+ ret = regulator_enable(priv->regulator_fuse);
+ if (ret) {
+ dev_err(priv->dev, "Cannot enable regulator: %pe\n", ERR_PTR(ret));
+ return ret;
+ }
if (word == 0 && priv->data->skip_init) {
unsigned int skip_mask = GENMASK(priv->data->skip_init, 0);
if (val & skip_mask) {
dev_err(priv->dev, "Lower %d bits of word 0 cannot be written\n",
priv->data->skip_init);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err;
}
}
if (val & GENMASK(31, priv->data->bits_per_row)) {
dev_err(priv->dev, "Each row only has %d bits",
priv->data->bits_per_row);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err;
}
arm_smccc_smc(K3_SIP_OTP_WRITE, bank, word,
@@ -154,10 +165,14 @@ static int ti_k3_otp_write(void *ctx, unsigned int offset, unsigned int val)
if (res.a0 != 0) {
dev_err(priv->dev, "Writing fuse 0x%08x failed with: %lu\n",
offset, res.a0);
- return -EIO;
+ ret = -EIO;
+ goto err;
}
- return 0;
+ ret = 0;
+err:
+ regulator_disable(priv->regulator_fuse);
+ return ret;
}
static struct regmap_bus ti_k3_otp_regmap_bus = {
@@ -177,6 +192,10 @@ static int ti_k3_otp_probe(struct device *dev)
priv->dev = dev;
priv->map = xzalloc(sizeof(uint32_t) * priv->data->nrows);
+ priv->regulator_fuse = regulator_get(dev, "fuse");
+ if (IS_ERR(priv->regulator_fuse))
+ return PTR_ERR(priv->regulator_fuse);
+
config.name = "k3-otp";
config.reg_bits = 32;
config.val_bits = 32;
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nvmem: k3: add regulator support
2026-01-29 11:40 [PATCH] nvmem: k3: add regulator support Sascha Hauer
@ 2026-02-03 11:08 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-02-03 11:08 UTC (permalink / raw)
To: Barebox List, Sascha Hauer
On Thu, 29 Jan 2026 12:40:00 +0100, Sascha Hauer wrote:
> K3 SoCs need an extra vpp for writing fuses. For boards which have that
> controllable add regulator support to the K3 OTP driver. The regulator
> is turned on before writing and turned off after writing.
>
>
Applied, thanks!
[1/1] nvmem: k3: add regulator support
https://git.pengutronix.de/cgit/barebox/commit/?id=2100f32ba0ee (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-03 11:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-29 11:40 [PATCH] nvmem: k3: add regulator support Sascha Hauer
2026-02-03 11:08 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox