diff options
author | Shengtan Mao <stmao@google.com> | 2022-03-07 12:06:02 -0800 |
---|---|---|
committer | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2022-03-08 18:46:48 +0100 |
commit | 648a488216837bda04114b700246011316b44478 (patch) | |
tree | af18f2cad7fa2eca7725d277221cbdc0e1e67594 /include/hw | |
parent | bf0e0c70924c725b7b778f6b870a72f789a359af (diff) |
hw/i2c: Added linear mode translation for pmbus devices
Signed-off-by: Shengtan Mao <stmao@google.com>
Reviewed-by: Titus Rwantare <titusr@google.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Acked-by: Corey Minyard <cminyard@mvista.com>
Message-Id: <20220307200605.4001451-7-titusr@google.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Diffstat (limited to 'include/hw')
-rw-r--r-- | include/hw/i2c/pmbus_device.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/hw/i2c/pmbus_device.h b/include/hw/i2c/pmbus_device.h index bab4526734..0f4d6b3fad 100644 --- a/include/hw/i2c/pmbus_device.h +++ b/include/hw/i2c/pmbus_device.h @@ -448,7 +448,7 @@ typedef struct PMBusCoefficients { * * Y = (m * x - b) * 10^R * - * @return uint32_t + * @return uint16_t */ uint16_t pmbus_data2direct_mode(PMBusCoefficients c, uint32_t value); @@ -462,6 +462,24 @@ uint16_t pmbus_data2direct_mode(PMBusCoefficients c, uint32_t value); uint32_t pmbus_direct_mode2data(PMBusCoefficients c, uint16_t value); /** + * Convert sensor values to linear mode format + * + * L = D * 2^(-e) + * + * @return uint16 + */ +uint16_t pmbus_data2linear_mode(uint16_t value, int exp); + +/** + * Convert linear mode formatted data into sensor reading + * + * D = L * 2^e + * + * @return uint16 + */ +uint16_t pmbus_linear_mode2data(uint16_t value, int exp); + +/** * @brief Send a block of data over PMBus * Assumes that the bytes in the block are already ordered correctly, * also assumes the length has been prepended to the block if necessary |