1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-22 20:06:40 +00:00

boot: various bugfixes (b/w logo displays now)

This commit is contained in:
Michael Scire 2020-11-10 05:02:41 -08:00 committed by SciresM
parent fdab964e3d
commit affdea9244
10 changed files with 47 additions and 19 deletions

View file

@ -67,8 +67,8 @@ namespace ams::i2c::driver::impl {
Result I2cSessionImpl::SendHandler(const u8 **cur_cmd, u8 **cur_dst) {
/* Read the header bytes. */
const util::BitPack8 hdr0{*(*cur_cmd++)};
const util::BitPack8 hdr1{*(*cur_cmd++)};
const util::BitPack8 hdr0{*((*cur_cmd)++)};
const util::BitPack8 hdr1{*((*cur_cmd)++)};
/* Decode the header. */
const bool start = hdr0.Get<i2c::impl::SendCommandFormat::StartCondition>();
@ -86,8 +86,8 @@ namespace ams::i2c::driver::impl {
Result I2cSessionImpl::ReceiveHandler(const u8 **cur_cmd, u8 **cur_dst) {
/* Read the header bytes. */
const util::BitPack8 hdr0{*(*cur_cmd++)};
const util::BitPack8 hdr1{*(*cur_cmd++)};
const util::BitPack8 hdr0{*((*cur_cmd)++)};
const util::BitPack8 hdr1{*((*cur_cmd)++)};
/* Decode the header. */
const bool start = hdr0.Get<i2c::impl::ReceiveCommandFormat::StartCondition>();
@ -105,13 +105,13 @@ namespace ams::i2c::driver::impl {
Result I2cSessionImpl::ExtensionHandler(const u8 **cur_cmd, u8 **cur_dst) {
/* Read the header bytes. */
const util::BitPack8 hdr0{*(*cur_cmd++)};
const util::BitPack8 hdr0{*((*cur_cmd)++)};
/* Execute the subcommand. */
switch (hdr0.Get<i2c::impl::CommonCommandFormat::SubCommandId>()) {
case i2c::impl::SubCommandId_Sleep:
{
const util::BitPack8 param{*(*cur_cmd++)};
const util::BitPack8 param{*((*cur_cmd)++)};
os::SleepThread(TimeSpan::FromMicroSeconds(param.Get<i2c::impl::SleepCommandFormat::MicroSeconds>()));
}

View file

@ -84,19 +84,23 @@ namespace ams::i2c {
{
std::scoped_lock lk(g_i2c_mutex);
AMS_ASSERT(g_i2c_count > 0);
if (g_i2c_count > 0) {
if ((--g_i2c_count) == 0) {
g_i2c_manager.reset();
}
}
}
{
std::scoped_lock lk(g_i2c_pcv_mutex);
AMS_ASSERT(g_i2c_pcv_count > 0);
if (g_i2c_pcv_count > 0) {
if ((--g_i2c_pcv_count) == 0) {
g_i2c_pcv_manager.reset();
}
}
}
}
}
Result OpenSession(I2cSession *out, DeviceCode device_code) {
/* Allocate the session. */

View file

@ -25,8 +25,8 @@ namespace ams::pwm::driver::board::nintendo_nx::impl {
constexpr inline size_t PwmRegistersSize = 0x100;
constexpr const ChannelDefinition SupportedChannels[] = {
{ pwm::DeviceCode_CpuFan, 0 },
{ pwm::DeviceCode_LcdBacklight, 1 },
{ pwm::DeviceCode_LcdBacklight, 0 },
{ pwm::DeviceCode_CpuFan, 1 },
};
}

View file

@ -141,7 +141,7 @@ namespace ams::pwm::driver::board::nintendo_nx::impl {
AMS_ASSERT(device != nullptr);
/* Validate the duty. */
R_UNLESS(0 <= duty && duty < MaxDuty, pwm::ResultInvalidArgument());
R_UNLESS(0 <= duty && duty <= MaxDuty, pwm::ResultInvalidArgument());
/* Acquire exclusive access to the device registers. */
std::scoped_lock lk(device->SafeCastTo<PwmDeviceImpl>());

View file

@ -54,7 +54,7 @@
DEFINE_I2C_REG(I2C_CNFG_LENGTH, 1, 3);
DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_CMD1, 6, WRITE, READ);
DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_SEND, 9, NOP, GO);
DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_PACKET_MODE_EN, 9, NOP, GO);
DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_PACKET_MODE_EN, 10, NOP, GO);
DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_NEW_MASTER_FSM, 11, DISABLE, ENABLE);
DEFINE_I2C_REG_THREE_BIT_ENUM(I2C_CNFG_DEBOUNCE_CNT, 12, NO_DEBOUNCE, DEBOUNCE_2T, DEBOUNCE_4T, DEBOUNCE_6T, DEBOUNCE_8T, DEBOUNCE_10T, DEBOUNCE_12T, DEBOUNCE_14T);

View file

@ -94,4 +94,6 @@ DEFINE_PINMUX_REG_TWO_BIT_ENUM(AUX_UART3_PM, 0, UARTC, SPI4, RSVD2, RSVD3);
DEFINE_PINMUX_REG_TWO_BIT_ENUM(AUX_DVFS_PWM_PM, 0, RSVD0, CLDVFS, SPI3, RSVD3);
DEFINE_PINMUX_REG_TWO_BIT_ENUM(AUX_LCD_BL_PWM_PM, 0, DISPLAYA, PWM0, SOR0, RSVD3);
DEFINE_PINMUX_REG_TWO_BIT_ENUM(AUX_GPIO_PA6_PM, 0, SATA, RSVD1, RSVD2, RSVD3);

View file

@ -123,6 +123,15 @@
"is_io": true
}
},
{
"type": "map",
"value": {
"address": "0x7000A000",
"size": "0x1000",
"is_ro": false,
"is_io": true
}
},
{
"type": "map",
"value": {

View file

@ -319,6 +319,11 @@ namespace ams::boot {
reg::SetBits(g_gpio_regs + GPIO_PORT3_OUT_0, 0x2);
os::SleepThread(TimeSpan::FromMilliSeconds(10));
/* Configure LCD backlight to use PWM. */
reg::ClearBits(g_gpio_regs + GPIO_PORT6_CNF_1, 0x1);
reg::Write(g_apb_misc_regs + PINMUX_AUX_LCD_BL_PWM, PINMUX_REG_BITS_ENUM(AUX_LCD_BL_PWM_PM, PWM0),
PINMUX_REG_BITS_ENUM(AUX_PUPD, PULL_DOWN));
/* Configure LCD backlight. */
R_ABORT_UNLESS(pwm::driver::OpenSession(std::addressof(g_lcd_backlight_session), pwm::DeviceCode_LcdBacklight));
pwm::driver::SetPeriod(g_lcd_backlight_session, TimeSpan::FromNanoSeconds(33898));

View file

@ -50,8 +50,16 @@ namespace ams::boot {
}
void FinalizeI2cDriverLibrary() {
/* TODO */
AMS_ABORT();
/* Finalize the i2c driver library. */
i2c::driver::Finalize();
/* Finalize the i2c client library. */
i2c::Finalize();
/* NOTE: Unknown finalize function is called here by Nintendo. */
/* Finalize the pwm client library. */
pwm::Finalize();
}
}