Lines Matching +full:disable +full:- +full:report +full:- +full:mask

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2014-2015 Capella Microsystems Inc.
8 * IIO driver for CM3232 (7-bit I2C slave address 0x10).
78 * cm3232_reg_init() - Initialize CM3232
87 struct i2c_client *client = chip->client; in cm3232_reg_init()
90 chip->als_info = &cm3232_als_info_default; in cm3232_reg_init()
95 dev_err(&chip->client->dev, "Error reading addr_id\n"); in cm3232_reg_init()
99 if ((ret & 0xFF) != chip->als_info->hw_id) in cm3232_reg_init()
100 return -ENODEV; in cm3232_reg_init()
102 /* Disable and reset device */ in cm3232_reg_init()
103 chip->regs_cmd = CM3232_CMD_ALS_DISABLE | CM3232_CMD_ALS_RESET; in cm3232_reg_init()
105 chip->regs_cmd); in cm3232_reg_init()
107 dev_err(&chip->client->dev, "Error writing reg_cmd\n"); in cm3232_reg_init()
112 chip->regs_cmd = chip->als_info->regs_cmd_default; in cm3232_reg_init()
116 chip->regs_cmd); in cm3232_reg_init()
118 dev_err(&chip->client->dev, "Error writing reg_cmd\n"); in cm3232_reg_init()
124 * cm3232_read_als_it() - Get sensor integration time
129 * Report the current integration time.
131 * Return: IIO_VAL_INT_PLUS_MICRO for success, otherwise -EINVAL.
138 als_it = chip->regs_cmd; in cm3232_read_als_it()
149 return -EINVAL; in cm3232_read_als_it()
153 * cm3232_write_als_it() - Write sensor integration time
164 struct i2c_client *client = chip->client; in cm3232_write_als_it()
176 cmd = chip->regs_cmd & ~CM3232_CMD_ALS_IT_MASK; in cm3232_write_als_it()
183 chip->regs_cmd = cmd; in cm3232_write_als_it()
187 return -EINVAL; in cm3232_write_als_it()
191 * cm3232_get_lux() - report current lux value
201 struct i2c_client *client = chip->client; in cm3232_get_lux()
202 struct cm3232_als_info *als_info = chip->als_info; in cm3232_get_lux()
211 return -EINVAL; in cm3232_get_lux()
213 lux = (__force u64)als_info->mlux_per_bit; in cm3232_get_lux()
214 lux *= als_info->mlux_per_bit_base_it; in cm3232_get_lux()
219 dev_err(&client->dev, "Error reading reg_addr_als\n"); in cm3232_get_lux()
223 chip->regs_als = (u16)ret; in cm3232_get_lux()
224 lux *= chip->regs_als; in cm3232_get_lux()
225 lux *= als_info->calibscale; in cm3232_get_lux()
237 int *val, int *val2, long mask) in cm3232_read_raw() argument
240 struct cm3232_als_info *als_info = chip->als_info; in cm3232_read_raw()
243 switch (mask) { in cm3232_read_raw()
251 *val = als_info->calibscale; in cm3232_read_raw()
257 return -EINVAL; in cm3232_read_raw()
262 int val, int val2, long mask) in cm3232_write_raw() argument
265 struct cm3232_als_info *als_info = chip->als_info; in cm3232_write_raw()
267 switch (mask) { in cm3232_write_raw()
269 als_info->calibscale = val; in cm3232_write_raw()
275 return -EINVAL; in cm3232_write_raw()
279 * cm3232_get_it_available() - Get available ALS IT value
294 len += scnprintf(buf + len, PAGE_SIZE - len, "%u.%06u ", in cm3232_get_it_available()
297 return len + scnprintf(buf + len, PAGE_SIZE - len, "\n"); in cm3232_get_it_available()
335 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); in cm3232_probe()
337 return -ENOMEM; in cm3232_probe()
341 chip->client = client; in cm3232_probe()
343 indio_dev->channels = cm3232_channels; in cm3232_probe()
344 indio_dev->num_channels = ARRAY_SIZE(cm3232_channels); in cm3232_probe()
345 indio_dev->info = &cm3232_info; in cm3232_probe()
346 indio_dev->name = id->name; in cm3232_probe()
347 indio_dev->modes = INDIO_DIRECT_MODE; in cm3232_probe()
351 dev_err(&client->dev, in cm3232_probe()
379 struct i2c_client *client = chip->client; in cm3232_suspend()
382 chip->regs_cmd |= CM3232_CMD_ALS_DISABLE; in cm3232_suspend()
384 chip->regs_cmd); in cm3232_suspend()
393 struct i2c_client *client = chip->client; in cm3232_resume()
396 chip->regs_cmd &= ~CM3232_CMD_ALS_DISABLE; in cm3232_resume()
398 chip->regs_cmd | CM3232_CMD_ALS_RESET); in cm3232_resume()