mirror of
https://github.com/CTCaer/hekate
synced 2024-12-22 11:21:23 +00:00
bdk: timer: add instruction sleep
usage: `isleep(ILOOP(instructions))` Each loop is 3 cycles, or approximately 7.35ns on 408MHz CPU clock.
This commit is contained in:
parent
191a0533d9
commit
b674624ad0
3 changed files with 13 additions and 3 deletions
|
@ -85,7 +85,7 @@ static void _config_oscillators()
|
||||||
CLOCK(CLK_RST_CONTROLLER_CLK_SYSTEM_RATE) = 0x10; // Set HCLK div to 2 and PCLK div to 1.
|
CLOCK(CLK_RST_CONTROLLER_CLK_SYSTEM_RATE) = 0x10; // Set HCLK div to 2 and PCLK div to 1.
|
||||||
CLOCK(CLK_RST_CONTROLLER_PLLMB_BASE) &= 0xBFFFFFFF; // PLLMB disable.
|
CLOCK(CLK_RST_CONTROLLER_PLLMB_BASE) &= 0xBFFFFFFF; // PLLMB disable.
|
||||||
|
|
||||||
PMC(APBDEV_PMC_TSC_MULT) = (PMC(APBDEV_PMC_TSC_MULT) & 0xFFFF0000) | 0x249F; //0x249F = 19200000 * (16 / 32.768 kHz)
|
PMC(APBDEV_PMC_TSC_MULT) = (PMC(APBDEV_PMC_TSC_MULT) & 0xFFFF0000) | 0x249F; // 0x249F = 19200000 * (16 / 32.768 kHz).
|
||||||
|
|
||||||
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_SYS) = 0; // Set BPMP/SCLK div to 1.
|
CLOCK(CLK_RST_CONTROLLER_CLK_SOURCE_SYS) = 0; // Set BPMP/SCLK div to 1.
|
||||||
CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20004444; // Set BPMP/SCLK source to Run and PLLP_OUT2 (204MHz).
|
CLOCK(CLK_RST_CONTROLLER_SCLK_BURST_POLICY) = 0x20004444; // Set BPMP/SCLK source to Run and PLLP_OUT2 (204MHz).
|
||||||
|
@ -328,8 +328,10 @@ void hw_init()
|
||||||
// Bootrom stuff we skipped by going through rcm.
|
// Bootrom stuff we skipped by going through rcm.
|
||||||
_config_se_brom();
|
_config_se_brom();
|
||||||
//FUSE(FUSE_PRIVATEKEYDISABLE) = 0x11;
|
//FUSE(FUSE_PRIVATEKEYDISABLE) = 0x11;
|
||||||
SYSREG(AHB_AHB_SPARE_REG) &= 0xFFFFFF9F; // Unset APB2JTAG_OVERRIDE_EN and OBS_OVERRIDE_EN.
|
|
||||||
PMC(APBDEV_PMC_SCRATCH49) = PMC(APBDEV_PMC_SCRATCH49) & 0xFFFFFFFC;
|
// Unset APB2JTAG_OVERRIDE_EN and OBS_OVERRIDE_EN.
|
||||||
|
SYSREG(AHB_AHB_SPARE_REG) &= 0xFFFFFF9F;
|
||||||
|
PMC(APBDEV_PMC_SCRATCH49) &= 0xFFFFFFFC;
|
||||||
|
|
||||||
// Perform Memory Built-In Self Test WAR if T210.
|
// Perform Memory Built-In Self Test WAR if T210.
|
||||||
if (tegra_t210)
|
if (tegra_t210)
|
||||||
|
|
|
@ -71,6 +71,12 @@ void usleep(u32 us)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Instruction wait loop. Each loop is 3 cycles (SUBS+BGT). Usage: isleep(ILOOP(instr)). Base 408MHz: 7.35ns.
|
||||||
|
void __attribute__((target("arm"))) isleep(u32 is)
|
||||||
|
{
|
||||||
|
asm volatile( "0:" "SUBS %[is_cnt], #1;" "BGT 0b;" : [is_cnt] "+r" (is));
|
||||||
|
}
|
||||||
|
|
||||||
void timer_usleep(u32 us)
|
void timer_usleep(u32 us)
|
||||||
{
|
{
|
||||||
TMR(TIMER_TMR8_TMR_PTV) = TIMER_EN | us;
|
TMR(TIMER_TMR8_TMR_PTV) = TIMER_EN | us;
|
||||||
|
|
|
@ -51,6 +51,8 @@ u32 get_tmr_ms();
|
||||||
u32 get_tmr_s();
|
u32 get_tmr_s();
|
||||||
void usleep(u32 us);
|
void usleep(u32 us);
|
||||||
void msleep(u32 ms);
|
void msleep(u32 ms);
|
||||||
|
#define ILOOP(is) ((is) / 3)
|
||||||
|
void isleep(u32 is);
|
||||||
|
|
||||||
void timer_usleep(u32 us);
|
void timer_usleep(u32 us);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue