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 "gpio.h"
#include "pmc.h"
#include "uart.h"
#include "t210.h"
#include "../mem/minerva.h"
#include "../gfx/di.h"
#include "../input/joycon.h"
#include "../input/touch.h"
#include "../power/regulator_5v.h"
#include "../storage/nx_sd.h"
@ -38,10 +40,13 @@ void reconfig_hw_workaround(bool extra_reconfig, u32 magic)
// Disable BPMP max clock.
bpmp_clk_rate_set(BPMP_CLK_NORMAL);
// Deinit touchscreen and 5V regulators.
// Deinit touchscreen, 5V regulators and Joy-Con.
touch_power_off();
set_fan_duty(0);
jc_deinit();
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.
bpmp_mmu_disable();

View file

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