diff mbox series

[RFC,v1,12/20] gpio: Add event count to Intel(R) PMC Timed I/O driver

Message ID 20210824164801.28896-13-lakshmi.sowjanya.d@intel.com
State New
Headers show
Series Review Request: Add support for Intel PMC | expand

Commit Message

D, Lakshmi Sowjanya Aug. 24, 2021, 4:47 p.m. UTC
From: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>

Implement event count interface added to GPIOlib in Intel PMC
Timed I/O device

The Intel(R) PMC Timed I/O device has an event count register counting
the number of missed input edges. The register interface captures the
event count and timestamp of the last event. For an event rate
exceeding the rate that software can read events, the software can use
the missed event count to calculate average event rates.

Co-developed-by: Christopher Hall <christopher.s.hall@intel.com>
Signed-off-by: Christopher Hall <christopher.s.hall@intel.com>
Signed-off-by: Tamal Saha <tamal.saha@intel.com>
Signed-off-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@intel.com>
Reviewed-by: Mark Gross <mgross@linux.intel.com>
---
 drivers/gpio/gpio-intel-tio-pmc.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-intel-tio-pmc.c b/drivers/gpio/gpio-intel-tio-pmc.c
index f57f521edc40..7c4dd5c2661c 100644
--- a/drivers/gpio/gpio-intel-tio-pmc.c
+++ b/drivers/gpio/gpio-intel-tio-pmc.c
@@ -60,6 +60,7 @@  struct intel_pmc_tio_get_time_arg {
 	struct intel_pmc_tio_chip *tio;
 	u32 eflags;
 	u32 event_id;
+	u32 event_count;
 	u64 abs_event_count;
 };
 
@@ -276,6 +277,7 @@  static int intel_pmc_tio_get_time(ktime_t *device_time,
 
 	*system_counterval = convert_art_to_tsc(art_timestamp);
 	arg->abs_event_count = abs_event_count;
+	arg->event_count = rel_event_count;
 	arg->event_id = 0;
 	arg->event_id |= (flags & GPIO_V2_LINE_FLAG_EDGE_RISING) ?
 		GPIO_V2_LINE_EVENT_RISING_EDGE : 0;
@@ -310,6 +312,7 @@  static int intel_pmc_tio_do_poll(struct gpio_chip *chip, unsigned int offset,
 			data->timestamp = ktime_to_ns(xtstamp.sys_realtime);
 			data->id = arg.event_id;
 			tio->last_event_count = arg.abs_event_count;
+			data->event_count = arg.event_count;
 		}
 		if (!err || err == -EAGAIN)
 			break;