Lines Matching +full:vrefa +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
3 * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5625, AD5625R,
56 * enum ad5064_regmap_type - Register layout variant
68 * struct ad5064_chip_info - chip specific information
69 * @shared_vref: whether the vref supply is shared between channels
91 * struct ad5064_state - driver instance specific data
94 * @vref_reg: vref supply regulators
197 return st->write(st, cmd, addr, val); in ad5064_write()
207 if (st->chip_info->regmap_type == AD5064_REGMAP_LTC) { in ad5064_sync_powerdown_mode()
209 address = chan->address; in ad5064_sync_powerdown_mode()
211 if (st->chip_info->regmap_type == AD5064_REGMAP_ADI2) in ad5064_sync_powerdown_mode()
216 val = (0x1 << chan->address); in ad5064_sync_powerdown_mode()
219 if (st->pwr_down[chan->channel]) in ad5064_sync_powerdown_mode()
220 val |= st->pwr_down_mode[chan->channel] << shift; in ad5064_sync_powerdown_mode()
243 return st->pwr_down_mode[chan->channel] - 1; in ad5064_get_powerdown_mode()
252 mutex_lock(&st->lock); in ad5064_set_powerdown_mode()
253 st->pwr_down_mode[chan->channel] = mode + 1; in ad5064_set_powerdown_mode()
256 mutex_unlock(&st->lock); in ad5064_set_powerdown_mode()
280 return sysfs_emit(buf, "%d\n", st->pwr_down[chan->channel]); in ad5064_read_dac_powerdown()
295 mutex_lock(&st->lock); in ad5064_write_dac_powerdown()
296 st->pwr_down[chan->channel] = pwr_down; in ad5064_write_dac_powerdown()
299 mutex_unlock(&st->lock); in ad5064_write_dac_powerdown()
308 if (st->use_internal_vref) in ad5064_get_vref()
309 return st->chip_info->internal_vref; in ad5064_get_vref()
311 i = st->chip_info->shared_vref ? 0 : chan->channel; in ad5064_get_vref()
312 return regulator_get_voltage(st->vref_reg[i].consumer); in ad5064_get_vref()
326 *val = st->dac_cache[chan->channel]; in ad5064_read_raw()
334 *val2 = chan->scan_type.realbits; in ad5064_read_raw()
339 return -EINVAL; in ad5064_read_raw()
350 if (val >= (1 << chan->scan_type.realbits) || val < 0) in ad5064_write_raw()
351 return -EINVAL; in ad5064_write_raw()
353 mutex_lock(&st->lock); in ad5064_write_raw()
355 chan->address, val, chan->scan_type.shift); in ad5064_write_raw()
357 st->dac_cache[chan->channel] = val; in ad5064_write_raw()
358 mutex_unlock(&st->lock); in ad5064_write_raw()
361 ret = -EINVAL; in ad5064_write_raw()
780 return st->chip_info->shared_vref ? 1 : st->chip_info->num_channels; in ad5064_num_vref()
784 "vrefA",
793 return st->chip_info->shared_vref ? "vref" : ad5064_vref_names[vref]; in ad5064_vref_name()
800 switch (st->chip_info->regmap_type) { in ad5064_set_config()
818 st->vref_reg[i].supply = ad5064_vref_name(st, i); in ad5064_request_vref()
820 if (!st->chip_info->internal_vref) in ad5064_request_vref()
822 st->vref_reg); in ad5064_request_vref()
829 st->vref_reg[0].consumer = devm_regulator_get_optional(dev, "vref"); in ad5064_request_vref()
830 if (!IS_ERR(st->vref_reg[0].consumer)) in ad5064_request_vref()
833 ret = PTR_ERR(st->vref_reg[0].consumer); in ad5064_request_vref()
834 if (ret != -ENODEV) in ad5064_request_vref()
838 st->use_internal_vref = true; in ad5064_request_vref()
850 regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); in ad5064_bulk_reg_disable()
864 return -ENOMEM; in ad5064_probe()
867 mutex_init(&st->lock); in ad5064_probe()
869 st->chip_info = &ad5064_chip_info_tbl[type]; in ad5064_probe()
870 st->dev = dev; in ad5064_probe()
871 st->write = write; in ad5064_probe()
877 if (!st->use_internal_vref) { in ad5064_probe()
878 ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg); in ad5064_probe()
887 indio_dev->name = name; in ad5064_probe()
888 indio_dev->info = &ad5064_info; in ad5064_probe()
889 indio_dev->modes = INDIO_DIRECT_MODE; in ad5064_probe()
890 indio_dev->channels = st->chip_info->channels; in ad5064_probe()
891 indio_dev->num_channels = st->chip_info->num_channels; in ad5064_probe()
893 midscale = (1 << indio_dev->channels[0].scan_type.realbits) / 2; in ad5064_probe()
895 for (i = 0; i < st->chip_info->num_channels; ++i) { in ad5064_probe()
896 st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K; in ad5064_probe()
897 st->dac_cache[i] = midscale; in ad5064_probe()
908 struct spi_device *spi = to_spi_device(st->dev); in ad5064_spi_write()
910 st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val); in ad5064_spi_write()
911 return spi_write(spi, &st->data.spi, sizeof(st->data.spi)); in ad5064_spi_write()
918 return ad5064_probe(&spi->dev, id->driver_data, id->name, in ad5064_spi_probe()
928 {"ad5064-1", ID_AD5064_1},
930 {"ad5628-1", ID_AD5628_1},
931 {"ad5628-2", ID_AD5628_2},
932 {"ad5648-1", ID_AD5648_1},
933 {"ad5648-2", ID_AD5648_2},
934 {"ad5666-1", ID_AD5666_1},
935 {"ad5666-2", ID_AD5666_2},
936 {"ad5668-1", ID_AD5668_1},
937 {"ad5668-2", ID_AD5668_2},
938 {"ad5668-3", ID_AD5668_2}, /* similar enough to ad5668-2 */
973 struct i2c_client *i2c = to_i2c_client(st->dev); in ad5064_i2c_write()
977 switch (st->chip_info->regmap_type) { in ad5064_i2c_write()
986 st->data.i2c[0] = (cmd << cmd_shift) | addr; in ad5064_i2c_write()
987 put_unaligned_be16(val, &st->data.i2c[1]); in ad5064_i2c_write()
989 ret = i2c_master_send(i2c, st->data.i2c, 3); in ad5064_i2c_write()
999 return ad5064_probe(&i2c->dev, id->driver_data, id->name, in ad5064_i2c_probe()
1005 {"ad5625r-1v25", ID_AD5625R_1V25 },
1006 {"ad5625r-2v5", ID_AD5625R_2V5 },
1008 {"ad5627r-1v25", ID_AD5627R_1V25 },
1009 {"ad5627r-2v5", ID_AD5627R_2V5 },
1010 {"ad5629-1", ID_AD5629_1},
1011 {"ad5629-2", ID_AD5629_2},
1012 {"ad5629-3", ID_AD5629_2}, /* similar enough to ad5629-2 */
1013 {"ad5645r-1v25", ID_AD5645R_1V25 },
1014 {"ad5645r-2v5", ID_AD5645R_2V5 },
1016 {"ad5665r-1v25", ID_AD5665R_1V25 },
1017 {"ad5665r-2v5", ID_AD5665R_2V5 },
1019 {"ad5667r-1v25", ID_AD5667R_1V25 },
1020 {"ad5667r-2v5", ID_AD5667R_2V5 },
1021 {"ad5669-1", ID_AD5669_1},
1022 {"ad5669-2", ID_AD5669_2},
1023 {"ad5669-3", ID_AD5669_2}, /* similar enough to ad5669-2 */
1033 {"ltc2631-l12", ID_LTC2631_L12},
1034 {"ltc2631-h12", ID_LTC2631_H12},
1035 {"ltc2631-l10", ID_LTC2631_L10},
1036 {"ltc2631-h10", ID_LTC2631_H10},
1037 {"ltc2631-l8", ID_LTC2631_L8},
1038 {"ltc2631-h8", ID_LTC2631_H8},
1039 {"ltc2633-l12", ID_LTC2633_L12},
1040 {"ltc2633-h12", ID_LTC2633_H12},
1041 {"ltc2633-l10", ID_LTC2633_L10},
1042 {"ltc2633-h10", ID_LTC2633_H10},
1043 {"ltc2633-l8", ID_LTC2633_L8},
1044 {"ltc2633-h8", ID_LTC2633_H8},
1045 {"ltc2635-l12", ID_LTC2635_L12},
1046 {"ltc2635-h12", ID_LTC2635_H12},
1047 {"ltc2635-l10", ID_LTC2635_L10},
1048 {"ltc2635-h10", ID_LTC2635_H10},
1049 {"ltc2635-l8", ID_LTC2635_L8},
1050 {"ltc2635-h8", ID_LTC2635_H8},
1105 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
1106 MODULE_DESCRIPTION("Analog Devices AD5024 and similar multi-channel DACs");