From a20e2ad87b59b64377f5fe17694e4898b0dd9d28 Mon Sep 17 00:00:00 2001 From: macphyter Date: Sun, 28 Jan 2024 23:22:35 -0700 Subject: [PATCH] more config init stuff --- main/TPS546.c | 23 +++++++++++++++++++++++ main/TPS546.h | 4 ++++ main/pmbus_commands.h | 4 ++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/main/TPS546.c b/main/TPS546.c index f5e26f7d..6088a975 100644 --- a/main/TPS546.c +++ b/main/TPS546.c @@ -27,6 +27,8 @@ static uint8_t MFR_ID[] = {'B', 'A', 'X'}; static uint8_t MFR_MODEL[] = {'H', 'E', 'X'}; static uint8_t MFR_REVISION[] = {0x00, 0x00, 0x01}; +static uint8_t COMPENSATION_CONFIG[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + /** * @brief SMBus read byte */ @@ -295,6 +297,7 @@ int TPS546_init(void) int iout; uint8_t mfr_revision[3]; int temp; + uint8_t comp_config[5]; ESP_LOGI(TAG, "Initializing the core voltage regulator"); @@ -321,6 +324,8 @@ int TPS546_init(void) ESP_LOGI(TAG, "Config version mismatch, writing new config values"); //TPS546_write_entire_config(); // TODO write new config version here + + } /* Show temperature */ @@ -367,6 +372,11 @@ int TPS546_init(void) ESP_LOGI(TAG, "TOFF_FALL: %d", temp); ESP_LOGI(TAG, "--------------------------------------"); + // Read the compensation config registers + smb_read_block(PMBUS_COMPENSATION_CONFIG, comp_config, 5); + ESP_LOGI(TAG, "COMPENSATION CONFIG"); + ESP_LOGI(TAG, "%02x %02x %02x %02x %02x", comp_config[0], comp_config[1], + comp_config[2], comp_config[3], comp_config[4]); return 0; } @@ -440,6 +450,19 @@ void TPS546_write_entire_config(void) smb_write_word(PMBUS_TOFF_DELAY, int_2_slinear11(TPS546_INIT_TOFF_DELAY)); smb_write_word(PMBUS_TOFF_FALL, int_2_slinear11(TPS546_INIT_TOFF_FALL)); + /* Stack/sync config */ + smb_write_word(PMBUS_STACK_CONFIG, INIT_STACK_CONFIG); + smb_write_word(PMBUS_SYNC_CONFIG, INIT_SYNC_CONFIG); + + /* Compensation config */ + smb_write_block(PMBUS_COMPENSATION_CONFIG, COMPENSATION_CONFIG, 5); + + /* Slave address */ + smb_write_byte(PMBUS_SLAVE_ADDRESS, TPS546_I2CADDR); + + /* configure the bootup behavior regarding pin detect values vs NVM values */ + smb_write_word(PMBUS_PIN_DETECT_OVERRIDE, INIT_PIN_DETECT_OVERRIDE); + /* store configuration in NVM */ smb_write_byte(PMBUS_STORE_USER_ALL, 0xFF); diff --git a/main/TPS546.h b/main/TPS546.h index bd7aa2ad..42cd3419 100644 --- a/main/TPS546.h +++ b/main/TPS546.h @@ -47,6 +47,10 @@ #define TPS546_INIT_TOFF_DELAY 0 #define TPS546_INIT_TOFF_FALL 0 +#define INIT_STACK_CONFIG 0x0000 +#define INIT_SYNC_CONFIG 0x0010 +#define INIT_PIN_DETECT_OVERRIDE 0x0000 + /*-------------------------*/ /* PMBUS_ON_OFF_CONFIG initialization values */ diff --git a/main/pmbus_commands.h b/main/pmbus_commands.h index 761c804d..8879ffee 100644 --- a/main/pmbus_commands.h +++ b/main/pmbus_commands.h @@ -64,8 +64,8 @@ #define PMBUS_MFR_SERIAL 0x9E #define PMBUS_IC_DEVICE_ID 0xAD #define PMBUS_IC_DEVICE_REV 0xAE -#define PMBUS_USER_DATA_01 0xB1 -#define PMBUS_USER_DATA_05 0xB5 +#define PMBUS_COMPENSATION_CONFIG 0xB1 +#define PMBUS_POWER_STAGE_CONFIG 0xB5 /* Manufacturer Specific PMBUS commands used by the TPS546D24A */ #define PMBUS_TELEMETRY_CFG 0xD0