Lines Matching +full:iio +full:- +full:consumer

1 // SPDX-License-Identifier: GPL-2.0-only
4 * 7-bit, Multi-Channel Sink/Source Current DAC Driver
11 #include <linux/regulator/consumer.h>
14 #include <linux/iio/iio.h>
15 #include <linux/iio/driver.h>
16 #include <linux/iio/machine.h>
17 #include <linux/iio/consumer.h>
76 mutex_lock(&data->lock); in ds4424_get_value()
77 ret = i2c_smbus_read_byte_data(data->client, DS4424_DAC_ADDR(channel)); in ds4424_get_value()
84 mutex_unlock(&data->lock); in ds4424_get_value()
94 mutex_lock(&data->lock); in ds4424_set_value()
95 ret = i2c_smbus_write_byte_data(data->client, in ds4424_set_value()
96 DS4424_DAC_ADDR(chan->channel), val); in ds4424_set_value()
100 data->raw[chan->channel] = val; in ds4424_set_value()
103 mutex_unlock(&data->lock); in ds4424_set_value()
116 ret = ds4424_get_value(indio_dev, val, chan->channel); in ds4424_read_raw()
125 *val = -*val; in ds4424_read_raw()
129 return -EINVAL; in ds4424_read_raw()
140 return -EINVAL; in ds4424_write_raw()
145 return -EINVAL; in ds4424_write_raw()
152 raw.dx = -val; in ds4424_write_raw()
158 return -EINVAL; in ds4424_write_raw()
168 dev_err(&indio_dev->dev, in ds4424_verify_chip()
182 for (i = 0; i < indio_dev->num_channels; i++) { in ds4424_suspend()
183 data->save[i] = data->raw[i]; in ds4424_suspend()
185 &indio_dev->channels[i]); in ds4424_suspend()
200 for (i = 0; i < indio_dev->num_channels; i++) { in ds4424_resume()
201 ret = ds4424_set_value(indio_dev, data->save[i], in ds4424_resume()
202 &indio_dev->channels[i]); in ds4424_resume()
223 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in ds4424_probe()
225 dev_err(&client->dev, "iio dev alloc failed.\n"); in ds4424_probe()
226 return -ENOMEM; in ds4424_probe()
231 data->client = client; in ds4424_probe()
232 indio_dev->name = id->name; in ds4424_probe()
234 data->vcc_reg = devm_regulator_get(&client->dev, "vcc"); in ds4424_probe()
235 if (IS_ERR(data->vcc_reg)) in ds4424_probe()
236 return dev_err_probe(&client->dev, PTR_ERR(data->vcc_reg), in ds4424_probe()
237 "Failed to get vcc-supply regulator.\n"); in ds4424_probe()
239 mutex_init(&data->lock); in ds4424_probe()
240 ret = regulator_enable(data->vcc_reg); in ds4424_probe()
242 dev_err(&client->dev, in ds4424_probe()
252 switch (id->driver_data) { in ds4424_probe()
254 indio_dev->num_channels = DS4422_MAX_DAC_CHANNELS; in ds4424_probe()
257 indio_dev->num_channels = DS4424_MAX_DAC_CHANNELS; in ds4424_probe()
260 dev_err(&client->dev, in ds4424_probe()
262 ret = -ENXIO; in ds4424_probe()
266 indio_dev->channels = ds4424_channels; in ds4424_probe()
267 indio_dev->modes = INDIO_DIRECT_MODE; in ds4424_probe()
268 indio_dev->info = &ds4424_info; in ds4424_probe()
272 dev_err(&client->dev, in ds4424_probe()
280 regulator_disable(data->vcc_reg); in ds4424_probe()
290 regulator_disable(data->vcc_reg); in ds4424_remove()