Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ads1015.c - lm_sensors driver for ads1015 12-bit 4-input ADC |
| 3 | * (C) Copyright 2010 |
| 4 | * Dirk Eibach, Guntermann & Drunck GmbH <eibach@gdsys.de> |
| 5 | * |
| 6 | * Based on the ads7828 driver by Steve Hardy. |
| 7 | * |
| 8 | * Datasheet available at: http://focus.ti.com/lit/ds/symlink/ads1015.pdf |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 23 | */ |
| 24 | |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/init.h> |
| 27 | #include <linux/slab.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/i2c.h> |
| 30 | #include <linux/hwmon.h> |
| 31 | #include <linux/hwmon-sysfs.h> |
| 32 | #include <linux/err.h> |
| 33 | #include <linux/mutex.h> |
Javier Martinez Canillas | a140986 | 2017-02-24 10:12:56 -0300 | [diff] [blame] | 34 | #include <linux/of_device.h> |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 35 | #include <linux/of.h> |
| 36 | |
Wolfram Sang | 9010624c | 2017-05-21 22:34:39 +0200 | [diff] [blame] | 37 | #include <linux/platform_data/ads1015.h> |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 38 | |
| 39 | /* ADS1015 registers */ |
| 40 | enum { |
| 41 | ADS1015_CONVERSION = 0, |
| 42 | ADS1015_CONFIG = 1, |
| 43 | }; |
| 44 | |
| 45 | /* PGA fullscale voltages in mV */ |
| 46 | static const unsigned int fullscale_table[8] = { |
| 47 | 6144, 4096, 2048, 1024, 512, 256, 256, 256 }; |
| 48 | |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 49 | /* Data rates in samples per second */ |
Evgeniy Dushistov | 60c1f31 | 2013-08-01 23:23:48 +0400 | [diff] [blame] | 50 | static const unsigned int data_rate_table_1015[8] = { |
| 51 | 128, 250, 490, 920, 1600, 2400, 3300, 3300 |
| 52 | }; |
| 53 | |
| 54 | static const unsigned int data_rate_table_1115[8] = { |
| 55 | 8, 16, 32, 64, 128, 250, 475, 860 |
| 56 | }; |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 57 | |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 58 | #define ADS1015_DEFAULT_CHANNELS 0xff |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 59 | #define ADS1015_DEFAULT_PGA 2 |
| 60 | #define ADS1015_DEFAULT_DATA_RATE 4 |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 61 | |
Evgeniy Dushistov | 60c1f31 | 2013-08-01 23:23:48 +0400 | [diff] [blame] | 62 | enum ads1015_chips { |
| 63 | ads1015, |
| 64 | ads1115, |
| 65 | }; |
| 66 | |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 67 | struct ads1015_data { |
| 68 | struct device *hwmon_dev; |
| 69 | struct mutex update_lock; /* mutex protect updates */ |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 70 | struct ads1015_channel_data channel_data[ADS1015_CHANNELS]; |
Evgeniy Dushistov | 60c1f31 | 2013-08-01 23:23:48 +0400 | [diff] [blame] | 71 | enum ads1015_chips id; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 72 | }; |
| 73 | |
Guenter Roeck | 1196573f | 2012-04-09 13:53:00 -0400 | [diff] [blame] | 74 | static int ads1015_read_adc(struct i2c_client *client, unsigned int channel) |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 75 | { |
| 76 | u16 config; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 77 | struct ads1015_data *data = i2c_get_clientdata(client); |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 78 | unsigned int pga = data->channel_data[channel].pga; |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 79 | unsigned int data_rate = data->channel_data[channel].data_rate; |
| 80 | unsigned int conversion_time_ms; |
Evgeniy Dushistov | 60c1f31 | 2013-08-01 23:23:48 +0400 | [diff] [blame] | 81 | const unsigned int * const rate_table = data->id == ads1115 ? |
| 82 | data_rate_table_1115 : data_rate_table_1015; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 83 | int res; |
| 84 | |
| 85 | mutex_lock(&data->update_lock); |
| 86 | |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 87 | /* get channel parameters */ |
Jean Delvare | 90f4102 | 2011-11-04 12:00:47 +0100 | [diff] [blame] | 88 | res = i2c_smbus_read_word_swapped(client, ADS1015_CONFIG); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 89 | if (res < 0) |
| 90 | goto err_unlock; |
| 91 | config = res; |
Evgeniy Dushistov | 60c1f31 | 2013-08-01 23:23:48 +0400 | [diff] [blame] | 92 | conversion_time_ms = DIV_ROUND_UP(1000, rate_table[data_rate]); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 93 | |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 94 | /* setup and start single conversion */ |
| 95 | config &= 0x001f; |
| 96 | config |= (1 << 15) | (1 << 8); |
| 97 | config |= (channel & 0x0007) << 12; |
| 98 | config |= (pga & 0x0007) << 9; |
| 99 | config |= (data_rate & 0x0007) << 5; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 100 | |
Jean Delvare | 90f4102 | 2011-11-04 12:00:47 +0100 | [diff] [blame] | 101 | res = i2c_smbus_write_word_swapped(client, ADS1015_CONFIG, config); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 102 | if (res < 0) |
| 103 | goto err_unlock; |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 104 | |
| 105 | /* wait until conversion finished */ |
| 106 | msleep(conversion_time_ms); |
Jean Delvare | 90f4102 | 2011-11-04 12:00:47 +0100 | [diff] [blame] | 107 | res = i2c_smbus_read_word_swapped(client, ADS1015_CONFIG); |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 108 | if (res < 0) |
| 109 | goto err_unlock; |
| 110 | config = res; |
| 111 | if (!(config & (1 << 15))) { |
| 112 | /* conversion not finished in time */ |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 113 | res = -EIO; |
| 114 | goto err_unlock; |
| 115 | } |
| 116 | |
Jean Delvare | 90f4102 | 2011-11-04 12:00:47 +0100 | [diff] [blame] | 117 | res = i2c_smbus_read_word_swapped(client, ADS1015_CONVERSION); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 118 | |
| 119 | err_unlock: |
| 120 | mutex_unlock(&data->update_lock); |
| 121 | return res; |
| 122 | } |
| 123 | |
Guenter Roeck | 1196573f | 2012-04-09 13:53:00 -0400 | [diff] [blame] | 124 | static int ads1015_reg_to_mv(struct i2c_client *client, unsigned int channel, |
| 125 | s16 reg) |
| 126 | { |
| 127 | struct ads1015_data *data = i2c_get_clientdata(client); |
| 128 | unsigned int pga = data->channel_data[channel].pga; |
| 129 | int fullscale = fullscale_table[pga]; |
Peter Rosin | acc1469 | 2016-02-18 14:07:52 +0100 | [diff] [blame] | 130 | const int mask = data->id == ads1115 ? 0x7fff : 0x7ff0; |
Guenter Roeck | 1196573f | 2012-04-09 13:53:00 -0400 | [diff] [blame] | 131 | |
Evgeniy Dushistov | 60c1f31 | 2013-08-01 23:23:48 +0400 | [diff] [blame] | 132 | return DIV_ROUND_CLOSEST(reg * fullscale, mask); |
Guenter Roeck | 1196573f | 2012-04-09 13:53:00 -0400 | [diff] [blame] | 133 | } |
| 134 | |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 135 | /* sysfs callback function */ |
| 136 | static ssize_t show_in(struct device *dev, struct device_attribute *da, |
| 137 | char *buf) |
| 138 | { |
| 139 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
| 140 | struct i2c_client *client = to_i2c_client(dev); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 141 | int res; |
Guenter Roeck | 1196573f | 2012-04-09 13:53:00 -0400 | [diff] [blame] | 142 | int index = attr->index; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 143 | |
Guenter Roeck | 1196573f | 2012-04-09 13:53:00 -0400 | [diff] [blame] | 144 | res = ads1015_read_adc(client, index); |
| 145 | if (res < 0) |
| 146 | return res; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 147 | |
Guenter Roeck | 1196573f | 2012-04-09 13:53:00 -0400 | [diff] [blame] | 148 | return sprintf(buf, "%d\n", ads1015_reg_to_mv(client, index, res)); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 149 | } |
| 150 | |
Jean Delvare | fdf241a | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 151 | static const struct sensor_device_attribute ads1015_in[] = { |
| 152 | SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), |
| 153 | SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), |
| 154 | SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), |
| 155 | SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), |
| 156 | SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), |
| 157 | SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), |
| 158 | SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), |
| 159 | SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 160 | }; |
| 161 | |
| 162 | /* |
| 163 | * Driver interface |
| 164 | */ |
| 165 | |
| 166 | static int ads1015_remove(struct i2c_client *client) |
| 167 | { |
| 168 | struct ads1015_data *data = i2c_get_clientdata(client); |
Jean Delvare | fdf241a | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 169 | int k; |
| 170 | |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 171 | hwmon_device_unregister(data->hwmon_dev); |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 172 | for (k = 0; k < ADS1015_CHANNELS; ++k) |
Jean Delvare | fdf241a | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 173 | device_remove_file(&client->dev, &ads1015_in[k].dev_attr); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 174 | return 0; |
| 175 | } |
| 176 | |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 177 | #ifdef CONFIG_OF |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 178 | static int ads1015_get_channels_config_of(struct i2c_client *client) |
| 179 | { |
| 180 | struct ads1015_data *data = i2c_get_clientdata(client); |
| 181 | struct device_node *node; |
| 182 | |
| 183 | if (!client->dev.of_node |
| 184 | || !of_get_next_child(client->dev.of_node, NULL)) |
| 185 | return -EINVAL; |
| 186 | |
| 187 | for_each_child_of_node(client->dev.of_node, node) { |
Axel Lin | 8e35762 | 2014-08-05 10:56:47 +0800 | [diff] [blame] | 188 | u32 pval; |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 189 | unsigned int channel; |
| 190 | unsigned int pga = ADS1015_DEFAULT_PGA; |
| 191 | unsigned int data_rate = ADS1015_DEFAULT_DATA_RATE; |
| 192 | |
Axel Lin | 8e35762 | 2014-08-05 10:56:47 +0800 | [diff] [blame] | 193 | if (of_property_read_u32(node, "reg", &pval)) { |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 194 | dev_err(&client->dev, "invalid reg on %s\n", |
| 195 | node->full_name); |
| 196 | continue; |
| 197 | } |
| 198 | |
Axel Lin | 8e35762 | 2014-08-05 10:56:47 +0800 | [diff] [blame] | 199 | channel = pval; |
Axel Lin | 56de137 | 2014-07-30 11:13:52 +0800 | [diff] [blame] | 200 | if (channel >= ADS1015_CHANNELS) { |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 201 | dev_err(&client->dev, |
| 202 | "invalid channel index %d on %s\n", |
| 203 | channel, node->full_name); |
| 204 | continue; |
| 205 | } |
| 206 | |
Axel Lin | 8e35762 | 2014-08-05 10:56:47 +0800 | [diff] [blame] | 207 | if (!of_property_read_u32(node, "ti,gain", &pval)) { |
| 208 | pga = pval; |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 209 | if (pga > 6) { |
Axel Lin | 8e35762 | 2014-08-05 10:56:47 +0800 | [diff] [blame] | 210 | dev_err(&client->dev, "invalid gain on %s\n", |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 211 | node->full_name); |
Axel Lin | e981429 | 2014-08-05 09:59:49 +0800 | [diff] [blame] | 212 | return -EINVAL; |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | |
Axel Lin | 8e35762 | 2014-08-05 10:56:47 +0800 | [diff] [blame] | 216 | if (!of_property_read_u32(node, "ti,datarate", &pval)) { |
| 217 | data_rate = pval; |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 218 | if (data_rate > 7) { |
| 219 | dev_err(&client->dev, |
| 220 | "invalid data_rate on %s\n", |
| 221 | node->full_name); |
Axel Lin | e981429 | 2014-08-05 09:59:49 +0800 | [diff] [blame] | 222 | return -EINVAL; |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | |
| 226 | data->channel_data[channel].enabled = true; |
| 227 | data->channel_data[channel].pga = pga; |
| 228 | data->channel_data[channel].data_rate = data_rate; |
| 229 | } |
| 230 | |
| 231 | return 0; |
| 232 | } |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 233 | #endif |
| 234 | |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 235 | static void ads1015_get_channels_config(struct i2c_client *client) |
| 236 | { |
| 237 | unsigned int k; |
| 238 | struct ads1015_data *data = i2c_get_clientdata(client); |
| 239 | struct ads1015_platform_data *pdata = dev_get_platdata(&client->dev); |
| 240 | |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 241 | /* prefer platform data */ |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 242 | if (pdata) { |
| 243 | memcpy(data->channel_data, pdata->channel_data, |
| 244 | sizeof(data->channel_data)); |
| 245 | return; |
| 246 | } |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 247 | |
| 248 | #ifdef CONFIG_OF |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 249 | if (!ads1015_get_channels_config_of(client)) |
| 250 | return; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 251 | #endif |
| 252 | |
| 253 | /* fallback on default configuration */ |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 254 | for (k = 0; k < ADS1015_CHANNELS; ++k) { |
| 255 | data->channel_data[k].enabled = true; |
| 256 | data->channel_data[k].pga = ADS1015_DEFAULT_PGA; |
| 257 | data->channel_data[k].data_rate = ADS1015_DEFAULT_DATA_RATE; |
| 258 | } |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | static int ads1015_probe(struct i2c_client *client, |
| 262 | const struct i2c_device_id *id) |
| 263 | { |
| 264 | struct ads1015_data *data; |
| 265 | int err; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 266 | unsigned int k; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 267 | |
Guenter Roeck | 57457e3 | 2012-06-02 09:58:00 -0700 | [diff] [blame] | 268 | data = devm_kzalloc(&client->dev, sizeof(struct ads1015_data), |
| 269 | GFP_KERNEL); |
| 270 | if (!data) |
| 271 | return -ENOMEM; |
Javier Martinez Canillas | a140986 | 2017-02-24 10:12:56 -0300 | [diff] [blame] | 272 | |
| 273 | if (client->dev.of_node) |
| 274 | data->id = (enum ads1015_chips) |
| 275 | of_device_get_match_data(&client->dev); |
| 276 | else |
| 277 | data->id = id->driver_data; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 278 | i2c_set_clientdata(client, data); |
| 279 | mutex_init(&data->update_lock); |
| 280 | |
| 281 | /* build sysfs attribute group */ |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 282 | ads1015_get_channels_config(client); |
| 283 | for (k = 0; k < ADS1015_CHANNELS; ++k) { |
| 284 | if (!data->channel_data[k].enabled) |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 285 | continue; |
Jean Delvare | fdf241a | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 286 | err = device_create_file(&client->dev, &ads1015_in[k].dev_attr); |
| 287 | if (err) |
Guenter Roeck | 363434b | 2012-02-22 08:13:52 -0800 | [diff] [blame] | 288 | goto exit_remove; |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 289 | } |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 290 | |
| 291 | data->hwmon_dev = hwmon_device_register(&client->dev); |
| 292 | if (IS_ERR(data->hwmon_dev)) { |
| 293 | err = PTR_ERR(data->hwmon_dev); |
| 294 | goto exit_remove; |
| 295 | } |
| 296 | |
| 297 | return 0; |
| 298 | |
| 299 | exit_remove: |
Dirk Eibach | c004686 | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 300 | for (k = 0; k < ADS1015_CHANNELS; ++k) |
Jean Delvare | fdf241a | 2011-03-21 17:59:37 +0100 | [diff] [blame] | 301 | device_remove_file(&client->dev, &ads1015_in[k].dev_attr); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 302 | return err; |
| 303 | } |
| 304 | |
| 305 | static const struct i2c_device_id ads1015_id[] = { |
Evgeniy Dushistov | 60c1f31 | 2013-08-01 23:23:48 +0400 | [diff] [blame] | 306 | { "ads1015", ads1015}, |
| 307 | { "ads1115", ads1115}, |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 308 | { } |
| 309 | }; |
| 310 | MODULE_DEVICE_TABLE(i2c, ads1015_id); |
| 311 | |
Javier Martinez Canillas | a140986 | 2017-02-24 10:12:56 -0300 | [diff] [blame] | 312 | static const struct of_device_id ads1015_of_match[] = { |
| 313 | { |
| 314 | .compatible = "ti,ads1015", |
| 315 | .data = (void *)ads1015 |
| 316 | }, |
| 317 | { |
| 318 | .compatible = "ti,ads1115", |
| 319 | .data = (void *)ads1115 |
| 320 | }, |
| 321 | { }, |
| 322 | }; |
| 323 | MODULE_DEVICE_TABLE(of, ads1015_of_match); |
| 324 | |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 325 | static struct i2c_driver ads1015_driver = { |
| 326 | .driver = { |
| 327 | .name = "ads1015", |
Javier Martinez Canillas | a140986 | 2017-02-24 10:12:56 -0300 | [diff] [blame] | 328 | .of_match_table = of_match_ptr(ads1015_of_match), |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 329 | }, |
| 330 | .probe = ads1015_probe, |
| 331 | .remove = ads1015_remove, |
| 332 | .id_table = ads1015_id, |
| 333 | }; |
| 334 | |
Axel Lin | f0967ee | 2012-01-20 15:38:18 +0800 | [diff] [blame] | 335 | module_i2c_driver(ads1015_driver); |
Dirk Eibach | 8c22a8f | 2011-03-21 17:59:36 +0100 | [diff] [blame] | 336 | |
| 337 | MODULE_AUTHOR("Dirk Eibach <eibach@gdsys.de>"); |
| 338 | MODULE_DESCRIPTION("ADS1015 driver"); |
| 339 | MODULE_LICENSE("GPL"); |