Re: [PATCH 2/2] iio: adc: rohm-bd79112: Support ROHM BD79111

From: Matti Vaittinen

Date: Thu Nov 19 2026 - 02:13:48 EST


Hi & Thanks Jonathan!

On 19/11/2026 04:51, Jonathan Cameron wrote:
On Wed, 18 Nov 2026 16:19:35 +0200
Matti Vaittinen <matti.vaittinen@xxxxxxxxx> wrote:

From: Matti Vaittinen <mazziesaccount@xxxxxxxxx>

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.

FWIW there are quite a few drivers implementing that scheme for
buffered capture. Look for drivers that preprepare an SPI transfer.
Absolutely fine to not support that optimization!

This seems like text that probably applies to both parts rather than

Yes. This applies to both of these ADCs. And thanks for the pointer! Once again, I really appreciate your help. I will definitely take a look at how this is done by other ADCs. These two aren't the only (ROHM) ICs using this type of mechanism, so spending some time is well justified :)

being directly relevant to what is added here? If you did add that
support it would be in a different patch.

Sure.

I'd cut most of that info
to keep the commit message focused.

I kind of agree - while I also believe that noting the performance limitation coming from the driver itself makes sense. It does not need to be this verbose though. Besides, the verbosity already worked as it made you to drop me the above info ;)
//snip

static const struct gpio_chip bd79112_gpio_chip = {
- .label = "bd79112-gpio",
.get_direction = bd79112_gpio_dir_get,
.direction_input = bd79112_gpio_input,
.direction_output = bd79112_gpio_output,
@@ -378,20 +387,20 @@ static const struct gpio_chip bd79112_gpio_chip = {
.set_multiple = bd79112_gpio_set_multiple,
.init_valid_mask = bd79112_gpio_init_valid_mask,
.can_sleep = true,
- .ngpio = 32,
.base = -1,
};

There are only two parts, maybe it is simpler to have dual gpio_chip
instances pointed to by your chip_data? Keep the full state of each in
one place? I don't mind much either way on this.

I didn't even evaluate such option. I'll try it out and see how it looks like.

I agree with all other comments - even though declaring the indexer variable in a for-loop requires a bit of learning ;) (Which doesn't mean limiting the scope didn't make sense when index is not used outside the loop).

Thanks!



--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~