Lines Matching +full:vref +full:- +full:ltc2632

1 // SPDX-License-Identifier: GPL-2.0-only
3 * LTC2632 Digital to analog convertors spi driver
5 * Copyright 2017 Maxime Roussin-Bélanger
28 * struct ltc2632_chip_info - chip specific information
40 * struct ltc2632_state - driver instance specific data
83 * followed by the 4-bit DAC address, A3 to A0, and then the in ltc2632_spi_write()
84 * 12-, 10-, 8-bit data-word. The data-word comprises the 12-, in ltc2632_spi_write()
85 * 10-, 8-bit input code followed by 4, 6, or 8 don't care bits. in ltc2632_spi_write()
103 *val = st->vref_mv; in ltc2632_read_raw()
104 *val2 = chan->scan_type.realbits; in ltc2632_read_raw()
107 return -EINVAL; in ltc2632_read_raw()
120 if (val >= (1 << chan->scan_type.realbits) || val < 0) in ltc2632_write_raw()
121 return -EINVAL; in ltc2632_write_raw()
123 return ltc2632_spi_write(st->spi_dev, in ltc2632_write_raw()
125 chan->address, val, in ltc2632_write_raw()
126 chan->scan_type.shift); in ltc2632_write_raw()
128 return -EINVAL; in ltc2632_write_raw()
140 !!(st->powerdown_cache_mask & (1 << chan->channel))); in ltc2632_read_dac_powerdown()
158 st->powerdown_cache_mask |= (1 << chan->channel); in ltc2632_write_dac_powerdown()
160 st->powerdown_cache_mask &= ~(1 << chan->channel); in ltc2632_write_dac_powerdown()
162 ret = ltc2632_spi_write(st->spi_dev, in ltc2632_write_dac_powerdown()
164 chan->channel, 0, 0); in ltc2632_write_dac_powerdown()
194 .shift = 16 - (_bits), \
315 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ltc2632_probe()
317 return -ENOMEM; in ltc2632_probe()
322 st->spi_dev = spi; in ltc2632_probe()
325 spi_get_device_id(spi)->driver_data; in ltc2632_probe()
327 st->vref_reg = devm_regulator_get_optional(&spi->dev, "vref"); in ltc2632_probe()
328 if (PTR_ERR(st->vref_reg) == -ENODEV) { in ltc2632_probe()
330 st->vref_reg = NULL; in ltc2632_probe()
331 st->vref_mv = chip_info->vref_mv; in ltc2632_probe()
336 dev_err(&spi->dev, in ltc2632_probe()
341 } else if (IS_ERR(st->vref_reg)) { in ltc2632_probe()
342 dev_err(&spi->dev, in ltc2632_probe()
344 return PTR_ERR(st->vref_reg); in ltc2632_probe()
347 ret = regulator_enable(st->vref_reg); in ltc2632_probe()
349 dev_err(&spi->dev, in ltc2632_probe()
354 st->vref_mv = regulator_get_voltage(st->vref_reg) / 1000; in ltc2632_probe()
359 dev_err(&spi->dev, in ltc2632_probe()
366 indio_dev->name = fwnode_get_name(dev_fwnode(&spi->dev)) ?: spi_get_device_id(spi)->name; in ltc2632_probe()
367 indio_dev->info = &ltc2632_info; in ltc2632_probe()
368 indio_dev->modes = INDIO_DIRECT_MODE; in ltc2632_probe()
369 indio_dev->channels = chip_info->channels; in ltc2632_probe()
370 indio_dev->num_channels = chip_info->num_channels; in ltc2632_probe()
382 if (st->vref_reg) in ltc2632_remove()
383 regulator_disable(st->vref_reg); in ltc2632_remove()
387 { "ltc2632-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L12] },
388 { "ltc2632-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L10] },
389 { "ltc2632-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L8] },
390 { "ltc2632-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H12] },
391 { "ltc2632-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H10] },
392 { "ltc2632-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H8] },
393 { "ltc2634-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L12] },
394 { "ltc2634-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L10] },
395 { "ltc2634-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L8] },
396 { "ltc2634-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H12] },
397 { "ltc2634-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H10] },
398 { "ltc2634-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H8] },
399 { "ltc2636-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L12] },
400 { "ltc2636-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L10] },
401 { "ltc2636-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L8] },
402 { "ltc2636-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H12] },
403 { "ltc2636-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H10] },
404 { "ltc2636-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H8] },
411 .compatible = "lltc,ltc2632-l12",
414 .compatible = "lltc,ltc2632-l10",
417 .compatible = "lltc,ltc2632-l8",
420 .compatible = "lltc,ltc2632-h12",
423 .compatible = "lltc,ltc2632-h10",
426 .compatible = "lltc,ltc2632-h8",
429 .compatible = "lltc,ltc2634-l12",
432 .compatible = "lltc,ltc2634-l10",
435 .compatible = "lltc,ltc2634-l8",
438 .compatible = "lltc,ltc2634-h12",
441 .compatible = "lltc,ltc2634-h10",
444 .compatible = "lltc,ltc2634-h8",
447 .compatible = "lltc,ltc2636-l12",
450 .compatible = "lltc,ltc2636-l10",
453 .compatible = "lltc,ltc2636-l8",
456 .compatible = "lltc,ltc2636-h12",
459 .compatible = "lltc,ltc2636-h10",
462 .compatible = "lltc,ltc2636-h8",
471 .name = "ltc2632",
480 MODULE_AUTHOR("Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>");
481 MODULE_DESCRIPTION("LTC2632 DAC SPI driver");