From patchwork Wed Oct 14 23:11:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 285598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1097BC433DF for ; Thu, 15 Oct 2020 01:40:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA03922257 for ; Thu, 15 Oct 2020 01:40:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d+VCXrwI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389159AbgJOBji (ORCPT ); Wed, 14 Oct 2020 21:39:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387776AbgJOBji (ORCPT ); Wed, 14 Oct 2020 21:39:38 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D0EDC05113B; Wed, 14 Oct 2020 16:12:19 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id p11so514545pld.5; Wed, 14 Oct 2020 16:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p72ZdDxHI4dsq8AJ/ZFHhJ0EwFxWhrCYmlDXjgdTJgY=; b=d+VCXrwI0NXI9nWxhwkSnqAAHrPseaX1HXs6m+BIi7zlwsPmGC8KbQTNe3xXsD84Ei 0WbmLGS/sofYuWKZvsTM5PWUxlKjtAQPjzhARoUYOq87CTqGQrbzzYTnUNvma+VDxPVq dAimA4gFsbvuLBVRzCWkI80YQHyLQiLjyWIImpsC0LgK2UObc8xtLEk0hRH/FaOvaHVY ZYA+PvY0/th0xlxDZfquEk+VSmFGFqoKBRIyZkxXNqooC7loiI5YszCitL1nF5O3AnLq 4wO/79HA7C97/mSF3uMvdg0CkvwdFuZTBYF4gYL2y+3XAaxjvFhBWJ68UQ0uBknsmD7D Smgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p72ZdDxHI4dsq8AJ/ZFHhJ0EwFxWhrCYmlDXjgdTJgY=; b=ptzvuiYeW7SNnTOHeQJthQ5U2yKCY8Okjs+UcwZ2XwxiZjfMg90BWSTvwQ2rGxleV+ mfK9/Y5qg/VU+uT3UzdniLoqhcdUaNU14BYHg5r7G+LszoikPIHWHCIsbObtcJX+AuA+ AJaiNiUlQ+JtDGnO55ZfrflRXwjaTEYwGLYKHZ/zkw0mQl9D6kH+pCpal6drFIA9jyGe PkkKbBTSKRR00KVqkjIl5eA6E9cqt7+KumcAY7RId5pRxWFwniGk00fJWnEBBbrMjXhF Kgi0LNbjczY7d8ZSWs6Vb5fQF1jxGPiDwekGxgDgqAlEGgj/IlgXbFSz6b9Qw0FL8+mK bhew== X-Gm-Message-State: AOAM531H7nvnmYME1xxg+dZpdweCiVd2lJQF0jjw2TuMgko8OdD5vPJq uIp34EdxBjhm2mGarxRSTYsecTPwg0vflA== X-Google-Smtp-Source: ABdhPJzm8/mJyKcmeTDkPU+PhecU72La+D522Y3j05fI5/FdvWUdFXkYQHJ3YYCko0osD9Q7BRHrSg== X-Received: by 2002:a17:90b:3393:: with SMTP id ke19mr1470836pjb.3.1602717138463; Wed, 14 Oct 2020 16:12:18 -0700 (PDT) Received: from sol.lan (106-69-182-59.dyn.iinet.net.au. [106.69.182.59]) by smtp.gmail.com with ESMTPSA id e5sm723157pjd.0.2020.10.14.16.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 16:12:17 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Cc: Kent Gibson , Jack Winch Subject: [PATCH v2 1/3] gpiolib: cdev: allow edge event timestamps to be configured as REALTIME Date: Thu, 15 Oct 2020 07:11:56 +0800 Message-Id: <20201014231158.34117-2-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201014231158.34117-1-warthog618@gmail.com> References: <20201014231158.34117-1-warthog618@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Using CLOCK_REALTIME as the source for event timestamps is crucial for some specific applications, particularly those requiring timetamps relative to a PTP clock, so provide an option to switch the event timestamp source from the default CLOCK_MONOTONIC to CLOCK_REALTIME. Note that CLOCK_REALTIME was the default source clock for GPIO until Linux 5.7 when it was changed to CLOCK_MONOTONIC due to issues with the shifting of the realtime clock. Providing this option maintains the CLOCK_MONOTONIC as the default, while also providing a path forward for those dependent on the pre-5.7 behaviour. Suggested-by: Jack Winch Signed-off-by: Kent Gibson --- drivers/gpio/gpiolib-cdev.c | 21 ++++++++++++++++++--- drivers/gpio/gpiolib.h | 1 + include/uapi/linux/gpio.h | 12 +++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 678de9264617..ea787eb3810d 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -515,6 +515,7 @@ struct linereq { GPIO_V2_LINE_DIRECTION_FLAGS | \ GPIO_V2_LINE_DRIVE_FLAGS | \ GPIO_V2_LINE_EDGE_FLAGS | \ + GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME | \ GPIO_V2_LINE_BIAS_FLAGS) static void linereq_put_event(struct linereq *lr, @@ -535,6 +536,14 @@ static void linereq_put_event(struct linereq *lr, pr_debug_ratelimited("event FIFO is full - event dropped\n"); } +static u64 line_event_timestamp(struct line *line) +{ + if (test_bit(FLAG_EVENT_CLOCK_REALTIME, &line->desc->flags)) + return ktime_get_real_ns(); + + return ktime_get_ns(); +} + static irqreturn_t edge_irq_thread(int irq, void *p) { struct line *line = p; @@ -553,7 +562,7 @@ static irqreturn_t edge_irq_thread(int irq, void *p) * which case we didn't get the timestamp from * edge_irq_handler(). */ - le.timestamp_ns = ktime_get_ns(); + le.timestamp_ns = line_event_timestamp(line); if (lr->num_lines != 1) line->req_seqno = atomic_inc_return(&lr->seqno); } @@ -598,7 +607,7 @@ static irqreturn_t edge_irq_handler(int irq, void *p) * Just store the timestamp in hardirq context so we get it as * close in time as possible to the actual event. */ - line->timestamp_ns = ktime_get_ns(); + line->timestamp_ns = line_event_timestamp(line); if (lr->num_lines != 1) line->req_seqno = atomic_inc_return(&lr->seqno); @@ -673,7 +682,7 @@ static void debounce_work_func(struct work_struct *work) memset(&le, 0, sizeof(le)); lr = line->req; - le.timestamp_ns = ktime_get_ns(); + le.timestamp_ns = line_event_timestamp(line); le.offset = gpio_chip_hwgpio(line->desc); line->line_seqno++; le.line_seqno = line->line_seqno; @@ -977,6 +986,9 @@ static void gpio_v2_line_config_flags_to_desc_flags(u64 flags, flags & GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN); assign_bit(FLAG_BIAS_DISABLE, flagsp, flags & GPIO_V2_LINE_FLAG_BIAS_DISABLED); + + assign_bit(FLAG_EVENT_CLOCK_REALTIME, flagsp, + flags & GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME); } static long linereq_get_values(struct linereq *lr, void __user *ip) @@ -1940,6 +1952,9 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc, if (test_bit(FLAG_EDGE_FALLING, &desc->flags)) info->flags |= GPIO_V2_LINE_FLAG_EDGE_FALLING; + if (test_bit(FLAG_EVENT_CLOCK_REALTIME, &desc->flags)) + info->flags |= GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME; + debounce_period_us = READ_ONCE(desc->debounce_period_us); if (debounce_period_us) { info->attrs[num_attrs].id = GPIO_V2_LINE_ATTR_ID_DEBOUNCE; diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index b674b5bb980e..2f228ffe8320 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -116,6 +116,7 @@ struct gpio_desc { #define FLAG_BIAS_DISABLE 15 /* GPIO has pull disabled */ #define FLAG_EDGE_RISING 16 /* GPIO CDEV detects rising edge events */ #define FLAG_EDGE_FALLING 17 /* GPIO CDEV detects falling edge events */ +#define FLAG_EVENT_CLOCK_REALTIME 18 /* GPIO CDEV reports REALTIME timestamps in events */ /* Connection label */ const char *label; diff --git a/include/uapi/linux/gpio.h b/include/uapi/linux/gpio.h index 2072c260f5d0..e4eb0b8c5cf9 100644 --- a/include/uapi/linux/gpio.h +++ b/include/uapi/linux/gpio.h @@ -65,6 +65,7 @@ struct gpiochip_info { * @GPIO_V2_LINE_FLAG_BIAS_PULL_UP: line has pull-up bias enabled * @GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN: line has pull-down bias enabled * @GPIO_V2_LINE_FLAG_BIAS_DISABLED: line has bias disabled + * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME: line events contain REALTIME timestamps */ enum gpio_v2_line_flag { GPIO_V2_LINE_FLAG_USED = _BITULL(0), @@ -78,6 +79,7 @@ enum gpio_v2_line_flag { GPIO_V2_LINE_FLAG_BIAS_PULL_UP = _BITULL(8), GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = _BITULL(9), GPIO_V2_LINE_FLAG_BIAS_DISABLED = _BITULL(10), + GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = _BITULL(11), }; /** @@ -270,9 +272,6 @@ enum gpio_v2_line_event_id { /** * struct gpio_v2_line_event - The actual event being pushed to userspace * @timestamp_ns: best estimate of time of event occurrence, in nanoseconds. - * The @timestamp_ns is read from %CLOCK_MONOTONIC and is intended to allow - * the accurate measurement of the time between events. It does not provide - * the wall-clock time. * @id: event identifier with value from &enum gpio_v2_line_event_id * @offset: the offset of the line that triggered the event * @seqno: the sequence number for this event in the sequence of events for @@ -280,6 +279,13 @@ enum gpio_v2_line_event_id { * @line_seqno: the sequence number for this event in the sequence of * events on this particular line * @padding: reserved for future use + * + * By default the @timestamp_ns is read from %CLOCK_MONOTONIC and is + * intended to allow the accurate measurement of the time between events. + * It does not provide the wall-clock time. + * + * If the %GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME flag is set then the + * @timestamp_ns is read from %CLOCK_REALTIME. */ struct gpio_v2_line_event { __aligned_u64 timestamp_ns; From patchwork Wed Oct 14 23:11:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 285597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D54BC43457 for ; Thu, 15 Oct 2020 01:40:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C515222257 for ; Thu, 15 Oct 2020 01:40:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J5bIT6z0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389445AbgJOBk1 (ORCPT ); Wed, 14 Oct 2020 21:40:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389040AbgJOBjh (ORCPT ); Wed, 14 Oct 2020 21:39:37 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25641C05113C; Wed, 14 Oct 2020 16:12:25 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id x13so602712pgp.7; Wed, 14 Oct 2020 16:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=El/pzj9jX1MRiZIL1sB1BOM0SgriA1p/FtOnL1weGFo=; b=J5bIT6z0TX+eVs8xDW9zOw85VcZRLKNeJHVPD7iao1P2SCJPovIzVZbQuOxLxtOzQm JJ8rD20SCZK87cjll2bKuvEhdVmPCwJEC5DBZIKpyZx/YVa/mN274LrVA8Dc+V0GKccW Kfj0qd347oz9T63kQpWHG/BGnD9XzeN+H/a/+ggOFxRQ8B4KTOXv+apYWNzVa43P8xK6 BrTQeaEOU5XYB78nh2Vs/SVVG8Zs8CQX7yt5mHdUDC1Td1yKpzhSFyFB25icffYVG/qe HwZEFdLp2Gj8glbrO9XY8BcY6Yw0soPnQdtmwhqqbAKPhNWXkM5k0lC1VdKs6b/duEuS 1FiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=El/pzj9jX1MRiZIL1sB1BOM0SgriA1p/FtOnL1weGFo=; b=PX1WtaUC7jfvVti/5jJag23IKr1Gq6u1QbaXjPV924UWkwAx+qbhNzg4urQEDx3OMW gEXxLsMkxwYNKX00SEyZlWDkfxKA6ePkI6bFnvbipwTBNzvGUNaqtMnYN4DdQMrbT6zp /LkylkjnlFr6QTGtWWyKAded5koRpWculRgdGLIFzm7pv+5dMZVfMMJCehoejtGZV9n+ xHlPGlHtGUtBU4HuknlTnvEal10TACTWvFww0rP6ZLJNHSNzuPf33XMupDzL4w6o04fL vRlN5OFVfUiKdFkQ4c5CBazohpSEhw4KsjK5AqW1sHk+1zydSxaJqpdOe4FNzPwLZ75q VcSQ== X-Gm-Message-State: AOAM533wTmJaCT5clVPj6yfyTOTi7gsrRmVRCk8T61wCMJKuGmhiZ1A4 uDRqQjMcsjvByFE4yVvMLlNuucQ2M1SqBw== X-Google-Smtp-Source: ABdhPJy9xT71FwNcunMPImQQmE8t/49Ekelzfy+BJWZLW3EbgpRA4B2rGOShCtbn8XFl/tsUl7aE6g== X-Received: by 2002:a62:878c:0:b029:155:c0e4:fb39 with SMTP id i134-20020a62878c0000b0290155c0e4fb39mr1472751pfe.62.1602717144332; Wed, 14 Oct 2020 16:12:24 -0700 (PDT) Received: from sol.lan (106-69-182-59.dyn.iinet.net.au. [106.69.182.59]) by smtp.gmail.com with ESMTPSA id e5sm723157pjd.0.2020.10.14.16.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 16:12:23 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Cc: Kent Gibson Subject: [PATCH v2 2/3] tools: gpio: add support for reporting realtime event clock to lsgpio Date: Thu, 15 Oct 2020 07:11:57 +0800 Message-Id: <20201014231158.34117-3-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201014231158.34117-1-warthog618@gmail.com> References: <20201014231158.34117-1-warthog618@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Add support for reporting if a line is configured to report realtime timestamps in events. Signed-off-by: Kent Gibson --- tools/gpio/lsgpio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/gpio/lsgpio.c b/tools/gpio/lsgpio.c index 5a05a454d0c9..c61d061247e1 100644 --- a/tools/gpio/lsgpio.c +++ b/tools/gpio/lsgpio.c @@ -65,6 +65,10 @@ struct gpio_flag flagnames[] = { .name = "bias-disabled", .mask = GPIO_V2_LINE_FLAG_BIAS_DISABLED, }, + { + .name = "clock-realtime", + .mask = GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME, + }, }; static void print_attributes(struct gpio_v2_line_info *info) From patchwork Wed Oct 14 23:11:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 269599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6C0BC43457 for ; Thu, 15 Oct 2020 01:40:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65B9022257 for ; Thu, 15 Oct 2020 01:40:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RwuteCnh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389122AbgJOBji (ORCPT ); Wed, 14 Oct 2020 21:39:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389064AbgJOBjh (ORCPT ); Wed, 14 Oct 2020 21:39:37 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46EC8C05113F; Wed, 14 Oct 2020 16:12:32 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id q21so581227pgi.13; Wed, 14 Oct 2020 16:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=35fYZ5fGVbU2fwG24QMeC4xi8klfAcZjjBgE7NnhZ48=; b=RwuteCnhfi17fv1zs7LBl62j31eLJVMldVwMOoSc28MyYP3Cy9Z0BEGi2Wgbcs74aO Cn6pyJReUkmWJmGuDMr9/16AmqxOUcLd7ZEB49fJPU8kM9xDNVgk4rUncysh7b0orHLz L+fTJ8W17W169El0IrNg1HIc9To9j8UUiJjpJau9BEOwxaAP5G8eXNP3i/RW22uiNUes VczmcP6zrmERwxYOW5NUkbvQEVp0ciSoKomgsNdBY2q1zzmXjAHHP/9Txm0uyiwCR+0g x0GrHfn+zdR9mVrQ8w0HfBI3TXV6NFuz8dibsmy19fEjhSRacXYIG/mdqhwrlNOZLxJV bH9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=35fYZ5fGVbU2fwG24QMeC4xi8klfAcZjjBgE7NnhZ48=; b=tTCahFcFkKoG8VAmT6C/4lAGXrcJF/TJfT+tbpd5OE5ST9yKneVKPakOCWoKe7OAKO nCqtd1S1v3jfG7Yr/TLd2YB3A3BNrY5ZqFff8yHK0JhFQ+W0TCZPalJ+kVi5HguBNZ0J CU36kvQjV3E1FRGtS5D3FXD1q9I2X0aNnS7HtR7PMi1Wh6rfRYxc9w/4OErIcV1fLVzY RaHkcQAEZfBZjoxTOdbHBLJH4qqxvEetOZs2qOSBojupV6Ap2lrGUbs8W6NoCIwt1DHa 8XE6Lv0sncmd4LCMDbfUt2L9EguCrOzuZX4heARJ3HOMU1eIUBmIYKbqz0LXSHq/c+BO ln/w== X-Gm-Message-State: AOAM530vWffDJ9xUfJxuxtO/hR+YwtFPVfp5q6OvMREyBAfmtB2S5EFj Ur3dZgQJKC8KHTyWEXqE1sTGalF0Wk9PiA== X-Google-Smtp-Source: ABdhPJzPhzFk5l2hKTgx58KjumsE5OHLnayybtAifx5PWFJjAtI7gS2r8EVq6abFbQXDNcG1xNb6+Q== X-Received: by 2002:a62:7cd4:0:b029:154:f9ee:320b with SMTP id x203-20020a627cd40000b0290154f9ee320bmr1505877pfc.26.1602717151392; Wed, 14 Oct 2020 16:12:31 -0700 (PDT) Received: from sol.lan (106-69-182-59.dyn.iinet.net.au. [106.69.182.59]) by smtp.gmail.com with ESMTPSA id e5sm723157pjd.0.2020.10.14.16.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 16:12:30 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Cc: Kent Gibson Subject: [PATCH v2 3/3] tools: gpio: add option to report wall-clock time to gpio-event-mon Date: Thu, 15 Oct 2020 07:11:58 +0800 Message-Id: <20201014231158.34117-4-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201014231158.34117-1-warthog618@gmail.com> References: <20201014231158.34117-1-warthog618@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Add support for selecting the realtime clock for events. Signed-off-by: Kent Gibson --- tools/gpio/gpio-event-mon.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c index 90c3155f05b1..cacd66ad7926 100644 --- a/tools/gpio/gpio-event-mon.c +++ b/tools/gpio/gpio-event-mon.c @@ -148,6 +148,7 @@ void print_usage(void) " -s Set line as open source\n" " -r Listen for rising edges\n" " -f Listen for falling edges\n" + " -w Report the wall-clock time for events\n" " -b Debounce the line with period n microseconds\n" " [-c ] Do loops (optional, infinite loop if not stated)\n" " -? This helptext\n" @@ -173,7 +174,7 @@ int main(int argc, char **argv) memset(&config, 0, sizeof(config)); config.flags = GPIO_V2_LINE_FLAG_INPUT; - while ((c = getopt(argc, argv, "c:n:o:b:dsrf?")) != -1) { + while ((c = getopt(argc, argv, "c:n:o:b:dsrfw?")) != -1) { switch (c) { case 'c': loops = strtoul(optarg, NULL, 10); @@ -204,6 +205,9 @@ int main(int argc, char **argv) case 'f': config.flags |= GPIO_V2_LINE_FLAG_EDGE_FALLING; break; + case 'w': + config.flags |= GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME; + break; case '?': print_usage(); return -1;