[PATCH V2 2/2] clocksource/drivers/timer-imx-gpt: Change to cyclecounter for GPT input capture.

From: Kane Jiang
Date: Thu Mar 03 2022 - 20:57:49 EST


Modify the timestamp to cyclecounter in i.MX GPT driver for input
capture function.

Signed-off-by: Kane Jiang <jian.jiang@xxxxxxx>
---
V2:
- remove compatible support for NXP i.MX8MM
---
drivers/clocksource/timer-imx-gpt.c | 9 +++++----
include/linux/mxc_icap.h | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
index c6aa1462e441..01f4d78d0b6e 100644
--- a/drivers/clocksource/timer-imx-gpt.c
+++ b/drivers/clocksource/timer-imx-gpt.c
@@ -417,22 +417,23 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id)

for (i = 0; i < 2; i++) {
struct icap_channel *ic = &icap_channel[i];
- ktime_t timestamp;
+ u64 cyclecounter;

if (!imxtm->gpt->gpt_is_ic_irq(ic, tstat))
continue;

imxtm->gpt->gpt_ic_irq_acknowledge(ic);

- timestamp = ns_to_ktime(timecounter_read(&ic->tc));
+ cyclecounter = ic->cc.read(&ic->cc);

if (ic->handler)
- ic->handler(ic->chan, ic->dev_id, timestamp);
+ ic->handler(ic->chan, ic->dev_id, cyclecounter);
}

if (imxtm->gpt->gpt_is_oc_irq(imxtm, tstat)) {
imxtm->gpt->gpt_oc_irq_acknowledge(imxtm);
- ced->event_handler(ced);
+ if (ced->event_handler)
+ ced->event_handler(ced);
}

return IRQ_HANDLED;
diff --git a/include/linux/mxc_icap.h b/include/linux/mxc_icap.h
index fa5ffdf3b589..292c15b6b028 100644
--- a/include/linux/mxc_icap.h
+++ b/include/linux/mxc_icap.h
@@ -7,7 +7,7 @@
#ifndef __MXC_ICAP_H__
#define __MXC_ICAP_H__

-typedef void (*mxc_icap_handler_t)(int, void *, ktime_t);
+typedef void (*mxc_icap_handler_t)(int, void *, u64);

int mxc_request_input_capture(unsigned int chan, mxc_icap_handler_t handler,
unsigned long capflags, void *dev_id);
--
2.25.1