From c5b64a2b580eec48560aaa4b20f593390b5d582c Mon Sep 17 00:00:00 2001 From: CTCaer Date: Wed, 11 Sep 2019 02:19:41 +0300 Subject: [PATCH] tsec: Don't disable HOST1x clock because it's used Tsec keys function always disabled host1x clock after running. This interferes with display interface and disables further window frame syncing. Display_end code already handles disable and reset of said clock. It also fixes an ancient bug that was mitigated by removing the 5 frame sync on HOST1X_SYNC_SYNCPT_9 at channel 0: https://github.com/CTCaer/hekate/commit/5fd9daa3642216ae8a28f6cb662a262e29e7ce06#diff-6b0c56eab8515465d559ff0ea73a22c3L152 --- bootloader/sec/tsec.c | 18 +++++++++--------- bootloader/soc/t210.h | 5 +++++ nyx/nyx_gui/frontend/gui.c | 2 -- nyx/nyx_gui/sec/tsec.c | 18 +++++++++--------- nyx/nyx_gui/soc/t210.h | 5 +++++ 5 files changed, 28 insertions(+), 20 deletions(-) diff --git a/bootloader/sec/tsec.c b/bootloader/sec/tsec.c index fe1256d..06120e1 100644 --- a/bootloader/sec/tsec.c +++ b/bootloader/sec/tsec.c @@ -69,15 +69,16 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt) bpmp_mmu_disable(); bpmp_clk_rate_set(BPMP_CLK_NORMAL); - //Enable clocks. + // Enable clocks. clock_enable_host1x(); + usleep(2); clock_enable_tsec(); clock_enable_sor_safe(); clock_enable_sor0(); clock_enable_sor1(); clock_enable_kfuse(); - //Configure Falcon. + // Configure Falcon. TSEC(TSEC_DMACTL) = 0; TSEC(TSEC_IRQMSET) = TSEC_IRQMSET_EXT(0xFF) | @@ -99,7 +100,7 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt) goto out; } - //Load firmware or emulate memio environment for newer TSEC fw. + // Load firmware or emulate memio environment for newer TSEC fw. if (kb == KB_FIRMWARE_VERSION_620) TSEC(TSEC_DMATRFBASE) = (u32)tsec_ctxt->fw >> 8; else @@ -174,8 +175,8 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt) smmu_map(pdir, EXCP_VEC_BASE, (u32)evec, 1, _READABLE | _WRITABLE | _NONSECURE); } - //Execute firmware. - HOST1X(0x3300) = 0x34C2E1DA; + // Execute firmware. + HOST1X(HOST1X_CH0_SYNC_SYNCPT_160) = 0x34C2E1DA; TSEC(TSEC_STATUS) = 0; TSEC(TSEC_BOOTKEYVER) = 1; // HOS uses key version 1. TSEC(TSEC_BOOTVEC) = 0; @@ -251,8 +252,8 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt) goto out_free; } - //Fetch result. - HOST1X(0x3300) = 0; + // Fetch result. + HOST1X(HOST1X_CH0_SYNC_SYNCPT_160) = 0; u32 buf[4]; buf[0] = SOR1(SOR_NV_PDISP_SOR_DP_HDCP_BKSV_LSB); buf[1] = SOR1(SOR_NV_PDISP_SOR_TMDS_HDCP_BKSV_LSB); @@ -271,13 +272,12 @@ out_free:; out:; - //Disable clocks. + // Disable clocks. clock_disable_kfuse(); clock_disable_sor1(); clock_disable_sor0(); clock_disable_sor_safe(); clock_disable_tsec(); - clock_disable_host1x(); bpmp_mmu_enable(); bpmp_clk_rate_set(BPMP_CLK_SUPER_BOOST); diff --git a/bootloader/soc/t210.h b/bootloader/soc/t210.h index 5d372a8..2f7fadd 100644 --- a/bootloader/soc/t210.h +++ b/bootloader/soc/t210.h @@ -101,6 +101,11 @@ #define CL_DVFS(off) _REG(CL_DVFS_BASE, off) #define TEST_REG(off) _REG(0x0, off) +/* HOST1X registers. */ +#define HOST1X_CH0_SYNC_BASE 0x2100 +#define HOST1X_CH0_SYNC_SYNCPT_9 (HOST1X_CH0_SYNC_BASE + 0xFA4) +#define HOST1X_CH0_SYNC_SYNCPT_160 (HOST1X_CH0_SYNC_BASE + 0x1200) + /*! EVP registers. */ #define EVP_CPU_RESET_VECTOR 0x100 diff --git a/nyx/nyx_gui/frontend/gui.c b/nyx/nyx_gui/frontend/gui.c index db8903a..d30c92f 100644 --- a/nyx/nyx_gui/frontend/gui.c +++ b/nyx/nyx_gui/frontend/gui.c @@ -693,8 +693,6 @@ static void _create_text_button(lv_theme_t *th, lv_obj_t *parent, lv_obj_t *btn, lv_btn_set_action(btn, LV_BTN_ACTION_CLICK, action); } - - static void _create_tab_about(lv_theme_t * th, lv_obj_t * parent) { lv_obj_t * lbl_credits = lv_label_create(parent, NULL); diff --git a/nyx/nyx_gui/sec/tsec.c b/nyx/nyx_gui/sec/tsec.c index fe1256d..06120e1 100644 --- a/nyx/nyx_gui/sec/tsec.c +++ b/nyx/nyx_gui/sec/tsec.c @@ -69,15 +69,16 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt) bpmp_mmu_disable(); bpmp_clk_rate_set(BPMP_CLK_NORMAL); - //Enable clocks. + // Enable clocks. clock_enable_host1x(); + usleep(2); clock_enable_tsec(); clock_enable_sor_safe(); clock_enable_sor0(); clock_enable_sor1(); clock_enable_kfuse(); - //Configure Falcon. + // Configure Falcon. TSEC(TSEC_DMACTL) = 0; TSEC(TSEC_IRQMSET) = TSEC_IRQMSET_EXT(0xFF) | @@ -99,7 +100,7 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt) goto out; } - //Load firmware or emulate memio environment for newer TSEC fw. + // Load firmware or emulate memio environment for newer TSEC fw. if (kb == KB_FIRMWARE_VERSION_620) TSEC(TSEC_DMATRFBASE) = (u32)tsec_ctxt->fw >> 8; else @@ -174,8 +175,8 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt) smmu_map(pdir, EXCP_VEC_BASE, (u32)evec, 1, _READABLE | _WRITABLE | _NONSECURE); } - //Execute firmware. - HOST1X(0x3300) = 0x34C2E1DA; + // Execute firmware. + HOST1X(HOST1X_CH0_SYNC_SYNCPT_160) = 0x34C2E1DA; TSEC(TSEC_STATUS) = 0; TSEC(TSEC_BOOTKEYVER) = 1; // HOS uses key version 1. TSEC(TSEC_BOOTVEC) = 0; @@ -251,8 +252,8 @@ int tsec_query(u8 *tsec_keys, u8 kb, tsec_ctxt_t *tsec_ctxt) goto out_free; } - //Fetch result. - HOST1X(0x3300) = 0; + // Fetch result. + HOST1X(HOST1X_CH0_SYNC_SYNCPT_160) = 0; u32 buf[4]; buf[0] = SOR1(SOR_NV_PDISP_SOR_DP_HDCP_BKSV_LSB); buf[1] = SOR1(SOR_NV_PDISP_SOR_TMDS_HDCP_BKSV_LSB); @@ -271,13 +272,12 @@ out_free:; out:; - //Disable clocks. + // Disable clocks. clock_disable_kfuse(); clock_disable_sor1(); clock_disable_sor0(); clock_disable_sor_safe(); clock_disable_tsec(); - clock_disable_host1x(); bpmp_mmu_enable(); bpmp_clk_rate_set(BPMP_CLK_SUPER_BOOST); diff --git a/nyx/nyx_gui/soc/t210.h b/nyx/nyx_gui/soc/t210.h index 5d372a8..2f7fadd 100644 --- a/nyx/nyx_gui/soc/t210.h +++ b/nyx/nyx_gui/soc/t210.h @@ -101,6 +101,11 @@ #define CL_DVFS(off) _REG(CL_DVFS_BASE, off) #define TEST_REG(off) _REG(0x0, off) +/* HOST1X registers. */ +#define HOST1X_CH0_SYNC_BASE 0x2100 +#define HOST1X_CH0_SYNC_SYNCPT_9 (HOST1X_CH0_SYNC_BASE + 0xFA4) +#define HOST1X_CH0_SYNC_SYNCPT_160 (HOST1X_CH0_SYNC_BASE + 0x1200) + /*! EVP registers. */ #define EVP_CPU_RESET_VECTOR 0x100