21 #include <linux/module.h>
23 #include <linux/slab.h>
25 #include <linux/i2c.h>
32 #define MAX517_DRV_NAME "max517"
35 #define COMMAND_CHANNEL0 0x00
36 #define COMMAND_CHANNEL1 0x01
37 #define COMMAND_PD 0x08
55 static int max517_set_value(
struct iio_dev *indio_dev,
63 if (val < 0 || val > 255)
78 static int max517_read_raw(
struct iio_dev *indio_dev,
85 unsigned int scale_uv;
91 *val = scale_uv / 1000000;
92 *val2 = scale_uv % 1000000;
100 static int max517_write_raw(
struct iio_dev *indio_dev,
107 ret = max517_set_value(indio_dev, val, chan->
channel);
117 #ifdef CONFIG_PM_SLEEP
118 static int max517_suspend(
struct device *
dev)
125 static int max517_resume(
struct device *dev)
133 #define MAX517_PM_OPS (&max517_pm_ops)
135 #define MAX517_PM_OPS NULL
138 static const struct iio_info max517_info = {
139 .read_raw = max517_read_raw,
140 .write_raw = max517_write_raw,
144 #define MAX517_CHANNEL(chan) { \
145 .type = IIO_VOLTAGE, \
149 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
150 IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
151 .scan_type = IIO_ST('u', 8, 8, 0), \
168 if (indio_dev ==
NULL) {
172 data = iio_priv(indio_dev);
173 i2c_set_clientdata(client, indio_dev);
177 indio_dev->
dev.parent = &client->
dev;
184 indio_dev->
channels = max517_channels;
186 indio_dev->
info = &max517_info;
192 if (id->driver_data ==
ID_MAX518 || !platform_data) {
201 goto exit_free_device;
234 .probe = max517_probe,
236 .id_table = max517_id,