Lines Matching refs:otp
60 static void enable_non_secure_access(uint32_t otp) in enable_non_secure_access() argument
62 otp_nsec_access[otp / __WORD_BIT] |= BIT(otp % __WORD_BIT); in enable_non_secure_access()
64 if (bsec_shadow_register(otp) != BSEC_OK) { in enable_non_secure_access()
69 static bool non_secure_can_access(uint32_t otp) in non_secure_can_access() argument
71 return (otp_nsec_access[otp / __WORD_BIT] & in non_secure_can_access()
72 BIT(otp % __WORD_BIT)) != 0; in non_secure_can_access()
116 static uint32_t otp_bank_offset(uint32_t otp) in otp_bank_offset() argument
118 assert(otp <= STM32MP1_OTP_MAX_ID); in otp_bank_offset()
120 return ((otp & ~BSEC_OTP_MASK) >> BSEC_OTP_BANK_SHIFT) * in otp_bank_offset()
124 static uint32_t bsec_check_error(uint32_t otp) in bsec_check_error() argument
126 uint32_t bit = BIT(otp & BSEC_OTP_MASK); in bsec_check_error()
127 uint32_t bank = otp_bank_offset(otp); in bsec_check_error()
259 uint32_t bsec_shadow_register(uint32_t otp) in bsec_shadow_register() argument
264 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_shadow_register()
269 if (bsec_read_sr_lock(otp)) { in bsec_shadow_register()
271 otp); in bsec_shadow_register()
287 mmio_write_32(bsec_base + BSEC_OTP_CTRL_OFF, otp | BSEC_READ); in bsec_shadow_register()
293 result = bsec_check_error(otp); in bsec_shadow_register()
312 uint32_t bsec_read_otp(uint32_t *val, uint32_t otp) in bsec_read_otp() argument
316 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_read_otp()
323 (otp * sizeof(uint32_t))); in bsec_read_otp()
325 result = bsec_check_error(otp); in bsec_read_otp()
338 uint32_t bsec_write_otp(uint32_t val, uint32_t otp) in bsec_write_otp() argument
342 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_write_otp()
347 if (bsec_read_sw_lock(otp)) { in bsec_write_otp()
349 otp); in bsec_write_otp()
355 (otp * sizeof(uint32_t)), val); in bsec_write_otp()
357 result = bsec_check_error(otp); in bsec_write_otp()
371 uint32_t bsec_program_otp(uint32_t val, uint32_t otp) in bsec_program_otp() argument
376 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_program_otp()
381 if (bsec_read_sp_lock(otp)) { in bsec_program_otp()
406 mmio_write_32(bsec_base + BSEC_OTP_CTRL_OFF, otp | BSEC_WRITE); in bsec_program_otp()
415 result = bsec_check_error(otp); in bsec_program_otp()
434 uint32_t bsec_permanent_lock_otp(uint32_t otp) in bsec_permanent_lock_otp() argument
441 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_permanent_lock_otp()
455 if (otp < STM32MP1_UPPER_OTP_START) { in bsec_permanent_lock_otp()
456 addr = otp >> ADDR_LOWER_OTP_PERLOCK_SHIFT; in bsec_permanent_lock_otp()
458 ((otp & DATA_LOWER_OTP_PERLOCK_MASK) << 1U); in bsec_permanent_lock_otp()
460 addr = (otp >> ADDR_UPPER_OTP_PERLOCK_SHIFT) + 2U; in bsec_permanent_lock_otp()
462 (otp & DATA_UPPER_OTP_PERLOCK_MASK); in bsec_permanent_lock_otp()
481 result = bsec_check_error(otp); in bsec_permanent_lock_otp()
574 bool bsec_write_sr_lock(uint32_t otp, uint32_t value) in bsec_write_sr_lock() argument
577 uint32_t bank = otp_bank_offset(otp); in bsec_write_sr_lock()
579 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_write_sr_lock()
619 bool bsec_read_sr_lock(uint32_t otp) in bsec_read_sr_lock() argument
621 uint32_t bank = otp_bank_offset(otp); in bsec_read_sr_lock()
622 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_read_sr_lock()
635 bool bsec_write_sw_lock(uint32_t otp, uint32_t value) in bsec_write_sw_lock() argument
638 uint32_t bank = otp_bank_offset(otp); in bsec_write_sw_lock()
639 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_write_sw_lock()
680 bool bsec_read_sw_lock(uint32_t otp) in bsec_read_sw_lock() argument
682 uint32_t bank = otp_bank_offset(otp); in bsec_read_sw_lock()
683 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_read_sw_lock()
696 bool bsec_write_sp_lock(uint32_t otp, uint32_t value) in bsec_write_sp_lock() argument
699 uint32_t bank = otp_bank_offset(otp); in bsec_write_sp_lock()
701 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_write_sp_lock()
741 bool bsec_read_sp_lock(uint32_t otp) in bsec_read_sp_lock() argument
743 uint32_t bank = otp_bank_offset(otp); in bsec_read_sp_lock()
744 uint32_t otp_mask = BIT(otp & BSEC_OTP_MASK); in bsec_read_sp_lock()
755 bool bsec_wr_lock(uint32_t otp) in bsec_wr_lock() argument
757 uint32_t bank = otp_bank_offset(otp); in bsec_wr_lock()
758 uint32_t lock_bit = BIT(otp & BSEC_OTP_MASK); in bsec_wr_lock()
872 uint32_t bsec_check_nsec_access_rights(uint32_t otp) in bsec_check_nsec_access_rights() argument
875 if (otp > STM32MP1_OTP_MAX_ID) { in bsec_check_nsec_access_rights()
879 if (otp >= STM32MP1_UPPER_OTP_START) { in bsec_check_nsec_access_rights()
882 if (!non_secure_can_access(otp)) { in bsec_check_nsec_access_rights()