Skip to content

Commit f804bd0

Browse files
akemnadejic23
authored andcommitted
iio:adc:twl6030: Enable measurements of VUSB, VBAT and others
Some inputs need to be wired up to produce proper measurements, without this change only near zero values are reported. Signed-off-by: Andreas Kemnade <[email protected]> Fixes: 1696f36 ("iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver") Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 0fc3562 commit f804bd0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

drivers/iio/adc/twl6030-gpadc.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@
5757
#define TWL6030_GPADCS BIT(1)
5858
#define TWL6030_GPADCR BIT(0)
5959

60+
#define USB_VBUS_CTRL_SET 0x04
61+
#define USB_ID_CTRL_SET 0x06
62+
63+
#define TWL6030_MISC1 0xE4
64+
#define VBUS_MEAS 0x01
65+
#define ID_MEAS 0x01
66+
67+
#define VAC_MEAS 0x04
68+
#define VBAT_MEAS 0x02
69+
#define BB_MEAS 0x01
70+
71+
6072
/**
6173
* struct twl6030_chnl_calib - channel calibration
6274
* @gain: slope coefficient for ideal curve
@@ -927,6 +939,26 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
927939
return ret;
928940
}
929941

942+
ret = twl_i2c_write_u8(TWL_MODULE_USB, VBUS_MEAS, USB_VBUS_CTRL_SET);
943+
if (ret < 0) {
944+
dev_err(dev, "failed to wire up inputs\n");
945+
return ret;
946+
}
947+
948+
ret = twl_i2c_write_u8(TWL_MODULE_USB, ID_MEAS, USB_ID_CTRL_SET);
949+
if (ret < 0) {
950+
dev_err(dev, "failed to wire up inputs\n");
951+
return ret;
952+
}
953+
954+
ret = twl_i2c_write_u8(TWL6030_MODULE_ID0,
955+
VBAT_MEAS | BB_MEAS | BB_MEAS,
956+
TWL6030_MISC1);
957+
if (ret < 0) {
958+
dev_err(dev, "failed to wire up inputs\n");
959+
return ret;
960+
}
961+
930962
indio_dev->name = DRIVER_NAME;
931963
indio_dev->info = &twl6030_gpadc_iio_info;
932964
indio_dev->modes = INDIO_DIRECT_MODE;

0 commit comments

Comments
 (0)