Lines Matching +full:lock +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
16 /* BSEC REGISTER OFFSET (base relative) */
24 #define BSEC_SPLOCK_OFF 0x064 /* Program safmem sticky lock */
25 #define BSEC_SWLOCK_OFF 0x07C /* write in OTP sticky lock */
26 #define BSEC_SRLOCK_OFF 0x094 /* shadowing sticky lock */
36 /* LOCK Register */
47 * OTP Lock services definition
53 * bsec_check_error() - Check status of one otp
55 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
56 * Return: 0 if no error, -EAGAIN or -ENOTSUPP
67 return -EAGAIN; in bsec_check_error()
69 return -ENOTSUPP; in bsec_check_error()
75 * bsec_lock() - manage lock for each type SR/SP/SW
77 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
92 * bsec_read_SR_lock() - read SR lock (Shadowing)
94 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
103 * bsec_read_SP_lock() - read SP lock (program Lock)
105 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
114 * bsec_SW_lock() - manage SW lock (Write in Shadow)
116 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
125 * bsec_power_safmem() - Activate or deactivate safmem power
150 * bsec_shadow_register() - copy safmen otp to bsec data
152 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
192 * bsec_read_shadow() - read an otp data value from shadow
195 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
206 * bsec_write_shadow() - write value in BSEC data register in shadow
209 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
216 pr_debug("bsec : OTP %d is lock, write will be ignore\n", otp); in bsec_write_shadow()
224 * bsec_program_otp() - program a bit in SAFMEM
227 * @otp: otp number (0 - BSEC_OTP_MAX_VALUE)
240 pr_debug("bsec : Global lock, prog will be ignore\n"); in bsec_program_otp()
264 ret = -EACCES; in bsec_program_otp()
286 ret = bsec_read_shadow(plat->base, &tmp_data, otp); in stm32mp_bsec_read_otp()
291 ret = bsec_shadow_register(plat->base, otp); in stm32mp_bsec_read_otp()
295 ret = bsec_read_shadow(plat->base, val, otp); in stm32mp_bsec_read_otp()
300 ret = bsec_write_shadow(plat->base, tmp_data, otp); in stm32mp_bsec_read_otp()
308 return bsec_read_shadow(plat->base, val, otp); in stm32mp_bsec_read_shadow()
315 return bsec_program_otp(plat->base, val, otp); in stm32mp_bsec_write_otp()
322 return bsec_write_shadow(plat->base, val, otp); in stm32mp_bsec_write_shadow()
325 static int stm32mp_bsec_read(struct udevice *dev, int offset, in stm32mp_bsec_read() argument
334 if (offset >= STM32_BSEC_OTP_OFFSET) { in stm32mp_bsec_read()
335 offset -= STM32_BSEC_OTP_OFFSET; in stm32mp_bsec_read()
338 otp = offset / sizeof(u32); in stm32mp_bsec_read()
340 if (otp < 0 || (otp + nb_otp - 1) > BSEC_OTP_MAX_VALUE) { in stm32mp_bsec_read()
343 return -EINVAL; in stm32mp_bsec_read()
347 u32 *addr = &((u32 *)buf)[i - otp]; in stm32mp_bsec_read()
360 static int stm32mp_bsec_write(struct udevice *dev, int offset, in stm32mp_bsec_write() argument
369 if (offset >= STM32_BSEC_OTP_OFFSET) { in stm32mp_bsec_write()
370 offset -= STM32_BSEC_OTP_OFFSET; in stm32mp_bsec_write()
373 otp = offset / sizeof(u32); in stm32mp_bsec_write()
375 if (otp < 0 || (otp + nb_otp - 1) > BSEC_OTP_MAX_VALUE) { in stm32mp_bsec_write()
378 return -EINVAL; in stm32mp_bsec_write()
382 u32 *val = &((u32 *)buf)[i - otp]; in stm32mp_bsec_write()
403 plat->base = (u32)dev_read_addr_ptr(dev); in stm32mp_bsec_ofdata_to_platdata()
409 { .compatible = "st,stm32mp-bsec" },