afe4404.c (617894cd848f592fa84d7cf561dc80929afc66ff) | afe4404.c (3593cd53962fa17e4eaaae8faa5c8f62ec7bbd5e) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * AFE4404 Heart Rate Monitors and Low-Cost Pulse Oximeters 4 * | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * AFE4404 Heart Rate Monitors and Low-Cost Pulse Oximeters 4 * |
5 * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/ | 5 * Copyright (C) 2015-2016 Texas Instruments Incorporated - https://www.ti.com/ |
6 * Andrew F. Davis <afd@ti.com> 7 */ 8 9#include <linux/device.h> 10#include <linux/err.h> 11#include <linux/interrupt.h> 12#include <linux/i2c.h> 13#include <linux/kernel.h> --- 64 unchanged lines hidden (view full) --- 78/** 79 * struct afe4404_data - AFE4404 device instance data 80 * @dev: Device structure 81 * @regmap: Register map of the device 82 * @fields: Register fields of the device 83 * @regulator: Pointer to the regulator for the IC 84 * @trig: IIO trigger for this device 85 * @irq: ADC_RDY line interrupt number | 6 * Andrew F. Davis <afd@ti.com> 7 */ 8 9#include <linux/device.h> 10#include <linux/err.h> 11#include <linux/interrupt.h> 12#include <linux/i2c.h> 13#include <linux/kernel.h> --- 64 unchanged lines hidden (view full) --- 78/** 79 * struct afe4404_data - AFE4404 device instance data 80 * @dev: Device structure 81 * @regmap: Register map of the device 82 * @fields: Register fields of the device 83 * @regulator: Pointer to the regulator for the IC 84 * @trig: IIO trigger for this device 85 * @irq: ADC_RDY line interrupt number |
86 * @buffer: Used to construct a scan to push to the iio buffer. | |
87 */ 88struct afe4404_data { 89 struct device *dev; 90 struct regmap *regmap; 91 struct regmap_field *fields[F_MAX_FIELDS]; 92 struct regulator *regulator; 93 struct iio_trigger *trig; 94 int irq; | 86 */ 87struct afe4404_data { 88 struct device *dev; 89 struct regmap *regmap; 90 struct regmap_field *fields[F_MAX_FIELDS]; 91 struct regulator *regulator; 92 struct iio_trigger *trig; 93 int irq; |
95 s32 buffer[10] __aligned(8); | |
96}; 97 98enum afe4404_chan_id { 99 LED2 = 1, 100 ALED2, 101 LED1, 102 ALED1, 103 LED2_ALED2, --- 221 unchanged lines hidden (view full) --- 325}; 326 327static irqreturn_t afe4404_trigger_handler(int irq, void *private) 328{ 329 struct iio_poll_func *pf = private; 330 struct iio_dev *indio_dev = pf->indio_dev; 331 struct afe4404_data *afe = iio_priv(indio_dev); 332 int ret, bit, i = 0; | 94}; 95 96enum afe4404_chan_id { 97 LED2 = 1, 98 ALED2, 99 LED1, 100 ALED1, 101 LED2_ALED2, --- 221 unchanged lines hidden (view full) --- 323}; 324 325static irqreturn_t afe4404_trigger_handler(int irq, void *private) 326{ 327 struct iio_poll_func *pf = private; 328 struct iio_dev *indio_dev = pf->indio_dev; 329 struct afe4404_data *afe = iio_priv(indio_dev); 330 int ret, bit, i = 0; |
331 s32 buffer[10]; |
|
333 334 for_each_set_bit(bit, indio_dev->active_scan_mask, 335 indio_dev->masklength) { 336 ret = regmap_read(afe->regmap, afe4404_channel_values[bit], | 332 333 for_each_set_bit(bit, indio_dev->active_scan_mask, 334 indio_dev->masklength) { 335 ret = regmap_read(afe->regmap, afe4404_channel_values[bit], |
337 &afe->buffer[i++]); | 336 &buffer[i++]); |
338 if (ret) 339 goto err; 340 } 341 | 337 if (ret) 338 goto err; 339 } 340 |
342 iio_push_to_buffers_with_timestamp(indio_dev, afe->buffer, 343 pf->timestamp); | 341 iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp); |
344err: 345 iio_trigger_notify_done(indio_dev->trig); 346 347 return IRQ_HANDLED; 348} 349 350static const struct iio_trigger_ops afe4404_trigger_ops = { 351}; --- 162 unchanged lines hidden (view full) --- 514 ret = regmap_multi_reg_write(afe->regmap, afe4404_reg_sequences, 515 ARRAY_SIZE(afe4404_reg_sequences)); 516 if (ret) { 517 dev_err(afe->dev, "Unable to set register defaults\n"); 518 goto disable_reg; 519 } 520 521 indio_dev->modes = INDIO_DIRECT_MODE; | 342err: 343 iio_trigger_notify_done(indio_dev->trig); 344 345 return IRQ_HANDLED; 346} 347 348static const struct iio_trigger_ops afe4404_trigger_ops = { 349}; --- 162 unchanged lines hidden (view full) --- 512 ret = regmap_multi_reg_write(afe->regmap, afe4404_reg_sequences, 513 ARRAY_SIZE(afe4404_reg_sequences)); 514 if (ret) { 515 dev_err(afe->dev, "Unable to set register defaults\n"); 516 goto disable_reg; 517 } 518 519 indio_dev->modes = INDIO_DIRECT_MODE; |
522 indio_dev->dev.parent = afe->dev; | |
523 indio_dev->channels = afe4404_channels; 524 indio_dev->num_channels = ARRAY_SIZE(afe4404_channels); 525 indio_dev->name = AFE4404_DRIVER_NAME; 526 indio_dev->info = &afe4404_iio_info; 527 528 if (afe->irq > 0) { 529 afe->trig = devm_iio_trigger_alloc(afe->dev, 530 "%s-dev%d", --- 99 unchanged lines hidden --- | 520 indio_dev->channels = afe4404_channels; 521 indio_dev->num_channels = ARRAY_SIZE(afe4404_channels); 522 indio_dev->name = AFE4404_DRIVER_NAME; 523 indio_dev->info = &afe4404_iio_info; 524 525 if (afe->irq > 0) { 526 afe->trig = devm_iio_trigger_alloc(afe->dev, 527 "%s-dev%d", --- 99 unchanged lines hidden --- |