[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230625121401.0fd87cc8@jic23-huawei>
Date: Sun, 25 Jun 2023 12:14:01 +0100
From: Jonathan Cameron <jic23@...nel.org>
To: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Cosmin Tanislav <cosmin.tanislav@...log.com>,
devicetree@...r.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Rob Herring <robh+dt@...nel.org>, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] iio: addac: ad74413r: wire up
digital-input-threshold-microvolt DT property
On Fri, 23 Jun 2023 13:33:26 +0200
Rasmus Villemoes <linux@...musvillemoes.dk> wrote:
> The threshold is common to all channels configured as digital
> input.
>
> So far, we have not seen the settings in the DIN_THRESH affecting
> functions other than digital input, but with a4cba07e64e6 ("iio:
> addac: ad74413: don't set DIN_SINK for functions other than digital
> input") in mind, do not read and apply the
> digital-input-threshold-microvolt setting unless at least one channel
> has been configured as one of the digital input variants.
>
> Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
LGTM. Will pick up once the minor change in binding is done if no
other feedback comes in.
Thanks,
Jonathan
> ---
> drivers/iio/addac/ad74413r.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
> index e3366cf5eb31..efdd7fdd7ab9 100644
> --- a/drivers/iio/addac/ad74413r.c
> +++ b/drivers/iio/addac/ad74413r.c
> @@ -129,6 +129,12 @@ struct ad74413r_state {
> #define AD74413R_GPO_CONFIG_COMPARATOR 0b011
> #define AD74413R_GPO_CONFIG_HIGH_IMPEDANCE 0b100
>
> +#define AD74413R_REG_DIN_THRESH 0x22
> +#define AD74413R_DIN_COMP_THRESH_MASK GENMASK(5, 1)
> +#define AD74413R_DIN_THRESH_MODE BIT(0)
> +#define AD74413R_DIN_THRESH_MODE_16V BIT(0)
> +#define AD74413R_DIN_THRESH_MODE_AVDD 0
> +
> #define AD74413R_REG_ADC_CONV_CTRL 0x23
> #define AD74413R_CONV_SEQ_MASK GENMASK(9, 8)
> #define AD74413R_CONV_SEQ_ON 0b00
> @@ -1446,6 +1452,20 @@ static int ad74413r_probe(struct spi_device *spi)
> }
>
> if (st->num_comparator_gpios) {
> + u32 thresh, val, mask;
> +
> + if (!device_property_read_u32(st->dev, "digital-input-threshold-microvolt",
> + &thresh)) {
> + val = thresh/500000 - 1;
> + val = FIELD_PREP(AD74413R_DIN_COMP_THRESH_MASK, val);
> + val |= AD74413R_DIN_THRESH_MODE_16V;
> + mask = AD74413R_DIN_COMP_THRESH_MASK | AD74413R_DIN_THRESH_MODE;
> + ret = regmap_update_bits(st->regmap, AD74413R_REG_DIN_THRESH,
> + mask, val);
> + if (ret)
> + return ret;
> + }
> +
> st->comp_gpiochip.owner = THIS_MODULE;
> st->comp_gpiochip.label = st->chip_info->name;
> st->comp_gpiochip.base = -1;
Powered by blists - more mailing lists