2019-06-22 08:10:21 +01:00
|
|
|
/*
|
2020-01-24 10:10:40 +00:00
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
2019-06-22 08:10:21 +01:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2019-06-22 19:34:18 +01:00
|
|
|
#include "pinmux_initial_configuration.hpp"
|
|
|
|
#include "pinmux_utils.hpp"
|
2019-06-22 08:10:21 +01:00
|
|
|
|
2019-10-24 10:30:10 +01:00
|
|
|
namespace ams::pinmux {
|
2019-06-22 08:10:21 +01:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct InitialConfig {
|
|
|
|
u32 name;
|
|
|
|
u32 val;
|
|
|
|
u32 mask;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Include all initial configuration definitions. */
|
2019-06-22 19:34:18 +01:00
|
|
|
#include "pinmux_initial_configuration_icosa.inc"
|
|
|
|
#include "pinmux_initial_configuration_copper.inc"
|
|
|
|
#include "pinmux_initial_configuration_hoag.inc"
|
|
|
|
#include "pinmux_initial_configuration_iowa.inc"
|
2020-02-24 16:21:31 +00:00
|
|
|
#include "pinmux_initial_configuration_calcio.inc"
|
|
|
|
|
2019-06-22 19:34:18 +01:00
|
|
|
#include "pinmux_initial_drive_pad_configuration.inc"
|
2020-02-24 16:21:31 +00:00
|
|
|
#include "pinmux_initial_drive_pad_configuration_hoag.inc"
|
2019-06-22 08:10:21 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Configuration helpers. */
|
|
|
|
void ConfigureInitialPads() {
|
|
|
|
const InitialConfig *configs = nullptr;
|
|
|
|
size_t num_configs = 0;
|
2019-06-22 19:34:18 +01:00
|
|
|
const auto hw_type = spl::GetHardwareType();
|
2019-06-22 08:10:21 +01:00
|
|
|
|
|
|
|
switch (hw_type) {
|
|
|
|
case spl::HardwareType::Icosa:
|
2020-02-24 16:21:31 +00:00
|
|
|
configs = InitialConfigsIcosa;
|
2019-06-22 08:10:21 +01:00
|
|
|
num_configs = NumInitialConfigsIcosa;
|
|
|
|
break;
|
|
|
|
case spl::HardwareType::Copper:
|
2020-02-24 16:21:31 +00:00
|
|
|
configs = InitialConfigsCopper;
|
2019-06-22 08:10:21 +01:00
|
|
|
num_configs = NumInitialConfigsCopper;
|
|
|
|
break;
|
|
|
|
case spl::HardwareType::Hoag:
|
2020-02-24 16:21:31 +00:00
|
|
|
configs = InitialConfigsHoag;
|
2019-06-22 08:10:21 +01:00
|
|
|
num_configs = NumInitialConfigsHoag;
|
|
|
|
break;
|
|
|
|
case spl::HardwareType::Iowa:
|
2020-02-24 16:21:31 +00:00
|
|
|
configs = InitialConfigsIowa;
|
2019-06-22 08:10:21 +01:00
|
|
|
num_configs = NumInitialConfigsIowa;
|
2020-02-24 17:45:40 +00:00
|
|
|
break;
|
2020-02-24 16:21:31 +00:00
|
|
|
case spl::HardwareType::Calcio:
|
|
|
|
configs = InitialConfigsCalcio;
|
|
|
|
num_configs = NumInitialConfigsCalcio;
|
2019-06-22 08:10:21 +01:00
|
|
|
break;
|
2019-09-28 23:13:20 +01:00
|
|
|
/* Unknown hardware type, we can't proceed. */
|
2019-10-24 10:30:10 +01:00
|
|
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
2019-06-22 08:10:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure we found an appropriate config. */
|
2020-02-23 07:05:14 +00:00
|
|
|
AMS_ABORT_UNLESS(configs != nullptr);
|
2019-06-22 08:10:21 +01:00
|
|
|
|
2019-08-29 08:18:40 +01:00
|
|
|
for (size_t i = 0; i < num_configs; i++) {
|
2019-06-22 08:10:21 +01:00
|
|
|
UpdatePad(configs[i].name, configs[i].val, configs[i].mask);
|
|
|
|
}
|
|
|
|
|
2020-02-24 16:21:31 +00:00
|
|
|
/* Extra configs for mariko only. */
|
|
|
|
if (hw_type == spl::HardwareType::Hoag || hw_type == spl::HardwareType::Iowa || hw_type == spl::HardwareType::Calcio) {
|
|
|
|
static constexpr u32 ExtraMarikoPadNames[] = {
|
2019-06-22 08:10:21 +01:00
|
|
|
0xAA, 0xAC, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9
|
|
|
|
};
|
2020-02-24 16:21:31 +00:00
|
|
|
for (size_t i = 0; i < util::size(ExtraMarikoPadNames); i++) {
|
|
|
|
UpdatePad(ExtraMarikoPadNames[i], 0x2000, 0x2000);
|
2019-06-22 08:10:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureInitialDrivePads() {
|
2020-02-24 16:21:31 +00:00
|
|
|
const InitialConfig *configs = nullptr;
|
|
|
|
size_t num_configs = 0;
|
|
|
|
const auto hw_type = spl::GetHardwareType();
|
|
|
|
|
|
|
|
switch (hw_type) {
|
|
|
|
case spl::HardwareType::Icosa:
|
|
|
|
case spl::HardwareType::Copper:
|
|
|
|
case spl::HardwareType::Iowa:
|
|
|
|
case spl::HardwareType::Calcio:
|
|
|
|
configs = InitialDrivePadConfigs;
|
|
|
|
num_configs = NumInitialDrivePadConfigs;
|
2020-02-24 17:45:40 +00:00
|
|
|
break;
|
2020-02-24 16:21:31 +00:00
|
|
|
case spl::HardwareType::Hoag:
|
|
|
|
configs = InitialDrivePadConfigsHoag;
|
|
|
|
num_configs = NumInitialDrivePadConfigsHoag;
|
|
|
|
break;
|
|
|
|
/* Unknown hardware type, we can't proceed. */
|
|
|
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure we found an appropriate config. */
|
|
|
|
AMS_ABORT_UNLESS(configs != nullptr);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < num_configs; i++) {
|
2019-06-22 08:10:21 +01:00
|
|
|
UpdateDrivePad(configs[i].name, configs[i].val, configs[i].mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetInitialConfiguration() {
|
|
|
|
/* Update all parks. */
|
|
|
|
UpdateAllParks();
|
|
|
|
|
|
|
|
/* Dummy read all drive pads. */
|
|
|
|
DummyReadAllDrivePads();
|
|
|
|
|
|
|
|
/* Set initial pad configs. */
|
|
|
|
ConfigureInitialPads();
|
|
|
|
|
|
|
|
/* Set initial drive pad configs. */
|
|
|
|
ConfigureInitialDrivePads();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|