Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 1 | /* |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 2 | * Driver for the ADC on Freescale Semiconductor MC13783 and MC13892 PMICs. |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 3 | * |
| 4 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. |
| 5 | * Copyright (C) 2009 Sascha Hauer, Pengutronix |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License |
| 9 | * as published by the Free Software Foundation; either version 2 |
| 10 | * of the License, or (at your option) any later version. |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * this program; if not, write to the Free Software Foundation, Inc., 51 |
| 18 | * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 21 | #include <linux/mfd/mc13xxx.h> |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/hwmon-sysfs.h> |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/hwmon.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 27 | #include <linux/slab.h> |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 28 | #include <linux/init.h> |
| 29 | #include <linux/err.h> |
| 30 | |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 31 | #define DRIVER_NAME "mc13783-adc" |
| 32 | |
| 33 | /* platform device id driver data */ |
| 34 | #define MC13783_ADC_16CHANS 1 |
| 35 | #define MC13783_ADC_BPDIV2 2 |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 36 | |
| 37 | struct mc13783_adc_priv { |
Uwe Kleine-König | 613c27a | 2011-08-24 15:28:24 +0200 | [diff] [blame] | 38 | struct mc13xxx *mc13xxx; |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 39 | struct device *hwmon_dev; |
Guenter Roeck | ae02e74 | 2013-09-13 10:25:53 -0700 | [diff] [blame] | 40 | char name[PLATFORM_NAME_SIZE]; |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 41 | }; |
| 42 | |
Julia Lawall | 918b4056 | 2016-12-22 13:04:59 +0100 | [diff] [blame] | 43 | static ssize_t name_show(struct device *dev, struct device_attribute *devattr, |
| 44 | char *buf) |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 45 | { |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 46 | struct mc13783_adc_priv *priv = dev_get_drvdata(dev); |
| 47 | |
| 48 | return sprintf(buf, "%s\n", priv->name); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | static int mc13783_adc_read(struct device *dev, |
| 52 | struct device_attribute *devattr, unsigned int *val) |
| 53 | { |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 54 | struct mc13783_adc_priv *priv = dev_get_drvdata(dev); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 55 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
| 56 | unsigned int channel = attr->index; |
| 57 | unsigned int sample[4]; |
| 58 | int ret; |
| 59 | |
Uwe Kleine-König | 613c27a | 2011-08-24 15:28:24 +0200 | [diff] [blame] | 60 | ret = mc13xxx_adc_do_conversion(priv->mc13xxx, |
| 61 | MC13XXX_ADC_MODE_MULT_CHAN, |
Michael Thalmeier | 1039d76 | 2012-02-20 12:18:13 +0100 | [diff] [blame] | 62 | channel, 0, 0, sample); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 63 | if (ret) |
| 64 | return ret; |
| 65 | |
Andrey Gusakov | ed645cc | 2018-03-27 17:19:49 +0300 | [diff] [blame] | 66 | /* ADIN7 subchannels */ |
| 67 | if (channel >= 16) |
| 68 | channel = 7; |
| 69 | |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 70 | channel &= 0x7; |
| 71 | |
| 72 | *val = (sample[channel % 4] >> (channel > 3 ? 14 : 2)) & 0x3ff; |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | static ssize_t mc13783_adc_read_bp(struct device *dev, |
| 78 | struct device_attribute *devattr, char *buf) |
| 79 | { |
| 80 | unsigned val; |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 81 | struct platform_device *pdev = to_platform_device(dev); |
| 82 | kernel_ulong_t driver_data = platform_get_device_id(pdev)->driver_data; |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 83 | int ret = mc13783_adc_read(dev, devattr, &val); |
| 84 | |
| 85 | if (ret) |
| 86 | return ret; |
| 87 | |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 88 | if (driver_data & MC13783_ADC_BPDIV2) |
| 89 | val = DIV_ROUND_CLOSEST(val * 9, 2); |
| 90 | else |
| 91 | /* |
| 92 | * BP (channel 2) reports with offset 2.4V to the actual value |
| 93 | * to fit the input range of the ADC. unit = 2.25mV = 9/4 mV. |
| 94 | */ |
| 95 | val = DIV_ROUND_CLOSEST(val * 9, 4) + 2400; |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 96 | |
| 97 | return sprintf(buf, "%u\n", val); |
| 98 | } |
| 99 | |
| 100 | static ssize_t mc13783_adc_read_gp(struct device *dev, |
| 101 | struct device_attribute *devattr, char *buf) |
| 102 | { |
| 103 | unsigned val; |
| 104 | int ret = mc13783_adc_read(dev, devattr, &val); |
| 105 | |
| 106 | if (ret) |
| 107 | return ret; |
| 108 | |
| 109 | /* |
| 110 | * input range is [0, 2.3V], val has 10 bits, so each bit |
| 111 | * is worth 9/4 mV. |
| 112 | */ |
| 113 | val = DIV_ROUND_CLOSEST(val * 9, 4); |
| 114 | |
| 115 | return sprintf(buf, "%u\n", val); |
| 116 | } |
| 117 | |
Andrey Gusakov | ed645cc | 2018-03-27 17:19:49 +0300 | [diff] [blame] | 118 | static ssize_t mc13783_adc_read_uid(struct device *dev, |
| 119 | struct device_attribute *devattr, char *buf) |
| 120 | { |
| 121 | unsigned int val; |
| 122 | struct platform_device *pdev = to_platform_device(dev); |
| 123 | kernel_ulong_t driver_data = platform_get_device_id(pdev)->driver_data; |
| 124 | int ret = mc13783_adc_read(dev, devattr, &val); |
| 125 | |
| 126 | if (ret) |
| 127 | return ret; |
| 128 | |
| 129 | if (driver_data & MC13783_ADC_BPDIV2) |
| 130 | /* MC13892 have 1/2 divider, input range is [0, 4.800V] */ |
| 131 | val = DIV_ROUND_CLOSEST(val * 4800, 1024); |
| 132 | else |
| 133 | /* MC13783 have 0.9 divider, input range is [0, 2.555V] */ |
| 134 | val = DIV_ROUND_CLOSEST(val * 2555, 1024); |
| 135 | |
| 136 | return sprintf(buf, "%u\n", val); |
| 137 | } |
| 138 | |
| 139 | static ssize_t mc13783_adc_read_temp(struct device *dev, |
| 140 | struct device_attribute *devattr, char *buf) |
| 141 | { |
| 142 | unsigned int val; |
| 143 | struct platform_device *pdev = to_platform_device(dev); |
| 144 | kernel_ulong_t driver_data = platform_get_device_id(pdev)->driver_data; |
| 145 | int ret = mc13783_adc_read(dev, devattr, &val); |
| 146 | |
| 147 | if (ret) |
| 148 | return ret; |
| 149 | |
| 150 | if (driver_data & MC13783_ADC_BPDIV2) { |
| 151 | /* |
| 152 | * MC13892: |
| 153 | * Die Temperature Read Out Code at 25C 680 |
| 154 | * Temperature change per LSB +0.4244C |
| 155 | */ |
| 156 | ret = DIV_ROUND_CLOSEST(-2635920 + val * 4244, 10); |
| 157 | } else { |
| 158 | /* |
| 159 | * MC13783: |
| 160 | * Die Temperature Read Out Code at 25C 282 |
| 161 | * Temperature change per LSB -1.14C |
| 162 | */ |
| 163 | ret = 346480 - 1140 * val; |
| 164 | } |
| 165 | |
| 166 | return sprintf(buf, "%d\n", ret); |
| 167 | } |
| 168 | |
Julia Lawall | 918b4056 | 2016-12-22 13:04:59 +0100 | [diff] [blame] | 169 | static DEVICE_ATTR_RO(name); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 170 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, mc13783_adc_read_bp, NULL, 2); |
| 171 | static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, mc13783_adc_read_gp, NULL, 5); |
| 172 | static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, mc13783_adc_read_gp, NULL, 6); |
| 173 | static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, mc13783_adc_read_gp, NULL, 7); |
| 174 | static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, mc13783_adc_read_gp, NULL, 8); |
| 175 | static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, mc13783_adc_read_gp, NULL, 9); |
| 176 | static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, mc13783_adc_read_gp, NULL, 10); |
| 177 | static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, mc13783_adc_read_gp, NULL, 11); |
| 178 | static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, mc13783_adc_read_gp, NULL, 12); |
| 179 | static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, mc13783_adc_read_gp, NULL, 13); |
| 180 | static SENSOR_DEVICE_ATTR(in14_input, S_IRUGO, mc13783_adc_read_gp, NULL, 14); |
| 181 | static SENSOR_DEVICE_ATTR(in15_input, S_IRUGO, mc13783_adc_read_gp, NULL, 15); |
Andrey Gusakov | ed645cc | 2018-03-27 17:19:49 +0300 | [diff] [blame] | 182 | static SENSOR_DEVICE_ATTR(in16_input, S_IRUGO, mc13783_adc_read_uid, NULL, 16); |
| 183 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, |
| 184 | mc13783_adc_read_temp, NULL, 17); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 185 | |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 186 | static struct attribute *mc13783_attr_base[] = { |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 187 | &dev_attr_name.attr, |
| 188 | &sensor_dev_attr_in2_input.dev_attr.attr, |
| 189 | &sensor_dev_attr_in5_input.dev_attr.attr, |
| 190 | &sensor_dev_attr_in6_input.dev_attr.attr, |
| 191 | &sensor_dev_attr_in7_input.dev_attr.attr, |
Andrey Gusakov | ed645cc | 2018-03-27 17:19:49 +0300 | [diff] [blame] | 192 | &sensor_dev_attr_in16_input.dev_attr.attr, |
| 193 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 194 | NULL |
| 195 | }; |
| 196 | |
| 197 | static const struct attribute_group mc13783_group_base = { |
| 198 | .attrs = mc13783_attr_base, |
| 199 | }; |
| 200 | |
| 201 | /* these are only used if MC13783_ADC_16CHANS is provided in driver data */ |
| 202 | static struct attribute *mc13783_attr_16chans[] = { |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 203 | &sensor_dev_attr_in8_input.dev_attr.attr, |
| 204 | &sensor_dev_attr_in9_input.dev_attr.attr, |
| 205 | &sensor_dev_attr_in10_input.dev_attr.attr, |
| 206 | &sensor_dev_attr_in11_input.dev_attr.attr, |
| 207 | NULL |
| 208 | }; |
| 209 | |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 210 | static const struct attribute_group mc13783_group_16chans = { |
| 211 | .attrs = mc13783_attr_16chans, |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | /* last four channels may be occupied by the touchscreen */ |
| 215 | static struct attribute *mc13783_attr_ts[] = { |
| 216 | &sensor_dev_attr_in12_input.dev_attr.attr, |
| 217 | &sensor_dev_attr_in13_input.dev_attr.attr, |
| 218 | &sensor_dev_attr_in14_input.dev_attr.attr, |
| 219 | &sensor_dev_attr_in15_input.dev_attr.attr, |
| 220 | NULL |
| 221 | }; |
| 222 | |
| 223 | static const struct attribute_group mc13783_group_ts = { |
| 224 | .attrs = mc13783_attr_ts, |
| 225 | }; |
| 226 | |
Uwe Kleine-König | eaf06ee | 2010-08-02 11:14:18 +0200 | [diff] [blame] | 227 | static int mc13783_adc_use_touchscreen(struct platform_device *pdev) |
| 228 | { |
| 229 | struct mc13783_adc_priv *priv = platform_get_drvdata(pdev); |
Uwe Kleine-König | 613c27a | 2011-08-24 15:28:24 +0200 | [diff] [blame] | 230 | unsigned flags = mc13xxx_get_flags(priv->mc13xxx); |
Uwe Kleine-König | eaf06ee | 2010-08-02 11:14:18 +0200 | [diff] [blame] | 231 | |
Uwe Kleine-König | 613c27a | 2011-08-24 15:28:24 +0200 | [diff] [blame] | 232 | return flags & MC13XXX_USE_TOUCHSCREEN; |
Uwe Kleine-König | eaf06ee | 2010-08-02 11:14:18 +0200 | [diff] [blame] | 233 | } |
| 234 | |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 235 | static int __init mc13783_adc_probe(struct platform_device *pdev) |
| 236 | { |
| 237 | struct mc13783_adc_priv *priv; |
| 238 | int ret; |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 239 | const struct platform_device_id *id = platform_get_device_id(pdev); |
| 240 | char *dash; |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 241 | |
Guenter Roeck | ed2e073 | 2012-06-02 09:49:11 -0700 | [diff] [blame] | 242 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 243 | if (!priv) |
| 244 | return -ENOMEM; |
| 245 | |
Uwe Kleine-König | 613c27a | 2011-08-24 15:28:24 +0200 | [diff] [blame] | 246 | priv->mc13xxx = dev_get_drvdata(pdev->dev.parent); |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 247 | snprintf(priv->name, ARRAY_SIZE(priv->name), "%s", id->name); |
| 248 | dash = strchr(priv->name, '-'); |
| 249 | if (dash) |
| 250 | *dash = '\0'; |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 251 | |
| 252 | platform_set_drvdata(pdev, priv); |
| 253 | |
| 254 | /* Register sysfs hooks */ |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 255 | ret = sysfs_create_group(&pdev->dev.kobj, &mc13783_group_base); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 256 | if (ret) |
Guenter Roeck | ed2e073 | 2012-06-02 09:49:11 -0700 | [diff] [blame] | 257 | return ret; |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 258 | |
| 259 | if (id->driver_data & MC13783_ADC_16CHANS) { |
| 260 | ret = sysfs_create_group(&pdev->dev.kobj, |
| 261 | &mc13783_group_16chans); |
| 262 | if (ret) |
| 263 | goto out_err_create_16chans; |
| 264 | } |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 265 | |
Uwe Kleine-König | eaf06ee | 2010-08-02 11:14:18 +0200 | [diff] [blame] | 266 | if (!mc13783_adc_use_touchscreen(pdev)) { |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 267 | ret = sysfs_create_group(&pdev->dev.kobj, &mc13783_group_ts); |
| 268 | if (ret) |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 269 | goto out_err_create_ts; |
Uwe Kleine-König | eaf06ee | 2010-08-02 11:14:18 +0200 | [diff] [blame] | 270 | } |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 271 | |
| 272 | priv->hwmon_dev = hwmon_device_register(&pdev->dev); |
| 273 | if (IS_ERR(priv->hwmon_dev)) { |
| 274 | ret = PTR_ERR(priv->hwmon_dev); |
| 275 | dev_err(&pdev->dev, |
| 276 | "hwmon_device_register failed with %d.\n", ret); |
| 277 | goto out_err_register; |
| 278 | } |
| 279 | |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 280 | return 0; |
| 281 | |
| 282 | out_err_register: |
| 283 | |
Uwe Kleine-König | eaf06ee | 2010-08-02 11:14:18 +0200 | [diff] [blame] | 284 | if (!mc13783_adc_use_touchscreen(pdev)) |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 285 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_ts); |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 286 | out_err_create_ts: |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 287 | |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 288 | if (id->driver_data & MC13783_ADC_16CHANS) |
| 289 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_16chans); |
| 290 | out_err_create_16chans: |
| 291 | |
| 292 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_base); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 293 | return ret; |
| 294 | } |
| 295 | |
Bill Pemberton | 281dfd0 | 2012-11-19 13:25:51 -0500 | [diff] [blame] | 296 | static int mc13783_adc_remove(struct platform_device *pdev) |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 297 | { |
| 298 | struct mc13783_adc_priv *priv = platform_get_drvdata(pdev); |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 299 | kernel_ulong_t driver_data = platform_get_device_id(pdev)->driver_data; |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 300 | |
| 301 | hwmon_device_unregister(priv->hwmon_dev); |
| 302 | |
Uwe Kleine-König | eaf06ee | 2010-08-02 11:14:18 +0200 | [diff] [blame] | 303 | if (!mc13783_adc_use_touchscreen(pdev)) |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 304 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_ts); |
| 305 | |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 306 | if (driver_data & MC13783_ADC_16CHANS) |
| 307 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_16chans); |
| 308 | |
| 309 | sysfs_remove_group(&pdev->dev.kobj, &mc13783_group_base); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 310 | |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 311 | return 0; |
| 312 | } |
| 313 | |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 314 | static const struct platform_device_id mc13783_adc_idtable[] = { |
| 315 | { |
| 316 | .name = "mc13783-adc", |
| 317 | .driver_data = MC13783_ADC_16CHANS, |
| 318 | }, { |
| 319 | .name = "mc13892-adc", |
| 320 | .driver_data = MC13783_ADC_BPDIV2, |
| 321 | }, { |
| 322 | /* sentinel */ |
| 323 | } |
| 324 | }; |
| 325 | MODULE_DEVICE_TABLE(platform, mc13783_adc_idtable); |
| 326 | |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 327 | static struct platform_driver mc13783_adc_driver = { |
Bill Pemberton | 9e5e9b7 | 2012-11-19 13:21:20 -0500 | [diff] [blame] | 328 | .remove = mc13783_adc_remove, |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 329 | .driver = { |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 330 | .name = DRIVER_NAME, |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 331 | }, |
Uwe Kleine-Koenig | 0c27321 | 2012-03-23 10:02:19 +0100 | [diff] [blame] | 332 | .id_table = mc13783_adc_idtable, |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 333 | }; |
| 334 | |
Jingoo Han | f40fb63 | 2013-03-05 12:12:55 +0900 | [diff] [blame] | 335 | module_platform_driver_probe(mc13783_adc_driver, mc13783_adc_probe); |
Luotao Fu | 93ee0a7 | 2009-12-09 20:35:58 +0100 | [diff] [blame] | 336 | |
| 337 | MODULE_DESCRIPTION("MC13783 ADC driver"); |
| 338 | MODULE_AUTHOR("Luotao Fu <l.fu@pengutronix.de>"); |
| 339 | MODULE_LICENSE("GPL"); |