1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-26 22:02:15 +00:00

boot: split out gpio, pinmux.

This commit is contained in:
Michael Scire 2019-06-22 11:34:18 -07:00
parent 6d1d226842
commit 804e5d49bb
29 changed files with 52 additions and 51 deletions

View file

@ -33,7 +33,7 @@ endef
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR)) TARGET := $(notdir $(CURDIR))
BUILD := build 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 DATA := data
INCLUDES := include ../../common/include INCLUDES := include ../../common/include
EXEFS_SRC := exefs_src EXEFS_SRC := exefs_src

View file

@ -52,7 +52,7 @@ namespace sts::boot {
return 1; return 1;
} }
if (rtc_intr & 0x04) { if (rtc_intr & 0x04) {
if (nv_erc != 0x80 && !IsRecoveryBoot()) { if (nv_erc != 0x80 && !spl::IsRecoveryBoot()) {
return 4; return 4;
} }
} }

View file

@ -19,9 +19,10 @@
#include <stratosphere.hpp> #include <stratosphere.hpp>
#include "boot_bq24193_charger.hpp" #include "boot_bq24193_charger.hpp"
#include "boot_gpio_utils.hpp"
#include "boot_i2c_utils.hpp" #include "boot_i2c_utils.hpp"
#include "gpio/gpio_utils.hpp"
namespace sts::boot { namespace sts::boot {
class ChargerDriver { class ChargerDriver {

View file

@ -199,7 +199,7 @@ namespace sts::boot {
void InitializeDisplay() { void InitializeDisplay() {
/* Setup globals. */ /* Setup globals. */
InitializeRegisterBaseAddresses(); InitializeRegisterBaseAddresses();
g_is_mariko = IsMariko(); g_is_mariko = spl::IsMariko();
InitializeFrameBuffer(); InitializeFrameBuffer();
/* Turn on DSI/voltage rail. */ /* Turn on DSI/voltage rail. */

View file

@ -15,9 +15,10 @@
*/ */
#include "boot_fan_enable.hpp" #include "boot_fan_enable.hpp"
#include "boot_gpio_utils.hpp"
#include "boot_spl_utils.hpp" #include "boot_spl_utils.hpp"
#include "gpio/gpio_utils.hpp"
namespace sts::boot { namespace sts::boot {
namespace { namespace {
@ -28,7 +29,7 @@ namespace sts::boot {
} }
void SetFanEnabled() { void SetFanEnabled() {
if (GetHardwareType() == spl::HardwareType::Copper) { if (spl::GetHardwareType() == spl::HardwareType::Copper) {
gpio::Configure(GpioPadName_FanEnable); gpio::Configure(GpioPadName_FanEnable);
gpio::SetDirection(GpioPadName_FanEnable, GpioDirection_Output); gpio::SetDirection(GpioPadName_FanEnable, GpioDirection_Output);
gpio::SetValue(GpioPadName_FanEnable, GpioValue_High); gpio::SetValue(GpioPadName_FanEnable, GpioValue_High);

View file

@ -29,12 +29,13 @@
#include "boot_check_clock.hpp" #include "boot_check_clock.hpp"
#include "boot_clock_initial_configuration.hpp" #include "boot_clock_initial_configuration.hpp"
#include "boot_fan_enable.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_repair_boot_images.hpp"
#include "boot_splash_screen.hpp" #include "boot_splash_screen.hpp"
#include "boot_wake_pins.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_power_utils.hpp"
#include "boot_spl_utils.hpp" #include "boot_spl_utils.hpp"
@ -111,7 +112,7 @@ int main(int argc, char **argv)
boot::ChangeGpioVoltageTo1_8v(); boot::ChangeGpioVoltageTo1_8v();
/* Setup GPIO. */ /* Setup GPIO. */
boot::gpio::SetInitialConfiguration(); gpio::SetInitialConfiguration();
/* Check USB PLL/UTMIP clock. */ /* Check USB PLL/UTMIP clock. */
boot::CheckClock(); boot::CheckClock();
@ -119,7 +120,7 @@ int main(int argc, char **argv)
/* Talk to PMIC/RTC, set boot reason with SPL. */ /* Talk to PMIC/RTC, set boot reason with SPL. */
boot::DetectBootReason(); boot::DetectBootReason();
const auto hw_type = boot::GetHardwareType(); const auto hw_type = spl::GetHardwareType();
if (hw_type != spl::HardwareType::Copper) { if (hw_type != spl::HardwareType::Copper) {
/* Display splash screen for two seconds. */ /* Display splash screen for two seconds. */
boot::ShowSplashScreen(); boot::ShowSplashScreen();
@ -129,7 +130,7 @@ int main(int argc, char **argv)
} }
/* Configure pinmux + drive pads. */ /* Configure pinmux + drive pads. */
boot::pinmux::SetInitialConfiguration(); pinmux::SetInitialConfiguration();
/* Configure the PMC wake pin settings. */ /* Configure the PMC wake pin settings. */
boot::SetInitialWakePinConfiguration(); boot::SetInitialWakePinConfiguration();

View file

@ -30,7 +30,7 @@ namespace sts::boot {
} }
void CheckAndRepairBootImages() { 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; 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) { 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) {

View file

@ -16,7 +16,7 @@
#include "boot_spl_utils.hpp" #include "boot_spl_utils.hpp"
namespace sts::boot { namespace sts::spl {
spl::HardwareType GetHardwareType() { spl::HardwareType GetHardwareType() {
u64 out_val = 0; u64 out_val = 0;

View file

@ -27,12 +27,8 @@ namespace sts::spl {
Iowa = 3, Iowa = 3,
}; };
}
namespace sts::boot {
/* SPL Utilities. */ /* SPL Utilities. */
spl::HardwareType GetHardwareType(); HardwareType GetHardwareType();
bool IsRecoveryBoot(); bool IsRecoveryBoot();
bool IsMariko(); bool IsMariko();

View file

@ -95,7 +95,7 @@ namespace sts::boot {
/* Set wake event levels, wake event enables. */ /* Set wake event levels, wake event enables. */
const WakePinConfig *configs; const WakePinConfig *configs;
size_t num_configs; size_t num_configs;
if (GetHardwareType() == spl::HardwareType::Copper) { if (spl::GetHardwareType() == spl::HardwareType::Copper) {
configs = WakePinConfigsCopper; configs = WakePinConfigsCopper;
num_configs = NumWakePinConfigsCopper; num_configs = NumWakePinConfigsCopper;
} else { } else {

View file

@ -14,11 +14,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "boot_gpio_initial_configuration.hpp" #include "gpio_initial_configuration.hpp"
#include "boot_gpio_utils.hpp" #include "gpio_utils.hpp"
#include "boot_spl_utils.hpp"
namespace sts::boot::gpio { /* TODO: Better way? */
#include "../boot_spl_utils.hpp"
namespace sts::gpio {
namespace { namespace {
@ -29,17 +31,17 @@ namespace sts::boot::gpio {
}; };
/* Include all initial configuration definitions. */ /* Include all initial configuration definitions. */
#include "boot_gpio_initial_configuration_icosa.inc" #include "gpio_initial_configuration_icosa.inc"
#include "boot_gpio_initial_configuration_copper.inc" #include "gpio_initial_configuration_copper.inc"
#include "boot_gpio_initial_configuration_hoag.inc" #include "gpio_initial_configuration_hoag.inc"
#include "boot_gpio_initial_configuration_iowa.inc" #include "gpio_initial_configuration_iowa.inc"
} }
void SetInitialConfiguration() { void SetInitialConfiguration() {
const InitialConfig *configs = nullptr; const InitialConfig *configs = nullptr;
size_t num_configs = 0; size_t num_configs = 0;
const auto hw_type = GetHardwareType(); const auto hw_type = spl::GetHardwareType();
const FirmwareVersion fw_ver = GetRuntimeFirmwareVersion(); const FirmwareVersion fw_ver = GetRuntimeFirmwareVersion();
/* Choose GPIO map. */ /* Choose GPIO map. */

View file

@ -18,7 +18,7 @@
#include <switch.h> #include <switch.h>
#include <stratosphere.hpp> #include <stratosphere.hpp>
namespace sts::boot::gpio { namespace sts::gpio {
void SetInitialConfiguration(); void SetInitialConfiguration();

View file

@ -16,14 +16,14 @@
#include <stratosphere/reg.hpp> #include <stratosphere/reg.hpp>
#include "boot_gpio_utils.hpp" #include "gpio_utils.hpp"
namespace sts::boot::gpio { namespace sts::gpio {
namespace { namespace {
/* Pull in GPIO map definitions. */ /* Pull in GPIO map definitions. */
#include "boot_gpio_map.inc" #include "gpio_map.inc"
constexpr u32 PhysicalBase = 0x6000D000; constexpr u32 PhysicalBase = 0x6000D000;

View file

@ -18,9 +18,7 @@
#include <switch.h> #include <switch.h>
#include <stratosphere.hpp> #include <stratosphere.hpp>
#include "i2c/driver/i2c_api.hpp" namespace sts::gpio {
namespace sts::boot::gpio {
/* GPIO Utilities. */ /* GPIO Utilities. */
u32 Configure(u32 gpio_pad_name); u32 Configure(u32 gpio_pad_name);

View file

@ -15,11 +15,13 @@
*/ */
#include "boot_pinmux_initial_configuration.hpp" #include "pinmux_initial_configuration.hpp"
#include "boot_pinmux_utils.hpp" #include "pinmux_utils.hpp"
#include "boot_spl_utils.hpp"
namespace sts::boot::pinmux { /* TODO: Better way? */
#include "../boot_spl_utils.hpp"
namespace sts::pinmux {
namespace { namespace {
@ -30,18 +32,18 @@ namespace sts::boot::pinmux {
}; };
/* Include all initial configuration definitions. */ /* Include all initial configuration definitions. */
#include "boot_pinmux_initial_configuration_icosa.inc" #include "pinmux_initial_configuration_icosa.inc"
#include "boot_pinmux_initial_configuration_copper.inc" #include "pinmux_initial_configuration_copper.inc"
#include "boot_pinmux_initial_configuration_hoag.inc" #include "pinmux_initial_configuration_hoag.inc"
#include "boot_pinmux_initial_configuration_iowa.inc" #include "pinmux_initial_configuration_iowa.inc"
#include "boot_pinmux_initial_drive_pad_configuration.inc" #include "pinmux_initial_drive_pad_configuration.inc"
/* Configuration helpers. */ /* Configuration helpers. */
void ConfigureInitialPads() { void ConfigureInitialPads() {
const InitialConfig *configs = nullptr; const InitialConfig *configs = nullptr;
size_t num_configs = 0; size_t num_configs = 0;
const auto hw_type = GetHardwareType(); const auto hw_type = spl::GetHardwareType();
switch (hw_type) { switch (hw_type) {
case spl::HardwareType::Icosa: case spl::HardwareType::Icosa:

View file

@ -18,7 +18,7 @@
#include <switch.h> #include <switch.h>
#include <stratosphere.hpp> #include <stratosphere.hpp>
namespace sts::boot::pinmux { namespace sts::pinmux {
void SetInitialConfiguration(); void SetInitialConfiguration();

View file

@ -16,14 +16,14 @@
#include <stratosphere/reg.hpp> #include <stratosphere/reg.hpp>
#include "boot_pinmux_utils.hpp" #include "pinmux_utils.hpp"
namespace sts::boot::pinmux { namespace sts::pinmux {
namespace { namespace {
/* Pull in Pinmux map definitions. */ /* Pull in Pinmux map definitions. */
#include "boot_pinmux_map.inc" #include "pinmux_map.inc"
constexpr u32 ApbMiscPhysicalBase = 0x70000000; constexpr u32 ApbMiscPhysicalBase = 0x70000000;

View file

@ -18,7 +18,7 @@
#include <switch.h> #include <switch.h>
#include <stratosphere.hpp> #include <stratosphere.hpp>
namespace sts::boot::pinmux { namespace sts::pinmux {
/* Pinmux Utilities. */ /* Pinmux Utilities. */
u32 UpdatePark(u32 pinmux_name); u32 UpdatePark(u32 pinmux_name);