Thomas Gleixner | 2b27bdc | 2019-05-29 16:57:50 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 2 | /* |
Jonathan Cameron | 9c2251d | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 3 | * drivers/iio/light/tsl2563.c |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2008 Nokia Corporation |
| 6 | * |
| 7 | * Written by Timo O. Karjalainen <timo.o.karjalainen@nokia.com> |
| 8 | * Contact: Amit Kucheria <amit.kucheria@verdurent.com> |
| 9 | * |
| 10 | * Converted to IIO driver |
| 11 | * Amit Kucheria <amit.kucheria@verdurent.com> |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
Vaishnav M A | d884da1 | 2020-10-19 02:05:52 +0530 | [diff] [blame] | 15 | #include <linux/mod_devicetable.h> |
| 16 | #include <linux/property.h> |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 17 | #include <linux/i2c.h> |
| 18 | #include <linux/interrupt.h> |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 19 | #include <linux/irq.h> |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 20 | #include <linux/sched.h> |
| 21 | #include <linux/mutex.h> |
| 22 | #include <linux/delay.h> |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 23 | #include <linux/pm.h> |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 24 | #include <linux/err.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 26 | |
Jonathan Cameron | 06458e2 | 2012-04-25 15:54:58 +0100 | [diff] [blame] | 27 | #include <linux/iio/iio.h> |
| 28 | #include <linux/iio/sysfs.h> |
| 29 | #include <linux/iio/events.h> |
Jonathan Cameron | 9c2251d | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 30 | #include <linux/platform_data/tsl2563.h> |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 31 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 32 | /* Use this many bits for fraction part. */ |
Jonathan Cameron | 5ade763 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 33 | #define ADC_FRAC_BITS 14 |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 34 | |
| 35 | /* Given number of 1/10000's in ADC_FRAC_BITS precision. */ |
| 36 | #define FRAC10K(f) (((f) * (1L << (ADC_FRAC_BITS))) / (10000)) |
| 37 | |
| 38 | /* Bits used for fraction in calibration coefficients.*/ |
Jonathan Cameron | 5ade763 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 39 | #define CALIB_FRAC_BITS 10 |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 40 | /* 0.5 in CALIB_FRAC_BITS precision */ |
| 41 | #define CALIB_FRAC_HALF (1 << (CALIB_FRAC_BITS - 1)) |
| 42 | /* Make a fraction from a number n that was multiplied with b. */ |
| 43 | #define CALIB_FRAC(n, b) (((n) << CALIB_FRAC_BITS) / (b)) |
| 44 | /* Decimal 10^(digits in sysfs presentation) */ |
Jonathan Cameron | 5ade763 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 45 | #define CALIB_BASE_SYSFS 1000 |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 46 | |
Jonathan Cameron | 5ade763 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 47 | #define TSL2563_CMD 0x80 |
| 48 | #define TSL2563_CLEARINT 0x40 |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 49 | |
Jonathan Cameron | 5ade763 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 50 | #define TSL2563_REG_CTRL 0x00 |
| 51 | #define TSL2563_REG_TIMING 0x01 |
| 52 | #define TSL2563_REG_LOWLOW 0x02 /* data0 low threshold, 2 bytes */ |
| 53 | #define TSL2563_REG_LOWHIGH 0x03 |
| 54 | #define TSL2563_REG_HIGHLOW 0x04 /* data0 high threshold, 2 bytes */ |
| 55 | #define TSL2563_REG_HIGHHIGH 0x05 |
| 56 | #define TSL2563_REG_INT 0x06 |
| 57 | #define TSL2563_REG_ID 0x0a |
| 58 | #define TSL2563_REG_DATA0LOW 0x0c /* broadband sensor value, 2 bytes */ |
| 59 | #define TSL2563_REG_DATA0HIGH 0x0d |
| 60 | #define TSL2563_REG_DATA1LOW 0x0e /* infrared sensor value, 2 bytes */ |
| 61 | #define TSL2563_REG_DATA1HIGH 0x0f |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 62 | |
Jonathan Cameron | 5ade763 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 63 | #define TSL2563_CMD_POWER_ON 0x03 |
| 64 | #define TSL2563_CMD_POWER_OFF 0x00 |
| 65 | #define TSL2563_CTRL_POWER_MASK 0x03 |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 66 | |
Jonathan Cameron | 5ade763 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 67 | #define TSL2563_TIMING_13MS 0x00 |
| 68 | #define TSL2563_TIMING_100MS 0x01 |
| 69 | #define TSL2563_TIMING_400MS 0x02 |
| 70 | #define TSL2563_TIMING_MASK 0x03 |
| 71 | #define TSL2563_TIMING_GAIN16 0x10 |
| 72 | #define TSL2563_TIMING_GAIN1 0x00 |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 73 | |
Nishant Malpani | 9fd2857 | 2020-03-18 13:33:11 +0530 | [diff] [blame] | 74 | #define TSL2563_INT_DISABLED 0x00 |
Jonathan Cameron | 5ade763 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 75 | #define TSL2563_INT_LEVEL 0x10 |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 76 | #define TSL2563_INT_PERSIST(n) ((n) & 0x0F) |
| 77 | |
| 78 | struct tsl2563_gainlevel_coeff { |
| 79 | u8 gaintime; |
| 80 | u16 min; |
| 81 | u16 max; |
| 82 | }; |
| 83 | |
Jonathan Cameron | 1ff7e1d | 2011-04-18 12:58:56 +0100 | [diff] [blame] | 84 | static const struct tsl2563_gainlevel_coeff tsl2563_gainlevel_table[] = { |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 85 | { |
| 86 | .gaintime = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN16, |
| 87 | .min = 0, |
| 88 | .max = 65534, |
| 89 | }, { |
| 90 | .gaintime = TSL2563_TIMING_400MS | TSL2563_TIMING_GAIN1, |
| 91 | .min = 2048, |
| 92 | .max = 65534, |
| 93 | }, { |
| 94 | .gaintime = TSL2563_TIMING_100MS | TSL2563_TIMING_GAIN1, |
| 95 | .min = 4095, |
| 96 | .max = 37177, |
| 97 | }, { |
| 98 | .gaintime = TSL2563_TIMING_13MS | TSL2563_TIMING_GAIN1, |
| 99 | .min = 3000, |
| 100 | .max = 65535, |
| 101 | }, |
| 102 | }; |
| 103 | |
| 104 | struct tsl2563_chip { |
| 105 | struct mutex lock; |
| 106 | struct i2c_client *client; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 107 | struct delayed_work poweroff_work; |
| 108 | |
| 109 | /* Remember state for suspend and resume functions */ |
Lars-Peter Clausen | 01788c5 | 2012-02-20 19:37:05 +0100 | [diff] [blame] | 110 | bool suspended; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 111 | |
Jonathan Cameron | 1ff7e1d | 2011-04-18 12:58:56 +0100 | [diff] [blame] | 112 | struct tsl2563_gainlevel_coeff const *gainlevel; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 113 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 114 | u16 low_thres; |
| 115 | u16 high_thres; |
| 116 | u8 intr; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 117 | bool int_enabled; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 118 | |
| 119 | /* Calibration coefficients */ |
| 120 | u32 calib0; |
| 121 | u32 calib1; |
| 122 | int cover_comp_gain; |
| 123 | |
| 124 | /* Cache current values, to be returned while suspended */ |
| 125 | u32 data0; |
| 126 | u32 data1; |
| 127 | }; |
| 128 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 129 | static int tsl2563_set_power(struct tsl2563_chip *chip, int on) |
| 130 | { |
| 131 | struct i2c_client *client = chip->client; |
| 132 | u8 cmd; |
| 133 | |
| 134 | cmd = on ? TSL2563_CMD_POWER_ON : TSL2563_CMD_POWER_OFF; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 135 | return i2c_smbus_write_byte_data(client, |
| 136 | TSL2563_CMD | TSL2563_REG_CTRL, cmd); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | /* |
| 140 | * Return value is 0 for off, 1 for on, or a negative error |
| 141 | * code if reading failed. |
| 142 | */ |
| 143 | static int tsl2563_get_power(struct tsl2563_chip *chip) |
| 144 | { |
| 145 | struct i2c_client *client = chip->client; |
| 146 | int ret; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 147 | |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 148 | ret = i2c_smbus_read_byte_data(client, TSL2563_CMD | TSL2563_REG_CTRL); |
| 149 | if (ret < 0) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 150 | return ret; |
| 151 | |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 152 | return (ret & TSL2563_CTRL_POWER_MASK) == TSL2563_CMD_POWER_ON; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | static int tsl2563_configure(struct tsl2563_chip *chip) |
| 156 | { |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 157 | int ret; |
| 158 | |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 159 | ret = i2c_smbus_write_byte_data(chip->client, |
| 160 | TSL2563_CMD | TSL2563_REG_TIMING, |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 161 | chip->gainlevel->gaintime); |
| 162 | if (ret) |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 163 | goto error_ret; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 164 | ret = i2c_smbus_write_byte_data(chip->client, |
| 165 | TSL2563_CMD | TSL2563_REG_HIGHLOW, |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 166 | chip->high_thres & 0xFF); |
| 167 | if (ret) |
| 168 | goto error_ret; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 169 | ret = i2c_smbus_write_byte_data(chip->client, |
| 170 | TSL2563_CMD | TSL2563_REG_HIGHHIGH, |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 171 | (chip->high_thres >> 8) & 0xFF); |
| 172 | if (ret) |
| 173 | goto error_ret; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 174 | ret = i2c_smbus_write_byte_data(chip->client, |
| 175 | TSL2563_CMD | TSL2563_REG_LOWLOW, |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 176 | chip->low_thres & 0xFF); |
| 177 | if (ret) |
| 178 | goto error_ret; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 179 | ret = i2c_smbus_write_byte_data(chip->client, |
| 180 | TSL2563_CMD | TSL2563_REG_LOWHIGH, |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 181 | (chip->low_thres >> 8) & 0xFF); |
Jonathan Cameron | a9e244f6 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 182 | /* |
| 183 | * Interrupt register is automatically written anyway if it is relevant |
| 184 | * so is not here. |
| 185 | */ |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 186 | error_ret: |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 187 | return ret; |
| 188 | } |
| 189 | |
| 190 | static void tsl2563_poweroff_work(struct work_struct *work) |
| 191 | { |
| 192 | struct tsl2563_chip *chip = |
| 193 | container_of(work, struct tsl2563_chip, poweroff_work.work); |
| 194 | tsl2563_set_power(chip, 0); |
| 195 | } |
| 196 | |
| 197 | static int tsl2563_detect(struct tsl2563_chip *chip) |
| 198 | { |
| 199 | int ret; |
| 200 | |
| 201 | ret = tsl2563_set_power(chip, 1); |
| 202 | if (ret) |
| 203 | return ret; |
| 204 | |
| 205 | ret = tsl2563_get_power(chip); |
| 206 | if (ret < 0) |
| 207 | return ret; |
| 208 | |
| 209 | return ret ? 0 : -ENODEV; |
| 210 | } |
| 211 | |
| 212 | static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id) |
| 213 | { |
| 214 | struct i2c_client *client = chip->client; |
| 215 | int ret; |
| 216 | |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 217 | ret = i2c_smbus_read_byte_data(client, TSL2563_CMD | TSL2563_REG_ID); |
| 218 | if (ret < 0) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 219 | return ret; |
| 220 | |
Maxin B. John | 22dc09c | 2011-10-26 17:27:37 +0100 | [diff] [blame] | 221 | *id = ret; |
| 222 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 223 | return 0; |
| 224 | } |
| 225 | |
| 226 | /* |
| 227 | * "Normalized" ADC value is one obtained with 400ms of integration time and |
| 228 | * 16x gain. This function returns the number of bits of shift needed to |
| 229 | * convert between normalized values and HW values obtained using given |
| 230 | * timing and gain settings. |
| 231 | */ |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 232 | static int tsl2563_adc_shiftbits(u8 timing) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 233 | { |
| 234 | int shift = 0; |
| 235 | |
| 236 | switch (timing & TSL2563_TIMING_MASK) { |
| 237 | case TSL2563_TIMING_13MS: |
| 238 | shift += 5; |
| 239 | break; |
| 240 | case TSL2563_TIMING_100MS: |
| 241 | shift += 2; |
| 242 | break; |
| 243 | case TSL2563_TIMING_400MS: |
| 244 | /* no-op */ |
| 245 | break; |
| 246 | } |
| 247 | |
| 248 | if (!(timing & TSL2563_TIMING_GAIN16)) |
| 249 | shift += 4; |
| 250 | |
| 251 | return shift; |
| 252 | } |
| 253 | |
| 254 | /* Convert a HW ADC value to normalized scale. */ |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 255 | static u32 tsl2563_normalize_adc(u16 adc, u8 timing) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 256 | { |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 257 | return adc << tsl2563_adc_shiftbits(timing); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | static void tsl2563_wait_adc(struct tsl2563_chip *chip) |
| 261 | { |
| 262 | unsigned int delay; |
| 263 | |
| 264 | switch (chip->gainlevel->gaintime & TSL2563_TIMING_MASK) { |
| 265 | case TSL2563_TIMING_13MS: |
| 266 | delay = 14; |
| 267 | break; |
| 268 | case TSL2563_TIMING_100MS: |
| 269 | delay = 101; |
| 270 | break; |
| 271 | default: |
| 272 | delay = 402; |
| 273 | } |
| 274 | /* |
| 275 | * TODO: Make sure that we wait at least required delay but why we |
| 276 | * have to extend it one tick more? |
| 277 | */ |
| 278 | schedule_timeout_interruptible(msecs_to_jiffies(delay) + 2); |
| 279 | } |
| 280 | |
| 281 | static int tsl2563_adjust_gainlevel(struct tsl2563_chip *chip, u16 adc) |
| 282 | { |
| 283 | struct i2c_client *client = chip->client; |
| 284 | |
| 285 | if (adc > chip->gainlevel->max || adc < chip->gainlevel->min) { |
| 286 | |
| 287 | (adc > chip->gainlevel->max) ? |
| 288 | chip->gainlevel++ : chip->gainlevel--; |
| 289 | |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 290 | i2c_smbus_write_byte_data(client, |
| 291 | TSL2563_CMD | TSL2563_REG_TIMING, |
| 292 | chip->gainlevel->gaintime); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 293 | |
| 294 | tsl2563_wait_adc(chip); |
| 295 | tsl2563_wait_adc(chip); |
| 296 | |
| 297 | return 1; |
| 298 | } else |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | static int tsl2563_get_adc(struct tsl2563_chip *chip) |
| 303 | { |
| 304 | struct i2c_client *client = chip->client; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 305 | u16 adc0, adc1; |
| 306 | int retry = 1; |
| 307 | int ret = 0; |
| 308 | |
Lars-Peter Clausen | 01788c5 | 2012-02-20 19:37:05 +0100 | [diff] [blame] | 309 | if (chip->suspended) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 310 | goto out; |
| 311 | |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 312 | if (!chip->int_enabled) { |
| 313 | cancel_delayed_work(&chip->poweroff_work); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 314 | |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 315 | if (!tsl2563_get_power(chip)) { |
| 316 | ret = tsl2563_set_power(chip, 1); |
| 317 | if (ret) |
| 318 | goto out; |
| 319 | ret = tsl2563_configure(chip); |
| 320 | if (ret) |
| 321 | goto out; |
| 322 | tsl2563_wait_adc(chip); |
| 323 | } |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | while (retry) { |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 327 | ret = i2c_smbus_read_word_data(client, |
| 328 | TSL2563_CMD | TSL2563_REG_DATA0LOW); |
| 329 | if (ret < 0) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 330 | goto out; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 331 | adc0 = ret; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 332 | |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 333 | ret = i2c_smbus_read_word_data(client, |
| 334 | TSL2563_CMD | TSL2563_REG_DATA1LOW); |
| 335 | if (ret < 0) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 336 | goto out; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 337 | adc1 = ret; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 338 | |
| 339 | retry = tsl2563_adjust_gainlevel(chip, adc0); |
| 340 | } |
| 341 | |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 342 | chip->data0 = tsl2563_normalize_adc(adc0, chip->gainlevel->gaintime); |
| 343 | chip->data1 = tsl2563_normalize_adc(adc1, chip->gainlevel->gaintime); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 344 | |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 345 | if (!chip->int_enabled) |
| 346 | schedule_delayed_work(&chip->poweroff_work, 5 * HZ); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 347 | |
| 348 | ret = 0; |
| 349 | out: |
| 350 | return ret; |
| 351 | } |
| 352 | |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 353 | static inline int tsl2563_calib_to_sysfs(u32 calib) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 354 | { |
| 355 | return (int) (((calib * CALIB_BASE_SYSFS) + |
| 356 | CALIB_FRAC_HALF) >> CALIB_FRAC_BITS); |
| 357 | } |
| 358 | |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 359 | static inline u32 tsl2563_calib_from_sysfs(int value) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 360 | { |
| 361 | return (((u32) value) << CALIB_FRAC_BITS) / CALIB_BASE_SYSFS; |
| 362 | } |
| 363 | |
| 364 | /* |
| 365 | * Conversions between lux and ADC values. |
| 366 | * |
| 367 | * The basic formula is lux = c0 * adc0 - c1 * adc1, where c0 and c1 are |
| 368 | * appropriate constants. Different constants are needed for different |
| 369 | * kinds of light, determined by the ratio adc1/adc0 (basically the ratio |
| 370 | * of the intensities in infrared and visible wavelengths). lux_table below |
| 371 | * lists the upper threshold of the adc1/adc0 ratio and the corresponding |
| 372 | * constants. |
| 373 | */ |
| 374 | |
| 375 | struct tsl2563_lux_coeff { |
| 376 | unsigned long ch_ratio; |
| 377 | unsigned long ch0_coeff; |
| 378 | unsigned long ch1_coeff; |
| 379 | }; |
| 380 | |
| 381 | static const struct tsl2563_lux_coeff lux_table[] = { |
| 382 | { |
| 383 | .ch_ratio = FRAC10K(1300), |
| 384 | .ch0_coeff = FRAC10K(315), |
| 385 | .ch1_coeff = FRAC10K(262), |
| 386 | }, { |
| 387 | .ch_ratio = FRAC10K(2600), |
| 388 | .ch0_coeff = FRAC10K(337), |
| 389 | .ch1_coeff = FRAC10K(430), |
| 390 | }, { |
| 391 | .ch_ratio = FRAC10K(3900), |
| 392 | .ch0_coeff = FRAC10K(363), |
| 393 | .ch1_coeff = FRAC10K(529), |
| 394 | }, { |
| 395 | .ch_ratio = FRAC10K(5200), |
| 396 | .ch0_coeff = FRAC10K(392), |
| 397 | .ch1_coeff = FRAC10K(605), |
| 398 | }, { |
| 399 | .ch_ratio = FRAC10K(6500), |
| 400 | .ch0_coeff = FRAC10K(229), |
| 401 | .ch1_coeff = FRAC10K(291), |
| 402 | }, { |
| 403 | .ch_ratio = FRAC10K(8000), |
| 404 | .ch0_coeff = FRAC10K(157), |
| 405 | .ch1_coeff = FRAC10K(180), |
| 406 | }, { |
| 407 | .ch_ratio = FRAC10K(13000), |
| 408 | .ch0_coeff = FRAC10K(34), |
| 409 | .ch1_coeff = FRAC10K(26), |
| 410 | }, { |
| 411 | .ch_ratio = ULONG_MAX, |
| 412 | .ch0_coeff = 0, |
| 413 | .ch1_coeff = 0, |
| 414 | }, |
| 415 | }; |
| 416 | |
Jonathan Cameron | a9e244f6 | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 417 | /* Convert normalized, scaled ADC values to lux. */ |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 418 | static unsigned int tsl2563_adc_to_lux(u32 adc0, u32 adc1) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 419 | { |
| 420 | const struct tsl2563_lux_coeff *lp = lux_table; |
| 421 | unsigned long ratio, lux, ch0 = adc0, ch1 = adc1; |
| 422 | |
| 423 | ratio = ch0 ? ((ch1 << ADC_FRAC_BITS) / ch0) : ULONG_MAX; |
| 424 | |
| 425 | while (lp->ch_ratio < ratio) |
| 426 | lp++; |
| 427 | |
| 428 | lux = ch0 * lp->ch0_coeff - ch1 * lp->ch1_coeff; |
| 429 | |
| 430 | return (unsigned int) (lux >> ADC_FRAC_BITS); |
| 431 | } |
| 432 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 433 | /* Apply calibration coefficient to ADC count. */ |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 434 | static u32 tsl2563_calib_adc(u32 adc, u32 calib) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 435 | { |
| 436 | unsigned long scaled = adc; |
| 437 | |
| 438 | scaled *= calib; |
| 439 | scaled >>= CALIB_FRAC_BITS; |
| 440 | |
| 441 | return (u32) scaled; |
| 442 | } |
| 443 | |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 444 | static int tsl2563_write_raw(struct iio_dev *indio_dev, |
| 445 | struct iio_chan_spec const *chan, |
| 446 | int val, |
| 447 | int val2, |
| 448 | long mask) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 449 | { |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 450 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
| 451 | |
Ivaylo Dimitrov | 3b5c163 | 2014-01-13 17:24:00 +0000 | [diff] [blame] | 452 | if (mask != IIO_CHAN_INFO_CALIBSCALE) |
| 453 | return -EINVAL; |
| 454 | if (chan->channel2 == IIO_MOD_LIGHT_BOTH) |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 455 | chip->calib0 = tsl2563_calib_from_sysfs(val); |
Ivaylo Dimitrov | 3b5c163 | 2014-01-13 17:24:00 +0000 | [diff] [blame] | 456 | else if (chan->channel2 == IIO_MOD_LIGHT_IR) |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 457 | chip->calib1 = tsl2563_calib_from_sysfs(val); |
Ivaylo Dimitrov | 3b5c163 | 2014-01-13 17:24:00 +0000 | [diff] [blame] | 458 | else |
| 459 | return -EINVAL; |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 460 | |
| 461 | return 0; |
| 462 | } |
| 463 | |
| 464 | static int tsl2563_read_raw(struct iio_dev *indio_dev, |
| 465 | struct iio_chan_spec const *chan, |
| 466 | int *val, |
| 467 | int *val2, |
Ivaylo Dimitrov | 3b5c163 | 2014-01-13 17:24:00 +0000 | [diff] [blame] | 468 | long mask) |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 469 | { |
| 470 | int ret = -EINVAL; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 471 | u32 calib0, calib1; |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 472 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 473 | |
| 474 | mutex_lock(&chip->lock); |
Ivaylo Dimitrov | 3b5c163 | 2014-01-13 17:24:00 +0000 | [diff] [blame] | 475 | switch (mask) { |
Jonathan Cameron | 90354d0 | 2012-04-15 17:41:22 +0100 | [diff] [blame] | 476 | case IIO_CHAN_INFO_RAW: |
| 477 | case IIO_CHAN_INFO_PROCESSED: |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 478 | switch (chan->type) { |
| 479 | case IIO_LIGHT: |
| 480 | ret = tsl2563_get_adc(chip); |
| 481 | if (ret) |
| 482 | goto error_ret; |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 483 | calib0 = tsl2563_calib_adc(chip->data0, chip->calib0) * |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 484 | chip->cover_comp_gain; |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 485 | calib1 = tsl2563_calib_adc(chip->data1, chip->calib1) * |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 486 | chip->cover_comp_gain; |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 487 | *val = tsl2563_adc_to_lux(calib0, calib1); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 488 | ret = IIO_VAL_INT; |
| 489 | break; |
| 490 | case IIO_INTENSITY: |
| 491 | ret = tsl2563_get_adc(chip); |
| 492 | if (ret) |
| 493 | goto error_ret; |
Ivaylo Dimitrov | 3b5c163 | 2014-01-13 17:24:00 +0000 | [diff] [blame] | 494 | if (chan->channel2 == IIO_MOD_LIGHT_BOTH) |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 495 | *val = chip->data0; |
| 496 | else |
| 497 | *val = chip->data1; |
| 498 | ret = IIO_VAL_INT; |
| 499 | break; |
| 500 | default: |
| 501 | break; |
| 502 | } |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 503 | break; |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 504 | |
Jonathan Cameron | c8a9f80 | 2011-10-26 17:41:36 +0100 | [diff] [blame] | 505 | case IIO_CHAN_INFO_CALIBSCALE: |
Ivaylo Dimitrov | 3b5c163 | 2014-01-13 17:24:00 +0000 | [diff] [blame] | 506 | if (chan->channel2 == IIO_MOD_LIGHT_BOTH) |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 507 | *val = tsl2563_calib_to_sysfs(chip->calib0); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 508 | else |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 509 | *val = tsl2563_calib_to_sysfs(chip->calib1); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 510 | ret = IIO_VAL_INT; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 511 | break; |
| 512 | default: |
Dan Carpenter | 97d35f2 | 2011-10-06 09:15:03 +0300 | [diff] [blame] | 513 | ret = -EINVAL; |
| 514 | goto error_ret; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | error_ret: |
| 518 | mutex_unlock(&chip->lock); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 519 | return ret; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 520 | } |
| 521 | |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 522 | static const struct iio_event_spec tsl2563_events[] = { |
| 523 | { |
| 524 | .type = IIO_EV_TYPE_THRESH, |
| 525 | .dir = IIO_EV_DIR_RISING, |
| 526 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | |
| 527 | BIT(IIO_EV_INFO_ENABLE), |
| 528 | }, { |
| 529 | .type = IIO_EV_TYPE_THRESH, |
| 530 | .dir = IIO_EV_DIR_FALLING, |
| 531 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | |
| 532 | BIT(IIO_EV_INFO_ENABLE), |
| 533 | }, |
| 534 | }; |
| 535 | |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 536 | static const struct iio_chan_spec tsl2563_channels[] = { |
Jonathan Cameron | 7993906 | 2011-08-30 12:41:16 +0100 | [diff] [blame] | 537 | { |
| 538 | .type = IIO_LIGHT, |
| 539 | .indexed = 1, |
Jonathan Cameron | d292ef8 | 2013-02-27 19:33:40 +0000 | [diff] [blame] | 540 | .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), |
Jonathan Cameron | 7993906 | 2011-08-30 12:41:16 +0100 | [diff] [blame] | 541 | .channel = 0, |
| 542 | }, { |
| 543 | .type = IIO_INTENSITY, |
| 544 | .modified = 1, |
| 545 | .channel2 = IIO_MOD_LIGHT_BOTH, |
Jonathan Cameron | d292ef8 | 2013-02-27 19:33:40 +0000 | [diff] [blame] | 546 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
| 547 | BIT(IIO_CHAN_INFO_CALIBSCALE), |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 548 | .event_spec = tsl2563_events, |
| 549 | .num_event_specs = ARRAY_SIZE(tsl2563_events), |
Jonathan Cameron | 7993906 | 2011-08-30 12:41:16 +0100 | [diff] [blame] | 550 | }, { |
| 551 | .type = IIO_INTENSITY, |
| 552 | .modified = 1, |
Jonathan Cameron | a7e3bd6 | 2011-10-26 17:27:36 +0100 | [diff] [blame] | 553 | .channel2 = IIO_MOD_LIGHT_IR, |
Jonathan Cameron | d292ef8 | 2013-02-27 19:33:40 +0000 | [diff] [blame] | 554 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
| 555 | BIT(IIO_CHAN_INFO_CALIBSCALE), |
Jonathan Cameron | 7993906 | 2011-08-30 12:41:16 +0100 | [diff] [blame] | 556 | } |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 557 | }; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 558 | |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 559 | static int tsl2563_read_thresh(struct iio_dev *indio_dev, |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 560 | const struct iio_chan_spec *chan, enum iio_event_type type, |
| 561 | enum iio_event_direction dir, enum iio_event_info info, int *val, |
| 562 | int *val2) |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 563 | { |
| 564 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
| 565 | |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 566 | switch (dir) { |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 567 | case IIO_EV_DIR_RISING: |
| 568 | *val = chip->high_thres; |
| 569 | break; |
| 570 | case IIO_EV_DIR_FALLING: |
| 571 | *val = chip->low_thres; |
| 572 | break; |
| 573 | default: |
| 574 | return -EINVAL; |
| 575 | } |
| 576 | |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 577 | return IIO_VAL_INT; |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 578 | } |
| 579 | |
Dan Carpenter | 15fbc19 | 2011-10-06 09:15:36 +0300 | [diff] [blame] | 580 | static int tsl2563_write_thresh(struct iio_dev *indio_dev, |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 581 | const struct iio_chan_spec *chan, enum iio_event_type type, |
| 582 | enum iio_event_direction dir, enum iio_event_info info, int val, |
| 583 | int val2) |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 584 | { |
| 585 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
| 586 | int ret; |
| 587 | u8 address; |
| 588 | |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 589 | if (dir == IIO_EV_DIR_RISING) |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 590 | address = TSL2563_REG_HIGHLOW; |
| 591 | else |
| 592 | address = TSL2563_REG_LOWLOW; |
| 593 | mutex_lock(&chip->lock); |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 594 | ret = i2c_smbus_write_byte_data(chip->client, TSL2563_CMD | address, |
| 595 | val & 0xFF); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 596 | if (ret) |
| 597 | goto error_ret; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 598 | ret = i2c_smbus_write_byte_data(chip->client, |
| 599 | TSL2563_CMD | (address + 1), |
| 600 | (val >> 8) & 0xFF); |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 601 | if (dir == IIO_EV_DIR_RISING) |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 602 | chip->high_thres = val; |
| 603 | else |
| 604 | chip->low_thres = val; |
| 605 | |
| 606 | error_ret: |
| 607 | mutex_unlock(&chip->lock); |
| 608 | |
| 609 | return ret; |
| 610 | } |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 611 | |
Jonathan Cameron | bdab100 | 2011-05-18 14:41:03 +0100 | [diff] [blame] | 612 | static irqreturn_t tsl2563_event_handler(int irq, void *private) |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 613 | { |
Jonathan Cameron | bdab100 | 2011-05-18 14:41:03 +0100 | [diff] [blame] | 614 | struct iio_dev *dev_info = private; |
Jonathan Cameron | 33789dc | 2011-04-18 12:58:55 +0100 | [diff] [blame] | 615 | struct tsl2563_chip *chip = iio_priv(dev_info); |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 616 | |
Jonathan Cameron | 5aa9618 | 2011-08-30 12:41:06 +0100 | [diff] [blame] | 617 | iio_push_event(dev_info, |
Akinobu Mita | a3507e4 | 2017-06-21 01:46:37 +0900 | [diff] [blame] | 618 | IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, |
Jonathan Cameron | da1d8b6 | 2010-10-08 12:14:05 +0100 | [diff] [blame] | 619 | 0, |
| 620 | IIO_EV_TYPE_THRESH, |
| 621 | IIO_EV_DIR_EITHER), |
Gregor Boirie | bc2b7da | 2016-03-09 19:05:49 +0100 | [diff] [blame] | 622 | iio_get_time_ns(dev_info)); |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 623 | |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 624 | /* clear the interrupt and push the event */ |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 625 | i2c_smbus_write_byte(chip->client, TSL2563_CMD | TSL2563_CLEARINT); |
Jonathan Cameron | bdab100 | 2011-05-18 14:41:03 +0100 | [diff] [blame] | 626 | return IRQ_HANDLED; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 627 | } |
| 628 | |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 629 | static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev, |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 630 | const struct iio_chan_spec *chan, enum iio_event_type type, |
| 631 | enum iio_event_direction dir, int state) |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 632 | { |
Jonathan Cameron | 33789dc | 2011-04-18 12:58:55 +0100 | [diff] [blame] | 633 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 634 | int ret = 0; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 635 | |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 636 | mutex_lock(&chip->lock); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 637 | if (state && !(chip->intr & 0x30)) { |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 638 | chip->intr &= ~0x30; |
| 639 | chip->intr |= 0x10; |
| 640 | /* ensure the chip is actually on */ |
| 641 | cancel_delayed_work(&chip->poweroff_work); |
| 642 | if (!tsl2563_get_power(chip)) { |
| 643 | ret = tsl2563_set_power(chip, 1); |
| 644 | if (ret) |
| 645 | goto out; |
| 646 | ret = tsl2563_configure(chip); |
| 647 | if (ret) |
| 648 | goto out; |
| 649 | } |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 650 | ret = i2c_smbus_write_byte_data(chip->client, |
| 651 | TSL2563_CMD | TSL2563_REG_INT, |
| 652 | chip->intr); |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 653 | chip->int_enabled = true; |
| 654 | } |
| 655 | |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 656 | if (!state && (chip->intr & 0x30)) { |
Derek Basehore | 95273f8 | 2012-10-05 00:54:00 +0100 | [diff] [blame] | 657 | chip->intr &= ~0x30; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 658 | ret = i2c_smbus_write_byte_data(chip->client, |
| 659 | TSL2563_CMD | TSL2563_REG_INT, |
| 660 | chip->intr); |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 661 | chip->int_enabled = false; |
| 662 | /* now the interrupt is not enabled, we can go to sleep */ |
| 663 | schedule_delayed_work(&chip->poweroff_work, 5 * HZ); |
| 664 | } |
| 665 | out: |
| 666 | mutex_unlock(&chip->lock); |
| 667 | |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 668 | return ret; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 669 | } |
| 670 | |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 671 | static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev, |
Lars-Peter Clausen | 6d59747 | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 672 | const struct iio_chan_spec *chan, enum iio_event_type type, |
| 673 | enum iio_event_direction dir) |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 674 | { |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 675 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 676 | int ret; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 677 | |
| 678 | mutex_lock(&chip->lock); |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 679 | ret = i2c_smbus_read_byte_data(chip->client, |
| 680 | TSL2563_CMD | TSL2563_REG_INT); |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 681 | mutex_unlock(&chip->lock); |
| 682 | if (ret < 0) |
Jonathan Cameron | a722dcc | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 683 | return ret; |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 684 | |
Jonathan Cameron | a722dcc | 2013-01-12 10:35:00 +0000 | [diff] [blame] | 685 | return !!(ret & 0x30); |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 686 | } |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 687 | |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 688 | static const struct iio_info tsl2563_info_no_irq = { |
Bryan Freed | 9e4216f | 2011-06-21 15:54:57 -0700 | [diff] [blame] | 689 | .read_raw = &tsl2563_read_raw, |
| 690 | .write_raw = &tsl2563_write_raw, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 691 | }; |
| 692 | |
| 693 | static const struct iio_info tsl2563_info = { |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 694 | .read_raw = &tsl2563_read_raw, |
| 695 | .write_raw = &tsl2563_write_raw, |
Lars-Peter Clausen | cb95585 | 2013-12-07 10:45:00 +0000 | [diff] [blame] | 696 | .read_event_value = &tsl2563_read_thresh, |
| 697 | .write_event_value = &tsl2563_write_thresh, |
| 698 | .read_event_config = &tsl2563_read_interrupt_config, |
| 699 | .write_event_config = &tsl2563_write_interrupt_config, |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 700 | }; |
| 701 | |
Bill Pemberton | 4ae1c61 | 2012-11-19 13:21:57 -0500 | [diff] [blame] | 702 | static int tsl2563_probe(struct i2c_client *client, |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 703 | const struct i2c_device_id *device_id) |
| 704 | { |
Jonathan Cameron | 33789dc | 2011-04-18 12:58:55 +0100 | [diff] [blame] | 705 | struct iio_dev *indio_dev; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 706 | struct tsl2563_chip *chip; |
| 707 | struct tsl2563_platform_data *pdata = client->dev.platform_data; |
| 708 | int err = 0; |
Jonathan Cameron | deda386 | 2011-08-12 17:08:35 +0100 | [diff] [blame] | 709 | u8 id = 0; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 710 | |
Sachin Kamat | bace48f | 2013-07-30 09:44:00 +0100 | [diff] [blame] | 711 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); |
Jonathan Cameron | 33789dc | 2011-04-18 12:58:55 +0100 | [diff] [blame] | 712 | if (!indio_dev) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 713 | return -ENOMEM; |
| 714 | |
Jonathan Cameron | 33789dc | 2011-04-18 12:58:55 +0100 | [diff] [blame] | 715 | chip = iio_priv(indio_dev); |
| 716 | |
Alexandru Ardelean | 70804e5 | 2020-05-22 10:08:01 +0300 | [diff] [blame] | 717 | i2c_set_clientdata(client, indio_dev); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 718 | chip->client = client; |
| 719 | |
| 720 | err = tsl2563_detect(chip); |
| 721 | if (err) { |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 722 | dev_err(&client->dev, "detect error %d\n", -err); |
Sachin Kamat | bace48f | 2013-07-30 09:44:00 +0100 | [diff] [blame] | 723 | return err; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | err = tsl2563_read_id(chip, &id); |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 727 | if (err) { |
| 728 | dev_err(&client->dev, "read id error %d\n", -err); |
Sachin Kamat | bace48f | 2013-07-30 09:44:00 +0100 | [diff] [blame] | 729 | return err; |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 730 | } |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 731 | |
| 732 | mutex_init(&chip->lock); |
| 733 | |
| 734 | /* Default values used until userspace says otherwise */ |
| 735 | chip->low_thres = 0x0; |
| 736 | chip->high_thres = 0xffff; |
| 737 | chip->gainlevel = tsl2563_gainlevel_table; |
| 738 | chip->intr = TSL2563_INT_PERSIST(4); |
Peter Meerwald | 6fa273c | 2015-04-15 22:39:37 +0200 | [diff] [blame] | 739 | chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS); |
| 740 | chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 741 | |
Vaishnav M A | d884da1 | 2020-10-19 02:05:52 +0530 | [diff] [blame] | 742 | if (pdata) { |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 743 | chip->cover_comp_gain = pdata->cover_comp_gain; |
Vaishnav M A | d884da1 | 2020-10-19 02:05:52 +0530 | [diff] [blame] | 744 | } else { |
| 745 | err = device_property_read_u32(&client->dev, "amstaos,cover-comp-gain", |
| 746 | &chip->cover_comp_gain); |
| 747 | if (err) |
| 748 | chip->cover_comp_gain = 1; |
| 749 | } |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 750 | |
| 751 | dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f); |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 752 | indio_dev->name = client->name; |
| 753 | indio_dev->channels = tsl2563_channels; |
| 754 | indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels); |
Jonathan Cameron | 33789dc | 2011-04-18 12:58:55 +0100 | [diff] [blame] | 755 | indio_dev->modes = INDIO_DIRECT_MODE; |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 756 | |
Jonathan Cameron | cbcdf4d | 2011-05-18 14:41:45 +0100 | [diff] [blame] | 757 | if (client->irq) |
Jonathan Cameron | 6fe8135 | 2011-05-18 14:42:37 +0100 | [diff] [blame] | 758 | indio_dev->info = &tsl2563_info; |
| 759 | else |
| 760 | indio_dev->info = &tsl2563_info_no_irq; |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 761 | |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 762 | if (client->irq) { |
Sachin Kamat | bace48f | 2013-07-30 09:44:00 +0100 | [diff] [blame] | 763 | err = devm_request_threaded_irq(&client->dev, client->irq, |
Jonathan Cameron | bdab100 | 2011-05-18 14:41:03 +0100 | [diff] [blame] | 764 | NULL, |
| 765 | &tsl2563_event_handler, |
| 766 | IRQF_TRIGGER_RISING | IRQF_ONESHOT, |
| 767 | "tsl2563_event", |
| 768 | indio_dev); |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 769 | if (err) { |
| 770 | dev_err(&client->dev, "irq request error %d\n", -err); |
Sachin Kamat | bace48f | 2013-07-30 09:44:00 +0100 | [diff] [blame] | 771 | return err; |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 772 | } |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 773 | } |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 774 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 775 | err = tsl2563_configure(chip); |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 776 | if (err) { |
| 777 | dev_err(&client->dev, "configure error %d\n", -err); |
Sachin Kamat | bace48f | 2013-07-30 09:44:00 +0100 | [diff] [blame] | 778 | return err; |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 779 | } |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 780 | |
| 781 | INIT_DELAYED_WORK(&chip->poweroff_work, tsl2563_poweroff_work); |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 782 | |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 783 | /* The interrupt cannot yet be enabled so this is fine without lock */ |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 784 | schedule_delayed_work(&chip->poweroff_work, 5 * HZ); |
| 785 | |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 786 | err = iio_device_register(indio_dev); |
| 787 | if (err) { |
| 788 | dev_err(&client->dev, "iio registration error %d\n", -err); |
Sachin Kamat | bace48f | 2013-07-30 09:44:00 +0100 | [diff] [blame] | 789 | goto fail; |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 790 | } |
Jonathan Cameron | 26d25ae | 2011-09-02 17:14:40 +0100 | [diff] [blame] | 791 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 792 | return 0; |
Grant Grundler | dbf717f | 2012-03-05 09:15:59 -0800 | [diff] [blame] | 793 | |
Sachin Kamat | bace48f | 2013-07-30 09:44:00 +0100 | [diff] [blame] | 794 | fail: |
Amitoj Kaur Chawla | 9e61d90 | 2016-03-17 19:25:11 +0530 | [diff] [blame] | 795 | cancel_delayed_work_sync(&chip->poweroff_work); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 796 | return err; |
| 797 | } |
| 798 | |
Bill Pemberton | 447d4f2 | 2012-11-19 13:26:37 -0500 | [diff] [blame] | 799 | static int tsl2563_remove(struct i2c_client *client) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 800 | { |
Alexandru Ardelean | 70804e5 | 2020-05-22 10:08:01 +0300 | [diff] [blame] | 801 | struct iio_dev *indio_dev = i2c_get_clientdata(client); |
| 802 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
Jonathan Cameron | d2fffd6 | 2011-10-14 14:46:58 +0100 | [diff] [blame] | 803 | |
| 804 | iio_device_unregister(indio_dev); |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 805 | if (!chip->int_enabled) |
| 806 | cancel_delayed_work(&chip->poweroff_work); |
| 807 | /* Ensure that interrupts are disabled - then flush any bottom halves */ |
Derek Basehore | 95273f8 | 2012-10-05 00:54:00 +0100 | [diff] [blame] | 808 | chip->intr &= ~0x30; |
Bryan Freed | d9b42c0 | 2011-06-24 13:40:47 -0700 | [diff] [blame] | 809 | i2c_smbus_write_byte_data(chip->client, TSL2563_CMD | TSL2563_REG_INT, |
| 810 | chip->intr); |
Jonathan Cameron | 388be48 | 2010-06-26 12:54:21 +0100 | [diff] [blame] | 811 | flush_scheduled_work(); |
| 812 | tsl2563_set_power(chip, 0); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 813 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 814 | return 0; |
| 815 | } |
| 816 | |
Lars-Peter Clausen | 01788c5 | 2012-02-20 19:37:05 +0100 | [diff] [blame] | 817 | #ifdef CONFIG_PM_SLEEP |
| 818 | static int tsl2563_suspend(struct device *dev) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 819 | { |
Alexandru Ardelean | 70804e5 | 2020-05-22 10:08:01 +0300 | [diff] [blame] | 820 | struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); |
| 821 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 822 | int ret; |
| 823 | |
| 824 | mutex_lock(&chip->lock); |
| 825 | |
| 826 | ret = tsl2563_set_power(chip, 0); |
| 827 | if (ret) |
| 828 | goto out; |
| 829 | |
Lars-Peter Clausen | 01788c5 | 2012-02-20 19:37:05 +0100 | [diff] [blame] | 830 | chip->suspended = true; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 831 | |
| 832 | out: |
| 833 | mutex_unlock(&chip->lock); |
| 834 | return ret; |
| 835 | } |
| 836 | |
Lars-Peter Clausen | 01788c5 | 2012-02-20 19:37:05 +0100 | [diff] [blame] | 837 | static int tsl2563_resume(struct device *dev) |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 838 | { |
Alexandru Ardelean | 70804e5 | 2020-05-22 10:08:01 +0300 | [diff] [blame] | 839 | struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); |
| 840 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 841 | int ret; |
| 842 | |
| 843 | mutex_lock(&chip->lock); |
| 844 | |
| 845 | ret = tsl2563_set_power(chip, 1); |
| 846 | if (ret) |
| 847 | goto out; |
| 848 | |
| 849 | ret = tsl2563_configure(chip); |
| 850 | if (ret) |
| 851 | goto out; |
| 852 | |
Lars-Peter Clausen | 01788c5 | 2012-02-20 19:37:05 +0100 | [diff] [blame] | 853 | chip->suspended = false; |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 854 | |
| 855 | out: |
| 856 | mutex_unlock(&chip->lock); |
| 857 | return ret; |
| 858 | } |
| 859 | |
Lars-Peter Clausen | 01788c5 | 2012-02-20 19:37:05 +0100 | [diff] [blame] | 860 | static SIMPLE_DEV_PM_OPS(tsl2563_pm_ops, tsl2563_suspend, tsl2563_resume); |
| 861 | #define TSL2563_PM_OPS (&tsl2563_pm_ops) |
| 862 | #else |
| 863 | #define TSL2563_PM_OPS NULL |
| 864 | #endif |
| 865 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 866 | static const struct i2c_device_id tsl2563_id[] = { |
Jonathan Cameron | dbd5d23 | 2009-11-22 16:03:25 +0000 | [diff] [blame] | 867 | { "tsl2560", 0 }, |
| 868 | { "tsl2561", 1 }, |
| 869 | { "tsl2562", 2 }, |
| 870 | { "tsl2563", 3 }, |
| 871 | {} |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 872 | }; |
| 873 | MODULE_DEVICE_TABLE(i2c, tsl2563_id); |
| 874 | |
Javier Martinez Canillas | 9d3922b2 | 2017-03-15 01:44:54 -0300 | [diff] [blame] | 875 | static const struct of_device_id tsl2563_of_match[] = { |
| 876 | { .compatible = "amstaos,tsl2560" }, |
| 877 | { .compatible = "amstaos,tsl2561" }, |
| 878 | { .compatible = "amstaos,tsl2562" }, |
| 879 | { .compatible = "amstaos,tsl2563" }, |
| 880 | {} |
| 881 | }; |
| 882 | MODULE_DEVICE_TABLE(of, tsl2563_of_match); |
| 883 | |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 884 | static struct i2c_driver tsl2563_i2c_driver = { |
| 885 | .driver = { |
Jonathan Cameron | dbd5d23 | 2009-11-22 16:03:25 +0000 | [diff] [blame] | 886 | .name = "tsl2563", |
Javier Martinez Canillas | 9d3922b2 | 2017-03-15 01:44:54 -0300 | [diff] [blame] | 887 | .of_match_table = tsl2563_of_match, |
Lars-Peter Clausen | 01788c5 | 2012-02-20 19:37:05 +0100 | [diff] [blame] | 888 | .pm = TSL2563_PM_OPS, |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 889 | }, |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 890 | .probe = tsl2563_probe, |
Bill Pemberton | e543acf | 2012-11-19 13:21:38 -0500 | [diff] [blame] | 891 | .remove = tsl2563_remove, |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 892 | .id_table = tsl2563_id, |
| 893 | }; |
Lars-Peter Clausen | 6e5af18 | 2011-11-16 10:13:38 +0100 | [diff] [blame] | 894 | module_i2c_driver(tsl2563_i2c_driver); |
Amit Kucheria | ee1f1fa | 2009-11-09 15:14:28 +0200 | [diff] [blame] | 895 | |
| 896 | MODULE_AUTHOR("Nokia Corporation"); |
| 897 | MODULE_DESCRIPTION("tsl2563 light sensor driver"); |
| 898 | MODULE_LICENSE("GPL"); |