Lines Matching +full:ad7091r +full:- +full:4

1 // SPDX-License-Identifier: GPL-2.0
3 * Analog Devices AD7091R8 12-bit SAR ADC driver
15 #include "ad7091r-base.h"
31 /* AD7091R-2/-4/-8 don't set sample/command/autocycle mode in conf reg */ in ad7091r8_set_mode()
32 st->mode = mode; in ad7091r8_set_mode()
43 .channels = ad7091r##_n##_channels, \
44 .num_channels = ARRAY_SIZE(ad7091r##_n##_channels), \
52 .channels = ad7091r##_n##_channels_irq, \
53 .num_channels = ARRAY_SIZE(ad7091r##_n##_channels_irq), \
91 AD7091R_CHANNEL(4, 12, NULL, 0),
102 AD7091R_CHANNEL(4, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)),
110 gpiod_set_value_cansleep(st->convst_gpio, 1); in ad7091r_pulse_convst()
111 gpiod_set_value_cansleep(st->convst_gpio, 0); in ad7091r_pulse_convst()
118 struct spi_device *spi = container_of(st->dev, struct spi_device, dev); in ad7091r_regmap_bus_reg_read()
123 .tx_buf = &st->tx_buf, in ad7091r_regmap_bus_reg_read()
127 .rx_buf = &st->rx_buf, in ad7091r_regmap_bus_reg_read()
135 st->tx_buf = cpu_to_be16(reg << 11); in ad7091r_regmap_bus_reg_read()
141 *val = be16_to_cpu(st->rx_buf); in ad7091r_regmap_bus_reg_read()
149 struct spi_device *spi = container_of(st->dev, struct spi_device, dev); in ad7091r_regmap_bus_reg_write()
152 * AD7091R-2/-4/-8 protocol (datasheet page 31) is to do a single SPI in ad7091r_regmap_bus_reg_write()
155 st->tx_buf = cpu_to_be16(FIELD_PREP(AD7091R8_REG_DATA_MSK, val) | in ad7091r_regmap_bus_reg_write()
159 return spi_write(spi, &st->tx_buf, 2); in ad7091r_regmap_bus_reg_write()
170 [AD7091R2_INFO] = AD7091R_SPI_CHIP_INFO(2, "ad7091r-2"),
171 [AD7091R4_INFO] = AD7091R_SPI_CHIP_INFO(4, "ad7091r-4"),
172 [AD7091R4_INFO_IRQ] = AD7091R_SPI_CHIP_INFO_IRQ(4, "ad7091r-4"),
173 [AD7091R8_INFO] = AD7091R_SPI_CHIP_INFO(8, "ad7091r-8"),
174 [AD7091R8_INFO_IRQ] = AD7091R_SPI_CHIP_INFO_IRQ(8, "ad7091r-8")
178 static const struct regmap_config ad7091r4_reg_conf = AD7091R_SPI_REGMAP_CONFIG(4);
184 st->map = devm_regmap_init(st->dev, &ad7091r8_regmap_bus, st, in ad7091r8_regmap_init()
190 st->convst_gpio = devm_gpiod_get(st->dev, "convst", GPIOD_OUT_LOW); in ad7091r8_gpio_setup()
191 if (IS_ERR(st->convst_gpio)) in ad7091r8_gpio_setup()
192 return dev_err_probe(st->dev, PTR_ERR(st->convst_gpio), in ad7091r8_gpio_setup()
195 st->reset_gpio = devm_gpiod_get_optional(st->dev, "reset", in ad7091r8_gpio_setup()
197 if (IS_ERR(st->reset_gpio)) in ad7091r8_gpio_setup()
198 return dev_err_probe(st->dev, PTR_ERR(st->reset_gpio), in ad7091r8_gpio_setup()
201 if (st->reset_gpio) { in ad7091r8_gpio_setup()
203 gpiod_set_value_cansleep(st->reset_gpio, 0); in ad7091r8_gpio_setup()
238 return -EINVAL; in ad7091r8_spi_probe()
240 return ad7091r_probe(&spi->dev, init_info, spi->irq); in ad7091r8_spi_probe()