diff --git a/stratosphere/boot/Makefile b/stratosphere/boot/Makefile index 6bf16b0..8574f69 100644 --- a/stratosphere/boot/Makefile +++ b/stratosphere/boot/Makefile @@ -33,7 +33,7 @@ #--------------------------------------------------------------------------------- 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 fc5634c..fdad4f0 100644 --- a/stratosphere/boot/source/boot_boot_reason.cpp +++ b/stratosphere/boot/source/boot_boot_reason.cpp @@ -52,7 +52,7 @@ 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 85f68a9..a099908 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 2747ebe..eb3994f 100644 --- a/stratosphere/boot/source/boot_display.cpp +++ b/stratosphere/boot/source/boot_display.cpp @@ -199,7 +199,7 @@ 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 41daa9e..190c0b6 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 @@ } 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_gpio_initial_configuration.cpp b/stratosphere/boot/source/boot_gpio_initial_configuration.cpp deleted file mode 100644 index 67036d3..0000000 --- a/stratosphere/boot/source/boot_gpio_initial_configuration.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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_gpio_initial_configuration.hpp" -#include "boot_gpio_utils.hpp" -#include "boot_spl_utils.hpp" - -namespace sts::boot::gpio { - - namespace { - - struct InitialConfig { - u32 pad_name; - GpioDirection direction; - GpioValue value; - }; - - /* 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" - - } - - void SetInitialConfiguration() { - const InitialConfig *configs = nullptr; - size_t num_configs = 0; - const auto hw_type = GetHardwareType(); - const FirmwareVersion fw_ver = GetRuntimeFirmwareVersion(); - - /* Choose GPIO map. */ - if (fw_ver >= FirmwareVersion_200) { - switch (hw_type) { - case spl::HardwareType::Icosa: - { - if (fw_ver >= FirmwareVersion_400) { - configs = InitialConfigsIcosa4x; - num_configs = NumInitialConfigsIcosa4x; - } else { - configs = InitialConfigsIcosa; - num_configs = NumInitialConfigsIcosa; - } - } - break; - case spl::HardwareType::Copper: - configs = InitialConfigsCopper; - num_configs = NumInitialConfigsCopper; - break; - case spl::HardwareType::Hoag: - configs = InitialConfigsHoag; - num_configs = NumInitialConfigsHoag; - break; - case spl::HardwareType::Iowa: - configs = InitialConfigsIowa; - num_configs = NumInitialConfigsIowa; - break; - default: - /* Unknown hardware type, we can't proceed. */ - std::abort(); - } - } else { - /* Until 2.0.0, the GPIO map for Icosa was used for all hardware types. */ - configs = InitialConfigsIcosa; - num_configs = NumInitialConfigsIcosa; - } - - /* Ensure we found an appropriate config. */ - if (configs == nullptr) { - std::abort(); - } - - for (size_t i = 0; i < num_configs; i++) { - /* Configure the GPIO. */ - Configure(configs[i].pad_name); - - /* Set the GPIO's direction. */ - SetDirection(configs[i].pad_name, configs[i].direction); - - if (configs[i].direction == GpioDirection_Output) { - /* Set the GPIO's value. */ - SetValue(configs[i].pad_name, configs[i].value); - } - } - } - -} - diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration.hpp b/stratosphere/boot/source/boot_gpio_initial_configuration.hpp deleted file mode 100644 index f7bdb7c..0000000 --- a/stratosphere/boot/source/boot_gpio_initial_configuration.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 . - */ - -#pragma once -#include -#include - -namespace sts::boot::gpio { - - void SetInitialConfiguration(); - -} diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration_copper.inc b/stratosphere/boot/source/boot_gpio_initial_configuration_copper.inc deleted file mode 100644 index 8f4d8ab..0000000 --- a/stratosphere/boot/source/boot_gpio_initial_configuration_copper.inc +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialConfigsCopper[] = { - {0x40, GpioDirection_Output, GpioValue_Low}, - {0x05, GpioDirection_Output, GpioValue_Low}, - {0x41, GpioDirection_Input, GpioValue_High}, - {0x42, GpioDirection_Input, GpioValue_Low}, - {0x43, GpioDirection_Output, GpioValue_Low}, - {0x02, GpioDirection_Output, GpioValue_Low}, - {0x07, GpioDirection_Output, GpioValue_Low}, - {0x44, GpioDirection_Input, GpioValue_High}, - {0x45, GpioDirection_Input, GpioValue_High}, - {0x0F, GpioDirection_Input, GpioValue_High}, - {0x46, GpioDirection_Output, GpioValue_Low}, - {0x47, GpioDirection_Output, GpioValue_Low}, - {0x10, GpioDirection_Input, GpioValue_Low}, - {0x11, GpioDirection_Input, GpioValue_Low}, - {0x12, GpioDirection_Input, GpioValue_Low}, - {0x13, GpioDirection_Input, GpioValue_Low}, - {0x14, GpioDirection_Input, GpioValue_High}, - {0x18, GpioDirection_Input, GpioValue_Low}, - {0x19, GpioDirection_Input, GpioValue_High}, - {0x1A, GpioDirection_Input, GpioValue_High}, - {0x1C, GpioDirection_Input, GpioValue_High}, - {0x4D, GpioDirection_Output, GpioValue_Low}, - {0x20, GpioDirection_Output, GpioValue_Low}, - {0x38, GpioDirection_Input, GpioValue_High}, - {0x23, GpioDirection_Input, GpioValue_High}, - {0x25, GpioDirection_Input, GpioValue_Low}, - {0x26, GpioDirection_Input, GpioValue_Low}, - {0x27, GpioDirection_Input, GpioValue_Low}, - {0x28, GpioDirection_Input, GpioValue_High}, - {0x29, GpioDirection_Input, GpioValue_High}, - {0x2A, GpioDirection_Input, GpioValue_High}, - {0x48, GpioDirection_Output, GpioValue_Low}, - {0x49, GpioDirection_Output, GpioValue_Low}, - {0x4A, GpioDirection_Output, GpioValue_Low}, - {0x2D, GpioDirection_Output, GpioValue_Low}, - {0x2E, GpioDirection_Output, GpioValue_Low}, - {0x37, GpioDirection_Input, GpioValue_Low}, - {0x2F, GpioDirection_Output, GpioValue_Low}, - {0x03, GpioDirection_Output, GpioValue_Low}, - {0x30, GpioDirection_Input, GpioValue_Low}, - {0x31, GpioDirection_Output, GpioValue_Low}, - {0x4B, GpioDirection_Output, GpioValue_Low}, - {0x4C, GpioDirection_Input, GpioValue_High}, - {0x4E, GpioDirection_Input, GpioValue_Low}, -}; - -constexpr u32 NumInitialConfigsCopper = (sizeof(InitialConfigsCopper) / sizeof(InitialConfigsCopper[0])); diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration_hoag.inc b/stratosphere/boot/source/boot_gpio_initial_configuration_hoag.inc deleted file mode 100644 index 60ffdd3..0000000 --- a/stratosphere/boot/source/boot_gpio_initial_configuration_hoag.inc +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialConfigsHoag[] = { - {0x04, GpioDirection_Input, GpioValue_High}, - {0x05, GpioDirection_Output, GpioValue_Low}, - {0x06, GpioDirection_Input, GpioValue_Low}, - {0x02, GpioDirection_Output, GpioValue_Low}, - {0x3C, GpioDirection_Input, GpioValue_Low}, - {0x0F, GpioDirection_Input, GpioValue_High}, - {0x08, GpioDirection_Input, GpioValue_Low}, - {0x09, GpioDirection_Input, GpioValue_Low}, - {0x0A, GpioDirection_Output, GpioValue_Low}, - {0x0B, GpioDirection_Input, GpioValue_Low}, - {0x0D, GpioDirection_Output, GpioValue_Low}, - {0x0E, GpioDirection_Input, GpioValue_Low}, - {0x10, GpioDirection_Input, GpioValue_Low}, - {0x11, GpioDirection_Input, GpioValue_Low}, - {0x12, GpioDirection_Input, GpioValue_Low}, - {0x13, GpioDirection_Input, GpioValue_Low}, - {0x14, GpioDirection_Input, GpioValue_High}, - {0x16, GpioDirection_Input, GpioValue_Low}, - {0x15, GpioDirection_Input, GpioValue_Low}, - {0x17, GpioDirection_Input, GpioValue_High}, - {0x18, GpioDirection_Input, GpioValue_Low}, - {0x19, GpioDirection_Input, GpioValue_High}, - {0x1A, GpioDirection_Input, GpioValue_High}, - {0x1B, GpioDirection_Input, GpioValue_Low}, - {0x1C, GpioDirection_Input, GpioValue_Low}, - {0x1D, GpioDirection_Output, GpioValue_Low}, - {0x1E, GpioDirection_Output, GpioValue_Low}, - {0x20, GpioDirection_Output, GpioValue_Low}, - {0x21, GpioDirection_Input, GpioValue_Low}, - {0x38, GpioDirection_Input, GpioValue_High}, - {0x22, GpioDirection_Input, GpioValue_Low}, - {0x23, GpioDirection_Input, GpioValue_High}, - {0x01, GpioDirection_Output, GpioValue_Low}, - {0x39, GpioDirection_Output, GpioValue_Low}, - {0x24, GpioDirection_Output, GpioValue_Low}, - {0x34, GpioDirection_Input, GpioValue_Low}, - {0x25, GpioDirection_Input, GpioValue_Low}, - {0x26, GpioDirection_Input, GpioValue_Low}, - {0x27, GpioDirection_Input, GpioValue_Low}, - {0x2B, GpioDirection_Output, GpioValue_Low}, - {0x28, GpioDirection_Input, GpioValue_High}, - {0x1F, GpioDirection_Output, GpioValue_Low}, - {0x29, GpioDirection_Input, GpioValue_High}, - {0x3A, GpioDirection_Output, GpioValue_Low}, - {0x0C, GpioDirection_Input, GpioValue_Low}, - {0x2D, GpioDirection_Output, GpioValue_Low}, - {0x2E, GpioDirection_Output, GpioValue_Low}, - {0x37, GpioDirection_Input, GpioValue_Low}, - {0x2F, GpioDirection_Output, GpioValue_Low}, - {0x03, GpioDirection_Output, GpioValue_Low}, - {0x30, GpioDirection_Input, GpioValue_Low}, - {0x3B, GpioDirection_Input, GpioValue_Low}, - {0x31, GpioDirection_Output, GpioValue_Low}, - {0x32, GpioDirection_Output, GpioValue_Low}, - {0x33, GpioDirection_Output, GpioValue_Low}, - {0x35, GpioDirection_Input, GpioValue_High}, - {0x2C, GpioDirection_Output, GpioValue_Low}, - {0x36, GpioDirection_Output, GpioValue_Low}, -}; - -constexpr u32 NumInitialConfigsHoag = (sizeof(InitialConfigsHoag) / sizeof(InitialConfigsHoag[0])); diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration_icosa.inc b/stratosphere/boot/source/boot_gpio_initial_configuration_icosa.inc deleted file mode 100644 index 44c3482..0000000 --- a/stratosphere/boot/source/boot_gpio_initial_configuration_icosa.inc +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialConfigsIcosa[] = { - {0x04, GpioDirection_Input, GpioValue_High}, - {0x05, GpioDirection_Output, GpioValue_Low}, - {0x06, GpioDirection_Input, GpioValue_Low}, - {0x02, GpioDirection_Output, GpioValue_Low}, - {0x07, GpioDirection_Output, GpioValue_Low}, - {0x3C, GpioDirection_Input, GpioValue_Low}, - {0x0F, GpioDirection_Input, GpioValue_High}, - {0x08, GpioDirection_Input, GpioValue_Low}, - {0x09, GpioDirection_Input, GpioValue_Low}, - {0x0A, GpioDirection_Output, GpioValue_Low}, - {0x0B, GpioDirection_Input, GpioValue_High}, - {0x0D, GpioDirection_Output, GpioValue_Low}, - {0x0E, GpioDirection_Input, GpioValue_Low}, - {0x10, GpioDirection_Input, GpioValue_Low}, - {0x11, GpioDirection_Input, GpioValue_Low}, - {0x12, GpioDirection_Input, GpioValue_Low}, - {0x13, GpioDirection_Input, GpioValue_Low}, - {0x14, GpioDirection_Input, GpioValue_High}, - {0x16, GpioDirection_Input, GpioValue_Low}, - {0x15, GpioDirection_Input, GpioValue_Low}, - {0x17, GpioDirection_Input, GpioValue_High}, - {0x18, GpioDirection_Input, GpioValue_Low}, - {0x19, GpioDirection_Input, GpioValue_High}, - {0x1A, GpioDirection_Input, GpioValue_High}, - {0x1B, GpioDirection_Input, GpioValue_High}, - {0x1C, GpioDirection_Input, GpioValue_Low}, - {0x1D, GpioDirection_Output, GpioValue_Low}, - {0x1E, GpioDirection_Output, GpioValue_Low}, - {0x20, GpioDirection_Output, GpioValue_Low}, - {0x21, GpioDirection_Input, GpioValue_High}, - {0x38, GpioDirection_Input, GpioValue_High}, - {0x22, GpioDirection_Input, GpioValue_Low}, - {0x23, GpioDirection_Input, GpioValue_High}, - {0x01, GpioDirection_Output, GpioValue_Low}, - {0x39, GpioDirection_Output, GpioValue_Low}, - {0x24, GpioDirection_Output, GpioValue_Low}, - {0x34, GpioDirection_Input, GpioValue_Low}, - {0x25, GpioDirection_Input, GpioValue_Low}, - {0x26, GpioDirection_Input, GpioValue_Low}, - {0x27, GpioDirection_Input, GpioValue_Low}, - {0x2B, GpioDirection_Output, GpioValue_Low}, - {0x28, GpioDirection_Input, GpioValue_High}, - {0x1F, GpioDirection_Output, GpioValue_Low}, - {0x29, GpioDirection_Input, GpioValue_High}, - {0x2A, GpioDirection_Input, GpioValue_High}, - {0x3A, GpioDirection_Output, GpioValue_Low}, - {0x0C, GpioDirection_Input, GpioValue_Low}, - {0x2D, GpioDirection_Output, GpioValue_Low}, - {0x2E, GpioDirection_Output, GpioValue_Low}, - {0x37, GpioDirection_Input, GpioValue_Low}, - {0x2F, GpioDirection_Output, GpioValue_Low}, - {0x03, GpioDirection_Output, GpioValue_Low}, - {0x30, GpioDirection_Input, GpioValue_Low}, - {0x3B, GpioDirection_Input, GpioValue_Low}, - {0x31, GpioDirection_Output, GpioValue_Low}, - {0x32, GpioDirection_Output, GpioValue_Low}, - {0x33, GpioDirection_Output, GpioValue_Low}, - {0x35, GpioDirection_Input, GpioValue_High}, - {0x2C, GpioDirection_Output, GpioValue_Low}, - {0x36, GpioDirection_Output, GpioValue_Low}, -}; - -constexpr u32 NumInitialConfigsIcosa = (sizeof(InitialConfigsIcosa) / sizeof(InitialConfigsIcosa[0])); - -constexpr InitialConfig InitialConfigsIcosa4x[] = { - {0x04, GpioDirection_Input, GpioValue_High}, - {0x05, GpioDirection_Output, GpioValue_Low}, - {0x06, GpioDirection_Input, GpioValue_Low}, - {0x02, GpioDirection_Output, GpioValue_Low}, - {0x07, GpioDirection_Output, GpioValue_Low}, - {0x3C, GpioDirection_Input, GpioValue_Low}, - {0x0F, GpioDirection_Input, GpioValue_High}, - {0x08, GpioDirection_Input, GpioValue_Low}, - {0x09, GpioDirection_Input, GpioValue_Low}, - {0x0A, GpioDirection_Output, GpioValue_Low}, - {0x0B, GpioDirection_Input, GpioValue_High}, - {0x0D, GpioDirection_Output, GpioValue_Low}, - {0x0E, GpioDirection_Input, GpioValue_Low}, - {0x10, GpioDirection_Input, GpioValue_Low}, - {0x11, GpioDirection_Input, GpioValue_Low}, - {0x12, GpioDirection_Input, GpioValue_Low}, - {0x13, GpioDirection_Input, GpioValue_Low}, - {0x14, GpioDirection_Input, GpioValue_High}, - {0x16, GpioDirection_Input, GpioValue_Low}, - {0x15, GpioDirection_Input, GpioValue_Low}, - {0x17, GpioDirection_Input, GpioValue_High}, - {0x18, GpioDirection_Input, GpioValue_High}, - {0x19, GpioDirection_Input, GpioValue_High}, - {0x1A, GpioDirection_Input, GpioValue_High}, - {0x1B, GpioDirection_Input, GpioValue_High}, - {0x1C, GpioDirection_Input, GpioValue_Low}, - {0x1D, GpioDirection_Output, GpioValue_Low}, - {0x1E, GpioDirection_Output, GpioValue_Low}, - {0x20, GpioDirection_Output, GpioValue_Low}, - {0x21, GpioDirection_Input, GpioValue_High}, - {0x38, GpioDirection_Input, GpioValue_High}, - {0x22, GpioDirection_Input, GpioValue_Low}, - {0x23, GpioDirection_Input, GpioValue_High}, - {0x01, GpioDirection_Output, GpioValue_Low}, - {0x39, GpioDirection_Output, GpioValue_Low}, - {0x24, GpioDirection_Output, GpioValue_Low}, - {0x34, GpioDirection_Input, GpioValue_Low}, - {0x25, GpioDirection_Input, GpioValue_Low}, - {0x26, GpioDirection_Input, GpioValue_Low}, - {0x27, GpioDirection_Input, GpioValue_Low}, - {0x2B, GpioDirection_Output, GpioValue_Low}, - {0x28, GpioDirection_Input, GpioValue_High}, - {0x1F, GpioDirection_Output, GpioValue_Low}, - {0x29, GpioDirection_Input, GpioValue_High}, - {0x2A, GpioDirection_Input, GpioValue_High}, - {0x3A, GpioDirection_Output, GpioValue_Low}, - {0x0C, GpioDirection_Input, GpioValue_Low}, - {0x2D, GpioDirection_Output, GpioValue_Low}, - {0x2E, GpioDirection_Output, GpioValue_Low}, - {0x37, GpioDirection_Input, GpioValue_Low}, - {0x2F, GpioDirection_Output, GpioValue_Low}, - {0x03, GpioDirection_Output, GpioValue_Low}, - {0x30, GpioDirection_Input, GpioValue_Low}, - {0x3B, GpioDirection_Input, GpioValue_Low}, - {0x31, GpioDirection_Output, GpioValue_Low}, - {0x32, GpioDirection_Output, GpioValue_Low}, - {0x33, GpioDirection_Output, GpioValue_Low}, - {0x35, GpioDirection_Input, GpioValue_High}, - {0x2C, GpioDirection_Output, GpioValue_Low}, - {0x36, GpioDirection_Output, GpioValue_Low}, -}; - -constexpr u32 NumInitialConfigsIcosa4x = (sizeof(InitialConfigsIcosa4x) / sizeof(InitialConfigsIcosa4x[0])); diff --git a/stratosphere/boot/source/boot_gpio_initial_configuration_iowa.inc b/stratosphere/boot/source/boot_gpio_initial_configuration_iowa.inc deleted file mode 100644 index e6c0d16..0000000 --- a/stratosphere/boot/source/boot_gpio_initial_configuration_iowa.inc +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialConfigsIowa[] = { - {0x04, GpioDirection_Input, GpioValue_High}, - {0x05, GpioDirection_Output, GpioValue_Low}, - {0x06, GpioDirection_Input, GpioValue_Low}, - {0x02, GpioDirection_Output, GpioValue_Low}, - {0x3C, GpioDirection_Input, GpioValue_Low}, - {0x0F, GpioDirection_Input, GpioValue_High}, - {0x08, GpioDirection_Input, GpioValue_Low}, - {0x09, GpioDirection_Input, GpioValue_Low}, - {0x0A, GpioDirection_Output, GpioValue_Low}, - {0x0B, GpioDirection_Input, GpioValue_Low}, - {0x0D, GpioDirection_Output, GpioValue_Low}, - {0x0E, GpioDirection_Input, GpioValue_Low}, - {0x10, GpioDirection_Input, GpioValue_Low}, - {0x11, GpioDirection_Input, GpioValue_Low}, - {0x12, GpioDirection_Input, GpioValue_Low}, - {0x13, GpioDirection_Input, GpioValue_Low}, - {0x14, GpioDirection_Input, GpioValue_High}, - {0x16, GpioDirection_Input, GpioValue_Low}, - {0x15, GpioDirection_Input, GpioValue_Low}, - {0x17, GpioDirection_Input, GpioValue_High}, - {0x18, GpioDirection_Input, GpioValue_Low}, - {0x19, GpioDirection_Input, GpioValue_High}, - {0x1A, GpioDirection_Input, GpioValue_High}, - {0x1B, GpioDirection_Input, GpioValue_Low}, - {0x1C, GpioDirection_Input, GpioValue_Low}, - {0x1D, GpioDirection_Output, GpioValue_Low}, - {0x1E, GpioDirection_Output, GpioValue_Low}, - {0x20, GpioDirection_Output, GpioValue_Low}, - {0x21, GpioDirection_Input, GpioValue_Low}, - {0x38, GpioDirection_Input, GpioValue_High}, - {0x22, GpioDirection_Input, GpioValue_Low}, - {0x23, GpioDirection_Input, GpioValue_High}, - {0x01, GpioDirection_Output, GpioValue_Low}, - {0x39, GpioDirection_Output, GpioValue_Low}, - {0x24, GpioDirection_Output, GpioValue_Low}, - {0x34, GpioDirection_Input, GpioValue_Low}, - {0x25, GpioDirection_Input, GpioValue_Low}, - {0x26, GpioDirection_Input, GpioValue_Low}, - {0x27, GpioDirection_Input, GpioValue_Low}, - {0x2B, GpioDirection_Output, GpioValue_Low}, - {0x28, GpioDirection_Input, GpioValue_High}, - {0x1F, GpioDirection_Output, GpioValue_Low}, - {0x29, GpioDirection_Input, GpioValue_High}, - {0x3A, GpioDirection_Output, GpioValue_Low}, - {0x0C, GpioDirection_Input, GpioValue_Low}, - {0x2D, GpioDirection_Output, GpioValue_Low}, - {0x2E, GpioDirection_Output, GpioValue_Low}, - {0x37, GpioDirection_Input, GpioValue_Low}, - {0x2F, GpioDirection_Output, GpioValue_Low}, - {0x03, GpioDirection_Output, GpioValue_Low}, - {0x30, GpioDirection_Input, GpioValue_Low}, - {0x3B, GpioDirection_Input, GpioValue_Low}, - {0x31, GpioDirection_Output, GpioValue_Low}, - {0x32, GpioDirection_Output, GpioValue_Low}, - {0x33, GpioDirection_Output, GpioValue_Low}, - {0x35, GpioDirection_Input, GpioValue_High}, - {0x2C, GpioDirection_Output, GpioValue_Low}, - {0x36, GpioDirection_Output, GpioValue_Low}, -}; - -constexpr u32 NumInitialConfigsIowa = (sizeof(InitialConfigsIowa) / sizeof(InitialConfigsIowa[0])); diff --git a/stratosphere/boot/source/boot_gpio_map.inc b/stratosphere/boot/source/boot_gpio_map.inc deleted file mode 100644 index c3527da..0000000 --- a/stratosphere/boot/source/boot_gpio_map.inc +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 . - */ - -constexpr u32 InvalidPadName = UINT32_MAX; - -constexpr u32 Map[] = { - InvalidPadName, /* Invalid */ - 0x000000CC, /* Port Z, Pin 4 */ - 0x00000024, /* Port E, Pin 4 */ - 0x0000003C, /* Port H, Pin 4 */ - 0x000000DA, /* Port BB, Pin 2 */ - 0x000000DB, /* Port BB, Pin 3 */ - 0x000000DC, /* Port BB, Pin 4 */ - 0x00000025, /* Port E, Pin 5 */ - 0x00000090, /* Port S, Pin 0 */ - 0x00000091, /* Port S, Pin 1 */ - 0x00000096, /* Port S, Pin 6 */ - 0x00000097, /* Port S, Pin 7 */ - 0x00000026, /* Port E, Pin 6 */ - 0x00000005, /* Port A, Pin 5 */ - 0x00000078, /* Port P, Pin 0 */ - 0x00000093, /* Port S, Pin 3 */ - 0x0000007D, /* Port P, Pin 5 */ - 0x0000007C, /* Port P, Pin 4 */ - 0x0000007B, /* Port P, Pin 3 */ - 0x0000007A, /* Port P, Pin 2 */ - 0x000000BC, /* Port X, Pin 4 */ - 0x000000AE, /* Port V, Pin 6 */ - 0x000000BA, /* Port X, Pin 2 */ - 0x000000B9, /* Port X, Pin 1 */ - 0x000000BD, /* Port X, Pin 5 */ - 0x000000BE, /* Port X, Pin 6 */ - 0x000000BF, /* Port X, Pin 7 */ - 0x000000C0, /* Port Y, Pin 0 */ - 0x000000C1, /* Port Y, Pin 1 */ - 0x000000A9, /* Port V, Pin 1 */ - 0x000000AA, /* Port V, Pin 2 */ - 0x00000055, /* Port K, Pin 5 */ - 0x000000AD, /* Port V, Pin 5 */ - 0x000000C8, /* Port Z, Pin 0 */ - 0x000000CA, /* Port Z, Pin 2 */ - 0x000000CB, /* Port Z, Pin 3 */ - 0x0000004F, /* Port J, Pin 7 */ - 0x00000050, /* Port K, Pin 0 */ - 0x00000051, /* Port K, Pin 1 */ - 0x00000052, /* Port K, Pin 2 */ - 0x00000054, /* Port K, Pin 4 */ - 0x00000056, /* Port K, Pin 6 */ - 0x00000057, /* Port K, Pin 7 */ - 0x00000053, /* Port K, Pin 3 */ - 0x000000E3, /* Port CC, Pin 3 */ - 0x00000038, /* Port H, Pin 0 */ - 0x00000039, /* Port H, Pin 1 */ - 0x0000003B, /* Port H, Pin 3 */ - 0x0000003D, /* Port H, Pin 5 */ - 0x0000003F, /* Port H, Pin 7 */ - 0x00000040, /* Port I, Pin 0 */ - 0x00000041, /* Port I, Pin 1 */ - 0x0000003E, /* Port H, Pin 6 */ - 0x000000E2, /* Port CC, Pin 2 */ - 0x000000E4, /* Port CC, Pin 4 */ - 0x0000003A, /* Port H, Pin 2 */ - 0x000000C9, /* Port Z, Pin 1 */ - 0x0000004D, /* Port J, Pin 5 */ - 0x00000058, /* Port L, Pin 0 */ - 0x0000003E, /* Port H, Pin 6 */ - 0x00000026, /* Port E, Pin 6 */ - - /* Copper only */ - InvalidPadName, /* Invalid */ - 0x00000033, /* Port G, Pin 3 */ - 0x0000001C, /* Port D, Pin 4 */ - 0x000000D9, /* Port BB, Pin 1 */ - 0x0000000C, /* Port B, Pin 4 */ - 0x0000000D, /* Port B, Pin 5 */ - 0x00000021, /* Port E, Pin 1 */ - 0x00000027, /* Port E, Pin 7 */ - 0x00000092, /* Port S, Pin 2 */ - 0x00000095, /* Port S, Pin 5 */ - 0x00000098, /* Port T, Pin 0 */ - 0x00000010, /* Port C, Pin 0 */ - 0x00000011, /* Port C, Pin 1 */ - 0x00000012, /* Port C, Pin 2 */ - 0x00000042, /* Port I, Pin 2 */ - 0x000000E6, /* Port CC, Pin 6 */ - - /* 2.0.0+ Copper only */ - 0x000000AC, /* Port V, Pin 4 */ - 0x000000E1, /* Port CC, Pin 1 */ - - /* 5.0.0+ Copper only (unused) */ - 0x00000056, /* Port K, Pin 6 */ -}; - -static constexpr u32 PadNameMax = (sizeof(Map) / sizeof(Map[0])); diff --git a/stratosphere/boot/source/boot_gpio_utils.cpp b/stratosphere/boot/source/boot_gpio_utils.cpp deleted file mode 100644 index 8626687..0000000 --- a/stratosphere/boot/source/boot_gpio_utils.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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 - -#include "boot_gpio_utils.hpp" - -namespace sts::boot::gpio { - - namespace { - - /* Pull in GPIO map definitions. */ -#include "boot_gpio_map.inc" - - constexpr u32 PhysicalBase = 0x6000D000; - - /* Globals. */ - bool g_initialized_gpio_vaddr = false; - uintptr_t g_gpio_vaddr = 0; - - /* Helpers. */ - inline u32 GetPadDescriptor(u32 gpio_pad_name) { - if (gpio_pad_name >= PadNameMax) { - std::abort(); - } - - return Map[gpio_pad_name]; - } - - uintptr_t GetBaseAddress() { - if (!g_initialized_gpio_vaddr) { - g_gpio_vaddr = GetIoMapping(PhysicalBase, 0x1000); - g_initialized_gpio_vaddr = true; - } - return g_gpio_vaddr; - } - - - } - - u32 Configure(u32 gpio_pad_name) { - uintptr_t gpio_base_vaddr = GetBaseAddress(); - - /* Fetch this GPIO's pad descriptor */ - const u32 gpio_pad_desc = GetPadDescriptor(gpio_pad_name); - - /* Discard invalid GPIOs */ - if (gpio_pad_desc == InvalidPadName) { - return InvalidPadName; - } - - /* Convert the GPIO pad descriptor into its register offset */ - u32 gpio_reg_offset = (((gpio_pad_desc << 0x03) & 0xFFFFFF00) | ((gpio_pad_desc >> 0x01) & 0x0C)); - - /* Extract the bit and lock values from the GPIO pad descriptor */ - u32 gpio_cnf_val = ((0x01 << ((gpio_pad_desc & 0x07) | 0x08)) | (0x01 << (gpio_pad_desc & 0x07))); - - /* Write to the appropriate GPIO_CNF_x register (upper offset) */ - reg::Write(gpio_base_vaddr + gpio_reg_offset + 0x80, gpio_cnf_val); - - /* Do a dummy read from GPIO_CNF_x register (lower offset) */ - gpio_cnf_val = reg::Read(gpio_base_vaddr + gpio_reg_offset + 0x00); - - return gpio_cnf_val; - } - - u32 SetDirection(u32 gpio_pad_name, GpioDirection dir) { - uintptr_t gpio_base_vaddr = GetBaseAddress(); - - /* Fetch this GPIO's pad descriptor */ - const u32 gpio_pad_desc = GetPadDescriptor(gpio_pad_name); - - /* Discard invalid GPIOs */ - if (gpio_pad_desc == InvalidPadName) { - return InvalidPadName; - } - - /* Convert the GPIO pad descriptor into its register offset */ - u32 gpio_reg_offset = (((gpio_pad_desc << 0x03) & 0xFFFFFF00) | ((gpio_pad_desc >> 0x01) & 0x0C)); - - /* Set the direction bit and lock values */ - u32 gpio_oe_val = ((0x01 << ((gpio_pad_desc & 0x07) | 0x08)) | (static_cast(dir) << (gpio_pad_desc & 0x07))); - - /* Write to the appropriate GPIO_OE_x register (upper offset) */ - reg::Write(gpio_base_vaddr + gpio_reg_offset + 0x90, gpio_oe_val); - - /* Do a dummy read from GPIO_OE_x register (lower offset) */ - gpio_oe_val = reg::Read(gpio_base_vaddr + gpio_reg_offset + 0x10); - - return gpio_oe_val; - } - - u32 SetValue(u32 gpio_pad_name, GpioValue val) { - uintptr_t gpio_base_vaddr = GetBaseAddress(); - - /* Fetch this GPIO's pad descriptor */ - const u32 gpio_pad_desc = GetPadDescriptor(gpio_pad_name); - - /* Discard invalid GPIOs */ - if (gpio_pad_desc == InvalidPadName) { - return InvalidPadName; - } - - /* Convert the GPIO pad descriptor into its register offset */ - u32 gpio_reg_offset = (((gpio_pad_desc << 0x03) & 0xFFFFFF00) | ((gpio_pad_desc >> 0x01) & 0x0C)); - - /* Set the output bit and lock values */ - u32 gpio_out_val = ((0x01 << ((gpio_pad_desc & 0x07) | 0x08)) | (static_cast(val) << (gpio_pad_desc & 0x07))); - - /* Write to the appropriate GPIO_OUT_x register (upper offset) */ - reg::Write(gpio_base_vaddr + gpio_reg_offset + 0xA0, gpio_out_val); - - /* Do a dummy read from GPIO_OUT_x register (lower offset) */ - gpio_out_val = reg::Read(gpio_base_vaddr + gpio_reg_offset + 0x20); - - return gpio_out_val; - } - -} diff --git a/stratosphere/boot/source/boot_gpio_utils.hpp b/stratosphere/boot/source/boot_gpio_utils.hpp deleted file mode 100644 index 4a281de..0000000 --- a/stratosphere/boot/source/boot_gpio_utils.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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 . - */ - -#pragma once -#include -#include - -#include "i2c/driver/i2c_api.hpp" - -namespace sts::boot::gpio { - - /* GPIO Utilities. */ - u32 Configure(u32 gpio_pad_name); - u32 SetDirection(u32 gpio_pad_name, GpioDirection dir); - u32 SetValue(u32 gpio_pad_name, GpioValue val); - -} diff --git a/stratosphere/boot/source/boot_main.cpp b/stratosphere/boot/source/boot_main.cpp index 4e1203c..a28b72a 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 @@ boot::ChangeGpioVoltageTo1_8v(); /* Setup GPIO. */ - boot::gpio::SetInitialConfiguration(); + gpio::SetInitialConfiguration(); /* Check USB PLL/UTMIP clock. */ boot::CheckClock(); @@ -119,7 +120,7 @@ /* 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 @@ } /* Configure pinmux + drive pads. */ - boot::pinmux::SetInitialConfiguration(); + pinmux::SetInitialConfiguration(); /* Configure the PMC wake pin settings. */ boot::SetInitialWakePinConfiguration(); diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration.cpp b/stratosphere/boot/source/boot_pinmux_initial_configuration.cpp deleted file mode 100644 index b20620a..0000000 --- a/stratosphere/boot/source/boot_pinmux_initial_configuration.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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_pinmux_initial_configuration.hpp" -#include "boot_pinmux_utils.hpp" -#include "boot_spl_utils.hpp" - -namespace sts::boot::pinmux { - - namespace { - - struct InitialConfig { - u32 name; - u32 val; - u32 mask; - }; - - /* 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" - - - /* Configuration helpers. */ - void ConfigureInitialPads() { - const InitialConfig *configs = nullptr; - size_t num_configs = 0; - const auto hw_type = GetHardwareType(); - - switch (hw_type) { - case spl::HardwareType::Icosa: - configs = InitialConfigsIcosa; - num_configs = NumInitialConfigsIcosa; - break; - case spl::HardwareType::Copper: - configs = InitialConfigsCopper; - num_configs = NumInitialConfigsCopper; - break; - case spl::HardwareType::Hoag: - configs = InitialConfigsHoag; - num_configs = NumInitialConfigsHoag; - break; - case spl::HardwareType::Iowa: - configs = InitialConfigsIowa; - num_configs = NumInitialConfigsIowa; - break; - default: - /* Unknown hardware type, we can't proceed. */ - std::abort(); - } - - /* Ensure we found an appropriate config. */ - if (configs == nullptr) { - std::abort(); - } - - for (size_t i = 0; i < num_configs - 1; i++) { - UpdatePad(configs[i].name, configs[i].val, configs[i].mask); - } - - /* Extra configs for iowa only. */ - if (hw_type == spl::HardwareType::Iowa) { - static constexpr u32 ExtraIowaPadNames[] = { - 0xAA, 0xAC, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9 - }; - for (size_t i = 0; i < sizeof(ExtraIowaPadNames) / sizeof(ExtraIowaPadNames[0]); i++) { - UpdatePad(ExtraIowaPadNames[i], 0x2000, 0x2000); - } - } - } - - void ConfigureInitialDrivePads() { - const InitialConfig *configs = InitialDrivePadConfigs; - for (size_t i = 0; i < NumInitialDrivePadConfigs; i++) { - UpdateDrivePad(configs[i].name, configs[i].val, configs[i].mask); - } - } - - } - - void SetInitialConfiguration() { - /* Update all parks. */ - UpdateAllParks(); - - /* Dummy read all drive pads. */ - DummyReadAllDrivePads(); - - /* Set initial pad configs. */ - ConfigureInitialPads(); - - /* Set initial drive pad configs. */ - ConfigureInitialDrivePads(); - } - -} diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration.hpp b/stratosphere/boot/source/boot_pinmux_initial_configuration.hpp deleted file mode 100644 index d3e36bc..0000000 --- a/stratosphere/boot/source/boot_pinmux_initial_configuration.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 . - */ - -#pragma once -#include -#include - -namespace sts::boot::pinmux { - - void SetInitialConfiguration(); - -} diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration_copper.inc b/stratosphere/boot/source/boot_pinmux_initial_configuration_copper.inc deleted file mode 100644 index 6e8aa2f..0000000 --- a/stratosphere/boot/source/boot_pinmux_initial_configuration_copper.inc +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialConfigsCopper[] = { - {0x10, 0x20, 0x27F}, - {0x0F, 0x00, 0x267}, - {0x0E, 0x20, 0x27F}, - {0x5B, 0x00, 0x00}, - {0x80, 0x01, 0x7F}, - {0x34, 0x40, 0x267}, - {0x35, 0x40, 0x267}, - {0x55, 0x00, 0x18}, - {0x56, 0x01, 0x67}, - {0x5C, 0x00, 0x00}, - {0x59, 0x00, 0x00}, - {0x5A, 0x10, 0x18}, - {0x2C, 0x40, 0x267}, - {0x2D, 0x40, 0x267}, - {0x2E, 0x40, 0x267}, - {0x2F, 0x40, 0x267}, - {0x36, 0x00, 0x67}, - {0x37, 0x30, 0x7F}, - {0x38, 0x00, 0x67}, - {0x39, 0x28, 0x7F}, - {0x54, 0x00, 0x67}, - {0x9B, 0x30, 0x7F}, - {0x42, 0x00, 0x67}, - {0x43, 0x28, 0x7F}, - {0x44, 0x00, 0x67}, - {0x45, 0x28, 0x7F}, - {0x4B, 0x28, 0x7F}, - {0x4C, 0x00, 0x67}, - {0x4A, 0x00, 0x67}, - {0x4D, 0x00, 0x67}, - {0x64, 0x20, 0x27F}, - {0x63, 0x40, 0x267}, - {0x5E, 0x04, 0x67}, - {0x60, 0x04, 0x67}, - {0x17, 0x24, 0x7F}, - {0x18, 0x24, 0x7F}, - {0x27, 0x04, 0x67}, - {0x2A, 0x04, 0x67}, - {0x2B, 0x04, 0x67}, - {0x90, 0x24, 0x7F}, - {0x32, 0x24, 0x27F}, - {0x33, 0x34, 0x27F}, - {0x76, 0x04, 0x67}, - {0x79, 0x04, 0x67}, - {0x08, 0x24, 0x7F}, - {0x09, 0x24, 0x7F}, - {0x0A, 0x24, 0x7F}, - {0x0B, 0x24, 0x7F}, - {0x88, 0x34, 0x7F}, - {0x89, 0x24, 0x7F}, - {0x8A, 0x34, 0x7F}, - {0x8B, 0x34, 0x7F}, - {0x8D, 0x34, 0x7F}, - {0x81, 0x04, 0x67}, - {0x9D, 0x34, 0x7F}, - {0x9F, 0x34, 0x7F}, - {0xA1, 0x34, 0x7F}, - {0x92, 0x4C, 0x7F}, - {0x93, 0x4C, 0x7F}, - {0x94, 0x44, 0x7F}, - {0x96, 0x34, 0x7F}, - {0x98, 0x34, 0x7F}, - {0x99, 0x34, 0x7F}, - {0x12, 0x04, 0x7F}, - {0x13, 0x04, 0x67}, - {0x14, 0x04, 0x7F}, - {0x6A, 0x04, 0x67}, - {0x6B, 0x04, 0x67}, - {0x6C, 0x2C, 0x7F}, - {0x6D, 0x04, 0x67}, - {0x6E, 0x04, 0x67}, - {0x6F, 0x24, 0x7F}, - {0x70, 0x04, 0x7F}, - {0x73, 0x04, 0x67}, - {0x69, 0x24, 0x7F}, - {0x5D, 0x05, 0x07}, - {0x5F, 0x05, 0x07}, - {0x61, 0x05, 0x07}, - {0x47, 0x05, 0x07}, - {0x48, 0x05, 0x07}, - {0x46, 0x05, 0x07}, - {0x49, 0x05, 0x07}, - {0x19, 0x05, 0x07}, - {0x1A, 0x05, 0x07}, - {0x1B, 0x05, 0x07}, - {0x26, 0x05, 0x07}, - {0x28, 0x05, 0x07}, - {0x29, 0x05, 0x07}, - {0x8F, 0x05, 0x07}, - {0x30, 0x05, 0x07}, - {0x31, 0x05, 0x07}, - {0x52, 0x05, 0x07}, - {0x53, 0x05, 0x07}, - {0x75, 0x05, 0x07}, - {0x77, 0x05, 0x07}, - {0x78, 0x05, 0x07}, - {0x7A, 0x05, 0x07}, - {0x0D, 0x05, 0x07}, - {0x0C, 0x05, 0x07}, - {0x11, 0x05, 0x07}, - {0x8E, 0x05, 0x07}, - {0x00, 0x05, 0x07}, - {0x01, 0x05, 0x07}, - {0x05, 0x05, 0x07}, - {0x04, 0x05, 0x07}, - {0x03, 0x05, 0x07}, - {0x02, 0x05, 0x07}, - {0x06, 0x05, 0x07}, - {0x07, 0x05, 0x07}, - {0x87, 0x05, 0x07}, - {0x86, 0x05, 0x07}, - {0x82, 0x05, 0x07}, - {0x83, 0x05, 0x07}, - {0x85, 0x05, 0x07}, - {0x84, 0x05, 0x07}, - {0x8C, 0x05, 0x07}, - {0x7B, 0x05, 0x07}, - {0x7C, 0x05, 0x07}, - {0x7D, 0x05, 0x07}, - {0x7E, 0x05, 0x07}, - {0x7F, 0x05, 0x07}, - {0x9C, 0x05, 0x07}, - {0x9E, 0x05, 0x07}, - {0xA0, 0x05, 0x07}, - {0x58, 0x00, 0x00}, - {0x4F, 0x05, 0x07}, - {0x50, 0x05, 0x07}, - {0x4E, 0x05, 0x07}, - {0x51, 0x05, 0x07}, - {0x3A, 0x05, 0x07}, - {0x3B, 0x05, 0x07}, - {0x3C, 0x05, 0x07}, - {0x3D, 0x05, 0x07}, - {0x95, 0x05, 0x07}, - {0x97, 0x05, 0x07}, - {0x9A, 0x05, 0x07}, - {0x15, 0x05, 0x07}, - {0x16, 0x05, 0x07}, - {0x1C, 0x05, 0x07}, - {0x1D, 0x05, 0x07}, - {0x1E, 0x05, 0x07}, - {0x1F, 0x05, 0x07}, - {0x3E, 0x05, 0x07}, - {0x3F, 0x05, 0x07}, - {0x40, 0x05, 0x07}, - {0x41, 0x05, 0x07}, - {0x91, 0x05, 0x07}, - {0x71, 0x05, 0x07}, - {0x72, 0x05, 0x07}, - {0x74, 0x05, 0x07}, - {0x22, 0x05, 0x07}, - {0x23, 0x05, 0x07}, - {0x20, 0x05, 0x07}, - {0x21, 0x05, 0x07}, - {0x24, 0x05, 0x07}, - {0x25, 0x05, 0x07}, - {0x62, 0x05, 0x07}, - {0x65, 0x05, 0x07}, - {0x66, 0x05, 0x07}, - {0x67, 0x05, 0x07}, - {0x68, 0x05, 0x07}, -}; - -constexpr u32 NumInitialConfigsCopper = (sizeof(InitialConfigsCopper) / sizeof(InitialConfigsCopper[0])); diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration_hoag.inc b/stratosphere/boot/source/boot_pinmux_initial_configuration_hoag.inc deleted file mode 100644 index e33e880..0000000 --- a/stratosphere/boot/source/boot_pinmux_initial_configuration_hoag.inc +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialConfigsHoag[] = { - {0x5D, 0x00, 0x67}, - {0x47, 0x28, 0x7F}, - {0x48, 0x00, 0x67}, - {0x46, 0x00, 0x67}, - {0x49, 0x00, 0x67}, - {0x30, 0x40, 0x27F}, - {0x31, 0x40, 0x27F}, - {0x0D, 0x20, 0x27F}, - {0x0C, 0x00, 0x267}, - {0x10, 0x20, 0x27F}, - {0x0F, 0x00, 0x267}, - {0x0E, 0x20, 0x27F}, - {0x00, 0x48, 0x7F}, - {0x01, 0x50, 0x7F}, - {0x05, 0x50, 0x7F}, - {0x04, 0x50, 0x7F}, - {0x03, 0x50, 0x7F}, - {0x02, 0x50, 0x7F}, - {0x5B, 0x00, 0x78}, - {0x7C, 0x01, 0x67}, - {0x80, 0x01, 0x7F}, - {0x34, 0x40, 0x27F}, - {0x35, 0x40, 0x27F}, - {0x55, 0x20, 0x78}, - {0x56, 0x20, 0x7F}, - {0xA1, 0x30, 0x7F}, - {0x5C, 0x00, 0x78}, - {0x59, 0x00, 0x60}, - {0x5A, 0x30, 0x78}, - {0x2C, 0x40, 0x27F}, - {0x2D, 0x40, 0x27F}, - {0x2E, 0x40, 0x27F}, - {0x2F, 0x40, 0x27F}, - {0x3B, 0x20, 0x7F}, - {0x3C, 0x00, 0x67}, - {0x3D, 0x20, 0x7F}, - {0x36, 0x00, 0x67}, - {0x37, 0x30, 0x7F}, - {0x38, 0x00, 0x67}, - {0x39, 0x28, 0x7F}, - {0x54, 0x00, 0x67}, - {0x9B, 0x30, 0x7F}, - {0x1C, 0x00, 0x67}, - {0x1D, 0x30, 0x7F}, - {0x1E, 0x00, 0x67}, - {0x1F, 0x00, 0x67}, - {0x3F, 0x20, 0x7F}, - {0x40, 0x00, 0x67}, - {0x41, 0x20, 0x7F}, - {0x42, 0x00, 0x67}, - {0x43, 0x28, 0x7F}, - {0x44, 0x00, 0x67}, - {0x45, 0x28, 0x7F}, - {0x22, 0x00, 0x67}, - {0x23, 0x28, 0x7F}, - {0x20, 0x00, 0x67}, - {0x21, 0x00, 0x67}, - {0x4B, 0x28, 0x7F}, - {0x4C, 0x00, 0x67}, - {0x4A, 0x00, 0x67}, - {0x4D, 0x00, 0x67}, - {0x64, 0x20, 0x27F}, - {0x5F, 0x34, 0x7F}, - {0x60, 0x04, 0x67}, - {0x61, 0x2C, 0x7F}, - {0x2A, 0x04, 0x67}, - {0x2B, 0x04, 0x67}, - {0x8F, 0x24, 0x7F}, - {0x33, 0x34, 0x27F}, - {0x52, 0x2C, 0x7F}, - {0x53, 0x24, 0x7F}, - {0x77, 0x04, 0x67}, - {0x78, 0x34, 0x7F}, - {0x11, 0x04, 0x67}, - {0x06, 0x2C, 0x7F}, - {0x08, 0x24, 0x7F}, - {0x09, 0x24, 0x7F}, - {0x0A, 0x24, 0x7F}, - {0x0B, 0x24, 0x7F}, - {0x88, 0x34, 0x7F}, - {0x86, 0x2C, 0x7F}, - {0x82, 0x24, 0x7F}, - {0x85, 0x34, 0x7F}, - {0x89, 0x24, 0x7F}, - {0x8A, 0x34, 0x7F}, - {0x8B, 0x34, 0x7F}, - {0x8C, 0x34, 0x7F}, - {0x8D, 0x24, 0x7F}, - {0x7D, 0x04, 0x67}, - {0x7E, 0x04, 0x67}, - {0x81, 0x04, 0x67}, - {0x9C, 0x34, 0x7F}, - {0x9D, 0x34, 0x7F}, - {0x9E, 0x2C, 0x7F}, - {0x9F, 0x34, 0x7F}, - {0xA0, 0x04, 0x67}, - {0x4F, 0x04, 0x67}, - {0x51, 0x04, 0x67}, - {0x3A, 0x24, 0x7F}, - {0x92, 0x4C, 0x7F}, - {0x93, 0x4C, 0x7F}, - {0x94, 0x44, 0x7F}, - {0x95, 0x04, 0x67}, - {0x96, 0x34, 0x7F}, - {0x97, 0x04, 0x67}, - {0x98, 0x34, 0x7F}, - {0x99, 0x34, 0x7F}, - {0x9A, 0x04, 0x67}, - {0x3E, 0x24, 0x7F}, - {0x6A, 0x04, 0x67}, - {0x6B, 0x04, 0x67}, - {0x6C, 0x2C, 0x7F}, - {0x6D, 0x04, 0x67}, - {0x6E, 0x04, 0x67}, - {0x6F, 0x24, 0x7F}, - {0x91, 0x24, 0x7F}, - {0x70, 0x04, 0x7F}, - {0x71, 0x04, 0x67}, - {0x72, 0x04, 0x67}, - {0x65, 0x34, 0x7F}, - {0x66, 0x04, 0x67}, - {0x67, 0x04, 0x267}, - {0x5E, 0x05, 0x07}, - {0x17, 0x05, 0x07}, - {0x18, 0x05, 0x07}, - {0x19, 0x05, 0x07}, - {0x1A, 0x05, 0x07}, - {0x1B, 0x05, 0x07}, - {0x26, 0x05, 0x07}, - {0x27, 0x05, 0x07}, - {0x28, 0x05, 0x07}, - {0x29, 0x05, 0x07}, - {0x90, 0x05, 0x07}, - {0x32, 0x05, 0x07}, - {0x75, 0x05, 0x07}, - {0x76, 0x05, 0x07}, - {0x79, 0x05, 0x07}, - {0x7A, 0x05, 0x07}, - {0x8E, 0x05, 0x07}, - {0x07, 0x05, 0x07}, - {0x87, 0x05, 0x07}, - {0x83, 0x05, 0x07}, - {0x84, 0x05, 0x07}, - {0x7B, 0x05, 0x07}, - {0x7F, 0x05, 0x07}, - {0x58, 0x00, 0x00}, - {0x50, 0x05, 0x07}, - {0x4E, 0x05, 0x07}, - {0x12, 0x05, 0x07}, - {0x13, 0x05, 0x07}, - {0x14, 0x05, 0x07}, - {0x15, 0x05, 0x07}, - {0x16, 0x05, 0x07}, - {0x73, 0x05, 0x07}, - {0x74, 0x05, 0x07}, - {0x24, 0x05, 0x07}, - {0x25, 0x05, 0x07}, - {0x62, 0x05, 0x07}, - {0x68, 0x05, 0x07}, - {0x69, 0x05, 0x07}, - {0x63, 0x05, 0x07}, -}; - -constexpr u32 NumInitialConfigsHoag = (sizeof(InitialConfigsHoag) / sizeof(InitialConfigsHoag[0])); diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration_icosa.inc b/stratosphere/boot/source/boot_pinmux_initial_configuration_icosa.inc deleted file mode 100644 index 17d9af0..0000000 --- a/stratosphere/boot/source/boot_pinmux_initial_configuration_icosa.inc +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialConfigsIcosa[] = { - {0x5D, 0x00, 0x67}, - {0x47, 0x28, 0x7F}, - {0x48, 0x00, 0x67}, - {0x46, 0x00, 0x67}, - {0x49, 0x00, 0x67}, - {0x30, 0x40, 0x27F}, - {0x31, 0x40, 0x27F}, - {0x0D, 0x20, 0x27F}, - {0x0C, 0x00, 0x267}, - {0x10, 0x20, 0x27F}, - {0x0F, 0x00, 0x267}, - {0x0E, 0x20, 0x27F}, - {0x00, 0x48, 0x7F}, - {0x01, 0x50, 0x7F}, - {0x05, 0x50, 0x7F}, - {0x04, 0x50, 0x7F}, - {0x03, 0x50, 0x7F}, - {0x02, 0x50, 0x7F}, - {0x5B, 0x00, 0x78}, - {0x7C, 0x01, 0x67}, - {0x80, 0x01, 0x7F}, - {0x34, 0x40, 0x27F}, - {0x35, 0x40, 0x27F}, - {0x55, 0x20, 0x78}, - {0x56, 0x20, 0x7F}, - {0xA1, 0x30, 0x7F}, - {0x5C, 0x00, 0x78}, - {0x59, 0x00, 0x60}, - {0x5A, 0x30, 0x78}, - {0x2C, 0x40, 0x27F}, - {0x2D, 0x40, 0x27F}, - {0x2E, 0x40, 0x27F}, - {0x2F, 0x40, 0x27F}, - {0x3B, 0x20, 0x7F}, - {0x3C, 0x00, 0x67}, - {0x3D, 0x20, 0x7F}, - {0x36, 0x00, 0x67}, - {0x37, 0x30, 0x7F}, - {0x38, 0x00, 0x67}, - {0x39, 0x28, 0x7F}, - {0x54, 0x00, 0x67}, - {0x9B, 0x30, 0x7F}, - {0x1C, 0x00, 0x67}, - {0x1D, 0x30, 0x7F}, - {0x1E, 0x00, 0x67}, - {0x1F, 0x00, 0x67}, - {0x3F, 0x20, 0x7F}, - {0x40, 0x00, 0x67}, - {0x41, 0x20, 0x7F}, - {0x42, 0x00, 0x67}, - {0x43, 0x28, 0x7F}, - {0x44, 0x00, 0x67}, - {0x45, 0x28, 0x7F}, - {0x22, 0x00, 0x67}, - {0x23, 0x28, 0x7F}, - {0x20, 0x00, 0x67}, - {0x21, 0x00, 0x67}, - {0x4B, 0x28, 0x7F}, - {0x4C, 0x00, 0x67}, - {0x4A, 0x00, 0x67}, - {0x4D, 0x00, 0x67}, - {0x64, 0x20, 0x27F}, - {0x5F, 0x34, 0x7F}, - {0x60, 0x04, 0x67}, - {0x61, 0x2C, 0x7F}, - {0x2A, 0x04, 0x67}, - {0x2B, 0x04, 0x67}, - {0x8F, 0x24, 0x7F}, - {0x33, 0x34, 0x27F}, - {0x52, 0x2C, 0x7F}, - {0x53, 0x24, 0x7F}, - {0x77, 0x04, 0x67}, - {0x78, 0x34, 0x7F}, - {0x11, 0x04, 0x67}, - {0x06, 0x2C, 0x7F}, - {0x08, 0x24, 0x7F}, - {0x09, 0x24, 0x7F}, - {0x0A, 0x24, 0x7F}, - {0x0B, 0x24, 0x7F}, - {0x88, 0x34, 0x7F}, - {0x86, 0x2C, 0x7F}, - {0x82, 0x24, 0x7F}, - {0x85, 0x34, 0x7F}, - {0x89, 0x24, 0x7F}, - {0x8A, 0x34, 0x7F}, - {0x8B, 0x34, 0x7F}, - {0x8C, 0x34, 0x7F}, - {0x8D, 0x24, 0x7F}, - {0x7D, 0x04, 0x67}, - {0x7E, 0x04, 0x67}, - {0x81, 0x04, 0x67}, - {0x9C, 0x34, 0x7F}, - {0x9D, 0x34, 0x7F}, - {0x9E, 0x2C, 0x7F}, - {0x9F, 0x34, 0x7F}, - {0xA0, 0x04, 0x67}, - {0x4F, 0x04, 0x67}, - {0x51, 0x04, 0x67}, - {0x3A, 0x24, 0x7F}, - {0x92, 0x4C, 0x7F}, - {0x93, 0x4C, 0x7F}, - {0x94, 0x44, 0x7F}, - {0x95, 0x04, 0x67}, - {0x96, 0x34, 0x7F}, - {0x97, 0x04, 0x67}, - {0x98, 0x34, 0x7F}, - {0x99, 0x34, 0x7F}, - {0x9A, 0x04, 0x67}, - {0x3E, 0x24, 0x7F}, - {0x6A, 0x04, 0x67}, - {0x6B, 0x04, 0x67}, - {0x6C, 0x2C, 0x7F}, - {0x6D, 0x04, 0x67}, - {0x6E, 0x04, 0x67}, - {0x6F, 0x24, 0x7F}, - {0x91, 0x24, 0x7F}, - {0x70, 0x04, 0x7F}, - {0x71, 0x04, 0x67}, - {0x72, 0x04, 0x67}, - {0x65, 0x34, 0x7F}, - {0x66, 0x04, 0x67}, - {0x67, 0x04, 0x267}, - {0x5E, 0x05, 0x07}, - {0x17, 0x05, 0x07}, - {0x18, 0x05, 0x07}, - {0x19, 0x05, 0x07}, - {0x1A, 0x05, 0x07}, - {0x1B, 0x05, 0x07}, - {0x26, 0x05, 0x07}, - {0x27, 0x05, 0x07}, - {0x28, 0x05, 0x07}, - {0x29, 0x05, 0x07}, - {0x90, 0x05, 0x07}, - {0x32, 0x05, 0x07}, - {0x75, 0x05, 0x07}, - {0x76, 0x05, 0x07}, - {0x79, 0x05, 0x07}, - {0x7A, 0x05, 0x07}, - {0x8E, 0x05, 0x07}, - {0x07, 0x05, 0x07}, - {0x87, 0x05, 0x07}, - {0x83, 0x05, 0x07}, - {0x84, 0x05, 0x07}, - {0x7B, 0x05, 0x07}, - {0x7F, 0x05, 0x07}, - {0x58, 0x00, 0x00}, - {0x50, 0x05, 0x07}, - {0x4E, 0x05, 0x07}, - {0x12, 0x05, 0x07}, - {0x13, 0x05, 0x07}, - {0x14, 0x05, 0x07}, - {0x15, 0x05, 0x07}, - {0x16, 0x05, 0x07}, - {0x73, 0x05, 0x07}, - {0x74, 0x05, 0x07}, - {0x24, 0x05, 0x07}, - {0x25, 0x05, 0x07}, - {0x62, 0x05, 0x07}, - {0x68, 0x05, 0x07}, - {0x69, 0x05, 0x07}, - {0x63, 0x05, 0x07}, -}; - -constexpr u32 NumInitialConfigsIcosa = (sizeof(InitialConfigsIcosa) / sizeof(InitialConfigsIcosa[0])); diff --git a/stratosphere/boot/source/boot_pinmux_initial_configuration_iowa.inc b/stratosphere/boot/source/boot_pinmux_initial_configuration_iowa.inc deleted file mode 100644 index 11e7b57..0000000 --- a/stratosphere/boot/source/boot_pinmux_initial_configuration_iowa.inc +++ /dev/null @@ -1,194 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialConfigsIowa[] = { - {0x5D, 0x00, 0x7F}, - {0x47, 0x28, 0x7F}, - {0x48, 0x00, 0x7F}, - {0x46, 0x00, 0x7F}, - {0x49, 0x00, 0x7F}, - {0x30, 0x40, 0x27F}, - {0x31, 0x40, 0x27F}, - {0x0D, 0x20, 0x27F}, - {0x0C, 0x00, 0x27F}, - {0x10, 0x40, 0x27F}, - {0x0F, 0x00, 0x27F}, - {0x0E, 0x20, 0x27F}, - {0x00, 0x40, 0x7F}, - {0x01, 0x50, 0x7F}, - {0x05, 0x50, 0x7F}, - {0x04, 0x50, 0x7F}, - {0x03, 0x50, 0x7F}, - {0x02, 0x50, 0x7F}, - {0xAA, 0x40, 0x7F}, - {0xAC, 0x40, 0x7F}, - {0xA2, 0x50, 0x7F}, - {0xA3, 0x50, 0x7F}, - {0xA4, 0x50, 0x7F}, - {0xA5, 0x50, 0x7F}, - {0xA6, 0x50, 0x7F}, - {0xA7, 0x50, 0x7F}, - {0xA8, 0x50, 0x7F}, - {0xA9, 0x50, 0x7F}, - {0x5B, 0x00, 0x78}, - {0x7C, 0x01, 0x67}, - {0x80, 0x01, 0x7F}, - {0x34, 0x40, 0x27F}, - {0x35, 0x40, 0x27F}, - {0x55, 0x20, 0x78}, - {0x56, 0x20, 0x7F}, - {0xA1, 0x30, 0x7F}, - {0x5C, 0x00, 0x78}, - {0x5A, 0x20, 0x78}, - {0x2C, 0x40, 0x27F}, - {0x2D, 0x40, 0x27F}, - {0x2E, 0x40, 0x27F}, - {0x2F, 0x40, 0x27F}, - {0x3B, 0x20, 0x7F}, - {0x3C, 0x00, 0x7F}, - {0x3D, 0x20, 0x7F}, - {0x36, 0x00, 0x7F}, - {0x37, 0x30, 0x7F}, - {0x38, 0x00, 0x7F}, - {0x39, 0x28, 0x7F}, - {0x54, 0x00, 0x67}, - {0x9B, 0x30, 0x7F}, - {0x1C, 0x00, 0x7F}, - {0x1D, 0x30, 0x7F}, - {0x1E, 0x00, 0x7F}, - {0x1F, 0x00, 0x7F}, - {0x3F, 0x20, 0x7F}, - {0x40, 0x00, 0x7F}, - {0x41, 0x20, 0x7F}, - {0x42, 0x00, 0x7F}, - {0x43, 0x28, 0x7F}, - {0x44, 0x00, 0x7F}, - {0x45, 0x28, 0x7F}, - {0x4B, 0x28, 0x7F}, - {0x4C, 0x00, 0x7F}, - {0x4A, 0x00, 0x7F}, - {0x4D, 0x00, 0x7F}, - {0x64, 0x20, 0x27F}, - {0x5F, 0x34, 0x7F}, - {0x60, 0x04, 0x67}, - {0x61, 0x2C, 0x7F}, - {0x2A, 0x04, 0x67}, - {0x8F, 0x24, 0x7F}, - {0x33, 0x34, 0x27F}, - {0x52, 0x2C, 0x7F}, - {0x53, 0x24, 0x7F}, - {0x77, 0x04, 0x67}, - {0x78, 0x24, 0x7F}, - {0x11, 0x04, 0x67}, - {0x06, 0x2C, 0x7F}, - {0x08, 0x24, 0x7F}, - {0x09, 0x24, 0x7F}, - {0x0A, 0x24, 0x7F}, - {0x0B, 0x24, 0x7F}, - {0x88, 0x34, 0x7F}, - {0x86, 0x2C, 0x7F}, - {0x82, 0x24, 0x7F}, - {0x85, 0x34, 0x7F}, - {0x89, 0x24, 0x7F}, - {0x8A, 0x34, 0x7F}, - {0x8B, 0x34, 0x7F}, - {0x8C, 0x24, 0x7F}, - {0x8D, 0x24, 0x7F}, - {0x7D, 0x04, 0x67}, - {0x7E, 0x04, 0x67}, - {0x81, 0x04, 0x67}, - {0x9C, 0x24, 0x7F}, - {0x9D, 0x34, 0x7F}, - {0x9E, 0x2C, 0x7F}, - {0x9F, 0x34, 0x7F}, - {0xA0, 0x04, 0x67}, - {0x4F, 0x04, 0x67}, - {0x51, 0x04, 0x67}, - {0x3A, 0x24, 0x7F}, - {0x92, 0x4C, 0x7F}, - {0x93, 0x4C, 0x7F}, - {0x94, 0x44, 0x7F}, - {0x95, 0x04, 0x67}, - {0x96, 0x34, 0x7F}, - {0x97, 0x04, 0x67}, - {0x98, 0x34, 0x7F}, - {0x9A, 0x04, 0x67}, - {0x3E, 0x24, 0x7F}, - {0x6A, 0x04, 0x67}, - {0x6B, 0x04, 0x67}, - {0x6C, 0x2C, 0x7F}, - {0x6D, 0x04, 0x67}, - {0x6E, 0x04, 0x67}, - {0x6F, 0x24, 0x7F}, - {0x91, 0x24, 0x7F}, - {0x70, 0x04, 0x7F}, - {0x71, 0x04, 0x67}, - {0x72, 0x04, 0x67}, - {0x65, 0x34, 0x7F}, - {0x66, 0x04, 0x67}, - {0x67, 0x04, 0x267}, - {0x5E, 0x05, 0x07}, - {0x17, 0x05, 0x07}, - {0x18, 0x05, 0x07}, - {0x19, 0x05, 0x07}, - {0x1A, 0x05, 0x07}, - {0x1B, 0x05, 0x07}, - {0x26, 0x05, 0x07}, - {0x27, 0x05, 0x07}, - {0x28, 0x05, 0x07}, - {0x29, 0x05, 0x07}, - {0x2B, 0x05, 0x07}, - {0x90, 0x05, 0x07}, - {0x32, 0x05, 0x07}, - {0x75, 0x05, 0x07}, - {0x76, 0x05, 0x07}, - {0x79, 0x05, 0x07}, - {0x7A, 0x05, 0x07}, - {0x8E, 0x05, 0x07}, - {0xAB, 0x05, 0x07}, - {0xAD, 0x05, 0x07}, - {0xAE, 0x05, 0x07}, - {0x07, 0x05, 0x07}, - {0x87, 0x05, 0x07}, - {0x83, 0x05, 0x07}, - {0x84, 0x05, 0x07}, - {0x7B, 0x05, 0x07}, - {0x7F, 0x05, 0x07}, - {0x58, 0x00, 0x00}, - {0x59, 0x00, 0x00}, - {0x50, 0x05, 0x07}, - {0x4E, 0x05, 0x07}, - {0x99, 0x05, 0x07}, - {0x12, 0x05, 0x07}, - {0x13, 0x05, 0x07}, - {0x14, 0x05, 0x07}, - {0x15, 0x05, 0x07}, - {0x16, 0x05, 0x07}, - {0x73, 0x05, 0x07}, - {0x74, 0x05, 0x07}, - {0x22, 0x05, 0x07}, - {0x23, 0x05, 0x07}, - {0x20, 0x05, 0x07}, - {0x21, 0x05, 0x07}, - {0x24, 0x05, 0x07}, - {0x25, 0x05, 0x07}, - {0x62, 0x05, 0x07}, - {0x68, 0x05, 0x07}, - {0x69, 0x05, 0x07}, - {0x63, 0x05, 0x07}, -}; - -constexpr u32 NumInitialConfigsIowa = (sizeof(InitialConfigsIowa) / sizeof(InitialConfigsIowa[0])); diff --git a/stratosphere/boot/source/boot_pinmux_initial_drive_pad_configuration.inc b/stratosphere/boot/source/boot_pinmux_initial_drive_pad_configuration.inc deleted file mode 100644 index 8d5d2fe..0000000 --- a/stratosphere/boot/source/boot_pinmux_initial_drive_pad_configuration.inc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 . - */ - -constexpr InitialConfig InitialDrivePadConfigs[] = { - {0x04, 0x01010000, 0x01F1F000}, - {0x0D, 0x01010000, 0x01F1F000}, - {0x10, 0x01010000, 0x01F1F000}, - {0x12, 0x01010000, 0x01F1F000}, - {0x13, 0x01010000, 0x01F1F000}, - {0x14, 0x0001F000, 0x01F1F000}, - {0x15, 0x0001F000, 0x01F1F000}, - {0x24, 0x01010000, 0x01F1F000}, - {0x25, 0x01010000, 0x01F1F000}, - {0x26, 0x01010000, 0x01F1F000}, - {0x27, 0x01010000, 0x01F1F000}, - {0x28, 0x01010000, 0x01F1F000}, - {0x29, 0x01010000, 0x01F1F000}, - {0x2A, 0x01010000, 0x01F1F000}, - {0x2B, 0x01010000, 0x01F1F000}, - {0x2C, 0x01F1F000, 0x01F1F000}, - {0x2D, 0x01F1F000, 0x01F1F000}, - {0x2F, 0x01F1F000, 0x01F1F000}, - {0x30, 0x01404000, 0x01F1F000}, - {0x31, 0x0001F000, 0x01F1F000}, - {0x32, 0x0001F000, 0x01F1F000}, - {0x33, 0x0001F000, 0x01F1F000}, - {0x34, 0x0001F000, 0x01F1F000}, - {0x35, 0x00007000, 0x01F1F000}, - {0x36, 0x00007000, 0x01F1F000}, - {0x46, 0x01010000, 0x01F1F000}, - {0x47, 0x01010000, 0x01F1F000}, - {0x4C, 0x01404000, 0x01F1F000}, - {0x4D, 0x01404000, 0x01F1F000}, - {0x62, 0x0001F000, 0x01F1F000}, - {0x63, 0x0001F000, 0x01F1F000}, - {0x7C, 0x01414000, 0x01F1F000}, - {0x87, 0x01404000, 0x01F1F000}, - {0x88, 0x01404000, 0x01F1F000}, - {0x89, 0x01404000, 0x01F1F000}, - {0x8A, 0x01404000, 0x01F1F000}, - {0x6D, 0x00000000, 0xF0000000}, - {0x6E, 0x00000000, 0xF0000000}, - {0x6F, 0x00000000, 0xF0000000}, - {0x70, 0x00000000, 0xF0000000}, - {0x71, 0x00000000, 0xF0000000}, - {0x72, 0x00000000, 0xF0000000}, - {0x73, 0x00000000, 0xF0000000}, - {0x74, 0x00000000, 0xF0000000}, - {0x75, 0x00000000, 0xF0000000}, - {0x76, 0x00000000, 0xF0000000}, - {0x69, 0x51212000, 0xF1F1F000}, -}; - -constexpr u32 NumInitialDrivePadConfigs = (sizeof(InitialDrivePadConfigs) / sizeof(InitialDrivePadConfigs[0])); diff --git a/stratosphere/boot/source/boot_pinmux_map.inc b/stratosphere/boot/source/boot_pinmux_map.inc deleted file mode 100644 index 9890dd9..0000000 --- a/stratosphere/boot/source/boot_pinmux_map.inc +++ /dev/null @@ -1,361 +0,0 @@ -/* - * 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 . - */ - -struct Definition { - u32 reg_offset; - u32 mask_val; - u32 pm_val; -}; - -struct DrivePadDefinition { - u32 reg_offset; - u32 mask_val; -}; - -constexpr Definition Map[] = { - {0x00003000, 0x72FF, 0x01}, /* Sdmmc1Clk */ - {0x00003004, 0x72FF, 0x02}, /* Sdmmc1Cmd */ - {0x00003008, 0x72FF, 0x02}, /* Sdmmc1Dat3 */ - {0x0000300C, 0x72FF, 0x02}, /* Sdmmc1Dat2 */ - {0x00003010, 0x72FF, 0x02}, /* Sdmmc1Dat1 */ - {0x00003014, 0x72FF, 0x01}, /* Sdmmc1Dat0 */ - {0x0000301C, 0x72FF, 0x01}, /* Sdmmc3Clk */ - {0x00003020, 0x72FF, 0x01}, /* Sdmmc3Cmd */ - {0x00003024, 0x72FF, 0x01}, /* Sdmmc3Dat0 */ - {0x00003028, 0x72FF, 0x01}, /* Sdmmc3Dat1 */ - {0x0000302C, 0x72FF, 0x01}, /* Sdmmc3Dat2 */ - {0x00003030, 0x72FF, 0x01}, /* Sdmmc3Dat3 */ - {0x00003038, 0x1DFF, 0x01}, /* PexL0RstN */ - {0x0000303C, 0x1DFF, 0x01}, /* PexL0ClkreqN */ - {0x00003040, 0x1DFF, 0x01}, /* PexWakeN */ - {0x00003044, 0x1DFF, 0x01}, /* PexL1RstN */ - {0x00003048, 0x1DFF, 0x01}, /* PexL1ClkreqN */ - {0x0000304C, 0x19FF, 0x01}, /* SataLedActive */ - {0x00003050, 0x1F2FF, 0x01}, /* Spi1Mosi */ - {0x00003054, 0x1F2FF, 0x01}, /* Spi1Miso */ - {0x00003058, 0x1F2FF, 0x01}, /* Spi1Sck */ - {0x0000305C, 0x1F2FF, 0x01}, /* Spi1Cs0 */ - {0x00003060, 0x1F2FF, 0x01}, /* Spi1Cs1 */ - {0x00003064, 0x72FF, 0x02}, /* Spi2Mosi */ - {0x00003068, 0x72FF, 0x02}, /* Spi2Miso */ - {0x0000306C, 0x72FF, 0x02}, /* Spi2Sck */ - {0x00003070, 0x72FF, 0x02}, /* Spi2Cs0 */ - {0x00003074, 0x72FF, 0x01}, /* Spi2Cs1 */ - {0x00003078, 0x1F2FF, 0x01}, /* Spi4Mosi */ - {0x0000307C, 0x1F2FF, 0x01}, /* Spi4Miso */ - {0x00003080, 0x1F2FF, 0x01}, /* Spi4Sck */ - {0x00003084, 0x1F2FF, 0x01}, /* Spi4Cs0 */ - {0x00003088, 0x72FF, 0x01}, /* QspiSck */ - {0x0000308C, 0x72FF, 0x01}, /* QspiCsN */ - {0x00003090, 0x72FF, 0x01}, /* QspiIo0 */ - {0x00003094, 0x72FF, 0x01}, /* QspiIo1 */ - {0x00003098, 0x72FF, 0x01}, /* QspiIo2 */ - {0x0000309C, 0x72FF, 0x01}, /* QspiIo3 */ - {0x000030A4, 0x19FF, 0x02}, /* Dmic1Clk */ - {0x000030A8, 0x19FF, 0x02}, /* Dmic1Dat */ - {0x000030AC, 0x19FF, 0x02}, /* Dmic2Clk */ - {0x000030B0, 0x19FF, 0x02}, /* Dmic2Dat */ - {0x000030B4, 0x19FF, 0x02}, /* Dmic3Clk */ - {0x000030B8, 0x19FF, 0x02}, /* Dmic3Dat */ - {0x000030BC, 0x1DFF, 0x01}, /* Gen1I2cScl */ - {0x000030C0, 0x1DFF, 0x01}, /* Gen1I2cSda */ - {0x000030C4, 0x1DFF, 0x01}, /* Gen2I2cScl */ - {0x000030C8, 0x1DFF, 0x01}, /* Gen2I2cSda */ - {0x000030CC, 0x1DFF, 0x01}, /* Gen3I2cScl */ - {0x000030D0, 0x1DFF, 0x01}, /* Gen3I2cSda */ - {0x000030D4, 0x1DFF, 0x02}, /* CamI2cScl */ - {0x000030D8, 0x1DFF, 0x02}, /* CamI2cSda */ - {0x000030DC, 0x1DFF, 0x01}, /* PwrI2cScl */ - {0x000030E0, 0x1DFF, 0x01}, /* PwrI2cSda */ - {0x000030E4, 0x19FF, 0x01}, /* Uart1Tx */ - {0x000030E8, 0x19FF, 0x01}, /* Uart1Rx */ - {0x000030EC, 0x19FF, 0x01}, /* Uart1Rts */ - {0x000030F0, 0x19FF, 0x01}, /* Uart1Cts */ - {0x000030F4, 0x19FF, 0x00}, /* Uart2Tx */ - {0x000030F8, 0x19FF, 0x00}, /* Uart2Rx */ - {0x000030FC, 0x19FF, 0x02}, /* Uart2Rts */ - {0x00003100, 0x19FF, 0x02}, /* Uart2Cts */ - {0x00003104, 0x19FF, 0x02}, /* Uart3Tx */ - {0x00003108, 0x19FF, 0x02}, /* Uart3Rx */ - {0x0000310C, 0x19FF, 0x02}, /* Uart3Rts */ - {0x00003110, 0x19FF, 0x02}, /* Uart3Cts */ - {0x00003114, 0x19FF, 0x02}, /* Uart4Tx */ - {0x00003118, 0x19FF, 0x02}, /* Uart4Rx */ - {0x0000311C, 0x19FF, 0x02}, /* Uart4Rts */ - {0x00003120, 0x19FF, 0x02}, /* Uart4Cts */ - {0x00003124, 0x72FF, 0x01}, /* Dap1Fs */ - {0x00003128, 0x72FF, 0x01}, /* Dap1Din */ - {0x0000312C, 0x72FF, 0x01}, /* Dap1Dout */ - {0x00003130, 0x72FF, 0x01}, /* Dap1Sclk */ - {0x00003134, 0x72FF, 0x01}, /* Dap2Fs */ - {0x00003138, 0x72FF, 0x01}, /* Dap2Din */ - {0x0000313C, 0x72FF, 0x01}, /* Dap2Dout */ - {0x00003140, 0x72FF, 0x01}, /* Dap2Sclk */ - {0x00003144, 0x72FF, 0x01}, /* Dap4Fs */ - {0x00003148, 0x72FF, 0x01}, /* Dap4Din */ - {0x0000314C, 0x72FF, 0x01}, /* Dap4Dout */ - {0x00003150, 0x72FF, 0x01}, /* Dap4Sclk */ - {0x00003154, 0x72FF, 0x01}, /* Cam1Mclk */ - {0x00003158, 0x72FF, 0x01}, /* Cam2Mclk */ - {0x0000315C, 0x72FF, 0x01}, /* JtagRtck */ - {0x00003160, 0x118C, 0xFF}, /* Clk32kIn */ - {0x00003164, 0x72FF, 0x02}, /* Clk32kOut */ - {0x00003168, 0x1DFF, 0x01}, /* BattBcl */ - {0x0000316C, 0x11CC, 0xFF}, /* ClkReq */ - {0x00003170, 0x11CC, 0xFF}, /* CpuPwrReq */ - {0x00003174, 0x11CC, 0xFF}, /* PwrIntN */ - {0x00003178, 0x11CC, 0xFF}, /* Shutdown */ - {0x0000317C, 0x11CC, 0xFF}, /* CorePwrReq */ - {0x00003180, 0x19FF, 0x01}, /* AudMclk */ - {0x00003184, 0x19FF, 0x00}, /* DvfsPwm */ - {0x00003188, 0x19FF, 0x00}, /* DvfsClk */ - {0x0000318C, 0x19FF, 0x00}, /* GpioX1Aud */ - {0x00003190, 0x19FF, 0x00}, /* GpioX3Aud */ - {0x00003194, 0x1DFF, 0x00}, /* GpioPcc7 */ - {0x00003198, 0x1DFF, 0x01}, /* HdmiCec */ - {0x0000319C, 0x1DFF, 0x01}, /* HdmiIntDpHpd */ - {0x000031A0, 0x19FF, 0x01}, /* SpdifOut */ - {0x000031A4, 0x19FF, 0x01}, /* SpdifIn */ - {0x000031A8, 0x1DFF, 0x01}, /* UsbVbusEn0 */ - {0x000031AC, 0x1DFF, 0x01}, /* UsbVbusEn1 */ - {0x000031B0, 0x19FF, 0x01}, /* DpHpd0 */ - {0x000031B4, 0x19FF, 0x00}, /* WifiEn */ - {0x000031B8, 0x19FF, 0x00}, /* WifiRst */ - {0x000031BC, 0x19FF, 0x00}, /* WifiWakeAp */ - {0x000031C0, 0x19FF, 0x00}, /* ApWakeBt */ - {0x000031C4, 0x19FF, 0x00}, /* BtRst */ - {0x000031C8, 0x19FF, 0x00}, /* BtWakeAp */ - {0x000031CC, 0x19FF, 0x00}, /* ApWakeNfc */ - {0x000031D0, 0x19FF, 0x00}, /* NfcEn */ - {0x000031D4, 0x19FF, 0x00}, /* NfcInt */ - {0x000031D8, 0x19FF, 0x00}, /* GpsEn */ - {0x000031DC, 0x19FF, 0x00}, /* GpsRst */ - {0x000031E0, 0x19FF, 0x01}, /* CamRst */ - {0x000031E4, 0x19FF, 0x02}, /* CamAfEn */ - {0x000031E8, 0x19FF, 0x02}, /* CamFlashEn */ - {0x000031EC, 0x19FF, 0x01}, /* Cam1Pwdn */ - {0x000031F0, 0x19FF, 0x01}, /* Cam2Pwdn */ - {0x000031F4, 0x19FF, 0x01}, /* Cam1Strobe */ - {0x000031F8, 0x19FF, 0x01}, /* LcdTe */ - {0x000031FC, 0x19FF, 0x03}, /* LcdBlPwm */ - {0x00003200, 0x19FF, 0x00}, /* LcdBlEn */ - {0x00003204, 0x19FF, 0x00}, /* LcdRst */ - {0x00003208, 0x19FF, 0x01}, /* LcdGpio1 */ - {0x0000320C, 0x19FF, 0x02}, /* LcdGpio2 */ - {0x00003210, 0x19FF, 0x00}, /* ApReady */ - {0x00003214, 0x19FF, 0x00}, /* TouchRst */ - {0x00003218, 0x19FF, 0x01}, /* TouchClk */ - {0x0000321C, 0x19FF, 0x00}, /* ModemWakeAp */ - {0x00003220, 0x19FF, 0x00}, /* TouchInt */ - {0x00003224, 0x19FF, 0x00}, /* MotionInt */ - {0x00003228, 0x19FF, 0x00}, /* AlsProxInt */ - {0x0000322C, 0x19FF, 0x00}, /* TempAlert */ - {0x00003230, 0x19FF, 0x00}, /* ButtonPowerOn */ - {0x00003234, 0x19FF, 0x00}, /* ButtonVolUp */ - {0x00003238, 0x19FF, 0x00}, /* ButtonVolDown */ - {0x0000323C, 0x19FF, 0x00}, /* ButtonSlideSw */ - {0x00003240, 0x19FF, 0x00}, /* ButtonHome */ - {0x00003244, 0x19FF, 0x01}, /* GpioPa6 */ - {0x00003248, 0x19FF, 0x00}, /* GpioPe6 */ - {0x0000324C, 0x19FF, 0x00}, /* GpioPe7 */ - {0x00003250, 0x19FF, 0x00}, /* GpioPh6 */ - {0x00003254, 0x72FF, 0x02}, /* GpioPk0 */ - {0x00003258, 0x72FF, 0x02}, /* GpioPk1 */ - {0x0000325C, 0x72FF, 0x02}, /* GpioPk2 */ - {0x00003260, 0x72FF, 0x02}, /* GpioPk3 */ - {0x00003264, 0x72FF, 0x01}, /* GpioPk4 */ - {0x00003268, 0x72FF, 0x01}, /* GpioPk5 */ - {0x0000326C, 0x72FF, 0x01}, /* GpioPk6 */ - {0x00003270, 0x72FF, 0x01}, /* GpioPk7 */ - {0x00003274, 0x72FF, 0x00}, /* GpioPl0 */ - {0x00003278, 0x72FF, 0x01}, /* GpioPl1 */ - {0x0000327C, 0x72FF, 0x01}, /* GpioPz0 */ - {0x00003280, 0x72FF, 0x02}, /* GpioPz1 */ - {0x00003284, 0x72FF, 0x02}, /* GpioPz2 */ - {0x00003288, 0x72FF, 0x01}, /* GpioPz3 */ - {0x0000328C, 0x72FF, 0x01}, /* GpioPz4 */ - {0x00003290, 0x72FF, 0x01}, /* GpioPz5 */ - - /* 5.0.0+ only */ - {0x00003294, 0x1F2FF, 0x02}, /* Sdmmc2Dat0 */ - {0x00003298, 0x1F2FF, 0x02}, /* Sdmmc2Dat1 */ - {0x0000329C, 0x1F2FF, 0x02}, /* Sdmmc2Dat2 */ - {0x000032A0, 0x1F2FF, 0x02}, /* Sdmmc2Dat3 */ - {0x000032A4, 0x1F2FF, 0x02}, /* Sdmmc2Dat4 */ - {0x000032A8, 0x1F2FF, 0x02}, /* Sdmmc2Dat5 */ - {0x000032AC, 0x1F2FF, 0x02}, /* Sdmmc2Dat6 */ - {0x000032B0, 0x1F2FF, 0x02}, /* Sdmmc2Dat7 */ - {0x000032B4, 0x1F2FF, 0x02}, /* Sdmmc2Clk */ - {0x000032B8, 0x1F2FF, 0x00}, /* Sdmmc2Clkb */ - {0x000032BC, 0x1F2FF, 0x02}, /* Sdmmc2Cmd */ - {0x000032C0, 0x1F2FF, 0x00}, /* Sdmmc2Dqs */ - {0x000032C4, 0x1F2FF, 0x00}, /* Sdmmc2Dqsb */ -}; - -constexpr u32 PadNameMax = (sizeof(Map) / sizeof(Map[0])); - -constexpr DrivePadDefinition DrivePadMap[] = { - {0x000008E4, 0x01F1F000}, /* AlsProxInt */ - {0x000008E8, 0x01F1F000}, /* ApReady */ - {0x000008EC, 0x01F1F000}, /* ApWakeBt */ - {0x000008F0, 0x01F1F000}, /* ApWakeNfc */ - {0x000008F4, 0x01F1F000}, /* AudMclk */ - {0x000008F8, 0x01F1F000}, /* BattBcl */ - {0x000008FC, 0x01F1F000}, /* BtRst */ - {0x00000900, 0x01F1F000}, /* BtWakeAp */ - {0x00000904, 0x01F1F000}, /* ButtonHome */ - {0x00000908, 0x01F1F000}, /* ButtonPowerOn */ - {0x0000090C, 0x01F1F000}, /* ButtonSlideSw */ - {0x00000910, 0x01F1F000}, /* ButtonVolDown */ - {0x00000914, 0x01F1F000}, /* ButtonVolUp */ - {0x00000918, 0x01F1F000}, /* Cam1Mclk */ - {0x0000091C, 0x01F1F000}, /* Cam1Pwdn */ - {0x00000920, 0x01F1F000}, /* Cam1Strobe */ - {0x00000924, 0x01F1F000}, /* Cam2Mclk */ - {0x00000928, 0x01F1F000}, /* Cam2Pwdn */ - {0x0000092C, 0x01F1F000}, /* CamAfEn */ - {0x00000930, 0x01F1F000}, /* CamFlashEn */ - {0x00000934, 0x01F1F000}, /* CamI2cScl */ - {0x00000938, 0x01F1F000}, /* CamI2cSda */ - {0x0000093C, 0x01F1F000}, /* CamRst */ - {0x00000940, 0x01F1F000}, /* Clk32kIn */ - {0x00000944, 0x01F1F000}, /* Clk32kOut */ - {0x00000948, 0x01F1F000}, /* ClkReq */ - {0x0000094C, 0x01F1F000}, /* CorePwrReq */ - {0x00000950, 0x01F1F000}, /* CpuPwrReq */ - {0x00000954, 0xF0000000}, /* Dap1Din */ - {0x00000958, 0xF0000000}, /* Dap1Dout */ - {0x0000095C, 0xF0000000}, /* Dap1Fs */ - {0x00000960, 0xF0000000}, /* Dap1Sclk */ - {0x00000964, 0xF0000000}, /* Dap2Din */ - {0x00000968, 0xF0000000}, /* Dap2Dout */ - {0x0000096C, 0xF0000000}, /* Dap2Fs */ - {0x00000970, 0xF0000000}, /* Dap2Sclk */ - {0x00000974, 0x01F1F000}, /* Dap4Din */ - {0x00000978, 0x01F1F000}, /* Dap4Dout */ - {0x0000097C, 0x01F1F000}, /* Dap4Fs */ - {0x00000980, 0x01F1F000}, /* Dap4Sclk */ - {0x00000984, 0x01F1F000}, /* Dmic1Clk */ - {0x00000988, 0x01F1F000}, /* Dmic1Dat */ - {0x0000098C, 0x01F1F000}, /* Dmic2Clk */ - {0x00000990, 0x01F1F000}, /* Dmic2Dat */ - {0x00000994, 0x01F1F000}, /* Dmic3Clk */ - {0x00000998, 0x01F1F000}, /* Dmic3Dat */ - {0x0000099C, 0x01F1F000}, /* DpHpd */ - {0x000009A0, 0x01F1F000}, /* DvfsClk */ - {0x000009A4, 0x01F1F000}, /* DvfsPwm */ - {0x000009A8, 0x01F1F000}, /* Gen1I2cScl */ - {0x000009AC, 0x01F1F000}, /* Gen1I2cSda */ - {0x000009B0, 0x01F1F000}, /* Gen2I2cScl */ - {0x000009B4, 0x01F1F000}, /* Gen2I2cSda */ - {0x000009B8, 0x01F1F000}, /* Gen3I2cScl */ - {0x000009BC, 0x01F1F000}, /* Gen3I2cSda */ - {0x000009C0, 0x01F1F000}, /* GpioPa6 */ - {0x000009C4, 0x01F1F000}, /* GpioPcc7 */ - {0x000009C8, 0x01F1F000}, /* GpioPe6 */ - {0x000009CC, 0x01F1F000}, /* GpioPe7 */ - {0x000009D0, 0x01F1F000}, /* GpioPh6 */ - {0x000009D4, 0xF0000000}, /* GpioPk0 */ - {0x000009D8, 0xF0000000}, /* GpioPk1 */ - {0x000009DC, 0xF0000000}, /* GpioPk2 */ - {0x000009E0, 0xF0000000}, /* GpioPk3 */ - {0x000009E4, 0xF0000000}, /* GpioPk4 */ - {0x000009E8, 0xF0000000}, /* GpioPk5 */ - {0x000009EC, 0xF0000000}, /* GpioPk6 */ - {0x000009F0, 0xF0000000}, /* GpioPk7 */ - {0x000009F4, 0xF0000000}, /* GpioPl0 */ - {0x000009F8, 0xF0000000}, /* GpioPl1 */ - {0x000009FC, 0x07F7F000}, /* GpioPz0 */ - {0x00000A00, 0x07F7F000}, /* GpioPz1 */ - {0x00000A04, 0x07F7F000}, /* GpioPz2 */ - {0x00000A08, 0x07F7F000}, /* GpioPz3 */ - {0x00000A0C, 0x07F7F000}, /* GpioPz4 */ - {0x00000A10, 0x07F7F000}, /* GpioPz5 */ - {0x00000A14, 0x01F1F000}, /* GpioX1Aud */ - {0x00000A18, 0x01F1F000}, /* GpioX3Aud */ - {0x00000A1C, 0x01F1F000}, /* GpsEn */ - {0x00000A20, 0x01F1F000}, /* GpsRst */ - {0x00000A24, 0x01F1F000}, /* HdmiCec */ - {0x00000A28, 0x01F1F000}, /* HdmiIntDpHpd */ - {0x00000A2C, 0x01F1F000}, /* JtagRtck */ - {0x00000A30, 0x01F1F000}, /* LcdBlEn */ - {0x00000A34, 0x01F1F000}, /* LcdBlPwm */ - {0x00000A38, 0x01F1F000}, /* LcdGpio1 */ - {0x00000A3C, 0x01F1F000}, /* LcdGpio2 */ - {0x00000A40, 0x01F1F000}, /* LcdRst */ - {0x00000A44, 0x01F1F000}, /* LcdTe */ - {0x00000A48, 0x01F1F000}, /* ModemWakeAp */ - {0x00000A4C, 0x01F1F000}, /* MotionInt */ - {0x00000A50, 0x01F1F000}, /* NfcEn */ - {0x00000A54, 0x01F1F000}, /* NfcInt */ - {0x00000A58, 0x01F1F000}, /* PexL0ClkReqN */ - {0x00000A5C, 0x01F1F000}, /* PexL0RstN */ - {0x00000A60, 0x01F1F000}, /* PexL1ClkreqN */ - {0x00000A64, 0x01F1F000}, /* PexL1RstN */ - {0x00000A68, 0x01F1F000}, /* PexWakeN */ - {0x00000A6C, 0x01F1F000}, /* PwrI2cScl */ - {0x00000A70, 0x01F1F000}, /* PwrI2cSda */ - {0x00000A74, 0x01F1F000}, /* PwrIntN */ - {0x00000A78, 0x07F7F000}, /* QspiComp */ - {0x00000A90, 0xF0000000}, /* QspiSck */ - {0x00000A94, 0x01F1F000}, /* SataLedActive */ - {0x00000A98, 0xF7F7F000}, /* Sdmmc1Pad */ - {0x00000AB0, 0xF7F7F000}, /* Sdmmc3Pad */ - {0x00000AC8, 0x01F1F000}, /* Shutdown */ - {0x00000ACC, 0x01F1F000}, /* SpdifIn */ - {0x00000AD0, 0x01F1F000}, /* SpdifOut */ - {0x00000AD4, 0xF0000000}, /* Spi1Cs0 */ - {0x00000AD8, 0xF0000000}, /* Spi1Cs1 */ - {0x00000ADC, 0xF0000000}, /* Spi1Miso */ - {0x00000AE0, 0xF0000000}, /* Spi1Mosi */ - {0x00000AE4, 0xF0000000}, /* Spi1Sck */ - {0x00000AE8, 0xF0000000}, /* Spi2Cs0 */ - {0x00000AEC, 0xF0000000}, /* Spi2Cs1 */ - {0x00000AF0, 0xF0000000}, /* Spi2Miso */ - {0x00000AF4, 0xF0000000}, /* Spi2Mosi */ - {0x00000AF8, 0xF0000000}, /* Spi2Sck */ - {0x00000AFC, 0xF0000000}, /* Spi4Cs0 */ - {0x00000B00, 0xF0000000}, /* Spi4Miso */ - {0x00000B04, 0xF0000000}, /* Spi4Mosi */ - {0x00000B08, 0xF0000000}, /* Spi4Sck */ - {0x00000B0C, 0x01F1F000}, /* TempAlert */ - {0x00000B10, 0x01F1F000}, /* TouchClk */ - {0x00000B14, 0x01F1F000}, /* TouchInt */ - {0x00000B18, 0x01F1F000}, /* TouchRst */ - {0x00000B1C, 0x01F1F000}, /* Uart1Cts */ - {0x00000B20, 0x01F1F000}, /* Uart1Rts */ - {0x00000B24, 0x01F1F000}, /* Uart1Rx */ - {0x00000B28, 0x01F1F000}, /* Uart1Tx */ - {0x00000B2C, 0x01F1F000}, /* Uart2Cts */ - {0x00000B30, 0x01F1F000}, /* Uart2Rts */ - {0x00000B34, 0x01F1F000}, /* Uart2Rx */ - {0x00000B38, 0x01F1F000}, /* Uart2Tx */ - {0x00000B3C, 0x01F1F000}, /* Uart3Cts */ - {0x00000B40, 0x01F1F000}, /* Uart3Rts */ - {0x00000B44, 0x01F1F000}, /* Uart3Rx */ - {0x00000B48, 0x01F1F000}, /* Uart3Tx */ - {0x00000B4C, 0x01F1F000}, /* Uart4Cts */ - {0x00000B50, 0x01F1F000}, /* Uart4Rts */ - {0x00000B54, 0x01F1F000}, /* Uart4Rx */ - {0x00000B58, 0x01F1F000}, /* Uart4Tx */ - {0x00000B5C, 0x01F1F000}, /* UsbVbusEn0 */ - {0x00000B60, 0x01F1F000}, /* UsbVbusEn1 */ - {0x00000B64, 0x01F1F000}, /* WifiEn */ - {0x00000B68, 0x01F1F000}, /* WifiRst */ - {0x00000B6C, 0x01F1F000}, /* WifiWakeAp */ -}; - -constexpr u32 DrivePadNameMax = (sizeof(DrivePadMap) / sizeof(DrivePadMap[0])); diff --git a/stratosphere/boot/source/boot_pinmux_utils.cpp b/stratosphere/boot/source/boot_pinmux_utils.cpp deleted file mode 100644 index 8ed5531..0000000 --- a/stratosphere/boot/source/boot_pinmux_utils.cpp +++ /dev/null @@ -1,533 +0,0 @@ -/* - * 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 - -#include "boot_pinmux_utils.hpp" - -namespace sts::boot::pinmux { - - namespace { - - /* Pull in Pinmux map definitions. */ -#include "boot_pinmux_map.inc" - - constexpr u32 ApbMiscPhysicalBase = 0x70000000; - - /* Globals. */ - bool g_initialized_pinmux_vaddr = false; - uintptr_t g_pinmux_vaddr = 0; - - /* Helpers. */ - inline const Definition *GetDefinition(u32 pinmux_name) { - if (pinmux_name >= PadNameMax) { - std::abort(); - } - - return &Map[pinmux_name]; - } - - inline const DrivePadDefinition *GetDrivePadDefinition(u32 pinmux_name) { - if (pinmux_name >= DrivePadNameMax) { - std::abort(); - } - - return &DrivePadMap[pinmux_name]; - } - - uintptr_t GetBaseAddress() { - if (!g_initialized_pinmux_vaddr) { - g_pinmux_vaddr = GetIoMapping(ApbMiscPhysicalBase, 0x4000); - g_initialized_pinmux_vaddr = true; - } - return g_pinmux_vaddr; - } - - - - } - - u32 UpdatePark(u32 pinmux_name) { - const uintptr_t pinmux_base_vaddr = GetBaseAddress(); - const Definition *pinmux_def = GetDefinition(pinmux_name); - - /* Fetch this PINMUX's register offset */ - u32 pinmux_reg_offset = pinmux_def->reg_offset; - - /* Fetch this PINMUX's mask value */ - u32 pinmux_mask_val = pinmux_def->mask_val; - - /* Get current register ptr. */ - uintptr_t pinmux_reg = pinmux_base_vaddr + pinmux_reg_offset; - - /* Read from the PINMUX register */ - u32 pinmux_val = reg::Read(pinmux_reg); - - /* This PINMUX supports park change */ - if (pinmux_mask_val & 0x20) { - /* Clear park status if set */ - if (pinmux_val & 0x20) { - pinmux_val &= ~(0x20); - } - } - - /* Write to the appropriate PINMUX register */ - reg::Write(pinmux_reg, pinmux_val); - - /* Do a dummy read from the PINMUX register */ - pinmux_val = reg::Read(pinmux_reg); - - return pinmux_val; - } - - u32 UpdatePad(u32 pinmux_name, u32 pinmux_config_val, u32 pinmux_config_mask_val) { - const uintptr_t pinmux_base_vaddr = GetBaseAddress(); - const Definition *pinmux_def = GetDefinition(pinmux_name); - - /* Fetch this PINMUX's register offset */ - u32 pinmux_reg_offset = pinmux_def->reg_offset; - - /* Fetch this PINMUX's mask value */ - u32 pinmux_mask_val = pinmux_def->mask_val; - - /* Get current register ptr. */ - uintptr_t pinmux_reg = pinmux_base_vaddr + pinmux_reg_offset; - - /* Read from the PINMUX register */ - u32 pinmux_val = reg::Read(pinmux_reg); - - /* This PINMUX register is locked */ - if (pinmux_val & 0x80) { - std::abort(); - } - - u32 pm_val = (pinmux_config_val & 0x07); - - /* Adjust PM */ - if (pinmux_config_mask_val & 0x07) { - /* Apply additional changes first */ - if (pm_val == 0x05) { - /* This pin supports PUPD change */ - if (pinmux_mask_val & 0x0C) { - /* Change PUPD */ - if ((pinmux_val & 0x0C) != 0x04) { - pinmux_val &= 0xFFFFFFF3; - pinmux_val |= 0x04; - } - } - - /* This pin supports Tristate change */ - if (pinmux_mask_val & 0x10) { - /* Change Tristate */ - if (!(pinmux_val & 0x10)) { - pinmux_val |= 0x10; - } - } - - /* This pin supports EInput change */ - if (pinmux_mask_val & 0x40) { - /* Change EInput */ - if (pinmux_val & 0x40) { - pinmux_val &= 0xFFFFFFBF; - } - } - } else if (pm_val >= 0x06) { - /* Default to safe value */ - pm_val = 0x04; - } - - /* Translate PM value if necessary */ - if (pm_val == 0x04 || pm_val == 0x05) { - pm_val = pinmux_def->pm_val; - } - - /* This pin supports PM change */ - if (pinmux_mask_val & 0x03) { - /* Change PM */ - if ((pinmux_val & 0x03) != (pm_val & 0x03)) { - pinmux_val &= 0xFFFFFFFC; - pinmux_val |= (pm_val & 0x03); - } - } - } - - u32 pupd_config_val = (pinmux_config_val & 0x18); - - /* Adjust PUPD */ - if (pinmux_config_mask_val & 0x18) { - if (pupd_config_val < 0x11) { - /* This pin supports PUPD change */ - if (pinmux_mask_val & 0x0C) { - /* Change PUPD */ - if (((pinmux_val >> 0x02) & 0x03) != (pupd_config_val >> 0x03)) { - pinmux_val &= 0xFFFFFFF3; - pinmux_val |= (pupd_config_val >> 0x01); - } - } - } - } - - u32 eod_config_val = (pinmux_config_val & 0x60); - - /* Adjust EOd field */ - if (pinmux_config_mask_val & 0x60) { - if (eod_config_val == 0x20) { - /* This pin supports Tristate change */ - if (pinmux_mask_val & 0x10) { - /* Change Tristate */ - if (!(pinmux_val & 0x10)) { - pinmux_val |= 0x10; - } - } - - /* This pin supports EInput change */ - if (pinmux_mask_val & 0x40) { - /* Change EInput */ - if (!(pinmux_val & 0x40)) { - pinmux_val |= 0x40; - } - } - - /* This pin supports EOd change */ - if (pinmux_mask_val & 0x800) { - /* Change EOd */ - if (pinmux_val & 0x800) { - pinmux_val &= 0xFFFFF7FF; - } - } - } else if (eod_config_val == 0x40) { - /* This pin supports Tristate change */ - if (pinmux_mask_val & 0x10) { - /* Change Tristate */ - if (pinmux_val & 0x10) { - pinmux_val &= 0xFFFFFFEF; - } - } - - /* This pin supports EInput change */ - if (pinmux_mask_val & 0x40) { - /* Change EInput */ - if (!(pinmux_val & 0x40)) { - pinmux_val |= 0x40; - } - } - - /* This pin supports EOd change */ - if (pinmux_mask_val & 0x800) { - /* Change EOd */ - if (pinmux_val & 0x800) { - pinmux_val &= 0xFFFFF7FF; - } - } - } else if (eod_config_val == 0x60) { - /* This pin supports Tristate change */ - if (pinmux_mask_val & 0x10) { - /* Change Tristate */ - if (pinmux_val & 0x10) { - pinmux_val &= 0xFFFFFFEF; - } - } - - /* This pin supports EInput change */ - if (pinmux_mask_val & 0x40) { - /* Change EInput */ - if (!(pinmux_val & 0x40)) { - pinmux_val |= 0x40; - } - } - - /* This pin supports EOd change */ - if (pinmux_mask_val & 0x800) { - /* Change EOd */ - if (!(pinmux_val & 0x800)) { - pinmux_val |= 0x800; - } - } - } else { - /* This pin supports Tristate change */ - if (pinmux_mask_val & 0x10) { - /* Change Tristate */ - if (pinmux_val & 0x10) { - pinmux_val &= 0xFFFFFFEF; - } - } - - /* This pin supports EInput change */ - if (pinmux_mask_val & 0x40) { - /* Change EInput */ - if (pinmux_val & 0x40) { - pinmux_val &= 0xFFFFFFBF; - } - } - - /* This pin supports EOd change */ - if (pinmux_mask_val & 0x800) { - /* Change EOd */ - if (pinmux_val & 0x800) { - pinmux_val &= 0xFFFFF7FF; - } - } - } - } - - u32 lock_config_val = (pinmux_config_val & 0x80); - - /* Adjust Lock */ - if (pinmux_config_mask_val & 0x80) { - /* This pin supports Lock change */ - if (pinmux_mask_val & 0x80) { - /* Change Lock */ - if ((pinmux_val ^ pinmux_config_val) & 0x80) { - pinmux_val &= 0xFFFFFF7F; - pinmux_val |= lock_config_val; - } - } - } - - u32 ioreset_config_val = (((pinmux_config_val >> 0x08) & 0x1) << 0x10); - - /* Adjust IoReset */ - if (pinmux_config_mask_val & 0x100) { - /* This pin supports IoReset change */ - if (pinmux_mask_val & 0x10000) { - /* Change IoReset */ - if (((pinmux_val >> 0x10) ^ (pinmux_config_val >> 0x08)) & 0x01) { - pinmux_val &= 0xFFFEFFFF; - pinmux_val |= ioreset_config_val; - } - } - } - - u32 park_config_val = (((pinmux_config_val >> 0x0A) & 0x1) << 0x5); - - /* Adjust Park */ - if (pinmux_config_mask_val & 0x400) { - /* This pin supports Park change */ - if (pinmux_mask_val & 0x20) { - /* Change Park */ - if (((pinmux_val >> 0x05) ^ (pinmux_config_val >> 0x0A)) & 0x01) { - pinmux_val &= 0xFFFFFFDF; - pinmux_val |= park_config_val; - } - } - } - - u32 elpdr_config_val = (((pinmux_config_val >> 0x0B) & 0x1) << 0x08); - - /* Adjust ELpdr */ - if (pinmux_config_mask_val & 0x800) { - /* This pin supports ELpdr change */ - if (pinmux_mask_val & 0x100) { - /* Change ELpdr */ - if (((pinmux_val >> 0x08) ^ (pinmux_config_val >> 0x0B)) & 0x01) { - pinmux_val &= 0xFFFFFEFF; - pinmux_val |= elpdr_config_val; - } - } - } - - u32 ehsm_config_val = (((pinmux_config_val >> 0x0C) & 0x1) << 0x09); - - /* Adjust EHsm */ - if (pinmux_config_mask_val & 0x1000) { - /* This pin supports EHsm change */ - if (pinmux_mask_val & 0x200) { - /* Change EHsm */ - if (((pinmux_val >> 0x09) ^ (pinmux_config_val >> 0x0C)) & 0x01) { - pinmux_val &= 0xFFFFFDFF; - pinmux_val |= ehsm_config_val; - } - } - } - - u32 eiohv_config_val = (((pinmux_config_val >> 0x09) & 0x1) << 0x0A); - - /* Adjust EIoHv */ - if (pinmux_config_mask_val & 0x200) { - /* This pin supports EIoHv change */ - if (pinmux_mask_val & 0x400) { - /* Change EIoHv */ - if (((pinmux_val >> 0x0A) ^ (pinmux_config_val >> 0x09)) & 0x01) { - pinmux_val &= 0xFFFFFBFF; - pinmux_val |= eiohv_config_val; - } - } - } - - u32 eschmt_config_val = (((pinmux_config_val >> 0x0D) & 0x1) << 0x0C); - - /* Adjust ESchmt */ - if (pinmux_config_mask_val & 0x2000) { - /* This pin supports ESchmt change */ - if (pinmux_mask_val & 0x1000) { - /* Change ESchmt */ - if (((pinmux_val >> 0x0C) ^ (pinmux_config_val >> 0x0D)) & 0x01) { - pinmux_val &= 0xFFFFEFFF; - pinmux_val |= eschmt_config_val; - } - } - } - - u32 preemp_config_val = (((pinmux_config_val >> 0x10) & 0x1) << 0xF); - - /* Adjust Preemp */ - if (pinmux_config_mask_val & 0x10000) { - /* This pin supports Preemp change */ - if (pinmux_mask_val & 0x8000) { - /* Change Preemp */ - if (((pinmux_val >> 0x0F) ^ (pinmux_config_val >> 0x10)) & 0x01) { - pinmux_val &= 0xFFFF7FFF; - pinmux_val |= preemp_config_val; - } - } - } - - u32 drvtype_config_val = (((pinmux_config_val >> 0x0E) & 0x3) << 0xD); - - /* Adjust DrvType */ - if (pinmux_config_mask_val & 0xC000) { - /* This pin supports DrvType change */ - if (pinmux_mask_val & 0x6000) { - /* Change DrvType */ - if (((pinmux_val >> 0x0D) ^ (pinmux_config_val >> 0x0E)) & 0x03) { - pinmux_val &= 0xFFFF9FFF; - pinmux_val |= drvtype_config_val; - } - } - } - - /* Write to the appropriate PINMUX register */ - reg::Write(pinmux_reg, pinmux_val); - - /* Do a dummy read from the PINMUX register */ - pinmux_val = reg::Read(pinmux_reg); - - return pinmux_val; - } - - u32 UpdateDrivePad(u32 pinmux_drivepad_name, u32 pinmux_drivepad_config_val, u32 pinmux_drivepad_config_mask_val) { - const uintptr_t pinmux_base_vaddr = GetBaseAddress(); - const DrivePadDefinition *pinmux_drivepad_def = GetDrivePadDefinition(pinmux_drivepad_name); - - /* Fetch this PINMUX drive group's register offset */ - u32 pinmux_drivepad_reg_offset = pinmux_drivepad_def->reg_offset; - - /* Fetch this PINMUX drive group's mask value */ - u32 pinmux_drivepad_mask_val = pinmux_drivepad_def->mask_val; - - /* Get current register ptr. */ - uintptr_t pinmux_drivepad_reg = pinmux_base_vaddr + pinmux_drivepad_reg_offset; - - /* Read from the PINMUX drive group register */ - u32 pinmux_drivepad_val = reg::Read(pinmux_drivepad_reg); - - /* Adjust DriveDownStrength */ - if (pinmux_drivepad_config_mask_val & 0x1F000) { - u32 mask_val = 0x7F000; - - /* Adjust mask value */ - if ((pinmux_drivepad_mask_val & 0x7F000) != 0x7F000) - mask_val = 0x1F000; - - /* This drive group supports DriveDownStrength change */ - if (pinmux_drivepad_mask_val & mask_val) { - /* Change DriveDownStrength */ - if (((pinmux_drivepad_config_val & 0x7F000) & mask_val) != (pinmux_drivepad_val & mask_val)) { - pinmux_drivepad_val &= ~(mask_val); - pinmux_drivepad_val |= ((pinmux_drivepad_config_val & 0x7F000) & mask_val); - } - } - } - - /* Adjust DriveUpStrength */ - if (pinmux_drivepad_config_mask_val & 0x1F00000) { - u32 mask_val = 0x7F00000; - - /* Adjust mask value */ - if ((pinmux_drivepad_mask_val & 0x7F00000) != 0x7F00000) - mask_val = 0x1F00000; - - /* This drive group supports DriveUpStrength change */ - if (pinmux_drivepad_mask_val & mask_val) { - /* Change DriveUpStrength */ - if (((pinmux_drivepad_config_val & 0x7F00000) & mask_val) != (pinmux_drivepad_val & mask_val)) { - pinmux_drivepad_val &= ~(mask_val); - pinmux_drivepad_val |= ((pinmux_drivepad_config_val & 0x7F00000) & mask_val); - } - } - } - - /* Adjust DriveDownSlew */ - if (pinmux_drivepad_config_mask_val & 0x30000000) { - /* This drive group supports DriveDownSlew change */ - if (pinmux_drivepad_mask_val & 0x30000000) { - /* Change DriveDownSlew */ - if ((pinmux_drivepad_val ^ pinmux_drivepad_config_val) & 0x30000000) { - pinmux_drivepad_val &= 0xCFFFFFFF; - pinmux_drivepad_val |= (pinmux_drivepad_config_val & 0x30000000); - } - } - } - - /* Adjust DriveUpSlew */ - if (pinmux_drivepad_config_mask_val & 0xC0000000) { - /* This drive group supports DriveUpSlew change */ - if (pinmux_drivepad_mask_val & 0xC0000000) { - /* Change DriveUpSlew */ - if ((pinmux_drivepad_val ^ pinmux_drivepad_config_val) & 0xC0000000) { - pinmux_drivepad_val &= 0x3FFFFFFF; - pinmux_drivepad_val |= (pinmux_drivepad_config_val & 0xC0000000); - } - } - } - - /* Write to the appropriate PINMUX drive group register */ - reg::Write(pinmux_drivepad_reg, pinmux_drivepad_val); - - /* Do a dummy read from the PINMUX drive group register */ - pinmux_drivepad_val = reg::Read(pinmux_drivepad_reg); - - return pinmux_drivepad_val; - } - - u32 DummyReadDrivePad(u32 pinmux_drivepad_name) { - const uintptr_t pinmux_base_vaddr = GetBaseAddress(); - const DrivePadDefinition *pinmux_drivepad_def = GetDrivePadDefinition(pinmux_drivepad_name); - - /* Fetch this PINMUX drive group's register offset */ - u32 pinmux_drivepad_reg_offset = pinmux_drivepad_def->reg_offset; - - /* Get current register ptr. */ - uintptr_t pinmux_drivepad_reg = pinmux_base_vaddr + pinmux_drivepad_reg_offset; - - return reg::Read(pinmux_drivepad_reg); - } - - void UpdateAllParks() { - /* Update parks. */ - for (size_t i = 0; i < PadNameMax; i++) { - UpdatePark(static_cast(i)); - } - } - - void DummyReadAllDrivePads() { - /* Dummy read all drive pads. */ - for (size_t i = 0; i < DrivePadNameMax; i++) { - DummyReadDrivePad(static_cast(i)); - } - } - -} diff --git a/stratosphere/boot/source/boot_pinmux_utils.hpp b/stratosphere/boot/source/boot_pinmux_utils.hpp deleted file mode 100644 index 00c3cdf..0000000 --- a/stratosphere/boot/source/boot_pinmux_utils.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 . - */ - -#pragma once -#include -#include - -namespace sts::boot::pinmux { - - /* Pinmux Utilities. */ - u32 UpdatePark(u32 pinmux_name); - u32 UpdatePad(u32 pinmux_name, u32 config_val, u32 config_mask); - u32 UpdateDrivePad(u32 pinmux_drivepad_name, u32 config_val, u32 config_mask); - u32 DummyReadDrivePad(u32 pinmux_drivepad_name); - - /* Helper API. */ - void UpdateAllParks(); - void DummyReadAllDrivePads(); - -} diff --git a/stratosphere/boot/source/boot_repair_boot_images.cpp b/stratosphere/boot/source/boot_repair_boot_images.cpp index b807f78..78fd8fa 100644 --- a/stratosphere/boot/source/boot_repair_boot_images.cpp +++ b/stratosphere/boot/source/boot_repair_boot_images.cpp @@ -30,7 +30,7 @@ } 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 d0ef1ab..d5e60e1 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 5029234..a12171f 100644 --- a/stratosphere/boot/source/boot_spl_utils.hpp +++ b/stratosphere/boot/source/boot_spl_utils.hpp @@ -27,13 +27,9 @@ 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 43fd146..9df434f 100644 --- a/stratosphere/boot/source/boot_wake_pins.cpp +++ b/stratosphere/boot/source/boot_wake_pins.cpp @@ -95,7 +95,7 @@ /* 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/gpio/gpio_initial_configuration.cpp b/stratosphere/boot/source/gpio/gpio_initial_configuration.cpp new file mode 100644 index 0000000..c516be8 --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_initial_configuration.cpp @@ -0,0 +1,103 @@ +/* + * 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 "gpio_initial_configuration.hpp" +#include "gpio_utils.hpp" + +/* TODO: Better way? */ +#include "../boot_spl_utils.hpp" + +namespace sts::gpio { + + namespace { + + struct InitialConfig { + u32 pad_name; + GpioDirection direction; + GpioValue value; + }; + + /* Include all initial configuration definitions. */ +#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 = spl::GetHardwareType(); + const FirmwareVersion fw_ver = GetRuntimeFirmwareVersion(); + + /* Choose GPIO map. */ + if (fw_ver >= FirmwareVersion_200) { + switch (hw_type) { + case spl::HardwareType::Icosa: + { + if (fw_ver >= FirmwareVersion_400) { + configs = InitialConfigsIcosa4x; + num_configs = NumInitialConfigsIcosa4x; + } else { + configs = InitialConfigsIcosa; + num_configs = NumInitialConfigsIcosa; + } + } + break; + case spl::HardwareType::Copper: + configs = InitialConfigsCopper; + num_configs = NumInitialConfigsCopper; + break; + case spl::HardwareType::Hoag: + configs = InitialConfigsHoag; + num_configs = NumInitialConfigsHoag; + break; + case spl::HardwareType::Iowa: + configs = InitialConfigsIowa; + num_configs = NumInitialConfigsIowa; + break; + default: + /* Unknown hardware type, we can't proceed. */ + std::abort(); + } + } else { + /* Until 2.0.0, the GPIO map for Icosa was used for all hardware types. */ + configs = InitialConfigsIcosa; + num_configs = NumInitialConfigsIcosa; + } + + /* Ensure we found an appropriate config. */ + if (configs == nullptr) { + std::abort(); + } + + for (size_t i = 0; i < num_configs; i++) { + /* Configure the GPIO. */ + Configure(configs[i].pad_name); + + /* Set the GPIO's direction. */ + SetDirection(configs[i].pad_name, configs[i].direction); + + if (configs[i].direction == GpioDirection_Output) { + /* Set the GPIO's value. */ + SetValue(configs[i].pad_name, configs[i].value); + } + } + } + +} + diff --git a/stratosphere/boot/source/gpio/gpio_initial_configuration.hpp b/stratosphere/boot/source/gpio/gpio_initial_configuration.hpp new file mode 100644 index 0000000..030ef89 --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_initial_configuration.hpp @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +#pragma once +#include +#include + +namespace sts::gpio { + + void SetInitialConfiguration(); + +} diff --git a/stratosphere/boot/source/gpio/gpio_initial_configuration_copper.inc b/stratosphere/boot/source/gpio/gpio_initial_configuration_copper.inc new file mode 100644 index 0000000..8f4d8ab --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_initial_configuration_copper.inc @@ -0,0 +1,64 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialConfigsCopper[] = { + {0x40, GpioDirection_Output, GpioValue_Low}, + {0x05, GpioDirection_Output, GpioValue_Low}, + {0x41, GpioDirection_Input, GpioValue_High}, + {0x42, GpioDirection_Input, GpioValue_Low}, + {0x43, GpioDirection_Output, GpioValue_Low}, + {0x02, GpioDirection_Output, GpioValue_Low}, + {0x07, GpioDirection_Output, GpioValue_Low}, + {0x44, GpioDirection_Input, GpioValue_High}, + {0x45, GpioDirection_Input, GpioValue_High}, + {0x0F, GpioDirection_Input, GpioValue_High}, + {0x46, GpioDirection_Output, GpioValue_Low}, + {0x47, GpioDirection_Output, GpioValue_Low}, + {0x10, GpioDirection_Input, GpioValue_Low}, + {0x11, GpioDirection_Input, GpioValue_Low}, + {0x12, GpioDirection_Input, GpioValue_Low}, + {0x13, GpioDirection_Input, GpioValue_Low}, + {0x14, GpioDirection_Input, GpioValue_High}, + {0x18, GpioDirection_Input, GpioValue_Low}, + {0x19, GpioDirection_Input, GpioValue_High}, + {0x1A, GpioDirection_Input, GpioValue_High}, + {0x1C, GpioDirection_Input, GpioValue_High}, + {0x4D, GpioDirection_Output, GpioValue_Low}, + {0x20, GpioDirection_Output, GpioValue_Low}, + {0x38, GpioDirection_Input, GpioValue_High}, + {0x23, GpioDirection_Input, GpioValue_High}, + {0x25, GpioDirection_Input, GpioValue_Low}, + {0x26, GpioDirection_Input, GpioValue_Low}, + {0x27, GpioDirection_Input, GpioValue_Low}, + {0x28, GpioDirection_Input, GpioValue_High}, + {0x29, GpioDirection_Input, GpioValue_High}, + {0x2A, GpioDirection_Input, GpioValue_High}, + {0x48, GpioDirection_Output, GpioValue_Low}, + {0x49, GpioDirection_Output, GpioValue_Low}, + {0x4A, GpioDirection_Output, GpioValue_Low}, + {0x2D, GpioDirection_Output, GpioValue_Low}, + {0x2E, GpioDirection_Output, GpioValue_Low}, + {0x37, GpioDirection_Input, GpioValue_Low}, + {0x2F, GpioDirection_Output, GpioValue_Low}, + {0x03, GpioDirection_Output, GpioValue_Low}, + {0x30, GpioDirection_Input, GpioValue_Low}, + {0x31, GpioDirection_Output, GpioValue_Low}, + {0x4B, GpioDirection_Output, GpioValue_Low}, + {0x4C, GpioDirection_Input, GpioValue_High}, + {0x4E, GpioDirection_Input, GpioValue_Low}, +}; + +constexpr u32 NumInitialConfigsCopper = (sizeof(InitialConfigsCopper) / sizeof(InitialConfigsCopper[0])); diff --git a/stratosphere/boot/source/gpio/gpio_initial_configuration_hoag.inc b/stratosphere/boot/source/gpio/gpio_initial_configuration_hoag.inc new file mode 100644 index 0000000..60ffdd3 --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_initial_configuration_hoag.inc @@ -0,0 +1,78 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialConfigsHoag[] = { + {0x04, GpioDirection_Input, GpioValue_High}, + {0x05, GpioDirection_Output, GpioValue_Low}, + {0x06, GpioDirection_Input, GpioValue_Low}, + {0x02, GpioDirection_Output, GpioValue_Low}, + {0x3C, GpioDirection_Input, GpioValue_Low}, + {0x0F, GpioDirection_Input, GpioValue_High}, + {0x08, GpioDirection_Input, GpioValue_Low}, + {0x09, GpioDirection_Input, GpioValue_Low}, + {0x0A, GpioDirection_Output, GpioValue_Low}, + {0x0B, GpioDirection_Input, GpioValue_Low}, + {0x0D, GpioDirection_Output, GpioValue_Low}, + {0x0E, GpioDirection_Input, GpioValue_Low}, + {0x10, GpioDirection_Input, GpioValue_Low}, + {0x11, GpioDirection_Input, GpioValue_Low}, + {0x12, GpioDirection_Input, GpioValue_Low}, + {0x13, GpioDirection_Input, GpioValue_Low}, + {0x14, GpioDirection_Input, GpioValue_High}, + {0x16, GpioDirection_Input, GpioValue_Low}, + {0x15, GpioDirection_Input, GpioValue_Low}, + {0x17, GpioDirection_Input, GpioValue_High}, + {0x18, GpioDirection_Input, GpioValue_Low}, + {0x19, GpioDirection_Input, GpioValue_High}, + {0x1A, GpioDirection_Input, GpioValue_High}, + {0x1B, GpioDirection_Input, GpioValue_Low}, + {0x1C, GpioDirection_Input, GpioValue_Low}, + {0x1D, GpioDirection_Output, GpioValue_Low}, + {0x1E, GpioDirection_Output, GpioValue_Low}, + {0x20, GpioDirection_Output, GpioValue_Low}, + {0x21, GpioDirection_Input, GpioValue_Low}, + {0x38, GpioDirection_Input, GpioValue_High}, + {0x22, GpioDirection_Input, GpioValue_Low}, + {0x23, GpioDirection_Input, GpioValue_High}, + {0x01, GpioDirection_Output, GpioValue_Low}, + {0x39, GpioDirection_Output, GpioValue_Low}, + {0x24, GpioDirection_Output, GpioValue_Low}, + {0x34, GpioDirection_Input, GpioValue_Low}, + {0x25, GpioDirection_Input, GpioValue_Low}, + {0x26, GpioDirection_Input, GpioValue_Low}, + {0x27, GpioDirection_Input, GpioValue_Low}, + {0x2B, GpioDirection_Output, GpioValue_Low}, + {0x28, GpioDirection_Input, GpioValue_High}, + {0x1F, GpioDirection_Output, GpioValue_Low}, + {0x29, GpioDirection_Input, GpioValue_High}, + {0x3A, GpioDirection_Output, GpioValue_Low}, + {0x0C, GpioDirection_Input, GpioValue_Low}, + {0x2D, GpioDirection_Output, GpioValue_Low}, + {0x2E, GpioDirection_Output, GpioValue_Low}, + {0x37, GpioDirection_Input, GpioValue_Low}, + {0x2F, GpioDirection_Output, GpioValue_Low}, + {0x03, GpioDirection_Output, GpioValue_Low}, + {0x30, GpioDirection_Input, GpioValue_Low}, + {0x3B, GpioDirection_Input, GpioValue_Low}, + {0x31, GpioDirection_Output, GpioValue_Low}, + {0x32, GpioDirection_Output, GpioValue_Low}, + {0x33, GpioDirection_Output, GpioValue_Low}, + {0x35, GpioDirection_Input, GpioValue_High}, + {0x2C, GpioDirection_Output, GpioValue_Low}, + {0x36, GpioDirection_Output, GpioValue_Low}, +}; + +constexpr u32 NumInitialConfigsHoag = (sizeof(InitialConfigsHoag) / sizeof(InitialConfigsHoag[0])); diff --git a/stratosphere/boot/source/gpio/gpio_initial_configuration_icosa.inc b/stratosphere/boot/source/gpio/gpio_initial_configuration_icosa.inc new file mode 100644 index 0000000..44c3482 --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_initial_configuration_icosa.inc @@ -0,0 +1,145 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialConfigsIcosa[] = { + {0x04, GpioDirection_Input, GpioValue_High}, + {0x05, GpioDirection_Output, GpioValue_Low}, + {0x06, GpioDirection_Input, GpioValue_Low}, + {0x02, GpioDirection_Output, GpioValue_Low}, + {0x07, GpioDirection_Output, GpioValue_Low}, + {0x3C, GpioDirection_Input, GpioValue_Low}, + {0x0F, GpioDirection_Input, GpioValue_High}, + {0x08, GpioDirection_Input, GpioValue_Low}, + {0x09, GpioDirection_Input, GpioValue_Low}, + {0x0A, GpioDirection_Output, GpioValue_Low}, + {0x0B, GpioDirection_Input, GpioValue_High}, + {0x0D, GpioDirection_Output, GpioValue_Low}, + {0x0E, GpioDirection_Input, GpioValue_Low}, + {0x10, GpioDirection_Input, GpioValue_Low}, + {0x11, GpioDirection_Input, GpioValue_Low}, + {0x12, GpioDirection_Input, GpioValue_Low}, + {0x13, GpioDirection_Input, GpioValue_Low}, + {0x14, GpioDirection_Input, GpioValue_High}, + {0x16, GpioDirection_Input, GpioValue_Low}, + {0x15, GpioDirection_Input, GpioValue_Low}, + {0x17, GpioDirection_Input, GpioValue_High}, + {0x18, GpioDirection_Input, GpioValue_Low}, + {0x19, GpioDirection_Input, GpioValue_High}, + {0x1A, GpioDirection_Input, GpioValue_High}, + {0x1B, GpioDirection_Input, GpioValue_High}, + {0x1C, GpioDirection_Input, GpioValue_Low}, + {0x1D, GpioDirection_Output, GpioValue_Low}, + {0x1E, GpioDirection_Output, GpioValue_Low}, + {0x20, GpioDirection_Output, GpioValue_Low}, + {0x21, GpioDirection_Input, GpioValue_High}, + {0x38, GpioDirection_Input, GpioValue_High}, + {0x22, GpioDirection_Input, GpioValue_Low}, + {0x23, GpioDirection_Input, GpioValue_High}, + {0x01, GpioDirection_Output, GpioValue_Low}, + {0x39, GpioDirection_Output, GpioValue_Low}, + {0x24, GpioDirection_Output, GpioValue_Low}, + {0x34, GpioDirection_Input, GpioValue_Low}, + {0x25, GpioDirection_Input, GpioValue_Low}, + {0x26, GpioDirection_Input, GpioValue_Low}, + {0x27, GpioDirection_Input, GpioValue_Low}, + {0x2B, GpioDirection_Output, GpioValue_Low}, + {0x28, GpioDirection_Input, GpioValue_High}, + {0x1F, GpioDirection_Output, GpioValue_Low}, + {0x29, GpioDirection_Input, GpioValue_High}, + {0x2A, GpioDirection_Input, GpioValue_High}, + {0x3A, GpioDirection_Output, GpioValue_Low}, + {0x0C, GpioDirection_Input, GpioValue_Low}, + {0x2D, GpioDirection_Output, GpioValue_Low}, + {0x2E, GpioDirection_Output, GpioValue_Low}, + {0x37, GpioDirection_Input, GpioValue_Low}, + {0x2F, GpioDirection_Output, GpioValue_Low}, + {0x03, GpioDirection_Output, GpioValue_Low}, + {0x30, GpioDirection_Input, GpioValue_Low}, + {0x3B, GpioDirection_Input, GpioValue_Low}, + {0x31, GpioDirection_Output, GpioValue_Low}, + {0x32, GpioDirection_Output, GpioValue_Low}, + {0x33, GpioDirection_Output, GpioValue_Low}, + {0x35, GpioDirection_Input, GpioValue_High}, + {0x2C, GpioDirection_Output, GpioValue_Low}, + {0x36, GpioDirection_Output, GpioValue_Low}, +}; + +constexpr u32 NumInitialConfigsIcosa = (sizeof(InitialConfigsIcosa) / sizeof(InitialConfigsIcosa[0])); + +constexpr InitialConfig InitialConfigsIcosa4x[] = { + {0x04, GpioDirection_Input, GpioValue_High}, + {0x05, GpioDirection_Output, GpioValue_Low}, + {0x06, GpioDirection_Input, GpioValue_Low}, + {0x02, GpioDirection_Output, GpioValue_Low}, + {0x07, GpioDirection_Output, GpioValue_Low}, + {0x3C, GpioDirection_Input, GpioValue_Low}, + {0x0F, GpioDirection_Input, GpioValue_High}, + {0x08, GpioDirection_Input, GpioValue_Low}, + {0x09, GpioDirection_Input, GpioValue_Low}, + {0x0A, GpioDirection_Output, GpioValue_Low}, + {0x0B, GpioDirection_Input, GpioValue_High}, + {0x0D, GpioDirection_Output, GpioValue_Low}, + {0x0E, GpioDirection_Input, GpioValue_Low}, + {0x10, GpioDirection_Input, GpioValue_Low}, + {0x11, GpioDirection_Input, GpioValue_Low}, + {0x12, GpioDirection_Input, GpioValue_Low}, + {0x13, GpioDirection_Input, GpioValue_Low}, + {0x14, GpioDirection_Input, GpioValue_High}, + {0x16, GpioDirection_Input, GpioValue_Low}, + {0x15, GpioDirection_Input, GpioValue_Low}, + {0x17, GpioDirection_Input, GpioValue_High}, + {0x18, GpioDirection_Input, GpioValue_High}, + {0x19, GpioDirection_Input, GpioValue_High}, + {0x1A, GpioDirection_Input, GpioValue_High}, + {0x1B, GpioDirection_Input, GpioValue_High}, + {0x1C, GpioDirection_Input, GpioValue_Low}, + {0x1D, GpioDirection_Output, GpioValue_Low}, + {0x1E, GpioDirection_Output, GpioValue_Low}, + {0x20, GpioDirection_Output, GpioValue_Low}, + {0x21, GpioDirection_Input, GpioValue_High}, + {0x38, GpioDirection_Input, GpioValue_High}, + {0x22, GpioDirection_Input, GpioValue_Low}, + {0x23, GpioDirection_Input, GpioValue_High}, + {0x01, GpioDirection_Output, GpioValue_Low}, + {0x39, GpioDirection_Output, GpioValue_Low}, + {0x24, GpioDirection_Output, GpioValue_Low}, + {0x34, GpioDirection_Input, GpioValue_Low}, + {0x25, GpioDirection_Input, GpioValue_Low}, + {0x26, GpioDirection_Input, GpioValue_Low}, + {0x27, GpioDirection_Input, GpioValue_Low}, + {0x2B, GpioDirection_Output, GpioValue_Low}, + {0x28, GpioDirection_Input, GpioValue_High}, + {0x1F, GpioDirection_Output, GpioValue_Low}, + {0x29, GpioDirection_Input, GpioValue_High}, + {0x2A, GpioDirection_Input, GpioValue_High}, + {0x3A, GpioDirection_Output, GpioValue_Low}, + {0x0C, GpioDirection_Input, GpioValue_Low}, + {0x2D, GpioDirection_Output, GpioValue_Low}, + {0x2E, GpioDirection_Output, GpioValue_Low}, + {0x37, GpioDirection_Input, GpioValue_Low}, + {0x2F, GpioDirection_Output, GpioValue_Low}, + {0x03, GpioDirection_Output, GpioValue_Low}, + {0x30, GpioDirection_Input, GpioValue_Low}, + {0x3B, GpioDirection_Input, GpioValue_Low}, + {0x31, GpioDirection_Output, GpioValue_Low}, + {0x32, GpioDirection_Output, GpioValue_Low}, + {0x33, GpioDirection_Output, GpioValue_Low}, + {0x35, GpioDirection_Input, GpioValue_High}, + {0x2C, GpioDirection_Output, GpioValue_Low}, + {0x36, GpioDirection_Output, GpioValue_Low}, +}; + +constexpr u32 NumInitialConfigsIcosa4x = (sizeof(InitialConfigsIcosa4x) / sizeof(InitialConfigsIcosa4x[0])); diff --git a/stratosphere/boot/source/gpio/gpio_initial_configuration_iowa.inc b/stratosphere/boot/source/gpio/gpio_initial_configuration_iowa.inc new file mode 100644 index 0000000..e6c0d16 --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_initial_configuration_iowa.inc @@ -0,0 +1,78 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialConfigsIowa[] = { + {0x04, GpioDirection_Input, GpioValue_High}, + {0x05, GpioDirection_Output, GpioValue_Low}, + {0x06, GpioDirection_Input, GpioValue_Low}, + {0x02, GpioDirection_Output, GpioValue_Low}, + {0x3C, GpioDirection_Input, GpioValue_Low}, + {0x0F, GpioDirection_Input, GpioValue_High}, + {0x08, GpioDirection_Input, GpioValue_Low}, + {0x09, GpioDirection_Input, GpioValue_Low}, + {0x0A, GpioDirection_Output, GpioValue_Low}, + {0x0B, GpioDirection_Input, GpioValue_Low}, + {0x0D, GpioDirection_Output, GpioValue_Low}, + {0x0E, GpioDirection_Input, GpioValue_Low}, + {0x10, GpioDirection_Input, GpioValue_Low}, + {0x11, GpioDirection_Input, GpioValue_Low}, + {0x12, GpioDirection_Input, GpioValue_Low}, + {0x13, GpioDirection_Input, GpioValue_Low}, + {0x14, GpioDirection_Input, GpioValue_High}, + {0x16, GpioDirection_Input, GpioValue_Low}, + {0x15, GpioDirection_Input, GpioValue_Low}, + {0x17, GpioDirection_Input, GpioValue_High}, + {0x18, GpioDirection_Input, GpioValue_Low}, + {0x19, GpioDirection_Input, GpioValue_High}, + {0x1A, GpioDirection_Input, GpioValue_High}, + {0x1B, GpioDirection_Input, GpioValue_Low}, + {0x1C, GpioDirection_Input, GpioValue_Low}, + {0x1D, GpioDirection_Output, GpioValue_Low}, + {0x1E, GpioDirection_Output, GpioValue_Low}, + {0x20, GpioDirection_Output, GpioValue_Low}, + {0x21, GpioDirection_Input, GpioValue_Low}, + {0x38, GpioDirection_Input, GpioValue_High}, + {0x22, GpioDirection_Input, GpioValue_Low}, + {0x23, GpioDirection_Input, GpioValue_High}, + {0x01, GpioDirection_Output, GpioValue_Low}, + {0x39, GpioDirection_Output, GpioValue_Low}, + {0x24, GpioDirection_Output, GpioValue_Low}, + {0x34, GpioDirection_Input, GpioValue_Low}, + {0x25, GpioDirection_Input, GpioValue_Low}, + {0x26, GpioDirection_Input, GpioValue_Low}, + {0x27, GpioDirection_Input, GpioValue_Low}, + {0x2B, GpioDirection_Output, GpioValue_Low}, + {0x28, GpioDirection_Input, GpioValue_High}, + {0x1F, GpioDirection_Output, GpioValue_Low}, + {0x29, GpioDirection_Input, GpioValue_High}, + {0x3A, GpioDirection_Output, GpioValue_Low}, + {0x0C, GpioDirection_Input, GpioValue_Low}, + {0x2D, GpioDirection_Output, GpioValue_Low}, + {0x2E, GpioDirection_Output, GpioValue_Low}, + {0x37, GpioDirection_Input, GpioValue_Low}, + {0x2F, GpioDirection_Output, GpioValue_Low}, + {0x03, GpioDirection_Output, GpioValue_Low}, + {0x30, GpioDirection_Input, GpioValue_Low}, + {0x3B, GpioDirection_Input, GpioValue_Low}, + {0x31, GpioDirection_Output, GpioValue_Low}, + {0x32, GpioDirection_Output, GpioValue_Low}, + {0x33, GpioDirection_Output, GpioValue_Low}, + {0x35, GpioDirection_Input, GpioValue_High}, + {0x2C, GpioDirection_Output, GpioValue_Low}, + {0x36, GpioDirection_Output, GpioValue_Low}, +}; + +constexpr u32 NumInitialConfigsIowa = (sizeof(InitialConfigsIowa) / sizeof(InitialConfigsIowa[0])); diff --git a/stratosphere/boot/source/gpio/gpio_map.inc b/stratosphere/boot/source/gpio/gpio_map.inc new file mode 100644 index 0000000..c3527da --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_map.inc @@ -0,0 +1,108 @@ +/* + * 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 . + */ + +constexpr u32 InvalidPadName = UINT32_MAX; + +constexpr u32 Map[] = { + InvalidPadName, /* Invalid */ + 0x000000CC, /* Port Z, Pin 4 */ + 0x00000024, /* Port E, Pin 4 */ + 0x0000003C, /* Port H, Pin 4 */ + 0x000000DA, /* Port BB, Pin 2 */ + 0x000000DB, /* Port BB, Pin 3 */ + 0x000000DC, /* Port BB, Pin 4 */ + 0x00000025, /* Port E, Pin 5 */ + 0x00000090, /* Port S, Pin 0 */ + 0x00000091, /* Port S, Pin 1 */ + 0x00000096, /* Port S, Pin 6 */ + 0x00000097, /* Port S, Pin 7 */ + 0x00000026, /* Port E, Pin 6 */ + 0x00000005, /* Port A, Pin 5 */ + 0x00000078, /* Port P, Pin 0 */ + 0x00000093, /* Port S, Pin 3 */ + 0x0000007D, /* Port P, Pin 5 */ + 0x0000007C, /* Port P, Pin 4 */ + 0x0000007B, /* Port P, Pin 3 */ + 0x0000007A, /* Port P, Pin 2 */ + 0x000000BC, /* Port X, Pin 4 */ + 0x000000AE, /* Port V, Pin 6 */ + 0x000000BA, /* Port X, Pin 2 */ + 0x000000B9, /* Port X, Pin 1 */ + 0x000000BD, /* Port X, Pin 5 */ + 0x000000BE, /* Port X, Pin 6 */ + 0x000000BF, /* Port X, Pin 7 */ + 0x000000C0, /* Port Y, Pin 0 */ + 0x000000C1, /* Port Y, Pin 1 */ + 0x000000A9, /* Port V, Pin 1 */ + 0x000000AA, /* Port V, Pin 2 */ + 0x00000055, /* Port K, Pin 5 */ + 0x000000AD, /* Port V, Pin 5 */ + 0x000000C8, /* Port Z, Pin 0 */ + 0x000000CA, /* Port Z, Pin 2 */ + 0x000000CB, /* Port Z, Pin 3 */ + 0x0000004F, /* Port J, Pin 7 */ + 0x00000050, /* Port K, Pin 0 */ + 0x00000051, /* Port K, Pin 1 */ + 0x00000052, /* Port K, Pin 2 */ + 0x00000054, /* Port K, Pin 4 */ + 0x00000056, /* Port K, Pin 6 */ + 0x00000057, /* Port K, Pin 7 */ + 0x00000053, /* Port K, Pin 3 */ + 0x000000E3, /* Port CC, Pin 3 */ + 0x00000038, /* Port H, Pin 0 */ + 0x00000039, /* Port H, Pin 1 */ + 0x0000003B, /* Port H, Pin 3 */ + 0x0000003D, /* Port H, Pin 5 */ + 0x0000003F, /* Port H, Pin 7 */ + 0x00000040, /* Port I, Pin 0 */ + 0x00000041, /* Port I, Pin 1 */ + 0x0000003E, /* Port H, Pin 6 */ + 0x000000E2, /* Port CC, Pin 2 */ + 0x000000E4, /* Port CC, Pin 4 */ + 0x0000003A, /* Port H, Pin 2 */ + 0x000000C9, /* Port Z, Pin 1 */ + 0x0000004D, /* Port J, Pin 5 */ + 0x00000058, /* Port L, Pin 0 */ + 0x0000003E, /* Port H, Pin 6 */ + 0x00000026, /* Port E, Pin 6 */ + + /* Copper only */ + InvalidPadName, /* Invalid */ + 0x00000033, /* Port G, Pin 3 */ + 0x0000001C, /* Port D, Pin 4 */ + 0x000000D9, /* Port BB, Pin 1 */ + 0x0000000C, /* Port B, Pin 4 */ + 0x0000000D, /* Port B, Pin 5 */ + 0x00000021, /* Port E, Pin 1 */ + 0x00000027, /* Port E, Pin 7 */ + 0x00000092, /* Port S, Pin 2 */ + 0x00000095, /* Port S, Pin 5 */ + 0x00000098, /* Port T, Pin 0 */ + 0x00000010, /* Port C, Pin 0 */ + 0x00000011, /* Port C, Pin 1 */ + 0x00000012, /* Port C, Pin 2 */ + 0x00000042, /* Port I, Pin 2 */ + 0x000000E6, /* Port CC, Pin 6 */ + + /* 2.0.0+ Copper only */ + 0x000000AC, /* Port V, Pin 4 */ + 0x000000E1, /* Port CC, Pin 1 */ + + /* 5.0.0+ Copper only (unused) */ + 0x00000056, /* Port K, Pin 6 */ +}; + +static constexpr u32 PadNameMax = (sizeof(Map) / sizeof(Map[0])); diff --git a/stratosphere/boot/source/gpio/gpio_utils.cpp b/stratosphere/boot/source/gpio/gpio_utils.cpp new file mode 100644 index 0000000..778f3a9 --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_utils.cpp @@ -0,0 +1,132 @@ +/* + * 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 + +#include "gpio_utils.hpp" + +namespace sts::gpio { + + namespace { + + /* Pull in GPIO map definitions. */ +#include "gpio_map.inc" + + constexpr u32 PhysicalBase = 0x6000D000; + + /* Globals. */ + bool g_initialized_gpio_vaddr = false; + uintptr_t g_gpio_vaddr = 0; + + /* Helpers. */ + inline u32 GetPadDescriptor(u32 gpio_pad_name) { + if (gpio_pad_name >= PadNameMax) { + std::abort(); + } + + return Map[gpio_pad_name]; + } + + uintptr_t GetBaseAddress() { + if (!g_initialized_gpio_vaddr) { + g_gpio_vaddr = GetIoMapping(PhysicalBase, 0x1000); + g_initialized_gpio_vaddr = true; + } + return g_gpio_vaddr; + } + + + } + + u32 Configure(u32 gpio_pad_name) { + uintptr_t gpio_base_vaddr = GetBaseAddress(); + + /* Fetch this GPIO's pad descriptor */ + const u32 gpio_pad_desc = GetPadDescriptor(gpio_pad_name); + + /* Discard invalid GPIOs */ + if (gpio_pad_desc == InvalidPadName) { + return InvalidPadName; + } + + /* Convert the GPIO pad descriptor into its register offset */ + u32 gpio_reg_offset = (((gpio_pad_desc << 0x03) & 0xFFFFFF00) | ((gpio_pad_desc >> 0x01) & 0x0C)); + + /* Extract the bit and lock values from the GPIO pad descriptor */ + u32 gpio_cnf_val = ((0x01 << ((gpio_pad_desc & 0x07) | 0x08)) | (0x01 << (gpio_pad_desc & 0x07))); + + /* Write to the appropriate GPIO_CNF_x register (upper offset) */ + reg::Write(gpio_base_vaddr + gpio_reg_offset + 0x80, gpio_cnf_val); + + /* Do a dummy read from GPIO_CNF_x register (lower offset) */ + gpio_cnf_val = reg::Read(gpio_base_vaddr + gpio_reg_offset + 0x00); + + return gpio_cnf_val; + } + + u32 SetDirection(u32 gpio_pad_name, GpioDirection dir) { + uintptr_t gpio_base_vaddr = GetBaseAddress(); + + /* Fetch this GPIO's pad descriptor */ + const u32 gpio_pad_desc = GetPadDescriptor(gpio_pad_name); + + /* Discard invalid GPIOs */ + if (gpio_pad_desc == InvalidPadName) { + return InvalidPadName; + } + + /* Convert the GPIO pad descriptor into its register offset */ + u32 gpio_reg_offset = (((gpio_pad_desc << 0x03) & 0xFFFFFF00) | ((gpio_pad_desc >> 0x01) & 0x0C)); + + /* Set the direction bit and lock values */ + u32 gpio_oe_val = ((0x01 << ((gpio_pad_desc & 0x07) | 0x08)) | (static_cast(dir) << (gpio_pad_desc & 0x07))); + + /* Write to the appropriate GPIO_OE_x register (upper offset) */ + reg::Write(gpio_base_vaddr + gpio_reg_offset + 0x90, gpio_oe_val); + + /* Do a dummy read from GPIO_OE_x register (lower offset) */ + gpio_oe_val = reg::Read(gpio_base_vaddr + gpio_reg_offset + 0x10); + + return gpio_oe_val; + } + + u32 SetValue(u32 gpio_pad_name, GpioValue val) { + uintptr_t gpio_base_vaddr = GetBaseAddress(); + + /* Fetch this GPIO's pad descriptor */ + const u32 gpio_pad_desc = GetPadDescriptor(gpio_pad_name); + + /* Discard invalid GPIOs */ + if (gpio_pad_desc == InvalidPadName) { + return InvalidPadName; + } + + /* Convert the GPIO pad descriptor into its register offset */ + u32 gpio_reg_offset = (((gpio_pad_desc << 0x03) & 0xFFFFFF00) | ((gpio_pad_desc >> 0x01) & 0x0C)); + + /* Set the output bit and lock values */ + u32 gpio_out_val = ((0x01 << ((gpio_pad_desc & 0x07) | 0x08)) | (static_cast(val) << (gpio_pad_desc & 0x07))); + + /* Write to the appropriate GPIO_OUT_x register (upper offset) */ + reg::Write(gpio_base_vaddr + gpio_reg_offset + 0xA0, gpio_out_val); + + /* Do a dummy read from GPIO_OUT_x register (lower offset) */ + gpio_out_val = reg::Read(gpio_base_vaddr + gpio_reg_offset + 0x20); + + return gpio_out_val; + } + +} diff --git a/stratosphere/boot/source/gpio/gpio_utils.hpp b/stratosphere/boot/source/gpio/gpio_utils.hpp new file mode 100644 index 0000000..ce39514 --- /dev/null +++ b/stratosphere/boot/source/gpio/gpio_utils.hpp @@ -0,0 +1,28 @@ +/* + * 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 . + */ + +#pragma once +#include +#include + +namespace sts::gpio { + + /* GPIO Utilities. */ + u32 Configure(u32 gpio_pad_name); + u32 SetDirection(u32 gpio_pad_name, GpioDirection dir); + u32 SetValue(u32 gpio_pad_name, GpioValue val); + +} diff --git a/stratosphere/boot/source/pinmux/pinmux_initial_configuration.cpp b/stratosphere/boot/source/pinmux/pinmux_initial_configuration.cpp new file mode 100644 index 0000000..091c55f --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_initial_configuration.cpp @@ -0,0 +1,113 @@ +/* + * 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 "pinmux_initial_configuration.hpp" +#include "pinmux_utils.hpp" + +/* TODO: Better way? */ +#include "../boot_spl_utils.hpp" + +namespace sts::pinmux { + + namespace { + + struct InitialConfig { + u32 name; + u32 val; + u32 mask; + }; + + /* Include all initial configuration definitions. */ +#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 = spl::GetHardwareType(); + + switch (hw_type) { + case spl::HardwareType::Icosa: + configs = InitialConfigsIcosa; + num_configs = NumInitialConfigsIcosa; + break; + case spl::HardwareType::Copper: + configs = InitialConfigsCopper; + num_configs = NumInitialConfigsCopper; + break; + case spl::HardwareType::Hoag: + configs = InitialConfigsHoag; + num_configs = NumInitialConfigsHoag; + break; + case spl::HardwareType::Iowa: + configs = InitialConfigsIowa; + num_configs = NumInitialConfigsIowa; + break; + default: + /* Unknown hardware type, we can't proceed. */ + std::abort(); + } + + /* Ensure we found an appropriate config. */ + if (configs == nullptr) { + std::abort(); + } + + for (size_t i = 0; i < num_configs - 1; i++) { + UpdatePad(configs[i].name, configs[i].val, configs[i].mask); + } + + /* Extra configs for iowa only. */ + if (hw_type == spl::HardwareType::Iowa) { + static constexpr u32 ExtraIowaPadNames[] = { + 0xAA, 0xAC, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9 + }; + for (size_t i = 0; i < sizeof(ExtraIowaPadNames) / sizeof(ExtraIowaPadNames[0]); i++) { + UpdatePad(ExtraIowaPadNames[i], 0x2000, 0x2000); + } + } + } + + void ConfigureInitialDrivePads() { + const InitialConfig *configs = InitialDrivePadConfigs; + for (size_t i = 0; i < NumInitialDrivePadConfigs; i++) { + UpdateDrivePad(configs[i].name, configs[i].val, configs[i].mask); + } + } + + } + + void SetInitialConfiguration() { + /* Update all parks. */ + UpdateAllParks(); + + /* Dummy read all drive pads. */ + DummyReadAllDrivePads(); + + /* Set initial pad configs. */ + ConfigureInitialPads(); + + /* Set initial drive pad configs. */ + ConfigureInitialDrivePads(); + } + +} diff --git a/stratosphere/boot/source/pinmux/pinmux_initial_configuration.hpp b/stratosphere/boot/source/pinmux/pinmux_initial_configuration.hpp new file mode 100644 index 0000000..8fee795 --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_initial_configuration.hpp @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +#pragma once +#include +#include + +namespace sts::pinmux { + + void SetInitialConfiguration(); + +} diff --git a/stratosphere/boot/source/pinmux/pinmux_initial_configuration_copper.inc b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_copper.inc new file mode 100644 index 0000000..6e8aa2f --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_copper.inc @@ -0,0 +1,181 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialConfigsCopper[] = { + {0x10, 0x20, 0x27F}, + {0x0F, 0x00, 0x267}, + {0x0E, 0x20, 0x27F}, + {0x5B, 0x00, 0x00}, + {0x80, 0x01, 0x7F}, + {0x34, 0x40, 0x267}, + {0x35, 0x40, 0x267}, + {0x55, 0x00, 0x18}, + {0x56, 0x01, 0x67}, + {0x5C, 0x00, 0x00}, + {0x59, 0x00, 0x00}, + {0x5A, 0x10, 0x18}, + {0x2C, 0x40, 0x267}, + {0x2D, 0x40, 0x267}, + {0x2E, 0x40, 0x267}, + {0x2F, 0x40, 0x267}, + {0x36, 0x00, 0x67}, + {0x37, 0x30, 0x7F}, + {0x38, 0x00, 0x67}, + {0x39, 0x28, 0x7F}, + {0x54, 0x00, 0x67}, + {0x9B, 0x30, 0x7F}, + {0x42, 0x00, 0x67}, + {0x43, 0x28, 0x7F}, + {0x44, 0x00, 0x67}, + {0x45, 0x28, 0x7F}, + {0x4B, 0x28, 0x7F}, + {0x4C, 0x00, 0x67}, + {0x4A, 0x00, 0x67}, + {0x4D, 0x00, 0x67}, + {0x64, 0x20, 0x27F}, + {0x63, 0x40, 0x267}, + {0x5E, 0x04, 0x67}, + {0x60, 0x04, 0x67}, + {0x17, 0x24, 0x7F}, + {0x18, 0x24, 0x7F}, + {0x27, 0x04, 0x67}, + {0x2A, 0x04, 0x67}, + {0x2B, 0x04, 0x67}, + {0x90, 0x24, 0x7F}, + {0x32, 0x24, 0x27F}, + {0x33, 0x34, 0x27F}, + {0x76, 0x04, 0x67}, + {0x79, 0x04, 0x67}, + {0x08, 0x24, 0x7F}, + {0x09, 0x24, 0x7F}, + {0x0A, 0x24, 0x7F}, + {0x0B, 0x24, 0x7F}, + {0x88, 0x34, 0x7F}, + {0x89, 0x24, 0x7F}, + {0x8A, 0x34, 0x7F}, + {0x8B, 0x34, 0x7F}, + {0x8D, 0x34, 0x7F}, + {0x81, 0x04, 0x67}, + {0x9D, 0x34, 0x7F}, + {0x9F, 0x34, 0x7F}, + {0xA1, 0x34, 0x7F}, + {0x92, 0x4C, 0x7F}, + {0x93, 0x4C, 0x7F}, + {0x94, 0x44, 0x7F}, + {0x96, 0x34, 0x7F}, + {0x98, 0x34, 0x7F}, + {0x99, 0x34, 0x7F}, + {0x12, 0x04, 0x7F}, + {0x13, 0x04, 0x67}, + {0x14, 0x04, 0x7F}, + {0x6A, 0x04, 0x67}, + {0x6B, 0x04, 0x67}, + {0x6C, 0x2C, 0x7F}, + {0x6D, 0x04, 0x67}, + {0x6E, 0x04, 0x67}, + {0x6F, 0x24, 0x7F}, + {0x70, 0x04, 0x7F}, + {0x73, 0x04, 0x67}, + {0x69, 0x24, 0x7F}, + {0x5D, 0x05, 0x07}, + {0x5F, 0x05, 0x07}, + {0x61, 0x05, 0x07}, + {0x47, 0x05, 0x07}, + {0x48, 0x05, 0x07}, + {0x46, 0x05, 0x07}, + {0x49, 0x05, 0x07}, + {0x19, 0x05, 0x07}, + {0x1A, 0x05, 0x07}, + {0x1B, 0x05, 0x07}, + {0x26, 0x05, 0x07}, + {0x28, 0x05, 0x07}, + {0x29, 0x05, 0x07}, + {0x8F, 0x05, 0x07}, + {0x30, 0x05, 0x07}, + {0x31, 0x05, 0x07}, + {0x52, 0x05, 0x07}, + {0x53, 0x05, 0x07}, + {0x75, 0x05, 0x07}, + {0x77, 0x05, 0x07}, + {0x78, 0x05, 0x07}, + {0x7A, 0x05, 0x07}, + {0x0D, 0x05, 0x07}, + {0x0C, 0x05, 0x07}, + {0x11, 0x05, 0x07}, + {0x8E, 0x05, 0x07}, + {0x00, 0x05, 0x07}, + {0x01, 0x05, 0x07}, + {0x05, 0x05, 0x07}, + {0x04, 0x05, 0x07}, + {0x03, 0x05, 0x07}, + {0x02, 0x05, 0x07}, + {0x06, 0x05, 0x07}, + {0x07, 0x05, 0x07}, + {0x87, 0x05, 0x07}, + {0x86, 0x05, 0x07}, + {0x82, 0x05, 0x07}, + {0x83, 0x05, 0x07}, + {0x85, 0x05, 0x07}, + {0x84, 0x05, 0x07}, + {0x8C, 0x05, 0x07}, + {0x7B, 0x05, 0x07}, + {0x7C, 0x05, 0x07}, + {0x7D, 0x05, 0x07}, + {0x7E, 0x05, 0x07}, + {0x7F, 0x05, 0x07}, + {0x9C, 0x05, 0x07}, + {0x9E, 0x05, 0x07}, + {0xA0, 0x05, 0x07}, + {0x58, 0x00, 0x00}, + {0x4F, 0x05, 0x07}, + {0x50, 0x05, 0x07}, + {0x4E, 0x05, 0x07}, + {0x51, 0x05, 0x07}, + {0x3A, 0x05, 0x07}, + {0x3B, 0x05, 0x07}, + {0x3C, 0x05, 0x07}, + {0x3D, 0x05, 0x07}, + {0x95, 0x05, 0x07}, + {0x97, 0x05, 0x07}, + {0x9A, 0x05, 0x07}, + {0x15, 0x05, 0x07}, + {0x16, 0x05, 0x07}, + {0x1C, 0x05, 0x07}, + {0x1D, 0x05, 0x07}, + {0x1E, 0x05, 0x07}, + {0x1F, 0x05, 0x07}, + {0x3E, 0x05, 0x07}, + {0x3F, 0x05, 0x07}, + {0x40, 0x05, 0x07}, + {0x41, 0x05, 0x07}, + {0x91, 0x05, 0x07}, + {0x71, 0x05, 0x07}, + {0x72, 0x05, 0x07}, + {0x74, 0x05, 0x07}, + {0x22, 0x05, 0x07}, + {0x23, 0x05, 0x07}, + {0x20, 0x05, 0x07}, + {0x21, 0x05, 0x07}, + {0x24, 0x05, 0x07}, + {0x25, 0x05, 0x07}, + {0x62, 0x05, 0x07}, + {0x65, 0x05, 0x07}, + {0x66, 0x05, 0x07}, + {0x67, 0x05, 0x07}, + {0x68, 0x05, 0x07}, +}; + +constexpr u32 NumInitialConfigsCopper = (sizeof(InitialConfigsCopper) / sizeof(InitialConfigsCopper[0])); diff --git a/stratosphere/boot/source/pinmux/pinmux_initial_configuration_hoag.inc b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_hoag.inc new file mode 100644 index 0000000..e33e880 --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_hoag.inc @@ -0,0 +1,181 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialConfigsHoag[] = { + {0x5D, 0x00, 0x67}, + {0x47, 0x28, 0x7F}, + {0x48, 0x00, 0x67}, + {0x46, 0x00, 0x67}, + {0x49, 0x00, 0x67}, + {0x30, 0x40, 0x27F}, + {0x31, 0x40, 0x27F}, + {0x0D, 0x20, 0x27F}, + {0x0C, 0x00, 0x267}, + {0x10, 0x20, 0x27F}, + {0x0F, 0x00, 0x267}, + {0x0E, 0x20, 0x27F}, + {0x00, 0x48, 0x7F}, + {0x01, 0x50, 0x7F}, + {0x05, 0x50, 0x7F}, + {0x04, 0x50, 0x7F}, + {0x03, 0x50, 0x7F}, + {0x02, 0x50, 0x7F}, + {0x5B, 0x00, 0x78}, + {0x7C, 0x01, 0x67}, + {0x80, 0x01, 0x7F}, + {0x34, 0x40, 0x27F}, + {0x35, 0x40, 0x27F}, + {0x55, 0x20, 0x78}, + {0x56, 0x20, 0x7F}, + {0xA1, 0x30, 0x7F}, + {0x5C, 0x00, 0x78}, + {0x59, 0x00, 0x60}, + {0x5A, 0x30, 0x78}, + {0x2C, 0x40, 0x27F}, + {0x2D, 0x40, 0x27F}, + {0x2E, 0x40, 0x27F}, + {0x2F, 0x40, 0x27F}, + {0x3B, 0x20, 0x7F}, + {0x3C, 0x00, 0x67}, + {0x3D, 0x20, 0x7F}, + {0x36, 0x00, 0x67}, + {0x37, 0x30, 0x7F}, + {0x38, 0x00, 0x67}, + {0x39, 0x28, 0x7F}, + {0x54, 0x00, 0x67}, + {0x9B, 0x30, 0x7F}, + {0x1C, 0x00, 0x67}, + {0x1D, 0x30, 0x7F}, + {0x1E, 0x00, 0x67}, + {0x1F, 0x00, 0x67}, + {0x3F, 0x20, 0x7F}, + {0x40, 0x00, 0x67}, + {0x41, 0x20, 0x7F}, + {0x42, 0x00, 0x67}, + {0x43, 0x28, 0x7F}, + {0x44, 0x00, 0x67}, + {0x45, 0x28, 0x7F}, + {0x22, 0x00, 0x67}, + {0x23, 0x28, 0x7F}, + {0x20, 0x00, 0x67}, + {0x21, 0x00, 0x67}, + {0x4B, 0x28, 0x7F}, + {0x4C, 0x00, 0x67}, + {0x4A, 0x00, 0x67}, + {0x4D, 0x00, 0x67}, + {0x64, 0x20, 0x27F}, + {0x5F, 0x34, 0x7F}, + {0x60, 0x04, 0x67}, + {0x61, 0x2C, 0x7F}, + {0x2A, 0x04, 0x67}, + {0x2B, 0x04, 0x67}, + {0x8F, 0x24, 0x7F}, + {0x33, 0x34, 0x27F}, + {0x52, 0x2C, 0x7F}, + {0x53, 0x24, 0x7F}, + {0x77, 0x04, 0x67}, + {0x78, 0x34, 0x7F}, + {0x11, 0x04, 0x67}, + {0x06, 0x2C, 0x7F}, + {0x08, 0x24, 0x7F}, + {0x09, 0x24, 0x7F}, + {0x0A, 0x24, 0x7F}, + {0x0B, 0x24, 0x7F}, + {0x88, 0x34, 0x7F}, + {0x86, 0x2C, 0x7F}, + {0x82, 0x24, 0x7F}, + {0x85, 0x34, 0x7F}, + {0x89, 0x24, 0x7F}, + {0x8A, 0x34, 0x7F}, + {0x8B, 0x34, 0x7F}, + {0x8C, 0x34, 0x7F}, + {0x8D, 0x24, 0x7F}, + {0x7D, 0x04, 0x67}, + {0x7E, 0x04, 0x67}, + {0x81, 0x04, 0x67}, + {0x9C, 0x34, 0x7F}, + {0x9D, 0x34, 0x7F}, + {0x9E, 0x2C, 0x7F}, + {0x9F, 0x34, 0x7F}, + {0xA0, 0x04, 0x67}, + {0x4F, 0x04, 0x67}, + {0x51, 0x04, 0x67}, + {0x3A, 0x24, 0x7F}, + {0x92, 0x4C, 0x7F}, + {0x93, 0x4C, 0x7F}, + {0x94, 0x44, 0x7F}, + {0x95, 0x04, 0x67}, + {0x96, 0x34, 0x7F}, + {0x97, 0x04, 0x67}, + {0x98, 0x34, 0x7F}, + {0x99, 0x34, 0x7F}, + {0x9A, 0x04, 0x67}, + {0x3E, 0x24, 0x7F}, + {0x6A, 0x04, 0x67}, + {0x6B, 0x04, 0x67}, + {0x6C, 0x2C, 0x7F}, + {0x6D, 0x04, 0x67}, + {0x6E, 0x04, 0x67}, + {0x6F, 0x24, 0x7F}, + {0x91, 0x24, 0x7F}, + {0x70, 0x04, 0x7F}, + {0x71, 0x04, 0x67}, + {0x72, 0x04, 0x67}, + {0x65, 0x34, 0x7F}, + {0x66, 0x04, 0x67}, + {0x67, 0x04, 0x267}, + {0x5E, 0x05, 0x07}, + {0x17, 0x05, 0x07}, + {0x18, 0x05, 0x07}, + {0x19, 0x05, 0x07}, + {0x1A, 0x05, 0x07}, + {0x1B, 0x05, 0x07}, + {0x26, 0x05, 0x07}, + {0x27, 0x05, 0x07}, + {0x28, 0x05, 0x07}, + {0x29, 0x05, 0x07}, + {0x90, 0x05, 0x07}, + {0x32, 0x05, 0x07}, + {0x75, 0x05, 0x07}, + {0x76, 0x05, 0x07}, + {0x79, 0x05, 0x07}, + {0x7A, 0x05, 0x07}, + {0x8E, 0x05, 0x07}, + {0x07, 0x05, 0x07}, + {0x87, 0x05, 0x07}, + {0x83, 0x05, 0x07}, + {0x84, 0x05, 0x07}, + {0x7B, 0x05, 0x07}, + {0x7F, 0x05, 0x07}, + {0x58, 0x00, 0x00}, + {0x50, 0x05, 0x07}, + {0x4E, 0x05, 0x07}, + {0x12, 0x05, 0x07}, + {0x13, 0x05, 0x07}, + {0x14, 0x05, 0x07}, + {0x15, 0x05, 0x07}, + {0x16, 0x05, 0x07}, + {0x73, 0x05, 0x07}, + {0x74, 0x05, 0x07}, + {0x24, 0x05, 0x07}, + {0x25, 0x05, 0x07}, + {0x62, 0x05, 0x07}, + {0x68, 0x05, 0x07}, + {0x69, 0x05, 0x07}, + {0x63, 0x05, 0x07}, +}; + +constexpr u32 NumInitialConfigsHoag = (sizeof(InitialConfigsHoag) / sizeof(InitialConfigsHoag[0])); diff --git a/stratosphere/boot/source/pinmux/pinmux_initial_configuration_icosa.inc b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_icosa.inc new file mode 100644 index 0000000..17d9af0 --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_icosa.inc @@ -0,0 +1,181 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialConfigsIcosa[] = { + {0x5D, 0x00, 0x67}, + {0x47, 0x28, 0x7F}, + {0x48, 0x00, 0x67}, + {0x46, 0x00, 0x67}, + {0x49, 0x00, 0x67}, + {0x30, 0x40, 0x27F}, + {0x31, 0x40, 0x27F}, + {0x0D, 0x20, 0x27F}, + {0x0C, 0x00, 0x267}, + {0x10, 0x20, 0x27F}, + {0x0F, 0x00, 0x267}, + {0x0E, 0x20, 0x27F}, + {0x00, 0x48, 0x7F}, + {0x01, 0x50, 0x7F}, + {0x05, 0x50, 0x7F}, + {0x04, 0x50, 0x7F}, + {0x03, 0x50, 0x7F}, + {0x02, 0x50, 0x7F}, + {0x5B, 0x00, 0x78}, + {0x7C, 0x01, 0x67}, + {0x80, 0x01, 0x7F}, + {0x34, 0x40, 0x27F}, + {0x35, 0x40, 0x27F}, + {0x55, 0x20, 0x78}, + {0x56, 0x20, 0x7F}, + {0xA1, 0x30, 0x7F}, + {0x5C, 0x00, 0x78}, + {0x59, 0x00, 0x60}, + {0x5A, 0x30, 0x78}, + {0x2C, 0x40, 0x27F}, + {0x2D, 0x40, 0x27F}, + {0x2E, 0x40, 0x27F}, + {0x2F, 0x40, 0x27F}, + {0x3B, 0x20, 0x7F}, + {0x3C, 0x00, 0x67}, + {0x3D, 0x20, 0x7F}, + {0x36, 0x00, 0x67}, + {0x37, 0x30, 0x7F}, + {0x38, 0x00, 0x67}, + {0x39, 0x28, 0x7F}, + {0x54, 0x00, 0x67}, + {0x9B, 0x30, 0x7F}, + {0x1C, 0x00, 0x67}, + {0x1D, 0x30, 0x7F}, + {0x1E, 0x00, 0x67}, + {0x1F, 0x00, 0x67}, + {0x3F, 0x20, 0x7F}, + {0x40, 0x00, 0x67}, + {0x41, 0x20, 0x7F}, + {0x42, 0x00, 0x67}, + {0x43, 0x28, 0x7F}, + {0x44, 0x00, 0x67}, + {0x45, 0x28, 0x7F}, + {0x22, 0x00, 0x67}, + {0x23, 0x28, 0x7F}, + {0x20, 0x00, 0x67}, + {0x21, 0x00, 0x67}, + {0x4B, 0x28, 0x7F}, + {0x4C, 0x00, 0x67}, + {0x4A, 0x00, 0x67}, + {0x4D, 0x00, 0x67}, + {0x64, 0x20, 0x27F}, + {0x5F, 0x34, 0x7F}, + {0x60, 0x04, 0x67}, + {0x61, 0x2C, 0x7F}, + {0x2A, 0x04, 0x67}, + {0x2B, 0x04, 0x67}, + {0x8F, 0x24, 0x7F}, + {0x33, 0x34, 0x27F}, + {0x52, 0x2C, 0x7F}, + {0x53, 0x24, 0x7F}, + {0x77, 0x04, 0x67}, + {0x78, 0x34, 0x7F}, + {0x11, 0x04, 0x67}, + {0x06, 0x2C, 0x7F}, + {0x08, 0x24, 0x7F}, + {0x09, 0x24, 0x7F}, + {0x0A, 0x24, 0x7F}, + {0x0B, 0x24, 0x7F}, + {0x88, 0x34, 0x7F}, + {0x86, 0x2C, 0x7F}, + {0x82, 0x24, 0x7F}, + {0x85, 0x34, 0x7F}, + {0x89, 0x24, 0x7F}, + {0x8A, 0x34, 0x7F}, + {0x8B, 0x34, 0x7F}, + {0x8C, 0x34, 0x7F}, + {0x8D, 0x24, 0x7F}, + {0x7D, 0x04, 0x67}, + {0x7E, 0x04, 0x67}, + {0x81, 0x04, 0x67}, + {0x9C, 0x34, 0x7F}, + {0x9D, 0x34, 0x7F}, + {0x9E, 0x2C, 0x7F}, + {0x9F, 0x34, 0x7F}, + {0xA0, 0x04, 0x67}, + {0x4F, 0x04, 0x67}, + {0x51, 0x04, 0x67}, + {0x3A, 0x24, 0x7F}, + {0x92, 0x4C, 0x7F}, + {0x93, 0x4C, 0x7F}, + {0x94, 0x44, 0x7F}, + {0x95, 0x04, 0x67}, + {0x96, 0x34, 0x7F}, + {0x97, 0x04, 0x67}, + {0x98, 0x34, 0x7F}, + {0x99, 0x34, 0x7F}, + {0x9A, 0x04, 0x67}, + {0x3E, 0x24, 0x7F}, + {0x6A, 0x04, 0x67}, + {0x6B, 0x04, 0x67}, + {0x6C, 0x2C, 0x7F}, + {0x6D, 0x04, 0x67}, + {0x6E, 0x04, 0x67}, + {0x6F, 0x24, 0x7F}, + {0x91, 0x24, 0x7F}, + {0x70, 0x04, 0x7F}, + {0x71, 0x04, 0x67}, + {0x72, 0x04, 0x67}, + {0x65, 0x34, 0x7F}, + {0x66, 0x04, 0x67}, + {0x67, 0x04, 0x267}, + {0x5E, 0x05, 0x07}, + {0x17, 0x05, 0x07}, + {0x18, 0x05, 0x07}, + {0x19, 0x05, 0x07}, + {0x1A, 0x05, 0x07}, + {0x1B, 0x05, 0x07}, + {0x26, 0x05, 0x07}, + {0x27, 0x05, 0x07}, + {0x28, 0x05, 0x07}, + {0x29, 0x05, 0x07}, + {0x90, 0x05, 0x07}, + {0x32, 0x05, 0x07}, + {0x75, 0x05, 0x07}, + {0x76, 0x05, 0x07}, + {0x79, 0x05, 0x07}, + {0x7A, 0x05, 0x07}, + {0x8E, 0x05, 0x07}, + {0x07, 0x05, 0x07}, + {0x87, 0x05, 0x07}, + {0x83, 0x05, 0x07}, + {0x84, 0x05, 0x07}, + {0x7B, 0x05, 0x07}, + {0x7F, 0x05, 0x07}, + {0x58, 0x00, 0x00}, + {0x50, 0x05, 0x07}, + {0x4E, 0x05, 0x07}, + {0x12, 0x05, 0x07}, + {0x13, 0x05, 0x07}, + {0x14, 0x05, 0x07}, + {0x15, 0x05, 0x07}, + {0x16, 0x05, 0x07}, + {0x73, 0x05, 0x07}, + {0x74, 0x05, 0x07}, + {0x24, 0x05, 0x07}, + {0x25, 0x05, 0x07}, + {0x62, 0x05, 0x07}, + {0x68, 0x05, 0x07}, + {0x69, 0x05, 0x07}, + {0x63, 0x05, 0x07}, +}; + +constexpr u32 NumInitialConfigsIcosa = (sizeof(InitialConfigsIcosa) / sizeof(InitialConfigsIcosa[0])); diff --git a/stratosphere/boot/source/pinmux/pinmux_initial_configuration_iowa.inc b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_iowa.inc new file mode 100644 index 0000000..11e7b57 --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_initial_configuration_iowa.inc @@ -0,0 +1,194 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialConfigsIowa[] = { + {0x5D, 0x00, 0x7F}, + {0x47, 0x28, 0x7F}, + {0x48, 0x00, 0x7F}, + {0x46, 0x00, 0x7F}, + {0x49, 0x00, 0x7F}, + {0x30, 0x40, 0x27F}, + {0x31, 0x40, 0x27F}, + {0x0D, 0x20, 0x27F}, + {0x0C, 0x00, 0x27F}, + {0x10, 0x40, 0x27F}, + {0x0F, 0x00, 0x27F}, + {0x0E, 0x20, 0x27F}, + {0x00, 0x40, 0x7F}, + {0x01, 0x50, 0x7F}, + {0x05, 0x50, 0x7F}, + {0x04, 0x50, 0x7F}, + {0x03, 0x50, 0x7F}, + {0x02, 0x50, 0x7F}, + {0xAA, 0x40, 0x7F}, + {0xAC, 0x40, 0x7F}, + {0xA2, 0x50, 0x7F}, + {0xA3, 0x50, 0x7F}, + {0xA4, 0x50, 0x7F}, + {0xA5, 0x50, 0x7F}, + {0xA6, 0x50, 0x7F}, + {0xA7, 0x50, 0x7F}, + {0xA8, 0x50, 0x7F}, + {0xA9, 0x50, 0x7F}, + {0x5B, 0x00, 0x78}, + {0x7C, 0x01, 0x67}, + {0x80, 0x01, 0x7F}, + {0x34, 0x40, 0x27F}, + {0x35, 0x40, 0x27F}, + {0x55, 0x20, 0x78}, + {0x56, 0x20, 0x7F}, + {0xA1, 0x30, 0x7F}, + {0x5C, 0x00, 0x78}, + {0x5A, 0x20, 0x78}, + {0x2C, 0x40, 0x27F}, + {0x2D, 0x40, 0x27F}, + {0x2E, 0x40, 0x27F}, + {0x2F, 0x40, 0x27F}, + {0x3B, 0x20, 0x7F}, + {0x3C, 0x00, 0x7F}, + {0x3D, 0x20, 0x7F}, + {0x36, 0x00, 0x7F}, + {0x37, 0x30, 0x7F}, + {0x38, 0x00, 0x7F}, + {0x39, 0x28, 0x7F}, + {0x54, 0x00, 0x67}, + {0x9B, 0x30, 0x7F}, + {0x1C, 0x00, 0x7F}, + {0x1D, 0x30, 0x7F}, + {0x1E, 0x00, 0x7F}, + {0x1F, 0x00, 0x7F}, + {0x3F, 0x20, 0x7F}, + {0x40, 0x00, 0x7F}, + {0x41, 0x20, 0x7F}, + {0x42, 0x00, 0x7F}, + {0x43, 0x28, 0x7F}, + {0x44, 0x00, 0x7F}, + {0x45, 0x28, 0x7F}, + {0x4B, 0x28, 0x7F}, + {0x4C, 0x00, 0x7F}, + {0x4A, 0x00, 0x7F}, + {0x4D, 0x00, 0x7F}, + {0x64, 0x20, 0x27F}, + {0x5F, 0x34, 0x7F}, + {0x60, 0x04, 0x67}, + {0x61, 0x2C, 0x7F}, + {0x2A, 0x04, 0x67}, + {0x8F, 0x24, 0x7F}, + {0x33, 0x34, 0x27F}, + {0x52, 0x2C, 0x7F}, + {0x53, 0x24, 0x7F}, + {0x77, 0x04, 0x67}, + {0x78, 0x24, 0x7F}, + {0x11, 0x04, 0x67}, + {0x06, 0x2C, 0x7F}, + {0x08, 0x24, 0x7F}, + {0x09, 0x24, 0x7F}, + {0x0A, 0x24, 0x7F}, + {0x0B, 0x24, 0x7F}, + {0x88, 0x34, 0x7F}, + {0x86, 0x2C, 0x7F}, + {0x82, 0x24, 0x7F}, + {0x85, 0x34, 0x7F}, + {0x89, 0x24, 0x7F}, + {0x8A, 0x34, 0x7F}, + {0x8B, 0x34, 0x7F}, + {0x8C, 0x24, 0x7F}, + {0x8D, 0x24, 0x7F}, + {0x7D, 0x04, 0x67}, + {0x7E, 0x04, 0x67}, + {0x81, 0x04, 0x67}, + {0x9C, 0x24, 0x7F}, + {0x9D, 0x34, 0x7F}, + {0x9E, 0x2C, 0x7F}, + {0x9F, 0x34, 0x7F}, + {0xA0, 0x04, 0x67}, + {0x4F, 0x04, 0x67}, + {0x51, 0x04, 0x67}, + {0x3A, 0x24, 0x7F}, + {0x92, 0x4C, 0x7F}, + {0x93, 0x4C, 0x7F}, + {0x94, 0x44, 0x7F}, + {0x95, 0x04, 0x67}, + {0x96, 0x34, 0x7F}, + {0x97, 0x04, 0x67}, + {0x98, 0x34, 0x7F}, + {0x9A, 0x04, 0x67}, + {0x3E, 0x24, 0x7F}, + {0x6A, 0x04, 0x67}, + {0x6B, 0x04, 0x67}, + {0x6C, 0x2C, 0x7F}, + {0x6D, 0x04, 0x67}, + {0x6E, 0x04, 0x67}, + {0x6F, 0x24, 0x7F}, + {0x91, 0x24, 0x7F}, + {0x70, 0x04, 0x7F}, + {0x71, 0x04, 0x67}, + {0x72, 0x04, 0x67}, + {0x65, 0x34, 0x7F}, + {0x66, 0x04, 0x67}, + {0x67, 0x04, 0x267}, + {0x5E, 0x05, 0x07}, + {0x17, 0x05, 0x07}, + {0x18, 0x05, 0x07}, + {0x19, 0x05, 0x07}, + {0x1A, 0x05, 0x07}, + {0x1B, 0x05, 0x07}, + {0x26, 0x05, 0x07}, + {0x27, 0x05, 0x07}, + {0x28, 0x05, 0x07}, + {0x29, 0x05, 0x07}, + {0x2B, 0x05, 0x07}, + {0x90, 0x05, 0x07}, + {0x32, 0x05, 0x07}, + {0x75, 0x05, 0x07}, + {0x76, 0x05, 0x07}, + {0x79, 0x05, 0x07}, + {0x7A, 0x05, 0x07}, + {0x8E, 0x05, 0x07}, + {0xAB, 0x05, 0x07}, + {0xAD, 0x05, 0x07}, + {0xAE, 0x05, 0x07}, + {0x07, 0x05, 0x07}, + {0x87, 0x05, 0x07}, + {0x83, 0x05, 0x07}, + {0x84, 0x05, 0x07}, + {0x7B, 0x05, 0x07}, + {0x7F, 0x05, 0x07}, + {0x58, 0x00, 0x00}, + {0x59, 0x00, 0x00}, + {0x50, 0x05, 0x07}, + {0x4E, 0x05, 0x07}, + {0x99, 0x05, 0x07}, + {0x12, 0x05, 0x07}, + {0x13, 0x05, 0x07}, + {0x14, 0x05, 0x07}, + {0x15, 0x05, 0x07}, + {0x16, 0x05, 0x07}, + {0x73, 0x05, 0x07}, + {0x74, 0x05, 0x07}, + {0x22, 0x05, 0x07}, + {0x23, 0x05, 0x07}, + {0x20, 0x05, 0x07}, + {0x21, 0x05, 0x07}, + {0x24, 0x05, 0x07}, + {0x25, 0x05, 0x07}, + {0x62, 0x05, 0x07}, + {0x68, 0x05, 0x07}, + {0x69, 0x05, 0x07}, + {0x63, 0x05, 0x07}, +}; + +constexpr u32 NumInitialConfigsIowa = (sizeof(InitialConfigsIowa) / sizeof(InitialConfigsIowa[0])); diff --git a/stratosphere/boot/source/pinmux/pinmux_initial_drive_pad_configuration.inc b/stratosphere/boot/source/pinmux/pinmux_initial_drive_pad_configuration.inc new file mode 100644 index 0000000..8d5d2fe --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_initial_drive_pad_configuration.inc @@ -0,0 +1,67 @@ +/* + * 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 . + */ + +constexpr InitialConfig InitialDrivePadConfigs[] = { + {0x04, 0x01010000, 0x01F1F000}, + {0x0D, 0x01010000, 0x01F1F000}, + {0x10, 0x01010000, 0x01F1F000}, + {0x12, 0x01010000, 0x01F1F000}, + {0x13, 0x01010000, 0x01F1F000}, + {0x14, 0x0001F000, 0x01F1F000}, + {0x15, 0x0001F000, 0x01F1F000}, + {0x24, 0x01010000, 0x01F1F000}, + {0x25, 0x01010000, 0x01F1F000}, + {0x26, 0x01010000, 0x01F1F000}, + {0x27, 0x01010000, 0x01F1F000}, + {0x28, 0x01010000, 0x01F1F000}, + {0x29, 0x01010000, 0x01F1F000}, + {0x2A, 0x01010000, 0x01F1F000}, + {0x2B, 0x01010000, 0x01F1F000}, + {0x2C, 0x01F1F000, 0x01F1F000}, + {0x2D, 0x01F1F000, 0x01F1F000}, + {0x2F, 0x01F1F000, 0x01F1F000}, + {0x30, 0x01404000, 0x01F1F000}, + {0x31, 0x0001F000, 0x01F1F000}, + {0x32, 0x0001F000, 0x01F1F000}, + {0x33, 0x0001F000, 0x01F1F000}, + {0x34, 0x0001F000, 0x01F1F000}, + {0x35, 0x00007000, 0x01F1F000}, + {0x36, 0x00007000, 0x01F1F000}, + {0x46, 0x01010000, 0x01F1F000}, + {0x47, 0x01010000, 0x01F1F000}, + {0x4C, 0x01404000, 0x01F1F000}, + {0x4D, 0x01404000, 0x01F1F000}, + {0x62, 0x0001F000, 0x01F1F000}, + {0x63, 0x0001F000, 0x01F1F000}, + {0x7C, 0x01414000, 0x01F1F000}, + {0x87, 0x01404000, 0x01F1F000}, + {0x88, 0x01404000, 0x01F1F000}, + {0x89, 0x01404000, 0x01F1F000}, + {0x8A, 0x01404000, 0x01F1F000}, + {0x6D, 0x00000000, 0xF0000000}, + {0x6E, 0x00000000, 0xF0000000}, + {0x6F, 0x00000000, 0xF0000000}, + {0x70, 0x00000000, 0xF0000000}, + {0x71, 0x00000000, 0xF0000000}, + {0x72, 0x00000000, 0xF0000000}, + {0x73, 0x00000000, 0xF0000000}, + {0x74, 0x00000000, 0xF0000000}, + {0x75, 0x00000000, 0xF0000000}, + {0x76, 0x00000000, 0xF0000000}, + {0x69, 0x51212000, 0xF1F1F000}, +}; + +constexpr u32 NumInitialDrivePadConfigs = (sizeof(InitialDrivePadConfigs) / sizeof(InitialDrivePadConfigs[0])); diff --git a/stratosphere/boot/source/pinmux/pinmux_map.inc b/stratosphere/boot/source/pinmux/pinmux_map.inc new file mode 100644 index 0000000..9890dd9 --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_map.inc @@ -0,0 +1,361 @@ +/* + * 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 . + */ + +struct Definition { + u32 reg_offset; + u32 mask_val; + u32 pm_val; +}; + +struct DrivePadDefinition { + u32 reg_offset; + u32 mask_val; +}; + +constexpr Definition Map[] = { + {0x00003000, 0x72FF, 0x01}, /* Sdmmc1Clk */ + {0x00003004, 0x72FF, 0x02}, /* Sdmmc1Cmd */ + {0x00003008, 0x72FF, 0x02}, /* Sdmmc1Dat3 */ + {0x0000300C, 0x72FF, 0x02}, /* Sdmmc1Dat2 */ + {0x00003010, 0x72FF, 0x02}, /* Sdmmc1Dat1 */ + {0x00003014, 0x72FF, 0x01}, /* Sdmmc1Dat0 */ + {0x0000301C, 0x72FF, 0x01}, /* Sdmmc3Clk */ + {0x00003020, 0x72FF, 0x01}, /* Sdmmc3Cmd */ + {0x00003024, 0x72FF, 0x01}, /* Sdmmc3Dat0 */ + {0x00003028, 0x72FF, 0x01}, /* Sdmmc3Dat1 */ + {0x0000302C, 0x72FF, 0x01}, /* Sdmmc3Dat2 */ + {0x00003030, 0x72FF, 0x01}, /* Sdmmc3Dat3 */ + {0x00003038, 0x1DFF, 0x01}, /* PexL0RstN */ + {0x0000303C, 0x1DFF, 0x01}, /* PexL0ClkreqN */ + {0x00003040, 0x1DFF, 0x01}, /* PexWakeN */ + {0x00003044, 0x1DFF, 0x01}, /* PexL1RstN */ + {0x00003048, 0x1DFF, 0x01}, /* PexL1ClkreqN */ + {0x0000304C, 0x19FF, 0x01}, /* SataLedActive */ + {0x00003050, 0x1F2FF, 0x01}, /* Spi1Mosi */ + {0x00003054, 0x1F2FF, 0x01}, /* Spi1Miso */ + {0x00003058, 0x1F2FF, 0x01}, /* Spi1Sck */ + {0x0000305C, 0x1F2FF, 0x01}, /* Spi1Cs0 */ + {0x00003060, 0x1F2FF, 0x01}, /* Spi1Cs1 */ + {0x00003064, 0x72FF, 0x02}, /* Spi2Mosi */ + {0x00003068, 0x72FF, 0x02}, /* Spi2Miso */ + {0x0000306C, 0x72FF, 0x02}, /* Spi2Sck */ + {0x00003070, 0x72FF, 0x02}, /* Spi2Cs0 */ + {0x00003074, 0x72FF, 0x01}, /* Spi2Cs1 */ + {0x00003078, 0x1F2FF, 0x01}, /* Spi4Mosi */ + {0x0000307C, 0x1F2FF, 0x01}, /* Spi4Miso */ + {0x00003080, 0x1F2FF, 0x01}, /* Spi4Sck */ + {0x00003084, 0x1F2FF, 0x01}, /* Spi4Cs0 */ + {0x00003088, 0x72FF, 0x01}, /* QspiSck */ + {0x0000308C, 0x72FF, 0x01}, /* QspiCsN */ + {0x00003090, 0x72FF, 0x01}, /* QspiIo0 */ + {0x00003094, 0x72FF, 0x01}, /* QspiIo1 */ + {0x00003098, 0x72FF, 0x01}, /* QspiIo2 */ + {0x0000309C, 0x72FF, 0x01}, /* QspiIo3 */ + {0x000030A4, 0x19FF, 0x02}, /* Dmic1Clk */ + {0x000030A8, 0x19FF, 0x02}, /* Dmic1Dat */ + {0x000030AC, 0x19FF, 0x02}, /* Dmic2Clk */ + {0x000030B0, 0x19FF, 0x02}, /* Dmic2Dat */ + {0x000030B4, 0x19FF, 0x02}, /* Dmic3Clk */ + {0x000030B8, 0x19FF, 0x02}, /* Dmic3Dat */ + {0x000030BC, 0x1DFF, 0x01}, /* Gen1I2cScl */ + {0x000030C0, 0x1DFF, 0x01}, /* Gen1I2cSda */ + {0x000030C4, 0x1DFF, 0x01}, /* Gen2I2cScl */ + {0x000030C8, 0x1DFF, 0x01}, /* Gen2I2cSda */ + {0x000030CC, 0x1DFF, 0x01}, /* Gen3I2cScl */ + {0x000030D0, 0x1DFF, 0x01}, /* Gen3I2cSda */ + {0x000030D4, 0x1DFF, 0x02}, /* CamI2cScl */ + {0x000030D8, 0x1DFF, 0x02}, /* CamI2cSda */ + {0x000030DC, 0x1DFF, 0x01}, /* PwrI2cScl */ + {0x000030E0, 0x1DFF, 0x01}, /* PwrI2cSda */ + {0x000030E4, 0x19FF, 0x01}, /* Uart1Tx */ + {0x000030E8, 0x19FF, 0x01}, /* Uart1Rx */ + {0x000030EC, 0x19FF, 0x01}, /* Uart1Rts */ + {0x000030F0, 0x19FF, 0x01}, /* Uart1Cts */ + {0x000030F4, 0x19FF, 0x00}, /* Uart2Tx */ + {0x000030F8, 0x19FF, 0x00}, /* Uart2Rx */ + {0x000030FC, 0x19FF, 0x02}, /* Uart2Rts */ + {0x00003100, 0x19FF, 0x02}, /* Uart2Cts */ + {0x00003104, 0x19FF, 0x02}, /* Uart3Tx */ + {0x00003108, 0x19FF, 0x02}, /* Uart3Rx */ + {0x0000310C, 0x19FF, 0x02}, /* Uart3Rts */ + {0x00003110, 0x19FF, 0x02}, /* Uart3Cts */ + {0x00003114, 0x19FF, 0x02}, /* Uart4Tx */ + {0x00003118, 0x19FF, 0x02}, /* Uart4Rx */ + {0x0000311C, 0x19FF, 0x02}, /* Uart4Rts */ + {0x00003120, 0x19FF, 0x02}, /* Uart4Cts */ + {0x00003124, 0x72FF, 0x01}, /* Dap1Fs */ + {0x00003128, 0x72FF, 0x01}, /* Dap1Din */ + {0x0000312C, 0x72FF, 0x01}, /* Dap1Dout */ + {0x00003130, 0x72FF, 0x01}, /* Dap1Sclk */ + {0x00003134, 0x72FF, 0x01}, /* Dap2Fs */ + {0x00003138, 0x72FF, 0x01}, /* Dap2Din */ + {0x0000313C, 0x72FF, 0x01}, /* Dap2Dout */ + {0x00003140, 0x72FF, 0x01}, /* Dap2Sclk */ + {0x00003144, 0x72FF, 0x01}, /* Dap4Fs */ + {0x00003148, 0x72FF, 0x01}, /* Dap4Din */ + {0x0000314C, 0x72FF, 0x01}, /* Dap4Dout */ + {0x00003150, 0x72FF, 0x01}, /* Dap4Sclk */ + {0x00003154, 0x72FF, 0x01}, /* Cam1Mclk */ + {0x00003158, 0x72FF, 0x01}, /* Cam2Mclk */ + {0x0000315C, 0x72FF, 0x01}, /* JtagRtck */ + {0x00003160, 0x118C, 0xFF}, /* Clk32kIn */ + {0x00003164, 0x72FF, 0x02}, /* Clk32kOut */ + {0x00003168, 0x1DFF, 0x01}, /* BattBcl */ + {0x0000316C, 0x11CC, 0xFF}, /* ClkReq */ + {0x00003170, 0x11CC, 0xFF}, /* CpuPwrReq */ + {0x00003174, 0x11CC, 0xFF}, /* PwrIntN */ + {0x00003178, 0x11CC, 0xFF}, /* Shutdown */ + {0x0000317C, 0x11CC, 0xFF}, /* CorePwrReq */ + {0x00003180, 0x19FF, 0x01}, /* AudMclk */ + {0x00003184, 0x19FF, 0x00}, /* DvfsPwm */ + {0x00003188, 0x19FF, 0x00}, /* DvfsClk */ + {0x0000318C, 0x19FF, 0x00}, /* GpioX1Aud */ + {0x00003190, 0x19FF, 0x00}, /* GpioX3Aud */ + {0x00003194, 0x1DFF, 0x00}, /* GpioPcc7 */ + {0x00003198, 0x1DFF, 0x01}, /* HdmiCec */ + {0x0000319C, 0x1DFF, 0x01}, /* HdmiIntDpHpd */ + {0x000031A0, 0x19FF, 0x01}, /* SpdifOut */ + {0x000031A4, 0x19FF, 0x01}, /* SpdifIn */ + {0x000031A8, 0x1DFF, 0x01}, /* UsbVbusEn0 */ + {0x000031AC, 0x1DFF, 0x01}, /* UsbVbusEn1 */ + {0x000031B0, 0x19FF, 0x01}, /* DpHpd0 */ + {0x000031B4, 0x19FF, 0x00}, /* WifiEn */ + {0x000031B8, 0x19FF, 0x00}, /* WifiRst */ + {0x000031BC, 0x19FF, 0x00}, /* WifiWakeAp */ + {0x000031C0, 0x19FF, 0x00}, /* ApWakeBt */ + {0x000031C4, 0x19FF, 0x00}, /* BtRst */ + {0x000031C8, 0x19FF, 0x00}, /* BtWakeAp */ + {0x000031CC, 0x19FF, 0x00}, /* ApWakeNfc */ + {0x000031D0, 0x19FF, 0x00}, /* NfcEn */ + {0x000031D4, 0x19FF, 0x00}, /* NfcInt */ + {0x000031D8, 0x19FF, 0x00}, /* GpsEn */ + {0x000031DC, 0x19FF, 0x00}, /* GpsRst */ + {0x000031E0, 0x19FF, 0x01}, /* CamRst */ + {0x000031E4, 0x19FF, 0x02}, /* CamAfEn */ + {0x000031E8, 0x19FF, 0x02}, /* CamFlashEn */ + {0x000031EC, 0x19FF, 0x01}, /* Cam1Pwdn */ + {0x000031F0, 0x19FF, 0x01}, /* Cam2Pwdn */ + {0x000031F4, 0x19FF, 0x01}, /* Cam1Strobe */ + {0x000031F8, 0x19FF, 0x01}, /* LcdTe */ + {0x000031FC, 0x19FF, 0x03}, /* LcdBlPwm */ + {0x00003200, 0x19FF, 0x00}, /* LcdBlEn */ + {0x00003204, 0x19FF, 0x00}, /* LcdRst */ + {0x00003208, 0x19FF, 0x01}, /* LcdGpio1 */ + {0x0000320C, 0x19FF, 0x02}, /* LcdGpio2 */ + {0x00003210, 0x19FF, 0x00}, /* ApReady */ + {0x00003214, 0x19FF, 0x00}, /* TouchRst */ + {0x00003218, 0x19FF, 0x01}, /* TouchClk */ + {0x0000321C, 0x19FF, 0x00}, /* ModemWakeAp */ + {0x00003220, 0x19FF, 0x00}, /* TouchInt */ + {0x00003224, 0x19FF, 0x00}, /* MotionInt */ + {0x00003228, 0x19FF, 0x00}, /* AlsProxInt */ + {0x0000322C, 0x19FF, 0x00}, /* TempAlert */ + {0x00003230, 0x19FF, 0x00}, /* ButtonPowerOn */ + {0x00003234, 0x19FF, 0x00}, /* ButtonVolUp */ + {0x00003238, 0x19FF, 0x00}, /* ButtonVolDown */ + {0x0000323C, 0x19FF, 0x00}, /* ButtonSlideSw */ + {0x00003240, 0x19FF, 0x00}, /* ButtonHome */ + {0x00003244, 0x19FF, 0x01}, /* GpioPa6 */ + {0x00003248, 0x19FF, 0x00}, /* GpioPe6 */ + {0x0000324C, 0x19FF, 0x00}, /* GpioPe7 */ + {0x00003250, 0x19FF, 0x00}, /* GpioPh6 */ + {0x00003254, 0x72FF, 0x02}, /* GpioPk0 */ + {0x00003258, 0x72FF, 0x02}, /* GpioPk1 */ + {0x0000325C, 0x72FF, 0x02}, /* GpioPk2 */ + {0x00003260, 0x72FF, 0x02}, /* GpioPk3 */ + {0x00003264, 0x72FF, 0x01}, /* GpioPk4 */ + {0x00003268, 0x72FF, 0x01}, /* GpioPk5 */ + {0x0000326C, 0x72FF, 0x01}, /* GpioPk6 */ + {0x00003270, 0x72FF, 0x01}, /* GpioPk7 */ + {0x00003274, 0x72FF, 0x00}, /* GpioPl0 */ + {0x00003278, 0x72FF, 0x01}, /* GpioPl1 */ + {0x0000327C, 0x72FF, 0x01}, /* GpioPz0 */ + {0x00003280, 0x72FF, 0x02}, /* GpioPz1 */ + {0x00003284, 0x72FF, 0x02}, /* GpioPz2 */ + {0x00003288, 0x72FF, 0x01}, /* GpioPz3 */ + {0x0000328C, 0x72FF, 0x01}, /* GpioPz4 */ + {0x00003290, 0x72FF, 0x01}, /* GpioPz5 */ + + /* 5.0.0+ only */ + {0x00003294, 0x1F2FF, 0x02}, /* Sdmmc2Dat0 */ + {0x00003298, 0x1F2FF, 0x02}, /* Sdmmc2Dat1 */ + {0x0000329C, 0x1F2FF, 0x02}, /* Sdmmc2Dat2 */ + {0x000032A0, 0x1F2FF, 0x02}, /* Sdmmc2Dat3 */ + {0x000032A4, 0x1F2FF, 0x02}, /* Sdmmc2Dat4 */ + {0x000032A8, 0x1F2FF, 0x02}, /* Sdmmc2Dat5 */ + {0x000032AC, 0x1F2FF, 0x02}, /* Sdmmc2Dat6 */ + {0x000032B0, 0x1F2FF, 0x02}, /* Sdmmc2Dat7 */ + {0x000032B4, 0x1F2FF, 0x02}, /* Sdmmc2Clk */ + {0x000032B8, 0x1F2FF, 0x00}, /* Sdmmc2Clkb */ + {0x000032BC, 0x1F2FF, 0x02}, /* Sdmmc2Cmd */ + {0x000032C0, 0x1F2FF, 0x00}, /* Sdmmc2Dqs */ + {0x000032C4, 0x1F2FF, 0x00}, /* Sdmmc2Dqsb */ +}; + +constexpr u32 PadNameMax = (sizeof(Map) / sizeof(Map[0])); + +constexpr DrivePadDefinition DrivePadMap[] = { + {0x000008E4, 0x01F1F000}, /* AlsProxInt */ + {0x000008E8, 0x01F1F000}, /* ApReady */ + {0x000008EC, 0x01F1F000}, /* ApWakeBt */ + {0x000008F0, 0x01F1F000}, /* ApWakeNfc */ + {0x000008F4, 0x01F1F000}, /* AudMclk */ + {0x000008F8, 0x01F1F000}, /* BattBcl */ + {0x000008FC, 0x01F1F000}, /* BtRst */ + {0x00000900, 0x01F1F000}, /* BtWakeAp */ + {0x00000904, 0x01F1F000}, /* ButtonHome */ + {0x00000908, 0x01F1F000}, /* ButtonPowerOn */ + {0x0000090C, 0x01F1F000}, /* ButtonSlideSw */ + {0x00000910, 0x01F1F000}, /* ButtonVolDown */ + {0x00000914, 0x01F1F000}, /* ButtonVolUp */ + {0x00000918, 0x01F1F000}, /* Cam1Mclk */ + {0x0000091C, 0x01F1F000}, /* Cam1Pwdn */ + {0x00000920, 0x01F1F000}, /* Cam1Strobe */ + {0x00000924, 0x01F1F000}, /* Cam2Mclk */ + {0x00000928, 0x01F1F000}, /* Cam2Pwdn */ + {0x0000092C, 0x01F1F000}, /* CamAfEn */ + {0x00000930, 0x01F1F000}, /* CamFlashEn */ + {0x00000934, 0x01F1F000}, /* CamI2cScl */ + {0x00000938, 0x01F1F000}, /* CamI2cSda */ + {0x0000093C, 0x01F1F000}, /* CamRst */ + {0x00000940, 0x01F1F000}, /* Clk32kIn */ + {0x00000944, 0x01F1F000}, /* Clk32kOut */ + {0x00000948, 0x01F1F000}, /* ClkReq */ + {0x0000094C, 0x01F1F000}, /* CorePwrReq */ + {0x00000950, 0x01F1F000}, /* CpuPwrReq */ + {0x00000954, 0xF0000000}, /* Dap1Din */ + {0x00000958, 0xF0000000}, /* Dap1Dout */ + {0x0000095C, 0xF0000000}, /* Dap1Fs */ + {0x00000960, 0xF0000000}, /* Dap1Sclk */ + {0x00000964, 0xF0000000}, /* Dap2Din */ + {0x00000968, 0xF0000000}, /* Dap2Dout */ + {0x0000096C, 0xF0000000}, /* Dap2Fs */ + {0x00000970, 0xF0000000}, /* Dap2Sclk */ + {0x00000974, 0x01F1F000}, /* Dap4Din */ + {0x00000978, 0x01F1F000}, /* Dap4Dout */ + {0x0000097C, 0x01F1F000}, /* Dap4Fs */ + {0x00000980, 0x01F1F000}, /* Dap4Sclk */ + {0x00000984, 0x01F1F000}, /* Dmic1Clk */ + {0x00000988, 0x01F1F000}, /* Dmic1Dat */ + {0x0000098C, 0x01F1F000}, /* Dmic2Clk */ + {0x00000990, 0x01F1F000}, /* Dmic2Dat */ + {0x00000994, 0x01F1F000}, /* Dmic3Clk */ + {0x00000998, 0x01F1F000}, /* Dmic3Dat */ + {0x0000099C, 0x01F1F000}, /* DpHpd */ + {0x000009A0, 0x01F1F000}, /* DvfsClk */ + {0x000009A4, 0x01F1F000}, /* DvfsPwm */ + {0x000009A8, 0x01F1F000}, /* Gen1I2cScl */ + {0x000009AC, 0x01F1F000}, /* Gen1I2cSda */ + {0x000009B0, 0x01F1F000}, /* Gen2I2cScl */ + {0x000009B4, 0x01F1F000}, /* Gen2I2cSda */ + {0x000009B8, 0x01F1F000}, /* Gen3I2cScl */ + {0x000009BC, 0x01F1F000}, /* Gen3I2cSda */ + {0x000009C0, 0x01F1F000}, /* GpioPa6 */ + {0x000009C4, 0x01F1F000}, /* GpioPcc7 */ + {0x000009C8, 0x01F1F000}, /* GpioPe6 */ + {0x000009CC, 0x01F1F000}, /* GpioPe7 */ + {0x000009D0, 0x01F1F000}, /* GpioPh6 */ + {0x000009D4, 0xF0000000}, /* GpioPk0 */ + {0x000009D8, 0xF0000000}, /* GpioPk1 */ + {0x000009DC, 0xF0000000}, /* GpioPk2 */ + {0x000009E0, 0xF0000000}, /* GpioPk3 */ + {0x000009E4, 0xF0000000}, /* GpioPk4 */ + {0x000009E8, 0xF0000000}, /* GpioPk5 */ + {0x000009EC, 0xF0000000}, /* GpioPk6 */ + {0x000009F0, 0xF0000000}, /* GpioPk7 */ + {0x000009F4, 0xF0000000}, /* GpioPl0 */ + {0x000009F8, 0xF0000000}, /* GpioPl1 */ + {0x000009FC, 0x07F7F000}, /* GpioPz0 */ + {0x00000A00, 0x07F7F000}, /* GpioPz1 */ + {0x00000A04, 0x07F7F000}, /* GpioPz2 */ + {0x00000A08, 0x07F7F000}, /* GpioPz3 */ + {0x00000A0C, 0x07F7F000}, /* GpioPz4 */ + {0x00000A10, 0x07F7F000}, /* GpioPz5 */ + {0x00000A14, 0x01F1F000}, /* GpioX1Aud */ + {0x00000A18, 0x01F1F000}, /* GpioX3Aud */ + {0x00000A1C, 0x01F1F000}, /* GpsEn */ + {0x00000A20, 0x01F1F000}, /* GpsRst */ + {0x00000A24, 0x01F1F000}, /* HdmiCec */ + {0x00000A28, 0x01F1F000}, /* HdmiIntDpHpd */ + {0x00000A2C, 0x01F1F000}, /* JtagRtck */ + {0x00000A30, 0x01F1F000}, /* LcdBlEn */ + {0x00000A34, 0x01F1F000}, /* LcdBlPwm */ + {0x00000A38, 0x01F1F000}, /* LcdGpio1 */ + {0x00000A3C, 0x01F1F000}, /* LcdGpio2 */ + {0x00000A40, 0x01F1F000}, /* LcdRst */ + {0x00000A44, 0x01F1F000}, /* LcdTe */ + {0x00000A48, 0x01F1F000}, /* ModemWakeAp */ + {0x00000A4C, 0x01F1F000}, /* MotionInt */ + {0x00000A50, 0x01F1F000}, /* NfcEn */ + {0x00000A54, 0x01F1F000}, /* NfcInt */ + {0x00000A58, 0x01F1F000}, /* PexL0ClkReqN */ + {0x00000A5C, 0x01F1F000}, /* PexL0RstN */ + {0x00000A60, 0x01F1F000}, /* PexL1ClkreqN */ + {0x00000A64, 0x01F1F000}, /* PexL1RstN */ + {0x00000A68, 0x01F1F000}, /* PexWakeN */ + {0x00000A6C, 0x01F1F000}, /* PwrI2cScl */ + {0x00000A70, 0x01F1F000}, /* PwrI2cSda */ + {0x00000A74, 0x01F1F000}, /* PwrIntN */ + {0x00000A78, 0x07F7F000}, /* QspiComp */ + {0x00000A90, 0xF0000000}, /* QspiSck */ + {0x00000A94, 0x01F1F000}, /* SataLedActive */ + {0x00000A98, 0xF7F7F000}, /* Sdmmc1Pad */ + {0x00000AB0, 0xF7F7F000}, /* Sdmmc3Pad */ + {0x00000AC8, 0x01F1F000}, /* Shutdown */ + {0x00000ACC, 0x01F1F000}, /* SpdifIn */ + {0x00000AD0, 0x01F1F000}, /* SpdifOut */ + {0x00000AD4, 0xF0000000}, /* Spi1Cs0 */ + {0x00000AD8, 0xF0000000}, /* Spi1Cs1 */ + {0x00000ADC, 0xF0000000}, /* Spi1Miso */ + {0x00000AE0, 0xF0000000}, /* Spi1Mosi */ + {0x00000AE4, 0xF0000000}, /* Spi1Sck */ + {0x00000AE8, 0xF0000000}, /* Spi2Cs0 */ + {0x00000AEC, 0xF0000000}, /* Spi2Cs1 */ + {0x00000AF0, 0xF0000000}, /* Spi2Miso */ + {0x00000AF4, 0xF0000000}, /* Spi2Mosi */ + {0x00000AF8, 0xF0000000}, /* Spi2Sck */ + {0x00000AFC, 0xF0000000}, /* Spi4Cs0 */ + {0x00000B00, 0xF0000000}, /* Spi4Miso */ + {0x00000B04, 0xF0000000}, /* Spi4Mosi */ + {0x00000B08, 0xF0000000}, /* Spi4Sck */ + {0x00000B0C, 0x01F1F000}, /* TempAlert */ + {0x00000B10, 0x01F1F000}, /* TouchClk */ + {0x00000B14, 0x01F1F000}, /* TouchInt */ + {0x00000B18, 0x01F1F000}, /* TouchRst */ + {0x00000B1C, 0x01F1F000}, /* Uart1Cts */ + {0x00000B20, 0x01F1F000}, /* Uart1Rts */ + {0x00000B24, 0x01F1F000}, /* Uart1Rx */ + {0x00000B28, 0x01F1F000}, /* Uart1Tx */ + {0x00000B2C, 0x01F1F000}, /* Uart2Cts */ + {0x00000B30, 0x01F1F000}, /* Uart2Rts */ + {0x00000B34, 0x01F1F000}, /* Uart2Rx */ + {0x00000B38, 0x01F1F000}, /* Uart2Tx */ + {0x00000B3C, 0x01F1F000}, /* Uart3Cts */ + {0x00000B40, 0x01F1F000}, /* Uart3Rts */ + {0x00000B44, 0x01F1F000}, /* Uart3Rx */ + {0x00000B48, 0x01F1F000}, /* Uart3Tx */ + {0x00000B4C, 0x01F1F000}, /* Uart4Cts */ + {0x00000B50, 0x01F1F000}, /* Uart4Rts */ + {0x00000B54, 0x01F1F000}, /* Uart4Rx */ + {0x00000B58, 0x01F1F000}, /* Uart4Tx */ + {0x00000B5C, 0x01F1F000}, /* UsbVbusEn0 */ + {0x00000B60, 0x01F1F000}, /* UsbVbusEn1 */ + {0x00000B64, 0x01F1F000}, /* WifiEn */ + {0x00000B68, 0x01F1F000}, /* WifiRst */ + {0x00000B6C, 0x01F1F000}, /* WifiWakeAp */ +}; + +constexpr u32 DrivePadNameMax = (sizeof(DrivePadMap) / sizeof(DrivePadMap[0])); diff --git a/stratosphere/boot/source/pinmux/pinmux_utils.cpp b/stratosphere/boot/source/pinmux/pinmux_utils.cpp new file mode 100644 index 0000000..404086a --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_utils.cpp @@ -0,0 +1,533 @@ +/* + * 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 + +#include "pinmux_utils.hpp" + +namespace sts::pinmux { + + namespace { + + /* Pull in Pinmux map definitions. */ +#include "pinmux_map.inc" + + constexpr u32 ApbMiscPhysicalBase = 0x70000000; + + /* Globals. */ + bool g_initialized_pinmux_vaddr = false; + uintptr_t g_pinmux_vaddr = 0; + + /* Helpers. */ + inline const Definition *GetDefinition(u32 pinmux_name) { + if (pinmux_name >= PadNameMax) { + std::abort(); + } + + return &Map[pinmux_name]; + } + + inline const DrivePadDefinition *GetDrivePadDefinition(u32 pinmux_name) { + if (pinmux_name >= DrivePadNameMax) { + std::abort(); + } + + return &DrivePadMap[pinmux_name]; + } + + uintptr_t GetBaseAddress() { + if (!g_initialized_pinmux_vaddr) { + g_pinmux_vaddr = GetIoMapping(ApbMiscPhysicalBase, 0x4000); + g_initialized_pinmux_vaddr = true; + } + return g_pinmux_vaddr; + } + + + + } + + u32 UpdatePark(u32 pinmux_name) { + const uintptr_t pinmux_base_vaddr = GetBaseAddress(); + const Definition *pinmux_def = GetDefinition(pinmux_name); + + /* Fetch this PINMUX's register offset */ + u32 pinmux_reg_offset = pinmux_def->reg_offset; + + /* Fetch this PINMUX's mask value */ + u32 pinmux_mask_val = pinmux_def->mask_val; + + /* Get current register ptr. */ + uintptr_t pinmux_reg = pinmux_base_vaddr + pinmux_reg_offset; + + /* Read from the PINMUX register */ + u32 pinmux_val = reg::Read(pinmux_reg); + + /* This PINMUX supports park change */ + if (pinmux_mask_val & 0x20) { + /* Clear park status if set */ + if (pinmux_val & 0x20) { + pinmux_val &= ~(0x20); + } + } + + /* Write to the appropriate PINMUX register */ + reg::Write(pinmux_reg, pinmux_val); + + /* Do a dummy read from the PINMUX register */ + pinmux_val = reg::Read(pinmux_reg); + + return pinmux_val; + } + + u32 UpdatePad(u32 pinmux_name, u32 pinmux_config_val, u32 pinmux_config_mask_val) { + const uintptr_t pinmux_base_vaddr = GetBaseAddress(); + const Definition *pinmux_def = GetDefinition(pinmux_name); + + /* Fetch this PINMUX's register offset */ + u32 pinmux_reg_offset = pinmux_def->reg_offset; + + /* Fetch this PINMUX's mask value */ + u32 pinmux_mask_val = pinmux_def->mask_val; + + /* Get current register ptr. */ + uintptr_t pinmux_reg = pinmux_base_vaddr + pinmux_reg_offset; + + /* Read from the PINMUX register */ + u32 pinmux_val = reg::Read(pinmux_reg); + + /* This PINMUX register is locked */ + if (pinmux_val & 0x80) { + std::abort(); + } + + u32 pm_val = (pinmux_config_val & 0x07); + + /* Adjust PM */ + if (pinmux_config_mask_val & 0x07) { + /* Apply additional changes first */ + if (pm_val == 0x05) { + /* This pin supports PUPD change */ + if (pinmux_mask_val & 0x0C) { + /* Change PUPD */ + if ((pinmux_val & 0x0C) != 0x04) { + pinmux_val &= 0xFFFFFFF3; + pinmux_val |= 0x04; + } + } + + /* This pin supports Tristate change */ + if (pinmux_mask_val & 0x10) { + /* Change Tristate */ + if (!(pinmux_val & 0x10)) { + pinmux_val |= 0x10; + } + } + + /* This pin supports EInput change */ + if (pinmux_mask_val & 0x40) { + /* Change EInput */ + if (pinmux_val & 0x40) { + pinmux_val &= 0xFFFFFFBF; + } + } + } else if (pm_val >= 0x06) { + /* Default to safe value */ + pm_val = 0x04; + } + + /* Translate PM value if necessary */ + if (pm_val == 0x04 || pm_val == 0x05) { + pm_val = pinmux_def->pm_val; + } + + /* This pin supports PM change */ + if (pinmux_mask_val & 0x03) { + /* Change PM */ + if ((pinmux_val & 0x03) != (pm_val & 0x03)) { + pinmux_val &= 0xFFFFFFFC; + pinmux_val |= (pm_val & 0x03); + } + } + } + + u32 pupd_config_val = (pinmux_config_val & 0x18); + + /* Adjust PUPD */ + if (pinmux_config_mask_val & 0x18) { + if (pupd_config_val < 0x11) { + /* This pin supports PUPD change */ + if (pinmux_mask_val & 0x0C) { + /* Change PUPD */ + if (((pinmux_val >> 0x02) & 0x03) != (pupd_config_val >> 0x03)) { + pinmux_val &= 0xFFFFFFF3; + pinmux_val |= (pupd_config_val >> 0x01); + } + } + } + } + + u32 eod_config_val = (pinmux_config_val & 0x60); + + /* Adjust EOd field */ + if (pinmux_config_mask_val & 0x60) { + if (eod_config_val == 0x20) { + /* This pin supports Tristate change */ + if (pinmux_mask_val & 0x10) { + /* Change Tristate */ + if (!(pinmux_val & 0x10)) { + pinmux_val |= 0x10; + } + } + + /* This pin supports EInput change */ + if (pinmux_mask_val & 0x40) { + /* Change EInput */ + if (!(pinmux_val & 0x40)) { + pinmux_val |= 0x40; + } + } + + /* This pin supports EOd change */ + if (pinmux_mask_val & 0x800) { + /* Change EOd */ + if (pinmux_val & 0x800) { + pinmux_val &= 0xFFFFF7FF; + } + } + } else if (eod_config_val == 0x40) { + /* This pin supports Tristate change */ + if (pinmux_mask_val & 0x10) { + /* Change Tristate */ + if (pinmux_val & 0x10) { + pinmux_val &= 0xFFFFFFEF; + } + } + + /* This pin supports EInput change */ + if (pinmux_mask_val & 0x40) { + /* Change EInput */ + if (!(pinmux_val & 0x40)) { + pinmux_val |= 0x40; + } + } + + /* This pin supports EOd change */ + if (pinmux_mask_val & 0x800) { + /* Change EOd */ + if (pinmux_val & 0x800) { + pinmux_val &= 0xFFFFF7FF; + } + } + } else if (eod_config_val == 0x60) { + /* This pin supports Tristate change */ + if (pinmux_mask_val & 0x10) { + /* Change Tristate */ + if (pinmux_val & 0x10) { + pinmux_val &= 0xFFFFFFEF; + } + } + + /* This pin supports EInput change */ + if (pinmux_mask_val & 0x40) { + /* Change EInput */ + if (!(pinmux_val & 0x40)) { + pinmux_val |= 0x40; + } + } + + /* This pin supports EOd change */ + if (pinmux_mask_val & 0x800) { + /* Change EOd */ + if (!(pinmux_val & 0x800)) { + pinmux_val |= 0x800; + } + } + } else { + /* This pin supports Tristate change */ + if (pinmux_mask_val & 0x10) { + /* Change Tristate */ + if (pinmux_val & 0x10) { + pinmux_val &= 0xFFFFFFEF; + } + } + + /* This pin supports EInput change */ + if (pinmux_mask_val & 0x40) { + /* Change EInput */ + if (pinmux_val & 0x40) { + pinmux_val &= 0xFFFFFFBF; + } + } + + /* This pin supports EOd change */ + if (pinmux_mask_val & 0x800) { + /* Change EOd */ + if (pinmux_val & 0x800) { + pinmux_val &= 0xFFFFF7FF; + } + } + } + } + + u32 lock_config_val = (pinmux_config_val & 0x80); + + /* Adjust Lock */ + if (pinmux_config_mask_val & 0x80) { + /* This pin supports Lock change */ + if (pinmux_mask_val & 0x80) { + /* Change Lock */ + if ((pinmux_val ^ pinmux_config_val) & 0x80) { + pinmux_val &= 0xFFFFFF7F; + pinmux_val |= lock_config_val; + } + } + } + + u32 ioreset_config_val = (((pinmux_config_val >> 0x08) & 0x1) << 0x10); + + /* Adjust IoReset */ + if (pinmux_config_mask_val & 0x100) { + /* This pin supports IoReset change */ + if (pinmux_mask_val & 0x10000) { + /* Change IoReset */ + if (((pinmux_val >> 0x10) ^ (pinmux_config_val >> 0x08)) & 0x01) { + pinmux_val &= 0xFFFEFFFF; + pinmux_val |= ioreset_config_val; + } + } + } + + u32 park_config_val = (((pinmux_config_val >> 0x0A) & 0x1) << 0x5); + + /* Adjust Park */ + if (pinmux_config_mask_val & 0x400) { + /* This pin supports Park change */ + if (pinmux_mask_val & 0x20) { + /* Change Park */ + if (((pinmux_val >> 0x05) ^ (pinmux_config_val >> 0x0A)) & 0x01) { + pinmux_val &= 0xFFFFFFDF; + pinmux_val |= park_config_val; + } + } + } + + u32 elpdr_config_val = (((pinmux_config_val >> 0x0B) & 0x1) << 0x08); + + /* Adjust ELpdr */ + if (pinmux_config_mask_val & 0x800) { + /* This pin supports ELpdr change */ + if (pinmux_mask_val & 0x100) { + /* Change ELpdr */ + if (((pinmux_val >> 0x08) ^ (pinmux_config_val >> 0x0B)) & 0x01) { + pinmux_val &= 0xFFFFFEFF; + pinmux_val |= elpdr_config_val; + } + } + } + + u32 ehsm_config_val = (((pinmux_config_val >> 0x0C) & 0x1) << 0x09); + + /* Adjust EHsm */ + if (pinmux_config_mask_val & 0x1000) { + /* This pin supports EHsm change */ + if (pinmux_mask_val & 0x200) { + /* Change EHsm */ + if (((pinmux_val >> 0x09) ^ (pinmux_config_val >> 0x0C)) & 0x01) { + pinmux_val &= 0xFFFFFDFF; + pinmux_val |= ehsm_config_val; + } + } + } + + u32 eiohv_config_val = (((pinmux_config_val >> 0x09) & 0x1) << 0x0A); + + /* Adjust EIoHv */ + if (pinmux_config_mask_val & 0x200) { + /* This pin supports EIoHv change */ + if (pinmux_mask_val & 0x400) { + /* Change EIoHv */ + if (((pinmux_val >> 0x0A) ^ (pinmux_config_val >> 0x09)) & 0x01) { + pinmux_val &= 0xFFFFFBFF; + pinmux_val |= eiohv_config_val; + } + } + } + + u32 eschmt_config_val = (((pinmux_config_val >> 0x0D) & 0x1) << 0x0C); + + /* Adjust ESchmt */ + if (pinmux_config_mask_val & 0x2000) { + /* This pin supports ESchmt change */ + if (pinmux_mask_val & 0x1000) { + /* Change ESchmt */ + if (((pinmux_val >> 0x0C) ^ (pinmux_config_val >> 0x0D)) & 0x01) { + pinmux_val &= 0xFFFFEFFF; + pinmux_val |= eschmt_config_val; + } + } + } + + u32 preemp_config_val = (((pinmux_config_val >> 0x10) & 0x1) << 0xF); + + /* Adjust Preemp */ + if (pinmux_config_mask_val & 0x10000) { + /* This pin supports Preemp change */ + if (pinmux_mask_val & 0x8000) { + /* Change Preemp */ + if (((pinmux_val >> 0x0F) ^ (pinmux_config_val >> 0x10)) & 0x01) { + pinmux_val &= 0xFFFF7FFF; + pinmux_val |= preemp_config_val; + } + } + } + + u32 drvtype_config_val = (((pinmux_config_val >> 0x0E) & 0x3) << 0xD); + + /* Adjust DrvType */ + if (pinmux_config_mask_val & 0xC000) { + /* This pin supports DrvType change */ + if (pinmux_mask_val & 0x6000) { + /* Change DrvType */ + if (((pinmux_val >> 0x0D) ^ (pinmux_config_val >> 0x0E)) & 0x03) { + pinmux_val &= 0xFFFF9FFF; + pinmux_val |= drvtype_config_val; + } + } + } + + /* Write to the appropriate PINMUX register */ + reg::Write(pinmux_reg, pinmux_val); + + /* Do a dummy read from the PINMUX register */ + pinmux_val = reg::Read(pinmux_reg); + + return pinmux_val; + } + + u32 UpdateDrivePad(u32 pinmux_drivepad_name, u32 pinmux_drivepad_config_val, u32 pinmux_drivepad_config_mask_val) { + const uintptr_t pinmux_base_vaddr = GetBaseAddress(); + const DrivePadDefinition *pinmux_drivepad_def = GetDrivePadDefinition(pinmux_drivepad_name); + + /* Fetch this PINMUX drive group's register offset */ + u32 pinmux_drivepad_reg_offset = pinmux_drivepad_def->reg_offset; + + /* Fetch this PINMUX drive group's mask value */ + u32 pinmux_drivepad_mask_val = pinmux_drivepad_def->mask_val; + + /* Get current register ptr. */ + uintptr_t pinmux_drivepad_reg = pinmux_base_vaddr + pinmux_drivepad_reg_offset; + + /* Read from the PINMUX drive group register */ + u32 pinmux_drivepad_val = reg::Read(pinmux_drivepad_reg); + + /* Adjust DriveDownStrength */ + if (pinmux_drivepad_config_mask_val & 0x1F000) { + u32 mask_val = 0x7F000; + + /* Adjust mask value */ + if ((pinmux_drivepad_mask_val & 0x7F000) != 0x7F000) + mask_val = 0x1F000; + + /* This drive group supports DriveDownStrength change */ + if (pinmux_drivepad_mask_val & mask_val) { + /* Change DriveDownStrength */ + if (((pinmux_drivepad_config_val & 0x7F000) & mask_val) != (pinmux_drivepad_val & mask_val)) { + pinmux_drivepad_val &= ~(mask_val); + pinmux_drivepad_val |= ((pinmux_drivepad_config_val & 0x7F000) & mask_val); + } + } + } + + /* Adjust DriveUpStrength */ + if (pinmux_drivepad_config_mask_val & 0x1F00000) { + u32 mask_val = 0x7F00000; + + /* Adjust mask value */ + if ((pinmux_drivepad_mask_val & 0x7F00000) != 0x7F00000) + mask_val = 0x1F00000; + + /* This drive group supports DriveUpStrength change */ + if (pinmux_drivepad_mask_val & mask_val) { + /* Change DriveUpStrength */ + if (((pinmux_drivepad_config_val & 0x7F00000) & mask_val) != (pinmux_drivepad_val & mask_val)) { + pinmux_drivepad_val &= ~(mask_val); + pinmux_drivepad_val |= ((pinmux_drivepad_config_val & 0x7F00000) & mask_val); + } + } + } + + /* Adjust DriveDownSlew */ + if (pinmux_drivepad_config_mask_val & 0x30000000) { + /* This drive group supports DriveDownSlew change */ + if (pinmux_drivepad_mask_val & 0x30000000) { + /* Change DriveDownSlew */ + if ((pinmux_drivepad_val ^ pinmux_drivepad_config_val) & 0x30000000) { + pinmux_drivepad_val &= 0xCFFFFFFF; + pinmux_drivepad_val |= (pinmux_drivepad_config_val & 0x30000000); + } + } + } + + /* Adjust DriveUpSlew */ + if (pinmux_drivepad_config_mask_val & 0xC0000000) { + /* This drive group supports DriveUpSlew change */ + if (pinmux_drivepad_mask_val & 0xC0000000) { + /* Change DriveUpSlew */ + if ((pinmux_drivepad_val ^ pinmux_drivepad_config_val) & 0xC0000000) { + pinmux_drivepad_val &= 0x3FFFFFFF; + pinmux_drivepad_val |= (pinmux_drivepad_config_val & 0xC0000000); + } + } + } + + /* Write to the appropriate PINMUX drive group register */ + reg::Write(pinmux_drivepad_reg, pinmux_drivepad_val); + + /* Do a dummy read from the PINMUX drive group register */ + pinmux_drivepad_val = reg::Read(pinmux_drivepad_reg); + + return pinmux_drivepad_val; + } + + u32 DummyReadDrivePad(u32 pinmux_drivepad_name) { + const uintptr_t pinmux_base_vaddr = GetBaseAddress(); + const DrivePadDefinition *pinmux_drivepad_def = GetDrivePadDefinition(pinmux_drivepad_name); + + /* Fetch this PINMUX drive group's register offset */ + u32 pinmux_drivepad_reg_offset = pinmux_drivepad_def->reg_offset; + + /* Get current register ptr. */ + uintptr_t pinmux_drivepad_reg = pinmux_base_vaddr + pinmux_drivepad_reg_offset; + + return reg::Read(pinmux_drivepad_reg); + } + + void UpdateAllParks() { + /* Update parks. */ + for (size_t i = 0; i < PadNameMax; i++) { + UpdatePark(static_cast(i)); + } + } + + void DummyReadAllDrivePads() { + /* Dummy read all drive pads. */ + for (size_t i = 0; i < DrivePadNameMax; i++) { + DummyReadDrivePad(static_cast(i)); + } + } + +} diff --git a/stratosphere/boot/source/pinmux/pinmux_utils.hpp b/stratosphere/boot/source/pinmux/pinmux_utils.hpp new file mode 100644 index 0000000..5e9a38b --- /dev/null +++ b/stratosphere/boot/source/pinmux/pinmux_utils.hpp @@ -0,0 +1,33 @@ +/* + * 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 . + */ + +#pragma once +#include +#include + +namespace sts::pinmux { + + /* Pinmux Utilities. */ + u32 UpdatePark(u32 pinmux_name); + u32 UpdatePad(u32 pinmux_name, u32 config_val, u32 config_mask); + u32 UpdateDrivePad(u32 pinmux_drivepad_name, u32 config_val, u32 config_mask); + u32 DummyReadDrivePad(u32 pinmux_drivepad_name); + + /* Helper API. */ + void UpdateAllParks(); + void DummyReadAllDrivePads(); + +}