5791df2606ffe35ad0390cb2c210ccb230f82c46
[openwrt/staging/neocturne.git] /
1 From d61784e6410f3df2028e6eb91b06ffed37a660e0 Mon Sep 17 00:00:00 2001
2 From: Patrick Delaunay <patrick.delaunay@foss.st.com>
3 Date: Fri, 18 Nov 2022 06:39:21 +0000
4 Subject: [PATCH] nvmem: stm32: add warning when upper OTPs are updated
5
6 As the upper OTPs are ECC protected, they support only one 32 bits word
7 programming.
8 For a second modification of this word, these ECC become invalid and
9 this OTP will be no more accessible, the shadowed value is invalid.
10
11 This patch adds a warning to indicate an upper OTP update, because this
12 operation is dangerous as OTP is not locked by the driver after the first
13 update to avoid a second update.
14
15 Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
16 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
17 Link: https://lore.kernel.org/r/20221118063932.6418-3-srinivas.kandagatla@linaro.org
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 ---
20 drivers/nvmem/stm32-romem.c | 3 +++
21 1 file changed, 3 insertions(+)
22
23 --- a/drivers/nvmem/stm32-romem.c
24 +++ b/drivers/nvmem/stm32-romem.c
25 @@ -132,6 +132,9 @@ static int stm32_bsec_write(void *contex
26 }
27 }
28
29 + if (offset + bytes >= priv->lower * 4)
30 + dev_warn(dev, "Update of upper OTPs with ECC protection (word programming, only once)\n");
31 +
32 return 0;
33 }
34