1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-29 13:02:09 +00:00

hwinit: Add proper deinit for new components

This commit is contained in:
CTCaer 2020-04-30 15:09:25 +03:00
parent 81f0c0a0dc
commit 448cc49cff
2 changed files with 11 additions and 11 deletions

View file

@ -21,9 +21,11 @@
#include "clock.h" #include "clock.h"
#include "gpio.h" #include "gpio.h"
#include "pmc.h" #include "pmc.h"
#include "uart.h"
#include "t210.h" #include "t210.h"
#include "../mem/minerva.h" #include "../mem/minerva.h"
#include "../gfx/di.h" #include "../gfx/di.h"
#include "../input/joycon.h"
#include "../input/touch.h" #include "../input/touch.h"
#include "../power/regulator_5v.h" #include "../power/regulator_5v.h"
#include "../storage/nx_sd.h" #include "../storage/nx_sd.h"
@ -38,10 +40,13 @@ void reconfig_hw_workaround(bool extra_reconfig, u32 magic)
// Disable BPMP max clock. // Disable BPMP max clock.
bpmp_clk_rate_set(BPMP_CLK_NORMAL); bpmp_clk_rate_set(BPMP_CLK_NORMAL);
// Deinit touchscreen and 5V regulators. // Deinit touchscreen, 5V regulators and Joy-Con.
touch_power_off(); touch_power_off();
set_fan_duty(0); set_fan_duty(0);
jc_deinit();
regulator_disable_5v(REGULATOR_5V_ALL); regulator_disable_5v(REGULATOR_5V_ALL);
clock_disable_uart(UART_B);
clock_disable_uart(UART_C);
// Flush/disable MMU cache and set DRAM clock to 204MHz. // Flush/disable MMU cache and set DRAM clock to 204MHz.
bpmp_mmu_disable(); bpmp_mmu_disable();

View file

@ -22,6 +22,7 @@
#include "../power/max77620.h" #include "../power/max77620.h"
#include "../rtc/max77620-rtc.h" #include "../rtc/max77620-rtc.h"
#include "../soc/bpmp.h" #include "../soc/bpmp.h"
#include "../soc/hw_init.h"
#include "../soc/i2c.h" #include "../soc/i2c.h"
#include "../soc/pmc.h" #include "../soc/pmc.h"
#include "../soc/t210.h" #include "../soc/t210.h"
@ -135,10 +136,8 @@ void panic(u32 val)
void reboot_normal() void reboot_normal()
{ {
bpmp_mmu_disable();
sd_unmount(true); sd_unmount(true);
display_end(); reconfig_hw_workaround(false, 0);
nyx_str->mtc_cfg.init_done = 0; nyx_str->mtc_cfg.init_done = 0;
@ -147,14 +146,10 @@ void reboot_normal()
void reboot_rcm() void reboot_rcm()
{ {
bpmp_mmu_disable();
sd_unmount(true); sd_unmount(true);
display_end(); reconfig_hw_workaround(false, 0);
nyx_str->mtc_cfg.init_done = 0; PMC(APBDEV_PMC_SCRATCH0) = PMC_SCRATCH0_MODE_RCM;
PMC(APBDEV_PMC_SCRATCH0) = 2; // Reboot into rcm.
PMC(APBDEV_PMC_CNTRL) |= PMC_CNTRL_MAIN_RST; PMC(APBDEV_PMC_CNTRL) |= PMC_CNTRL_MAIN_RST;
while (true) while (true)
@ -164,7 +159,7 @@ void reboot_rcm()
void power_off() void power_off()
{ {
sd_unmount(true); sd_unmount(true);
display_end(); reconfig_hw_workaround(false, 0);
// Stop the alarm, in case we injected and powered off too fast. // Stop the alarm, in case we injected and powered off too fast.
max77620_rtc_stop_alarm(); max77620_rtc_stop_alarm();