Lines Matching +full:ad5272 +full:- +full:020
1 // SPDX-License-Identifier: GPL-2.0+
3 * Analog Devices AD5272 digital potentiometer driver
6 * Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD5272_5274.pdf
9 * ad5272 1 1024 20, 50, 100 01011xx
67 data->buf[0] = (reg << 2) | ((val >> 8) & 0x3); in ad5272_write()
68 data->buf[1] = (u8)val; in ad5272_write()
70 mutex_lock(&data->lock); in ad5272_write()
71 ret = i2c_master_send(data->client, data->buf, sizeof(data->buf)); in ad5272_write()
72 mutex_unlock(&data->lock); in ad5272_write()
80 data->buf[0] = reg << 2; in ad5272_read()
81 data->buf[1] = 0; in ad5272_read()
83 mutex_lock(&data->lock); in ad5272_read()
84 ret = i2c_master_send(data->client, data->buf, sizeof(data->buf)); in ad5272_read()
88 ret = i2c_master_recv(data->client, data->buf, sizeof(data->buf)); in ad5272_read()
92 *val = ((data->buf[0] & 0x3) << 8) | data->buf[1]; in ad5272_read()
95 mutex_unlock(&data->lock); in ad5272_read()
109 *val = *val >> data->cfg->shift; in ad5272_read_raw()
113 *val = 1000 * data->cfg->kohms; in ad5272_read_raw()
114 *val2 = data->cfg->max_pos; in ad5272_read_raw()
118 return -EINVAL; in ad5272_read_raw()
128 return -EINVAL; in ad5272_write_raw()
130 if (val >= data->cfg->max_pos || val < 0 || val2) in ad5272_write_raw()
131 return -EINVAL; in ad5272_write_raw()
133 return ad5272_write(data, AD5272_RDAC_WR, val << data->cfg->shift); in ad5272_write_raw()
145 reset_gpio = devm_gpiod_get_optional(&data->client->dev, "reset", in ad5272_reset()
164 struct device *dev = &client->dev; in ad5272_probe()
171 return -ENOMEM; in ad5272_probe()
176 data->client = client; in ad5272_probe()
177 mutex_init(&data->lock); in ad5272_probe()
178 data->cfg = &ad5272_cfg[id->driver_data]; in ad5272_probe()
186 return -ENODEV; in ad5272_probe()
188 indio_dev->info = &ad5272_info; in ad5272_probe()
189 indio_dev->channels = &ad5272_channel; in ad5272_probe()
190 indio_dev->num_channels = 1; in ad5272_probe()
191 indio_dev->name = client->name; in ad5272_probe()
197 { .compatible = "adi,ad5272-020", .data = (void *)AD5272_020 },
198 { .compatible = "adi,ad5272-050", .data = (void *)AD5272_050 },
199 { .compatible = "adi,ad5272-100", .data = (void *)AD5272_100 },
200 { .compatible = "adi,ad5274-020", .data = (void *)AD5274_020 },
201 { .compatible = "adi,ad5274-100", .data = (void *)AD5274_100 },
207 { "ad5272-020", AD5272_020 },
208 { "ad5272-050", AD5272_050 },
209 { "ad5272-100", AD5272_100 },
210 { "ad5274-020", AD5274_020 },
211 { "ad5274-100", AD5274_100 },
218 .name = "ad5272",
228 MODULE_DESCRIPTION("AD5272 digital potentiometer");