Lines Matching +full:tuning +full:- +full:capacitor +full:- +full:pf

1 // SPDX-License-Identifier: GPL-2.0+
3 * as3935.c - Support for AS3935 Franklin lightning sensor
5 * Copyright (C) 2014, 2017-2018
15 #include <linux/devm-helpers.h>
94 ret = spi_w8r8(st->spi, cmd); in as3935_read()
106 u8 *buf = st->buf; in as3935_write()
111 return spi_write(st->spi, buf, 2); in as3935_write()
139 return -EINVAL; in as3935_sensor_sensitivity_store()
142 return -EINVAL; in as3935_sensor_sensitivity_store()
156 mutex_lock(&st->lock); in as3935_noise_level_tripped_show()
157 ret = sysfs_emit(buf, "%d\n", !time_after(jiffies, st->noise_tripped + HZ)); in as3935_noise_level_tripped_show()
158 mutex_unlock(&st->lock); in as3935_noise_level_tripped_show()
199 return -EINVAL; in as3935_read_raw()
211 return -EINVAL; in as3935_read_raw()
224 struct iio_poll_func *pf = private; in as3935_trigger_handler() local
225 struct iio_dev *indio_dev = pf->indio_dev; in as3935_trigger_handler()
233 st->scan.chan = val & AS3935_DATA_MASK; in as3935_trigger_handler()
234 iio_push_to_buffers_with_timestamp(indio_dev, &st->scan, in as3935_trigger_handler()
237 iio_trigger_notify_done(indio_dev->trig); in as3935_trigger_handler()
252 dev_warn(&st->spi->dev, "read error\n"); in as3935_event_work()
260 iio_trigger_poll_chained(st->trig); in as3935_event_work()
264 mutex_lock(&st->lock); in as3935_event_work()
265 st->noise_tripped = jiffies; in as3935_event_work()
266 mutex_unlock(&st->lock); in as3935_event_work()
267 dev_warn(&st->spi->dev, "noise level is too high\n"); in as3935_event_work()
282 schedule_delayed_work(&st->work, msecs_to_jiffies(3)); in as3935_interrupt_handler()
292 BIT(5) | (st->tune_cap / TUNE_CAP_DIV)); in calibrate_as3935()
295 as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); in calibrate_as3935()
296 as3935_write(st, AS3935_NFLWDTH, st->nflwdth_reg); in calibrate_as3935()
305 mutex_lock(&st->lock); in as3935_suspend()
314 mutex_unlock(&st->lock); in as3935_suspend()
325 mutex_lock(&st->lock); in as3935_resume()
335 mutex_unlock(&st->lock); in as3935_resume()
344 struct device *dev = &spi->dev; in as3935_probe()
351 if (!spi->irq) { in as3935_probe()
353 return -EINVAL; in as3935_probe()
358 return -ENOMEM; in as3935_probe()
361 st->spi = spi; in as3935_probe()
364 mutex_init(&st->lock); in as3935_probe()
367 "ams,tuning-capacitor-pf", &st->tune_cap); in as3935_probe()
369 st->tune_cap = 0; in as3935_probe()
370 dev_warn(dev, "no tuning-capacitor-pf set, defaulting to %d", in as3935_probe()
371 st->tune_cap); in as3935_probe()
374 if (st->tune_cap > MAX_PF_CAP) { in as3935_probe()
375 dev_err(dev, "wrong tuning-capacitor-pf setting of %d\n", in as3935_probe()
376 st->tune_cap); in as3935_probe()
377 return -EINVAL; in as3935_probe()
381 "ams,nflwdth", &st->nflwdth_reg); in as3935_probe()
382 if (!ret && st->nflwdth_reg > AS3935_NFLWDTH_MASK) { in as3935_probe()
384 st->nflwdth_reg); in as3935_probe()
385 return -EINVAL; in as3935_probe()
388 indio_dev->name = spi_get_device_id(spi)->name; in as3935_probe()
389 indio_dev->channels = as3935_channels; in as3935_probe()
390 indio_dev->num_channels = ARRAY_SIZE(as3935_channels); in as3935_probe()
391 indio_dev->modes = INDIO_DIRECT_MODE; in as3935_probe()
392 indio_dev->info = &as3935_info; in as3935_probe()
394 trig = devm_iio_trigger_alloc(dev, "%s-dev%d", in as3935_probe()
395 indio_dev->name, in as3935_probe()
399 return -ENOMEM; in as3935_probe()
401 st->trig = trig; in as3935_probe()
402 st->noise_tripped = jiffies - HZ; in as3935_probe()
422 ret = devm_delayed_work_autocancel(dev, &st->work, as3935_event_work); in as3935_probe()
426 ret = devm_request_irq(dev, spi->irq, in as3935_probe()