gpio: add (most of) driver framework for boot sysmodule usage

This commit is contained in:
Michael Scire 2020-10-30 23:57:21 -07:00 committed by SciresM
parent ddf2f5f3c5
commit 4b4f05b4a6
58 changed files with 3380 additions and 836 deletions

View file

@ -38,7 +38,6 @@ namespace ams::ddsf {
void EventHandlerManager::Initialize() {
/* Check that we're not already initialized. */
AMS_ASSERT(!this->is_initialized);
if (this->is_initialized) {
return;
}

View file

@ -0,0 +1,88 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "impl/gpio_driver_impl.hpp"
#include "impl/gpio_initial_config.hpp"
#include "impl/gpio_tegra_pad.hpp"
namespace ams::gpio::driver::board::nintendo_nx {
namespace {
ams::gpio::driver::board::nintendo_nx::impl::DriverImpl *g_driver_impl = nullptr;
}
void Initialize(bool enable_interrupt_handlers) {
/* Check that we haven't previously initialized. */
AMS_ABORT_UNLESS(g_driver_impl == nullptr);
/* Get the device driver subsystem framework memory resource. */
auto *memory_resource = ddsf::GetMemoryResource();
/* Allocate a new driver. */
auto *driver_storage = static_cast<decltype(g_driver_impl)>(memory_resource->Allocate(sizeof(*g_driver_impl)));
AMS_ABORT_UNLESS(driver_storage != nullptr);
/* Construct the new driver. */
g_driver_impl = new (driver_storage) ams::gpio::driver::board::nintendo_nx::impl::DriverImpl(impl::GpioRegistersPhysicalAddress, impl::GpioRegistersSize);
/* Register the driver. */
gpio::driver::RegisterDriver(g_driver_impl);
/* Register interrupt handlers, if we should. */
if (enable_interrupt_handlers) {
for (size_t i = 0; i < util::size(impl::InterruptNameTable); ++i) {
/* Allocate a handler. */
impl::InterruptEventHandler *handler_storage = static_cast<impl::InterruptEventHandler *>(memory_resource->Allocate(sizeof(impl::InterruptEventHandler)));
AMS_ABORT_UNLESS(handler_storage != nullptr);
/* Initialize the handler. */
impl::InterruptEventHandler *handler = new (handler_storage) impl::InterruptEventHandler;
handler->Initialize(g_driver_impl, impl::InterruptNameTable[i], static_cast<int>(i));
/* Register the handler. */
gpio::driver::RegisterInterruptHandler(handler);
}
}
/* Create and register all pads. */
for (const auto &entry : impl::PadMapCombinationList) {
/* Allocate a pad for our device. */
impl::TegraPad *pad_storage = static_cast<impl::TegraPad *>(memory_resource->Allocate(sizeof(impl::TegraPad)));
AMS_ABORT_UNLESS(pad_storage != nullptr);
/* Create a pad for our device. */
impl::TegraPad *pad = new (pad_storage) impl::TegraPad;
pad->SetParameters(entry.internal_number, impl::PadInfo{entry.wake_event});
/* Register the pad with our driver. */
g_driver_impl->RegisterDevice(pad);
/* Register the device code with our driver. */
R_ABORT_UNLESS(gpio::driver::RegisterDeviceCode(entry.device_code, pad));
}
}
void SetInitialGpioConfig() {
return impl::SetInitialGpioConfig();
}
void SetInitialWakePinConfig() {
return impl::SetInitialWakePinConfig();
}
}

View file

@ -0,0 +1,277 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "gpio_driver_impl.hpp"
#include "gpio_register_accessor.hpp"
namespace ams::gpio::driver::board::nintendo_nx::impl {
DriverImpl::DriverImpl(dd::PhysicalAddress reg_paddr, size_t size) : gpio_physical_address(reg_paddr), gpio_virtual_address(), suspend_handler(this), interrupt_pad_list(), interrupt_control_mutex() {
/* Get the corresponding virtual address for our physical address. */
this->gpio_virtual_address = dd::QueryIoMapping(reg_paddr, size);
AMS_ABORT_UNLESS(this->gpio_virtual_address != 0);
}
void DriverImpl::InitializeDriver() {
/* Initialize our suspend handler. */
this->suspend_handler.Initialize(this->gpio_virtual_address);
}
void DriverImpl::FinalizeDriver() {
/* ... */
}
Result DriverImpl::InitializePad(Pad *pad) {
/* Validate arguments. */
AMS_ASSERT(pad != nullptr);
/* Convert the pad to an internal number. */
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Configure the pad as GPIO by modifying the appropriate bit in CNF. */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_CNF, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
SetMaskedBit(pad_address, pad_index, 1);
/* Read the pad address to make sure our configuration takes. */
reg::Read(pad_address);
return ResultSuccess();
}
void DriverImpl::FinalizePad(Pad *pad) {
/* Validate arguments. */
AMS_ASSERT(pad != nullptr);
/* Nothing to do. */
AMS_UNUSED(pad);
}
Result DriverImpl::GetDirection(Direction *out, Pad *pad) const {
/* Validate arguments. */
AMS_ASSERT(out != nullptr);
AMS_ASSERT(pad != nullptr);
/* Convert the pad to an internal number. */
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Get the pad direction by reading the appropriate bit in OE */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
if (reg::Read(pad_address, 1u << pad_index) != 0) {
*out = Direction_Output;
} else {
*out = Direction_Input;
}
return ResultSuccess();
}
Result DriverImpl::SetDirection(Pad *pad, Direction direction) {
/* Validate arguments. */
AMS_ASSERT(pad != nullptr);
/* Convert the pad to an internal number. */
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Configure the pad direction by modifying the appropriate bit in OE */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_OE, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
SetMaskedBit(pad_address, pad_index, direction);
/* Read the pad address to make sure our configuration takes. */
reg::Read(pad_address);
return ResultSuccess();
}
Result DriverImpl::GetValue(GpioValue *out, Pad *pad) const {
/* Validate arguments. */
AMS_ASSERT(out != nullptr);
AMS_ASSERT(pad != nullptr);
/* Convert the pad to an internal number. */
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Get the pad value by reading the appropriate bit in IN */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
if (reg::Read(pad_address, 1u << pad_index) != 0) {
*out = GpioValue_High;
} else {
*out = GpioValue_Low;
}
return ResultSuccess();
}
Result DriverImpl::SetValue(Pad *pad, GpioValue value) {
/* Validate arguments. */
AMS_ASSERT(pad != nullptr);
/* Convert the pad to an internal number. */
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Configure the pad value by modifying the appropriate bit in IN */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_IN, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
SetMaskedBit(pad_address, pad_index, value);
/* Read the pad address to make sure our configuration takes. */
reg::Read(pad_address);
return ResultSuccess();
}
Result DriverImpl::GetInterruptMode(InterruptMode *out, Pad *pad) const {
/* Validate arguments. */
AMS_ASSERT(out != nullptr);
AMS_ASSERT(pad != nullptr);
/* Convert the pad to an internal number. */
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Get the pad mode by reading the appropriate bits in INT_LVL */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
switch ((reg::Read(pad_address) >> pad_index) & InternalInterruptMode_Mask) {
case InternalInterruptMode_LowLevel: *out = InterruptMode_LowLevel; break;
case InternalInterruptMode_HighLevel: *out = InterruptMode_HighLevel; break;
case InternalInterruptMode_RisingEdge: *out = InterruptMode_RisingEdge; break;
case InternalInterruptMode_FallingEdge: *out = InterruptMode_FallingEdge; break;
case InternalInterruptMode_AnyEdge: *out = InterruptMode_AnyEdge; break;
AMS_UNREACHABLE_DEFAULT_CASE();
}
return ResultSuccess();
}
Result DriverImpl::SetInterruptMode(Pad *pad, InterruptMode mode) {
/* Validate arguments. */
AMS_ASSERT(pad != nullptr);
/* Convert the pad to an internal number. */
const InternalGpioPadNumber pad_number = pad->GetPadNumber();
/* Configure the pad mode by modifying the appropriate bits in INT_LVL */
const uintptr_t pad_address = GetGpioRegisterAddress(this->gpio_virtual_address, GpioRegisterType_GPIO_INT_LVL, pad_number);
const uintptr_t pad_index = ConvertInternalGpioPadNumberToBitIndex(pad_number);
switch (mode) {
case InterruptMode_LowLevel: reg::ReadWrite(pad_address, InternalInterruptMode_LowLevel << pad_index, InternalInterruptMode_Mask << pad_index); break;
case InterruptMode_HighLevel: reg::ReadWrite(pad_address, InternalInterruptMode_HighLevel << pad_index, InternalInterruptMode_Mask << pad_index); break;
case InterruptMode_RisingEdge: reg::ReadWrite(pad_address, InternalInterruptMode_RisingEdge << pad_index, InternalInterruptMode_Mask << pad_index); break;
case InterruptMode_FallingEdge: reg::ReadWrite(pad_address, InternalInterruptMode_FallingEdge << pad_index, InternalInterruptMode_Mask << pad_index); break;
case InterruptMode_AnyEdge: reg::ReadWrite(pad_address, InternalInterruptMode_AnyEdge << pad_index, InternalInterruptMode_Mask << pad_index); break;
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Read the pad address to make sure our configuration takes. */
reg::Read(pad_address);
return ResultSuccess();
}
Result DriverImpl::SetInterruptEnabled(Pad *pad, bool en) {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::GetInterruptStatus(InterruptStatus *out, Pad *pad) {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::ClearInterruptStatus(Pad *pad) {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::GetDebounceEnabled(bool *out, Pad *pad) const {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::SetDebounceEnabled(Pad *pad, bool en) {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::GetDebounceTime(s32 *out_ms, Pad *pad) const {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::SetDebounceTime(Pad *pad, s32 ms) {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::GetUnknown22(u32 *out) {
/* TODO */
AMS_ABORT();
}
void DriverImpl::Unknown23() {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::SetValueForSleepState(Pad *pad, GpioValue value) {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::IsWakeEventActive(bool *out, Pad *pad) const {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::SetWakeEventActiveFlagSetForDebug(Pad *pad, bool en) {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::SetWakePinDebugMode(WakePinDebugMode mode) {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::Suspend() {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::SuspendLow() {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::Resume() {
/* TODO */
AMS_ABORT();
}
Result DriverImpl::ResumeLow() {
/* TODO */
AMS_ABORT();
}
}

View file

@ -0,0 +1,101 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "gpio_tegra_pad.hpp"
#include "gpio_register_accessor.hpp"
#include "gpio_suspend_handler.hpp"
namespace ams::gpio::driver::board::nintendo_nx::impl {
class DriverImpl;
class InterruptEventHandler : public ddsf::IEventHandler {
private:
DriverImpl *driver;
os::InterruptName interrupt_name;
os::InterruptEventType interrupt_event;
int port_number;
private:
void CheckAndHandleInterrupt(TegraPad *pad);
public:
InterruptEventHandler() : IEventHandler(), driver(nullptr), interrupt_name(), interrupt_event(), port_number() { /* ... */ }
void Initialize(DriverImpl *driver, os::InterruptName intr, int port);
virtual void HandleEvent() override;
};
class DriverImpl : public ::ams::gpio::driver::IGpioDriver {
NON_COPYABLE(DriverImpl);
NON_MOVEABLE(DriverImpl);
AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::board::nintendo_nx::impl::DriverImpl, ::ams::gpio::driver::IGpioDriver);
private:
dd::PhysicalAddress gpio_physical_address;
uintptr_t gpio_virtual_address;
SuspendHandler suspend_handler;
TegraPad::List interrupt_pad_list;
mutable os::SdkMutex interrupt_control_mutex;
public:
DriverImpl(dd::PhysicalAddress reg_paddr, size_t size);
virtual void InitializeDriver() override;
virtual void FinalizeDriver() override;
virtual Result InitializePad(Pad *pad) override;
virtual void FinalizePad(Pad *pad) override;
virtual Result GetDirection(Direction *out, Pad *pad) const override;
virtual Result SetDirection(Pad *pad, Direction direction) override;
virtual Result GetValue(GpioValue *out, Pad *pad) const override;
virtual Result SetValue(Pad *pad, GpioValue value) override;
virtual Result GetInterruptMode(InterruptMode *out, Pad *pad) const override;
virtual Result SetInterruptMode(Pad *pad, InterruptMode mode) override;
virtual Result SetInterruptEnabled(Pad *pad, bool en) override;
virtual Result GetInterruptStatus(InterruptStatus *out, Pad *pad) override;
virtual Result ClearInterruptStatus(Pad *pad) override;
virtual os::SdkMutex &GetInterruptControlMutex(const Pad &pad) const override {
AMS_UNUSED(pad);
return this->interrupt_control_mutex;
}
virtual Result GetDebounceEnabled(bool *out, Pad *pad) const override;
virtual Result SetDebounceEnabled(Pad *pad, bool en) override;
virtual Result GetDebounceTime(s32 *out_ms, Pad *pad) const override;
virtual Result SetDebounceTime(Pad *pad, s32 ms) override;
virtual Result GetUnknown22(u32 *out) override;
virtual void Unknown23() override;
virtual Result SetValueForSleepState(Pad *pad, GpioValue value) override;
virtual Result IsWakeEventActive(bool *out, Pad *pad) const override;
virtual Result SetWakeEventActiveFlagSetForDebug(Pad *pad, bool en) override;
virtual Result SetWakePinDebugMode(WakePinDebugMode mode) override;
virtual Result Suspend() override;
virtual Result SuspendLow() override;
virtual Result Resume() override;
virtual Result ResumeLow() override;
};
}

View file

@ -0,0 +1,172 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "gpio_driver_impl.hpp"
#include "gpio_initial_config.hpp"
#include "gpio_wake_pin_config.hpp"
namespace ams::gpio::driver::board::nintendo_nx::impl {
namespace {
spl::HardwareType GetHardwareType() {
/* Acquire access to spl: */
sm::ScopedServiceHolder<spl::Initialize, spl::Finalize> spl_holder;
AMS_ABORT_UNLESS(static_cast<bool>(spl_holder));
/* Get config. */
return ::ams::spl::GetHardwareType();
}
#include "gpio_initial_wake_pin_config_icosa.inc"
/* #include "gpio_initial_wake_pin_config_copper.inc" */
#include "gpio_initial_wake_pin_config_hoag.inc"
#include "gpio_initial_wake_pin_config_iowa.inc"
#include "gpio_initial_wake_pin_config_calcio.inc"
#include "gpio_initial_wake_pin_config_five.inc"
#include "gpio_initial_config_icosa.inc"
/* #include "gpio_initial_config_copper.inc" */
#include "gpio_initial_config_hoag.inc"
#include "gpio_initial_config_iowa.inc"
#include "gpio_initial_config_calcio.inc"
#include "gpio_initial_config_five.inc"
}
void SetInitialGpioConfig() {
/* Set wake event levels, wake event enables. */
const GpioInitialConfig *configs = nullptr;
size_t num_configs = 0;
/* Select the correct config. */
switch (GetHardwareType()) {
case spl::HardwareType::Icosa:
configs = InitialGpioConfigsIcosa;
num_configs = NumInitialGpioConfigsIcosa;
break;
case spl::HardwareType::Hoag:
configs = InitialGpioConfigsHoag;
num_configs = NumInitialGpioConfigsHoag;
break;
case spl::HardwareType::Iowa:
configs = InitialGpioConfigsIowa;
num_configs = NumInitialGpioConfigsIowa;
break;
case spl::HardwareType::Calcio:
configs = InitialGpioConfigsCalcio;
num_configs = NumInitialGpioConfigsCalcio;
break;
case spl::HardwareType::_Five_:
configs = InitialGpioConfigsFive;
num_configs = NumInitialGpioConfigsFive;
break;
case spl::HardwareType::Copper:
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Check we can use our config. */
AMS_ABORT_UNLESS(configs != nullptr);
/* Apply the configs. */
{
/* Create a driver to use for the duration of our application. */
DriverImpl driver(GpioRegistersPhysicalAddress, GpioRegistersSize);
driver.InitializeDriver();
for (size_t i = 0; i < num_configs; ++i) {
/* Find the internal pad number for our device. */
bool found = false;
for (const auto &entry : PadMapCombinationList) {
if (entry.device_code == configs[i].device_code) {
/* We found an entry. */
found = true;
/* Create a pad for our device. */
TegraPad pad;
pad.SetParameters(entry.internal_number, PadInfo{entry.wake_event});
/* Initialize the pad. */
R_ABORT_UNLESS(driver.InitializePad(std::addressof(pad)));
/* Set the direction. */
R_ABORT_UNLESS(driver.SetDirection(std::addressof(pad), configs[i].direction));
/* If the direction is output, set the value. */
if (configs[i].direction == Direction_Output) {
R_ABORT_UNLESS(driver.SetValue(std::addressof(pad), configs[i].value));
}
/* Finalize the pad we made. */
driver.FinalizePad(std::addressof(pad));
break;
}
}
/* Ensure that we applied the config for the pad we wanted. */
AMS_ABORT_UNLESS(found);
}
/* Finalize the driver. */
driver.FinalizeDriver();
}
}
void SetInitialWakePinConfig() {
/* Ensure the wec driver is initialized. */
ams::wec::Initialize();
/* Set wake event levels, wake event enables. */
const WakePinConfig *configs = nullptr;
size_t num_configs = 0;
/* Select the correct config. */
switch (GetHardwareType()) {
case spl::HardwareType::Icosa:
configs = InitialWakePinConfigsIcosa;
num_configs = NumInitialWakePinConfigsIcosa;
break;
case spl::HardwareType::Hoag:
configs = InitialWakePinConfigsHoag;
num_configs = NumInitialWakePinConfigsHoag;
break;
case spl::HardwareType::Iowa:
configs = InitialWakePinConfigsIowa;
num_configs = NumInitialWakePinConfigsIowa;
break;
case spl::HardwareType::Calcio:
configs = InitialWakePinConfigsCalcio;
num_configs = NumInitialWakePinConfigsCalcio;
break;
case spl::HardwareType::_Five_:
configs = InitialWakePinConfigsFive;
num_configs = NumInitialWakePinConfigsFive;
break;
case spl::HardwareType::Copper:
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Check we can use our config. */
AMS_ABORT_UNLESS(configs != nullptr);
/* Apply the config. */
for (size_t i = 0; i < num_configs; ++i) {
wec::SetWakeEventLevel(configs[i].wake_event, configs[i].level);
wec::SetWakeEventEnabled(configs[i].wake_event, configs[i].enable);
}
}
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::gpio::driver::board::nintendo_nx::impl {
struct GpioInitialConfig {
DeviceCode device_code;
gpio::Direction direction;
gpio::GpioValue value;
};
void SetInitialGpioConfig();
void SetInitialWakePinConfig();
}

View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by gpio_pad_gen.py, do not edit manually. */
constexpr inline const GpioInitialConfig InitialGpioConfigsCalcio[] = {
{ DeviceCode_Debug0, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug1, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug2, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug3, Direction_Output, GpioValue_Low },
{ DeviceCode_PowSdEn, Direction_Output, GpioValue_Low },
{ DeviceCode_GpioPortF1, Direction_Output, GpioValue_Low },
{ DeviceCode_FanTach, Direction_Input, GpioValue_Low },
{ DeviceCode_TempAlert, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonSleep2, Direction_Input, GpioValue_Low },
{ DeviceCode_ButtonVolUp, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonVolDn, Direction_Input, GpioValue_High },
{ DeviceCode_RecoveryKey, Direction_Input, GpioValue_High },
{ DeviceCode_PdRstN, Direction_Output, GpioValue_Low },
{ DeviceCode_SdCd, Direction_Input, GpioValue_High },
{ DeviceCode_SdWp, Direction_Input, GpioValue_High },
{ DeviceCode_BtGpio2, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio3, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio4, Direction_Input, GpioValue_Low },
{ DeviceCode_CradleIrq, Direction_Input, GpioValue_High },
{ DeviceCode_PowVcpuInt, Direction_Input, GpioValue_High },
{ DeviceCode_Hdmi5VEn, Direction_Output, GpioValue_Low },
{ DeviceCode_UsbSwitchB1Oc, Direction_Input, GpioValue_High },
{ DeviceCode_HdmiPdTrEn, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiRfDisable, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiReset, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiWakeHost, Direction_Input, GpioValue_Low },
{ DeviceCode_ApWakeBt, Direction_Output, GpioValue_Low },
{ DeviceCode_BtRst, Direction_Output, GpioValue_Low },
{ DeviceCode_BtWakeAp, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio5, Direction_Output, GpioValue_Low },
{ DeviceCode_UsbSwitchB1En, Direction_Output, GpioValue_Low },
{ DeviceCode_HdmiHpd, Direction_Input, GpioValue_Low },
};
constexpr inline size_t NumInitialGpioConfigsCalcio = util::size(InitialGpioConfigsCalcio);

View file

@ -0,0 +1,70 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by gpio_pad_gen.py, do not edit manually. */
constexpr inline const GpioInitialConfig InitialGpioConfigsFive[] = {
{ DeviceCode_GameCardReset, Direction_Output, GpioValue_Low },
{ DeviceCode_CodecAlert, Direction_Input, GpioValue_Low },
{ DeviceCode_Debug0, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug1, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug2, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug3, Direction_Output, GpioValue_Low },
{ DeviceCode_PowSdEn, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtConWakeS, Direction_Input, GpioValue_Low },
{ DeviceCode_GameCardCd, Direction_Input, GpioValue_High },
{ DeviceCode_BattChgStatus, Direction_Input, GpioValue_Low },
{ DeviceCode_BattChgEnableN, Direction_Output, GpioValue_Low },
{ DeviceCode_FanTach, Direction_Input, GpioValue_Low },
{ DeviceCode_Vdd50AEn, Direction_Output, GpioValue_Low },
{ DeviceCode_Vdd5V3En, Direction_Output, GpioValue_Low },
{ DeviceCode_TempAlert, Direction_Input, GpioValue_High },
{ DeviceCode_MotionInt, Direction_Input, GpioValue_Low },
{ DeviceCode_CodecHpDetIrq, Direction_Input, GpioValue_Low },
{ DeviceCode_TpIrq, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonSleep2, Direction_Input, GpioValue_Low },
{ DeviceCode_ButtonVolUp, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonVolDn, Direction_Input, GpioValue_High },
{ DeviceCode_BattMgicIrq, Direction_Input, GpioValue_Low },
{ DeviceCode_RecoveryKey, Direction_Input, GpioValue_Low },
{ DeviceCode_LcdReset, Direction_Output, GpioValue_Low },
{ DeviceCode_PdRstN, Direction_Output, GpioValue_Low },
{ DeviceCode_Bq24190Irq, Direction_Input, GpioValue_Low },
{ DeviceCode_SdCd, Direction_Input, GpioValue_High },
{ DeviceCode_SdWp, Direction_Input, GpioValue_High },
{ DeviceCode_CodecLdoEnTemp, Direction_Output, GpioValue_Low },
{ DeviceCode_TpReset, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtconDetU, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio2, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio3, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio4, Direction_Input, GpioValue_Low },
{ DeviceCode_ExtconChgU, Direction_Output, GpioValue_Low },
{ DeviceCode_CradleIrq, Direction_Input, GpioValue_High },
{ DeviceCode_PdVconnEn, Direction_Output, GpioValue_Low },
{ DeviceCode_PowVcpuInt, Direction_Input, GpioValue_High },
{ DeviceCode_ExtconDetS, Direction_Input, GpioValue_Low },
{ DeviceCode_GpioPortH0, Direction_Input, GpioValue_Low },
{ DeviceCode_WifiReset, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiWakeHost, Direction_Input, GpioValue_Low },
{ DeviceCode_ApWakeBt, Direction_Output, GpioValue_Low },
{ DeviceCode_BtRst, Direction_Output, GpioValue_Low },
{ DeviceCode_BtWakeAp, Direction_Input, GpioValue_Low },
{ DeviceCode_ExtConWakeU, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio5, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtconChgS, Direction_Output, GpioValue_Low },
};
constexpr inline size_t NumInitialGpioConfigsFive = util::size(InitialGpioConfigsFive);

View file

@ -0,0 +1,82 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by gpio_pad_gen.py, do not edit manually. */
constexpr inline const GpioInitialConfig InitialGpioConfigsHoag[] = {
{ DeviceCode_GameCardReset, Direction_Output, GpioValue_Low },
{ DeviceCode_CodecAlert, Direction_Input, GpioValue_Low },
{ DeviceCode_Debug0, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug1, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug2, Direction_Output, GpioValue_Low },
{ DeviceCode_Debug3, Direction_Output, GpioValue_Low },
{ DeviceCode_PowSdEn, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtConWakeS, Direction_Input, GpioValue_Low },
{ DeviceCode_McuIrq, Direction_Input, GpioValue_High },
{ DeviceCode_GameCardCd, Direction_Input, GpioValue_High },
{ DeviceCode_BattChgStatus, Direction_Input, GpioValue_Low },
{ DeviceCode_BattChgEnableN, Direction_Output, GpioValue_Low },
{ DeviceCode_FanTach, Direction_Input, GpioValue_Low },
{ DeviceCode_McuBoot, Direction_Output, GpioValue_Low },
{ DeviceCode_McuRst, Direction_Output, GpioValue_Low },
{ DeviceCode_Vdd50AEn, Direction_Output, GpioValue_Low },
{ DeviceCode_Vdd5V3En, Direction_Output, GpioValue_Low },
{ DeviceCode_TempAlert, Direction_Input, GpioValue_High },
{ DeviceCode_MotionInt, Direction_Input, GpioValue_Low },
{ DeviceCode_CodecHpDetIrq, Direction_Input, GpioValue_Low },
{ DeviceCode_TpIrq, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonSleep2, Direction_Input, GpioValue_Low },
{ DeviceCode_ButtonVolUp, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonVolDn, Direction_Input, GpioValue_High },
{ DeviceCode_BattMgicIrq, Direction_Input, GpioValue_Low },
{ DeviceCode_RecoveryKey, Direction_Input, GpioValue_High },
{ DeviceCode_PowLcdBlEn, Direction_Output, GpioValue_Low },
{ DeviceCode_LcdReset, Direction_Output, GpioValue_Low },
{ DeviceCode_LcdGpio1, Direction_Input, GpioValue_High },
{ DeviceCode_PdRstN, Direction_Output, GpioValue_Low },
{ DeviceCode_Bq24190Irq, Direction_Input, GpioValue_Low },
{ DeviceCode_SdCd, Direction_Input, GpioValue_High },
{ DeviceCode_SdWp, Direction_Input, GpioValue_High },
{ DeviceCode_CodecLdoEnTemp, Direction_Output, GpioValue_Low },
{ DeviceCode_NfcEn, Direction_Output, GpioValue_Low },
{ DeviceCode_NfcIrq, Direction_Input, GpioValue_Low },
{ DeviceCode_TpReset, Direction_Output, GpioValue_Low },
{ DeviceCode_BtGpio2, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio3, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio4, Direction_Input, GpioValue_Low },
{ DeviceCode_CradleIrq, Direction_Input, GpioValue_High },
{ DeviceCode_PdVconnEn, Direction_Output, GpioValue_Low },
{ DeviceCode_PowVcpuInt, Direction_Input, GpioValue_High },
{ DeviceCode_NfcRst, Direction_Output, GpioValue_Low },
{ DeviceCode_GpioPortC7, Direction_Input, GpioValue_Low },
{ DeviceCode_GpioPortD0, Direction_Input, GpioValue_Low },
{ DeviceCode_GpioPortC5, Direction_Input, GpioValue_Low },
{ DeviceCode_GpioPortC6, Direction_Input, GpioValue_Low },
{ DeviceCode_GpioPortY7, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiRfDisable, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiReset, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiWakeHost, Direction_Input, GpioValue_Low },
{ DeviceCode_ApWakeBt, Direction_Output, GpioValue_Low },
{ DeviceCode_BtRst, Direction_Output, GpioValue_Low },
{ DeviceCode_BtWakeAp, Direction_Input, GpioValue_Low },
{ DeviceCode_ExtConWakeU, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio5, Direction_Output, GpioValue_Low },
{ DeviceCode_PowLcdVddPEn, Direction_Output, GpioValue_Low },
{ DeviceCode_PowLcdVddNEn, Direction_Output, GpioValue_Low },
{ DeviceCode_McuPor, Direction_Output, GpioValue_Low },
};
constexpr inline size_t NumInitialGpioConfigsHoag = util::size(InitialGpioConfigsHoag);

View file

@ -0,0 +1,82 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by gpio_pad_gen.py, do not edit manually. */
constexpr inline const GpioInitialConfig InitialGpioConfigsIcosa[] = {
{ DeviceCode_RamCode3, Direction_Input, GpioValue_High },
{ DeviceCode_GameCardReset, Direction_Output, GpioValue_Low },
{ DeviceCode_CodecAlert, Direction_Input, GpioValue_Low },
{ DeviceCode_PowSdEn, Direction_Output, GpioValue_Low },
{ DeviceCode_PowGc, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtConWakeS, Direction_Input, GpioValue_Low },
{ DeviceCode_GameCardCd, Direction_Input, GpioValue_High },
{ DeviceCode_DebugControllerDet, Direction_Input, GpioValue_Low },
{ DeviceCode_BattChgStatus, Direction_Input, GpioValue_Low },
{ DeviceCode_BattChgEnableN, Direction_Output, GpioValue_Low },
{ DeviceCode_FanTach, Direction_Input, GpioValue_High },
{ DeviceCode_Vdd50AEn, Direction_Output, GpioValue_Low },
{ DeviceCode_SdevCoaxSel1, Direction_Input, GpioValue_Low },
{ DeviceCode_ProdType0, Direction_Input, GpioValue_Low },
{ DeviceCode_ProdType1, Direction_Input, GpioValue_Low },
{ DeviceCode_ProdType2, Direction_Input, GpioValue_Low },
{ DeviceCode_ProdType3, Direction_Input, GpioValue_Low },
{ DeviceCode_TempAlert, Direction_Input, GpioValue_High },
{ DeviceCode_MotionInt, Direction_Input, GpioValue_Low },
{ DeviceCode_CodecHpDetIrq, Direction_Input, GpioValue_Low },
{ DeviceCode_TpIrq, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonSleep2, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonVolUp, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonVolDn, Direction_Input, GpioValue_High },
{ DeviceCode_BattMgicIrq, Direction_Input, GpioValue_High },
{ DeviceCode_RecoveryKey, Direction_Input, GpioValue_Low },
{ DeviceCode_PowLcdBlEn, Direction_Output, GpioValue_Low },
{ DeviceCode_LcdReset, Direction_Output, GpioValue_Low },
{ DeviceCode_PdRstN, Direction_Output, GpioValue_Low },
{ DeviceCode_Bq24190Irq, Direction_Input, GpioValue_High },
{ DeviceCode_SdCd, Direction_Input, GpioValue_High },
{ DeviceCode_SdevCoaxSel0, Direction_Input, GpioValue_Low },
{ DeviceCode_SdWp, Direction_Input, GpioValue_High },
{ DeviceCode_CodecLdoEnTemp, Direction_Output, GpioValue_Low },
{ DeviceCode_OtgFet1ForSdev, Direction_Output, GpioValue_Low },
{ DeviceCode_TpReset, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtconDetU, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio2, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio3, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio4, Direction_Input, GpioValue_Low },
{ DeviceCode_ExtconChgU, Direction_Output, GpioValue_Low },
{ DeviceCode_CradleIrq, Direction_Input, GpioValue_High },
{ DeviceCode_PdVconnEn, Direction_Output, GpioValue_Low },
{ DeviceCode_PowVcpuInt, Direction_Input, GpioValue_High },
{ DeviceCode_Max77621GpuInt, Direction_Input, GpioValue_High },
{ DeviceCode_OtgFet2ForSdev, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtconDetS, Direction_Input, GpioValue_Low },
{ DeviceCode_WifiRfDisable, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiReset, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiWakeHost, Direction_Input, GpioValue_Low },
{ DeviceCode_ApWakeBt, Direction_Output, GpioValue_Low },
{ DeviceCode_BtRst, Direction_Output, GpioValue_Low },
{ DeviceCode_BtWakeAp, Direction_Input, GpioValue_Low },
{ DeviceCode_ExtConWakeU, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio5, Direction_Output, GpioValue_Low },
{ DeviceCode_PowLcdVddPEn, Direction_Output, GpioValue_Low },
{ DeviceCode_PowLcdVddNEn, Direction_Output, GpioValue_Low },
{ DeviceCode_RamCode2, Direction_Input, GpioValue_High },
{ DeviceCode_ExtconChgS, Direction_Output, GpioValue_Low },
{ DeviceCode_Vdd50BEn, Direction_Output, GpioValue_Low },
};
constexpr inline size_t NumInitialGpioConfigsIcosa = util::size(InitialGpioConfigsIcosa);

View file

@ -0,0 +1,81 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by gpio_pad_gen.py, do not edit manually. */
constexpr inline const GpioInitialConfig InitialGpioConfigsIowa[] = {
{ DeviceCode_RamCode3, Direction_Input, GpioValue_High },
{ DeviceCode_GameCardReset, Direction_Output, GpioValue_Low },
{ DeviceCode_CodecAlert, Direction_Input, GpioValue_Low },
{ DeviceCode_PowSdEn, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtConWakeS, Direction_Input, GpioValue_Low },
{ DeviceCode_GameCardCd, Direction_Input, GpioValue_High },
{ DeviceCode_DebugControllerDet, Direction_Input, GpioValue_Low },
{ DeviceCode_BattChgStatus, Direction_Input, GpioValue_Low },
{ DeviceCode_BattChgEnableN, Direction_Output, GpioValue_Low },
{ DeviceCode_FanTach, Direction_Input, GpioValue_Low },
{ DeviceCode_Vdd50AEn, Direction_Output, GpioValue_Low },
{ DeviceCode_SdevCoaxSel1, Direction_Input, GpioValue_Low },
{ DeviceCode_ProdType0, Direction_Input, GpioValue_Low },
{ DeviceCode_ProdType1, Direction_Input, GpioValue_Low },
{ DeviceCode_ProdType2, Direction_Input, GpioValue_Low },
{ DeviceCode_ProdType3, Direction_Input, GpioValue_Low },
{ DeviceCode_Vdd5V3En, Direction_Output, GpioValue_Low },
{ DeviceCode_TempAlert, Direction_Input, GpioValue_High },
{ DeviceCode_MotionInt, Direction_Input, GpioValue_Low },
{ DeviceCode_CodecHpDetIrq, Direction_Input, GpioValue_Low },
{ DeviceCode_TpIrq, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonSleep2, Direction_Input, GpioValue_Low },
{ DeviceCode_ButtonVolUp, Direction_Input, GpioValue_High },
{ DeviceCode_ButtonVolDn, Direction_Input, GpioValue_High },
{ DeviceCode_BattMgicIrq, Direction_Input, GpioValue_Low },
{ DeviceCode_RecoveryKey, Direction_Input, GpioValue_Low },
{ DeviceCode_PowLcdBlEn, Direction_Output, GpioValue_Low },
{ DeviceCode_LcdReset, Direction_Output, GpioValue_Low },
{ DeviceCode_PdRstN, Direction_Output, GpioValue_Low },
{ DeviceCode_Bq24190Irq, Direction_Input, GpioValue_Low },
{ DeviceCode_SdCd, Direction_Input, GpioValue_High },
{ DeviceCode_SdevCoaxSel0, Direction_Input, GpioValue_Low },
{ DeviceCode_SdWp, Direction_Input, GpioValue_High },
{ DeviceCode_CodecLdoEnTemp, Direction_Output, GpioValue_Low },
{ DeviceCode_OtgFet1ForSdev, Direction_Output, GpioValue_Low },
{ DeviceCode_TpReset, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtconDetU, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio2, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio3, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio4, Direction_Input, GpioValue_Low },
{ DeviceCode_ExtconChgU, Direction_Output, GpioValue_Low },
{ DeviceCode_CradleIrq, Direction_Input, GpioValue_High },
{ DeviceCode_PdVconnEn, Direction_Output, GpioValue_Low },
{ DeviceCode_PowVcpuInt, Direction_Input, GpioValue_High },
{ DeviceCode_OtgFet2ForSdev, Direction_Output, GpioValue_Low },
{ DeviceCode_ExtconDetS, Direction_Input, GpioValue_Low },
{ DeviceCode_WifiRfDisable, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiReset, Direction_Output, GpioValue_Low },
{ DeviceCode_WifiWakeHost, Direction_Input, GpioValue_Low },
{ DeviceCode_ApWakeBt, Direction_Output, GpioValue_Low },
{ DeviceCode_BtRst, Direction_Output, GpioValue_Low },
{ DeviceCode_BtWakeAp, Direction_Input, GpioValue_Low },
{ DeviceCode_ExtConWakeU, Direction_Input, GpioValue_Low },
{ DeviceCode_BtGpio5, Direction_Output, GpioValue_Low },
{ DeviceCode_PowLcdVddPEn, Direction_Output, GpioValue_Low },
{ DeviceCode_PowLcdVddNEn, Direction_Output, GpioValue_Low },
{ DeviceCode_RamCode2, Direction_Input, GpioValue_High },
{ DeviceCode_ExtconChgS, Direction_Output, GpioValue_Low },
{ DeviceCode_Vdd50BEn, Direction_Output, GpioValue_Low },
};
constexpr inline size_t NumInitialGpioConfigsIowa = util::size(InitialGpioConfigsIowa);

View file

@ -0,0 +1,80 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by wake_pin_gen.py, do not edit manually. */
constexpr inline const WakePinConfig InitialWakePinConfigsCalcio[] = {
{ ams::wec::WakeEvent_PexWakeN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortA6, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_QspiCsN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Spi2Mosi, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ExtconDetS, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_McuIrq, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart2Cts, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart3Cts, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_WifiWakeAp, true, ams::wec::WakeEventLevel_High },
/* { ams::wec::WakeEvent_AoTag2Pmc, }, */
{ ams::wec::WakeEvent_ExtconDetU, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_NfcInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen1I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen2I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CradleIrq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_GpioPortK6, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_RtcIrq, }, */
{ ams::wec::WakeEvent_Sdmmc1Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc2Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_HdmiCec, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen3I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortL1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Clk_32kOut, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrI2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonPowerOn, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolUp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolDown, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonSlideSw, false, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_ButtonHome, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_AlsProxInt, }, */
{ ams::wec::WakeEvent_TempAlert, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Bq24190Irq, false, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_SdCd, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ2, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_Utmip0, }, */
/* { ams::wec::WakeEvent_Utmip1, }, */
/* { ams::wec::WakeEvent_Utmip2, }, */
/* { ams::wec::WakeEvent_Utmip3, }, */
/* { ams::wec::WakeEvent_Uhsic, }, */
/* { ams::wec::WakeEvent_Wake2PmcXusbSystem, }, */
{ ams::wec::WakeEvent_Sdmmc3Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc4Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cScl, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ5, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_DpHpd0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrIntN, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_BtWakeAp, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_HdmiIntDpHpd, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdRst, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdGpio1, false, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_LcdGpio2, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart4Cts, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ModemWakeAp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_TouchInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_MotionInt, false, ams::wec::WakeEventLevel_Auto },
};
constexpr inline size_t NumInitialWakePinConfigsCalcio = util::size(InitialWakePinConfigsCalcio);

View file

@ -0,0 +1,80 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by wake_pin_gen.py, do not edit manually. */
constexpr inline const WakePinConfig InitialWakePinConfigsFive[] = {
{ ams::wec::WakeEvent_PexWakeN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortA6, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_QspiCsN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Spi2Mosi, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ExtconDetS, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_McuIrq, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart2Cts, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart3Cts, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_WifiWakeAp, true, ams::wec::WakeEventLevel_High },
/* { ams::wec::WakeEvent_AoTag2Pmc, }, */
{ ams::wec::WakeEvent_ExtconDetU, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_NfcInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen1I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen2I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CradleIrq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_GpioPortK6, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_RtcIrq, }, */
{ ams::wec::WakeEvent_Sdmmc1Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc2Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_HdmiCec, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen3I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortL1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Clk_32kOut, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrI2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonPowerOn, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolUp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolDown, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonSlideSw, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_ButtonHome, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_AlsProxInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_TempAlert, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Bq24190Irq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_SdCd, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ2, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_Utmip0, }, */
/* { ams::wec::WakeEvent_Utmip1, }, */
/* { ams::wec::WakeEvent_Utmip2, }, */
/* { ams::wec::WakeEvent_Utmip3, }, */
/* { ams::wec::WakeEvent_Uhsic, }, */
/* { ams::wec::WakeEvent_Wake2PmcXusbSystem, }, */
{ ams::wec::WakeEvent_Sdmmc3Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc4Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cScl, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cSda, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ5, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_DpHpd0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrIntN, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_BtWakeAp, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_HdmiIntDpHpd, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdRst, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdGpio1, false, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_LcdGpio2, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart4Cts, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ModemWakeAp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_TouchInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_MotionInt, false, ams::wec::WakeEventLevel_Auto },
};
constexpr inline size_t NumInitialWakePinConfigsFive = util::size(InitialWakePinConfigsFive);

View file

@ -0,0 +1,80 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by wake_pin_gen.py, do not edit manually. */
constexpr inline const WakePinConfig InitialWakePinConfigsHoag[] = {
{ ams::wec::WakeEvent_PexWakeN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortA6, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_QspiCsN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Spi2Mosi, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ExtconDetS, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_McuIrq, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart2Cts, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart3Cts, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_WifiWakeAp, true, ams::wec::WakeEventLevel_High },
/* { ams::wec::WakeEvent_AoTag2Pmc, }, */
{ ams::wec::WakeEvent_ExtconDetU, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_NfcInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen1I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen2I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CradleIrq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_GpioPortK6, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_RtcIrq, }, */
{ ams::wec::WakeEvent_Sdmmc1Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc2Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_HdmiCec, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen3I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortL1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Clk_32kOut, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrI2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonPowerOn, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolUp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolDown, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonSlideSw, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_ButtonHome, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_AlsProxInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_TempAlert, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Bq24190Irq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_SdCd, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ2, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_Utmip0, }, */
/* { ams::wec::WakeEvent_Utmip1, }, */
/* { ams::wec::WakeEvent_Utmip2, }, */
/* { ams::wec::WakeEvent_Utmip3, }, */
/* { ams::wec::WakeEvent_Uhsic, }, */
/* { ams::wec::WakeEvent_Wake2PmcXusbSystem, }, */
{ ams::wec::WakeEvent_Sdmmc3Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc4Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cScl, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cSda, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ5, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_DpHpd0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrIntN, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_BtWakeAp, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_HdmiIntDpHpd, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdRst, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdGpio1, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_LcdGpio2, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart4Cts, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ModemWakeAp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_TouchInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_MotionInt, false, ams::wec::WakeEventLevel_Auto },
};
constexpr inline size_t NumInitialWakePinConfigsHoag = util::size(InitialWakePinConfigsHoag);

View file

@ -0,0 +1,80 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by wake_pin_gen.py, do not edit manually. */
constexpr inline const WakePinConfig InitialWakePinConfigsIcosa[] = {
{ ams::wec::WakeEvent_PexWakeN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortA6, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_QspiCsN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Spi2Mosi, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ExtconDetS, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_McuIrq, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart2Cts, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart3Cts, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_WifiWakeAp, true, ams::wec::WakeEventLevel_High },
/* { ams::wec::WakeEvent_AoTag2Pmc, }, */
{ ams::wec::WakeEvent_ExtconDetU, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_NfcInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen1I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen2I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CradleIrq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_GpioPortK6, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_RtcIrq, }, */
{ ams::wec::WakeEvent_Sdmmc1Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc2Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_HdmiCec, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen3I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortL1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Clk_32kOut, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrI2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonPowerOn, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolUp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolDown, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonSlideSw, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_ButtonHome, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_AlsProxInt, }, */
{ ams::wec::WakeEvent_TempAlert, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Bq24190Irq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_SdCd, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ2, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_Utmip0, }, */
/* { ams::wec::WakeEvent_Utmip1, }, */
/* { ams::wec::WakeEvent_Utmip2, }, */
/* { ams::wec::WakeEvent_Utmip3, }, */
/* { ams::wec::WakeEvent_Uhsic, }, */
/* { ams::wec::WakeEvent_Wake2PmcXusbSystem, }, */
{ ams::wec::WakeEvent_Sdmmc3Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc4Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cScl, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cSda, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ5, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_DpHpd0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrIntN, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_BtWakeAp, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_HdmiIntDpHpd, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdRst, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdGpio1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdGpio2, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart4Cts, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ModemWakeAp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_TouchInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_MotionInt, false, ams::wec::WakeEventLevel_Auto },
};
constexpr inline size_t NumInitialWakePinConfigsIcosa = util::size(InitialWakePinConfigsIcosa);

View file

@ -0,0 +1,80 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by wake_pin_gen.py, do not edit manually. */
constexpr inline const WakePinConfig InitialWakePinConfigsIowa[] = {
{ ams::wec::WakeEvent_PexWakeN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortA6, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_QspiCsN, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Spi2Mosi, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ExtconDetS, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_McuIrq, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart2Cts, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart3Cts, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_WifiWakeAp, true, ams::wec::WakeEventLevel_High },
/* { ams::wec::WakeEvent_AoTag2Pmc, }, */
{ ams::wec::WakeEvent_ExtconDetU, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_NfcInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen1I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen2I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CradleIrq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_GpioPortK6, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_RtcIrq, }, */
{ ams::wec::WakeEvent_Sdmmc1Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc2Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_HdmiCec, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Gen3I2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortL1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Clk_32kOut, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrI2cSda, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonPowerOn, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolUp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonVolDown, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ButtonSlideSw, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_ButtonHome, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_AlsProxInt, }, */
{ ams::wec::WakeEvent_TempAlert, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Bq24190Irq, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_SdCd, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ2, false, ams::wec::WakeEventLevel_Auto },
/* { ams::wec::WakeEvent_Utmip0, }, */
/* { ams::wec::WakeEvent_Utmip1, }, */
/* { ams::wec::WakeEvent_Utmip2, }, */
/* { ams::wec::WakeEvent_Utmip3, }, */
/* { ams::wec::WakeEvent_Uhsic, }, */
/* { ams::wec::WakeEvent_Wake2PmcXusbSystem, }, */
{ ams::wec::WakeEvent_Sdmmc3Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Sdmmc4Dat1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cScl, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_CamI2cSda, true, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_GpioPortZ5, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_DpHpd0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_PwrIntN, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_BtWakeAp, true, ams::wec::WakeEventLevel_Low },
{ ams::wec::WakeEvent_HdmiIntDpHpd, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn0, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_UsbVbusEn1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdRst, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdGpio1, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_LcdGpio2, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_Uart4Cts, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_ModemWakeAp, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_TouchInt, false, ams::wec::WakeEventLevel_Auto },
{ ams::wec::WakeEvent_MotionInt, false, ams::wec::WakeEventLevel_Auto },
};
constexpr inline size_t NumInitialWakePinConfigsIowa = util::size(InitialWakePinConfigsIowa);

View file

@ -0,0 +1,112 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by gpio_pad_gen.py, do not edit manually. */
constexpr inline const PadMapCombination PadMapCombinationList[] = {
{ DeviceCode_CodecLdoEnTemp, InternalGpioPadNumber_Port_Z_4, ams::wec::WakeEvent_None },
{ DeviceCode_PowSdEn, InternalGpioPadNumber_Port_E_4, ams::wec::WakeEvent_None },
{ DeviceCode_BtRst, InternalGpioPadNumber_Port_H_4, ams::wec::WakeEvent_None },
{ DeviceCode_RamCode3, InternalGpioPadNumber_Port_BB_2, ams::wec::WakeEvent_None },
{ DeviceCode_GameCardReset, InternalGpioPadNumber_Port_BB_3, ams::wec::WakeEvent_None },
{ DeviceCode_CodecAlert, InternalGpioPadNumber_Port_BB_4, ams::wec::WakeEvent_None },
{ DeviceCode_PowGc, InternalGpioPadNumber_Port_E_5, ams::wec::WakeEvent_None },
{ DeviceCode_DebugControllerDet, InternalGpioPadNumber_Port_S_0, ams::wec::WakeEvent_None },
{ DeviceCode_BattChgStatus, InternalGpioPadNumber_Port_S_1, ams::wec::WakeEvent_None },
{ DeviceCode_BattChgEnableN, InternalGpioPadNumber_Port_S_6, ams::wec::WakeEvent_None },
{ DeviceCode_FanTach, InternalGpioPadNumber_Port_S_7, ams::wec::WakeEvent_None },
{ DeviceCode_Vdd50AEn, InternalGpioPadNumber_Port_A_5, ams::wec::WakeEvent_None },
{ DeviceCode_SdevCoaxSel1, InternalGpioPadNumber_Port_P_0, ams::wec::WakeEvent_None },
{ DeviceCode_ProdType0, InternalGpioPadNumber_Port_P_5, ams::wec::WakeEvent_None },
{ DeviceCode_ProdType1, InternalGpioPadNumber_Port_P_4, ams::wec::WakeEvent_None },
{ DeviceCode_ProdType2, InternalGpioPadNumber_Port_P_3, ams::wec::WakeEvent_None },
{ DeviceCode_ProdType3, InternalGpioPadNumber_Port_P_2, ams::wec::WakeEvent_None },
{ DeviceCode_TempAlert, InternalGpioPadNumber_Port_X_4, ams::wec::WakeEvent_None },
{ DeviceCode_CodecHpDetIrq, InternalGpioPadNumber_Port_V_6, ams::wec::WakeEvent_None },
{ DeviceCode_MotionInt, InternalGpioPadNumber_Port_X_2, ams::wec::WakeEvent_None },
{ DeviceCode_TpIrq, InternalGpioPadNumber_Port_X_1, ams::wec::WakeEvent_None },
{ DeviceCode_ButtonSleep2, InternalGpioPadNumber_Port_X_5, ams::wec::WakeEvent_None },
{ DeviceCode_ButtonVolUp, InternalGpioPadNumber_Port_X_6, ams::wec::WakeEvent_None },
{ DeviceCode_ButtonVolDn, InternalGpioPadNumber_Port_X_7, ams::wec::WakeEvent_None },
{ DeviceCode_RecoveryKey, InternalGpioPadNumber_Port_Y_1, ams::wec::WakeEvent_None },
{ DeviceCode_PowLcdBlEn, InternalGpioPadNumber_Port_V_1, ams::wec::WakeEvent_None },
{ DeviceCode_LcdReset, InternalGpioPadNumber_Port_V_2, ams::wec::WakeEvent_None },
{ DeviceCode_PdVconnEn, InternalGpioPadNumber_Port_K_5, ams::wec::WakeEvent_None },
{ DeviceCode_PdRstN, InternalGpioPadNumber_Port_V_5, ams::wec::WakeEvent_None },
{ DeviceCode_SdevCoaxSel0, InternalGpioPadNumber_Port_Z_2, ams::wec::WakeEvent_None },
{ DeviceCode_SdWp, InternalGpioPadNumber_Port_Z_3, ams::wec::WakeEvent_None },
{ DeviceCode_TpReset, InternalGpioPadNumber_Port_J_7, ams::wec::WakeEvent_None },
{ DeviceCode_BtGpio2, InternalGpioPadNumber_Port_K_0, ams::wec::WakeEvent_None },
{ DeviceCode_BtGpio3, InternalGpioPadNumber_Port_K_1, ams::wec::WakeEvent_None },
{ DeviceCode_BtGpio4, InternalGpioPadNumber_Port_K_2, ams::wec::WakeEvent_None },
{ DeviceCode_PowVcpuInt, InternalGpioPadNumber_Port_K_6, ams::wec::WakeEvent_None },
{ DeviceCode_Max77621GpuInt, InternalGpioPadNumber_Port_K_7, ams::wec::WakeEvent_None },
{ DeviceCode_ExtconChgU, InternalGpioPadNumber_Port_K_3, ams::wec::WakeEvent_None },
{ DeviceCode_ExtconChgS, InternalGpioPadNumber_Port_CC_3, ams::wec::WakeEvent_None },
{ DeviceCode_WifiRfDisable, InternalGpioPadNumber_Port_H_0, ams::wec::WakeEvent_None },
{ DeviceCode_WifiReset, InternalGpioPadNumber_Port_H_1, ams::wec::WakeEvent_None },
{ DeviceCode_ApWakeBt, InternalGpioPadNumber_Port_H_3, ams::wec::WakeEvent_None },
{ DeviceCode_BtGpio5, InternalGpioPadNumber_Port_H_7, ams::wec::WakeEvent_None },
{ DeviceCode_PowLcdVddPEn, InternalGpioPadNumber_Port_I_0, ams::wec::WakeEvent_None },
{ DeviceCode_PowLcdVddNEn, InternalGpioPadNumber_Port_I_1, ams::wec::WakeEvent_None },
{ DeviceCode_RamCode2, InternalGpioPadNumber_Port_CC_2, ams::wec::WakeEvent_None },
{ DeviceCode_Vdd50BEn, InternalGpioPadNumber_Port_CC_4, ams::wec::WakeEvent_None },
{ DeviceCode_OtgFet1ForSdev, InternalGpioPadNumber_Port_J_5, ams::wec::WakeEvent_None },
{ DeviceCode_OtgFet2ForSdev, InternalGpioPadNumber_Port_L_0, ams::wec::WakeEvent_None },
{ DeviceCode_ExtConWakeU, InternalGpioPadNumber_Port_H_6, ams::wec::WakeEvent_None },
{ DeviceCode_ExtConWakeS, InternalGpioPadNumber_Port_E_6, ams::wec::WakeEvent_None },
{ DeviceCode_ExtUart2Rts, InternalGpioPadNumber_Port_G_2, ams::wec::WakeEvent_None },
{ DeviceCode_ExtUart3Rts, InternalGpioPadNumber_Port_D_3, ams::wec::WakeEvent_None },
{ DeviceCode_Debug0, InternalGpioPadNumber_Port_E_0, ams::wec::WakeEvent_None },
{ DeviceCode_Debug1, InternalGpioPadNumber_Port_E_1, ams::wec::WakeEvent_None },
{ DeviceCode_Debug2, InternalGpioPadNumber_Port_E_2, ams::wec::WakeEvent_None },
{ DeviceCode_Debug3, InternalGpioPadNumber_Port_E_3, ams::wec::WakeEvent_None },
{ DeviceCode_NfcIrq, InternalGpioPadNumber_Port_J_4, ams::wec::WakeEvent_None },
{ DeviceCode_NfcRst, InternalGpioPadNumber_Port_K_7, ams::wec::WakeEvent_None },
{ DeviceCode_McuIrq, InternalGpioPadNumber_Port_E_7, ams::wec::WakeEvent_McuIrq },
{ DeviceCode_McuBoot, InternalGpioPadNumber_Port_T_0, ams::wec::WakeEvent_None },
{ DeviceCode_McuRst, InternalGpioPadNumber_Port_T_1, ams::wec::WakeEvent_None },
{ DeviceCode_Vdd5V3En, InternalGpioPadNumber_Port_X_3, ams::wec::WakeEvent_None },
{ DeviceCode_McuPor, InternalGpioPadNumber_Port_CC_5, ams::wec::WakeEvent_None },
{ DeviceCode_NfcEn, InternalGpioPadNumber_Port_J_6, ams::wec::WakeEvent_None },
{ DeviceCode_GpioPortC7, InternalGpioPadNumber_Port_C_7, ams::wec::WakeEvent_None },
{ DeviceCode_GpioPortD0, InternalGpioPadNumber_Port_D_0, ams::wec::WakeEvent_None },
{ DeviceCode_GpioPortC5, InternalGpioPadNumber_Port_C_5, ams::wec::WakeEvent_None },
{ DeviceCode_GpioPortC6, InternalGpioPadNumber_Port_C_6, ams::wec::WakeEvent_None },
{ DeviceCode_GpioPortY7, InternalGpioPadNumber_Port_Y_5, ams::wec::WakeEvent_None },
{ DeviceCode_Hdmi5VEn, InternalGpioPadNumber_Port_C_0, ams::wec::WakeEvent_None },
{ DeviceCode_UsbSwitchB1En, InternalGpioPadNumber_Port_C_1, ams::wec::WakeEvent_None },
{ DeviceCode_HdmiPdTrEn, InternalGpioPadNumber_Port_C_2, ams::wec::WakeEvent_None },
{ DeviceCode_UsbSwitchB1Oc, InternalGpioPadNumber_Port_CC_6, ams::wec::WakeEvent_None },
{ DeviceCode_HdmiHpd, InternalGpioPadNumber_Port_CC_1, ams::wec::WakeEvent_None },
{ DeviceCode_GpioPortF1, InternalGpioPadNumber_Port_F_1, ams::wec::WakeEvent_None },
{ DeviceCode_GpioPortH0, InternalGpioPadNumber_Port_H_0, ams::wec::WakeEvent_None },
{ DeviceCode_ExtconDetS, InternalGpioPadNumber_Port_E_6, ams::wec::WakeEvent_ExtconDetS },
{ DeviceCode_GameCardCd, InternalGpioPadNumber_Port_S_3, ams::wec::WakeEvent_CamI2cSda },
{ DeviceCode_BattMgicIrq, InternalGpioPadNumber_Port_Y_0, ams::wec::WakeEvent_ButtonSlideSw },
{ DeviceCode_Bq24190Irq, InternalGpioPadNumber_Port_Z_0, ams::wec::WakeEvent_Bq24190Irq },
{ DeviceCode_CradleIrq, InternalGpioPadNumber_Port_K_4, ams::wec::WakeEvent_CradleIrq },
{ DeviceCode_BtWakeAp, InternalGpioPadNumber_Port_H_5, ams::wec::WakeEvent_BtWakeAp },
{ DeviceCode_ExtconDetU, InternalGpioPadNumber_Port_H_6, ams::wec::WakeEvent_ExtconDetU },
{ DeviceCode_WifiWakeHost, InternalGpioPadNumber_Port_H_2, ams::wec::WakeEvent_WifiWakeAp },
{ DeviceCode_SdCd, InternalGpioPadNumber_Port_Z_1, ams::wec::WakeEvent_SdCd },
{ DeviceCode_ExtUart2Cts, InternalGpioPadNumber_Port_G_3, ams::wec::WakeEvent_Uart2Cts },
{ DeviceCode_ExtUart3Cts, InternalGpioPadNumber_Port_D_4, ams::wec::WakeEvent_Uart3Cts },
{ DeviceCode_LcdGpio1, InternalGpioPadNumber_Port_V_3, ams::wec::WakeEvent_LcdGpio1 },
{ DeviceCode_PmuIrq, InternalGpioPadNumber_None, ams::wec::WakeEvent_PwrIntN },
};
constexpr inline size_t PadMapCombinationListSize = util::size(PadMapCombinationList);

View file

@ -0,0 +1,135 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "gpio_tegra_pad.hpp"
namespace ams::gpio::driver::board::nintendo_nx::impl {
constexpr inline dd::PhysicalAddress GpioRegistersPhysicalAddress = 0x6000D000;
constexpr inline size_t GpioRegistersSize = 4_KB;
constexpr inline int GpioPerControllerBitWidth = 5;
constexpr inline int GpioControllerBitWidth = 3;
constexpr inline int PortPerControllerBitWidth = 2;
constexpr inline int PortPerController = (1 << PortPerControllerBitWidth);
constexpr inline int GpioPerPortBitWidth = 3;
constexpr inline int GpioPerPort = (1 << GpioPerPortBitWidth);
static_assert(PortPerControllerBitWidth + GpioPerPortBitWidth == GpioPerControllerBitWidth);
static_assert(PortPerController * GpioPerPort == (1 << GpioPerControllerBitWidth));
constexpr int ConvertInternalGpioPadNumberToController(InternalGpioPadNumber number) {
return (number >> GpioPerControllerBitWidth);
}
constexpr int ConvertInternalGpioPadNumberToPort(InternalGpioPadNumber number) {
return (number >> GpioControllerBitWidth);
}
constexpr InternalGpioPadNumber ConvertPortToInternalGpioPadNumber(int port) {
return static_cast<InternalGpioPadNumber>(port << GpioControllerBitWidth);
}
constexpr int ConvertInternalGpioPadNumberToBitIndex(InternalGpioPadNumber number) {
return (number & (GpioPerPort - 1));
}
constexpr int ConvertPortNumberToOffset(int port_number) {
return (port_number & (PortPerController - 1));
}
enum GpioController {
GpioController_1 = 0,
GpioController_2 = 1,
GpioController_3 = 2,
GpioController_4 = 3,
GpioController_5 = 4,
GpioController_6 = 5,
GpioController_7 = 6,
GpioController_8 = 7,
GpioController_Count = 8,
};
static_assert(GpioController_Count == static_cast<GpioController>(1 << GpioControllerBitWidth));
constexpr inline os::InterruptName InterruptNameTable[GpioController_Count] = {
64, /* GpioController_1 */
65, /* GpioController_2 */
66, /* GpioController_3 */
67, /* GpioController_4 */
87, /* GpioController_5 */
119, /* GpioController_6 */
121, /* GpioController_7 */
157, /* GpioController_8 */
};
enum InternalInterruptMode {
InternalInterruptMode_LowLevel = 0x000000,
InternalInterruptMode_HighLevel = 0x000001,
InternalInterruptMode_RisingEdge = 0x000101,
InternalInterruptMode_FallingEdge = 0x000100,
InternalInterruptMode_AnyEdge = 0x010100,
InternalInterruptMode_Mask = 0x010101,
};
enum GpioRegisterType {
GpioRegisterType_GPIO_CNF = 0,
GpioRegisterType_GPIO_OE = 1,
GpioRegisterType_GPIO_OUT = 2,
GpioRegisterType_GPIO_IN = 3,
GpioRegisterType_GPIO_INT_STA = 4,
GpioRegisterType_GPIO_INT_ENB = 5,
GpioRegisterType_GPIO_INT_LVL = 6,
GpioRegisterType_GPIO_INT_CLR = 7,
GpioRegisterType_GPIO_DB_CTRL = 8,
GpioRegisterType_GPIO_DB_CNT = 9,
};
constexpr inline uintptr_t MaskedWriteAddressOffset = 0x80;
constexpr inline int MaskedWriteBitOffset = 8;
constexpr inline uintptr_t GetGpioRegisterAddress(uintptr_t gpio_address, GpioRegisterType reg_type, InternalGpioPadNumber pad_number) {
const auto controller = ConvertInternalGpioPadNumberToController(pad_number);
const auto port = ConvertInternalGpioPadNumberToPort(pad_number);
const auto offset = ConvertPortNumberToOffset(port);
switch (reg_type) {
default:
return gpio_address + (0x100 * controller) + (0x10 * reg_type) + (0x4 * offset);
case GpioRegisterType_GPIO_DB_CTRL:
return gpio_address + (0x100 * controller) + (0x10 * GpioRegisterType_GPIO_IN) + (0x4 * offset);
case GpioRegisterType_GPIO_DB_CNT:
return gpio_address + (0x100 * controller) + MaskedWriteAddressOffset + (0x10 * GpioRegisterType_GPIO_INT_CLR) + (0x4 * offset);
}
}
inline void SetMaskedBit(uintptr_t pad_address, int index, int value) {
const uintptr_t mask_address = pad_address + MaskedWriteAddressOffset;
reg::Write(mask_address, (1u << (MaskedWriteBitOffset + index)) | (static_cast<unsigned int>(value) << index));
}
inline void SetMaskedBits(uintptr_t pad_address, unsigned int mask, unsigned int value) {
const uintptr_t mask_address = pad_address + MaskedWriteAddressOffset;
reg::Write(mask_address, (mask << MaskedWriteBitOffset) | (value));
}
}

View file

@ -0,0 +1,69 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "gpio_suspend_handler.hpp"
namespace ams::gpio::driver::board::nintendo_nx::impl {
void SuspendHandler::Initialize(uintptr_t gpio_vaddr) {
/* Set our gpio virtual address. */
this->gpio_virtual_address = gpio_vaddr;
/* Ensure that we can use the wec library. */
ams::wec::Initialize();
}
void SuspendHandler::SetValueForSleepState(TegraPad *pad, GpioValue value) {
/* TODO */
AMS_ABORT();
}
Result SuspendHandler::IsWakeEventActive(bool *out, TegraPad *pad) const {
/* TODO */
AMS_ABORT();
}
Result SuspendHandler::SetWakeEventActiveFlagSetForDebug(TegraPad *pad, bool en) {
/* TODO */
AMS_ABORT();
}
void SuspendHandler::SetWakePinDebugMode(WakePinDebugMode mode) {
/* TODO */
AMS_ABORT();
}
void SuspendHandler::Suspend() {
/* TODO */
AMS_ABORT();
}
void SuspendHandler::SuspendLow() {
/* TODO */
AMS_ABORT();
}
void SuspendHandler::Resume() {
/* TODO */
AMS_ABORT();
}
void SuspendHandler::ResumeLow() {
/* TODO */
AMS_ABORT();
}
}

View file

@ -0,0 +1,89 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
#include "gpio_tegra_pad.hpp"
namespace ams::gpio::driver::board::nintendo_nx::impl {
class SuspendHandler {
NON_COPYABLE(SuspendHandler);
NON_MOVEABLE(SuspendHandler);
private:
struct RegisterValues {
u16 conf;
u8 oe;
u8 out;
u8 int_enb;
u32 int_lvl;
u8 db_ctrl;
u8 db_cnt;
void Reset() {
this->conf = 0;
this->oe = 0;
this->out = 0;
this->int_enb = 0;
this->int_lvl = 0;
this->db_ctrl = 0;
this->db_cnt = 0;
}
};
struct ValuesForSleepState {
u8 force_set;
u8 out;
void Reset() {
this->force_set = 0;
this->out = 0;
}
};
private:
ddsf::IDriver &driver;
uintptr_t gpio_virtual_address;
RegisterValues register_values[GpioPadPort_Count];
ValuesForSleepState values_for_sleep_state[GpioPadPort_Count];
private:
uintptr_t GetGpioVirtualAddress() const {
AMS_ASSERT(this->gpio_virtual_address != 0);
return this->gpio_virtual_address;
}
public:
explicit SuspendHandler(ddsf::IDriver *drv) : driver(*drv), gpio_virtual_address(0) {
for (auto &rv : this->register_values) {
rv.Reset();
}
for (auto &v : this->values_for_sleep_state) {
v.Reset();
}
}
void Initialize(uintptr_t gpio_vaddr);
void SetValueForSleepState(TegraPad *pad, GpioValue value);
Result IsWakeEventActive(bool *out, TegraPad *pad) const;
Result SetWakeEventActiveFlagSetForDebug(TegraPad *pad, bool en);
void SetWakePinDebugMode(WakePinDebugMode mode);
void Suspend();
void SuspendLow();
void Resume();
void ResumeLow();
};
}

View file

@ -0,0 +1,377 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::gpio::driver::board::nintendo_nx::impl {
enum GpioPadPort {
GpioPadPort_A = 0,
GpioPadPort_B = 1,
GpioPadPort_C = 2,
GpioPadPort_D = 3,
GpioPadPort_E = 4,
GpioPadPort_F = 5,
GpioPadPort_G = 6,
GpioPadPort_H = 7,
GpioPadPort_I = 8,
GpioPadPort_J = 9,
GpioPadPort_K = 10,
GpioPadPort_L = 11,
GpioPadPort_M = 12,
GpioPadPort_N = 13,
GpioPadPort_O = 14,
GpioPadPort_P = 15,
GpioPadPort_Q = 16,
GpioPadPort_R = 17,
GpioPadPort_S = 18,
GpioPadPort_T = 19,
GpioPadPort_U = 20,
GpioPadPort_V = 21,
GpioPadPort_W = 22,
GpioPadPort_X = 23,
GpioPadPort_Y = 24,
GpioPadPort_Z = 25,
GpioPadPort_AA = 26,
GpioPadPort_BB = 27,
GpioPadPort_CC = 28,
GpioPadPort_DD = 29,
GpioPadPort_EE = 30,
GpioPadPort_FF = 31,
GpioPadPort_Count = 32,
};
using InternalGpioPadNumber = int;
constexpr unsigned int GetInternalGpioPadNumber(GpioPadPort port, unsigned int which) {
AMS_ASSERT(which < 8);
return (static_cast<unsigned int>(port) * 8) + which;
}
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_None = -1;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_0 = 0x00;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_1 = 0x01;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_2 = 0x02;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_3 = 0x03;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_4 = 0x04;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_5 = 0x05;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_6 = 0x06;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_A_7 = 0x07;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_0 = 0x08;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_1 = 0x09;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_2 = 0x0A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_3 = 0x0B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_4 = 0x0C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_5 = 0x0D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_6 = 0x0E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_B_7 = 0x0F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_0 = 0x10;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_1 = 0x11;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_2 = 0x12;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_3 = 0x13;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_4 = 0x14;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_5 = 0x15;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_6 = 0x16;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_C_7 = 0x17;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_0 = 0x18;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_1 = 0x19;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_2 = 0x1A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_3 = 0x1B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_4 = 0x1C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_5 = 0x1D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_6 = 0x1E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_D_7 = 0x1F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_0 = 0x20;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_1 = 0x21;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_2 = 0x22;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_3 = 0x23;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_4 = 0x24;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_5 = 0x25;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_6 = 0x26;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_E_7 = 0x27;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_0 = 0x28;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_1 = 0x29;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_2 = 0x2A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_3 = 0x2B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_4 = 0x2C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_5 = 0x2D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_6 = 0x2E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_F_7 = 0x2F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_0 = 0x30;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_1 = 0x31;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_2 = 0x32;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_3 = 0x33;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_4 = 0x34;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_5 = 0x35;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_6 = 0x36;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_G_7 = 0x37;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_0 = 0x38;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_1 = 0x39;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_2 = 0x3A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_3 = 0x3B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_4 = 0x3C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_5 = 0x3D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_6 = 0x3E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_H_7 = 0x3F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_0 = 0x40;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_1 = 0x41;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_2 = 0x42;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_3 = 0x43;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_4 = 0x44;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_5 = 0x45;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_6 = 0x46;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_I_7 = 0x47;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_0 = 0x48;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_1 = 0x49;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_2 = 0x4A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_3 = 0x4B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_4 = 0x4C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_5 = 0x4D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_6 = 0x4E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_J_7 = 0x4F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_0 = 0x50;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_1 = 0x51;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_2 = 0x52;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_3 = 0x53;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_4 = 0x54;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_5 = 0x55;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_6 = 0x56;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_K_7 = 0x57;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_0 = 0x58;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_1 = 0x59;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_2 = 0x5A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_3 = 0x5B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_4 = 0x5C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_5 = 0x5D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_6 = 0x5E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_L_7 = 0x5F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_0 = 0x60;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_1 = 0x61;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_2 = 0x62;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_3 = 0x63;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_4 = 0x64;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_5 = 0x65;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_6 = 0x66;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_M_7 = 0x67;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_0 = 0x68;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_1 = 0x69;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_2 = 0x6A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_3 = 0x6B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_4 = 0x6C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_5 = 0x6D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_6 = 0x6E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_N_7 = 0x6F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_0 = 0x70;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_1 = 0x71;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_2 = 0x72;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_3 = 0x73;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_4 = 0x74;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_5 = 0x75;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_6 = 0x76;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_O_7 = 0x77;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_0 = 0x78;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_1 = 0x79;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_2 = 0x7A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_3 = 0x7B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_4 = 0x7C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_5 = 0x7D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_6 = 0x7E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_P_7 = 0x7F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_0 = 0x80;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_1 = 0x81;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_2 = 0x82;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_3 = 0x83;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_4 = 0x84;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_5 = 0x85;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_6 = 0x86;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Q_7 = 0x87;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_0 = 0x88;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_1 = 0x89;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_2 = 0x8A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_3 = 0x8B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_4 = 0x8C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_5 = 0x8D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_6 = 0x8E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_R_7 = 0x8F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_0 = 0x90;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_1 = 0x91;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_2 = 0x92;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_3 = 0x93;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_4 = 0x94;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_5 = 0x95;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_6 = 0x96;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_S_7 = 0x97;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_0 = 0x98;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_1 = 0x99;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_2 = 0x9A;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_3 = 0x9B;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_4 = 0x9C;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_5 = 0x9D;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_6 = 0x9E;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_T_7 = 0x9F;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_0 = 0xA0;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_1 = 0xA1;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_2 = 0xA2;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_3 = 0xA3;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_4 = 0xA4;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_5 = 0xA5;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_6 = 0xA6;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_U_7 = 0xA7;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_0 = 0xA8;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_1 = 0xA9;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_2 = 0xAA;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_3 = 0xAB;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_4 = 0xAC;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_5 = 0xAD;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_6 = 0xAE;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_V_7 = 0xAF;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_0 = 0xB0;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_1 = 0xB1;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_2 = 0xB2;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_3 = 0xB3;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_4 = 0xB4;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_5 = 0xB5;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_6 = 0xB6;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_W_7 = 0xB7;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_0 = 0xB8;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_1 = 0xB9;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_2 = 0xBA;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_3 = 0xBB;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_4 = 0xBC;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_5 = 0xBD;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_6 = 0xBE;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_X_7 = 0xBF;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_0 = 0xC0;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_1 = 0xC1;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_2 = 0xC2;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_3 = 0xC3;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_4 = 0xC4;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_5 = 0xC5;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_6 = 0xC6;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Y_7 = 0xC7;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_0 = 0xC8;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_1 = 0xC9;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_2 = 0xCA;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_3 = 0xCB;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_4 = 0xCC;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_5 = 0xCD;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_6 = 0xCE;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_Z_7 = 0xCF;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_0 = 0xD0;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_1 = 0xD1;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_2 = 0xD2;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_3 = 0xD3;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_4 = 0xD4;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_5 = 0xD5;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_6 = 0xD6;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_AA_7 = 0xD7;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_0 = 0xD8;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_1 = 0xD9;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_2 = 0xDA;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_3 = 0xDB;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_4 = 0xDC;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_5 = 0xDD;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_6 = 0xDE;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_BB_7 = 0xDF;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_0 = 0xE0;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_1 = 0xE1;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_2 = 0xE2;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_3 = 0xE3;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_4 = 0xE4;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_5 = 0xE5;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_6 = 0xE6;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_CC_7 = 0xE7;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_0 = 0xE8;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_1 = 0xE9;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_2 = 0xEA;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_3 = 0xEB;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_4 = 0xEC;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_5 = 0xED;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_6 = 0xEE;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_DD_7 = 0xEF;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_0 = 0xF0;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_1 = 0xF1;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_2 = 0xF2;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_3 = 0xF3;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_4 = 0xF4;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_5 = 0xF5;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_6 = 0xF6;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_EE_7 = 0xF7;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_0 = 0xF8;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_1 = 0xF9;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_2 = 0xFA;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_3 = 0xFB;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_4 = 0xFC;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_5 = 0xFD;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_6 = 0xFE;
constexpr inline InternalGpioPadNumber InternalGpioPadNumber_Port_FF_7 = 0xFF;
struct PadMapCombination {
DeviceCode device_code;
InternalGpioPadNumber internal_number;
wec::WakeEvent wake_event;
};
#include "gpio_internal_pad_map_combination.inc"
struct PadInfo {
wec::WakeEvent wake_event;
constexpr PadInfo() : wake_event(wec::WakeEvent_None) { /* ... */ }
constexpr explicit PadInfo(wec::WakeEvent we) : wake_event(we) { /* ... */ }
constexpr bool operator ==(const PadInfo &rhs) const { return this->wake_event == rhs.wake_event; }
constexpr bool operator !=(const PadInfo &rhs) const { return !(*this == rhs); }
};
struct PadStatus {
bool is_wake_active;
bool is_wake_active_debug;
constexpr PadStatus() : is_wake_active(false), is_wake_active_debug(false) { /* ... */ }
};
class TegraPad : public ::ams::gpio::driver::Pad {
AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::board::nintendo_nx::impl::TegraPad, ::ams::gpio::driver::Pad);
private:
using Base = ::ams::gpio::driver::Pad;
private:
util::IntrusiveListNode interrupt_list_node;
PadInfo info;
PadStatus status;
public:
using InterruptListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&TegraPad::interrupt_list_node>;
using InterruptList = typename InterruptListTraits::ListType;
friend class util::IntrusiveList<TegraPad, util::IntrusiveListMemberTraitsDeferredAssert<&TegraPad::interrupt_list_node>>;
public:
TegraPad() : Pad(), interrupt_list_node(), info(), status() { /* ... */ }
const PadInfo &GetInfo() const { return this->info; }
PadStatus &GetStatus() { return this->status; }
void SetParameters(int pad, const PadInfo &i) {
Base::SetPadNumber(pad);
this->info = info;
}
bool IsLinkedToInterruptBoundPadList() const {
return this->interrupt_list_node.IsLinked();
}
};
}

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::gpio::driver::board::nintendo_nx::impl {
struct WakePinConfig {
wec::WakeEvent wake_event;
bool enable;
wec::WakeEventLevel level;
};
}

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "impl/gpio_driver_core.hpp"
namespace ams::gpio::driver {
void Initialize() {
return impl::InitializeDrivers();
}
void Finalize() {
return impl::FinalizeDrivers();
}
}

View file

@ -0,0 +1,54 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "impl/gpio_driver_core.hpp"
namespace ams::gpio::driver {
void RegisterDriver(IGpioDriver *driver) {
return impl::RegisterDriver(driver);
}
void UnregisterDriver(IGpioDriver *driver) {
return impl::UnregisterDriver(driver);
}
Result RegisterDeviceCode(DeviceCode device_code, Pad *pad) {
return impl::RegisterDeviceCode(device_code, pad);
}
bool UnregisterDeviceCode(DeviceCode device_code) {
return impl::UnregisterDeviceCode(device_code);
}
void RegisterInterruptHandler(ddsf::IEventHandler *handler) {
return impl::RegisterInterruptHandler(handler);
}
void UnregisterInterruptHandler(ddsf::IEventHandler *handler) {
return impl::UnregisterInterruptHandler(handler);
}
void SetInitialGpioConfig() {
return board::SetInitialGpioConfig();
}
void SetInitialWakePinConfig() {
return board::SetInitialWakePinConfig();
}
}

View file

@ -0,0 +1,149 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stratosphere.hpp>
#include "gpio_driver_core.hpp"
namespace ams::gpio::driver::impl {
namespace {
os::ThreadType g_interrupt_thread;
constexpr inline size_t InterruptThreadStackSize = os::MemoryPageSize;
alignas(os::MemoryPageSize) u8 g_interrupt_thread_stack[InterruptThreadStackSize];
gpio::driver::IGpioDriver::List &GetGpioDriverList() {
static gpio::driver::IGpioDriver::List s_gpio_driver_list;
return s_gpio_driver_list;
}
ddsf::EventHandlerManager &GetInterruptHandlerManager() {
static ddsf::EventHandlerManager s_interrupt_handler_manager;
return s_interrupt_handler_manager;
}
ddsf::DeviceCodeEntryManager &GetDeviceCodeEntryManager() {
static ddsf::DeviceCodeEntryManager s_device_code_entry_manager(ddsf::GetDeviceCodeEntryHolderMemoryResource());
return s_device_code_entry_manager;
}
void InterruptThreadFunction(void *arg) {
AMS_UNUSED(arg);
GetInterruptHandlerManager().LoopAuto();
}
}
void InitializeDrivers() {
/* Ensure the event handler manager is initialized. */
GetInterruptHandlerManager().Initialize();
/* Initialize all registered drivers. */
for (auto &driver : GetGpioDriverList()) {
driver.SafeCastTo<IGpioDriver>().InitializeDriver();
}
/* Create the interrupt thread. */
R_ABORT_UNLESS(os::CreateThread(std::addressof(g_interrupt_thread), InterruptThreadFunction, nullptr, g_interrupt_thread_stack, InterruptThreadStackSize, AMS_GET_SYSTEM_THREAD_PRIORITY(gpio, InterruptHandler)));
os::SetThreadNamePointer(std::addressof(g_interrupt_thread), AMS_GET_SYSTEM_THREAD_NAME(gpio, InterruptHandler));
os::StartThread(std::addressof(g_interrupt_thread));
/* Wait for the interrupt thread to enter the loop. */
GetInterruptHandlerManager().WaitLoopEnter();
}
void FinalizeDrivers() {
/* Request the interrupt thread stop. */
GetInterruptHandlerManager().RequestStop();
os::WaitThread(std::addressof(g_interrupt_thread));
os::DestroyThread(std::addressof(g_interrupt_thread));
/* TODO: What else? */
AMS_ABORT();
}
void RegisterDriver(IGpioDriver *driver) {
AMS_ASSERT(driver != nullptr);
GetGpioDriverList().push_back(*driver);
}
void UnregisterDriver(IGpioDriver *driver) {
AMS_ASSERT(driver != nullptr);
if (driver->IsLinkedToList()) {
auto &list = GetGpioDriverList();
list.erase(list.iterator_to(*driver));
}
}
Result RegisterDeviceCode(DeviceCode device_code, Pad *pad) {
AMS_ASSERT(pad != nullptr);
R_TRY(GetDeviceCodeEntryManager().Add(device_code, pad));
return ResultSuccess();
}
bool UnregisterDeviceCode(DeviceCode device_code) {
return GetDeviceCodeEntryManager().Remove(device_code);
}
void RegisterInterruptHandler(ddsf::IEventHandler *handler) {
AMS_ASSERT(handler != nullptr);
GetInterruptHandlerManager().RegisterHandler(handler);
}
void UnregisterInterruptHandler(ddsf::IEventHandler *handler) {
AMS_ASSERT(handler != nullptr);
GetInterruptHandlerManager().UnregisterHandler(handler);
}
Result FindPad(Pad **out, DeviceCode device_code) {
/* Validate output. */
AMS_ASSERT(out != nullptr);
/* Find the device. */
ddsf::IDevice *device;
R_TRY(GetDeviceCodeEntryManager().FindDevice(std::addressof(device), device_code));
/* Set output. */
*out = device->SafeCastToPointer<Pad>();
return ResultSuccess();
}
Result FindPadByNumber(Pad **out, int pad_number) {
/* Validate output. */
AMS_ASSERT(out != nullptr);
/* Find the pad. */
bool found = false;
GetDeviceCodeEntryManager().ForEachEntry([&](ddsf::DeviceCodeEntry &entry) -> bool {
/* Convert the entry to a pad. */
auto &pad = entry.GetDevice().SafeCastTo<Pad>();
/* Check if the pad is the one we're looking for. */
if (pad.GetPadNumber() == pad_number) {
found = true;
*out = std::addressof(pad);
return false;
}
return true;
});
/* Check that we found the pad. */
R_UNLESS(found, ddsf::ResultDeviceCodeNotFound());
return ResultSuccess();
}
}

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stratosphere.hpp>
namespace ams::gpio::driver::impl {
void InitializeDrivers();
void FinalizeDrivers();
void RegisterDriver(IGpioDriver *driver);
void UnregisterDriver(IGpioDriver *driver);
Result RegisterDeviceCode(DeviceCode device_code, Pad *pad);
bool UnregisterDeviceCode(DeviceCode device_code);
void RegisterInterruptHandler(ddsf::IEventHandler *handler);
void UnregisterInterruptHandler(ddsf::IEventHandler *handler);
Result FindPad(Pad **out, DeviceCode device_code);
Result FindPadByNumber(Pad **out, int pad_number);
}

View file

@ -29,7 +29,7 @@ namespace ams::spl {
Manu
};
os::Mutex g_mutex(false);
os::SdkMutex g_mutex;
s32 g_initialize_count = 0;
InitializeMode g_initialize_mode = InitializeMode::None;