1 // SPDX-License-Identifier: GPL-2.0+
4 * Jelle van der Waa <jelle@vdwaa.nl>
10 #define SY8106A_I2C_ADDR 0x65
11 #define SY8106A_VOUT1_SEL 1
12 #define SY8106A_VOUT1_SEL_ENABLE (1 << 7)
14 #ifdef CONFIG_SPL_BUILD
15 static u8 sy8106a_mvolt_to_cfg(int mvolt, int min, int max, int div)
22 return (mvolt - min) / div;
25 int sy8106a_set_vout1(unsigned int mvolt)
27 u8 data = sy8106a_mvolt_to_cfg(mvolt, 680, 1950, 10) | SY8106A_VOUT1_SEL_ENABLE;
28 return i2c_write(SY8106A_I2C_ADDR, SY8106A_VOUT1_SEL, 1, &data, 1);