Lines Matching +full:regulator +full:- +full:v5
1 // SPDX-License-Identifier: GPL-2.0-only
3 * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5625, AD5625R,
20 #include <linux/regulator/consumer.h>
56 * enum ad5064_regmap_type - Register layout variant
68 * struct ad5064_chip_info - chip specific information
91 * struct ad5064_state - driver instance specific data
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 sprintf(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()
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()
825 * This assumes that when the regulator has an internal VREF 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()
837 /* If no external regulator was supplied use the internal VREF */ in ad5064_request_vref()
838 st->use_internal_vref = true; in ad5064_request_vref()
857 return -ENOMEM; in ad5064_probe()
860 mutex_init(&st->lock); in ad5064_probe()
863 st->chip_info = &ad5064_chip_info_tbl[type]; in ad5064_probe()
864 st->dev = dev; in ad5064_probe()
865 st->write = write; in ad5064_probe()
871 if (!st->use_internal_vref) { in ad5064_probe()
872 ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg); in ad5064_probe()
877 indio_dev->name = name; in ad5064_probe()
878 indio_dev->info = &ad5064_info; in ad5064_probe()
879 indio_dev->modes = INDIO_DIRECT_MODE; in ad5064_probe()
880 indio_dev->channels = st->chip_info->channels; in ad5064_probe()
881 indio_dev->num_channels = st->chip_info->num_channels; in ad5064_probe()
883 midscale = (1 << indio_dev->channels[0].scan_type.realbits) / 2; in ad5064_probe()
885 for (i = 0; i < st->chip_info->num_channels; ++i) { in ad5064_probe()
886 st->pwr_down_mode[i] = AD5064_LDAC_PWRDN_1K; in ad5064_probe()
887 st->dac_cache[i] = midscale; in ad5064_probe()
897 if (!st->use_internal_vref) in ad5064_probe()
898 regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); in ad5064_probe()
910 if (!st->use_internal_vref) in ad5064_remove()
911 regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); in ad5064_remove()
921 struct spi_device *spi = to_spi_device(st->dev); in ad5064_spi_write()
923 st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val); in ad5064_spi_write()
924 return spi_write(spi, &st->data.spi, sizeof(st->data.spi)); in ad5064_spi_write()
931 return ad5064_probe(&spi->dev, id->driver_data, id->name, in ad5064_spi_probe()
937 return ad5064_remove(&spi->dev); in ad5064_spi_remove()
946 {"ad5064-1", ID_AD5064_1},
948 {"ad5628-1", ID_AD5628_1},
949 {"ad5628-2", ID_AD5628_2},
950 {"ad5648-1", ID_AD5648_1},
951 {"ad5648-2", ID_AD5648_2},
952 {"ad5666-1", ID_AD5666_1},
953 {"ad5666-2", ID_AD5666_2},
954 {"ad5668-1", ID_AD5668_1},
955 {"ad5668-2", ID_AD5668_2},
956 {"ad5668-3", ID_AD5668_2}, /* similar enough to ad5668-2 */
992 struct i2c_client *i2c = to_i2c_client(st->dev); in ad5064_i2c_write()
996 switch (st->chip_info->regmap_type) { in ad5064_i2c_write()
1005 st->data.i2c[0] = (cmd << cmd_shift) | addr; in ad5064_i2c_write()
1006 put_unaligned_be16(val, &st->data.i2c[1]); in ad5064_i2c_write()
1008 ret = i2c_master_send(i2c, st->data.i2c, 3); in ad5064_i2c_write()
1018 return ad5064_probe(&i2c->dev, id->driver_data, id->name, in ad5064_i2c_probe()
1024 return ad5064_remove(&i2c->dev); in ad5064_i2c_remove()
1029 {"ad5625r-1v25", ID_AD5625R_1V25 },
1030 {"ad5625r-2v5", ID_AD5625R_2V5 },
1032 {"ad5627r-1v25", ID_AD5627R_1V25 },
1033 {"ad5627r-2v5", ID_AD5627R_2V5 },
1034 {"ad5629-1", ID_AD5629_1},
1035 {"ad5629-2", ID_AD5629_2},
1036 {"ad5629-3", ID_AD5629_2}, /* similar enough to ad5629-2 */
1037 {"ad5645r-1v25", ID_AD5645R_1V25 },
1038 {"ad5645r-2v5", ID_AD5645R_2V5 },
1040 {"ad5665r-1v25", ID_AD5665R_1V25 },
1041 {"ad5665r-2v5", ID_AD5665R_2V5 },
1043 {"ad5667r-1v25", ID_AD5667R_1V25 },
1044 {"ad5667r-2v5", ID_AD5667R_2V5 },
1045 {"ad5669-1", ID_AD5669_1},
1046 {"ad5669-2", ID_AD5669_2},
1047 {"ad5669-3", ID_AD5669_2}, /* similar enough to ad5669-2 */
1057 {"ltc2631-l12", ID_LTC2631_L12},
1058 {"ltc2631-h12", ID_LTC2631_H12},
1059 {"ltc2631-l10", ID_LTC2631_L10},
1060 {"ltc2631-h10", ID_LTC2631_H10},
1061 {"ltc2631-l8", ID_LTC2631_L8},
1062 {"ltc2631-h8", ID_LTC2631_H8},
1063 {"ltc2633-l12", ID_LTC2633_L12},
1064 {"ltc2633-h12", ID_LTC2633_H12},
1065 {"ltc2633-l10", ID_LTC2633_L10},
1066 {"ltc2633-h10", ID_LTC2633_H10},
1067 {"ltc2633-l8", ID_LTC2633_L8},
1068 {"ltc2633-h8", ID_LTC2633_H8},
1069 {"ltc2635-l12", ID_LTC2635_L12},
1070 {"ltc2635-h12", ID_LTC2635_H12},
1071 {"ltc2635-l10", ID_LTC2635_L10},
1072 {"ltc2635-h10", ID_LTC2635_H10},
1073 {"ltc2635-l8", ID_LTC2635_L8},
1074 {"ltc2635-h8", ID_LTC2635_H8},
1130 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
1131 MODULE_DESCRIPTION("Analog Devices AD5024 and similar multi-channel DACs");