From 448cc49cff621152f06d9b1a089268039894a0c9 Mon Sep 17 00:00:00 2001 From: CTCaer Date: Thu, 30 Apr 2020 15:09:25 +0300 Subject: [PATCH] hwinit: Add proper deinit for new components --- nyx/nyx_gui/soc/hw_init.c | 7 ++++++- nyx/nyx_gui/utils/util.c | 15 +++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nyx/nyx_gui/soc/hw_init.c b/nyx/nyx_gui/soc/hw_init.c index 3528f69..45482cc 100644 --- a/nyx/nyx_gui/soc/hw_init.c +++ b/nyx/nyx_gui/soc/hw_init.c @@ -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(); diff --git a/nyx/nyx_gui/utils/util.c b/nyx/nyx_gui/utils/util.c index a7e2b1f..b718b0d 100644 --- a/nyx/nyx_gui/utils/util.c +++ b/nyx/nyx_gui/utils/util.c @@ -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();