-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fby3.5 hd support bom3 sensor (#468)
Summary: - Support VR sensor MP2856GUT - Add the sensor config table of 3rd source sensor, replace sensor talbe to it if board revision is SYS_BOARD_EVT_BOM3. Dependency: #467 Pull Request resolved: #468 Test Plan: - Build Code: Pass Known issue: - Pout reading for MP2856GUT is larger than expected, still checking with FAE. Log: Third source boar ``` root@bmc-oob:~# sensor-util slot1 ... HSC Temp (0xE) : 47.12 C | (ok) CPU0 VR Temp (0xF) : 49.00 C | (ok) SOC VR Temp (0x10) : 51.00 C | (ok) CPU1 VR Temp (0x11) : 34.00 C | (ok) PVDDIO VR Temp (0x12) : 34.00 C | (ok) PVDD11 VR Temp (0x13) : 31.00 C | (ok) P12V_STBY Vol (0x14) : 12.00 Volts | (ok) PVDD18_S5 Vol (0x15) : 1.81 Volts | (ok) P3V3_STBY Vol (0x16) : 3.30 Volts | (ok) PVDD11_S3 Vol (0x17) : 1.10 Volts | (ok) P3V_BAT Vol (0x18) : 3.08 Volts | (ok) PVDD33 (8abd13595b91e80483a23f1f1a3af919a502a536)_S5 Vol (0x19) : 3.31 Volts | (ok) P5V_STBY Vol (0x1A) : 4.99 Volts | (ok) P12V_MEM_1 Vol (0x1B) : 12.05 Volts | (ok) P12V_MEM_0 Vol (0x1C) : 12.03 Volts | (ok) P1V2_STBY Vol (0x1D) : 1.20 Volts | (ok) P3V3_M2 Vol (0x1E) : 3.31 Volts | (ok) P1V8_STBY Vol (0x1F) : 1.81 Volts | (ok) HSC Input Vol (0x20) : 12.05 Volts | (ok) CPU0 VR Vol (0x21) : 0.92 Volts | (ok) SOC VR Vol (0x22) : 1.19 Volts | (ok) CPU1 VR Vol (0x23) : 0.93 Volts | (ok) PVDDIO VR Vol (0x24) : 1.10 Volts | (ok) PVDD11 VR Vol (0x25) : 1.10 Volts | (ok) HSC Output Cur (0x26) : 12.75 Amps | (ok) CPU0 VR Cur (0x27) : 12.75 Amps | (ok) SOC VR Cur (0x28) : 59.75 Amps | (ok) CPU1 VR Cur (0x29) : 16.75 Amps | (ok) PVDDIO VR Cur (0x2A) : 31.75 Amps | (ok) PVDD11 VR Cur (0x2B) : 3.25 Amps | (ok) HSC Input Pwr (0x2C) : 155.15 Watts | (ok) CPU0 VR Pwr (0x2D) : 96.00 Watts | (ok) SOC VR Pwr (0x2E) : 568.00 Watts | (ucr) CPU1 VR Pwr (0x2F) : 120.00 Watts | (ok) PVDDIO VR Pwr (0x30) : 280.00 Watts | (ucr) PVDD11 VR Pwr (0x31) : 32.00 Watts | (ok) ... ``` Reviewed By: garnermic Differential Revision: D38518270 Pulled By: GoldenBug fbshipit-source-id: 15483ab462188061fca94e564f422fccd734fd6d
- Loading branch information
1 parent
156611f
commit 47ee82d
Showing
9 changed files
with
238 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include "sensor.h" | ||
#include "hal_i2c.h" | ||
#include "pmbus.h" | ||
#include "util_pmbus.h" | ||
|
||
#define MFR_VR_CONFIG2_VOUT_MODE_BIT BIT(11) | ||
#define MFR_VR_CONFIG2 0x5E | ||
|
||
uint8_t mp2856gut_read(uint8_t sensor_num, int *reading) | ||
{ | ||
if (reading == NULL || (sensor_num > SENSOR_NUM_MAX)) { | ||
return SENSOR_UNSPECIFIED_ERROR; | ||
} | ||
|
||
uint8_t retry = 5; | ||
sensor_val *sval = (sensor_val *)reading; | ||
I2C_MSG msg; | ||
memset(sval, 0, sizeof(sensor_val)); | ||
sensor_cfg *cfg = &sensor_config[sensor_config_index_map[sensor_num]]; | ||
|
||
msg.bus = cfg->port; | ||
msg.target_addr = cfg->target_addr; | ||
msg.tx_len = 1; | ||
msg.rx_len = 2; | ||
msg.data[0] = cfg->offset; | ||
|
||
if (i2c_master_read(&msg, retry)) { | ||
return SENSOR_FAIL_TO_ACCESS; | ||
} | ||
|
||
float val; | ||
if (cfg->offset == PMBUS_READ_VOUT) { | ||
val = (msg.data[1] << 8) | msg.data[0]; | ||
|
||
msg.bus = cfg->port; | ||
msg.target_addr = cfg->target_addr; | ||
msg.tx_len = 1; | ||
msg.rx_len = 2; | ||
msg.data[0] = MFR_VR_CONFIG2; | ||
|
||
if (i2c_master_read(&msg, retry)) { | ||
return SENSOR_FAIL_TO_ACCESS; | ||
} | ||
|
||
uint16_t mfg_vr_config2_data = (msg.data[1] << 8) | msg.data[0]; | ||
bool vout_mode = mfg_vr_config2_data && MFR_VR_CONFIG2_VOUT_MODE_BIT; | ||
|
||
if (vout_mode) { | ||
val *= 0.00390625; | ||
} else { | ||
val *= 0.005; | ||
} | ||
} else if (cfg->offset == PMBUS_READ_IOUT || cfg->offset == PMBUS_READ_POUT) { | ||
uint16_t read_value = (msg.data[1] << 8) | msg.data[0]; | ||
val = slinear11_to_float(read_value); | ||
} else if (cfg->offset == PMBUS_READ_TEMPERATURE_1) { | ||
val = msg.data[0]; | ||
} else { | ||
return SENSOR_FAIL_TO_ACCESS; | ||
} | ||
sval->integer = val; | ||
sval->fraction = (val - sval->integer) * 1000; | ||
|
||
return SENSOR_READ_SUCCESS; | ||
} | ||
|
||
uint8_t mp2856gut_init(uint8_t sensor_num) | ||
{ | ||
if (sensor_num > SENSOR_NUM_MAX) { | ||
return SENSOR_INIT_UNSPECIFIED_ERROR; | ||
} | ||
|
||
sensor_config[sensor_config_index_map[sensor_num]].read = mp2856gut_read; | ||
return SENSOR_INIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters