mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +00:00
kfuse: Ensure that kfuse is ready 100% for tsec
This commit is contained in:
parent
7c42f72b8a
commit
65fbdfddbf
6 changed files with 34 additions and 8 deletions
|
@ -23,6 +23,7 @@
|
||||||
#include "../sec/se_t210.h"
|
#include "../sec/se_t210.h"
|
||||||
#include "../soc/bpmp.h"
|
#include "../soc/bpmp.h"
|
||||||
#include "../soc/clock.h"
|
#include "../soc/clock.h"
|
||||||
|
#include "../soc/kfuse.h"
|
||||||
#include "../soc/smmu.h"
|
#include "../soc/smmu.h"
|
||||||
#include "../soc/t210.h"
|
#include "../soc/t210.h"
|
||||||
#include "../mem/heap.h"
|
#include "../mem/heap.h"
|
||||||
|
@ -78,6 +79,8 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt)
|
||||||
clock_enable_sor1();
|
clock_enable_sor1();
|
||||||
clock_enable_kfuse();
|
clock_enable_kfuse();
|
||||||
|
|
||||||
|
kfuse_wait_ready();
|
||||||
|
|
||||||
// Configure Falcon.
|
// Configure Falcon.
|
||||||
TSEC(TSEC_DMACTL) = 0;
|
TSEC(TSEC_DMACTL) = 0;
|
||||||
TSEC(TSEC_IRQMSET) =
|
TSEC(TSEC_IRQMSET) =
|
||||||
|
|
|
@ -21,16 +21,25 @@
|
||||||
#pragma GCC push_options
|
#pragma GCC push_options
|
||||||
#pragma GCC optimize ("Os")
|
#pragma GCC optimize ("Os")
|
||||||
|
|
||||||
|
int kfuse_wait_ready()
|
||||||
|
{
|
||||||
|
// Wait for KFUSE to finish init and verification of data.
|
||||||
|
while (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_DONE))
|
||||||
|
;
|
||||||
|
|
||||||
|
if (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_CRCPASS))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int kfuse_read(u32 *buf)
|
int kfuse_read(u32 *buf)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
clock_enable_kfuse();
|
clock_enable_kfuse();
|
||||||
|
|
||||||
while (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_DONE))
|
if (!kfuse_wait_ready())
|
||||||
;
|
|
||||||
|
|
||||||
if (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_CRCPASS))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
KFUSE(KFUSE_KEYADDR) = KFUSE_KEYADDR_AUTOINC;
|
KFUSE(KFUSE_KEYADDR) = KFUSE_KEYADDR_AUTOINC;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#define KFUSE_NUM_WORDS 144
|
#define KFUSE_NUM_WORDS 144
|
||||||
|
|
||||||
|
int kfuse_wait_ready();
|
||||||
int kfuse_read(u32 *buf);
|
int kfuse_read(u32 *buf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "../sec/se_t210.h"
|
#include "../sec/se_t210.h"
|
||||||
#include "../soc/bpmp.h"
|
#include "../soc/bpmp.h"
|
||||||
#include "../soc/clock.h"
|
#include "../soc/clock.h"
|
||||||
|
#include "../soc/kfuse.h"
|
||||||
#include "../soc/smmu.h"
|
#include "../soc/smmu.h"
|
||||||
#include "../soc/t210.h"
|
#include "../soc/t210.h"
|
||||||
#include "../mem/heap.h"
|
#include "../mem/heap.h"
|
||||||
|
@ -78,6 +79,8 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt)
|
||||||
clock_enable_sor1();
|
clock_enable_sor1();
|
||||||
clock_enable_kfuse();
|
clock_enable_kfuse();
|
||||||
|
|
||||||
|
kfuse_wait_ready();
|
||||||
|
|
||||||
// Configure Falcon.
|
// Configure Falcon.
|
||||||
TSEC(TSEC_DMACTL) = 0;
|
TSEC(TSEC_DMACTL) = 0;
|
||||||
TSEC(TSEC_IRQMSET) =
|
TSEC(TSEC_IRQMSET) =
|
||||||
|
|
|
@ -18,16 +18,25 @@
|
||||||
#include "../soc/clock.h"
|
#include "../soc/clock.h"
|
||||||
#include "../soc/t210.h"
|
#include "../soc/t210.h"
|
||||||
|
|
||||||
|
int kfuse_wait_ready()
|
||||||
|
{
|
||||||
|
// Wait for KFUSE to finish init and verification of data.
|
||||||
|
while (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_DONE))
|
||||||
|
;
|
||||||
|
|
||||||
|
if (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_CRCPASS))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int kfuse_read(u32 *buf)
|
int kfuse_read(u32 *buf)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
clock_enable_kfuse();
|
clock_enable_kfuse();
|
||||||
|
|
||||||
while (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_DONE))
|
if (!kfuse_wait_ready())
|
||||||
;
|
|
||||||
|
|
||||||
if (!(KFUSE(KFUSE_STATE) & KFUSE_STATE_CRCPASS))
|
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
KFUSE(KFUSE_KEYADDR) = KFUSE_KEYADDR_AUTOINC;
|
KFUSE(KFUSE_KEYADDR) = KFUSE_KEYADDR_AUTOINC;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#define KFUSE_NUM_WORDS 144
|
#define KFUSE_NUM_WORDS 144
|
||||||
|
|
||||||
|
int kfuse_wait_ready();
|
||||||
int kfuse_read(u32 *buf);
|
int kfuse_read(u32 *buf);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue