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
27 * struct ltc2632_chip_info - chip specific information
39 * struct ltc2632_state - driver instance specific data
82 * followed by the 4-bit DAC address, A3 to A0, and then the in ltc2632_spi_write()
83 * 12-, 10-, 8-bit data-word. The data-word comprises the 12-, in ltc2632_spi_write()
84 * 10-, 8-bit input code followed by 4, 6, or 8 don't care bits. in ltc2632_spi_write()
102 *val = st->vref_mv; in ltc2632_read_raw()
103 *val2 = chan->scan_type.realbits; in ltc2632_read_raw()
106 return -EINVAL; in ltc2632_read_raw()
119 if (val >= (1 << chan->scan_type.realbits) || val < 0) in ltc2632_write_raw()
120 return -EINVAL; in ltc2632_write_raw()
122 return ltc2632_spi_write(st->spi_dev, in ltc2632_write_raw()
124 chan->address, val, in ltc2632_write_raw()
125 chan->scan_type.shift); in ltc2632_write_raw()
127 return -EINVAL; in ltc2632_write_raw()
139 !!(st->powerdown_cache_mask & (1 << chan->channel))); in ltc2632_read_dac_powerdown()
157 st->powerdown_cache_mask |= (1 << chan->channel); in ltc2632_write_dac_powerdown()
159 st->powerdown_cache_mask &= ~(1 << chan->channel); in ltc2632_write_dac_powerdown()
161 ret = ltc2632_spi_write(st->spi_dev, in ltc2632_write_dac_powerdown()
163 chan->channel, 0, 0); in ltc2632_write_dac_powerdown()
193 .shift = 16 - (_bits), \
314 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ltc2632_probe()
316 return -ENOMEM; in ltc2632_probe()
321 st->spi_dev = spi; in ltc2632_probe()
324 spi_get_device_id(spi)->driver_data; in ltc2632_probe()
326 st->vref_reg = devm_regulator_get_optional(&spi->dev, "vref"); in ltc2632_probe()
327 if (PTR_ERR(st->vref_reg) == -ENODEV) { in ltc2632_probe()
329 st->vref_reg = NULL; in ltc2632_probe()
330 st->vref_mv = chip_info->vref_mv; in ltc2632_probe()
335 dev_err(&spi->dev, in ltc2632_probe()
340 } else if (IS_ERR(st->vref_reg)) { in ltc2632_probe()
341 dev_err(&spi->dev, in ltc2632_probe()
343 return PTR_ERR(st->vref_reg); in ltc2632_probe()
346 ret = regulator_enable(st->vref_reg); in ltc2632_probe()
348 dev_err(&spi->dev, in ltc2632_probe()
353 st->vref_mv = regulator_get_voltage(st->vref_reg) / 1000; in ltc2632_probe()
358 dev_err(&spi->dev, in ltc2632_probe()
365 indio_dev->name = dev_of_node(&spi->dev) ? dev_of_node(&spi->dev)->name in ltc2632_probe()
366 : 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()
389 { "ltc2632-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L12] },
390 { "ltc2632-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L10] },
391 { "ltc2632-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632L8] },
392 { "ltc2632-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H12] },
393 { "ltc2632-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H10] },
394 { "ltc2632-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2632H8] },
395 { "ltc2634-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L12] },
396 { "ltc2634-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L10] },
397 { "ltc2634-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634L8] },
398 { "ltc2634-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H12] },
399 { "ltc2634-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H10] },
400 { "ltc2634-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2634H8] },
401 { "ltc2636-l12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L12] },
402 { "ltc2636-l10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L10] },
403 { "ltc2636-l8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636L8] },
404 { "ltc2636-h12", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H12] },
405 { "ltc2636-h10", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H10] },
406 { "ltc2636-h8", (kernel_ulong_t)&ltc2632_chip_info_tbl[ID_LTC2636H8] },
413 .compatible = "lltc,ltc2632-l12",
416 .compatible = "lltc,ltc2632-l10",
419 .compatible = "lltc,ltc2632-l8",
422 .compatible = "lltc,ltc2632-h12",
425 .compatible = "lltc,ltc2632-h10",
428 .compatible = "lltc,ltc2632-h8",
431 .compatible = "lltc,ltc2634-l12",
434 .compatible = "lltc,ltc2634-l10",
437 .compatible = "lltc,ltc2634-l8",
440 .compatible = "lltc,ltc2634-h12",
443 .compatible = "lltc,ltc2634-h10",
446 .compatible = "lltc,ltc2634-h8",
449 .compatible = "lltc,ltc2636-l12",
452 .compatible = "lltc,ltc2636-l10",
455 .compatible = "lltc,ltc2636-l8",
458 .compatible = "lltc,ltc2636-h12",
461 .compatible = "lltc,ltc2636-h10",
464 .compatible = "lltc,ltc2636-h8",
473 .name = "ltc2632",
482 MODULE_AUTHOR("Maxime Roussin-Belanger <maxime.roussinbelanger@gmail.com>");
483 MODULE_DESCRIPTION("LTC2632 DAC SPI driver");