Browse Source

platform/asterix: explicitly configure BUCK1

We suspect that there is instability around BUCK1 in hysteretic mode.
We explicitly configure BUCK1 as 1.8V, and in force-PWM mode, until the
system FW boots and configures it for a lower-power configuration.

Signed-off-by: Joshua Wise <joshua@accelerated.tech>
Joshua Wise 3 months ago
parent
commit
86524f0b3d
1 changed files with 35 additions and 0 deletions
  1. 35 0
      platform/asterix/boot/src/drivers/pmic.c

+ 35 - 0
platform/asterix/boot/src/drivers/pmic.c

@@ -3,6 +3,7 @@
 #include <nrfx_twi.h>
 #include <nrfx_twi.h>
 
 
 #define CHARGER_BASE 0x03U
 #define CHARGER_BASE 0x03U
+#define BUCK_BASE 0x04U
 #define ADC_BASE 0x05U
 #define ADC_BASE 0x05U
 #define TIMER_BASE 0x07U
 #define TIMER_BASE 0x07U
 #define LDSW_BASE 0x08U
 #define LDSW_BASE 0x08U
@@ -25,6 +26,17 @@
 #define BCHGVTERMR 0x0DU
 #define BCHGVTERMR 0x0DU
 #define BCHGVTERMREDUCED_4V00 0x4U
 #define BCHGVTERMREDUCED_4V00 0x4U
 
 
+// BUCK
+#define BUCK1PWMSET 0x4U
+#define BUCK1PWMSET_SET 0x01U
+
+#define BUCK1NORMVOUT 0x8U
+#define BUCK1RETVOUT 0x8U
+#define BUCKVOUT_1V8 0x8U
+
+#define BUCKSWCTRLSET 0xFU
+#define BUCKSWCTRLSET_BUCK1SWCTRLSET 0x01U
+
 // ADC
 // ADC
 #define ADCNTCRSEL 0x0AU
 #define ADCNTCRSEL 0x0AU
 #define ADCNTCRSEL_10K 0x1U
 #define ADCNTCRSEL_10K 0x1U
@@ -46,6 +58,7 @@
 #define SCRATCH0 0x1U
 #define SCRATCH0 0x1U
 #define SCRATCH0_BOOTTIMEREN 0x01U
 #define SCRATCH0_BOOTTIMEREN 0x01U
 
 
+
 static const nrfx_twi_t twi = NRFX_TWI_INSTANCE(BOARD_PMIC_I2C);
 static const nrfx_twi_t twi = NRFX_TWI_INSTANCE(BOARD_PMIC_I2C);
 static const nrfx_twi_config_t config =
 static const nrfx_twi_config_t config =
     NRFX_TWI_DEFAULT_CONFIG(BOARD_PMIC_I2C_SCL_PIN, BOARD_PMIC_I2C_SDA_PIN);
     NRFX_TWI_DEFAULT_CONFIG(BOARD_PMIC_I2C_SCL_PIN, BOARD_PMIC_I2C_SDA_PIN);
@@ -89,6 +102,28 @@ int pmic_init(void) {
     return ret;
     return ret;
   }
   }
 
 
+  // Set up the BUCK1 regulator for maximal stability and manual control to
+  // 1.8V -- system FW can reenable hysteretic mode later to save power.
+  ret = prv_pmic_write(BUCK_BASE, BUCK1PWMSET, BUCK1PWMSET_SET);
+  if (ret != 0) {
+    return ret;
+  }
+
+  ret = prv_pmic_write(BUCK_BASE, BUCK1NORMVOUT, BUCKVOUT_1V8);
+  if (ret != 0) {
+    return ret;
+  }
+
+  ret = prv_pmic_write(BUCK_BASE, BUCK1RETVOUT, BUCKVOUT_1V8);
+  if (ret != 0) {
+    return ret;
+  }
+
+  ret = prv_pmic_write(BUCK_BASE, BUCKSWCTRLSET, BUCKSWCTRLSET_BUCK1SWCTRLSET);
+  if (ret != 0) {
+    return ret;
+  }
+
   // Configure charger (TODO: values are board/battery dependent)
   // Configure charger (TODO: values are board/battery dependent)
   // - Thermistor: 10K NTC
   // - Thermistor: 10K NTC
   // - Termination voltage: 4.2V
   // - Termination voltage: 4.2V