Lines Matching +full:sens +full:-

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright 2010-2011 Analog Devices Inc.
63 * struct ad7150_chip_info - instance specific chip data
71 * 3:0 are for timeout receding - applies if below lower threshold
72 * 7:4 are for timeout approaching - applies if above upper threshold
108 int channel = chan->channel; in ad7150_read_raw()
113 ret = i2c_smbus_read_word_swapped(chip->client, in ad7150_read_raw()
121 ret = i2c_smbus_read_word_swapped(chip->client, in ad7150_read_raw()
138 *val = -(12288 >> 4); /* To match shift in _RAW */ in ad7150_read_raw()
145 return -EINVAL; in ad7150_read_raw()
159 ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG_REG); in ad7150_read_event_config()
180 return -EINVAL; in ad7150_read_event_config()
193 if ((type != chip->type) || (dir != chip->dir)) in ad7150_write_event_params()
199 u16 value = chip->threshold[rising][chan]; in ad7150_write_event_params()
200 return i2c_smbus_write_word_swapped(chip->client, in ad7150_write_event_params()
206 u8 sens, timeout; in ad7150_write_event_params() local
208 sens = chip->thresh_sensitivity[rising][chan]; in ad7150_write_event_params()
209 ret = i2c_smbus_write_byte_data(chip->client, in ad7150_write_event_params()
211 sens); in ad7150_write_event_params()
220 chip->thresh_timeout[1][chan]); in ad7150_write_event_params()
222 chip->thresh_timeout[0][chan]); in ad7150_write_event_params()
223 return i2c_smbus_write_byte_data(chip->client, in ad7150_write_event_params()
228 return -EINVAL; in ad7150_write_event_params()
249 if ((chip->int_enabled[chan->channel]) && in ad7150_write_event_config()
250 (type == chip->type) && (dir == chip->dir)) { in ad7150_write_event_config()
251 disable_irq(chip->interrupts[chan->channel]); in ad7150_write_event_config()
252 chip->int_enabled[chan->channel] = false; in ad7150_write_event_config()
257 mutex_lock(&chip->state_lock); in ad7150_write_event_config()
258 if ((type != chip->type) || (dir != chip->dir)) { in ad7150_write_event_config()
264 * enabled - this is to avoid races around changing in ad7150_write_event_config()
269 disable_irq(chip->interrupts[0]); in ad7150_write_event_config()
270 disable_irq(chip->interrupts[1]); in ad7150_write_event_config()
272 ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG_REG); in ad7150_write_event_config()
291 ret = i2c_smbus_write_byte_data(chip->client, AD7150_CFG_REG, in ad7150_write_event_config()
301 chip->type = type; in ad7150_write_event_config()
302 chip->dir = dir; in ad7150_write_event_config()
305 ret = ad7150_write_event_params(indio_dev, chan->channel, type, in ad7150_write_event_config()
310 enable_irq(chip->interrupts[0]); in ad7150_write_event_config()
311 enable_irq(chip->interrupts[1]); in ad7150_write_event_config()
313 if (!chip->int_enabled[chan->channel]) { in ad7150_write_event_config()
314 enable_irq(chip->interrupts[chan->channel]); in ad7150_write_event_config()
315 chip->int_enabled[chan->channel] = true; in ad7150_write_event_config()
319 mutex_unlock(&chip->state_lock); in ad7150_write_event_config()
339 *val = chip->thresh_sensitivity[rising][chan->channel]; in ad7150_read_event_value()
342 *val = chip->threshold[rising][chan->channel]; in ad7150_read_event_value()
345 return -EINVAL; in ad7150_read_event_value()
349 *val2 = chip->thresh_timeout[rising][chan->channel] * 10000; in ad7150_read_event_value()
352 return -EINVAL; in ad7150_read_event_value()
367 mutex_lock(&chip->state_lock); in ad7150_write_event_value()
372 chip->thresh_sensitivity[rising][chan->channel] = val; in ad7150_write_event_value()
375 chip->threshold[rising][chan->channel] = val; in ad7150_write_event_value()
378 ret = -EINVAL; in ad7150_write_event_value()
391 ret = -EINVAL; in ad7150_write_event_value()
395 chip->thresh_timeout[rising][chan->channel] = timeout; in ad7150_write_event_value()
399 ret = -EINVAL; in ad7150_write_event_value()
404 ret = ad7150_write_event_params(indio_dev, chan->channel, type, dir); in ad7150_write_event_value()
407 mutex_unlock(&chip->state_lock); in ad7150_write_event_value()
487 int_status = i2c_smbus_read_byte_data(chip->client, AD7150_STATUS_REG); in __ad7150_event_handler()
496 chip->type, chip->dir), in __ad7150_event_handler()
547 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); in ad7150_probe()
549 return -ENOMEM; in ad7150_probe()
552 mutex_init(&chip->state_lock); in ad7150_probe()
553 chip->client = client; in ad7150_probe()
555 indio_dev->name = id->name; in ad7150_probe()
557 indio_dev->modes = INDIO_DIRECT_MODE; in ad7150_probe()
559 ret = devm_regulator_get_enable(&client->dev, "vdd"); in ad7150_probe()
563 chip->interrupts[0] = fwnode_irq_get(dev_fwnode(&client->dev), 0); in ad7150_probe()
564 if (chip->interrupts[0] < 0) in ad7150_probe()
566 else if (id->driver_data == AD7150) { in ad7150_probe()
567 chip->interrupts[1] = fwnode_irq_get(dev_fwnode(&client->dev), 1); in ad7150_probe()
568 if (chip->interrupts[1] < 0) in ad7150_probe()
572 irq_set_status_flags(chip->interrupts[0], IRQ_NOAUTOEN); in ad7150_probe()
573 ret = devm_request_threaded_irq(&client->dev, in ad7150_probe()
574 chip->interrupts[0], in ad7150_probe()
584 indio_dev->info = &ad7150_info; in ad7150_probe()
585 switch (id->driver_data) { in ad7150_probe()
587 indio_dev->channels = ad7150_channels; in ad7150_probe()
588 indio_dev->num_channels = ARRAY_SIZE(ad7150_channels); in ad7150_probe()
589 irq_set_status_flags(chip->interrupts[1], IRQ_NOAUTOEN); in ad7150_probe()
590 ret = devm_request_threaded_irq(&client->dev, in ad7150_probe()
591 chip->interrupts[1], in ad7150_probe()
602 indio_dev->channels = ad7151_channels; in ad7150_probe()
603 indio_dev->num_channels = ARRAY_SIZE(ad7151_channels); in ad7150_probe()
606 return -EINVAL; in ad7150_probe()
610 indio_dev->info = &ad7150_info_no_irq; in ad7150_probe()
611 switch (id->driver_data) { in ad7150_probe()
613 indio_dev->channels = ad7150_channels_no_irq; in ad7150_probe()
614 indio_dev->num_channels = in ad7150_probe()
618 indio_dev->channels = ad7151_channels_no_irq; in ad7150_probe()
619 indio_dev->num_channels = in ad7150_probe()
623 return -EINVAL; in ad7150_probe()
627 return devm_iio_device_register(indio_dev->dev.parent, indio_dev); in ad7150_probe()