Skip to content

Commit 8d6b3ea

Browse files
robhancocksedjic23
authored andcommitted
iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds
In the probe function, the driver was reading out the thresholds already set in the core, which can be configured by the user in the Vivado tools when the FPGA image is built. However, it later clobbered those values with zero or maximum values. In particular, the overtemperature shutdown threshold register was overwritten with the max value, which effectively prevents the FPGA from shutting down when the desired threshold was eached, potentially risking hardware damage in that case. Remove this code to leave the preconfigured default threshold values intact. The code was also disabling all alarms regardless of what enable state they were left in by the FPGA image, including the overtemperature shutdown feature. Leave these bits in their original state so they are not unconditionally disabled. Fixes: bdc8cda ("iio:adc: Add Xilinx XADC driver") Signed-off-by: Robert Hancock <robert.hancock@calian.com> Acked-by: O'Griofa, Conall <conall.ogriofa@amd.com> Tested-by: O'Griofa, Conall <conall.ogriofa@amd.com> Link: https://lore.kernel.org/r/20230915001019.2862964-2-robert.hancock@calian.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 7b695ef commit 8d6b3ea

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

drivers/iio/adc/xilinx-xadc-core.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,28 +1423,6 @@ static int xadc_probe(struct platform_device *pdev)
14231423
if (ret)
14241424
return ret;
14251425

1426-
/* Disable all alarms */
1427-
ret = xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK,
1428-
XADC_CONF1_ALARM_MASK);
1429-
if (ret)
1430-
return ret;
1431-
1432-
/* Set thresholds to min/max */
1433-
for (i = 0; i < 16; i++) {
1434-
/*
1435-
* Set max voltage threshold and both temperature thresholds to
1436-
* 0xffff, min voltage threshold to 0.
1437-
*/
1438-
if (i % 8 < 4 || i == 7)
1439-
xadc->threshold[i] = 0xffff;
1440-
else
1441-
xadc->threshold[i] = 0;
1442-
ret = xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(i),
1443-
xadc->threshold[i]);
1444-
if (ret)
1445-
return ret;
1446-
}
1447-
14481426
/* Go to non-buffered mode */
14491427
xadc_postdisable(indio_dev);
14501428

0 commit comments

Comments
 (0)