8000 iio: logic: m2k-trigger-ad: Add trigger holdoff support · analogdevicesinc/linux@bd9f616 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit bd9f616

Browse files
btogoreancommodo
authored andcommitted
iio: logic: m2k-trigger-ad: Add trigger holdoff support
Trigger hold off add the possibility to ingnore all the trigger events during a period specified using the holdoff attribute. The raw value from attribute times 10ns represent the actual holdoff period. Signed-off-by: Bogdan Togorean <bogdan.togorean@analog.com>
1 parent 8446cf3 commit bd9f616

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

drivers/iio/logic/m2k-trigger-ad.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define AXI_ADC_TRIG_REG_TRIGGERED 0x3c
3434
#define AXI_ADC_TRIG_REG_DELAY 0x40
3535
#define AXI_ADC_TRIG_REG_STREAMING 0x44
36+
#define AXI_ADC_TRIG_REG_HOLDOFF 0x48
3637

3738
/* AXI_ADC_TRIG_REG_CONFIG_TRIGGER */
3839
#define CONF_LOW_LEVEL 0
@@ -49,6 +50,8 @@
4950
#define TRIGGER_ADC_CHAN 2
5051
#define TRIGGER_MIX_CHAN 2
5152

53+
#define TRIGGER_HOLDOFF_MASK GENMASK(31, 0)
54+
5255
#define IIO_ENUM_AVAILABLE_SEPARATE(_name, _e) \
5356
{ \
5457
.name = (_name "_available"), \
@@ -497,6 +500,35 @@ static ssize_t axi_adc_trig_set_streaming(struct iio_dev *indio_dev,
497500
return len;
498501
}
499502

503+
static ssize_t axi_adc_trig_get_holdoff(struct iio_dev *indio_dev,
504+
uintptr_t priv, const struct iio_chan_spec *chan, char *buf)
505+
{
506+
struct axi_adc_trig *axi_adc_trig = iio_priv(indio_dev);
507+
unsigned int val;
508+
509+
val = axi_adc_trig_read(axi_adc_trig, AXI_ADC_TRIG_REG_HOLDOFF);
510+
val &= TRIGGER_HOLDOFF_MASK;
511+
512+
return scnprintf(buf, PAGE_SIZE, "%d\n", val);
513+
}
514+
515+
static ssize_t axi_adc_trig_set_holdoff(struct iio_dev *indio_dev,
516+
uintptr_t priv, const struct iio_chan_spec *chan, const char *buf,
517+
size_t len)
518+
{
519+
struct axi_adc_trig *axi_adc_trig = iio_priv(indio_dev);
520+
unsigned int val;
521+
int ret;
522+
523+
ret = kstrtouint(buf, 10, &val);
524+
if (ret < 0)
525+
return ret;
526+
527+
axi_adc_trig_write(axi_adc_trig, AXI_ADC_TRIG_REG_HOLDOFF, val);
528+
529+
return len;
530+
}
531+
500532
static ssize_t axi_adc_trig_get_embedded_trigger(struct iio_dev *indio_dev,
501533
uintptr_t priv, const struct iio_chan_spec *chan, char *buf)
502534
{
@@ -565,6 +597,12 @@ static const struct iio_chan_spec_ext_info axi_adc_trig_analog_info[] = {
565597
.write = axi_adc_trig_set_streaming,
566598
.read = axi_adc_trig_get_streaming,
567599
},
600+
{
601+
.name = "holdoff_raw",
602+
.shared = IIO_SHARED_BY_ALL,
603+
.write = axi_adc_trig_set_holdoff,
604+
.read = axi_adc_trig_get_holdoff,
605+
},
568606
{}
569607
};
570608

0 commit comments

Comments
 (0)
0