From 4ca53e2ef1cc8dfa266e80511c0e360b0fd97ac0 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 3 May 2019 05:18:36 -0700 Subject: [PATCH] boot: implement SetInitialClockConfiguration --- .../boot_clock_initial_configuration.cpp | 26 +++++++++++++++++++ stratosphere/boot/source/boot_functions.hpp | 1 + stratosphere/boot/source/boot_main.cpp | 12 ++++----- .../boot/source/boot_registers_pmc.hpp | 1 + 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 stratosphere/boot/source/boot_clock_initial_configuration.cpp diff --git a/stratosphere/boot/source/boot_clock_initial_configuration.cpp b/stratosphere/boot/source/boot_clock_initial_configuration.cpp new file mode 100644 index 000000000..f70ffaa21 --- /dev/null +++ b/stratosphere/boot/source/boot_clock_initial_configuration.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018-2019 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "boot_functions.hpp" +#include "boot_registers_pmc.hpp" + +static constexpr u32 PmcClkOutCntrl = PmcBase + APBDEV_PMC_CLK_OUT_CNTRL; +static constexpr u32 InitialClockOutMask = 0xC4C4; + +void Boot::SetInitialClockConfiguration() { + /* Write mask to APBDEV_PMC_PWR_DET, then clear APBDEV_PMC_PWR_DET_VAL. */ + WritePmcRegister(PmcClkOutCntrl, InitialClockOutMask, InitialClockOutMask); +} diff --git a/stratosphere/boot/source/boot_functions.hpp b/stratosphere/boot/source/boot_functions.hpp index 407c93650..c48d64e2d 100644 --- a/stratosphere/boot/source/boot_functions.hpp +++ b/stratosphere/boot/source/boot_functions.hpp @@ -31,6 +31,7 @@ class Boot { static void CheckClock(); static void DetectBootReason(); static void ShowSplashScreen(); + static void SetInitialClockConfiguration(); /* Power utilities. */ static void RebootSystem(); diff --git a/stratosphere/boot/source/boot_main.cpp b/stratosphere/boot/source/boot_main.cpp index 20db1c598..83d64b829 100644 --- a/stratosphere/boot/source/boot_main.cpp +++ b/stratosphere/boot/source/boot_main.cpp @@ -107,9 +107,7 @@ int main(int argc, char **argv) consoleDebugInit(debugDevice_SVC); /* TODO: Implement the boot sysmodule -- boot_old to be broadly rewritten. */ - - /* TODO: Explicitly: */ - + /* Change voltage from 3.3v to 1.8v for select devices. */ Boot::ChangeGpioVoltageTo1_8v(); @@ -129,12 +127,14 @@ int main(int argc, char **argv) /* TODO: SetInitialWakePinConfiguration(); */ - /* TODO: SetInitialClockConfiguration(); */ + Boot::SetInitialClockConfiguration(); /* TODO: CheckAndRepairBootImages(); */ - /* TODO: NotifyBootFinished(); */ - + /* Tell PM to start boot2. */ + if (R_FAILED(pmshellNotifyBootFinished())) { + std::abort(); + } return 0; } diff --git a/stratosphere/boot/source/boot_registers_pmc.hpp b/stratosphere/boot/source/boot_registers_pmc.hpp index 08f4e98fe..356cf94ad 100644 --- a/stratosphere/boot/source/boot_registers_pmc.hpp +++ b/stratosphere/boot/source/boot_registers_pmc.hpp @@ -39,6 +39,7 @@ static constexpr u32 PMC_CRYPTO_OP_SE_DISABLE = 1; static constexpr size_t APBDEV_PMC_SCRATCH33 = 0x120; static constexpr size_t APBDEV_PMC_SCRATCH40 = 0x13C; static constexpr size_t APBDEV_PMC_OSC_EDPD_OVER = 0x1A4; +static constexpr size_t APBDEV_PMC_CLK_OUT_CNTRL = 0x1A8; static constexpr size_t APBDEV_PMC_RST_STATUS = 0x1B4; static constexpr size_t APBDEV_PMC_IO_DPD_REQ = 0x1B8; static constexpr size_t APBDEV_PMC_IO_DPD2_REQ = 0x1C0;