From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Cosmin Tanislav <cosmin.tanislav@analog.com>,
Jonathan Cameron <jic23@kernel.org>, <devicetree@vger.kernel.org>,
Rob Herring <robh+dt@kernel.org>, <linux-iio@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] iio: ad74413r: wire up support for drive-strength-microamp property
Date: Fri, 3 Mar 2023 15:14:38 +0000 [thread overview]
Message-ID: <20230303151438.00003842@Huawei.com> (raw)
In-Reply-To: <20230302134922.1120217-3-linux@rasmusvillemoes.dk>
On Thu, 2 Mar 2023 14:49:21 +0100
Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> Use the value specified in the channel configuration node to populate
> the DIN_SINK field of the DIN_CONFIGx register.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Hi Rasmus,
Given you are doing a v2 for the binding issue
Rob's bot noted. One trivial comment inline.
(I'd have ignored it if everything else was fine!)
Thanks,
Jonathan
> ---
> drivers/iio/addac/ad74413r.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/iio/addac/ad74413r.c b/drivers/iio/addac/ad74413r.c
> index f32c8c2fb26d..cbf0f66fdc74 100644
> --- a/drivers/iio/addac/ad74413r.c
> +++ b/drivers/iio/addac/ad74413r.c
> @@ -39,6 +39,7 @@ struct ad74413r_chip_info {
>
> struct ad74413r_channel_config {
> u32 func;
> + u32 drive_strength;
> bool gpo_comparator;
> bool initialized;
> };
> @@ -111,6 +112,7 @@ struct ad74413r_state {
> #define AD74413R_REG_DIN_CONFIG_X(x) (0x09 + (x))
> #define AD74413R_DIN_DEBOUNCE_MASK GENMASK(4, 0)
> #define AD74413R_DIN_DEBOUNCE_LEN BIT(5)
> +#define AD74413R_DIN_SINK_MASK GENMASK(9, 6)
>
> #define AD74413R_REG_DAC_CODE_X(x) (0x16 + (x))
> #define AD74413R_DAC_CODE_MAX GENMASK(12, 0)
> @@ -261,6 +263,19 @@ static int ad74413r_set_comp_debounce(struct ad74413r_state *st,
> val);
> }
>
> +static int ad74413r_set_comp_drive_strength(struct ad74413r_state *st,
> + unsigned int offset,
> + unsigned int strength)
> +{
> + if (strength > 1800)
> + strength = 1800;
trivial but I think
strength = min(strength, 1800);
is perhaps a little more readable?
> +
> + return regmap_update_bits(st->regmap, AD74413R_REG_DIN_CONFIG_X(offset),
> + AD74413R_DIN_SINK_MASK,
> + FIELD_PREP(AD74413R_DIN_SINK_MASK, strength / 120));
> +}
> +
> +
> static void ad74413r_gpio_set(struct gpio_chip *chip,
> unsigned int offset, int val)
> {
> @@ -1190,6 +1205,9 @@ static int ad74413r_parse_channel_config(struct iio_dev *indio_dev,
> config->gpo_comparator = fwnode_property_read_bool(channel_node,
> "adi,gpo-comparator");
>
> + fwnode_property_read_u32(channel_node, "drive-strength-microamp",
> + &config->drive_strength);
> +
> if (!config->gpo_comparator)
> st->num_gpo_gpios++;
>
> @@ -1269,6 +1287,7 @@ static int ad74413r_setup_gpios(struct ad74413r_state *st)
> unsigned int gpo_gpio_i = 0;
> unsigned int i;
> u8 gpo_config;
> + u32 strength;
> int ret;
>
> for (i = 0; i < AD74413R_CHANNEL_MAX; i++) {
> @@ -1285,6 +1304,11 @@ static int ad74413r_setup_gpios(struct ad74413r_state *st)
> config->func == CH_FUNC_DIGITAL_INPUT_LOOP_POWER)
> st->comp_gpio_offsets[comp_gpio_i++] = i;
>
> + strength = config->drive_strength;
> + ret = ad74413r_set_comp_drive_strength(st, i, strength);
> + if (ret)
> + return ret;
> +
> ret = ad74413r_set_gpo_config(st, i, gpo_config);
> if (ret)
> return ret;
next prev parent reply other threads:[~2023-03-03 15:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-02 13:49 [PATCH 0/2] iio: ad74413r: allow setting sink current for digital input Rasmus Villemoes
2023-03-02 13:49 ` [PATCH 1/2] dt-bindings: " Rasmus Villemoes
2023-03-02 14:24 ` Rob Herring
2023-03-02 13:49 ` [PATCH 2/2] iio: ad74413r: wire up support for drive-strength-microamp property Rasmus Villemoes
2023-03-03 15:14 ` Jonathan Cameron [this message]
2023-03-06 9:42 ` [PATCH v2 0/2] iio: ad74413r: allow setting sink current for digital input Rasmus Villemoes
2023-03-06 9:43 ` [PATCH v2 1/2] dt-bindings: " Rasmus Villemoes
2023-03-07 8:53 ` Krzysztof Kozlowski
2023-03-06 9:43 ` [PATCH v2 2/2] iio: ad74413r: wire up support for drive-strength-microamp property Rasmus Villemoes
2023-03-12 15:48 ` [PATCH v2 0/2] iio: ad74413r: allow setting sink current for digital input Jonathan Cameron
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=20230303151438.00003842@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=cosmin.tanislav@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--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