[PATCH v1 5/7] nvmem: regmap: Implement protect operation using regmap_seal

Oleksij Rempel o.rempel at pengutronix.de
Wed Jun 4 21:40:34 PDT 2025


Hi Sascha,

On Mon, Jun 02, 2025 at 11:57:51AM +0200, Sascha Hauer wrote:
> > +	for (i = 0; i < bytes; i += reg_val_bytes) {
> > +		unsigned int current_reg_offset = offset + i;
> > +
> > +		ret = regmap_seal(map, current_reg_offset, seal_flags);
> > +		if (ret) {
> > +			dev_err(regmap_get_device(map), "regmap_seal failed for offset 0x%x: %pe\n",
> > +				current_reg_offset, ERR_PTR(ret));
> > +			/* No error handling for partial failures, we messed up
> > +			 * the HW state and can't recover.
> > +			 */
> > +			return ret;
> > +		}
> > +	}
> 
> The i.MX OCOTP offers write protection for fuses as well. AFAIR
> there are single fuses for protecting a whole range of fuses, so to
> support this we would have to pass the full range down to the driver
> instead of separating the range into registers here.
> 
> I never looked at the i.MX OCOTP locking capabilities very closely, so
> it could be that even passing a range is not good enough to make this
> implementable for the OCOTP. We might want to have a look into this
> before deciding if we want to implement protect for the drivers based on
> single registers.

Both are valid options and can be at least partially offloaded to the
framework. regmap already supports reg_[read|write] for per-register
accesses and [read|write] for bulk operations. The same we can do for
the seal operations - provide bulk or per-device ops of needed.

Best Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list