mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 10:34:58 -06:00
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>
This commit is contained in:
parent
bf0e0c7092
commit
648a488216
2 changed files with 37 additions and 1 deletions
|
@ -28,6 +28,24 @@ uint32_t pmbus_direct_mode2data(PMBusCoefficients c, uint16_t value)
|
|||
return x;
|
||||
}
|
||||
|
||||
uint16_t pmbus_data2linear_mode(uint16_t value, int exp)
|
||||
{
|
||||
/* L = D * 2^(-e) */
|
||||
if (exp < 0) {
|
||||
return value << (-exp);
|
||||
}
|
||||
return value >> exp;
|
||||
}
|
||||
|
||||
uint16_t pmbus_linear_mode2data(uint16_t value, int exp)
|
||||
{
|
||||
/* D = L * 2^e */
|
||||
if (exp < 0) {
|
||||
return value >> (-exp);
|
||||
}
|
||||
return value << exp;
|
||||
}
|
||||
|
||||
void pmbus_send(PMBusDevice *pmdev, const uint8_t *data, uint16_t len)
|
||||
{
|
||||
if (pmdev->out_buf_len + len > SMBUS_DATA_MAX_LEN) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue