diff mbox series

[v3,4/7] mtd: spinand: add start_page to otp layout

Message ID 20241226135623.43098-5-mmkurbanov@salutedevices.com
State New
Headers show
Series mtd: spinand: add OTP support | expand

Commit Message

Martin Kurbanov Dec. 26, 2024, 1:55 p.m. UTC
The OTP area is divided into two parts: the factory and the user.
In SPI-NAND, it is usually this one OTP region: the first few pages are
allocated to the factory area. Therefore, enter the start_page field,
which indicates from which page the custom OTP region starts.

Signed-off-by: Martin Kurbanov <mmkurbanov@salutedevices.com>
---
 include/linux/mtd/spinand.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Miquel Raynal Dec. 30, 2024, 9:16 a.m. UTC | #1
On 26/12/2024 at 16:55:49 +03, Martin Kurbanov <mmkurbanov@salutedevices.com> wrote:

> The OTP area is divided into two parts: the factory and the user.
> In SPI-NAND, it is usually this one OTP region: the first few pages
> are

(this sentence might be reworded, it is not very clear)

> allocated to the factory area. Therefore, enter the start_page field,
> which indicates from which page the custom OTP region starts.

TBH I don't like this shortcut and I would prefer having:
- two otp structures defining each parts (user/factory)
- both the user and factory otp hooks provided
- perhaps a top level macro which does both initializations based on
the (user_otp_)start_page parameter.

But I don't like much hiding the layout subtlety behind a
"start_page" member (although it should probably be named
"user_area_start_page" or something like that, otherwise it's
misleading).

This would also be more future proof, manufacturers are creative.

Thanks,
Miquèl
diff mbox series

Patch

diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
index 19d76057c0444..d6dbb85094283 100644
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -325,9 +325,11 @@  struct spinand_ondie_ecc_conf {
 /**
  * struct spinand_otp_layout - structure to describe the SPI NAND OTP area
  * @npages: number of pages in the OTP
+ * @start_page: start page of the user OTP area.
  */
 struct spinand_otp_layout {
 	unsigned int npages;
+	unsigned int start_page;
 };
 
 /**
@@ -417,10 +419,11 @@  struct spinand_info {
 #define SPINAND_SELECT_TARGET(__func)					\
 	.select_target = __func,
 
-#define SPINAND_OTP_INFO(__npages, __ops)				\
+#define SPINAND_OTP_INFO(__npages, __start_page, __ops)			\
 	.otp = {							\
 		.layout = {						\
 			.npages = __npages,				\
+			.start_page = __start_page,			\
 		},							\
 		.ops = __ops,						\
 	}