From 804e5d49bbcd8306cfd657032b58b116eb5e5aee Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 22 Jun 2019 11:34:18 -0700 Subject: [PATCH] boot: split out gpio, pinmux. --- stratosphere/boot/Makefile | 2 +- stratosphere/boot/source/boot_boot_reason.cpp | 2 +- .../boot/source/boot_charger_driver.hpp | 3 ++- stratosphere/boot/source/boot_display.cpp | 2 +- stratosphere/boot/source/boot_fan_enable.cpp | 5 +++-- stratosphere/boot/source/boot_main.cpp | 11 +++++----- .../boot/source/boot_repair_boot_images.cpp | 2 +- stratosphere/boot/source/boot_spl_utils.cpp | 2 +- stratosphere/boot/source/boot_spl_utils.hpp | 8 ++----- stratosphere/boot/source/boot_wake_pins.cpp | 2 +- .../gpio_initial_configuration.cpp} | 20 +++++++++-------- .../gpio_initial_configuration.hpp} | 2 +- .../gpio_initial_configuration_copper.inc} | 0 .../gpio_initial_configuration_hoag.inc} | 0 .../gpio_initial_configuration_icosa.inc} | 0 .../gpio_initial_configuration_iowa.inc} | 0 .../{boot_gpio_map.inc => gpio/gpio_map.inc} | 0 .../gpio_utils.cpp} | 6 ++--- .../gpio_utils.hpp} | 4 +--- .../pinmux_initial_configuration.cpp} | 22 ++++++++++--------- .../pinmux_initial_configuration.hpp} | 2 +- .../pinmux_initial_configuration_copper.inc} | 0 .../pinmux_initial_configuration_hoag.inc} | 0 .../pinmux_initial_configuration_icosa.inc} | 0 .../pinmux_initial_configuration_iowa.inc} | 0 ...inmux_initial_drive_pad_configuration.inc} | 0 .../pinmux_map.inc} | 0 .../pinmux_utils.cpp} | 6 ++--- .../pinmux_utils.hpp} | 2 +- 29 files changed, 52 insertions(+), 51 deletions(-) rename stratosphere/boot/source/{boot_gpio_initial_configuration.cpp => gpio/gpio_initial_configuration.cpp} (88%) rename stratosphere/boot/source/{boot_gpio_initial_configuration.hpp => gpio/gpio_initial_configuration.hpp} (96%) rename stratosphere/boot/source/{boot_gpio_initial_configuration_copper.inc => gpio/gpio_initial_configuration_copper.inc} (100%) rename stratosphere/boot/source/{boot_gpio_initial_configuration_hoag.inc => gpio/gpio_initial_configuration_hoag.inc} (100%) rename stratosphere/boot/source/{boot_gpio_initial_configuration_icosa.inc => gpio/gpio_initial_configuration_icosa.inc} (100%) rename stratosphere/boot/source/{boot_gpio_initial_configuration_iowa.inc => gpio/gpio_initial_configuration_iowa.inc} (100%) rename stratosphere/boot/source/{boot_gpio_map.inc => gpio/gpio_map.inc} (100%) rename stratosphere/boot/source/{boot_gpio_utils.cpp => gpio/gpio_utils.cpp} (98%) rename stratosphere/boot/source/{boot_gpio_utils.hpp => gpio/gpio_utils.hpp} (93%) rename stratosphere/boot/source/{boot_pinmux_initial_configuration.cpp => pinmux/pinmux_initial_configuration.cpp} (87%) rename stratosphere/boot/source/{boot_pinmux_initial_configuration.hpp => pinmux/pinmux_initial_configuration.hpp} (96%) rename stratosphere/boot/source/{boot_pinmux_initial_configuration_copper.inc => pinmux/pinmux_initial_configuration_copper.inc} (100%) rename stratosphere/boot/source/{boot_pinmux_initial_configuration_hoag.inc => pinmux/pinmux_initial_configuration_hoag.inc} (100%) rename stratosphere/boot/source/{boot_pinmux_initial_configuration_icosa.inc => pinmux/pinmux_initial_configuration_icosa.inc} (100%) rename stratosphere/boot/source/{boot_pinmux_initial_configuration_iowa.inc => pinmux/pinmux_initial_configuration_iowa.inc} (100%) rename stratosphere/boot/source/{boot_pinmux_initial_drive_pad_configuration.inc => pinmux/pinmux_initial_drive_pad_configuration.inc} (100%) rename stratosphere/boot/source/{boot_pinmux_map.inc => pinmux/pinmux_map.inc} (100%) rename stratosphere/boot/source/{boot_pinmux_utils.cpp => pinmux/pinmux_utils.cpp} (99%) rename stratosphere/boot/source/{boot_pinmux_utils.hpp => pinmux/pinmux_utils.hpp} (97%) diff --git a/stratosphere/boot/Makefile b/stratosphere/boot/Makefile index 6bf16b0bd..8574f6933 100644 --- a/stratosphere/boot/Makefile +++ b/stratosphere/boot/Makefile @@ -33,7 +33,7 @@ endef #--------------------------------------------------------------------------------- TARGET := $(notdir $(CURDIR)) BUILD := build -SOURCES := source source/i2c source/i2c/driver source/i2c/driver/impl source/updater +SOURCES := source source/i2c source/i2c/driver source/i2c/driver/impl source/updater source/gpio source/pinmux DATA := data INCLUDES := include ../../common/include EXEFS_SRC := exefs_src diff --git a/stratosphere/boot/source/boot_boot_reason.cpp b/stratosphere/boot/source/boot_boot_reason.cpp index fc5634cba..fdad4f068 100644 --- a/stratosphere/boot/source/boot_boot_reason.cpp +++ b/stratosphere/boot/source/boot_boot_reason.cpp @@ -52,7 +52,7 @@ namespace sts::boot { return 1; } if (rtc_intr & 0x04) { - if (nv_erc != 0x80 && !IsRecoveryBoot()) { + if (nv_erc != 0x80 && !spl::IsRecoveryBoot()) { return 4; } } diff --git a/stratosphere/boot/source/boot_charger_driver.hpp b/stratosphere/boot/source/boot_charger_driver.hpp index 85f68a964..a09990806 100644 --- a/stratosphere/boot/source/boot_charger_driver.hpp +++ b/stratosphere/boot/source/boot_charger_driver.hpp @@ -19,9 +19,10 @@ #include #include "boot_bq24193_charger.hpp" -#include "boot_gpio_utils.hpp" #include "boot_i2c_utils.hpp" +#include "gpio/gpio_utils.hpp" + namespace sts::boot { class ChargerDriver { diff --git a/stratosphere/boot/source/boot_display.cpp b/stratosphere/boot/source/boot_display.cpp index 2747ebee6..eb3994f99 100644 --- a/stratosphere/boot/source/boot_display.cpp +++ b/stratosphere/boot/source/boot_display.cpp @@ -199,7 +199,7 @@ namespace sts::boot { void InitializeDisplay() { /* Setup globals. */ InitializeRegisterBaseAddresses(); - g_is_mariko = IsMariko(); + g_is_mariko = spl::IsMariko(); InitializeFrameBuffer(); /* Turn on DSI/voltage rail. */ diff --git a/stratosphere/boot/source/boot_fan_enable.cpp b/stratosphere/boot/source/boot_fan_enable.cpp index 41daa9ea6..190c0b600 100644 --- a/stratosphere/boot/source/boot_fan_enable.cpp +++ b/stratosphere/boot/source/boot_fan_enable.cpp @@ -15,9 +15,10 @@ */ #include "boot_fan_enable.hpp" -#include "boot_gpio_utils.hpp" #include "boot_spl_utils.hpp" +#include "gpio/gpio_utils.hpp" + namespace sts::boot { namespace { @@ -28,7 +29,7 @@ namespace sts::boot { } void SetFanEnabled() { - if (GetHardwareType() == spl::HardwareType::Copper) { + if (spl::GetHardwareType() == spl::HardwareType::Copper) { gpio::Configure(GpioPadName_FanEnable); gpio::SetDirection(GpioPadName_FanEnable, GpioDirection_Output); gpio::SetValue(GpioPadName_FanEnable, GpioValue_High); diff --git a/stratosphere/boot/source/boot_main.cpp b/stratosphere/boot/source/boot_main.cpp index 4e1203cc6..a28b72a09 100644 --- a/stratosphere/boot/source/boot_main.cpp +++ b/stratosphere/boot/source/boot_main.cpp @@ -29,12 +29,13 @@ #include "boot_check_clock.hpp" #include "boot_clock_initial_configuration.hpp" #include "boot_fan_enable.hpp" -#include "boot_gpio_initial_configuration.hpp" -#include "boot_pinmux_initial_configuration.hpp" #include "boot_repair_boot_images.hpp" #include "boot_splash_screen.hpp" #include "boot_wake_pins.hpp" +#include "gpio/gpio_initial_configuration.hpp" +#include "pinmux/pinmux_initial_configuration.hpp" + #include "boot_power_utils.hpp" #include "boot_spl_utils.hpp" @@ -111,7 +112,7 @@ int main(int argc, char **argv) boot::ChangeGpioVoltageTo1_8v(); /* Setup GPIO. */ - boot::gpio::SetInitialConfiguration(); + gpio::SetInitialConfiguration(); /* Check USB PLL/UTMIP clock. */ boot::CheckClock(); @@ -119,7 +120,7 @@ int main(int argc, char **argv) /* Talk to PMIC/RTC, set boot reason with SPL. */ boot::DetectBootReason(); - const auto hw_type = boot::GetHardwareType(); + const auto hw_type = spl::GetHardwareType(); if (hw_type != spl::HardwareType::Copper) { /* Display splash screen for two seconds. */ boot::ShowSplashScreen(); @@ -129,7 +130,7 @@ int main(int argc, char **argv) } /* Configure pinmux + drive pads. */ - boot::pinmux::SetInitialConfiguration(); + pinmux::SetInitialConfiguration(); /* Configure the PMC wake pin settings. */ boot::SetInitialWakePinConfiguration(); diff --git a/stratosphere/boot/source/boot_repair_boot_images.cpp b/stratosphere/boot/source/boot_repair_boot_images.cpp index b807f78cb..78fd8fa27 100644 --- a/stratosphere/boot/source/boot_repair_boot_images.cpp +++ b/stratosphere/boot/source/boot_repair_boot_images.cpp @@ -30,7 +30,7 @@ namespace sts::boot { } void CheckAndRepairBootImages() { - const auto boot_image_update_type = updater::GetBootImageUpdateType(GetHardwareType()); + const auto boot_image_update_type = updater::GetBootImageUpdateType(spl::GetHardwareType()); bool repaired_normal, repaired_safe; if (R_SUCCEEDED(updater::VerifyBootImagesAndRepairIfNeeded(&repaired_normal, &repaired_safe, g_boot_image_work_buffer, sizeof(g_boot_image_work_buffer), boot_image_update_type)) && repaired_normal) { diff --git a/stratosphere/boot/source/boot_spl_utils.cpp b/stratosphere/boot/source/boot_spl_utils.cpp index d0ef1ab96..d5e60e1bd 100644 --- a/stratosphere/boot/source/boot_spl_utils.cpp +++ b/stratosphere/boot/source/boot_spl_utils.cpp @@ -16,7 +16,7 @@ #include "boot_spl_utils.hpp" -namespace sts::boot { +namespace sts::spl { spl::HardwareType GetHardwareType() { u64 out_val = 0; diff --git a/stratosphere/boot/source/boot_spl_utils.hpp b/stratosphere/boot/source/boot_spl_utils.hpp index 50292347b..a12171fca 100644 --- a/stratosphere/boot/source/boot_spl_utils.hpp +++ b/stratosphere/boot/source/boot_spl_utils.hpp @@ -27,13 +27,9 @@ namespace sts::spl { Iowa = 3, }; -} - -namespace sts::boot { - /* SPL Utilities. */ - spl::HardwareType GetHardwareType(); + HardwareType GetHardwareType(); bool IsRecoveryBoot(); bool IsMariko(); -} +} \ No newline at end of file diff --git a/stratosphere/boot/source/boot_wake_pins.cpp b/stratosphere/boot/source/boot_wake_pins.cpp index 43fd1462f..9df434f7e 100644 --- a/stratosphere/boot/source/boot_wake_pins.cpp +++ b/stratosphere/boot/source/boot_wake_pins.cpp @@ -95,7 +95,7 @@ namespace sts::boot { /* Set wake event levels, wake event enables. */ const WakePinConfig *configs; size_t num_configs; - if (GetHardwareType() == spl::HardwareType::Copper) { + if (spl::GetHardwareType() == spl::HardwareType::Copper) { configs = WakePinConfigsCopper; num_configs = NumWakePinConfigsCopper; } else { diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration.cpp b/stratosphere/boot/source/gpio/gpio_initial_configuration.cpp similarity index 88% rename from stratosphere/boot/source/boot_gpio_initial_configuration.cpp rename to stratosphere/boot/source/gpio/gpio_initial_configuration.cpp index 67036d3ed..c516be829 100644 --- a/stratosphere/boot/source/boot_gpio_initial_configuration.cpp +++ b/stratosphere/boot/source/gpio/gpio_initial_configuration.cpp @@ -14,11 +14,13 @@ * along with this program. If not, see . */ -#include "boot_gpio_initial_configuration.hpp" -#include "boot_gpio_utils.hpp" -#include "boot_spl_utils.hpp" +#include "gpio_initial_configuration.hpp" +#include "gpio_utils.hpp" -namespace sts::boot::gpio { +/* TODO: Better way? */ +#include "../boot_spl_utils.hpp" + +namespace sts::gpio { namespace { @@ -29,17 +31,17 @@ namespace sts::boot::gpio { }; /* Include all initial configuration definitions. */ -#include "boot_gpio_initial_configuration_icosa.inc" -#include "boot_gpio_initial_configuration_copper.inc" -#include "boot_gpio_initial_configuration_hoag.inc" -#include "boot_gpio_initial_configuration_iowa.inc" +#include "gpio_initial_configuration_icosa.inc" +#include "gpio_initial_configuration_copper.inc" +#include "gpio_initial_configuration_hoag.inc" +#include "gpio_initial_configuration_iowa.inc" } void SetInitialConfiguration() { const InitialConfig *configs = nullptr; size_t num_configs = 0; - const auto hw_type = GetHardwareType(); + const auto hw_type = spl::GetHardwareType(); const FirmwareVersion fw_ver = GetRuntimeFirmwareVersion(); /* Choose GPIO map. */ diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration.hpp b/stratosphere/boot/source/gpio/gpio_initial_configuration.hpp similarity index 96% rename from stratosphere/boot/source/boot_gpio_initial_configuration.hpp rename to stratosphere/boot/source/gpio/gpio_initial_configuration.hpp index f7bdb7cb4..030ef89df 100644 --- a/stratosphere/boot/source/boot_gpio_initial_configuration.hpp +++ b/stratosphere/boot/source/gpio/gpio_initial_configuration.hpp @@ -18,7 +18,7 @@ #include #include -namespace sts::boot::gpio { +namespace sts::gpio { void SetInitialConfiguration(); diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration_copper.inc b/stratosphere/boot/source/gpio/gpio_initial_configuration_copper.inc similarity index 100% rename from stratosphere/boot/source/boot_gpio_initial_configuration_copper.inc rename to stratosphere/boot/source/gpio/gpio_initial_configuration_copper.inc diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration_hoag.inc b/stratosphere/boot/source/gpio/gpio_initial_configuration_hoag.inc similarity index 100% rename from stratosphere/boot/source/boot_gpio_initial_configuration_hoag.inc rename to stratosphere/boot/source/gpio/gpio_initial_configuration_hoag.inc diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration_icosa.inc b/stratosphere/boot/source/gpio/gpio_initial_configuration_icosa.inc similarity index 100% rename from stratosphere/boot/source/boot_gpio_initial_configuration_icosa.inc rename to stratosphere/boot/source/gpio/gpio_initial_configuration_icosa.inc diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration_iowa.inc b/stratosphere/boot/source/gpio/gpio_initial_configuration_iowa.inc similarity index 100% rename from stratosphere/boot/source/boot_gpio_initial_configuration_iowa.inc rename to stratosphere/boot/source/gpio/gpio_initial_configuration_iowa.inc diff --git a/stratosphere/boot/source/boot_gpio_map.inc b/stratosphere/boot/source/gpio/gpio_map.inc similarity index 100% rename from stratosphere/boot/source/boot_gpio_map.inc rename to stratosphere/boot/source/gpio/gpio_map.inc diff --git a/stratosphere/boot/source/boot_gpio_utils.cpp b/stratosphere/boot/source/gpio/gpio_utils.cpp similarity index 98% rename from stratosphere/boot/source/boot_gpio_utils.cpp rename to stratosphere/boot/source/gpio/gpio_utils.cpp index 862668718..778f3a98d 100644 --- a/stratosphere/boot/source/boot_gpio_utils.cpp +++ b/stratosphere/boot/source/gpio/gpio_utils.cpp @@ -16,14 +16,14 @@ #include -#include "boot_gpio_utils.hpp" +#include "gpio_utils.hpp" -namespace sts::boot::gpio { +namespace sts::gpio { namespace { /* Pull in GPIO map definitions. */ -#include "boot_gpio_map.inc" +#include "gpio_map.inc" constexpr u32 PhysicalBase = 0x6000D000; diff --git a/stratosphere/boot/source/boot_gpio_utils.hpp b/stratosphere/boot/source/gpio/gpio_utils.hpp similarity index 93% rename from stratosphere/boot/source/boot_gpio_utils.hpp rename to stratosphere/boot/source/gpio/gpio_utils.hpp index 4a281de78..ce395148d 100644 --- a/stratosphere/boot/source/boot_gpio_utils.hpp +++ b/stratosphere/boot/source/gpio/gpio_utils.hpp @@ -18,9 +18,7 @@ #include #include -#include "i2c/driver/i2c_api.hpp" - -namespace sts::boot::gpio { +namespace sts::gpio { /* GPIO Utilities. */ u32 Configure(u32 gpio_pad_name); diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration.cpp b/stratosphere/boot/source/pinmux/pinmux_initial_configuration.cpp similarity index 87% rename from stratosphere/boot/source/boot_pinmux_initial_configuration.cpp rename to stratosphere/boot/source/pinmux/pinmux_initial_configuration.cpp index b20620a3d..091c55f1a 100644 --- a/stratosphere/boot/source/boot_pinmux_initial_configuration.cpp +++ b/stratosphere/boot/source/pinmux/pinmux_initial_configuration.cpp @@ -15,11 +15,13 @@ */ -#include "boot_pinmux_initial_configuration.hpp" -#include "boot_pinmux_utils.hpp" -#include "boot_spl_utils.hpp" +#include "pinmux_initial_configuration.hpp" +#include "pinmux_utils.hpp" -namespace sts::boot::pinmux { +/* TODO: Better way? */ +#include "../boot_spl_utils.hpp" + +namespace sts::pinmux { namespace { @@ -30,18 +32,18 @@ namespace sts::boot::pinmux { }; /* Include all initial configuration definitions. */ -#include "boot_pinmux_initial_configuration_icosa.inc" -#include "boot_pinmux_initial_configuration_copper.inc" -#include "boot_pinmux_initial_configuration_hoag.inc" -#include "boot_pinmux_initial_configuration_iowa.inc" -#include "boot_pinmux_initial_drive_pad_configuration.inc" +#include "pinmux_initial_configuration_icosa.inc" +#include "pinmux_initial_configuration_copper.inc" +#include "pinmux_initial_configuration_hoag.inc" +#include "pinmux_initial_configuration_iowa.inc" +#include "pinmux_initial_drive_pad_configuration.inc" /* Configuration helpers. */ void ConfigureInitialPads() { const InitialConfig *configs = nullptr; size_t num_configs = 0; - const auto hw_type = GetHardwareType(); + const auto hw_type = spl::GetHardwareType(); switch (hw_type) { case spl::HardwareType::Icosa: diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration.hpp b/stratosphere/boot/source/pinmux/pinmux_initial_configuration.hpp similarity index 96% rename from stratosphere/boot/source/boot_pinmux_initial_configuration.hpp rename to stratosphere/boot/source/pinmux/pinmux_initial_configuration.hpp index d3e36bcf0..8fee79525 100644 --- a/stratosphere/boot/source/boot_pinmux_initial_configuration.hpp +++ b/stratosphere/boot/source/pinmux/pinmux_initial_configuration.hpp @@ -18,7 +18,7 @@ #include #include -namespace sts::boot::pinmux { +namespace sts::pinmux { void SetInitialConfiguration(); diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration_copper.inc b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_copper.inc similarity index 100% rename from stratosphere/boot/source/boot_pinmux_initial_configuration_copper.inc rename to stratosphere/boot/source/pinmux/pinmux_initial_configuration_copper.inc diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration_hoag.inc b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_hoag.inc similarity index 100% rename from stratosphere/boot/source/boot_pinmux_initial_configuration_hoag.inc rename to stratosphere/boot/source/pinmux/pinmux_initial_configuration_hoag.inc diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration_icosa.inc b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_icosa.inc similarity index 100% rename from stratosphere/boot/source/boot_pinmux_initial_configuration_icosa.inc rename to stratosphere/boot/source/pinmux/pinmux_initial_configuration_icosa.inc diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration_iowa.inc b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_iowa.inc similarity index 100% rename from stratosphere/boot/source/boot_pinmux_initial_configuration_iowa.inc rename to stratosphere/boot/source/pinmux/pinmux_initial_configuration_iowa.inc diff --git a/stratosphere/boot/source/boot_pinmux_initial_drive_pad_configuration.inc b/stratosphere/boot/source/pinmux/pinmux_initial_drive_pad_configuration.inc similarity index 100% rename from stratosphere/boot/source/boot_pinmux_initial_drive_pad_configuration.inc rename to stratosphere/boot/source/pinmux/pinmux_initial_drive_pad_configuration.inc diff --git a/stratosphere/boot/source/boot_pinmux_map.inc b/stratosphere/boot/source/pinmux/pinmux_map.inc similarity index 100% rename from stratosphere/boot/source/boot_pinmux_map.inc rename to stratosphere/boot/source/pinmux/pinmux_map.inc diff --git a/stratosphere/boot/source/boot_pinmux_utils.cpp b/stratosphere/boot/source/pinmux/pinmux_utils.cpp similarity index 99% rename from stratosphere/boot/source/boot_pinmux_utils.cpp rename to stratosphere/boot/source/pinmux/pinmux_utils.cpp index 8ed5531d3..404086a56 100644 --- a/stratosphere/boot/source/boot_pinmux_utils.cpp +++ b/stratosphere/boot/source/pinmux/pinmux_utils.cpp @@ -16,14 +16,14 @@ #include -#include "boot_pinmux_utils.hpp" +#include "pinmux_utils.hpp" -namespace sts::boot::pinmux { +namespace sts::pinmux { namespace { /* Pull in Pinmux map definitions. */ -#include "boot_pinmux_map.inc" +#include "pinmux_map.inc" constexpr u32 ApbMiscPhysicalBase = 0x70000000; diff --git a/stratosphere/boot/source/boot_pinmux_utils.hpp b/stratosphere/boot/source/pinmux/pinmux_utils.hpp similarity index 97% rename from stratosphere/boot/source/boot_pinmux_utils.hpp rename to stratosphere/boot/source/pinmux/pinmux_utils.hpp index 00c3cdffb..5e9a38be4 100644 --- a/stratosphere/boot/source/boot_pinmux_utils.hpp +++ b/stratosphere/boot/source/pinmux/pinmux_utils.hpp @@ -18,7 +18,7 @@ #include #include -namespace sts::boot::pinmux { +namespace sts::pinmux { /* Pinmux Utilities. */ u32 UpdatePark(u32 pinmux_name);