2021-08-24 04:15:51 +00:00
|
|
|
/*
|
|
|
|
* 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 <exosphere.hpp>
|
|
|
|
|
|
|
|
namespace ams::nxboot {
|
|
|
|
|
2021-08-28 06:20:46 +00:00
|
|
|
void DoMemoryTrainingErista(int index);
|
|
|
|
void DoMemoryTrainingMariko(int index);
|
2021-08-24 04:15:51 +00:00
|
|
|
|
2021-08-24 23:51:16 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr const u8 MemoryTrainingTableIndex_Invalid = std::numeric_limits<u8>::max();
|
|
|
|
|
|
|
|
constexpr const u8 MemoryTrainingTableIndices[] = {
|
|
|
|
/* DramId_EristaIcosaSamsung4gb */ 0x00,
|
|
|
|
/* DramId_EristaIcosaHynix4gb */ 0x02,
|
|
|
|
/* DramId_EristaIcosaMicron4gb */ 0x03,
|
|
|
|
/* DramId_MarikoIowaHynix1y4gb */ 0x10,
|
|
|
|
/* DramId_EristaIcosaSamsung6gb */ 0x01,
|
|
|
|
/* DramId_MarikoHoagHynix1y4gb */ 0x10,
|
|
|
|
/* DramId_EristaCopperMicron4gb */ MemoryTrainingTableIndex_Invalid,
|
|
|
|
/* DramId_MarikoIowax1x2Samsung4gb */ 0x00,
|
|
|
|
/* DramId_MarikoIowaSamsung4gb */ 0x05,
|
|
|
|
/* DramId_MarikoIowaSamsung8gb */ 0x06,
|
|
|
|
/* DramId_MarikoIowaHynix4gb */ 0x07,
|
|
|
|
/* DramId_MarikoIowaMicron4gb */ 0x08,
|
|
|
|
/* DramId_MarikoHoagSamsung4gb */ 0x05,
|
|
|
|
/* DramId_MarikoHoagSamsung8gb */ 0x06,
|
|
|
|
/* DramId_MarikoHoagHynix4gb */ 0x07,
|
|
|
|
/* DramId_MarikoHoagMicron4gb */ 0x08,
|
|
|
|
/* DramId_MarikoIowaSamsung4gbY */ 0x09,
|
|
|
|
/* DramId_MarikoIowaSamsung1y4gbX */ 0x0C,
|
|
|
|
/* DramId_MarikoIowaSamsung1y8gbX */ 0x0D,
|
|
|
|
/* DramId_MarikoHoagSamsung1y4gbX */ 0x0C,
|
|
|
|
/* DramId_MarikoIowaSamsung1y4gbY */ 0x0A,
|
|
|
|
/* DramId_MarikoIowaSamsung1y8gbY */ 0x0B,
|
|
|
|
/* DramId_MarikoAulaSamsung1y4gb */ 0x0E,
|
|
|
|
/* DramId_MarikoHoagSamsung1y8gbX */ 0x0D,
|
|
|
|
/* DramId_MarikoAulaSamsung1y4gbX */ 0x0C,
|
|
|
|
/* DramId_MarikoIowaMicron1y4gb */ 0x0F,
|
|
|
|
/* DramId_MarikoHoagMicron1y4gb */ 0x0F,
|
|
|
|
/* DramId_MarikoAulaMicron1y4gb */ 0x0F,
|
|
|
|
/* DramId_MarikoAulaSamsung1y8gbX */ 0x0D,
|
|
|
|
};
|
|
|
|
|
2021-08-28 06:20:46 +00:00
|
|
|
int GetMemoryTrainingTableIndex() {
|
|
|
|
if (const auto dram_id = fuse::GetDramId(); dram_id < util::size(MemoryTrainingTableIndices) && MemoryTrainingTableIndices[dram_id] != MemoryTrainingTableIndex_Invalid) {
|
|
|
|
return static_cast<int>(MemoryTrainingTableIndices[dram_id]);
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-24 23:51:16 +00:00
|
|
|
}
|
|
|
|
|
2021-08-24 04:15:51 +00:00
|
|
|
void DoMemoryTraining() {
|
2021-08-28 06:20:46 +00:00
|
|
|
const auto index = GetMemoryTrainingTableIndex();
|
2021-08-24 04:15:51 +00:00
|
|
|
|
2021-08-28 06:20:46 +00:00
|
|
|
if (fuse::GetSocType() == fuse::SocType_Erista) {
|
|
|
|
DoMemoryTrainingErista(index);
|
2021-08-24 23:51:16 +00:00
|
|
|
} else {
|
2021-08-28 06:20:46 +00:00
|
|
|
DoMemoryTrainingMariko(index);
|
2021-08-24 23:51:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-24 04:15:51 +00:00
|
|
|
}
|