From: Robert Hancock <robert.hancock@calian.com> To: Jonathan Cameron <jic23@kernel.org> Cc: Lars-Peter Clausen <lars@metafoo.de>, Michal Simek <michal.simek@amd.com>, Anand Ashok Dumbre <anandash@xilinx.com>, linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Robert Hancock <robert.hancock@calian.com> Subject: [PATCH 1/2] iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds Date: Thu, 14 Sep 2023 15:24:31 -0600 [thread overview] Message-ID: <20230914212432.2842010-2-robert.hancock@calian.com> (raw) In-Reply-To: <20230914212432.2842010-1-robert.hancock@calian.com> 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. Fixes: bdc8cda1d010 ("iio:adc: Add Xilinx XADC driver") Signed-off-by: Robert Hancock <robert.hancock@calian.com> --- drivers/iio/adc/xilinx-xadc-core.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index dba73300f894..88d523ac7881 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -1429,22 +1429,6 @@ static int xadc_probe(struct platform_device *pdev) if (ret) return ret; - /* Set thresholds to min/max */ - for (i = 0; i < 16; i++) { - /* - * Set max voltage threshold and both temperature thresholds to - * 0xffff, min voltage threshold to 0. - */ - if (i % 8 < 4 || i == 7) - xadc->threshold[i] = 0xffff; - else - xadc->threshold[i] = 0; - ret = xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(i), - xadc->threshold[i]); - if (ret) - return ret; - } - /* Go to non-buffered mode */ xadc_postdisable(indio_dev); -- 2.41.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Robert Hancock <robert.hancock@calian.com> To: Jonathan Cameron <jic23@kernel.org> Cc: Lars-Peter Clausen <lars@metafoo.de>, Michal Simek <michal.simek@amd.com>, Anand Ashok Dumbre <anandash@xilinx.com>, linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Robert Hancock <robert.hancock@calian.com> Subject: [PATCH 1/2] iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds Date: Thu, 14 Sep 2023 15:24:31 -0600 [thread overview] Message-ID: <20230914212432.2842010-2-robert.hancock@calian.com> (raw) In-Reply-To: <20230914212432.2842010-1-robert.hancock@calian.com> 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. Fixes: bdc8cda1d010 ("iio:adc: Add Xilinx XADC driver") Signed-off-by: Robert Hancock <robert.hancock@calian.com> --- drivers/iio/adc/xilinx-xadc-core.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index dba73300f894..88d523ac7881 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -1429,22 +1429,6 @@ static int xadc_probe(struct platform_device *pdev) if (ret) return ret; - /* Set thresholds to min/max */ - for (i = 0; i < 16; i++) { - /* - * Set max voltage threshold and both temperature thresholds to - * 0xffff, min voltage threshold to 0. - */ - if (i % 8 < 4 || i == 7) - xadc->threshold[i] = 0xffff; - else - xadc->threshold[i] = 0; - ret = xadc_write_adc_reg(xadc, XADC_REG_THRESHOLD(i), - xadc->threshold[i]); - if (ret) - return ret; - } - /* Go to non-buffered mode */ xadc_postdisable(indio_dev); -- 2.41.0
next prev parent reply other threads:[~2023-09-14 21:25 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-14 21:24 [PATCH 0/2] Xilinx XADC fixes Robert Hancock 2023-09-14 21:24 ` Robert Hancock 2023-09-14 21:24 ` Robert Hancock [this message] 2023-09-14 21:24 ` [PATCH 1/2] iio: adc: xilinx-xadc: Don't clobber preset voltage/temperature thresholds Robert Hancock 2023-09-14 23:45 ` Robert Hancock 2023-09-14 23:45 ` Robert Hancock 2023-09-14 21:24 ` [PATCH 2/2] iio: adc: xilinx-xadc: Correct temperature offset/scale for UltraScale Robert Hancock 2023-09-14 21:24 ` Robert Hancock
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230914212432.2842010-2-robert.hancock@calian.com \ --to=robert.hancock@calian.com \ --cc=anandash@xilinx.com \ --cc=jic23@kernel.org \ --cc=lars@metafoo.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-iio@vger.kernel.org \ --cc=michal.simek@amd.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.