From: Jonathan Cameron <jic23@kernel.org>
To: Robert Hancock <robert.hancock@calian.com>
Cc: linux-iio@vger.kernel.org, robh+dt@kernel.org,
michal.simek@xilinx.com, anand.ashok.dumbre@xilinx.com,
lars@metafoo.de, manish.narani@xilinx.com,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
Michael Tretter <m.tretter@pengutronix.de>
Subject: Re: [PATCH 4/4] iio: adc: xilinx-ams: Fix single channel switching sequence
Date: Sun, 30 Jan 2022 12:34:59 +0000 [thread overview]
Message-ID: <20220130123459.5d44c1ec@jic23-huawei> (raw)
In-Reply-To: <20220120010246.3794962-5-robert.hancock@calian.com>
On Wed, 19 Jan 2022 19:02:46 -0600
Robert Hancock <robert.hancock@calian.com> wrote:
> Some of the AMS channels need to be read by switching into single-channel
> mode from the normal polling sequence. There was a logic issue in this
> switching code that could cause the first read of these channels to read
> back as zero.
>
> It appears that the sequencer should be set back to default mode before
> changing the channel selection, and the channel should be set before
> switching the sequencer back into single-channel mode.
>
> Also, write 1 to the EOC bit in the status register to clear it before
> waiting for it to become set, so that we actually wait for a new
> conversion to complete, and don't proceed based on a previous conversion
> completing.
>
> Fixes: d5c70627a794 ("iio: adc: Add Xilinx AMS driver")
> Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Looking for an Ack from Anand or someone else familiar with this device.
Thanks,
Jonathan
> ---
> drivers/iio/adc/xilinx-ams.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/xilinx-ams.c b/drivers/iio/adc/xilinx-ams.c
> index 199027c93cdc..7bf097fa10cb 100644
> --- a/drivers/iio/adc/xilinx-ams.c
> +++ b/drivers/iio/adc/xilinx-ams.c
> @@ -530,14 +530,18 @@ static int ams_enable_single_channel(struct ams *ams, unsigned int offset)
> return -EINVAL;
> }
>
> - /* set single channel, sequencer off mode */
> + /* put sysmon in a soft reset to change the sequence */
> ams_ps_update_reg(ams, AMS_REG_CONFIG1, AMS_CONF1_SEQ_MASK,
> - AMS_CONF1_SEQ_SINGLE_CHANNEL);
> + AMS_CONF1_SEQ_DEFAULT);
>
> /* write the channel number */
> ams_ps_update_reg(ams, AMS_REG_CONFIG0, AMS_CONF0_CHANNEL_NUM_MASK,
> channel_num);
>
> + /* set single channel, sequencer off mode */
> + ams_ps_update_reg(ams, AMS_REG_CONFIG1, AMS_CONF1_SEQ_MASK,
> + AMS_CONF1_SEQ_SINGLE_CHANNEL);
> +
> return 0;
> }
>
> @@ -551,6 +555,8 @@ static int ams_read_vcc_reg(struct ams *ams, unsigned int offset, u32 *data)
> if (ret)
> return ret;
>
> + /* clear end-of-conversion flag, wait for next conversion to complete */
> + writel(expect, ams->base + AMS_ISR_1);
> ret = readl_poll_timeout(ams->base + AMS_ISR_1, reg, (reg & expect),
> AMS_INIT_POLL_TIME_US, AMS_INIT_TIMEOUT_US);
> if (ret)
prev parent reply other threads:[~2022-01-30 12:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 1:02 [PATCH 0/4] Xilinx AMS fixes Robert Hancock
2022-01-20 1:02 ` [PATCH 1/4] arm64: dts: zynqmp: add AMS driver to device tree Robert Hancock
2022-01-25 8:02 ` Michael Tretter
2022-01-25 9:42 ` Michal Simek
2022-01-20 1:02 ` [PATCH 2/4] iio: adc: xilinx-ams: Fixed missing PS channels Robert Hancock
2022-01-20 1:09 ` Robert Hancock
2022-01-25 8:06 ` Michael Tretter
2022-01-30 12:29 ` Jonathan Cameron
2022-01-20 1:02 ` [PATCH 3/4] iio: adc: xilinx-ams: Fixed wrong sequencer register settings Robert Hancock
2022-01-25 8:21 ` Michael Tretter
2022-01-25 16:15 ` Robert Hancock
2022-01-26 9:12 ` Michael Tretter
2022-01-30 12:31 ` Jonathan Cameron
2022-01-20 1:02 ` [PATCH 4/4] iio: adc: xilinx-ams: Fix single channel switching sequence Robert Hancock
2022-01-30 12:34 ` Jonathan Cameron [this message]
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=20220130123459.5d44c1ec@jic23-huawei \
--to=jic23@kernel.org \
--cc=anand.ashok.dumbre@xilinx.com \
--cc=devicetree@vger.kernel.org \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=m.tretter@pengutronix.de \
--cc=manish.narani@xilinx.com \
--cc=michal.simek@xilinx.com \
--cc=robert.hancock@calian.com \
--cc=robh+dt@kernel.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).