From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: "Matti Vaittinen" <matti.vaittinen@fi.rohmeurope.com>,
"Matti Vaittinen" <matti.vaittinen@linux.dev>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
"Joshua Crofts" <joshua.crofts1@gmail.com>,
"Radu Sabau" <radu.sabau@analog.com>,
"Janani Sunil" <janani.sunil@analog.com>,
"Salih Erim" <salih.erim@amd.com>,
"Jishnu Prakash" <jishnu.prakash@oss.qualcomm.com>,
"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
"Jakub Szczudlo" <jakubszczudlo40@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: adc: rohm-bd79112: Support ROHM BD79111
Date: Thu, 19 Nov 2026 11:00:18 +0200 [thread overview]
Message-ID: <av66oui-2Pk1XOIi@ashevche-desk.local> (raw)
In-Reply-To: <ab74e547e892ccabb763a06e8231e8ed44f4fefb.1795009599.git.mazziesaccount@gmail.com>
On Wed, Nov 18, 2026 at 04:19:35PM +0200, Matti Vaittinen wrote:
>
> ROHM BD79111 is very similar to the BD79112. Both are ADC/GPIO devices,
> where pins can be configured to be either used as GPIO or ADC inputs.
> ADCs are 12-bit SAR ADCs and GPIOs support input/output but not being IRQ
> sources.
>
> The main difference is amount of channels/GPIOs. The BD79112 has 32 pins
> for this use, the BD79111 has 16. Furthermore, the BD79111 data-sheet
> promises 0.5 MSPS sample rate with maximum of 10 MHz SPI clock, whereas
> the BD79112 data-sheet mentioned 1MSPS rate with maximum of 20 MHz SPI
> clock.
>
> NOTE: In order to achieve those speeds one needs to use more optimized
> protocol compared to the one implemented in this driver. This driver
> retrieves samples using two 16-bit SPI transactions. The first
> transaction writes the channel to be sampled, and ignores data on MISO.
> Then the next 16-bit transaction carries the data.
>
> Achieving maximum sample-rate would require the driver to interpret the
> MISO data of each 16-bit transaction so, that when the
> channel-to-be-sampled was sent in transaction N, the data is read at
> transaction N+1 - which also already configures the channel to be
> sampled for transaction N+2. Supporting this would require the
> channel-to-be-read for the future read to be known when the current
> channel data is retrieved. For raw-reads this is not possible and for
> buffered reads it would make things a bit hairy.
>
> So, here we aim for simplicity instead of the peak performance.
...
> config ROHM_BD79112
> - tristate "Rohm BD79112 ADC driver"
> + tristate "ROHM BD79112 and BD79111 ADC/GPIO driver"
So, as Jonathan mentioned this should be rather relaxed, so we don't update it
each time the new HW is got supported. Also in a new style we want a bit of an
order by having this, text in top comment, and MODULE_DESCRIPTION() to be the
same (or very similar, like with or without word 'driver').
> depends on SPI && GPIOLIB
> select REGMAP_SPI
> select IIO_ADC_HELPER
> help
> - Say yes here to build support for the ROHM BD79112 ADC. The
> - ROHM BD79112 is a 12-bit, 32-channel, SAR ADC. Analog inputs
> - can also be used for GPIO.
> + Say yes here to build support for the ROHM BD79112 and BD79111
> + ADCs. Both of the ICs are 12-bit SAR ADCs. The ROHM BD79112 has
> + 32-channels, the BD79111 has 16. Analog inputs can also be used
> + for GPIO.
Yeah, and here the style is to have something like a list
Say yes here to build support for the following ROHM SAR ADCs:
- BD7911 (12-bit, 16 channels)
- BD7912 (12-bit, 32 channels)
Analog inputs can also be used for GPIO.
(feel free to amend, it's just an example).
...
> +static int bd79112_disable_gpios(struct bd79112_data *data)
> +{
> + unsigned int i;
> + int ret;
> + for (i = 0; i < BD79112_NUM_GPIO_EN_REGS; i++) {
for (unsigned int i = 0; i < BD79112_NUM_GPIO_EN_REGS; i++) {
> + ret = regmap_write(data->map, BD79112_FIRST_GPIO_EN_REG + i, 0);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
...
> +/* The BD79111 only has the registers for pins 0 - 15 */
> +static int bd79111_disable_gpios(struct bd79112_data *data)
> +{
> + static const unsigned int regs[] = {
> + BD79112_REG_GPI_EN_A8_A15, BD79112_REG_GPI_EN_A0_A7,
> + BD79112_REG_GPO_EN_A8_A15, BD79112_REG_GPO_EN_A0_A7,
> + };
> + unsigned int i;
> + int ret;
> + for (i = 0; i < ARRAY_SIZE(regs); i++) {
for (unsigned int i = 0; i < ARRAY_SIZE(regs); i++) {
> + ret = regmap_write(data->map, regs[i], 0);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
...
> data = iio_priv(iio_dev);
> + data->cd = spi_get_device_match_data(spi);
> + if (!data->cd)
> + return -ENODEV;
-ENODATA
...
> + data->gc.ngpio = data->cd->num_channels;
> + data->gc.label = devm_kasprintf(dev, GFP_KERNEL, "%s-gpio",
> + data->cd->name);
I would use a single line.
> + if (!data->gc.label)
> + return -ENOMEM;
...
> static const struct of_device_id bd79112_of_match[] = {
> - { .compatible = "rohm,bd79112" },
> + { .compatible = "rohm,bd79111", .data = &bd79111_chip_data },
> + { .compatible = "rohm,bd79112", .data = &bd79112_chip_data },
> { }
> };
So, this can be split to two patches:
- introduction of chip_info
- adding a new HW.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-11-19 9:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 14:18 [PATCH 0/2] Support ROHM BD79111 ADC/GPIO Matti Vaittinen
2026-11-18 14:19 ` [PATCH 1/2] dt-bindings: iio: Support ROHM BD79111 Matti Vaittinen
2026-11-18 17:37 ` Conor Dooley
2026-11-18 17:46 ` Matti Vaittinen
2026-11-18 14:19 ` [PATCH 2/2] iio: adc: rohm-bd79112: " Matti Vaittinen
2026-11-19 2:51 ` Jonathan Cameron
2026-11-19 7:13 ` Matti Vaittinen
2026-11-19 9:00 ` Andy Shevchenko [this message]
2026-11-19 9:09 ` Matti Vaittinen
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=av66oui-2Pk1XOIi@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=antoniu.miclaus@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jakubszczudlo40@gmail.com \
--cc=janani.sunil@analog.com \
--cc=jic23@kernel.org \
--cc=jishnu.prakash@oss.qualcomm.com \
--cc=joshua.crofts1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt@analog.com \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=matti.vaittinen@linux.dev \
--cc=mazziesaccount@gmail.com \
--cc=nuno.sa@analog.com \
--cc=radu.sabau@analog.com \
--cc=robh@kernel.org \
--cc=salih.erim@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: 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
all inboxes | Powered by JetHome®