Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * iio/adc/ad799x.c |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 3 | * Copyright (C) 2010-1011 Michael Hennerich, Analog Devices Inc. |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 4 | * |
| 5 | * based on iio/adc/max1363 |
| 6 | * Copyright (C) 2008-2010 Jonathan Cameron |
| 7 | * |
| 8 | * based on linux/drivers/i2c/chips/max123x |
| 9 | * Copyright (C) 2002-2004 Stefan Eletzhofer |
| 10 | * |
| 11 | * based on linux/drivers/acron/char/pcf8583.c |
| 12 | * Copyright (C) 2000 Russell King |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 as |
| 16 | * published by the Free Software Foundation. |
| 17 | * |
| 18 | * ad799x.c |
| 19 | * |
| 20 | * Support for ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, |
| 21 | * ad7998 and similar chips. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <linux/interrupt.h> |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 26 | #include <linux/device.h> |
| 27 | #include <linux/kernel.h> |
| 28 | #include <linux/sysfs.h> |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 29 | #include <linux/i2c.h> |
| 30 | #include <linux/regulator/consumer.h> |
| 31 | #include <linux/slab.h> |
| 32 | #include <linux/types.h> |
| 33 | #include <linux/err.h> |
Paul Gortmaker | 99c9785 | 2011-07-03 15:49:50 -0400 | [diff] [blame] | 34 | #include <linux/module.h> |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 35 | |
| 36 | #include "../iio.h" |
| 37 | #include "../sysfs.h" |
Jonathan Cameron | af5046a | 2011-10-26 17:41:32 +0100 | [diff] [blame^] | 38 | #include "../events.h" |
| 39 | #include "../buffer.h" |
Jonathan Cameron | cdf3870 | 2011-08-12 17:08:43 +0100 | [diff] [blame] | 40 | |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 41 | #include "ad799x.h" |
| 42 | |
| 43 | /* |
| 44 | * ad799x register access by I2C |
| 45 | */ |
| 46 | static int ad799x_i2c_read16(struct ad799x_state *st, u8 reg, u16 *data) |
| 47 | { |
| 48 | struct i2c_client *client = st->client; |
| 49 | int ret = 0; |
| 50 | |
| 51 | ret = i2c_smbus_read_word_data(client, reg); |
| 52 | if (ret < 0) { |
| 53 | dev_err(&client->dev, "I2C read error\n"); |
| 54 | return ret; |
| 55 | } |
| 56 | |
| 57 | *data = swab16((u16)ret); |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | static int ad799x_i2c_read8(struct ad799x_state *st, u8 reg, u8 *data) |
| 63 | { |
| 64 | struct i2c_client *client = st->client; |
| 65 | int ret = 0; |
| 66 | |
Michael Hennerich | aecac19 | 2010-10-06 10:25:49 +0200 | [diff] [blame] | 67 | ret = i2c_smbus_read_byte_data(client, reg); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 68 | if (ret < 0) { |
| 69 | dev_err(&client->dev, "I2C read error\n"); |
| 70 | return ret; |
| 71 | } |
| 72 | |
Michael Hennerich | aecac19 | 2010-10-06 10:25:49 +0200 | [diff] [blame] | 73 | *data = (u8)ret; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 74 | |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | static int ad799x_i2c_write16(struct ad799x_state *st, u8 reg, u16 data) |
| 79 | { |
| 80 | struct i2c_client *client = st->client; |
| 81 | int ret = 0; |
| 82 | |
| 83 | ret = i2c_smbus_write_word_data(client, reg, swab16(data)); |
| 84 | if (ret < 0) |
| 85 | dev_err(&client->dev, "I2C write error\n"); |
| 86 | |
| 87 | return ret; |
| 88 | } |
| 89 | |
| 90 | static int ad799x_i2c_write8(struct ad799x_state *st, u8 reg, u8 data) |
| 91 | { |
| 92 | struct i2c_client *client = st->client; |
| 93 | int ret = 0; |
| 94 | |
| 95 | ret = i2c_smbus_write_byte_data(client, reg, data); |
| 96 | if (ret < 0) |
| 97 | dev_err(&client->dev, "I2C write error\n"); |
| 98 | |
| 99 | return ret; |
| 100 | } |
| 101 | |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 102 | int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask) |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 103 | { |
| 104 | return ad799x_i2c_write16(st, AD7998_CONF_REG, |
| 105 | st->config | (mask << AD799X_CHANNEL_SHIFT)); |
| 106 | } |
| 107 | |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 108 | static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch) |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 109 | { |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 110 | u16 rxbuf; |
| 111 | u8 cmd; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 112 | int ret; |
| 113 | |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 114 | switch (st->id) { |
| 115 | case ad7991: |
| 116 | case ad7995: |
| 117 | case ad7999: |
| 118 | cmd = st->config | ((1 << ch) << AD799X_CHANNEL_SHIFT); |
| 119 | break; |
| 120 | case ad7992: |
| 121 | case ad7993: |
| 122 | case ad7994: |
| 123 | cmd = (1 << ch) << AD799X_CHANNEL_SHIFT; |
| 124 | break; |
| 125 | case ad7997: |
| 126 | case ad7998: |
| 127 | cmd = (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE; |
| 128 | break; |
| 129 | default: |
| 130 | return -EINVAL; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 131 | } |
| 132 | |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 133 | ret = ad799x_i2c_read16(st, cmd, &rxbuf); |
| 134 | if (ret < 0) |
| 135 | return ret; |
| 136 | |
| 137 | return rxbuf; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 138 | } |
| 139 | |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 140 | static int ad799x_read_raw(struct iio_dev *indio_dev, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 141 | struct iio_chan_spec const *chan, |
| 142 | int *val, |
| 143 | int *val2, |
| 144 | long m) |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 145 | { |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 146 | int ret; |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 147 | struct ad799x_state *st = iio_priv(indio_dev); |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 148 | unsigned int scale_uv; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 149 | |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 150 | switch (m) { |
| 151 | case 0: |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 152 | mutex_lock(&indio_dev->mlock); |
| 153 | if (iio_buffer_enabled(indio_dev)) |
| 154 | ret = ad799x_single_channel_from_ring(indio_dev, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 155 | chan->scan_index); |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 156 | else |
Jonathan Cameron | 58dffae | 2011-09-30 10:05:37 +0100 | [diff] [blame] | 157 | ret = ad799x_scan_direct(st, chan->scan_index); |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 158 | mutex_unlock(&indio_dev->mlock); |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 159 | |
Michael Hennerich | aecac19 | 2010-10-06 10:25:49 +0200 | [diff] [blame] | 160 | if (ret < 0) |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 161 | return ret; |
Jonathan Cameron | 5357ba3 | 2011-09-30 10:05:32 +0100 | [diff] [blame] | 162 | *val = (ret >> chan->scan_type.shift) & |
| 163 | RES_MASK(chan->scan_type.realbits); |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 164 | return IIO_VAL_INT; |
| 165 | case (1 << IIO_CHAN_INFO_SCALE_SHARED): |
Jonathan Cameron | 5357ba3 | 2011-09-30 10:05:32 +0100 | [diff] [blame] | 166 | scale_uv = (st->int_vref_mv * 1000) >> chan->scan_type.realbits; |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 167 | *val = scale_uv / 1000; |
| 168 | *val2 = (scale_uv % 1000) * 1000; |
| 169 | return IIO_VAL_INT_PLUS_MICRO; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 170 | } |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 171 | return -EINVAL; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 172 | } |
Jonathan Cameron | 24cba40 | 2011-09-30 10:05:33 +0100 | [diff] [blame] | 173 | static const unsigned int ad7998_frequencies[] = { |
| 174 | [AD7998_CYC_DIS] = 0, |
| 175 | [AD7998_CYC_TCONF_32] = 15625, |
| 176 | [AD7998_CYC_TCONF_64] = 7812, |
| 177 | [AD7998_CYC_TCONF_128] = 3906, |
| 178 | [AD7998_CYC_TCONF_512] = 976, |
| 179 | [AD7998_CYC_TCONF_1024] = 488, |
| 180 | [AD7998_CYC_TCONF_2048] = 244, |
| 181 | }; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 182 | static ssize_t ad799x_read_frequency(struct device *dev, |
| 183 | struct device_attribute *attr, |
| 184 | char *buf) |
| 185 | { |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 186 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 187 | struct ad799x_state *st = iio_priv(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 188 | |
Jonathan Cameron | 24cba40 | 2011-09-30 10:05:33 +0100 | [diff] [blame] | 189 | int ret; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 190 | u8 val; |
| 191 | ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &val); |
| 192 | if (ret) |
| 193 | return ret; |
| 194 | |
| 195 | val &= AD7998_CYC_MASK; |
| 196 | |
Jonathan Cameron | 24cba40 | 2011-09-30 10:05:33 +0100 | [diff] [blame] | 197 | return sprintf(buf, "%u\n", ad7998_frequencies[val]); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | static ssize_t ad799x_write_frequency(struct device *dev, |
| 201 | struct device_attribute *attr, |
| 202 | const char *buf, |
| 203 | size_t len) |
| 204 | { |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 205 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 206 | struct ad799x_state *st = iio_priv(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 207 | |
| 208 | long val; |
Jonathan Cameron | 24cba40 | 2011-09-30 10:05:33 +0100 | [diff] [blame] | 209 | int ret, i; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 210 | u8 t; |
| 211 | |
| 212 | ret = strict_strtol(buf, 10, &val); |
| 213 | if (ret) |
| 214 | return ret; |
| 215 | |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 216 | mutex_lock(&indio_dev->mlock); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 217 | ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &t); |
| 218 | if (ret) |
| 219 | goto error_ret_mutex; |
| 220 | /* Wipe the bits clean */ |
| 221 | t &= ~AD7998_CYC_MASK; |
| 222 | |
Jonathan Cameron | 24cba40 | 2011-09-30 10:05:33 +0100 | [diff] [blame] | 223 | for (i = 0; i < ARRAY_SIZE(ad7998_frequencies); i++) |
| 224 | if (val == ad7998_frequencies[i]) |
| 225 | break; |
| 226 | if (i == ARRAY_SIZE(ad7998_frequencies)) { |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 227 | ret = -EINVAL; |
| 228 | goto error_ret_mutex; |
| 229 | } |
Jonathan Cameron | 24cba40 | 2011-09-30 10:05:33 +0100 | [diff] [blame] | 230 | t |= i; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 231 | ret = ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t); |
| 232 | |
| 233 | error_ret_mutex: |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 234 | mutex_unlock(&indio_dev->mlock); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 235 | |
| 236 | return ret ? ret : len; |
| 237 | } |
| 238 | |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 239 | static int ad799x_read_event_config(struct iio_dev *indio_dev, |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 240 | u64 event_code) |
| 241 | { |
| 242 | return 1; |
| 243 | } |
| 244 | |
| 245 | static const u8 ad799x_threshold_addresses[][2] = { |
| 246 | { AD7998_DATALOW_CH1_REG, AD7998_DATAHIGH_CH1_REG }, |
| 247 | { AD7998_DATALOW_CH2_REG, AD7998_DATAHIGH_CH2_REG }, |
| 248 | { AD7998_DATALOW_CH3_REG, AD7998_DATAHIGH_CH3_REG }, |
| 249 | { AD7998_DATALOW_CH4_REG, AD7998_DATAHIGH_CH4_REG }, |
| 250 | }; |
| 251 | |
| 252 | static int ad799x_write_event_value(struct iio_dev *indio_dev, |
| 253 | u64 event_code, |
| 254 | int val) |
| 255 | { |
| 256 | int ret; |
| 257 | struct ad799x_state *st = iio_priv(indio_dev); |
| 258 | int direction = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == |
| 259 | IIO_EV_DIR_FALLING); |
| 260 | int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code); |
| 261 | |
| 262 | mutex_lock(&indio_dev->mlock); |
| 263 | ret = ad799x_i2c_write16(st, |
| 264 | ad799x_threshold_addresses[number][direction], |
| 265 | val); |
| 266 | mutex_unlock(&indio_dev->mlock); |
| 267 | |
| 268 | return ret; |
| 269 | } |
| 270 | |
| 271 | static int ad799x_read_event_value(struct iio_dev *indio_dev, |
| 272 | u64 event_code, |
| 273 | int *val) |
| 274 | { |
| 275 | int ret; |
| 276 | struct ad799x_state *st = iio_priv(indio_dev); |
| 277 | int direction = !!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == |
| 278 | IIO_EV_DIR_FALLING); |
| 279 | int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code); |
| 280 | u16 valin; |
| 281 | |
| 282 | mutex_lock(&indio_dev->mlock); |
| 283 | ret = ad799x_i2c_read16(st, |
| 284 | ad799x_threshold_addresses[number][direction], |
| 285 | &valin); |
| 286 | mutex_unlock(&indio_dev->mlock); |
| 287 | if (ret < 0) |
| 288 | return ret; |
| 289 | *val = valin; |
| 290 | |
| 291 | return 0; |
| 292 | } |
| 293 | |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 294 | static ssize_t ad799x_read_channel_config(struct device *dev, |
| 295 | struct device_attribute *attr, |
| 296 | char *buf) |
| 297 | { |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 298 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 299 | struct ad799x_state *st = iio_priv(indio_dev); |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 300 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 301 | |
| 302 | int ret; |
| 303 | u16 val; |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 304 | ret = ad799x_i2c_read16(st, this_attr->address, &val); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 305 | if (ret) |
| 306 | return ret; |
| 307 | |
| 308 | return sprintf(buf, "%d\n", val); |
| 309 | } |
| 310 | |
| 311 | static ssize_t ad799x_write_channel_config(struct device *dev, |
| 312 | struct device_attribute *attr, |
| 313 | const char *buf, |
| 314 | size_t len) |
| 315 | { |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 316 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
| 317 | struct ad799x_state *st = iio_priv(indio_dev); |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 318 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 319 | |
| 320 | long val; |
| 321 | int ret; |
| 322 | |
| 323 | ret = strict_strtol(buf, 10, &val); |
| 324 | if (ret) |
| 325 | return ret; |
| 326 | |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 327 | mutex_lock(&indio_dev->mlock); |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 328 | ret = ad799x_i2c_write16(st, this_attr->address, val); |
Jonathan Cameron | 84f79ec | 2011-10-06 17:14:37 +0100 | [diff] [blame] | 329 | mutex_unlock(&indio_dev->mlock); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 330 | |
| 331 | return ret ? ret : len; |
| 332 | } |
| 333 | |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 334 | static irqreturn_t ad799x_event_handler(int irq, void *private) |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 335 | { |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 336 | struct iio_dev *indio_dev = private; |
Jonathan Cameron | d8aea29 | 2011-06-27 13:07:20 +0100 | [diff] [blame] | 337 | struct ad799x_state *st = iio_priv(private); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 338 | u8 status; |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 339 | int i, ret; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 340 | |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 341 | ret = ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status); |
| 342 | if (ret) |
| 343 | return ret; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 344 | |
| 345 | if (!status) |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 346 | return -EIO; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 347 | |
| 348 | ad799x_i2c_write8(st, AD7998_ALERT_STAT_REG, AD7998_ALERT_STAT_CLEAR); |
| 349 | |
| 350 | for (i = 0; i < 8; i++) { |
| 351 | if (status & (1 << i)) |
Jonathan Cameron | 5aa9618 | 2011-08-30 12:41:06 +0100 | [diff] [blame] | 352 | iio_push_event(indio_dev, |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 353 | i & 0x1 ? |
Jonathan Cameron | 6835cb6 | 2011-09-27 09:56:41 +0100 | [diff] [blame] | 354 | IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, |
Jonathan Cameron | cdf3870 | 2011-08-12 17:08:43 +0100 | [diff] [blame] | 355 | (i >> 1), |
| 356 | IIO_EV_TYPE_THRESH, |
| 357 | IIO_EV_DIR_RISING) : |
Jonathan Cameron | 6835cb6 | 2011-09-27 09:56:41 +0100 | [diff] [blame] | 358 | IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, |
Jonathan Cameron | cdf3870 | 2011-08-12 17:08:43 +0100 | [diff] [blame] | 359 | (i >> 1), |
| 360 | IIO_EV_TYPE_THRESH, |
| 361 | IIO_EV_DIR_FALLING), |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 362 | iio_get_time_ns()); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 363 | } |
| 364 | |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 365 | return IRQ_HANDLED; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 366 | } |
| 367 | |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 368 | static IIO_DEVICE_ATTR(in_voltage0_thresh_both_hyst_raw, |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 369 | S_IRUGO | S_IWUSR, |
| 370 | ad799x_read_channel_config, |
| 371 | ad799x_write_channel_config, |
| 372 | AD7998_HYST_CH1_REG); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 373 | |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 374 | static IIO_DEVICE_ATTR(in_voltage1_thresh_both_hyst_raw, |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 375 | S_IRUGO | S_IWUSR, |
| 376 | ad799x_read_channel_config, |
| 377 | ad799x_write_channel_config, |
| 378 | AD7998_HYST_CH2_REG); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 379 | |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 380 | static IIO_DEVICE_ATTR(in_voltage2_thresh_both_hyst_raw, |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 381 | S_IRUGO | S_IWUSR, |
| 382 | ad799x_read_channel_config, |
| 383 | ad799x_write_channel_config, |
| 384 | AD7998_HYST_CH3_REG); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 385 | |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 386 | static IIO_DEVICE_ATTR(in_voltage3_thresh_both_hyst_raw, |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 387 | S_IRUGO | S_IWUSR, |
| 388 | ad799x_read_channel_config, |
| 389 | ad799x_write_channel_config, |
| 390 | AD7998_HYST_CH4_REG); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 391 | |
| 392 | static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, |
| 393 | ad799x_read_frequency, |
| 394 | ad799x_write_frequency); |
| 395 | static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0"); |
| 396 | |
| 397 | static struct attribute *ad7993_4_7_8_event_attributes[] = { |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 398 | &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr, |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 399 | &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr, |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 400 | &iio_dev_attr_in_voltage2_thresh_both_hyst_raw.dev_attr.attr, |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 401 | &iio_dev_attr_in_voltage3_thresh_both_hyst_raw.dev_attr.attr, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 402 | &iio_dev_attr_sampling_frequency.dev_attr.attr, |
| 403 | &iio_const_attr_sampling_frequency_available.dev_attr.attr, |
| 404 | NULL, |
| 405 | }; |
| 406 | |
| 407 | static struct attribute_group ad7993_4_7_8_event_attrs_group = { |
| 408 | .attrs = ad7993_4_7_8_event_attributes, |
Jonathan Cameron | 8e7d967 | 2011-08-30 12:32:45 +0100 | [diff] [blame] | 409 | .name = "events", |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 410 | }; |
| 411 | |
| 412 | static struct attribute *ad7992_event_attributes[] = { |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 413 | &iio_dev_attr_in_voltage0_thresh_both_hyst_raw.dev_attr.attr, |
Jonathan Cameron | 322c956 | 2011-09-14 13:01:23 +0100 | [diff] [blame] | 414 | &iio_dev_attr_in_voltage1_thresh_both_hyst_raw.dev_attr.attr, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 415 | &iio_dev_attr_sampling_frequency.dev_attr.attr, |
| 416 | &iio_const_attr_sampling_frequency_available.dev_attr.attr, |
| 417 | NULL, |
| 418 | }; |
| 419 | |
| 420 | static struct attribute_group ad7992_event_attrs_group = { |
| 421 | .attrs = ad7992_event_attributes, |
Jonathan Cameron | 8e7d967 | 2011-08-30 12:32:45 +0100 | [diff] [blame] | 422 | .name = "events", |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 423 | }; |
| 424 | |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 425 | static const struct iio_info ad7991_info = { |
| 426 | .read_raw = &ad799x_read_raw, |
| 427 | .driver_module = THIS_MODULE, |
| 428 | }; |
| 429 | |
| 430 | static const struct iio_info ad7992_info = { |
| 431 | .read_raw = &ad799x_read_raw, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 432 | .event_attrs = &ad7992_event_attrs_group, |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 433 | .read_event_config = &ad799x_read_event_config, |
| 434 | .read_event_value = &ad799x_read_event_value, |
| 435 | .write_event_value = &ad799x_write_event_value, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 436 | .driver_module = THIS_MODULE, |
| 437 | }; |
| 438 | |
| 439 | static const struct iio_info ad7993_4_7_8_info = { |
| 440 | .read_raw = &ad799x_read_raw, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 441 | .event_attrs = &ad7993_4_7_8_event_attrs_group, |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 442 | .read_event_config = &ad799x_read_event_config, |
| 443 | .read_event_value = &ad799x_read_event_value, |
| 444 | .write_event_value = &ad799x_write_event_value, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 445 | .driver_module = THIS_MODULE, |
| 446 | }; |
| 447 | |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 448 | #define AD799X_EV_MASK (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \ |
| 449 | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)) |
| 450 | |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 451 | static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { |
| 452 | [ad7991] = { |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 453 | .channel = { |
| 454 | [0] = { |
| 455 | .type = IIO_VOLTAGE, |
| 456 | .indexed = 1, |
| 457 | .channel = 0, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 458 | .scan_index = 0, |
| 459 | .scan_type = IIO_ST('u', 12, 16, 0), |
| 460 | }, |
| 461 | [1] = { |
| 462 | .type = IIO_VOLTAGE, |
| 463 | .indexed = 1, |
| 464 | .channel = 1, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 465 | .scan_index = 1, |
| 466 | .scan_type = IIO_ST('u', 12, 16, 0), |
| 467 | }, |
| 468 | [2] = { |
| 469 | .type = IIO_VOLTAGE, |
| 470 | .indexed = 1, |
| 471 | .channel = 2, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 472 | .scan_index = 2, |
| 473 | .scan_type = IIO_ST('u', 12, 16, 0), |
| 474 | }, |
| 475 | [3] = { |
| 476 | .type = IIO_VOLTAGE, |
| 477 | .indexed = 1, |
| 478 | .channel = 3, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 479 | .scan_index = 3, |
| 480 | .scan_type = IIO_ST('u', 12, 16, 0), |
| 481 | }, |
| 482 | [4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
| 483 | }, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 484 | .num_channels = 5, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 485 | .int_vref_mv = 4096, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 486 | .info = &ad7991_info, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 487 | }, |
| 488 | [ad7995] = { |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 489 | .channel = { |
| 490 | [0] = { |
| 491 | .type = IIO_VOLTAGE, |
| 492 | .indexed = 1, |
| 493 | .channel = 0, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 494 | .scan_index = 0, |
| 495 | .scan_type = IIO_ST('u', 10, 16, 2), |
| 496 | }, |
| 497 | [1] = { |
| 498 | .type = IIO_VOLTAGE, |
| 499 | .indexed = 1, |
| 500 | .channel = 1, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 501 | .scan_index = 1, |
| 502 | .scan_type = IIO_ST('u', 10, 16, 2), |
| 503 | }, |
| 504 | [2] = { |
| 505 | .type = IIO_VOLTAGE, |
| 506 | .indexed = 1, |
| 507 | .channel = 2, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 508 | .scan_index = 2, |
| 509 | .scan_type = IIO_ST('u', 10, 16, 2), |
| 510 | }, |
| 511 | [3] = { |
| 512 | .type = IIO_VOLTAGE, |
| 513 | .indexed = 1, |
| 514 | .channel = 3, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 515 | .scan_index = 3, |
| 516 | .scan_type = IIO_ST('u', 10, 16, 2), |
| 517 | }, |
| 518 | [4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
| 519 | }, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 520 | .num_channels = 5, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 521 | .int_vref_mv = 1024, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 522 | .info = &ad7991_info, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 523 | }, |
| 524 | [ad7999] = { |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 525 | .channel = { |
| 526 | [0] = { |
| 527 | .type = IIO_VOLTAGE, |
| 528 | .indexed = 1, |
| 529 | .channel = 0, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 530 | .scan_index = 0, |
| 531 | .scan_type = IIO_ST('u', 8, 16, 4), |
| 532 | }, |
| 533 | [1] = { |
| 534 | .type = IIO_VOLTAGE, |
| 535 | .indexed = 1, |
| 536 | .channel = 1, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 537 | .scan_index = 1, |
| 538 | .scan_type = IIO_ST('u', 8, 16, 4), |
| 539 | }, |
| 540 | [2] = { |
| 541 | .type = IIO_VOLTAGE, |
| 542 | .indexed = 1, |
| 543 | .channel = 2, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 544 | .scan_index = 2, |
| 545 | .scan_type = IIO_ST('u', 8, 16, 4), |
| 546 | }, |
| 547 | [3] = { |
| 548 | .type = IIO_VOLTAGE, |
| 549 | .indexed = 1, |
| 550 | .channel = 3, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 551 | .scan_index = 3, |
| 552 | .scan_type = IIO_ST('u', 8, 16, 4), |
| 553 | }, |
| 554 | [4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
| 555 | }, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 556 | .num_channels = 5, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 557 | .int_vref_mv = 1024, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 558 | .info = &ad7991_info, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 559 | }, |
| 560 | [ad7992] = { |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 561 | .channel = { |
| 562 | [0] = { |
| 563 | .type = IIO_VOLTAGE, |
| 564 | .indexed = 1, |
| 565 | .channel = 0, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 566 | .scan_index = 0, |
| 567 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 568 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 569 | }, |
| 570 | [1] = { |
| 571 | .type = IIO_VOLTAGE, |
| 572 | .indexed = 1, |
| 573 | .channel = 1, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 574 | .scan_index = 1, |
| 575 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 576 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 577 | }, |
| 578 | [2] = IIO_CHAN_SOFT_TIMESTAMP(2), |
| 579 | }, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 580 | .num_channels = 3, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 581 | .int_vref_mv = 4096, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 582 | .default_config = AD7998_ALERT_EN, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 583 | .info = &ad7992_info, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 584 | }, |
| 585 | [ad7993] = { |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 586 | .channel = { |
| 587 | [0] = { |
| 588 | .type = IIO_VOLTAGE, |
| 589 | .indexed = 1, |
| 590 | .channel = 0, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 591 | .scan_index = 0, |
| 592 | .scan_type = IIO_ST('u', 10, 16, 2), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 593 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 594 | }, |
| 595 | [1] = { |
| 596 | .type = IIO_VOLTAGE, |
| 597 | .indexed = 1, |
| 598 | .channel = 1, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 599 | .scan_index = 1, |
| 600 | .scan_type = IIO_ST('u', 10, 16, 2), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 601 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 602 | }, |
| 603 | [2] = { |
| 604 | .type = IIO_VOLTAGE, |
| 605 | .indexed = 1, |
| 606 | .channel = 2, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 607 | .scan_index = 2, |
| 608 | .scan_type = IIO_ST('u', 10, 16, 2), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 609 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 610 | }, |
| 611 | [3] = { |
| 612 | .type = IIO_VOLTAGE, |
| 613 | .indexed = 1, |
| 614 | .channel = 3, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 615 | .scan_index = 3, |
| 616 | .scan_type = IIO_ST('u', 10, 16, 2), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 617 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 618 | }, |
| 619 | [4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
| 620 | }, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 621 | .num_channels = 5, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 622 | .int_vref_mv = 1024, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 623 | .default_config = AD7998_ALERT_EN, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 624 | .info = &ad7993_4_7_8_info, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 625 | }, |
| 626 | [ad7994] = { |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 627 | .channel = { |
| 628 | [0] = { |
| 629 | .type = IIO_VOLTAGE, |
| 630 | .indexed = 1, |
| 631 | .channel = 0, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 632 | .scan_index = 0, |
| 633 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 634 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 635 | }, |
| 636 | [1] = { |
| 637 | .type = IIO_VOLTAGE, |
| 638 | .indexed = 1, |
| 639 | .channel = 1, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 640 | .scan_index = 1, |
| 641 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 642 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 643 | }, |
| 644 | [2] = { |
| 645 | .type = IIO_VOLTAGE, |
| 646 | .indexed = 1, |
| 647 | .channel = 2, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 648 | .scan_index = 2, |
| 649 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 650 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 651 | }, |
| 652 | [3] = { |
| 653 | .type = IIO_VOLTAGE, |
| 654 | .indexed = 1, |
| 655 | .channel = 3, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 656 | .scan_index = 3, |
| 657 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 658 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 659 | }, |
| 660 | [4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
| 661 | }, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 662 | .num_channels = 5, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 663 | .int_vref_mv = 4096, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 664 | .default_config = AD7998_ALERT_EN, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 665 | .info = &ad7993_4_7_8_info, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 666 | }, |
| 667 | [ad7997] = { |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 668 | .channel = { |
| 669 | [0] = { |
| 670 | .type = IIO_VOLTAGE, |
| 671 | .indexed = 1, |
| 672 | .channel = 0, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 673 | .scan_index = 0, |
| 674 | .scan_type = IIO_ST('u', 10, 16, 2), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 675 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 676 | }, |
| 677 | [1] = { |
| 678 | .type = IIO_VOLTAGE, |
| 679 | .indexed = 1, |
| 680 | .channel = 1, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 681 | .scan_index = 1, |
| 682 | .scan_type = IIO_ST('u', 10, 16, 2), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 683 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 684 | }, |
| 685 | [2] = { |
| 686 | .type = IIO_VOLTAGE, |
| 687 | .indexed = 1, |
| 688 | .channel = 2, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 689 | .scan_index = 2, |
| 690 | .scan_type = IIO_ST('u', 10, 16, 2), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 691 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 692 | }, |
| 693 | [3] = { |
| 694 | .type = IIO_VOLTAGE, |
| 695 | .indexed = 1, |
| 696 | .channel = 3, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 697 | .scan_index = 3, |
| 698 | .scan_type = IIO_ST('u', 10, 16, 2), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 699 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 700 | }, |
| 701 | [4] = { |
| 702 | .type = IIO_VOLTAGE, |
| 703 | .indexed = 1, |
| 704 | .channel = 4, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 705 | .scan_index = 4, |
| 706 | .scan_type = IIO_ST('u', 10, 16, 2), |
| 707 | }, |
| 708 | [5] = { |
| 709 | .type = IIO_VOLTAGE, |
| 710 | .indexed = 1, |
| 711 | .channel = 5, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 712 | .scan_index = 5, |
| 713 | .scan_type = IIO_ST('u', 10, 16, 2), |
| 714 | }, |
| 715 | [6] = { |
| 716 | .type = IIO_VOLTAGE, |
| 717 | .indexed = 1, |
| 718 | .channel = 6, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 719 | .scan_index = 6, |
| 720 | .scan_type = IIO_ST('u', 10, 16, 2), |
| 721 | }, |
| 722 | [7] = { |
| 723 | .type = IIO_VOLTAGE, |
| 724 | .indexed = 1, |
| 725 | .channel = 7, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 726 | .scan_index = 7, |
| 727 | .scan_type = IIO_ST('u', 10, 16, 2), |
| 728 | }, |
| 729 | [8] = IIO_CHAN_SOFT_TIMESTAMP(8), |
| 730 | }, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 731 | .num_channels = 9, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 732 | .int_vref_mv = 1024, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 733 | .default_config = AD7998_ALERT_EN, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 734 | .info = &ad7993_4_7_8_info, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 735 | }, |
| 736 | [ad7998] = { |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 737 | .channel = { |
| 738 | [0] = { |
| 739 | .type = IIO_VOLTAGE, |
| 740 | .indexed = 1, |
| 741 | .channel = 0, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 742 | .scan_index = 0, |
| 743 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 744 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 745 | }, |
| 746 | [1] = { |
| 747 | .type = IIO_VOLTAGE, |
| 748 | .indexed = 1, |
| 749 | .channel = 1, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 750 | .scan_index = 1, |
| 751 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 752 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 753 | }, |
| 754 | [2] = { |
| 755 | .type = IIO_VOLTAGE, |
| 756 | .indexed = 1, |
| 757 | .channel = 2, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 758 | .scan_index = 2, |
| 759 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 760 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 761 | }, |
| 762 | [3] = { |
| 763 | .type = IIO_VOLTAGE, |
| 764 | .indexed = 1, |
| 765 | .channel = 3, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 766 | .scan_index = 3, |
| 767 | .scan_type = IIO_ST('u', 12, 16, 0), |
Jonathan Cameron | 231c5c3 | 2011-09-30 10:05:35 +0100 | [diff] [blame] | 768 | .event_mask = AD799X_EV_MASK, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 769 | }, |
| 770 | [4] = { |
| 771 | .type = IIO_VOLTAGE, |
| 772 | .indexed = 1, |
| 773 | .channel = 4, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 774 | .scan_index = 4, |
| 775 | .scan_type = IIO_ST('u', 12, 16, 0), |
| 776 | }, |
| 777 | [5] = { |
| 778 | .type = IIO_VOLTAGE, |
| 779 | .indexed = 1, |
| 780 | .channel = 5, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 781 | .scan_index = 5, |
| 782 | .scan_type = IIO_ST('u', 12, 16, 0), |
| 783 | }, |
| 784 | [6] = { |
| 785 | .type = IIO_VOLTAGE, |
| 786 | .indexed = 1, |
| 787 | .channel = 6, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 788 | .scan_index = 6, |
| 789 | .scan_type = IIO_ST('u', 12, 16, 0), |
| 790 | }, |
| 791 | [7] = { |
| 792 | .type = IIO_VOLTAGE, |
| 793 | .indexed = 1, |
| 794 | .channel = 7, |
Jonathan Cameron | 7c626f5 | 2011-09-30 10:05:31 +0100 | [diff] [blame] | 795 | .scan_index = 7, |
| 796 | .scan_type = IIO_ST('u', 12, 16, 0), |
| 797 | }, |
| 798 | [8] = IIO_CHAN_SOFT_TIMESTAMP(8), |
| 799 | }, |
Michael Hennerich | d22fd9c | 2011-05-18 14:41:52 +0100 | [diff] [blame] | 800 | .num_channels = 9, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 801 | .int_vref_mv = 4096, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 802 | .default_config = AD7998_ALERT_EN, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 803 | .info = &ad7993_4_7_8_info, |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 804 | }, |
| 805 | }; |
| 806 | |
| 807 | static int __devinit ad799x_probe(struct i2c_client *client, |
| 808 | const struct i2c_device_id *id) |
| 809 | { |
Jonathan Cameron | 26d25ae | 2011-09-02 17:14:40 +0100 | [diff] [blame] | 810 | int ret; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 811 | struct ad799x_platform_data *pdata = client->dev.platform_data; |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 812 | struct ad799x_state *st; |
| 813 | struct iio_dev *indio_dev = iio_allocate_device(sizeof(*st)); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 814 | |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 815 | if (indio_dev == NULL) |
| 816 | return -ENOMEM; |
| 817 | |
| 818 | st = iio_priv(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 819 | /* this is only used for device removal purposes */ |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 820 | i2c_set_clientdata(client, indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 821 | |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 822 | st->id = id->driver_data; |
| 823 | st->chip_info = &ad799x_chip_info_tbl[st->id]; |
| 824 | st->config = st->chip_info->default_config; |
| 825 | |
| 826 | /* TODO: Add pdata options for filtering and bit delay */ |
| 827 | |
| 828 | if (pdata) |
| 829 | st->int_vref_mv = pdata->vref_mv; |
| 830 | else |
| 831 | st->int_vref_mv = st->chip_info->int_vref_mv; |
| 832 | |
| 833 | st->reg = regulator_get(&client->dev, "vcc"); |
| 834 | if (!IS_ERR(st->reg)) { |
| 835 | ret = regulator_enable(st->reg); |
| 836 | if (ret) |
| 837 | goto error_put_reg; |
| 838 | } |
| 839 | st->client = client; |
| 840 | |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 841 | indio_dev->dev.parent = &client->dev; |
| 842 | indio_dev->name = id->name; |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 843 | indio_dev->info = st->chip_info->info; |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 844 | |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 845 | indio_dev->modes = INDIO_DIRECT_MODE; |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 846 | indio_dev->channels = st->chip_info->channel; |
| 847 | indio_dev->num_channels = st->chip_info->num_channels; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 848 | |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 849 | ret = ad799x_register_ring_funcs_and_init(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 850 | if (ret) |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 851 | goto error_disable_reg; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 852 | |
Jonathan Cameron | 14555b1 | 2011-09-21 11:15:57 +0100 | [diff] [blame] | 853 | ret = iio_buffer_register(indio_dev, |
| 854 | indio_dev->channels, |
| 855 | indio_dev->num_channels); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 856 | if (ret) |
| 857 | goto error_cleanup_ring; |
| 858 | |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 859 | if (client->irq > 0) { |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 860 | ret = request_threaded_irq(client->irq, |
| 861 | NULL, |
| 862 | ad799x_event_handler, |
| 863 | IRQF_TRIGGER_FALLING | |
| 864 | IRQF_ONESHOT, |
| 865 | client->name, |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 866 | indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 867 | if (ret) |
| 868 | goto error_cleanup_ring; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 869 | } |
Jonathan Cameron | 26d25ae | 2011-09-02 17:14:40 +0100 | [diff] [blame] | 870 | ret = iio_device_register(indio_dev); |
| 871 | if (ret) |
| 872 | goto error_free_irq; |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 873 | |
| 874 | return 0; |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 875 | |
Jonathan Cameron | 26d25ae | 2011-09-02 17:14:40 +0100 | [diff] [blame] | 876 | error_free_irq: |
| 877 | free_irq(client->irq, indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 878 | error_cleanup_ring: |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 879 | ad799x_ring_cleanup(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 880 | error_disable_reg: |
| 881 | if (!IS_ERR(st->reg)) |
| 882 | regulator_disable(st->reg); |
| 883 | error_put_reg: |
| 884 | if (!IS_ERR(st->reg)) |
| 885 | regulator_put(st->reg); |
Jonathan Cameron | 26d25ae | 2011-09-02 17:14:40 +0100 | [diff] [blame] | 886 | iio_free_device(indio_dev); |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 887 | |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 888 | return ret; |
| 889 | } |
| 890 | |
| 891 | static __devexit int ad799x_remove(struct i2c_client *client) |
| 892 | { |
Michael Hennerich | 1bf7ac7 | 2011-05-18 14:41:53 +0100 | [diff] [blame] | 893 | struct iio_dev *indio_dev = i2c_get_clientdata(client); |
| 894 | struct ad799x_state *st = iio_priv(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 895 | |
Jonathan Cameron | d2fffd6 | 2011-10-14 14:46:58 +0100 | [diff] [blame] | 896 | iio_device_unregister(indio_dev); |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 897 | if (client->irq > 0) |
Jonathan Cameron | 72148f6 | 2011-05-18 14:41:15 +0100 | [diff] [blame] | 898 | free_irq(client->irq, indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 899 | |
Jonathan Cameron | 14555b1 | 2011-09-21 11:15:57 +0100 | [diff] [blame] | 900 | iio_buffer_unregister(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 901 | ad799x_ring_cleanup(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 902 | if (!IS_ERR(st->reg)) { |
| 903 | regulator_disable(st->reg); |
| 904 | regulator_put(st->reg); |
| 905 | } |
Jonathan Cameron | d2fffd6 | 2011-10-14 14:46:58 +0100 | [diff] [blame] | 906 | iio_free_device(indio_dev); |
Michael Hennerich | 985dbe7 | 2010-10-01 16:41:51 +0200 | [diff] [blame] | 907 | |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | static const struct i2c_device_id ad799x_id[] = { |
| 912 | { "ad7991", ad7991 }, |
| 913 | { "ad7995", ad7995 }, |
| 914 | { "ad7999", ad7999 }, |
| 915 | { "ad7992", ad7992 }, |
| 916 | { "ad7993", ad7993 }, |
| 917 | { "ad7994", ad7994 }, |
| 918 | { "ad7997", ad7997 }, |
| 919 | { "ad7998", ad7998 }, |
| 920 | {} |
| 921 | }; |
| 922 | |
| 923 | MODULE_DEVICE_TABLE(i2c, ad799x_id); |
| 924 | |
| 925 | static struct i2c_driver ad799x_driver = { |
| 926 | .driver = { |
| 927 | .name = "ad799x", |
| 928 | }, |
| 929 | .probe = ad799x_probe, |
| 930 | .remove = __devexit_p(ad799x_remove), |
| 931 | .id_table = ad799x_id, |
| 932 | }; |
| 933 | |
| 934 | static __init int ad799x_init(void) |
| 935 | { |
| 936 | return i2c_add_driver(&ad799x_driver); |
| 937 | } |
| 938 | |
| 939 | static __exit void ad799x_exit(void) |
| 940 | { |
| 941 | i2c_del_driver(&ad799x_driver); |
| 942 | } |
| 943 | |
| 944 | MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); |
| 945 | MODULE_DESCRIPTION("Analog Devices AD799x ADC"); |
| 946 | MODULE_LICENSE("GPL v2"); |
| 947 | MODULE_ALIAS("i2c:ad799x"); |
| 948 | |
| 949 | module_init(ad799x_init); |
| 950 | module_exit(ad799x_exit); |