Lines Matching refs:cm32181

91 static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val2);
140 static void cm32181_acpi_parse_cpm_tables(struct cm32181_chip *cm32181) in cm32181_acpi_parse_cpm_tables() argument
143 struct device *dev = cm32181->dev; in cm32181_acpi_parse_cpm_tables()
152 cm32181->init_regs_bitmap = vals[CPM0_REGS_BITMAP]; in cm32181_acpi_parse_cpm_tables()
153 cm32181->init_regs_bitmap &= GENMASK(count - 1, 0); in cm32181_acpi_parse_cpm_tables()
154 for_each_set_bit(i, &cm32181->init_regs_bitmap, count) in cm32181_acpi_parse_cpm_tables()
155 cm32181->conf_regs[i] = vals[CPM0_HEADER_SIZE + i]; in cm32181_acpi_parse_cpm_tables()
161 cm32181->lux_per_bit = vals[CPM1_LUX_PER_BIT]; in cm32181_acpi_parse_cpm_tables()
167 cm32181->calibscale = vals[CPM1_CALIBSCALE]; in cm32181_acpi_parse_cpm_tables()
169 cm32181_read_als_it(cm32181, &cm32181->lux_per_bit_base_it); in cm32181_acpi_parse_cpm_tables()
172 static void cm32181_acpi_parse_cpm_tables(struct cm32181_chip *cm32181) in cm32181_acpi_parse_cpm_tables() argument
185 static int cm32181_reg_init(struct cm32181_chip *cm32181) in cm32181_reg_init() argument
187 struct i2c_client *client = cm32181->client; in cm32181_reg_init()
198 cm32181->num_als_it = ARRAY_SIZE(cm3218_als_it_bits); in cm32181_reg_init()
199 cm32181->als_it_bits = cm3218_als_it_bits; in cm32181_reg_init()
200 cm32181->als_it_values = cm3218_als_it_values; in cm32181_reg_init()
204 cm32181->num_als_it = ARRAY_SIZE(cm32181_als_it_bits); in cm32181_reg_init()
205 cm32181->als_it_bits = cm32181_als_it_bits; in cm32181_reg_init()
206 cm32181->als_it_values = cm32181_als_it_values; in cm32181_reg_init()
213 cm32181->conf_regs[CM32181_REG_ADDR_CMD] = in cm32181_reg_init()
215 cm32181->init_regs_bitmap = BIT(CM32181_REG_ADDR_CMD); in cm32181_reg_init()
216 cm32181->calibscale = CM32181_CALIBSCALE_DEFAULT; in cm32181_reg_init()
217 cm32181->lux_per_bit = CM32181_LUX_PER_BIT; in cm32181_reg_init()
218 cm32181->lux_per_bit_base_it = CM32181_LUX_PER_BIT_BASE_IT; in cm32181_reg_init()
220 if (ACPI_HANDLE(cm32181->dev)) in cm32181_reg_init()
221 cm32181_acpi_parse_cpm_tables(cm32181); in cm32181_reg_init()
224 for_each_set_bit(i, &cm32181->init_regs_bitmap, CM32181_CONF_REG_NUM) { in cm32181_reg_init()
226 cm32181->conf_regs[i]); in cm32181_reg_init()
243 static int cm32181_read_als_it(struct cm32181_chip *cm32181, int *val2) in cm32181_read_als_it() argument
248 als_it = cm32181->conf_regs[CM32181_REG_ADDR_CMD]; in cm32181_read_als_it()
251 for (i = 0; i < cm32181->num_als_it; i++) { in cm32181_read_als_it()
252 if (als_it == cm32181->als_it_bits[i]) { in cm32181_read_als_it()
253 *val2 = cm32181->als_it_values[i]; in cm32181_read_als_it()
270 static int cm32181_write_als_it(struct cm32181_chip *cm32181, int val) in cm32181_write_als_it() argument
272 struct i2c_client *client = cm32181->client; in cm32181_write_als_it()
276 n = cm32181->num_als_it; in cm32181_write_als_it()
278 if (val <= cm32181->als_it_values[i]) in cm32181_write_als_it()
283 als_it = cm32181->als_it_bits[i]; in cm32181_write_als_it()
286 mutex_lock(&cm32181->lock); in cm32181_write_als_it()
287 cm32181->conf_regs[CM32181_REG_ADDR_CMD] &= in cm32181_write_als_it()
289 cm32181->conf_regs[CM32181_REG_ADDR_CMD] |= in cm32181_write_als_it()
292 cm32181->conf_regs[CM32181_REG_ADDR_CMD]); in cm32181_write_als_it()
293 mutex_unlock(&cm32181->lock); in cm32181_write_als_it()
307 static int cm32181_get_lux(struct cm32181_chip *cm32181) in cm32181_get_lux() argument
309 struct i2c_client *client = cm32181->client; in cm32181_get_lux()
314 ret = cm32181_read_als_it(cm32181, &als_it); in cm32181_get_lux()
318 lux = cm32181->lux_per_bit; in cm32181_get_lux()
319 lux *= cm32181->lux_per_bit_base_it; in cm32181_get_lux()
327 lux *= cm32181->calibscale; in cm32181_get_lux()
341 struct cm32181_chip *cm32181 = iio_priv(indio_dev); in cm32181_read_raw() local
346 ret = cm32181_get_lux(cm32181); in cm32181_read_raw()
352 *val = cm32181->calibscale; in cm32181_read_raw()
356 ret = cm32181_read_als_it(cm32181, val2); in cm32181_read_raw()
367 struct cm32181_chip *cm32181 = iio_priv(indio_dev); in cm32181_write_raw() local
372 cm32181->calibscale = val; in cm32181_write_raw()
375 ret = cm32181_write_als_it(cm32181, val2); in cm32181_write_raw()
395 struct cm32181_chip *cm32181 = iio_priv(dev_to_iio_dev(dev)); in cm32181_get_it_available() local
398 n = cm32181->num_als_it; in cm32181_get_it_available()
400 len += sprintf(buf + len, "0.%06u ", cm32181->als_it_values[i]); in cm32181_get_it_available()
443 struct cm32181_chip *cm32181; in cm32181_probe() local
447 indio_dev = devm_iio_device_alloc(dev, sizeof(*cm32181)); in cm32181_probe()
477 cm32181 = iio_priv(indio_dev); in cm32181_probe()
478 cm32181->client = client; in cm32181_probe()
479 cm32181->dev = dev; in cm32181_probe()
481 mutex_init(&cm32181->lock); in cm32181_probe()
488 ret = cm32181_reg_init(cm32181); in cm32181_probe()
505 struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev)); in cm32181_suspend() local
506 struct i2c_client *client = cm32181->client; in cm32181_suspend()
514 struct cm32181_chip *cm32181 = iio_priv(dev_get_drvdata(dev)); in cm32181_resume() local
515 struct i2c_client *client = cm32181->client; in cm32181_resume()
518 cm32181->conf_regs[CM32181_REG_ADDR_CMD]); in cm32181_resume()