mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-26 14:30:55 +07:00
max8925_power: Do not read random data from chip registers
Reading the voltage, charge etc requires that we tell the chip what property we want to read before reading it according to maxim. Signed-off-by: Philip Rakity <prakity@marvell.com> Signed-off-by: Thomas Liu <Thomas.Liu@maxim-ic.com> Tested-by: Ted Bennett <tbennett@marvell.com> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
This commit is contained in:
parent
60a1f6e446
commit
b57f2f6108
@ -160,25 +160,31 @@ static irqreturn_t max8925_charger_handler(int irq, void *data)
|
|||||||
static int start_measure(struct max8925_power_info *info, int type)
|
static int start_measure(struct max8925_power_info *info, int type)
|
||||||
{
|
{
|
||||||
unsigned char buf[2] = {0, 0};
|
unsigned char buf[2] = {0, 0};
|
||||||
|
int meas_cmd;
|
||||||
int meas_reg = 0, ret;
|
int meas_reg = 0, ret;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MEASURE_VCHG:
|
case MEASURE_VCHG:
|
||||||
|
meas_cmd = MAX8925_CMD_VCHG;
|
||||||
meas_reg = MAX8925_ADC_VCHG;
|
meas_reg = MAX8925_ADC_VCHG;
|
||||||
break;
|
break;
|
||||||
case MEASURE_VBBATT:
|
case MEASURE_VBBATT:
|
||||||
|
meas_cmd = MAX8925_CMD_VBBATT;
|
||||||
meas_reg = MAX8925_ADC_VBBATT;
|
meas_reg = MAX8925_ADC_VBBATT;
|
||||||
break;
|
break;
|
||||||
case MEASURE_VMBATT:
|
case MEASURE_VMBATT:
|
||||||
|
meas_cmd = MAX8925_CMD_VMBATT;
|
||||||
meas_reg = MAX8925_ADC_VMBATT;
|
meas_reg = MAX8925_ADC_VMBATT;
|
||||||
break;
|
break;
|
||||||
case MEASURE_ISNS:
|
case MEASURE_ISNS:
|
||||||
|
meas_cmd = MAX8925_CMD_ISNS;
|
||||||
meas_reg = MAX8925_ADC_ISNS;
|
meas_reg = MAX8925_ADC_ISNS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
max8925_reg_write(info->adc, meas_cmd, 0);
|
||||||
max8925_bulk_read(info->adc, meas_reg, 2, buf);
|
max8925_bulk_read(info->adc, meas_reg, 2, buf);
|
||||||
ret = ((buf[0]<<8) | buf[1]) >> 4;
|
ret = ((buf[0]<<8) | buf[1]) >> 4;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user