From d11d2f8cd5f908fa5d684071c994e8d550aa873d Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 25 Oct 2025 01:37:21 +0800 Subject: [PATCH] modify default voltages; normalize the setting location --- bao1x-boot/boot1/src/platform/bao1x/bao1x.rs | 19 +++++++++++++++---- libs/bao1x-hal/src/board/baosec.rs | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs b/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs index 38c3d5ec0..eeebf5354 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs @@ -124,10 +124,21 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::Boa // set PWM mode on DCDC2. greatly reduces noise on the regulator line pmic.set_pwm_mode(&mut i2c, bao1x_hal::axp2101::WhichDcDc::Dcdc2, true).unwrap(); - // make sure the DCDC2 is set to 0.9V, which will allow us to enter high-speed run - // mode. It defaults to 0.85V on boot. - pmic.set_dcdc(&mut i2c, Some((0.9, true)), bao1x_hal::axp2101::WhichDcDc::Dcdc2) - .unwrap(); + // make sure the DCDC2 is set. Target 20mV above the acceptable run threshold because + // we have to take into account the transistor loss on the + // power switch. + pmic.set_dcdc( + &mut i2c, + Some(( + (bao1x_hal::board::DEFAULT_CPU_VOLTAGE_MV + + bao1x_hal::board::VDD85_SWITCH_MARGIN_MV) + as f32 + / 1000.0, + true, + )), + bao1x_hal::axp2101::WhichDcDc::Dcdc2, + ) + .unwrap(); break; } diff --git a/libs/bao1x-hal/src/board/baosec.rs b/libs/bao1x-hal/src/board/baosec.rs index 085adda1c..a25a6b9ca 100644 --- a/libs/bao1x-hal/src/board/baosec.rs +++ b/libs/bao1x-hal/src/board/baosec.rs @@ -2,6 +2,8 @@ use bao1x_api::*; pub const DEFAULT_FCLK_FREQUENCY: u32 = bao1x_api::offsets::baosec::DEFAULT_FCLK_FREQUENCY; +pub const DEFAULT_CPU_VOLTAGE_MV: u32 = 820; +pub const VDD85_SWITCH_MARGIN_MV: u32 = 20; // margin, in mV, for the transistor power switch pub const I2C_AXP2101_ADR: u8 = 0x34; pub const I2C_TUSB320_ADR: u8 = 0x47;