Lines Matching +full:vref +full:- +full:mv
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * m62332.c - Support for Mitsubishi m62332 DAC
5 * Copyright (c) 2014 Dmitry Eremin-Solenikov
34 struct i2c_client *client = data->client; in m62332_set_value()
38 if (val == data->raw[channel]) in m62332_set_value()
44 mutex_lock(&data->mutex); in m62332_set_value()
47 res = regulator_enable(data->vcc); in m62332_set_value()
54 res = -EIO; in m62332_set_value()
58 data->raw[channel] = val; in m62332_set_value()
61 regulator_disable(data->vcc); in m62332_set_value()
63 mutex_unlock(&data->mutex); in m62332_set_value()
68 mutex_unlock(&data->mutex); in m62332_set_value()
84 /* Corresponds to Vref / 2^(bits) */ in m62332_read_raw()
85 ret = regulator_get_voltage(data->vcc); in m62332_read_raw()
89 *val = ret / 1000; /* mV */ in m62332_read_raw()
94 *val = data->raw[chan->channel]; in m62332_read_raw()
105 return -EINVAL; in m62332_read_raw()
115 return -EINVAL; in m62332_write_raw()
117 return m62332_set_value(indio_dev, val, chan->channel); in m62332_write_raw()
122 return -EINVAL; in m62332_write_raw()
132 data->save[0] = data->raw[0]; in m62332_suspend()
133 data->save[1] = data->raw[1]; in m62332_suspend()
149 ret = m62332_set_value(indio_dev, data->save[0], 0); in m62332_resume()
153 return m62332_set_value(indio_dev, data->save[1], 1); in m62332_resume()
185 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in m62332_probe()
187 return -ENOMEM; in m62332_probe()
191 data->client = client; in m62332_probe()
193 mutex_init(&data->mutex); in m62332_probe()
195 data->vcc = devm_regulator_get(&client->dev, "VCC"); in m62332_probe()
196 if (IS_ERR(data->vcc)) in m62332_probe()
197 return PTR_ERR(data->vcc); in m62332_probe()
199 indio_dev->num_channels = ARRAY_SIZE(m62332_channels); in m62332_probe()
200 indio_dev->channels = m62332_channels; in m62332_probe()
201 indio_dev->modes = INDIO_DIRECT_MODE; in m62332_probe()
202 indio_dev->info = &m62332_info; in m62332_probe()
204 ret = iio_map_array_register(indio_dev, client->dev.platform_data); in m62332_probe()
247 MODULE_AUTHOR("Dmitry Eremin-Solenikov");
248 MODULE_DESCRIPTION("M62332 8-bit DAC");