Lines Matching refs:otp

33 static uint32_t otp_bank(uint32_t otp)  in otp_bank()  argument
35 if (otp > STM32MP2_OTP_MAX_ID) { in otp_bank()
39 return (otp & ~BSEC_OTP_MASK) >> BSEC_OTP_BANK_SHIFT; in otp_bank()
42 static uint32_t otp_bit_mask(uint32_t otp) in otp_bit_mask() argument
44 return BIT(otp & BSEC_OTP_MASK); in otp_bit_mask()
71 static bool is_fuse_shadowed(uint32_t otp) in is_fuse_shadowed() argument
73 uint32_t bank = otp_bank(otp); in is_fuse_shadowed()
74 uint32_t otp_mask = otp_bit_mask(otp); in is_fuse_shadowed()
100 static uint32_t check_read_error(uint32_t otp) in check_read_error() argument
105 VERBOSE("BSEC read %u single error correction detected\n", otp); in check_read_error()
109 VERBOSE("BSEC read %u permanent programming lock detected.\n", otp); in check_read_error()
113 ERROR("BSEC read %u error 0x%x\n", otp, status); in check_read_error()
118 ERROR("BSEC read %u error 0x%x with invalid FVR\n", otp, status); in check_read_error()
125 static uint32_t check_program_error(uint32_t otp) in check_program_error() argument
130 ERROR("BSEC program %u error 0x%x\n", otp, status); in check_program_error()
193 static uint32_t bsec_shadow_register(uint32_t otp) in bsec_shadow_register() argument
199 result = bsec_read_sr_lock(otp, &value); in bsec_shadow_register()
201 WARN("BSEC: %u Sticky-read bit read Error %u\n", otp, result); in bsec_shadow_register()
203 VERBOSE("BSEC: OTP %u is locked and will not be refreshed\n", otp); in bsec_shadow_register()
207 mmio_write_32(BSEC_BASE + BSEC_OTPCR, otp); in bsec_shadow_register()
211 result = check_read_error(otp); in bsec_shadow_register()
226 uint32_t bsec_write_otp(uint32_t val, uint32_t otp) in bsec_write_otp() argument
231 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_write_otp()
235 if (!is_fuse_shadowed(otp)) { in bsec_write_otp()
243 result = bsec_read_sw_lock(otp, &state); in bsec_write_otp()
249 mmio_write_32(BSEC_BASE + BSEC_FVR(otp), val); in bsec_write_otp()
261 uint32_t bsec_program_otp(uint32_t val, uint32_t otp) in bsec_program_otp() argument
267 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_program_otp()
275 result = bsec_read_sp_lock(otp, &value); in bsec_program_otp()
277 WARN("BSEC: %u Sticky-prog bit read Error %u\n", otp, result); in bsec_program_otp()
286 mmio_write_32(BSEC_BASE + BSEC_OTPCR, otp | BSEC_OTPCR_PROG); in bsec_program_otp()
290 result = check_program_error(otp); in bsec_program_otp()
339 uint32_t bsec_set_sr_lock(uint32_t otp) in bsec_set_sr_lock() argument
341 uint32_t bank = otp_bank(otp); in bsec_set_sr_lock()
342 uint32_t otp_mask = otp_bit_mask(otp); in bsec_set_sr_lock()
344 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_set_sr_lock()
357 uint32_t bsec_read_sr_lock(uint32_t otp, bool *value) in bsec_read_sr_lock() argument
359 uint32_t bank = otp_bank(otp); in bsec_read_sr_lock()
360 uint32_t otp_mask = otp_bit_mask(otp); in bsec_read_sr_lock()
363 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_read_sr_lock()
377 uint32_t bsec_set_sw_lock(uint32_t otp) in bsec_set_sw_lock() argument
379 uint32_t bank = otp_bank(otp); in bsec_set_sw_lock()
380 uint32_t otp_mask = otp_bit_mask(otp); in bsec_set_sw_lock()
382 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_set_sw_lock()
395 uint32_t bsec_read_sw_lock(uint32_t otp, bool *value) in bsec_read_sw_lock() argument
397 uint32_t bank = otp_bank(otp); in bsec_read_sw_lock()
398 uint32_t otp_mask = otp_bit_mask(otp); in bsec_read_sw_lock()
401 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_read_sw_lock()
415 uint32_t bsec_set_sp_lock(uint32_t otp) in bsec_set_sp_lock() argument
417 uint32_t bank = otp_bank(otp); in bsec_set_sp_lock()
418 uint32_t otp_mask = otp_bit_mask(otp); in bsec_set_sp_lock()
420 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_set_sp_lock()
433 uint32_t bsec_read_sp_lock(uint32_t otp, bool *value) in bsec_read_sp_lock() argument
435 uint32_t bank = otp_bank(otp); in bsec_read_sp_lock()
436 uint32_t otp_mask = otp_bit_mask(otp); in bsec_read_sp_lock()
439 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_read_sp_lock()
480 uint32_t bsec_shadow_read_otp(uint32_t *val, uint32_t otp) in bsec_shadow_read_otp() argument
483 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_shadow_read_otp()
493 if (!is_fuse_shadowed(otp)) { in bsec_shadow_read_otp()
494 uint32_t result = bsec_shadow_register(otp); in bsec_shadow_read_otp()
497 ERROR("BSEC: %u Shadowing Error %u\n", otp, result); in bsec_shadow_read_otp()
502 *val = mmio_read_32(BSEC_BASE + BSEC_FVR(otp)); in bsec_shadow_read_otp()
513 uint32_t bsec_read_otp(uint32_t *val, uint32_t otp) in bsec_read_otp() argument
516 if (otp > STM32MP2_OTP_MAX_ID) { in bsec_read_otp()
520 return bsec_shadow_read_otp(val, otp); in bsec_read_otp()