boot: implement SetInitialClockConfiguration

This commit is contained in:
Michael Scire 2019-05-03 05:18:36 -07:00
parent d9da531b41
commit 4ca53e2ef1
4 changed files with 34 additions and 6 deletions

View file

@ -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 <http://www.gnu.org/licenses/>.
*/
#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);
}

View file

@ -31,6 +31,7 @@ class Boot {
static void CheckClock();
static void DetectBootReason();
static void ShowSplashScreen();
static void SetInitialClockConfiguration();
/* Power utilities. */
static void RebootSystem();

View file

@ -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;
}

View file

@ -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;