From: David Lechner <dlechner@baylibre.com>
To: Eason Yang <j2anfernee@gmail.com>,
jic23@kernel.org, lars@metafoo.de, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com,
javier.carrasco.cruz@gmail.com, tgamblin@baylibre.com,
olivier.moysan@foss.st.com, alisadariana@gmail.com,
gstols@baylibre.com, antoniu.miclaus@analog.com,
eblanc@baylibre.com, andriy.shevchenko@linux.intel.com,
matteomartelli3@gmail.com, marcelo.schmitt@analog.com,
chanh@os.amperecomputing.com, KWLIU@nuvoton.com,
yhyang2@nuvoton.com
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 2/2] iio: adc: add support for Nuvoton NCT7201
Date: Tue, 29 Apr 2025 11:32:19 -0500 [thread overview]
Message-ID: <ad489cc7-8c89-44fa-bcec-5c4b9cbcab74@baylibre.com> (raw)
In-Reply-To: <20250429025505.3278016-3-j2anfernee@gmail.com>
On 4/28/25 9:55 PM, Eason Yang wrote:
> Add Nuvoton NCT7201/NCT7202 system voltage monitor 12-bit ADC driver
>
...
> +static int nct7201_init_chip(struct nct7201_chip_info *chip)
> +{
> + struct device *dev = regmap_get_device(chip->regmap);
> + __le16 data = cpu_to_le16(GENMASK(chip->num_vin_channels - 1, 0));
> + unsigned int value;
> + int err;
> +
> + err = regmap_write(chip->regmap, NCT7201_REG_CONFIGURATION,
> + NCT7201_BIT_CONFIGURATION_RESET);
> + if (err)
> + return dev_err_probe(dev, err, "Failed to reset chip\n");
> +
> + /*
> + * After about 25 msecs, the device should be ready and then the power-up
> + * bit will be set to 1. If not, wait for it.
> + */
> + fsleep(25 * USEC_PER_MSEC);
> +
> + err = regmap_read(chip->regmap, NCT7201_REG_BUSY_STATUS, &value);
> + if (err)
> + return dev_err_probe(dev, err, "Failed to read busy status\n");
> + if (!(value & NCT7201_BIT_PWR_UP))
> + return dev_err_probe(dev, -EIO, "Failed to power up after reset\n");
> +
> + /* Enable Channel */
> + if (chip->num_vin_channels <= 8)
> + err = regmap_write(chip->regmap, NCT7201_REG_CHANNEL_ENABLE,
> + GENMASK(chip->num_vin_channels - 1, 0));
> + else
> + err = regmap_bulk_write(chip->regmap, NCT7201_REG_CHANNEL_ENABLE,
> + &data, sizeof(data));
Why does this use little-endian format for data but the later bulk_read of the
same register uses CPU-endian?
> + if (err)
> + return dev_err_probe(dev, err, "Failed to enable channel\n");
> +
> + err = regmap_bulk_read(chip->regmap, NCT7201_REG_CHANNEL_ENABLE,
> + &chip->vin_mask, sizeof(chip->vin_mask));
> + if (err)
> + return dev_err_probe(dev, err,
> + "Failed to read channel enable register\n");
> +
> + /* Start monitoring if needed */
> + err = regmap_set_bits(chip->regmap, NCT7201_REG_CONFIGURATION,
> + NCT7201_BIT_CONFIGURATION_START);
> + if (err)
> + return dev_err_probe(dev, err, "Failed to start monitoring\n");
> +
> + return 0;
> +}
> +
next prev parent reply other threads:[~2025-04-29 16:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 2:55 [PATCH v8 0/2] iio: adc: add Nuvoton NCT7201 ADC driver Eason Yang
2025-04-29 2:55 ` [PATCH v8 1/2] dt-bindings: iio: adc: add NCT7201 ADCs Eason Yang
2025-04-29 7:36 ` Krzysztof Kozlowski
2025-04-29 16:09 ` David Lechner
2025-04-29 17:43 ` Krzysztof Kozlowski
2025-04-29 17:50 ` David Lechner
2025-04-29 2:55 ` [PATCH v8 2/2] iio: adc: add support for Nuvoton NCT7201 Eason Yang
2025-04-29 16:32 ` David Lechner [this message]
2025-05-02 9:23 ` Andy Shevchenko
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=ad489cc7-8c89-44fa-bcec-5c4b9cbcab74@baylibre.com \
--to=dlechner@baylibre.com \
--cc=KWLIU@nuvoton.com \
--cc=alisadariana@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=antoniu.miclaus@analog.com \
--cc=chanh@os.amperecomputing.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=eblanc@baylibre.com \
--cc=gstols@baylibre.com \
--cc=j2anfernee@gmail.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt@analog.com \
--cc=matteomartelli3@gmail.com \
--cc=nuno.sa@analog.com \
--cc=olivier.moysan@foss.st.com \
--cc=robh@kernel.org \
--cc=tgamblin@baylibre.com \
--cc=yhyang2@nuvoton.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: 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