Lines Matching refs:otp

72 static void enable_non_secure_access(uint32_t otp)  in enable_non_secure_access()  argument
74 otp_nsec_access[otp / __WORD_BIT] |= BIT(otp % __WORD_BIT); in enable_non_secure_access()
76 if (bsec_shadow_register(otp) != BSEC_OK) { in enable_non_secure_access()
81 static bool non_secure_can_access(uint32_t otp) in non_secure_can_access() argument
83 return (otp_nsec_access[otp / __WORD_BIT] & in non_secure_can_access()
84 BIT(otp % __WORD_BIT)) != 0U; in non_secure_can_access()
93 uint32_t otp; in bsec_dt_otp_nsec_access() local
108 otp = offset / sizeof(uint32_t); in bsec_dt_otp_nsec_access()
110 if (otp < STM32MP1_UPPER_OTP_START) { in bsec_dt_otp_nsec_access()
120 otp = STM32MP1_UPPER_OTP_START; in bsec_dt_otp_nsec_access()
145 for (i = otp; i < (otp + size); i++) { in bsec_dt_otp_nsec_access()
172 static uint32_t otp_bank_offset(uint32_t otp) in otp_bank_offset() argument
174 assert(otp <= STM32MP1_OTP_MAX_ID); in otp_bank_offset()
176 return ((otp & ~BSEC_OTP_MASK) >> BSEC_OTP_BANK_SHIFT) * in otp_bank_offset()
187 static uint32_t bsec_check_error(uint32_t otp, bool check_disturbed) in bsec_check_error() argument
189 uint32_t bit = BIT(otp & BSEC_OTP_MASK); in bsec_check_error()
190 uint32_t bank = otp_bank_offset(otp); in bsec_check_error()
327 uint32_t bsec_shadow_register(uint32_t otp) in bsec_shadow_register() argument
337 result = bsec_read_sr_lock(otp, &value); in bsec_shadow_register()
339 ERROR("BSEC: %u Sticky-read bit read Error %u\n", otp, result); in bsec_shadow_register()
345 otp); in bsec_shadow_register()
360 mmio_write_32(bsec_base + BSEC_OTP_CTRL_OFF, otp | BSEC_READ); in bsec_shadow_register()
366 result = bsec_check_error(otp, true); in bsec_shadow_register()
385 uint32_t bsec_read_otp(uint32_t *val, uint32_t otp) in bsec_read_otp() argument
391 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_read_otp()
396 (otp * sizeof(uint32_t))); in bsec_read_otp()
407 uint32_t bsec_write_otp(uint32_t val, uint32_t otp) in bsec_write_otp() argument
416 result = bsec_read_sw_lock(otp, &value); in bsec_write_otp()
418 ERROR("BSEC: %u Sticky-write bit read Error %u\n", otp, result); in bsec_write_otp()
424 otp); in bsec_write_otp()
431 (otp * sizeof(uint32_t)), val); in bsec_write_otp()
445 uint32_t bsec_program_otp(uint32_t val, uint32_t otp) in bsec_program_otp() argument
456 result = bsec_read_sp_lock(otp, &sp_lock); in bsec_program_otp()
458 ERROR("BSEC: %u Sticky-prog bit read Error %u\n", otp, result); in bsec_program_otp()
462 result = bsec_read_permanent_lock(otp, &perm_lock); in bsec_program_otp()
464 ERROR("BSEC: %u permanent bit read Error %u\n", otp, result); in bsec_program_otp()
492 mmio_write_32(bsec_base + BSEC_OTP_CTRL_OFF, otp | BSEC_WRITE); in bsec_program_otp()
501 result = bsec_check_error(otp, true); in bsec_program_otp()
520 uint32_t bsec_permanent_lock_otp(uint32_t otp) in bsec_permanent_lock_otp() argument
531 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_permanent_lock_otp()
545 if (otp < STM32MP1_UPPER_OTP_START) { in bsec_permanent_lock_otp()
546 addr = otp >> ADDR_LOWER_OTP_PERLOCK_SHIFT; in bsec_permanent_lock_otp()
548 ((otp & DATA_LOWER_OTP_PERLOCK_MASK) << 1U); in bsec_permanent_lock_otp()
550 addr = (otp >> ADDR_UPPER_OTP_PERLOCK_SHIFT) + 2U; in bsec_permanent_lock_otp()
552 (otp & DATA_UPPER_OTP_PERLOCK_MASK); in bsec_permanent_lock_otp()
569 result = bsec_check_error(otp, false); in bsec_permanent_lock_otp()
681 uint32_t bsec_set_sr_lock(uint32_t otp) in bsec_set_sr_lock() argument
683 uint32_t bank = otp_bank_offset(otp); in bsec_set_sr_lock()
684 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_set_sr_lock()
690 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_set_sr_lock()
707 uint32_t bsec_read_sr_lock(uint32_t otp, bool *value) in bsec_read_sr_lock() argument
709 uint32_t bank = otp_bank_offset(otp); in bsec_read_sr_lock()
710 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_read_sr_lock()
713 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_read_sr_lock()
729 uint32_t bsec_set_sw_lock(uint32_t otp) in bsec_set_sw_lock() argument
731 uint32_t bank = otp_bank_offset(otp); in bsec_set_sw_lock()
732 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_set_sw_lock()
738 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_set_sw_lock()
755 uint32_t bsec_read_sw_lock(uint32_t otp, bool *value) in bsec_read_sw_lock() argument
757 uint32_t bank = otp_bank_offset(otp); in bsec_read_sw_lock()
758 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_read_sw_lock()
761 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_read_sw_lock()
777 uint32_t bsec_set_sp_lock(uint32_t otp) in bsec_set_sp_lock() argument
779 uint32_t bank = otp_bank_offset(otp); in bsec_set_sp_lock()
780 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_set_sp_lock()
786 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_set_sp_lock()
803 uint32_t bsec_read_sp_lock(uint32_t otp, bool *value) in bsec_read_sp_lock() argument
805 uint32_t bank = otp_bank_offset(otp); in bsec_read_sp_lock()
806 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_read_sp_lock()
809 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_read_sp_lock()
826 uint32_t bsec_read_permanent_lock(uint32_t otp, bool *value) in bsec_read_permanent_lock() argument
828 uint32_t bank = otp_bank_offset(otp); in bsec_read_permanent_lock()
829 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_read_permanent_lock()
832 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_read_permanent_lock()
945 uint32_t bsec_check_nsec_access_rights(uint32_t otp) in bsec_check_nsec_access_rights() argument
948 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_check_nsec_access_rights()
952 if (otp >= STM32MP1_UPPER_OTP_START) { in bsec_check_nsec_access_rights()
953 if (!non_secure_can_access(otp)) { in bsec_check_nsec_access_rights()