* [PATCH v2 0/3] Support ROHM BD79111 ADC/GPIO
@ 2026-11-20 12:26 Matti Vaittinen
2026-11-20 12:27 ` [PATCH v2 1/3] dt-bindings: iio: Support ROHM BD79111 Matti Vaittinen
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Matti Vaittinen @ 2026-11-20 12:26 UTC (permalink / raw)
To: Matti Vaittinen, Matti Vaittinen, Matti Vaittinen
Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matti Vaittinen,
Marcelo Schmitt, Joshua Crofts, Radu Sabau, Janani Sunil,
Salih Erim, Jishnu Prakash, Antoniu Miclaus, Jakub Szczudlo,
linux-iio, devicetree, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]
Support ROHM BD79111 ADC/GPIO
The ROHM BD79111 is a 12-bit, 16 channel SAR ADC / GPIO IC. Or, a "Signal
Monitor Hub IC" as data-sheet describes it. The key difference compared
to already supported BD79112 is the reduced number of channels (16,
BD79112 had 32) and halved sampling rate (500 KSPS when BD79112
data-sheet stated 1 MSPS).
Revision history:
v1 => v2:
dt-bindings:
- Don't drop the 'root-level' additionalProperties: false
driver + Kconfig:
- Styling as suggested by Andy / Jonathan
- Split to two patches as suggested by Andy
- Return -ENODATA instead of -ENODEV when no SPI match data is found
Matti Vaittinen (3):
dt-bindings: iio: Support ROHM BD79111
iio: adc: rohm-bd79112: Add chip info structure
iio: adc: rohm-bd79112: Support ROHM BD79111
.../bindings/iio/adc/rohm,bd79112.yaml | 29 ++++-
drivers/iio/adc/Kconfig | 10 +-
drivers/iio/adc/rohm-bd79112.c | 112 ++++++++++++++----
3 files changed, 121 insertions(+), 30 deletions(-)
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.56.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH v2 1/3] dt-bindings: iio: Support ROHM BD79111 2026-11-20 12:26 [PATCH v2 0/3] Support ROHM BD79111 ADC/GPIO Matti Vaittinen @ 2026-11-20 12:27 ` Matti Vaittinen 2026-11-20 17:39 ` Conor Dooley 2026-11-20 12:28 ` [PATCH v2 2/3] iio: adc: rohm-bd79112: Add chip info structure Matti Vaittinen 2026-11-20 12:28 ` [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 Matti Vaittinen 2 siblings, 1 reply; 11+ messages in thread From: Matti Vaittinen @ 2026-11-20 12:27 UTC (permalink / raw) To: Matti Vaittinen, Matti Vaittinen, Matti Vaittinen Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matti Vaittinen, Marcelo Schmitt, Joshua Crofts, Radu Sabau, Janani Sunil, Salih Erim, Jishnu Prakash, Antoniu Miclaus, Jakub Szczudlo, linux-iio, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 2684 bytes --] From: Matti Vaittinen <mazziesaccount@gmail.com> 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. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> --- Revision history: v1 => v2: Disallow additional properties again --- .../bindings/iio/adc/rohm,bd79112.yaml | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/rohm,bd79112.yaml b/Documentation/devicetree/bindings/iio/adc/rohm,bd79112.yaml index aa8b07c3fac1..a0fd87716611 100644 --- a/Documentation/devicetree/bindings/iio/adc/rohm,bd79112.yaml +++ b/Documentation/devicetree/bindings/iio/adc/rohm,bd79112.yaml @@ -4,18 +4,21 @@ $id: http://devicetree.org/schemas/iio/adc/rohm,bd79112.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: ROHM BD79112 ADC/GPO +title: ROHM BD79111 and BD79112 ADC/GPIO maintainers: - Matti Vaittinen <mazziesaccount@gmail.com> description: | - The ROHM BD79112 is a 12-bit, 32-channel, SAR ADC. ADC input pins can be - also configured as general purpose inputs/outputs. SPI should use MODE 3. + The ROHM BD79112 is a 12-bit, 32-channel, SAR ADC. The ROHM BD79111 is + a 12-bit, 16-channel, SAR ADC. ADC input pins can be also configured as + general purpose inputs/outputs. SPI should use MODE 3. properties: compatible: - const: rohm,bd79112 + enum: + - rohm,bd79111 + - rohm,bd79112 reg: maxItems: 1 @@ -45,7 +48,9 @@ patternProperties: properties: reg: - description: AIN pin number + description: + AIN pin number. The BD79111 has pins 0 - 15, the BD79112 has pins + 0 - 31. minimum: 0 maximum: 31 @@ -64,6 +69,20 @@ required: additionalProperties: false +allOf: + - if: + properties: + compatible: + contains: + const: rohm,bd79111 + then: + patternProperties: + "^channel@([0-9]|1[0-5])$": + properties: + reg: + maximum: 15 + "^channel@(1[6-9]|2[0-9]|3[01])$": false + examples: - | spi { -- 2.56.1 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: iio: Support ROHM BD79111 2026-11-20 12:27 ` [PATCH v2 1/3] dt-bindings: iio: Support ROHM BD79111 Matti Vaittinen @ 2026-11-20 17:39 ` Conor Dooley 0 siblings, 0 replies; 11+ messages in thread From: Conor Dooley @ 2026-11-20 17:39 UTC (permalink / raw) To: Matti Vaittinen Cc: Matti Vaittinen, Matti Vaittinen, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Marcelo Schmitt, Joshua Crofts, Radu Sabau, Janani Sunil, Salih Erim, Jishnu Prakash, Antoniu Miclaus, Jakub Szczudlo, linux-iio, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 995 bytes --] On Fri, Nov 20, 2026 at 02:27:02PM +0200, Matti Vaittinen wrote: > From: Matti Vaittinen <mazziesaccount@gmail.com> > > 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. > > Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> > > --- > Revision history: > v1 => v2: > Disallow additional properties again Acked-by: Conor Dooley <conor.dooley@microchip.com> pw-bot: not-applicable fyi, changelog isnt quite right, but in this case I don't actually need it so it is moot. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/3] iio: adc: rohm-bd79112: Add chip info structure 2026-11-20 12:26 [PATCH v2 0/3] Support ROHM BD79111 ADC/GPIO Matti Vaittinen 2026-11-20 12:27 ` [PATCH v2 1/3] dt-bindings: iio: Support ROHM BD79111 Matti Vaittinen @ 2026-11-20 12:28 ` Matti Vaittinen 2026-11-20 14:36 ` Andy Shevchenko 2026-11-20 12:28 ` [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 Matti Vaittinen 2 siblings, 1 reply; 11+ messages in thread From: Matti Vaittinen @ 2026-11-20 12:28 UTC (permalink / raw) To: Matti Vaittinen, Matti Vaittinen, Matti Vaittinen Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matti Vaittinen, Marcelo Schmitt, Joshua Crofts, Radu Sabau, Janani Sunil, Salih Erim, Jishnu Prakash, Antoniu Miclaus, Jakub Szczudlo, linux-iio, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 3966 bytes --] From: Matti Vaittinen <mazziesaccount@gmail.com> A new ADC variant, ROHM BD79111 is going to be supported by this same driver. As a preparatory step, introduce chip-specific data and pick it at probe time based on the spi-match data. This allows describing the necessary hardware differencies in data structures, which tends to result cleaner solution than some CHIP_ID specific switch-case blocks. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> --- Revision history: v1 => v2: - Split the chip-ID introduction into own patch as suggested by Andy. --- drivers/iio/adc/rohm-bd79112.c | 45 +++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/rohm-bd79112.c b/drivers/iio/adc/rohm-bd79112.c index 2506fec7be84..04084e88984a 100644 --- a/drivers/iio/adc/rohm-bd79112.c +++ b/drivers/iio/adc/rohm-bd79112.c @@ -26,7 +26,15 @@ #define BD79112_MAX_NUM_CHANNELS 32 +struct bd79112_data; + +struct bd7911x_chip_data { + const char * const *chan_names; + int (*init_disable_gpios)(struct bd79112_data *data); +}; + struct bd79112_data { + const struct bd7911x_chip_data *cd; struct spi_device *spi; struct regmap *map; struct device *dev; @@ -398,6 +406,19 @@ static unsigned int bd79112_get_gpio_pins(const struct iio_chan_spec *cs, int nu return gpio_channels; } +static int bd79112_disable_gpios(struct bd79112_data *data) +{ + int ret; + + 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; +} + /* ADC channels as named in the data-sheet */ static const char * const bd79112_chan_names[] = { "AGIO0A", "AGIO1A", "AGIO2A", "AGIO3A", /* 0 - 3 */ @@ -410,6 +431,11 @@ static const char * const bd79112_chan_names[] = { "AGIO12B", "AGIO13B", "AGIO14B", "AGIO15B", /* 28 - 31 */ }; +static const struct bd7911x_chip_data bd79112_chip_data = { + .chan_names = bd79112_chan_names, + .init_disable_gpios = bd79112_disable_gpios, +}; + static int bd79112_probe(struct spi_device *spi) { struct bd79112_data *data; @@ -425,6 +451,10 @@ static int bd79112_probe(struct spi_device *spi) return -ENOMEM; data = iio_priv(iio_dev); + data->cd = spi_get_device_match_data(spi); + if (!data->cd) + return -ENODEV; + data->spi = spi; data->dev = dev; data->map = devm_regmap_init(dev, NULL, data, &bd79112_regmap); @@ -476,7 +506,7 @@ static int bd79112_probe(struct spi_device *spi) iio_dev->channels = cs; for (i = 0; i < iio_dev->num_channels; i++) - cs[i].datasheet_name = bd79112_chan_names[cs[i].channel]; + cs[i].datasheet_name = data->cd->chan_names[cs[i].channel]; iio_dev->info = &bd79112_info; iio_dev->name = "bd79112"; @@ -488,12 +518,9 @@ static int bd79112_probe(struct spi_device *spi) * without having to worry about some pins being initially used for * GPIO. */ - for (i = 0; i < BD79112_NUM_GPIO_EN_REGS; i++) { - ret = regmap_write(data->map, BD79112_FIRST_GPIO_EN_REG + i, 0); - if (ret) - return dev_err_probe(dev, ret, - "Failed to initialize channels\n"); - } + ret = data->cd->init_disable_gpios(data); + if (ret) + return dev_err_probe(dev, ret, "Failed to initialize channels\n"); ret = devm_iio_device_register(data->dev, iio_dev); if (ret) @@ -523,13 +550,13 @@ static int bd79112_probe(struct spi_device *spi) } static const struct of_device_id bd79112_of_match[] = { - { .compatible = "rohm,bd79112" }, + { .compatible = "rohm,bd79112", .data = &bd79112_chip_data }, { } }; MODULE_DEVICE_TABLE(of, bd79112_of_match); static const struct spi_device_id bd79112_id[] = { - { .name = "bd79112" }, + { .name = "bd79112", .driver_data = (kernel_ulong_t)&bd79112_chip_data }, { } }; MODULE_DEVICE_TABLE(spi, bd79112_id); -- 2.56.1 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/3] iio: adc: rohm-bd79112: Add chip info structure 2026-11-20 12:28 ` [PATCH v2 2/3] iio: adc: rohm-bd79112: Add chip info structure Matti Vaittinen @ 2026-11-20 14:36 ` Andy Shevchenko 0 siblings, 0 replies; 11+ messages in thread From: Andy Shevchenko @ 2026-11-20 14:36 UTC (permalink / raw) To: Matti Vaittinen Cc: Matti Vaittinen, Matti Vaittinen, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Marcelo Schmitt, Joshua Crofts, Radu Sabau, Janani Sunil, Salih Erim, Jishnu Prakash, Antoniu Miclaus, Jakub Szczudlo, linux-iio, devicetree, linux-kernel On Fri, Nov 20, 2026 at 02:28:00PM +0200, Matti Vaittinen wrote: > > A new ADC variant, ROHM BD79111 is going to be supported by this same > driver. As a preparatory step, introduce chip-specific data and pick it > at probe time based on the spi-match data. This allows describing the > necessary hardware differencies in data structures, which tends to > result cleaner solution than some CHIP_ID specific switch-case blocks. ... > + data->cd = spi_get_device_match_data(spi); > + if (!data->cd) > + return -ENODEV; ENODATA ... Otherwise LGTM, Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 2026-11-20 12:26 [PATCH v2 0/3] Support ROHM BD79111 ADC/GPIO Matti Vaittinen 2026-11-20 12:27 ` [PATCH v2 1/3] dt-bindings: iio: Support ROHM BD79111 Matti Vaittinen 2026-11-20 12:28 ` [PATCH v2 2/3] iio: adc: rohm-bd79112: Add chip info structure Matti Vaittinen @ 2026-11-20 12:28 ` Matti Vaittinen 2026-11-20 12:34 ` sashiko-bot 2026-11-20 14:44 ` Andy Shevchenko 2 siblings, 2 replies; 11+ messages in thread From: Matti Vaittinen @ 2026-11-20 12:28 UTC (permalink / raw) To: Matti Vaittinen, Matti Vaittinen, Matti Vaittinen Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matti Vaittinen, Marcelo Schmitt, Joshua Crofts, Radu Sabau, Janani Sunil, Salih Erim, Jishnu Prakash, Antoniu Miclaus, Jakub Szczudlo, linux-iio, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 8443 bytes --] From: Matti Vaittinen <mazziesaccount@gmail.com> 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. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> --- Revision history: v1 => v2: - Various styling fixes as suggested by Jonathan and Andy - Return -ENODATA instead of -ENODEV when SPI match data is not available. --- drivers/iio/adc/Kconfig | 10 +++-- drivers/iio/adc/rohm-bd79112.c | 69 +++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index a802d8ee4dd9..78562e6c62f5 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1516,14 +1516,16 @@ config RN5T618_ADC will be called rn5t618-adc. config ROHM_BD79112 - tristate "Rohm BD79112 ADC driver" + tristate "ADC/GPIO Driver for ROHM BD79112 et al." 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 following ROHM SAR ADCs: + - BD79111 (12-bit, 16 channels) + - BD79112 (12-bit, 32 channels) + + Analog inputs can also be used for GPIO. config ROHM_BD79124 tristate "Rohm BD79124 ADC driver" diff --git a/drivers/iio/adc/rohm-bd79112.c b/drivers/iio/adc/rohm-bd79112.c index 04084e88984a..8bbb86098ff5 100644 --- a/drivers/iio/adc/rohm-bd79112.c +++ b/drivers/iio/adc/rohm-bd79112.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * ROHM ADC driver for BD79112 signal monitoring hub. + * ROHM ADC/GPIO driver for BD79112 and similar signal monitoring hubs. * Copyright (C) 2025, ROHM Semiconductor. * * SPI communication derived from ad7923.c and ti-ads7950.c @@ -29,7 +29,9 @@ struct bd79112_data; struct bd7911x_chip_data { + const char *name; const char * const *chan_names; + unsigned int num_max_channels; int (*init_disable_gpios)(struct bd79112_data *data); }; @@ -377,7 +379,6 @@ static int bd79112_gpio_output(struct gpio_chip *gc, unsigned int offset, } 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, @@ -386,26 +387,44 @@ 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, }; -static unsigned int bd79112_get_gpio_pins(const struct iio_chan_spec *cs, int num_channels) +static unsigned int bd79112_get_gpio_pins(const struct iio_chan_spec *cs, + int num_channels, int max_channels) { unsigned int i, gpio_channels; /* - * Let's initialize the mux config to say that all 32 channels are + * Let's initialize the mux config to say that all channels are * GPIOs. Then we can just loop through the iio_chan_spec and clear the * bits for found ADC channels. */ - gpio_channels = GENMASK(31, 0); + gpio_channels = GENMASK(max_channels - 1, 0); for (i = 0; i < num_channels; i++) gpio_channels &= ~BIT(cs[i].channel); return gpio_channels; } +/* 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, + }; + int ret; + + for (unsigned int i = 0; i < ARRAY_SIZE(regs); i++) { + ret = regmap_write(data->map, regs[i], 0); + if (ret) + return ret; + } + + return 0; +} + static int bd79112_disable_gpios(struct bd79112_data *data) { int ret; @@ -419,7 +438,15 @@ static int bd79112_disable_gpios(struct bd79112_data *data) return 0; } -/* ADC channels as named in the data-sheet */ +/* The BD79111 channel names as in the data-sheet */ +static const char * const bd79111_chan_names[] = { + "AGIO0", "AGIO1", "AGIO2", "AGIO3", /* 0 - 3 */ + "AGIO4", "AGIO5", "AGIO6", "AGIO7", /* 4 - 7 */ + "AGIO8", "AGIO9", "AGIO10", "AGIO11", /* 8 - 11 */ + "AGIO12", "AGIO13", "AGIO14", "AGIO15", /* 12 - 15 */ +}; + +/* The BD79112 channel name as in the data-sheet */ static const char * const bd79112_chan_names[] = { "AGIO0A", "AGIO1A", "AGIO2A", "AGIO3A", /* 0 - 3 */ "AGIO4A", "AGIO5A", "AGIO6A", "AGIO7A", /* 4 - 7 */ @@ -431,8 +458,17 @@ static const char * const bd79112_chan_names[] = { "AGIO12B", "AGIO13B", "AGIO14B", "AGIO15B", /* 28 - 31 */ }; +static const struct bd7911x_chip_data bd79111_chip_data = { + .name = "bd79111", + .chan_names = bd79111_chan_names, + .num_max_channels = 16, + .init_disable_gpios = bd79111_disable_gpios, +}; + static const struct bd7911x_chip_data bd79112_chip_data = { + .name = "bd79112", .chan_names = bd79112_chan_names, + .num_max_channels = 32, .init_disable_gpios = bd79112_disable_gpios, }; @@ -453,7 +489,7 @@ static int bd79112_probe(struct spi_device *spi) data = iio_priv(iio_dev); data->cd = spi_get_device_match_data(spi); if (!data->cd) - return -ENODEV; + return -ENODATA; data->spi = spi; data->dev = dev; @@ -492,7 +528,7 @@ static int bd79112_probe(struct spi_device *spi) "Failed to optimize SPI write message\n"); ret = devm_iio_adc_device_alloc_chaninfo_se(dev, &bd79112_chan_template, - BD79112_MAX_NUM_CHANNELS - 1, + data->cd->num_max_channels - 1, &cs); /* Register all pins as GPIOs if there are no ADC channels */ @@ -509,7 +545,7 @@ static int bd79112_probe(struct spi_device *spi) cs[i].datasheet_name = data->cd->chan_names[cs[i].channel]; iio_dev->info = &bd79112_info; - iio_dev->name = "bd79112"; + iio_dev->name = data->cd->name;; iio_dev->modes = INDIO_DIRECT_MODE; /* @@ -528,14 +564,15 @@ static int bd79112_probe(struct spi_device *spi) register_gpios: gpio_pins = bd79112_get_gpio_pins(iio_dev->channels, - iio_dev->num_channels); + iio_dev->num_channels, + data->cd->num_max_channels); /* If all channels are reserved for ADC, then we're done. */ if (!gpio_pins) return 0; /* Default all the GPIO pins to GPI */ - for_each_set_bit(pin, &gpio_pins, BD79112_MAX_NUM_CHANNELS) { + for_each_set_bit(pin, &gpio_pins, data->cd->num_max_channels) { ret = bd79112_gpio_dir_set(data, pin, GPIO_LINE_DIRECTION_IN); if (ret) return dev_err_probe(dev, ret, @@ -545,17 +582,23 @@ static int bd79112_probe(struct spi_device *spi) data->gpio_valid_mask = gpio_pins; data->gc = bd79112_gpio_chip; data->gc.parent = dev; + data->gc.ngpio = data->cd->num_max_channels; + data->gc.label = devm_kasprintf(dev, GFP_KERNEL, "%s-gpio", data->cd->name); + if (!data->gc.label) + return -ENOMEM; return devm_gpiochip_add_data(dev, &data->gc, data); } static const struct of_device_id bd79112_of_match[] = { + { .compatible = "rohm,bd79111", .data = &bd79111_chip_data }, { .compatible = "rohm,bd79112", .data = &bd79112_chip_data }, { } }; MODULE_DEVICE_TABLE(of, bd79112_of_match); static const struct spi_device_id bd79112_id[] = { + { .name = "bd79111", .driver_data = (kernel_ulong_t)&bd79111_chip_data }, { .name = "bd79112", .driver_data = (kernel_ulong_t)&bd79112_chip_data }, { } }; @@ -572,6 +615,6 @@ static struct spi_driver bd79112_driver = { module_spi_driver(bd79112_driver); MODULE_AUTHOR("Matti Vaittinen <mazziesaccount@gmail.com>"); -MODULE_DESCRIPTION("Driver for ROHM BD79112 ADC/GPIO"); +MODULE_DESCRIPTION("ADC/GPIO Driver for ROHM BD79112 et al."); MODULE_LICENSE("GPL"); MODULE_IMPORT_NS("IIO_DRIVER"); -- 2.56.1 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 2026-11-20 12:28 ` [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 Matti Vaittinen @ 2026-11-20 12:34 ` sashiko-bot 2026-11-20 12:53 ` Matti Vaittinen 2026-11-20 14:44 ` Andy Shevchenko 1 sibling, 1 reply; 11+ messages in thread From: sashiko-bot @ 2026-11-20 12:34 UTC (permalink / raw) To: Matti Vaittinen; +Cc: devicetree, robh, conor+dt Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Low] iio: adc: rohm-bd79112: double semicolon in bd79112_probe() - [Low] iio: adc: rohm-bd79112: unused BD79112_MAX_NUM_CHANNELS macro -- commit d2b6757018d5ccee4c939ad0350d93a29d26239d Author: Matti Vaittinen <mazziesaccount@gmail.com> iio: adc: rohm-bd79112: Support ROHM BD79111 This commit adds support for the 16-channel ROHM BD79111 SAR ADC and GPIO device to the rohm-bd79112 driver. > diff --git a/drivers/iio/adc/rohm-bd79112.c b/drivers/iio/adc/rohm-bd79112.c > index 04084e88984a5..8bbb86098ff5a 100644 > --- a/drivers/iio/adc/rohm-bd79112.c > +++ b/drivers/iio/adc/rohm-bd79112.c [ ... ] > @@ -431,8 +458,17 @@ static const char * const bd79112_chan_names[] = { > "AGIO12B", "AGIO13B", "AGIO14B", "AGIO15B", /* 28 - 31 */ > }; > > +static const struct bd7911x_chip_data bd79111_chip_data = { > + .name = "bd79111", > + .chan_names = bd79111_chan_names, > + .num_max_channels = 16, > + .init_disable_gpios = bd79111_disable_gpios, > +}; > + > static const struct bd7911x_chip_data bd79112_chip_data = { > + .name = "bd79112", > .chan_names = bd79112_chan_names, > + .num_max_channels = 32, > .init_disable_gpios = bd79112_disable_gpios, > }; [Severity: Low] This isn't a bug, but replacing the remaining uses of BD79112_MAX_NUM_CHANNELS in bd79112_probe() with data->cd->num_max_channels leaves the BD79112_MAX_NUM_CHANNELS macro unused. [ ... ] > @@ -509,7 +545,7 @@ static int bd79112_probe(struct spi_device *spi) > cs[i].datasheet_name = data->cd->chan_names[cs[i].channel]; > > iio_dev->info = &bd79112_info; > - iio_dev->name = "bd79112"; > + iio_dev->name = data->cd->name;; > iio_dev->modes = INDIO_DIRECT_MODE; [Severity: Low] This isn't a bug, but there is a double semicolon at the end of this assignment. -- Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795176984.git.mazziesaccount@gmail.com?part=3 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 2026-11-20 12:34 ` sashiko-bot @ 2026-11-20 12:53 ` Matti Vaittinen 2026-11-21 1:59 ` Jonathan Cameron 0 siblings, 1 reply; 11+ messages in thread From: Matti Vaittinen @ 2026-11-20 12:53 UTC (permalink / raw) To: sashiko-reviews; +Cc: devicetree, robh, conor+dt, Jonathan Cameron, open list On 20/11/2026 14:34, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issues to consider: > - [Low] iio: adc: rohm-bd79112: double semicolon in bd79112_probe() > - [Low] iio: adc: rohm-bd79112: unused BD79112_MAX_NUM_CHANNELS macro > -- > > commit d2b6757018d5ccee4c939ad0350d93a29d26239d > Author: Matti Vaittinen <mazziesaccount@gmail.com> > > iio: adc: rohm-bd79112: Support ROHM BD79111 > > This commit adds support for the 16-channel ROHM BD79111 SAR ADC and GPIO > device to the rohm-bd79112 driver. > >> diff --git a/drivers/iio/adc/rohm-bd79112.c b/drivers/iio/adc/rohm-bd79112.c >> index 04084e88984a5..8bbb86098ff5a 100644 >> --- a/drivers/iio/adc/rohm-bd79112.c >> +++ b/drivers/iio/adc/rohm-bd79112.c > > [ ... ] > >> @@ -431,8 +458,17 @@ static const char * const bd79112_chan_names[] = { >> "AGIO12B", "AGIO13B", "AGIO14B", "AGIO15B", /* 28 - 31 */ >> }; >> >> +static const struct bd7911x_chip_data bd79111_chip_data = { >> + .name = "bd79111", >> + .chan_names = bd79111_chan_names, >> + .num_max_channels = 16, >> + .init_disable_gpios = bd79111_disable_gpios, >> +}; >> + >> static const struct bd7911x_chip_data bd79112_chip_data = { >> + .name = "bd79112", >> .chan_names = bd79112_chan_names, >> + .num_max_channels = 32, >> .init_disable_gpios = bd79112_disable_gpios, >> }; > > [Severity: Low] > This isn't a bug, but replacing the remaining uses of > BD79112_MAX_NUM_CHANNELS in bd79112_probe() with > data->cd->num_max_channels leaves the BD79112_MAX_NUM_CHANNELS macro > unused. > > [ ... ] > >> @@ -509,7 +545,7 @@ static int bd79112_probe(struct spi_device *spi) >> cs[i].datasheet_name = data->cd->chan_names[cs[i].channel]; >> >> iio_dev->info = &bd79112_info; >> - iio_dev->name = "bd79112"; >> + iio_dev->name = data->cd->name;; >> iio_dev->modes = INDIO_DIRECT_MODE; > > [Severity: Low] > This isn't a bug, but there is a double semicolon at the end of this > assignment. > Both of the Sashiko's findings seem correct. However, I wonder why it picked the device-tree folks and dropped IIO people? This particular patch didn't have binding changes but driver changes. (Well I added Jonathan + IIO-list here) Yours, -- Matti -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 2026-11-20 12:53 ` Matti Vaittinen @ 2026-11-21 1:59 ` Jonathan Cameron 0 siblings, 0 replies; 11+ messages in thread From: Jonathan Cameron @ 2026-11-21 1:59 UTC (permalink / raw) To: Matti Vaittinen Cc: mazziesaccount, sashiko-reviews, devicetree, robh, conor+dt, open list On Fri, 20 Nov 2026 14:53:32 +0200 Matti Vaittinen <matti.vaittinen@linux.dev> wrote: > On 20/11/2026 14:34, sashiko-bot@kernel.org wrote: > > Thank you for your contribution! Sashiko AI review found 2 potential > > issues to consider: > > - [Low] iio: adc: rohm-bd79112: double semicolon in bd79112_probe() > > - [Low] iio: adc: rohm-bd79112: unused BD79112_MAX_NUM_CHANNELS macro > > -- > > > > commit d2b6757018d5ccee4c939ad0350d93a29d26239d > > Author: Matti Vaittinen <mazziesaccount@gmail.com> > > > > iio: adc: rohm-bd79112: Support ROHM BD79111 > > > > This commit adds support for the 16-channel ROHM BD79111 SAR ADC and GPIO > > device to the rohm-bd79112 driver. > > > >> diff --git a/drivers/iio/adc/rohm-bd79112.c b/drivers/iio/adc/rohm-bd79112.c > >> index 04084e88984a5..8bbb86098ff5a 100644 > >> --- a/drivers/iio/adc/rohm-bd79112.c > >> +++ b/drivers/iio/adc/rohm-bd79112.c > > > > [ ... ] > > > >> @@ -431,8 +458,17 @@ static const char * const bd79112_chan_names[] = { > >> "AGIO12B", "AGIO13B", "AGIO14B", "AGIO15B", /* 28 - 31 */ > >> }; > >> > >> +static const struct bd7911x_chip_data bd79111_chip_data = { > >> + .name = "bd79111", > >> + .chan_names = bd79111_chan_names, > >> + .num_max_channels = 16, > >> + .init_disable_gpios = bd79111_disable_gpios, > >> +}; > >> + > >> static const struct bd7911x_chip_data bd79112_chip_data = { > >> + .name = "bd79112", > >> .chan_names = bd79112_chan_names, > >> + .num_max_channels = 32, > >> .init_disable_gpios = bd79112_disable_gpios, > >> }; > > > > [Severity: Low] > > This isn't a bug, but replacing the remaining uses of > > BD79112_MAX_NUM_CHANNELS in bd79112_probe() with > > data->cd->num_max_channels leaves the BD79112_MAX_NUM_CHANNELS macro > > unused. > > > > [ ... ] > > > >> @@ -509,7 +545,7 @@ static int bd79112_probe(struct spi_device *spi) > >> cs[i].datasheet_name = data->cd->chan_names[cs[i].channel]; > >> > >> iio_dev->info = &bd79112_info; > >> - iio_dev->name = "bd79112"; > >> + iio_dev->name = data->cd->name;; > >> iio_dev->modes = INDIO_DIRECT_MODE; > > > > [Severity: Low] > > This isn't a bug, but there is a double semicolon at the end of this > > assignment. > > > > Both of the Sashiko's findings seem correct. However, I wonder why it > picked the device-tree folks and dropped IIO people? This particular > patch didn't have binding changes but driver changes. (Well I added > Jonathan + IIO-list here) Currently we haven't opted in to received emails to linux-iio but device tree folk have. There was some debate at LPC on what sashiko should do when this happens but there isn't really a right answer. If things ever quieten down I'll restart the discussion of whether we should opt IIO in. I'm personally in favour but want to here if anyone has a strong counter argument. I think we can manage the false positives for newbies issue as they are getting smaller all the time. Jonathan > > Yours, > -- Matti > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 2026-11-20 12:28 ` [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 Matti Vaittinen 2026-11-20 12:34 ` sashiko-bot @ 2026-11-20 14:44 ` Andy Shevchenko 2026-11-21 2:01 ` Jonathan Cameron 1 sibling, 1 reply; 11+ messages in thread From: Andy Shevchenko @ 2026-11-20 14:44 UTC (permalink / raw) To: Matti Vaittinen Cc: Matti Vaittinen, Matti Vaittinen, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Marcelo Schmitt, Joshua Crofts, Radu Sabau, Janani Sunil, Salih Erim, Jishnu Prakash, Antoniu Miclaus, Jakub Szczudlo, linux-iio, devicetree, linux-kernel On Fri, Nov 20, 2026 at 02:28:28PM +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. ... > - Return -ENODATA instead of -ENODEV when SPI match data is not > available. I guess you were distracted by something, the error code is now introduced in the very previous patch, fix it there. ... > - tristate "Rohm BD79112 ADC driver" > + tristate "ADC/GPIO Driver for ROHM BD79112 et al." > - * ROHM ADC driver for BD79112 signal monitoring hub. > + * ROHM ADC/GPIO driver for BD79112 and similar signal monitoring hubs. Can this text be modified to be closer to the other two? Something like: * ADC/GPIO Driver for ROHM BD79112 and similar signal monitoring hubs. > -MODULE_DESCRIPTION("Driver for ROHM BD79112 ADC/GPIO"); > +MODULE_DESCRIPTION("ADC/GPIO Driver for ROHM BD79112 et al."); ... Otherwise LGTM, Reviewed-by; Andy Shevchenko <andriy.shevchenko@intel.com> -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 2026-11-20 14:44 ` Andy Shevchenko @ 2026-11-21 2:01 ` Jonathan Cameron 0 siblings, 0 replies; 11+ messages in thread From: Jonathan Cameron @ 2026-11-21 2:01 UTC (permalink / raw) To: Andy Shevchenko Cc: Matti Vaittinen, Matti Vaittinen, Matti Vaittinen, David Lechner, Nuno Sá, Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Marcelo Schmitt, Joshua Crofts, Radu Sabau, Janani Sunil, Salih Erim, Jishnu Prakash, Antoniu Miclaus, Jakub Szczudlo, linux-iio, devicetree, linux-kernel On Fri, 20 Nov 2026 16:44:38 +0200 Andy Shevchenko <andriy.shevchenko@intel.com> wrote: > On Fri, Nov 20, 2026 at 02:28:28PM +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. > > ... > > > - Return -ENODATA instead of -ENODEV when SPI match data is not > > available. > > I guess you were distracted by something, the error code is now introduced in > the very previous patch, fix it there. > > ... > > > - tristate "Rohm BD79112 ADC driver" > > + tristate "ADC/GPIO Driver for ROHM BD79112 et al." > > > - * ROHM ADC driver for BD79112 signal monitoring hub. > > + * ROHM ADC/GPIO driver for BD79112 and similar signal monitoring hubs. > > Can this text be modified to be closer to the other two? > Something like: > > * ADC/GPIO Driver for ROHM BD79112 and similar signal monitoring hubs. I had nothing to add and nearly picked it up with tweaks. Given this is something you may well want to feedback on (or adopt as is!) I decided to ask for a v3. Given this is small and in a clean state, send it whenever you are ready - no need to wait a week in this case. Thanks, Jonathan > > > -MODULE_DESCRIPTION("Driver for ROHM BD79112 ADC/GPIO"); > > +MODULE_DESCRIPTION("ADC/GPIO Driver for ROHM BD79112 et al."); > > ... > > Otherwise LGTM, > Reviewed-by; Andy Shevchenko <andriy.shevchenko@intel.com> > ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-21 2:01 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-20 12:26 [PATCH v2 0/3] Support ROHM BD79111 ADC/GPIO Matti Vaittinen 2026-11-20 12:27 ` [PATCH v2 1/3] dt-bindings: iio: Support ROHM BD79111 Matti Vaittinen 2026-11-20 17:39 ` Conor Dooley 2026-11-20 12:28 ` [PATCH v2 2/3] iio: adc: rohm-bd79112: Add chip info structure Matti Vaittinen 2026-11-20 14:36 ` Andy Shevchenko 2026-11-20 12:28 ` [PATCH v2 3/3] iio: adc: rohm-bd79112: Support ROHM BD79111 Matti Vaittinen 2026-11-20 12:34 ` sashiko-bot 2026-11-20 12:53 ` Matti Vaittinen 2026-11-21 1:59 ` Jonathan Cameron 2026-11-20 14:44 ` Andy Shevchenko 2026-11-21 2:01 ` Jonathan Cameron
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox