Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: iio: tsl2x7x: rename driver to tsl2772

This patch renames this driver from tsl2x7x to tsl2772 since it is
highly likely that additional devices will be added to this driver that
do not match that wildcard. The tsl2772 driver name was selected since
that is currently the device with the most features that are supported
by this driver.

This patch also adds Brian Masney's copyright to tsl2772.h for all of
the work that has been done to move this driver out of staging.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Brian Masney and committed by
Jonathan Cameron
4e24c171 da18e890

+361 -359
+1 -1
drivers/staging/iio/light/Kconfig
··· 3 3 # 4 4 menu "Light sensors" 5 5 6 - config TSL2x7x 6 + config TSL2772 7 7 tristate "TAOS TSL/TMD2x71 and TSL/TMD2x72 Family of light and proximity sensors" 8 8 depends on I2C 9 9 help
+1 -1
drivers/staging/iio/light/Makefile
··· 2 2 # Makefile for industrial I/O Light sensors 3 3 # 4 4 5 - obj-$(CONFIG_TSL2x7x) += tsl2x7x.o 5 + obj-$(CONFIG_TSL2772) += tsl2772.o
+334 -333
drivers/staging/iio/light/tsl2x7x.c drivers/staging/iio/light/tsl2772.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0+ 2 2 /* 3 3 * Device driver for monitoring ambient light intensity in (lux) and proximity 4 - * detection (prox) within the TAOS TSL2X7X family of devices. 4 + * detection (prox) within the TAOS TSL2571, TSL2671, TMD2671, TSL2771, TMD2771, 5 + * TSL2572, TSL2672, TMD2672, TSL2772, and TMD2772 devices. 5 6 * 6 7 * Copyright (c) 2012, TAOS Corporation. 7 8 * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org> ··· 19 18 #include <linux/iio/events.h> 20 19 #include <linux/iio/iio.h> 21 20 #include <linux/iio/sysfs.h> 22 - #include "tsl2x7x.h" 21 + #include "tsl2772.h" 23 22 24 23 /* Cal defs */ 25 24 #define PROX_STAT_CAL 0 26 25 #define PROX_STAT_SAMP 1 27 26 #define MAX_SAMPLES_CAL 200 28 27 29 - /* TSL2X7X Device ID */ 28 + /* TSL2772 Device ID */ 30 29 #define TRITON_ID 0x00 31 30 #define SWORDFISH_ID 0x30 32 31 #define HALIBUT_ID 0x20 33 32 34 33 /* Lux calculation constants */ 35 - #define TSL2X7X_LUX_CALC_OVER_FLOW 65535 34 + #define TSL2772_LUX_CALC_OVER_FLOW 65535 36 35 37 36 /* 38 37 * TAOS Register definitions - Note: depending on device, some of these register 39 38 * are not used and the register address is benign. 40 39 */ 41 40 42 - /* 2X7X register offsets */ 43 - #define TSL2X7X_MAX_CONFIG_REG 16 41 + /* Register offsets */ 42 + #define TSL2772_MAX_CONFIG_REG 16 44 43 45 44 /* Device Registers and Masks */ 46 - #define TSL2X7X_CNTRL 0x00 47 - #define TSL2X7X_ALS_TIME 0X01 48 - #define TSL2X7X_PRX_TIME 0x02 49 - #define TSL2X7X_WAIT_TIME 0x03 50 - #define TSL2X7X_ALS_MINTHRESHLO 0X04 51 - #define TSL2X7X_ALS_MINTHRESHHI 0X05 52 - #define TSL2X7X_ALS_MAXTHRESHLO 0X06 53 - #define TSL2X7X_ALS_MAXTHRESHHI 0X07 54 - #define TSL2X7X_PRX_MINTHRESHLO 0X08 55 - #define TSL2X7X_PRX_MINTHRESHHI 0X09 56 - #define TSL2X7X_PRX_MAXTHRESHLO 0X0A 57 - #define TSL2X7X_PRX_MAXTHRESHHI 0X0B 58 - #define TSL2X7X_PERSISTENCE 0x0C 59 - #define TSL2X7X_ALS_PRX_CONFIG 0x0D 60 - #define TSL2X7X_PRX_COUNT 0x0E 61 - #define TSL2X7X_GAIN 0x0F 62 - #define TSL2X7X_NOTUSED 0x10 63 - #define TSL2X7X_REVID 0x11 64 - #define TSL2X7X_CHIPID 0x12 65 - #define TSL2X7X_STATUS 0x13 66 - #define TSL2X7X_ALS_CHAN0LO 0x14 67 - #define TSL2X7X_ALS_CHAN0HI 0x15 68 - #define TSL2X7X_ALS_CHAN1LO 0x16 69 - #define TSL2X7X_ALS_CHAN1HI 0x17 70 - #define TSL2X7X_PRX_LO 0x18 71 - #define TSL2X7X_PRX_HI 0x19 45 + #define TSL2772_CNTRL 0x00 46 + #define TSL2772_ALS_TIME 0X01 47 + #define TSL2772_PRX_TIME 0x02 48 + #define TSL2772_WAIT_TIME 0x03 49 + #define TSL2772_ALS_MINTHRESHLO 0X04 50 + #define TSL2772_ALS_MINTHRESHHI 0X05 51 + #define TSL2772_ALS_MAXTHRESHLO 0X06 52 + #define TSL2772_ALS_MAXTHRESHHI 0X07 53 + #define TSL2772_PRX_MINTHRESHLO 0X08 54 + #define TSL2772_PRX_MINTHRESHHI 0X09 55 + #define TSL2772_PRX_MAXTHRESHLO 0X0A 56 + #define TSL2772_PRX_MAXTHRESHHI 0X0B 57 + #define TSL2772_PERSISTENCE 0x0C 58 + #define TSL2772_ALS_PRX_CONFIG 0x0D 59 + #define TSL2772_PRX_COUNT 0x0E 60 + #define TSL2772_GAIN 0x0F 61 + #define TSL2772_NOTUSED 0x10 62 + #define TSL2772_REVID 0x11 63 + #define TSL2772_CHIPID 0x12 64 + #define TSL2772_STATUS 0x13 65 + #define TSL2772_ALS_CHAN0LO 0x14 66 + #define TSL2772_ALS_CHAN0HI 0x15 67 + #define TSL2772_ALS_CHAN1LO 0x16 68 + #define TSL2772_ALS_CHAN1HI 0x17 69 + #define TSL2772_PRX_LO 0x18 70 + #define TSL2772_PRX_HI 0x19 72 71 73 - /* tsl2X7X cmd reg masks */ 74 - #define TSL2X7X_CMD_REG 0x80 75 - #define TSL2X7X_CMD_SPL_FN 0x60 76 - #define TSL2X7X_CMD_REPEAT_PROTO 0x00 77 - #define TSL2X7X_CMD_AUTOINC_PROTO 0x20 72 + /* tsl2772 cmd reg masks */ 73 + #define TSL2772_CMD_REG 0x80 74 + #define TSL2772_CMD_SPL_FN 0x60 75 + #define TSL2772_CMD_REPEAT_PROTO 0x00 76 + #define TSL2772_CMD_AUTOINC_PROTO 0x20 78 77 79 - #define TSL2X7X_CMD_PROX_INT_CLR 0X05 80 - #define TSL2X7X_CMD_ALS_INT_CLR 0x06 81 - #define TSL2X7X_CMD_PROXALS_INT_CLR 0X07 78 + #define TSL2772_CMD_PROX_INT_CLR 0X05 79 + #define TSL2772_CMD_ALS_INT_CLR 0x06 80 + #define TSL2772_CMD_PROXALS_INT_CLR 0X07 82 81 83 - /* tsl2X7X cntrl reg masks */ 84 - #define TSL2X7X_CNTL_ADC_ENBL 0x02 85 - #define TSL2X7X_CNTL_PWR_ON 0x01 82 + /* tsl2772 cntrl reg masks */ 83 + #define TSL2772_CNTL_ADC_ENBL 0x02 84 + #define TSL2772_CNTL_PWR_ON 0x01 86 85 87 - /* tsl2X7X status reg masks */ 88 - #define TSL2X7X_STA_ADC_VALID 0x01 89 - #define TSL2X7X_STA_PRX_VALID 0x02 90 - #define TSL2X7X_STA_ADC_PRX_VALID (TSL2X7X_STA_ADC_VALID | \ 91 - TSL2X7X_STA_PRX_VALID) 92 - #define TSL2X7X_STA_ALS_INTR 0x10 93 - #define TSL2X7X_STA_PRX_INTR 0x20 86 + /* tsl2772 status reg masks */ 87 + #define TSL2772_STA_ADC_VALID 0x01 88 + #define TSL2772_STA_PRX_VALID 0x02 89 + #define TSL2772_STA_ADC_PRX_VALID (TSL2772_STA_ADC_VALID | \ 90 + TSL2772_STA_PRX_VALID) 91 + #define TSL2772_STA_ALS_INTR 0x10 92 + #define TSL2772_STA_PRX_INTR 0x20 94 93 95 - /* tsl2X7X cntrl reg masks */ 96 - #define TSL2X7X_CNTL_REG_CLEAR 0x00 97 - #define TSL2X7X_CNTL_PROX_INT_ENBL 0X20 98 - #define TSL2X7X_CNTL_ALS_INT_ENBL 0X10 99 - #define TSL2X7X_CNTL_WAIT_TMR_ENBL 0X08 100 - #define TSL2X7X_CNTL_PROX_DET_ENBL 0X04 101 - #define TSL2X7X_CNTL_PWRON 0x01 102 - #define TSL2X7X_CNTL_ALSPON_ENBL 0x03 103 - #define TSL2X7X_CNTL_INTALSPON_ENBL 0x13 104 - #define TSL2X7X_CNTL_PROXPON_ENBL 0x0F 105 - #define TSL2X7X_CNTL_INTPROXPON_ENBL 0x2F 94 + /* tsl2772 cntrl reg masks */ 95 + #define TSL2772_CNTL_REG_CLEAR 0x00 96 + #define TSL2772_CNTL_PROX_INT_ENBL 0X20 97 + #define TSL2772_CNTL_ALS_INT_ENBL 0X10 98 + #define TSL2772_CNTL_WAIT_TMR_ENBL 0X08 99 + #define TSL2772_CNTL_PROX_DET_ENBL 0X04 100 + #define TSL2772_CNTL_PWRON 0x01 101 + #define TSL2772_CNTL_ALSPON_ENBL 0x03 102 + #define TSL2772_CNTL_INTALSPON_ENBL 0x13 103 + #define TSL2772_CNTL_PROXPON_ENBL 0x0F 104 + #define TSL2772_CNTL_INTPROXPON_ENBL 0x2F 106 105 107 - #define TSL2X7X_ALS_GAIN_TRIM_MIN 250 108 - #define TSL2X7X_ALS_GAIN_TRIM_MAX 4000 106 + #define TSL2772_ALS_GAIN_TRIM_MIN 250 107 + #define TSL2772_ALS_GAIN_TRIM_MAX 4000 109 108 110 - /* TAOS txx2x7x Device family members */ 109 + /* Device family members */ 111 110 enum { 112 111 tsl2571, 113 112 tsl2671, ··· 122 121 }; 123 122 124 123 enum { 125 - TSL2X7X_CHIP_UNKNOWN = 0, 126 - TSL2X7X_CHIP_WORKING = 1, 127 - TSL2X7X_CHIP_SUSPENDED = 2 124 + TSL2772_CHIP_UNKNOWN = 0, 125 + TSL2772_CHIP_WORKING = 1, 126 + TSL2772_CHIP_SUSPENDED = 2 128 127 }; 129 128 130 129 /* Per-device data */ 131 - struct tsl2x7x_als_info { 130 + struct tsl2772_als_info { 132 131 u16 als_ch0; 133 132 u16 als_ch1; 134 133 u16 lux; 135 134 }; 136 135 137 - struct tsl2x7x_chip_info { 136 + struct tsl2772_chip_info { 138 137 int chan_table_elements; 139 138 struct iio_chan_spec channel_with_events[4]; 140 139 struct iio_chan_spec channel_without_events[4]; 141 140 const struct iio_info *info; 142 141 }; 143 142 144 - struct tsl2X7X_chip { 143 + struct tsl2772_chip { 145 144 kernel_ulong_t id; 146 145 struct mutex prox_mutex; 147 146 struct mutex als_mutex; 148 147 struct i2c_client *client; 149 148 u16 prox_data; 150 - struct tsl2x7x_als_info als_cur_info; 151 - struct tsl2x7x_settings settings; 152 - struct tsl2X7X_platform_data *pdata; 149 + struct tsl2772_als_info als_cur_info; 150 + struct tsl2772_settings settings; 151 + struct tsl2772_platform_data *pdata; 153 152 int als_gain_time_scale; 154 153 int als_saturation; 155 - int tsl2x7x_chip_status; 156 - u8 tsl2x7x_config[TSL2X7X_MAX_CONFIG_REG]; 157 - const struct tsl2x7x_chip_info *chip_info; 154 + int tsl2772_chip_status; 155 + u8 tsl2772_config[TSL2772_MAX_CONFIG_REG]; 156 + const struct tsl2772_chip_info *chip_info; 158 157 const struct iio_info *info; 159 158 s64 event_timestamp; 160 159 /* ··· 162 161 * updates via sysfs. 163 162 * Sized to 9 = max 8 segments + 1 termination segment 164 163 */ 165 - struct tsl2x7x_lux tsl2x7x_device_lux[TSL2X7X_MAX_LUX_TABLE_SIZE]; 164 + struct tsl2772_lux tsl2772_device_lux[TSL2772_MAX_LUX_TABLE_SIZE]; 166 165 }; 167 166 168 167 /* ··· 173 172 * The two rows in each table correspond to the Lux1 and Lux2 equations from 174 173 * the datasheets. 175 174 */ 176 - static const struct tsl2x7x_lux tsl2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { 175 + static const struct tsl2772_lux tsl2x71_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = { 177 176 { 53000, 106000 }, 178 177 { 31800, 53000 }, 179 178 { 0, 0 }, 180 179 }; 181 180 182 - static const struct tsl2x7x_lux tmd2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { 181 + static const struct tsl2772_lux tmd2x71_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = { 183 182 { 24000, 48000 }, 184 183 { 14400, 24000 }, 185 184 { 0, 0 }, 186 185 }; 187 186 188 - static const struct tsl2x7x_lux tsl2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { 187 + static const struct tsl2772_lux tsl2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = { 189 188 { 60000, 112200 }, 190 189 { 37800, 60000 }, 191 190 { 0, 0 }, 192 191 }; 193 192 194 - static const struct tsl2x7x_lux tmd2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { 193 + static const struct tsl2772_lux tmd2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = { 195 194 { 20000, 35000 }, 196 195 { 12600, 20000 }, 197 196 { 0, 0 }, 198 197 }; 199 198 200 - static const struct tsl2x7x_lux *tsl2x7x_default_lux_table_group[] = { 199 + static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = { 201 200 [tsl2571] = tsl2x71_lux_table, 202 201 [tsl2671] = tsl2x71_lux_table, 203 202 [tmd2671] = tmd2x71_lux_table, ··· 210 209 [tmd2772] = tmd2x72_lux_table, 211 210 }; 212 211 213 - static const struct tsl2x7x_settings tsl2x7x_default_settings = { 212 + static const struct tsl2772_settings tsl2772_default_settings = { 214 213 .als_time = 255, /* 2.72 / 2.73 ms */ 215 214 .als_gain = 0, 216 215 .prox_time = 255, /* 2.72 / 2.73 ms */ ··· 229 228 .prox_thres_high = 512, 230 229 .prox_max_samples_cal = 30, 231 230 .prox_pulse_count = 8, 232 - .prox_diode = TSL2X7X_DIODE1, 233 - .prox_power = TSL2X7X_100_mA 231 + .prox_diode = TSL2772_DIODE1, 232 + .prox_power = TSL2772_100_mA 234 233 }; 235 234 236 - static const s16 tsl2x7x_als_gain[] = { 235 + static const s16 tsl2772_als_gain[] = { 237 236 1, 238 237 8, 239 238 16, 240 239 120 241 240 }; 242 241 243 - static const s16 tsl2x7x_prox_gain[] = { 242 + static const s16 tsl2772_prox_gain[] = { 244 243 1, 245 244 2, 246 245 4, 247 246 8 248 247 }; 249 248 250 - static const int tsl2x7x_int_time_avail[][6] = { 249 + static const int tsl2772_int_time_avail[][6] = { 251 250 [tsl2571] = { 0, 2720, 0, 2720, 0, 696000 }, 252 251 [tsl2671] = { 0, 2720, 0, 2720, 0, 696000 }, 253 252 [tmd2671] = { 0, 2720, 0, 2720, 0, 696000 }, ··· 260 259 [tmd2772] = { 0, 2730, 0, 2730, 0, 699000 }, 261 260 }; 262 261 263 - static int tsl2x7x_int_calibscale_avail[] = { 1, 8, 16, 120 }; 262 + static int tsl2772_int_calibscale_avail[] = { 1, 8, 16, 120 }; 264 263 265 - static int tsl2x7x_prox_calibscale_avail[] = { 1, 2, 4, 8 }; 264 + static int tsl2772_prox_calibscale_avail[] = { 1, 2, 4, 8 }; 266 265 267 266 /* Channel variations */ 268 267 enum { ··· 286 285 [tmd2772] = ALSPRX2 287 286 }; 288 287 289 - static int tsl2x7x_read_status(struct tsl2X7X_chip *chip) 288 + static int tsl2772_read_status(struct tsl2772_chip *chip) 290 289 { 291 290 int ret; 292 291 293 292 ret = i2c_smbus_read_byte_data(chip->client, 294 - TSL2X7X_CMD_REG | TSL2X7X_STATUS); 293 + TSL2772_CMD_REG | TSL2772_STATUS); 295 294 if (ret < 0) 296 295 dev_err(&chip->client->dev, 297 296 "%s: failed to read STATUS register: %d\n", __func__, ··· 300 299 return ret; 301 300 } 302 301 303 - static int tsl2x7x_write_control_reg(struct tsl2X7X_chip *chip, u8 data) 302 + static int tsl2772_write_control_reg(struct tsl2772_chip *chip, u8 data) 304 303 { 305 304 int ret; 306 305 307 306 ret = i2c_smbus_write_byte_data(chip->client, 308 - TSL2X7X_CMD_REG | TSL2X7X_CNTRL, data); 307 + TSL2772_CMD_REG | TSL2772_CNTRL, data); 309 308 if (ret < 0) { 310 309 dev_err(&chip->client->dev, 311 310 "%s: failed to write to control register %x: %d\n", ··· 315 314 return ret; 316 315 } 317 316 318 - static int tsl2x7x_read_autoinc_regs(struct tsl2X7X_chip *chip, int lower_reg, 317 + static int tsl2772_read_autoinc_regs(struct tsl2772_chip *chip, int lower_reg, 319 318 int upper_reg) 320 319 { 321 320 u8 buf[2]; 322 321 int ret; 323 322 324 323 ret = i2c_smbus_write_byte(chip->client, 325 - TSL2X7X_CMD_REG | TSL2X7X_CMD_AUTOINC_PROTO | 324 + TSL2772_CMD_REG | TSL2772_CMD_AUTOINC_PROTO | 326 325 lower_reg); 327 326 if (ret < 0) { 328 327 dev_err(&chip->client->dev, ··· 332 331 } 333 332 334 333 ret = i2c_smbus_read_byte_data(chip->client, 335 - TSL2X7X_CMD_REG | lower_reg); 334 + TSL2772_CMD_REG | lower_reg); 336 335 if (ret < 0) { 337 336 dev_err(&chip->client->dev, 338 337 "%s: failed to read from register %x: %d\n", __func__, ··· 342 341 buf[0] = ret; 343 342 344 343 ret = i2c_smbus_read_byte_data(chip->client, 345 - TSL2X7X_CMD_REG | upper_reg); 344 + TSL2772_CMD_REG | upper_reg); 346 345 if (ret < 0) { 347 346 dev_err(&chip->client->dev, 348 347 "%s: failed to read from register %x: %d\n", __func__, ··· 352 351 buf[1] = ret; 353 352 354 353 ret = i2c_smbus_write_byte(chip->client, 355 - TSL2X7X_CMD_REG | TSL2X7X_CMD_REPEAT_PROTO | 354 + TSL2772_CMD_REG | TSL2772_CMD_REPEAT_PROTO | 356 355 lower_reg); 357 356 if (ret < 0) { 358 357 dev_err(&chip->client->dev, ··· 365 364 } 366 365 367 366 /** 368 - * tsl2x7x_get_lux() - Reads and calculates current lux value. 367 + * tsl2772_get_lux() - Reads and calculates current lux value. 369 368 * @indio_dev: pointer to IIO device 370 369 * 371 370 * The raw ch0 and ch1 values of the ambient light sensed in the last ··· 375 374 * coefficients. A lux gain trim is applied to each lux equation, and then the 376 375 * maximum lux within the interval 0..65535 is selected. 377 376 */ 378 - static int tsl2x7x_get_lux(struct iio_dev *indio_dev) 377 + static int tsl2772_get_lux(struct iio_dev *indio_dev) 379 378 { 380 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 381 - struct tsl2x7x_lux *p; 379 + struct tsl2772_chip *chip = iio_priv(indio_dev); 380 + struct tsl2772_lux *p; 382 381 int max_lux, ret; 383 382 bool overflow; 384 383 385 384 mutex_lock(&chip->als_mutex); 386 385 387 - if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) { 386 + if (chip->tsl2772_chip_status != TSL2772_CHIP_WORKING) { 388 387 dev_err(&chip->client->dev, "%s: device is not enabled\n", 389 388 __func__); 390 389 ret = -EBUSY; 391 390 goto out_unlock; 392 391 } 393 392 394 - ret = tsl2x7x_read_status(chip); 393 + ret = tsl2772_read_status(chip); 395 394 if (ret < 0) 396 395 goto out_unlock; 397 396 398 - if (!(ret & TSL2X7X_STA_ADC_VALID)) { 397 + if (!(ret & TSL2772_STA_ADC_VALID)) { 399 398 dev_err(&chip->client->dev, 400 399 "%s: data not valid yet\n", __func__); 401 400 ret = chip->als_cur_info.lux; /* return LAST VALUE */ 402 401 goto out_unlock; 403 402 } 404 403 405 - ret = tsl2x7x_read_autoinc_regs(chip, TSL2X7X_ALS_CHAN0LO, 406 - TSL2X7X_ALS_CHAN0HI); 404 + ret = tsl2772_read_autoinc_regs(chip, TSL2772_ALS_CHAN0LO, 405 + TSL2772_ALS_CHAN0HI); 407 406 if (ret < 0) 408 407 goto out_unlock; 409 408 chip->als_cur_info.als_ch0 = ret; 410 409 411 - ret = tsl2x7x_read_autoinc_regs(chip, TSL2X7X_ALS_CHAN1LO, 412 - TSL2X7X_ALS_CHAN1HI); 410 + ret = tsl2772_read_autoinc_regs(chip, TSL2772_ALS_CHAN1LO, 411 + TSL2772_ALS_CHAN1HI); 413 412 if (ret < 0) 414 413 goto out_unlock; 415 414 chip->als_cur_info.als_ch1 = ret; 416 415 417 416 if (chip->als_cur_info.als_ch0 >= chip->als_saturation) { 418 - max_lux = TSL2X7X_LUX_CALC_OVER_FLOW; 417 + max_lux = TSL2772_LUX_CALC_OVER_FLOW; 419 418 goto update_struct_with_max_lux; 420 419 } 421 420 ··· 427 426 428 427 max_lux = 0; 429 428 overflow = false; 430 - for (p = (struct tsl2x7x_lux *)chip->tsl2x7x_device_lux; p->ch0 != 0; 429 + for (p = (struct tsl2772_lux *)chip->tsl2772_device_lux; p->ch0 != 0; 431 430 p++) { 432 431 int lux; 433 432 ··· 443 442 */ 444 443 lux = (lux * chip->settings.als_gain_trim) / 1000; 445 444 446 - if (lux > TSL2X7X_LUX_CALC_OVER_FLOW) { 445 + if (lux > TSL2772_LUX_CALC_OVER_FLOW) { 447 446 overflow = true; 448 447 continue; 449 448 } ··· 452 451 } 453 452 454 453 if (overflow && max_lux == 0) 455 - max_lux = TSL2X7X_LUX_CALC_OVER_FLOW; 454 + max_lux = TSL2772_LUX_CALC_OVER_FLOW; 456 455 457 456 update_struct_with_max_lux: 458 457 chip->als_cur_info.lux = max_lux; ··· 465 464 } 466 465 467 466 /** 468 - * tsl2x7x_get_prox() - Reads proximity data registers and updates 467 + * tsl2772_get_prox() - Reads proximity data registers and updates 469 468 * chip->prox_data. 470 469 * 471 470 * @indio_dev: pointer to IIO device 472 471 */ 473 - static int tsl2x7x_get_prox(struct iio_dev *indio_dev) 472 + static int tsl2772_get_prox(struct iio_dev *indio_dev) 474 473 { 475 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 474 + struct tsl2772_chip *chip = iio_priv(indio_dev); 476 475 int ret; 477 476 478 477 mutex_lock(&chip->prox_mutex); 479 478 480 - ret = tsl2x7x_read_status(chip); 479 + ret = tsl2772_read_status(chip); 481 480 if (ret < 0) 482 481 goto prox_poll_err; 483 482 ··· 487 486 case tmd2671: 488 487 case tsl2771: 489 488 case tmd2771: 490 - if (!(ret & TSL2X7X_STA_ADC_VALID)) { 489 + if (!(ret & TSL2772_STA_ADC_VALID)) { 491 490 ret = -EINVAL; 492 491 goto prox_poll_err; 493 492 } ··· 497 496 case tmd2672: 498 497 case tsl2772: 499 498 case tmd2772: 500 - if (!(ret & TSL2X7X_STA_PRX_VALID)) { 499 + if (!(ret & TSL2772_STA_PRX_VALID)) { 501 500 ret = -EINVAL; 502 501 goto prox_poll_err; 503 502 } 504 503 break; 505 504 } 506 505 507 - ret = tsl2x7x_read_autoinc_regs(chip, TSL2X7X_PRX_LO, TSL2X7X_PRX_HI); 506 + ret = tsl2772_read_autoinc_regs(chip, TSL2772_PRX_LO, TSL2772_PRX_HI); 508 507 if (ret < 0) 509 508 goto prox_poll_err; 510 509 chip->prox_data = ret; ··· 516 515 } 517 516 518 517 /** 519 - * tsl2x7x_defaults() - Populates the device nominal operating parameters 518 + * tsl2772_defaults() - Populates the device nominal operating parameters 520 519 * with those provided by a 'platform' data struct or 521 520 * with prefined defaults. 522 521 * 523 522 * @chip: pointer to device structure. 524 523 */ 525 - static void tsl2x7x_defaults(struct tsl2X7X_chip *chip) 524 + static void tsl2772_defaults(struct tsl2772_chip *chip) 526 525 { 527 526 /* If Operational settings defined elsewhere.. */ 528 527 if (chip->pdata && chip->pdata->platform_default_settings) 529 528 memcpy(&chip->settings, chip->pdata->platform_default_settings, 530 - sizeof(tsl2x7x_default_settings)); 529 + sizeof(tsl2772_default_settings)); 531 530 else 532 - memcpy(&chip->settings, &tsl2x7x_default_settings, 533 - sizeof(tsl2x7x_default_settings)); 531 + memcpy(&chip->settings, &tsl2772_default_settings, 532 + sizeof(tsl2772_default_settings)); 534 533 535 534 /* Load up the proper lux table. */ 536 535 if (chip->pdata && chip->pdata->platform_lux_table[0].ch0 != 0) 537 - memcpy(chip->tsl2x7x_device_lux, 536 + memcpy(chip->tsl2772_device_lux, 538 537 chip->pdata->platform_lux_table, 539 538 sizeof(chip->pdata->platform_lux_table)); 540 539 else 541 - memcpy(chip->tsl2x7x_device_lux, 542 - tsl2x7x_default_lux_table_group[chip->id], 543 - TSL2X7X_DEFAULT_TABLE_BYTES); 540 + memcpy(chip->tsl2772_device_lux, 541 + tsl2772_default_lux_table_group[chip->id], 542 + TSL2772_DEFAULT_TABLE_BYTES); 544 543 } 545 544 546 545 /** 547 - * tsl2x7x_als_calibrate() - Obtain single reading and calculate 546 + * tsl2772_als_calibrate() - Obtain single reading and calculate 548 547 * the als_gain_trim. 549 548 * 550 549 * @indio_dev: pointer to IIO device 551 550 */ 552 - static int tsl2x7x_als_calibrate(struct iio_dev *indio_dev) 551 + static int tsl2772_als_calibrate(struct iio_dev *indio_dev) 553 552 { 554 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 553 + struct tsl2772_chip *chip = iio_priv(indio_dev); 555 554 int ret, lux_val; 556 555 557 556 ret = i2c_smbus_read_byte_data(chip->client, 558 - TSL2X7X_CMD_REG | TSL2X7X_CNTRL); 557 + TSL2772_CMD_REG | TSL2772_CNTRL); 559 558 if (ret < 0) { 560 559 dev_err(&chip->client->dev, 561 560 "%s: failed to read from the CNTRL register\n", ··· 563 562 return ret; 564 563 } 565 564 566 - if ((ret & (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) 567 - != (TSL2X7X_CNTL_ADC_ENBL | TSL2X7X_CNTL_PWR_ON)) { 565 + if ((ret & (TSL2772_CNTL_ADC_ENBL | TSL2772_CNTL_PWR_ON)) 566 + != (TSL2772_CNTL_ADC_ENBL | TSL2772_CNTL_PWR_ON)) { 568 567 dev_err(&chip->client->dev, 569 568 "%s: Device is not powered on and/or ADC is not enabled\n", 570 569 __func__); 571 570 return -EINVAL; 572 - } else if ((ret & TSL2X7X_STA_ADC_VALID) != TSL2X7X_STA_ADC_VALID) { 571 + } else if ((ret & TSL2772_STA_ADC_VALID) != TSL2772_STA_ADC_VALID) { 573 572 dev_err(&chip->client->dev, 574 573 "%s: The two ADC channels have not completed an integration cycle\n", 575 574 __func__); 576 575 return -ENODATA; 577 576 } 578 577 579 - lux_val = tsl2x7x_get_lux(indio_dev); 578 + lux_val = tsl2772_get_lux(indio_dev); 580 579 if (lux_val < 0) { 581 580 dev_err(&chip->client->dev, 582 581 "%s: failed to get lux\n", __func__); ··· 585 584 586 585 ret = (chip->settings.als_cal_target * chip->settings.als_gain_trim) / 587 586 lux_val; 588 - if (ret < TSL2X7X_ALS_GAIN_TRIM_MIN || ret > TSL2X7X_ALS_GAIN_TRIM_MAX) 587 + if (ret < TSL2772_ALS_GAIN_TRIM_MIN || ret > TSL2772_ALS_GAIN_TRIM_MAX) 589 588 return -ERANGE; 590 589 591 590 chip->settings.als_gain_trim = ret; ··· 593 592 return ret; 594 593 } 595 594 596 - static int tsl2x7x_chip_on(struct iio_dev *indio_dev) 595 + static int tsl2772_chip_on(struct iio_dev *indio_dev) 597 596 { 598 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 597 + struct tsl2772_chip *chip = iio_priv(indio_dev); 599 598 int ret, i, als_count, als_time_us; 600 599 u8 *dev_reg, reg_val; 601 600 602 601 /* Non calculated parameters */ 603 - chip->tsl2x7x_config[TSL2X7X_ALS_TIME] = chip->settings.als_time; 604 - chip->tsl2x7x_config[TSL2X7X_PRX_TIME] = chip->settings.prox_time; 605 - chip->tsl2x7x_config[TSL2X7X_WAIT_TIME] = chip->settings.wait_time; 606 - chip->tsl2x7x_config[TSL2X7X_ALS_PRX_CONFIG] = 602 + chip->tsl2772_config[TSL2772_ALS_TIME] = chip->settings.als_time; 603 + chip->tsl2772_config[TSL2772_PRX_TIME] = chip->settings.prox_time; 604 + chip->tsl2772_config[TSL2772_WAIT_TIME] = chip->settings.wait_time; 605 + chip->tsl2772_config[TSL2772_ALS_PRX_CONFIG] = 607 606 chip->settings.als_prox_config; 608 607 609 - chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHLO] = 608 + chip->tsl2772_config[TSL2772_ALS_MINTHRESHLO] = 610 609 (chip->settings.als_thresh_low) & 0xFF; 611 - chip->tsl2x7x_config[TSL2X7X_ALS_MINTHRESHHI] = 610 + chip->tsl2772_config[TSL2772_ALS_MINTHRESHHI] = 612 611 (chip->settings.als_thresh_low >> 8) & 0xFF; 613 - chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHLO] = 612 + chip->tsl2772_config[TSL2772_ALS_MAXTHRESHLO] = 614 613 (chip->settings.als_thresh_high) & 0xFF; 615 - chip->tsl2x7x_config[TSL2X7X_ALS_MAXTHRESHHI] = 614 + chip->tsl2772_config[TSL2772_ALS_MAXTHRESHHI] = 616 615 (chip->settings.als_thresh_high >> 8) & 0xFF; 617 - chip->tsl2x7x_config[TSL2X7X_PERSISTENCE] = 616 + chip->tsl2772_config[TSL2772_PERSISTENCE] = 618 617 (chip->settings.prox_persistence & 0xFF) << 4 | 619 618 (chip->settings.als_persistence & 0xFF); 620 619 621 - chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] = 620 + chip->tsl2772_config[TSL2772_PRX_COUNT] = 622 621 chip->settings.prox_pulse_count; 623 - chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] = 622 + chip->tsl2772_config[TSL2772_PRX_MINTHRESHLO] = 624 623 (chip->settings.prox_thres_low) & 0xFF; 625 - chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] = 624 + chip->tsl2772_config[TSL2772_PRX_MINTHRESHHI] = 626 625 (chip->settings.prox_thres_low >> 8) & 0xFF; 627 - chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] = 626 + chip->tsl2772_config[TSL2772_PRX_MAXTHRESHLO] = 628 627 (chip->settings.prox_thres_high) & 0xFF; 629 - chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] = 628 + chip->tsl2772_config[TSL2772_PRX_MAXTHRESHHI] = 630 629 (chip->settings.prox_thres_high >> 8) & 0xFF; 631 630 632 631 /* and make sure we're not already on */ 633 - if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) { 632 + if (chip->tsl2772_chip_status == TSL2772_CHIP_WORKING) { 634 633 /* if forcing a register update - turn off, then on */ 635 634 dev_info(&chip->client->dev, "device is already enabled\n"); 636 635 return -EINVAL; 637 636 } 638 637 639 - /* Set the gain based on tsl2x7x_settings struct */ 640 - chip->tsl2x7x_config[TSL2X7X_GAIN] = 638 + /* Set the gain based on tsl2772_settings struct */ 639 + chip->tsl2772_config[TSL2772_GAIN] = 641 640 (chip->settings.als_gain & 0xFF) | 642 641 ((chip->settings.prox_gain & 0xFF) << 2) | 643 642 (chip->settings.prox_diode << 4) | ··· 645 644 646 645 /* set chip time scaling and saturation */ 647 646 als_count = 256 - chip->settings.als_time; 648 - als_time_us = als_count * tsl2x7x_int_time_avail[chip->id][3]; 647 + als_time_us = als_count * tsl2772_int_time_avail[chip->id][3]; 649 648 chip->als_saturation = als_count * 768; /* 75% of full scale */ 650 649 chip->als_gain_time_scale = als_time_us * 651 - tsl2x7x_als_gain[chip->settings.als_gain]; 650 + tsl2772_als_gain[chip->settings.als_gain]; 652 651 653 652 /* 654 - * TSL2X7X Specific power-on / adc enable sequence 653 + * TSL2772 Specific power-on / adc enable sequence 655 654 * Power on the device 1st. 656 655 */ 657 - ret = tsl2x7x_write_control_reg(chip, TSL2X7X_CNTL_PWR_ON); 656 + ret = tsl2772_write_control_reg(chip, TSL2772_CNTL_PWR_ON); 658 657 if (ret < 0) 659 658 return ret; 660 659 ··· 662 661 * Use the following shadow copy for our delay before enabling ADC. 663 662 * Write all the registers. 664 663 */ 665 - for (i = 0, dev_reg = chip->tsl2x7x_config; 666 - i < TSL2X7X_MAX_CONFIG_REG; i++) { 667 - int reg = TSL2X7X_CMD_REG + i; 664 + for (i = 0, dev_reg = chip->tsl2772_config; 665 + i < TSL2772_MAX_CONFIG_REG; i++) { 666 + int reg = TSL2772_CMD_REG + i; 668 667 669 668 ret = i2c_smbus_write_byte_data(chip->client, reg, 670 669 *dev_reg++); ··· 679 678 /* Power-on settling time */ 680 679 usleep_range(3000, 3500); 681 680 682 - reg_val = TSL2X7X_CNTL_PWR_ON | TSL2X7X_CNTL_ADC_ENBL | 683 - TSL2X7X_CNTL_PROX_DET_ENBL; 681 + reg_val = TSL2772_CNTL_PWR_ON | TSL2772_CNTL_ADC_ENBL | 682 + TSL2772_CNTL_PROX_DET_ENBL; 684 683 if (chip->settings.als_interrupt_en) 685 - reg_val |= TSL2X7X_CNTL_ALS_INT_ENBL; 684 + reg_val |= TSL2772_CNTL_ALS_INT_ENBL; 686 685 if (chip->settings.prox_interrupt_en) 687 - reg_val |= TSL2X7X_CNTL_PROX_INT_ENBL; 686 + reg_val |= TSL2772_CNTL_PROX_INT_ENBL; 688 687 689 - ret = tsl2x7x_write_control_reg(chip, reg_val); 688 + ret = tsl2772_write_control_reg(chip, reg_val); 690 689 if (ret < 0) 691 690 return ret; 692 691 693 692 ret = i2c_smbus_write_byte(chip->client, 694 - TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | 695 - TSL2X7X_CMD_PROXALS_INT_CLR); 693 + TSL2772_CMD_REG | TSL2772_CMD_SPL_FN | 694 + TSL2772_CMD_PROXALS_INT_CLR); 696 695 if (ret < 0) { 697 696 dev_err(&chip->client->dev, 698 697 "%s: failed to clear interrupt status: %d\n", ··· 700 699 return ret; 701 700 } 702 701 703 - chip->tsl2x7x_chip_status = TSL2X7X_CHIP_WORKING; 702 + chip->tsl2772_chip_status = TSL2772_CHIP_WORKING; 704 703 705 704 return ret; 706 705 } 707 706 708 - static int tsl2x7x_chip_off(struct iio_dev *indio_dev) 707 + static int tsl2772_chip_off(struct iio_dev *indio_dev) 709 708 { 710 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 709 + struct tsl2772_chip *chip = iio_priv(indio_dev); 711 710 712 711 /* turn device off */ 713 - chip->tsl2x7x_chip_status = TSL2X7X_CHIP_SUSPENDED; 714 - return tsl2x7x_write_control_reg(chip, 0x00); 712 + chip->tsl2772_chip_status = TSL2772_CHIP_SUSPENDED; 713 + return tsl2772_write_control_reg(chip, 0x00); 715 714 } 716 715 717 716 /** 718 - * tsl2x7x_invoke_change - power cycle the device to implement the user 717 + * tsl2772_invoke_change - power cycle the device to implement the user 719 718 * parameters 720 719 * @indio_dev: pointer to IIO device 721 720 * ··· 723 722 * (On/Off), cycle device to implement updated parameter, put device back into 724 723 * proper state, and unlock resource. 725 724 */ 726 - static int tsl2x7x_invoke_change(struct iio_dev *indio_dev) 725 + static int tsl2772_invoke_change(struct iio_dev *indio_dev) 727 726 { 728 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 729 - int device_status = chip->tsl2x7x_chip_status; 727 + struct tsl2772_chip *chip = iio_priv(indio_dev); 728 + int device_status = chip->tsl2772_chip_status; 730 729 int ret; 731 730 732 731 mutex_lock(&chip->als_mutex); 733 732 mutex_lock(&chip->prox_mutex); 734 733 735 - if (device_status == TSL2X7X_CHIP_WORKING) { 736 - ret = tsl2x7x_chip_off(indio_dev); 734 + if (device_status == TSL2772_CHIP_WORKING) { 735 + ret = tsl2772_chip_off(indio_dev); 737 736 if (ret < 0) 738 737 goto unlock; 739 738 } 740 739 741 - ret = tsl2x7x_chip_on(indio_dev); 740 + ret = tsl2772_chip_on(indio_dev); 742 741 743 742 unlock: 744 743 mutex_unlock(&chip->prox_mutex); ··· 747 746 return ret; 748 747 } 749 748 750 - static int tsl2x7x_prox_cal(struct iio_dev *indio_dev) 749 + static int tsl2772_prox_cal(struct iio_dev *indio_dev) 751 750 { 752 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 751 + struct tsl2772_chip *chip = iio_priv(indio_dev); 753 752 int prox_history[MAX_SAMPLES_CAL + 1]; 754 753 int i, ret, mean, max, sample_sum; 755 754 ··· 759 758 760 759 for (i = 0; i < chip->settings.prox_max_samples_cal; i++) { 761 760 usleep_range(15000, 17500); 762 - ret = tsl2x7x_get_prox(indio_dev); 761 + ret = tsl2772_get_prox(indio_dev); 763 762 if (ret < 0) 764 763 return ret; 765 764 ··· 776 775 777 776 chip->settings.prox_thres_high = (max << 1) - mean; 778 777 779 - return tsl2x7x_invoke_change(indio_dev); 778 + return tsl2772_invoke_change(indio_dev); 780 779 } 781 780 782 - static int tsl2x7x_read_avail(struct iio_dev *indio_dev, 781 + static int tsl2772_read_avail(struct iio_dev *indio_dev, 783 782 struct iio_chan_spec const *chan, 784 783 const int **vals, int *type, int *length, 785 784 long mask) 786 785 { 787 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 786 + struct tsl2772_chip *chip = iio_priv(indio_dev); 788 787 789 788 switch (mask) { 790 789 case IIO_CHAN_INFO_CALIBSCALE: 791 790 if (chan->type == IIO_INTENSITY) { 792 - *length = ARRAY_SIZE(tsl2x7x_int_calibscale_avail); 793 - *vals = tsl2x7x_int_calibscale_avail; 791 + *length = ARRAY_SIZE(tsl2772_int_calibscale_avail); 792 + *vals = tsl2772_int_calibscale_avail; 794 793 } else { 795 - *length = ARRAY_SIZE(tsl2x7x_prox_calibscale_avail); 796 - *vals = tsl2x7x_prox_calibscale_avail; 794 + *length = ARRAY_SIZE(tsl2772_prox_calibscale_avail); 795 + *vals = tsl2772_prox_calibscale_avail; 797 796 } 798 797 *type = IIO_VAL_INT; 799 798 return IIO_AVAIL_LIST; 800 799 case IIO_CHAN_INFO_INT_TIME: 801 - *length = ARRAY_SIZE(tsl2x7x_int_time_avail[chip->id]); 802 - *vals = tsl2x7x_int_time_avail[chip->id]; 800 + *length = ARRAY_SIZE(tsl2772_int_time_avail[chip->id]); 801 + *vals = tsl2772_int_time_avail[chip->id]; 803 802 *type = IIO_VAL_INT_PLUS_MICRO; 804 803 return IIO_AVAIL_RANGE; 805 804 } ··· 811 810 struct device_attribute *attr, 812 811 char *buf) 813 812 { 814 - struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); 813 + struct tsl2772_chip *chip = iio_priv(dev_to_iio_dev(dev)); 815 814 816 815 return snprintf(buf, PAGE_SIZE, "%d\n", chip->settings.als_cal_target); 817 816 } ··· 821 820 const char *buf, size_t len) 822 821 { 823 822 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 824 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 823 + struct tsl2772_chip *chip = iio_priv(indio_dev); 825 824 u16 value; 826 825 int ret; 827 826 ··· 829 828 return -EINVAL; 830 829 831 830 chip->settings.als_cal_target = value; 832 - ret = tsl2x7x_invoke_change(indio_dev); 831 + ret = tsl2772_invoke_change(indio_dev); 833 832 if (ret < 0) 834 833 return ret; 835 834 ··· 847 846 if (kstrtobool(buf, &value) || !value) 848 847 return -EINVAL; 849 848 850 - ret = tsl2x7x_als_calibrate(indio_dev); 849 + ret = tsl2772_als_calibrate(indio_dev); 851 850 if (ret < 0) 852 851 return ret; 853 852 854 - ret = tsl2x7x_invoke_change(indio_dev); 853 + ret = tsl2772_invoke_change(indio_dev); 855 854 if (ret < 0) 856 855 return ret; 857 856 ··· 862 861 struct device_attribute *attr, 863 862 char *buf) 864 863 { 865 - struct tsl2X7X_chip *chip = iio_priv(dev_to_iio_dev(dev)); 864 + struct tsl2772_chip *chip = iio_priv(dev_to_iio_dev(dev)); 866 865 int i = 0; 867 866 int offset = 0; 868 867 869 - while (i < TSL2X7X_MAX_LUX_TABLE_SIZE) { 868 + while (i < TSL2772_MAX_LUX_TABLE_SIZE) { 870 869 offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,", 871 - chip->tsl2x7x_device_lux[i].ch0, 872 - chip->tsl2x7x_device_lux[i].ch1); 873 - if (chip->tsl2x7x_device_lux[i].ch0 == 0) { 870 + chip->tsl2772_device_lux[i].ch0, 871 + chip->tsl2772_device_lux[i].ch1); 872 + if (chip->tsl2772_device_lux[i].ch0 == 0) { 874 873 /* 875 874 * We just printed the first "0" entry. 876 875 * Now get rid of the extra "," and break. ··· 890 889 const char *buf, size_t len) 891 890 { 892 891 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 893 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 894 - int value[ARRAY_SIZE(chip->tsl2x7x_device_lux) * 2 + 1]; 892 + struct tsl2772_chip *chip = iio_priv(indio_dev); 893 + int value[ARRAY_SIZE(chip->tsl2772_device_lux) * 2 + 1]; 895 894 int n, ret; 896 895 897 896 get_options(buf, ARRAY_SIZE(value), value); ··· 904 903 */ 905 904 n = value[0]; 906 905 if ((n % 2) || n < 4 || 907 - n > ((ARRAY_SIZE(chip->tsl2x7x_device_lux) - 1) * 2)) 906 + n > ((ARRAY_SIZE(chip->tsl2772_device_lux) - 1) * 2)) 908 907 return -EINVAL; 909 908 910 909 if ((value[(n - 1)] | value[n]) != 0) 911 910 return -EINVAL; 912 911 913 - if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) { 914 - ret = tsl2x7x_chip_off(indio_dev); 912 + if (chip->tsl2772_chip_status == TSL2772_CHIP_WORKING) { 913 + ret = tsl2772_chip_off(indio_dev); 915 914 if (ret < 0) 916 915 return ret; 917 916 } 918 917 919 918 /* Zero out the table */ 920 - memset(chip->tsl2x7x_device_lux, 0, sizeof(chip->tsl2x7x_device_lux)); 921 - memcpy(chip->tsl2x7x_device_lux, &value[1], (value[0] * 4)); 919 + memset(chip->tsl2772_device_lux, 0, sizeof(chip->tsl2772_device_lux)); 920 + memcpy(chip->tsl2772_device_lux, &value[1], (value[0] * 4)); 922 921 923 - ret = tsl2x7x_invoke_change(indio_dev); 922 + ret = tsl2772_invoke_change(indio_dev); 924 923 if (ret < 0) 925 924 return ret; 926 925 ··· 938 937 if (kstrtobool(buf, &value) || !value) 939 938 return -EINVAL; 940 939 941 - ret = tsl2x7x_prox_cal(indio_dev); 940 + ret = tsl2772_prox_cal(indio_dev); 942 941 if (ret < 0) 943 942 return ret; 944 943 945 - ret = tsl2x7x_invoke_change(indio_dev); 944 + ret = tsl2772_invoke_change(indio_dev); 946 945 if (ret < 0) 947 946 return ret; 948 947 949 948 return len; 950 949 } 951 950 952 - static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev, 951 + static int tsl2772_read_interrupt_config(struct iio_dev *indio_dev, 953 952 const struct iio_chan_spec *chan, 954 953 enum iio_event_type type, 955 954 enum iio_event_direction dir) 956 955 { 957 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 956 + struct tsl2772_chip *chip = iio_priv(indio_dev); 958 957 959 958 if (chan->type == IIO_INTENSITY) 960 959 return chip->settings.als_interrupt_en; ··· 962 961 return chip->settings.prox_interrupt_en; 963 962 } 964 963 965 - static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev, 964 + static int tsl2772_write_interrupt_config(struct iio_dev *indio_dev, 966 965 const struct iio_chan_spec *chan, 967 966 enum iio_event_type type, 968 967 enum iio_event_direction dir, 969 968 int val) 970 969 { 971 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 970 + struct tsl2772_chip *chip = iio_priv(indio_dev); 972 971 973 972 if (chan->type == IIO_INTENSITY) 974 973 chip->settings.als_interrupt_en = val ? true : false; 975 974 else 976 975 chip->settings.prox_interrupt_en = val ? true : false; 977 976 978 - return tsl2x7x_invoke_change(indio_dev); 977 + return tsl2772_invoke_change(indio_dev); 979 978 } 980 979 981 - static int tsl2x7x_write_event_value(struct iio_dev *indio_dev, 980 + static int tsl2772_write_event_value(struct iio_dev *indio_dev, 982 981 const struct iio_chan_spec *chan, 983 982 enum iio_event_type type, 984 983 enum iio_event_direction dir, 985 984 enum iio_event_info info, 986 985 int val, int val2) 987 986 { 988 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 987 + struct tsl2772_chip *chip = iio_priv(indio_dev); 989 988 int ret = -EINVAL, count, persistence; 990 989 u8 time; 991 990 ··· 1027 1026 1028 1027 count = 256 - time; 1029 1028 persistence = ((val * 1000000) + val2) / 1030 - (count * tsl2x7x_int_time_avail[chip->id][3]); 1029 + (count * tsl2772_int_time_avail[chip->id][3]); 1031 1030 1032 1031 if (chan->type == IIO_INTENSITY) { 1033 1032 /* ALS filter values are 1, 2, 3, 5, 10, 15, ..., 60 */ ··· 1048 1047 if (ret < 0) 1049 1048 return ret; 1050 1049 1051 - return tsl2x7x_invoke_change(indio_dev); 1050 + return tsl2772_invoke_change(indio_dev); 1052 1051 } 1053 1052 1054 - static int tsl2x7x_read_event_value(struct iio_dev *indio_dev, 1053 + static int tsl2772_read_event_value(struct iio_dev *indio_dev, 1055 1054 const struct iio_chan_spec *chan, 1056 1055 enum iio_event_type type, 1057 1056 enum iio_event_direction dir, 1058 1057 enum iio_event_info info, 1059 1058 int *val, int *val2) 1060 1059 { 1061 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 1060 + struct tsl2772_chip *chip = iio_priv(indio_dev); 1062 1061 int filter_delay, persistence; 1063 1062 u8 time; 1064 1063 ··· 1102 1101 } 1103 1102 1104 1103 filter_delay = persistence * (256 - time) * 1105 - tsl2x7x_int_time_avail[chip->id][3]; 1104 + tsl2772_int_time_avail[chip->id][3]; 1106 1105 1107 1106 *val = filter_delay / 1000000; 1108 1107 *val2 = filter_delay % 1000000; ··· 1112 1111 } 1113 1112 } 1114 1113 1115 - static int tsl2x7x_read_raw(struct iio_dev *indio_dev, 1114 + static int tsl2772_read_raw(struct iio_dev *indio_dev, 1116 1115 struct iio_chan_spec const *chan, 1117 1116 int *val, 1118 1117 int *val2, 1119 1118 long mask) 1120 1119 { 1121 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 1120 + struct tsl2772_chip *chip = iio_priv(indio_dev); 1122 1121 1123 1122 switch (mask) { 1124 1123 case IIO_CHAN_INFO_PROCESSED: 1125 1124 switch (chan->type) { 1126 1125 case IIO_LIGHT: 1127 - tsl2x7x_get_lux(indio_dev); 1126 + tsl2772_get_lux(indio_dev); 1128 1127 *val = chip->als_cur_info.lux; 1129 1128 return IIO_VAL_INT; 1130 1129 default: ··· 1133 1132 case IIO_CHAN_INFO_RAW: 1134 1133 switch (chan->type) { 1135 1134 case IIO_INTENSITY: 1136 - tsl2x7x_get_lux(indio_dev); 1135 + tsl2772_get_lux(indio_dev); 1137 1136 if (chan->channel == 0) 1138 1137 *val = chip->als_cur_info.als_ch0; 1139 1138 else 1140 1139 *val = chip->als_cur_info.als_ch1; 1141 1140 return IIO_VAL_INT; 1142 1141 case IIO_PROXIMITY: 1143 - tsl2x7x_get_prox(indio_dev); 1142 + tsl2772_get_prox(indio_dev); 1144 1143 *val = chip->prox_data; 1145 1144 return IIO_VAL_INT; 1146 1145 default: ··· 1149 1148 break; 1150 1149 case IIO_CHAN_INFO_CALIBSCALE: 1151 1150 if (chan->type == IIO_LIGHT) 1152 - *val = tsl2x7x_als_gain[chip->settings.als_gain]; 1151 + *val = tsl2772_als_gain[chip->settings.als_gain]; 1153 1152 else 1154 - *val = tsl2x7x_prox_gain[chip->settings.prox_gain]; 1153 + *val = tsl2772_prox_gain[chip->settings.prox_gain]; 1155 1154 return IIO_VAL_INT; 1156 1155 case IIO_CHAN_INFO_CALIBBIAS: 1157 1156 *val = chip->settings.als_gain_trim; ··· 1159 1158 case IIO_CHAN_INFO_INT_TIME: 1160 1159 *val = 0; 1161 1160 *val2 = (256 - chip->settings.als_time) * 1162 - tsl2x7x_int_time_avail[chip->id][3]; 1161 + tsl2772_int_time_avail[chip->id][3]; 1163 1162 return IIO_VAL_INT_PLUS_MICRO; 1164 1163 default: 1165 1164 return -EINVAL; 1166 1165 } 1167 1166 } 1168 1167 1169 - static int tsl2x7x_write_raw(struct iio_dev *indio_dev, 1168 + static int tsl2772_write_raw(struct iio_dev *indio_dev, 1170 1169 struct iio_chan_spec const *chan, 1171 1170 int val, 1172 1171 int val2, 1173 1172 long mask) 1174 1173 { 1175 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 1174 + struct tsl2772_chip *chip = iio_priv(indio_dev); 1176 1175 1177 1176 switch (mask) { 1178 1177 case IIO_CHAN_INFO_CALIBSCALE: ··· 1213 1212 } 1214 1213 break; 1215 1214 case IIO_CHAN_INFO_CALIBBIAS: 1216 - if (val < TSL2X7X_ALS_GAIN_TRIM_MIN || 1217 - val > TSL2X7X_ALS_GAIN_TRIM_MAX) 1215 + if (val < TSL2772_ALS_GAIN_TRIM_MIN || 1216 + val > TSL2772_ALS_GAIN_TRIM_MAX) 1218 1217 return -EINVAL; 1219 1218 1220 1219 chip->settings.als_gain_trim = val; 1221 1220 break; 1222 1221 case IIO_CHAN_INFO_INT_TIME: 1223 - if (val != 0 || val2 < tsl2x7x_int_time_avail[chip->id][1] || 1224 - val2 > tsl2x7x_int_time_avail[chip->id][5]) 1222 + if (val != 0 || val2 < tsl2772_int_time_avail[chip->id][1] || 1223 + val2 > tsl2772_int_time_avail[chip->id][5]) 1225 1224 return -EINVAL; 1226 1225 1227 1226 chip->settings.als_time = 256 - 1228 - (val2 / tsl2x7x_int_time_avail[chip->id][3]); 1227 + (val2 / tsl2772_int_time_avail[chip->id][3]); 1229 1228 break; 1230 1229 default: 1231 1230 return -EINVAL; 1232 1231 } 1233 1232 1234 - return tsl2x7x_invoke_change(indio_dev); 1233 + return tsl2772_invoke_change(indio_dev); 1235 1234 } 1236 1235 1237 1236 static DEVICE_ATTR_RW(in_illuminance0_target_input); ··· 1243 1242 static DEVICE_ATTR_RW(in_illuminance0_lux_table); 1244 1243 1245 1244 /* Use the default register values to identify the Taos device */ 1246 - static int tsl2x7x_device_id_verif(int id, int target) 1245 + static int tsl2772_device_id_verif(int id, int target) 1247 1246 { 1248 1247 switch (target) { 1249 1248 case tsl2571: ··· 1264 1263 return -EINVAL; 1265 1264 } 1266 1265 1267 - static irqreturn_t tsl2x7x_event_handler(int irq, void *private) 1266 + static irqreturn_t tsl2772_event_handler(int irq, void *private) 1268 1267 { 1269 1268 struct iio_dev *indio_dev = private; 1270 - struct tsl2X7X_chip *chip = iio_priv(indio_dev); 1269 + struct tsl2772_chip *chip = iio_priv(indio_dev); 1271 1270 s64 timestamp = iio_get_time_ns(indio_dev); 1272 1271 int ret; 1273 1272 1274 - ret = tsl2x7x_read_status(chip); 1273 + ret = tsl2772_read_status(chip); 1275 1274 if (ret < 0) 1276 1275 return IRQ_HANDLED; 1277 1276 1278 1277 /* What type of interrupt do we need to process */ 1279 - if (ret & TSL2X7X_STA_PRX_INTR) { 1278 + if (ret & TSL2772_STA_PRX_INTR) { 1280 1279 iio_push_event(indio_dev, 1281 1280 IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 1282 1281 0, ··· 1285 1284 timestamp); 1286 1285 } 1287 1286 1288 - if (ret & TSL2X7X_STA_ALS_INTR) { 1287 + if (ret & TSL2772_STA_ALS_INTR) { 1289 1288 iio_push_event(indio_dev, 1290 1289 IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 1291 1290 0, ··· 1295 1294 } 1296 1295 1297 1296 ret = i2c_smbus_write_byte(chip->client, 1298 - TSL2X7X_CMD_REG | TSL2X7X_CMD_SPL_FN | 1299 - TSL2X7X_CMD_PROXALS_INT_CLR); 1297 + TSL2772_CMD_REG | TSL2772_CMD_SPL_FN | 1298 + TSL2772_CMD_PROXALS_INT_CLR); 1300 1299 if (ret < 0) 1301 1300 dev_err(&chip->client->dev, 1302 1301 "%s: failed to clear interrupt status: %d\n", ··· 1305 1304 return IRQ_HANDLED; 1306 1305 } 1307 1306 1308 - static struct attribute *tsl2x7x_ALS_device_attrs[] = { 1307 + static struct attribute *tsl2772_ALS_device_attrs[] = { 1309 1308 &dev_attr_in_illuminance0_target_input.attr, 1310 1309 &dev_attr_in_illuminance0_calibrate.attr, 1311 1310 &dev_attr_in_illuminance0_lux_table.attr, 1312 1311 NULL 1313 1312 }; 1314 1313 1315 - static struct attribute *tsl2x7x_PRX_device_attrs[] = { 1314 + static struct attribute *tsl2772_PRX_device_attrs[] = { 1316 1315 &dev_attr_in_proximity0_calibrate.attr, 1317 1316 NULL 1318 1317 }; 1319 1318 1320 - static struct attribute *tsl2x7x_ALSPRX_device_attrs[] = { 1319 + static struct attribute *tsl2772_ALSPRX_device_attrs[] = { 1321 1320 &dev_attr_in_illuminance0_target_input.attr, 1322 1321 &dev_attr_in_illuminance0_calibrate.attr, 1323 1322 &dev_attr_in_illuminance0_lux_table.attr, 1324 1323 NULL 1325 1324 }; 1326 1325 1327 - static struct attribute *tsl2x7x_PRX2_device_attrs[] = { 1326 + static struct attribute *tsl2772_PRX2_device_attrs[] = { 1328 1327 &dev_attr_in_proximity0_calibrate.attr, 1329 1328 NULL 1330 1329 }; 1331 1330 1332 - static struct attribute *tsl2x7x_ALSPRX2_device_attrs[] = { 1331 + static struct attribute *tsl2772_ALSPRX2_device_attrs[] = { 1333 1332 &dev_attr_in_illuminance0_target_input.attr, 1334 1333 &dev_attr_in_illuminance0_calibrate.attr, 1335 1334 &dev_attr_in_illuminance0_lux_table.attr, ··· 1337 1336 NULL 1338 1337 }; 1339 1338 1340 - static const struct attribute_group tsl2X7X_device_attr_group_tbl[] = { 1339 + static const struct attribute_group tsl2772_device_attr_group_tbl[] = { 1341 1340 [ALS] = { 1342 - .attrs = tsl2x7x_ALS_device_attrs, 1341 + .attrs = tsl2772_ALS_device_attrs, 1343 1342 }, 1344 1343 [PRX] = { 1345 - .attrs = tsl2x7x_PRX_device_attrs, 1344 + .attrs = tsl2772_PRX_device_attrs, 1346 1345 }, 1347 1346 [ALSPRX] = { 1348 - .attrs = tsl2x7x_ALSPRX_device_attrs, 1347 + .attrs = tsl2772_ALSPRX_device_attrs, 1349 1348 }, 1350 1349 [PRX2] = { 1351 - .attrs = tsl2x7x_PRX2_device_attrs, 1350 + .attrs = tsl2772_PRX2_device_attrs, 1352 1351 }, 1353 1352 [ALSPRX2] = { 1354 - .attrs = tsl2x7x_ALSPRX2_device_attrs, 1353 + .attrs = tsl2772_ALSPRX2_device_attrs, 1355 1354 }, 1356 1355 }; 1357 1356 1358 - #define TSL2X7X_DEVICE_INFO(type)[type] = \ 1357 + #define TSL2772_DEVICE_INFO(type)[type] = \ 1359 1358 { \ 1360 - .attrs = &tsl2X7X_device_attr_group_tbl[type], \ 1361 - .read_raw = &tsl2x7x_read_raw, \ 1362 - .read_avail = &tsl2x7x_read_avail, \ 1363 - .write_raw = &tsl2x7x_write_raw, \ 1364 - .read_event_value = &tsl2x7x_read_event_value, \ 1365 - .write_event_value = &tsl2x7x_write_event_value, \ 1366 - .read_event_config = &tsl2x7x_read_interrupt_config, \ 1367 - .write_event_config = &tsl2x7x_write_interrupt_config, \ 1359 + .attrs = &tsl2772_device_attr_group_tbl[type], \ 1360 + .read_raw = &tsl2772_read_raw, \ 1361 + .read_avail = &tsl2772_read_avail, \ 1362 + .write_raw = &tsl2772_write_raw, \ 1363 + .read_event_value = &tsl2772_read_event_value, \ 1364 + .write_event_value = &tsl2772_write_event_value, \ 1365 + .read_event_config = &tsl2772_read_interrupt_config, \ 1366 + .write_event_config = &tsl2772_write_interrupt_config, \ 1368 1367 } 1369 1368 1370 - static const struct iio_info tsl2X7X_device_info[] = { 1371 - TSL2X7X_DEVICE_INFO(ALS), 1372 - TSL2X7X_DEVICE_INFO(PRX), 1373 - TSL2X7X_DEVICE_INFO(ALSPRX), 1374 - TSL2X7X_DEVICE_INFO(PRX2), 1375 - TSL2X7X_DEVICE_INFO(ALSPRX2), 1369 + static const struct iio_info tsl2772_device_info[] = { 1370 + TSL2772_DEVICE_INFO(ALS), 1371 + TSL2772_DEVICE_INFO(PRX), 1372 + TSL2772_DEVICE_INFO(ALSPRX), 1373 + TSL2772_DEVICE_INFO(PRX2), 1374 + TSL2772_DEVICE_INFO(ALSPRX2), 1376 1375 }; 1377 1376 1378 - static const struct iio_event_spec tsl2x7x_events[] = { 1377 + static const struct iio_event_spec tsl2772_events[] = { 1379 1378 { 1380 1379 .type = IIO_EV_TYPE_THRESH, 1381 1380 .dir = IIO_EV_DIR_RISING, ··· 1392 1391 }, 1393 1392 }; 1394 1393 1395 - static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { 1394 + static const struct tsl2772_chip_info tsl2772_chip_info_tbl[] = { 1396 1395 [ALS] = { 1397 1396 .channel_with_events = { 1398 1397 { ··· 1411 1410 .info_mask_separate_available = 1412 1411 BIT(IIO_CHAN_INFO_INT_TIME) | 1413 1412 BIT(IIO_CHAN_INFO_CALIBSCALE), 1414 - .event_spec = tsl2x7x_events, 1415 - .num_event_specs = ARRAY_SIZE(tsl2x7x_events), 1413 + .event_spec = tsl2772_events, 1414 + .num_event_specs = ARRAY_SIZE(tsl2772_events), 1416 1415 }, { 1417 1416 .type = IIO_INTENSITY, 1418 1417 .indexed = 1, ··· 1443 1442 }, 1444 1443 }, 1445 1444 .chan_table_elements = 3, 1446 - .info = &tsl2X7X_device_info[ALS], 1445 + .info = &tsl2772_device_info[ALS], 1447 1446 }, 1448 1447 [PRX] = { 1449 1448 .channel_with_events = { ··· 1452 1451 .indexed = 1, 1453 1452 .channel = 0, 1454 1453 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 1455 - .event_spec = tsl2x7x_events, 1456 - .num_event_specs = ARRAY_SIZE(tsl2x7x_events), 1454 + .event_spec = tsl2772_events, 1455 + .num_event_specs = ARRAY_SIZE(tsl2772_events), 1457 1456 }, 1458 1457 }, 1459 1458 .channel_without_events = { ··· 1465 1464 }, 1466 1465 }, 1467 1466 .chan_table_elements = 1, 1468 - .info = &tsl2X7X_device_info[PRX], 1467 + .info = &tsl2772_device_info[PRX], 1469 1468 }, 1470 1469 [ALSPRX] = { 1471 1470 .channel_with_events = { ··· 1485 1484 .info_mask_separate_available = 1486 1485 BIT(IIO_CHAN_INFO_INT_TIME) | 1487 1486 BIT(IIO_CHAN_INFO_CALIBSCALE), 1488 - .event_spec = tsl2x7x_events, 1489 - .num_event_specs = ARRAY_SIZE(tsl2x7x_events), 1487 + .event_spec = tsl2772_events, 1488 + .num_event_specs = ARRAY_SIZE(tsl2772_events), 1490 1489 }, { 1491 1490 .type = IIO_INTENSITY, 1492 1491 .indexed = 1, ··· 1497 1496 .indexed = 1, 1498 1497 .channel = 0, 1499 1498 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 1500 - .event_spec = tsl2x7x_events, 1501 - .num_event_specs = ARRAY_SIZE(tsl2x7x_events), 1499 + .event_spec = tsl2772_events, 1500 + .num_event_specs = ARRAY_SIZE(tsl2772_events), 1502 1501 }, 1503 1502 }, 1504 1503 .channel_without_events = { ··· 1531 1530 }, 1532 1531 }, 1533 1532 .chan_table_elements = 4, 1534 - .info = &tsl2X7X_device_info[ALSPRX], 1533 + .info = &tsl2772_device_info[ALSPRX], 1535 1534 }, 1536 1535 [PRX2] = { 1537 1536 .channel_with_events = { ··· 1543 1542 BIT(IIO_CHAN_INFO_CALIBSCALE), 1544 1543 .info_mask_separate_available = 1545 1544 BIT(IIO_CHAN_INFO_CALIBSCALE), 1546 - .event_spec = tsl2x7x_events, 1547 - .num_event_specs = ARRAY_SIZE(tsl2x7x_events), 1545 + .event_spec = tsl2772_events, 1546 + .num_event_specs = ARRAY_SIZE(tsl2772_events), 1548 1547 }, 1549 1548 }, 1550 1549 .channel_without_events = { ··· 1559 1558 }, 1560 1559 }, 1561 1560 .chan_table_elements = 1, 1562 - .info = &tsl2X7X_device_info[PRX2], 1561 + .info = &tsl2772_device_info[PRX2], 1563 1562 }, 1564 1563 [ALSPRX2] = { 1565 1564 .channel_with_events = { ··· 1579 1578 .info_mask_separate_available = 1580 1579 BIT(IIO_CHAN_INFO_INT_TIME) | 1581 1580 BIT(IIO_CHAN_INFO_CALIBSCALE), 1582 - .event_spec = tsl2x7x_events, 1583 - .num_event_specs = ARRAY_SIZE(tsl2x7x_events), 1581 + .event_spec = tsl2772_events, 1582 + .num_event_specs = ARRAY_SIZE(tsl2772_events), 1584 1583 }, { 1585 1584 .type = IIO_INTENSITY, 1586 1585 .indexed = 1, ··· 1594 1593 BIT(IIO_CHAN_INFO_CALIBSCALE), 1595 1594 .info_mask_separate_available = 1596 1595 BIT(IIO_CHAN_INFO_CALIBSCALE), 1597 - .event_spec = tsl2x7x_events, 1598 - .num_event_specs = ARRAY_SIZE(tsl2x7x_events), 1596 + .event_spec = tsl2772_events, 1597 + .num_event_specs = ARRAY_SIZE(tsl2772_events), 1599 1598 }, 1600 1599 }, 1601 1600 .channel_without_events = { ··· 1631 1630 }, 1632 1631 }, 1633 1632 .chan_table_elements = 4, 1634 - .info = &tsl2X7X_device_info[ALSPRX2], 1633 + .info = &tsl2772_device_info[ALSPRX2], 1635 1634 }, 1636 1635 }; 1637 1636 1638 - static int tsl2x7x_probe(struct i2c_client *clientp, 1637 + static int tsl2772_probe(struct i2c_client *clientp, 1639 1638 const struct i2c_device_id *id) 1640 1639 { 1641 1640 struct iio_dev *indio_dev; 1642 - struct tsl2X7X_chip *chip; 1641 + struct tsl2772_chip *chip; 1643 1642 int ret; 1644 1643 1645 1644 indio_dev = devm_iio_device_alloc(&clientp->dev, sizeof(*chip)); ··· 1651 1650 i2c_set_clientdata(clientp, indio_dev); 1652 1651 1653 1652 ret = i2c_smbus_read_byte_data(chip->client, 1654 - TSL2X7X_CMD_REG | TSL2X7X_CHIPID); 1653 + TSL2772_CMD_REG | TSL2772_CHIPID); 1655 1654 if (ret < 0) 1656 1655 return ret; 1657 1656 1658 - if (tsl2x7x_device_id_verif(ret, id->driver_data) <= 0) { 1657 + if (tsl2772_device_id_verif(ret, id->driver_data) <= 0) { 1659 1658 dev_info(&chip->client->dev, 1660 1659 "%s: i2c device found does not match expected id\n", 1661 1660 __func__); 1662 1661 return -EINVAL; 1663 1662 } 1664 1663 1665 - ret = i2c_smbus_write_byte(clientp, TSL2X7X_CMD_REG | TSL2X7X_CNTRL); 1664 + ret = i2c_smbus_write_byte(clientp, TSL2772_CMD_REG | TSL2772_CNTRL); 1666 1665 if (ret < 0) { 1667 1666 dev_err(&clientp->dev, 1668 1667 "%s: Failed to write to CMD register: %d\n", ··· 1673 1672 mutex_init(&chip->als_mutex); 1674 1673 mutex_init(&chip->prox_mutex); 1675 1674 1676 - chip->tsl2x7x_chip_status = TSL2X7X_CHIP_UNKNOWN; 1675 + chip->tsl2772_chip_status = TSL2772_CHIP_UNKNOWN; 1677 1676 chip->pdata = dev_get_platdata(&clientp->dev); 1678 1677 chip->id = id->driver_data; 1679 1678 chip->chip_info = 1680 - &tsl2x7x_chip_info_tbl[device_channel_config[id->driver_data]]; 1679 + &tsl2772_chip_info_tbl[device_channel_config[id->driver_data]]; 1681 1680 1682 1681 indio_dev->info = chip->chip_info->info; 1683 1682 indio_dev->dev.parent = &clientp->dev; ··· 1690 1689 1691 1690 ret = devm_request_threaded_irq(&clientp->dev, clientp->irq, 1692 1691 NULL, 1693 - &tsl2x7x_event_handler, 1692 + &tsl2772_event_handler, 1694 1693 IRQF_TRIGGER_FALLING | 1695 1694 IRQF_ONESHOT, 1696 - "TSL2X7X_event", 1695 + "TSL2772_event", 1697 1696 indio_dev); 1698 1697 if (ret) { 1699 1698 dev_err(&clientp->dev, ··· 1704 1703 indio_dev->channels = chip->chip_info->channel_without_events; 1705 1704 } 1706 1705 1707 - tsl2x7x_defaults(chip); 1708 - ret = tsl2x7x_chip_on(indio_dev); 1706 + tsl2772_defaults(chip); 1707 + ret = tsl2772_chip_on(indio_dev); 1709 1708 if (ret < 0) 1710 1709 return ret; 1711 1710 1712 1711 ret = iio_device_register(indio_dev); 1713 1712 if (ret) { 1714 - tsl2x7x_chip_off(indio_dev); 1713 + tsl2772_chip_off(indio_dev); 1715 1714 dev_err(&clientp->dev, 1716 1715 "%s: iio registration failed\n", __func__); 1717 1716 return ret; ··· 1720 1719 return 0; 1721 1720 } 1722 1721 1723 - static int tsl2x7x_suspend(struct device *dev) 1722 + static int tsl2772_suspend(struct device *dev) 1724 1723 { 1725 1724 struct iio_dev *indio_dev = dev_get_drvdata(dev); 1726 1725 1727 - return tsl2x7x_chip_off(indio_dev); 1726 + return tsl2772_chip_off(indio_dev); 1728 1727 } 1729 1728 1730 - static int tsl2x7x_resume(struct device *dev) 1729 + static int tsl2772_resume(struct device *dev) 1731 1730 { 1732 1731 struct iio_dev *indio_dev = dev_get_drvdata(dev); 1733 1732 1734 - return tsl2x7x_chip_on(indio_dev); 1733 + return tsl2772_chip_on(indio_dev); 1735 1734 } 1736 1735 1737 - static int tsl2x7x_remove(struct i2c_client *client) 1736 + static int tsl2772_remove(struct i2c_client *client) 1738 1737 { 1739 1738 struct iio_dev *indio_dev = i2c_get_clientdata(client); 1740 1739 1741 - tsl2x7x_chip_off(indio_dev); 1740 + tsl2772_chip_off(indio_dev); 1742 1741 1743 1742 iio_device_unregister(indio_dev); 1744 1743 1745 1744 return 0; 1746 1745 } 1747 1746 1748 - static const struct i2c_device_id tsl2x7x_idtable[] = { 1747 + static const struct i2c_device_id tsl2772_idtable[] = { 1749 1748 { "tsl2571", tsl2571 }, 1750 1749 { "tsl2671", tsl2671 }, 1751 1750 { "tmd2671", tmd2671 }, ··· 1759 1758 {} 1760 1759 }; 1761 1760 1762 - MODULE_DEVICE_TABLE(i2c, tsl2x7x_idtable); 1761 + MODULE_DEVICE_TABLE(i2c, tsl2772_idtable); 1763 1762 1764 - static const struct of_device_id tsl2x7x_of_match[] = { 1763 + static const struct of_device_id tsl2772_of_match[] = { 1765 1764 { .compatible = "amstaos,tsl2571" }, 1766 1765 { .compatible = "amstaos,tsl2671" }, 1767 1766 { .compatible = "amstaos,tmd2671" }, ··· 1774 1773 { .compatible = "amstaos,tmd2772" }, 1775 1774 {} 1776 1775 }; 1777 - MODULE_DEVICE_TABLE(of, tsl2x7x_of_match); 1776 + MODULE_DEVICE_TABLE(of, tsl2772_of_match); 1778 1777 1779 - static const struct dev_pm_ops tsl2x7x_pm_ops = { 1780 - .suspend = tsl2x7x_suspend, 1781 - .resume = tsl2x7x_resume, 1778 + static const struct dev_pm_ops tsl2772_pm_ops = { 1779 + .suspend = tsl2772_suspend, 1780 + .resume = tsl2772_resume, 1782 1781 }; 1783 1782 1784 - static struct i2c_driver tsl2x7x_driver = { 1783 + static struct i2c_driver tsl2772_driver = { 1785 1784 .driver = { 1786 - .name = "tsl2x7x", 1787 - .of_match_table = tsl2x7x_of_match, 1788 - .pm = &tsl2x7x_pm_ops, 1785 + .name = "tsl2772", 1786 + .of_match_table = tsl2772_of_match, 1787 + .pm = &tsl2772_pm_ops, 1789 1788 }, 1790 - .id_table = tsl2x7x_idtable, 1791 - .probe = tsl2x7x_probe, 1792 - .remove = tsl2x7x_remove, 1789 + .id_table = tsl2772_idtable, 1790 + .probe = tsl2772_probe, 1791 + .remove = tsl2772_remove, 1793 1792 }; 1794 1793 1795 - module_i2c_driver(tsl2x7x_driver); 1794 + module_i2c_driver(tsl2772_driver); 1796 1795 1797 1796 MODULE_AUTHOR("J. August Brenner <Jon.Brenner@ams.com>"); 1798 1797 MODULE_AUTHOR("Brian Masney <masneyb@onstation.org>"); 1799 - MODULE_DESCRIPTION("TAOS tsl2x7x ambient and proximity light sensor driver"); 1798 + MODULE_DESCRIPTION("TAOS tsl2772 ambient and proximity light sensor driver"); 1800 1799 MODULE_LICENSE("GPL");
+25 -24
drivers/staging/iio/light/tsl2x7x.h drivers/staging/iio/light/tsl2772.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * Device driver for monitoring ambient light intensity (lux) 4 - * and proximity (prox) within the TAOS TSL2X7X family of devices. 4 + * and proximity (prox) within the TAOS TSL2772 family of devices. 5 5 * 6 6 * Copyright (c) 2012, TAOS Corporation. 7 + * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org> 7 8 */ 8 9 9 - #ifndef __TSL2X7X_H 10 - #define __TSL2X7X_H 10 + #ifndef __TSL2772_H 11 + #define __TSL2772_H 11 12 12 - struct tsl2x7x_lux { 13 + struct tsl2772_lux { 13 14 unsigned int ch0; 14 15 unsigned int ch1; 15 16 }; 16 17 17 18 /* Max number of segments allowable in LUX table */ 18 - #define TSL2X7X_MAX_LUX_TABLE_SIZE 6 19 + #define TSL2772_MAX_LUX_TABLE_SIZE 6 19 20 /* The default LUX tables all have 3 elements. */ 20 - #define TSL2X7X_DEF_LUX_TABLE_SZ 3 21 - #define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \ 22 - TSL2X7X_DEF_LUX_TABLE_SZ) 21 + #define TSL2772_DEF_LUX_TABLE_SZ 3 22 + #define TSL2772_DEFAULT_TABLE_BYTES (sizeof(struct tsl2772_lux) * \ 23 + TSL2772_DEF_LUX_TABLE_SZ) 23 24 24 25 /* Proximity diode to use */ 25 - #define TSL2X7X_DIODE0 0x01 26 - #define TSL2X7X_DIODE1 0x02 27 - #define TSL2X7X_DIODE_BOTH 0x03 26 + #define TSL2772_DIODE0 0x01 27 + #define TSL2772_DIODE1 0x02 28 + #define TSL2772_DIODE_BOTH 0x03 28 29 29 30 /* LED Power */ 30 - #define TSL2X7X_100_mA 0x00 31 - #define TSL2X7X_50_mA 0x01 32 - #define TSL2X7X_25_mA 0x02 33 - #define TSL2X7X_13_mA 0x03 31 + #define TSL2772_100_mA 0x00 32 + #define TSL2772_50_mA 0x01 33 + #define TSL2772_25_mA 0x02 34 + #define TSL2772_13_mA 0x03 34 35 35 36 /** 36 - * struct tsl2x7x_settings - Settings for the tsl2x7x driver 37 + * struct tsl2772_settings - Settings for the tsl2772 driver 37 38 * @als_time: Integration time of the ALS channel ADCs in 2.73 ms 38 39 * increments. Total integration time is 39 40 * (256 - als_time) * 2.73. 40 - * @als_gain: Index into the tsl2x7x_als_gain array. 41 + * @als_gain: Index into the tsl2772_als_gain array. 41 42 * @als_gain_trim: Default gain trim to account for aperture effects. 42 43 * @wait_time: Time between proximity and ALS cycles in 2.73 43 44 * periods. 44 45 * @prox_time: Integration time of the proximity ADC in 2.73 ms 45 46 * increments. Total integration time is 46 47 * (256 - prx_time) * 2.73. 47 - * @prox_gain: Index into the tsl2x7x_prx_gain array. 48 + * @prox_gain: Index into the tsl2772_prx_gain array. 48 49 * @als_prox_config: The value of the ALS / Proximity configuration 49 50 * register. 50 51 * @als_cal_target: Known external ALS reading for calibration. ··· 65 64 * LED(s) for proximity sensing. 66 65 * @prox_power The amount of power to use for the external LED(s). 67 66 */ 68 - struct tsl2x7x_settings { 67 + struct tsl2772_settings { 69 68 int als_time; 70 69 int als_gain; 71 70 int als_gain_trim; ··· 89 88 }; 90 89 91 90 /** 92 - * struct tsl2X7X_platform_data - Platform callback, glass and defaults 91 + * struct tsl2772_platform_data - Platform callback, glass and defaults 93 92 * @platform_lux_table: Device specific glass coefficents 94 93 * @platform_default_settings: Device specific power on defaults 95 94 */ 96 - struct tsl2X7X_platform_data { 97 - struct tsl2x7x_lux platform_lux_table[TSL2X7X_MAX_LUX_TABLE_SIZE]; 98 - struct tsl2x7x_settings *platform_default_settings; 95 + struct tsl2772_platform_data { 96 + struct tsl2772_lux platform_lux_table[TSL2772_MAX_LUX_TABLE_SIZE]; 97 + struct tsl2772_settings *platform_default_settings; 99 98 }; 100 99 101 - #endif /* __TSL2X7X_H */ 100 + #endif /* __TSL2772_H */