From patchwork Sun Jun 25 14:21:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 112604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6955045vqr; Sun, 25 Jun 2023 07:56:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wIIhwylkNcuk5G7zhD1izWaqt+mEdZvplBcAoV5M1UzKz6UdXM2YY7NQH++39J8/sHlsM X-Received: by 2002:a05:6a20:430e:b0:125:9d2e:ae1a with SMTP id h14-20020a056a20430e00b001259d2eae1amr10333471pzk.9.1687704976067; Sun, 25 Jun 2023 07:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687704976; cv=none; d=google.com; s=arc-20160816; b=r/H5n1tAYhBg8wl/WPbD12pkM6F9fvuMoaKl2SK6DYdH5QqNMOMiLIn8h9V6fDZRff JSYzWcDz65g9wxmVg5OveLSEiC3qWISp3XJnTZEJ0xBUCht2kLgrUSSRAqAjX4nfo5pD 9E62Uu/3EanEuNFKDI/kG/Zk4KRYhoXOvnwo/Sa6Gzqt/vlCJVjL4Lzyps8QPuavyHC6 MfutcMkhUvLfcfYgKHJxF49of6fRbFyLn/F8NtIXNRQSx6GPrbq6K1J6FXAEyz3pN0OA 8wARnpx8Bfn+RNAZEPFEe+FjdE+XLsCjglqbdO4hgSQVFKGqsmLbl24Rri7BB1hfAgPT uCVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=K9olSALxwiqvfXFwnOq4yhThTzE4wPH5nlr+cWBRTlc=; fh=/9rTqK0zswNCgLim86exJ2HNVgKWrjH8Cr/T0xC8qdo=; b=QuBqq8ZOkNmcoyE7IxTyTzhmgBhxjhpKGgmC6oxglrmQnIYTprGQ1fzFr8Fa31Qm49 NY1xIJOib2Q2OXX/a/kuNmpEFEOoYDALGFHNah5hHn9PAEZIZxUEV17670O6ISkt4e5Y trJ+5d/qR0aKIC8D9Oz2y2lcGuT2Nf6QOmz5A/pfiDYsNmjI8tKeZP8C6O6TtrPg7MR8 /ROtHUKARdkVpYdnBSuKyc7Py/fb6AI04JIKrciEQfC4eao+58r1J+TGKUAN0gGC9CrM KwnMPCllRPME9e/Q+EB/v74lfMoBeQgAiqo3YB7fSD8/I6AFkpWO/gJxqTm7r1iwQt1f lCHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=SDJIQhpc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a6566c5000000b0055acfb661c0si978930pgw.524.2023.06.25.07.56.03; Sun, 25 Jun 2023 07:56:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=SDJIQhpc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbjFYOVx (ORCPT + 99 others); Sun, 25 Jun 2023 10:21:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbjFYOVm (ORCPT ); Sun, 25 Jun 2023 10:21:42 -0400 Received: from smtp-fw-9105.amazon.com (smtp-fw-9105.amazon.com [207.171.188.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FEC91B1; Sun, 25 Jun 2023 07:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1687702902; x=1719238902; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K9olSALxwiqvfXFwnOq4yhThTzE4wPH5nlr+cWBRTlc=; b=SDJIQhpc1bN1h3cyiCuMKxM5viemm/wEDp84rSIuQ1Pq8PfMwmjEI+XB UpY3w7fqJ2j+8q3qD2a6Y7wzbbVOlEC3f6u2RrXQJkk611Ntp6y9Uw9Lt Cyz1J7ZeKQsQ6VwAheq1rq3taYTJtq5s36enZri+g8J2R8ecgFJEYF28B A=; X-IronPort-AV: E=Sophos;i="6.01,157,1684800000"; d="scan'208";a="656892651" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-m6i4x-e7094f15.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-9105.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 14:21:37 +0000 Received: from EX19MTAUWC002.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2c-m6i4x-e7094f15.us-west-2.amazon.com (Postfix) with ESMTPS id B89B740D61; Sun, 25 Jun 2023 14:21:35 +0000 (UTC) Received: from EX19D013UWB003.ant.amazon.com (10.13.138.111) by EX19MTAUWC002.ant.amazon.com (10.250.64.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Sun, 25 Jun 2023 14:21:34 +0000 Received: from EX19MTAUWA001.ant.amazon.com (10.250.64.204) by EX19D013UWB003.ant.amazon.com (10.13.138.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Sun, 25 Jun 2023 14:21:34 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.250.64.204) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sun, 25 Jun 2023 14:21:34 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 115AC5AA; Sun, 25 Jun 2023 14:21:34 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , Subject: [PATCH 1/5] pps: add pulse-width calculation in nsec Date: Sun, 25 Jun 2023 14:21:30 +0000 Message-ID: <20230625142134.33690-2-farbere@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230625142134.33690-1-farbere@amazon.com> References: <20230625142134.33690-1-farbere@amazon.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769686933142975398?= X-GMAIL-MSGID: =?utf-8?q?1769686933142975398?= This change adds PPS pulse-width calculation in nano seconds. Width time can be calculated for both assert time and reset time. Calculation can be done only if capture ASSERT and capture CLEAR modes are both enabled. Assert width is calculated as: clear-time - assert-time and clear width is calculated as: assert-time - clear-time Read-only sysfs were added to get the last pulse-width time and event sequence. Examples: * cat /sys/class/pps/pps0/pulse_width_assert 20001450#85 * cat /sys/class/pps/pps1/pulse_width_clear 979893314#16 Signed-off-by: Eliav Farber --- drivers/pps/kapi.c | 49 ++++++++++++++++++++++++++++++++++++++ drivers/pps/pps.c | 9 +++++++ drivers/pps/sysfs.c | 30 +++++++++++++++++++++++ include/linux/pps_kernel.h | 3 +++ include/uapi/linux/pps.h | 19 +++++++++++++++ 5 files changed, 110 insertions(+) diff --git a/drivers/pps/kapi.c b/drivers/pps/kapi.c index d9d566f70ed1..deeecfc0a3ee 100644 --- a/drivers/pps/kapi.c +++ b/drivers/pps/kapi.c @@ -82,6 +82,14 @@ struct pps_device *pps_register_source(struct pps_source_info *info, goto pps_register_source_exit; } + if ((info->mode & PPS_WIDTHBOTH) && + ((info->mode & PPS_CAPTUREBOTH) != PPS_CAPTUREBOTH)) { + pr_err("%s: width can't be calculated without both captures (mode = 0x%x)\n", + info->name, info->mode); + err = -EINVAL; + goto pps_register_source_exit; + } + /* Allocate memory for the new PPS source struct */ pps = kzalloc(sizeof(struct pps_device), GFP_KERNEL); if (pps == NULL) { @@ -143,6 +151,39 @@ void pps_unregister_source(struct pps_device *pps) } EXPORT_SYMBOL(pps_unregister_source); +static u64 pps_ktime_sub(struct pps_ktime *ts1, struct pps_ktime *ts2) +{ + if (ts1->sec == ts2->sec) + return (ts1->nsec > ts2->nsec) ? (ts1->nsec - ts2->nsec) : (ts2->nsec - ts1->nsec); + + if (ts1->sec > ts2->sec) + return (ts1->sec - ts2->sec) * NSEC_PER_SEC + ts1->nsec - ts2->nsec; + + return (ts2->sec - ts1->sec) * NSEC_PER_SEC + ts2->nsec - ts1->nsec; +} + +static void pps_calc_clear_width(struct pps_device *pps) +{ + if (pps->clear_sequence == 0) + return; + + pps->clear_width.sequence++; + pps->clear_width.nsec = pps_ktime_sub(&pps->assert_tu, &pps->clear_tu); + dev_dbg(pps->dev, "PPS clear width = %llu#%u\n", + pps->clear_width.nsec, pps->clear_width.sequence); +} + +static void pps_calc_assert_width(struct pps_device *pps) +{ + if (pps->assert_sequence == 0) + return; + + pps->assert_width.sequence++; + pps->assert_width.nsec = pps_ktime_sub(&pps->clear_tu, &pps->assert_tu); + dev_dbg(pps->dev, "PPS assert width = %llu#%u\n", + pps->assert_width.nsec, pps->assert_width.sequence); +} + /* pps_event - register a PPS event into the system * @pps: the PPS device * @ts: the event timestamp @@ -191,6 +232,10 @@ void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event, dev_dbg(pps->dev, "capture assert seq #%u\n", pps->assert_sequence); + /* Calculate clear pulse-width */ + if (pps->params.mode & PPS_WIDTHCLEAR) + pps_calc_clear_width(pps); + captured = ~0; } if (event & pps->params.mode & PPS_CAPTURECLEAR) { @@ -205,6 +250,10 @@ void pps_event(struct pps_device *pps, struct pps_event_time *ts, int event, dev_dbg(pps->dev, "capture clear seq #%u\n", pps->clear_sequence); + /* Calculate assert pulse-width */ + if (pps->params.mode & PPS_WIDTHASSERT) + pps_calc_assert_width(pps); + captured = ~0; } diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c index 5d19baae6a38..8299a272af11 100644 --- a/drivers/pps/pps.c +++ b/drivers/pps/pps.c @@ -195,6 +195,11 @@ static long pps_cdev_ioctl(struct file *file, fdata.info.clear_tu = pps->clear_tu; fdata.info.current_mode = pps->current_mode; + memcpy(&fdata.info.assert_width, &pps->assert_width, + sizeof(struct pps_kwidth)); + memcpy(&fdata.info.clear_width, &pps->clear_width, + sizeof(struct pps_kwidth)); + spin_unlock_irq(&pps->lock); err = copy_to_user(uarg, &fdata, sizeof(struct pps_fdata)); @@ -283,6 +288,10 @@ static long pps_cdev_compat_ioctl(struct file *file, sizeof(struct pps_ktime_compat)); memcpy(&compat.info.clear_tu, &pps->clear_tu, sizeof(struct pps_ktime_compat)); + memcpy(&compat.info.assert_width, &pps->assert_width, + sizeof(struct pps_kwidth_compat)); + memcpy(&compat.info.clear_width, &pps->clear_width, + sizeof(struct pps_kwidth_compat)); spin_unlock_irq(&pps->lock); diff --git a/drivers/pps/sysfs.c b/drivers/pps/sysfs.c index 134bc33f6ad0..3e34de77dba6 100644 --- a/drivers/pps/sysfs.c +++ b/drivers/pps/sysfs.c @@ -79,6 +79,34 @@ static ssize_t path_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(path); +static ssize_t pulse_width_assert_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct pps_device *pps = dev_get_drvdata(dev); + + if (!(pps->info.mode & PPS_WIDTHASSERT)) + return 0; + + return sprintf(buf, "%llu#%u\n", + pps->assert_width.nsec, pps->assert_width.sequence); +} +static DEVICE_ATTR_RO(pulse_width_assert); + +static ssize_t pulse_width_clear_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct pps_device *pps = dev_get_drvdata(dev); + + if (!(pps->info.mode & PPS_WIDTHCLEAR)) + return 0; + + return sprintf(buf, "%llu#%u\n", + pps->clear_width.nsec, pps->clear_width.sequence); +} +static DEVICE_ATTR_RO(pulse_width_clear); + static struct attribute *pps_attrs[] = { &dev_attr_assert.attr, &dev_attr_clear.attr, @@ -86,6 +114,8 @@ static struct attribute *pps_attrs[] = { &dev_attr_echo.attr, &dev_attr_name.attr, &dev_attr_path.attr, + &dev_attr_pulse_width_assert.attr, + &dev_attr_pulse_width_clear.attr, NULL, }; diff --git a/include/linux/pps_kernel.h b/include/linux/pps_kernel.h index 78c8ac4951b5..15f2338095c6 100644 --- a/include/linux/pps_kernel.h +++ b/include/linux/pps_kernel.h @@ -51,6 +51,9 @@ struct pps_device { struct pps_ktime clear_tu; int current_mode; /* PPS mode at event time */ + struct pps_kwidth assert_width; /* PPS assert pulse-width time and event seq # */ + struct pps_kwidth clear_width; /* PPS clear pulse-width time and event seq # */ + unsigned int last_ev; /* last PPS event id */ wait_queue_head_t queue; /* PPS event queue */ diff --git a/include/uapi/linux/pps.h b/include/uapi/linux/pps.h index 009ebcd8ced5..dd93dac0afc1 100644 --- a/include/uapi/linux/pps.h +++ b/include/uapi/linux/pps.h @@ -64,12 +64,24 @@ struct pps_ktime_compat { } __attribute__((packed, aligned(4))); #define PPS_TIME_INVALID (1<<0) /* used to specify timeout==NULL */ +struct pps_kwidth { + __u64 nsec; + __u32 sequence; +}; + +struct pps_kwidth_compat { + __u64 nsec; + __u32 sequence; +} __attribute__((packed, aligned(4))); + struct pps_kinfo { __u32 assert_sequence; /* seq. num. of assert event */ __u32 clear_sequence; /* seq. num. of clear event */ struct pps_ktime assert_tu; /* time of assert event */ struct pps_ktime clear_tu; /* time of clear event */ int current_mode; /* current mode bits */ + struct pps_kwidth assert_width; /* assert pulse-width time and seq. num. */ + struct pps_kwidth clear_width; /* clear pulse-width time and seq. num. */ }; struct pps_kinfo_compat { @@ -78,6 +90,8 @@ struct pps_kinfo_compat { struct pps_ktime_compat assert_tu; /* time of assert event */ struct pps_ktime_compat clear_tu; /* time of clear event */ int current_mode; /* current mode bits */ + struct pps_kwidth_compat assert_width; /* assert pulse-width time and seq. num. */ + struct pps_kwidth_compat clear_width; /* clear pulse-width time and seq. num. */ }; struct pps_kparams { @@ -96,6 +110,11 @@ struct pps_kparams { #define PPS_CAPTURECLEAR 0x02 /* capture clear events */ #define PPS_CAPTUREBOTH 0x03 /* capture assert and clear events */ +/* Pulse-width calculation */ +#define PPS_WIDTHASSERT 0x04 /* calculate assert width */ +#define PPS_WIDTHCLEAR 0x08 /* calculate clear width */ +#define PPS_WIDTHBOTH 0x0c /* calculate assert and clear width */ + #define PPS_OFFSETASSERT 0x10 /* apply compensation for assert event */ #define PPS_OFFSETCLEAR 0x20 /* apply compensation for clear event */ From patchwork Sun Jun 25 14:21:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 112599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6942270vqr; Sun, 25 Jun 2023 07:25:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GqKliunyxDF0hCYonIJt4STx9FVNxmMZhsp2BmqzjMH/KeGjxobLweOijykQ7g9HAMyAC X-Received: by 2002:a92:c60a:0:b0:340:6db8:e814 with SMTP id p10-20020a92c60a000000b003406db8e814mr28010641ilm.22.1687703101500; Sun, 25 Jun 2023 07:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687703101; cv=none; d=google.com; s=arc-20160816; b=CYdhbUhO3n9rAaDlbhHZmkEXKbTTMpV4c+Bl61l98tjSsgZ6RudXd3R9OydOFTR/o5 2l5lBBKFmhEVkCHwhY3N3SZ4/H7xqjvTESNygG4h8SfJQWvBBcWKVr4pJpA3hn4IAwzD wR5i3AyCgl/8H09cliiOGWj9CS1d5MkzmchzN4inNK1ZtP17ZrxuEwGPBTuh66jpPwV2 Pjp/pcTdNTCNx4+1zulz4WHJfquLqKwMMa0nlwkGHOP3m9k2J+t3sDoP1VnXkkE1Bee9 IC7TKYRWr0ZDfoQNdVLeqk/9nVs2VPoIh0eka5/Inu9QWu8azNrXiAmvS+F/x1M9Mgvi bp5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=54pb3GiuxGz5vr3/T2UHe4INajkdgiM6+/jwG7r8Q6Y=; fh=/9rTqK0zswNCgLim86exJ2HNVgKWrjH8Cr/T0xC8qdo=; b=G+uVl1YnvI0BnSBshCspCt0TeKCg6f1nHZsxhaxKNtHaQDEOyE841Obe0yeSsoRsCF nsxLyvhM4+RyzoIeYGL/ZlhVDMoWEObsoTnm9fsntxUBWSJ5CAGXMARZ2xZhz+8Rzrh8 ApW3RUhgG/+a5s6PKu6oZrpZ5ft8hPFwSEfA9Cc0pqRaFtJBtkOSqpt9hkw5xr0L5JiH AlyLKy9h2tnm9lCASmmroGJl7r9F66+STAPIiduls/qLf9yZ0jStlHr1Bnbg5MHI98oc u/wtwcPPzkmQHxASxRZ8RIUQWZzh4YkYIRrkrhxFuZWkvKSnePRVzdvXmz6bf63NPCux 9Jdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=MVrmVkpr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f28-20020a63101c000000b0053f23ffad1csi3344870pgl.544.2023.06.25.07.24.48; Sun, 25 Jun 2023 07:25:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=MVrmVkpr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbjFYOVm (ORCPT + 99 others); Sun, 25 Jun 2023 10:21:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbjFYOVk (ORCPT ); Sun, 25 Jun 2023 10:21:40 -0400 Received: from smtp-fw-52005.amazon.com (smtp-fw-52005.amazon.com [52.119.213.156]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7558E43; Sun, 25 Jun 2023 07:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1687702900; x=1719238900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=54pb3GiuxGz5vr3/T2UHe4INajkdgiM6+/jwG7r8Q6Y=; b=MVrmVkprZ6/H+VFEa4d0vEKEQPa/KibNPq7NFTUwzGza5JznxP+/A+fs 3qNE+R6cwttnFkBdYWjgXL+DKCC3wiUXf0SHuKgJKnhnWe+N61mbjNam7 xtT9OjTjg77Nsvv+JwatjngfTI3Opa6C5eEWskfAugrfkiBtk+209CEzr M=; X-IronPort-AV: E=Sophos;i="6.01,157,1684800000"; d="scan'208";a="589290998" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2b-m6i4x-7fa2de02.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-52005.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 14:21:37 +0000 Received: from EX19D014EUA003.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2b-m6i4x-7fa2de02.us-west-2.amazon.com (Postfix) with ESMTPS id 1B0C940D44; Sun, 25 Jun 2023 14:21:36 +0000 (UTC) Received: from EX19D040EUB004.ant.amazon.com (10.252.61.108) by EX19D014EUA003.ant.amazon.com (10.252.50.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 25 Jun 2023 14:21:34 +0000 Received: from EX19MTAUEB001.ant.amazon.com (10.252.135.35) by EX19D040EUB004.ant.amazon.com (10.252.61.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 25 Jun 2023 14:21:34 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.252.135.35) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sun, 25 Jun 2023 14:21:34 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 153DE4F0C; Sun, 25 Jun 2023 14:21:34 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , Subject: [PATCH 2/5] dt-bindings: pps: pps-gpio: introduce capture-clear property Date: Sun, 25 Jun 2023 14:21:31 +0000 Message-ID: <20230625142134.33690-3-farbere@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230625142134.33690-1-farbere@amazon.com> References: <20230625142134.33690-1-farbere@amazon.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769684967490408750?= X-GMAIL-MSGID: =?utf-8?q?1769684967490408750?= Add a new optional "capture-clear" boolean property. When present, PPS clear events shall also be reported. Signed-off-by: Eliav Farber --- Documentation/devicetree/bindings/pps/pps-gpio.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/pps/pps-gpio.txt b/Documentation/devicetree/bindings/pps/pps-gpio.txt index 9012a2a02e14..8d588e38c44e 100644 --- a/Documentation/devicetree/bindings/pps/pps-gpio.txt +++ b/Documentation/devicetree/bindings/pps/pps-gpio.txt @@ -14,6 +14,10 @@ Additional required properties for the PPS ECHO functionality: Optional properties: - assert-falling-edge: when present, assert is indicated by a falling edge (instead of by a rising edge) +- capture-clear: when present, report also PPS clear events, which is the + opposite of the assert edge (if assert is rising-edge then + clear is falling-edge and if assert is falling-edge then + clear is rising-edge). Example: pps { From patchwork Sun Jun 25 14:21:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 112601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6943949vqr; Sun, 25 Jun 2023 07:29:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7UsOqieKUPywmR47aGUnjw5T3mp5yZuxfDRMswI+T7e2ZYf56R8W/HGxLUbmD7VSza5syE X-Received: by 2002:a05:6a20:244a:b0:10e:440:6d36 with SMTP id t10-20020a056a20244a00b0010e04406d36mr32443790pzc.1.1687703361189; Sun, 25 Jun 2023 07:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687703361; cv=none; d=google.com; s=arc-20160816; b=Ni/IaETB71CoF9SJmtseL+Zy/kR0RJycdXLYwFwJyL4eq65m4bb1TzVNtm2NYKVvof jAhCl0FysKZVhUkSxV7+yVN9na7rU3ScJ8A2Xz+aOdZkU/S9225EDKD0GOUh3p45gyJ+ +HliZurUJvOo4LcCH9Wv3TETyfeigOB7FMCdac95aoZImUemJDkqSHTbhpgEljm0a8jA AUDIJZf0wABAzWpfkVDoxK44SkChb136Mv3ySlowUm//4msoKKCOTGQ+zhbPOxbIT8y7 tG434jN89jJZqplfNjBEYMWWhOnzF/BDerSvacilUwnxQUMPM1Xmr0yIVACGLD2w12g2 syrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hzkmriAJdrDXAPOXkzYgl+u0BMBeF3csMzsxYQTdpVE=; fh=/9rTqK0zswNCgLim86exJ2HNVgKWrjH8Cr/T0xC8qdo=; b=re0EZbrc2deNpoV+TAZBCjpDRQKkN1a3NA61WG24tzy7iQDZ/6YyqOnd1Eois80IdS oa80IvskVUw7sN8G6CbjSVbqGtOXRx/dK2rWJIA3dyPDb5qPeJGnmQyBlE6RgE6fO7xz yY9g4IoqpstIV6o5LUTgMfXJ/QnWeqj7eZAXAi26l+TyQQLq38o5NKBQ2KONcl3PKxiz q+JKy5IRTj8bEh0ElBa5lDfQBKAKxN+0M6/Ypifrx185+1zBsT1YNdY7cG3agNyIokYn LGD9KfhxswEyfkuP0ZWTfjko4l+uMnjWz+q1oWtyFtXqPytFBtX5/r8kwtig6XwAc/BI VELw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=v+j4JMfZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 201-20020a6301d2000000b005537d2a84f9si3504942pgb.400.2023.06.25.07.28.57; Sun, 25 Jun 2023 07:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=v+j4JMfZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230329AbjFYOVr (ORCPT + 99 others); Sun, 25 Jun 2023 10:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbjFYOVl (ORCPT ); Sun, 25 Jun 2023 10:21:41 -0400 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FACDE4C; Sun, 25 Jun 2023 07:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1687702900; x=1719238900; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hzkmriAJdrDXAPOXkzYgl+u0BMBeF3csMzsxYQTdpVE=; b=v+j4JMfZ7mgF092SNpNm3yrnhkLLXRlEk5L62XHeiEMLTiawXfi6av28 yhX3SXnnZvQo0dj7zx77YGSxrcAAuLaVXyjFDmezGXQjxcPbNswqM7B4r zbejXwDy1uSMCR8gOpkVkvmeCWqBodmRpVGriD/V+15aQsj6bsjKeGg0s o=; X-IronPort-AV: E=Sophos;i="6.01,157,1684800000"; d="scan'208";a="336051270" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-m6i4x-5eae960a.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 14:21:37 +0000 Received: from EX19D005EUA004.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2c-m6i4x-5eae960a.us-west-2.amazon.com (Postfix) with ESMTPS id EEDCB40AEB; Sun, 25 Jun 2023 14:21:35 +0000 (UTC) Received: from EX19MTAUEA001.ant.amazon.com (10.252.134.203) by EX19D005EUA004.ant.amazon.com (10.252.50.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 25 Jun 2023 14:21:34 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.252.134.102) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sun, 25 Jun 2023 14:21:34 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 18A034F0D; Sun, 25 Jun 2023 14:21:34 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , Subject: [PATCH 3/5] pps: clients: gpio: add option to set capture-clear from device-tree Date: Sun, 25 Jun 2023 14:21:32 +0000 Message-ID: <20230625142134.33690-4-farbere@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230625142134.33690-1-farbere@amazon.com> References: <20230625142134.33690-1-farbere@amazon.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769685239572353567?= X-GMAIL-MSGID: =?utf-8?q?1769685239572353567?= Enable capture clear events if "capture-clear" boolean property exists in device-tree. Signed-off-by: Eliav Farber --- drivers/pps/clients/pps-gpio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c index 2f4b11b4dfcd..a61dc1299ce9 100644 --- a/drivers/pps/clients/pps-gpio.c +++ b/drivers/pps/clients/pps-gpio.c @@ -112,6 +112,7 @@ static int pps_gpio_setup(struct device *dev) data->assert_falling_edge = device_property_read_bool(dev, "assert-falling-edge"); + data->capture_clear = device_property_read_bool(dev, "capture-clear"); data->echo_pin = devm_gpiod_get_optional(dev, "echo", GPIOD_OUT_LOW); if (IS_ERR(data->echo_pin)) From patchwork Sun Jun 25 14:21:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 112602 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6954481vqr; Sun, 25 Jun 2023 07:54:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4oBMCnv7sPNdRN7eqwJHlaAhXIgFAW1OMubqbVIJI2sCg/JS21QaQhKChnotgQ8etxnqqZ X-Received: by 2002:a17:903:22c2:b0:1b5:4164:a5b2 with SMTP id y2-20020a17090322c200b001b54164a5b2mr3373560plg.36.1687704891615; Sun, 25 Jun 2023 07:54:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687704891; cv=none; d=google.com; s=arc-20160816; b=mT5CCC+KgXLCmZpWOwG5fUhx8eoAsFzQRhXI1p2b5nnrS0U/0fMfSiuK17/S5+CRlr fg/Vg5Kh/0IxUX2BVPlLZeQ2305s0gzuUqPOM/S/jQDbr2qd+zb+Wo9JhpWIzDSWvT3P +QbCsajFuoF1TmJcYQeB0nwdVv25lE62JnlSM64tCdh0mj9Y/253yHymlDPDGpA6oO+S XfsIyoICaxIcxZ71Y9QWSZNoYyok9kDTd6ILenPjrczNkY1KtTQ9DXFgC10cgQO6YFla NxoQQhxDMxtq3yj+dRDirnbVbeNHPi3vzBA/uKTyVgs4cJVSUiPDl5tWM7zJsIrrNj76 yyRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xOf7NZnUQximwIOSiAVcKVvthWSLkf2RWP5JPwMyfkM=; fh=/9rTqK0zswNCgLim86exJ2HNVgKWrjH8Cr/T0xC8qdo=; b=lcU0e9e634wxzRWjJbITWPC4FonO0HU7epC46F3f9gaK2Tg5HI0pdwFtumMuXvDUJT eLCh1CtypNIDwSPcjEQzIJ1oIgID2qcJBPVc9y23+FQwden/jRbBPySs3Pxz2qEMOt1/ tw7aJ1yUemhfPmKQ9LcjddtOwQ/UfUK9S92I8W+pCwBUYyl+/SUQckFUeO9idBthGwl3 lNAqYTCO2/rvWlObph2xy2sDf8jwLxc/yy8kLeHbZbppkj0Lwj5tdzVyTlFxuaqcrzhD QRIW2G5ak1P662Ah8vbbJOXJGkgoc/AWnm4NPY1iOpnghjOMtWo3bR7hfgm/g+5Uzhm9 CDPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=hlCan534; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a17090a035800b002590f26818asi5997583pjf.0.2023.06.25.07.54.29; Sun, 25 Jun 2023 07:54:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=hlCan534; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbjFYOVu (ORCPT + 99 others); Sun, 25 Jun 2023 10:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjFYOVl (ORCPT ); Sun, 25 Jun 2023 10:21:41 -0400 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4EF4E4E; Sun, 25 Jun 2023 07:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1687702901; x=1719238901; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xOf7NZnUQximwIOSiAVcKVvthWSLkf2RWP5JPwMyfkM=; b=hlCan534UHgxcqsIhzGCfYS7fTjpM9iVqAOu3rONS9iU7GSRxGXD4hzy gQCa+7xIiRSFeyj4SF5NpC0RuKjcU9Lf59QN3ZPqOt9Wip+FX3/tQ10LL H+G3cO8wQTiaD9BtUZUNZMkfs2T/9k8qYXSjePKhoj8MXfzrctKtvcfzK s=; X-IronPort-AV: E=Sophos;i="6.01,157,1684800000"; d="scan'208";a="340868763" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-m6i4x-5eae960a.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 14:21:38 +0000 Received: from EX19D005EUB004.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2c-m6i4x-5eae960a.us-west-2.amazon.com (Postfix) with ESMTPS id 6FE8D40BBE; Sun, 25 Jun 2023 14:21:35 +0000 (UTC) Received: from EX19MTAUEB001.ant.amazon.com (10.252.135.35) by EX19D005EUB004.ant.amazon.com (10.252.51.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 25 Jun 2023 14:21:34 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.252.135.35) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sun, 25 Jun 2023 14:21:34 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 1C00B4F91; Sun, 25 Jun 2023 14:21:34 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , Subject: [PATCH 4/5] dt-bindings: pps: pps-gpio: introduce pulse-width properties Date: Sun, 25 Jun 2023 14:21:33 +0000 Message-ID: <20230625142134.33690-5-farbere@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230625142134.33690-1-farbere@amazon.com> References: <20230625142134.33690-1-farbere@amazon.com> MIME-Version: 1.0 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769686844332688326?= X-GMAIL-MSGID: =?utf-8?q?1769686844332688326?= Add two new optional properties to calculate PPS pulse-width in nano seconds: - assert-pulse-width - clear-pulse-width Signed-off-by: Eliav Farber --- Documentation/devicetree/bindings/pps/pps-gpio.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/pps/pps-gpio.txt b/Documentation/devicetree/bindings/pps/pps-gpio.txt index 8d588e38c44e..9ecfd5fb3b63 100644 --- a/Documentation/devicetree/bindings/pps/pps-gpio.txt +++ b/Documentation/devicetree/bindings/pps/pps-gpio.txt @@ -18,6 +18,12 @@ Optional properties: opposite of the assert edge (if assert is rising-edge then clear is falling-edge and if assert is falling-edge then clear is rising-edge). +- assert-pulse-width: when present, assert pulse width will be calculated in + nano seconds. + It should be enabled only if 'capture-clear' is enabled. +- clear-pulse-width: when present, clear pulse width will be calculated in + nano seconds. + It should be enabled only if 'capture-clear' is enabled. Example: pps { From patchwork Sun Jun 25 14:21:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Farber, Eliav" X-Patchwork-Id: 112608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6962836vqr; Sun, 25 Jun 2023 08:10:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72P3kN3vfzM8jNrfJuL4tGEeP2FB3pE4CEo/Alke7+VZFFd4eJtrMwRxS0HWcM136X0xHq X-Received: by 2002:aa7:c446:0:b0:51b:e834:9265 with SMTP id n6-20020aa7c446000000b0051be8349265mr8388539edr.33.1687705800920; Sun, 25 Jun 2023 08:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687705800; cv=none; d=google.com; s=arc-20160816; b=SF6E6tvJj1CLlysFRYab4aPJjGCr3/MlYMLWF8qg/pffCMeCP01TZDMsUacl/amHrb PchTwXHCBzuEie1ACc6TEWOuk+PN9q1399hA8ufRzNq0LE8uJIYStdoTp/TjUvNBKcKg b0mMV6CxSwOxs+MxkPrwq9iAfVcv+6TwKG0oECX3qZmIO5C5lbHbmjAnHfxkFgojLuSh FKeltUTMqRI4/pMqJFtQUoWAazlGryuW4X22dAXseNApRES0h+1GqU3StsArRdhWaID2 OibROO2Ljz3zacND25VdKme76CavbeXaaT7Qz77JGJK9/De5EJAFwYJ16Gg0I7m8vWTz EgGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MvMgTuAn0uYdFTGp+Tc21ooe+rx3n9Gtbjp0LnEzoh8=; fh=/9rTqK0zswNCgLim86exJ2HNVgKWrjH8Cr/T0xC8qdo=; b=dV3//quwegyQEe7hyuu74MidzXNq+rRZ4IKDeL6FmmyyRASZRCWuUqoapD4aU0Jeda UE7ItjTOMK89IUo4St6BKcmirK/JIHHvu2GXcr2Ekc0DpeXqxTDhtQ+BFCnQFyPebwJo 9sSqqr82W3kq9qnsMLvrAP9kd9NszHtmo8Ban0lPiqNgDqJ3CGlz9y0cCowl8qelQw9U nug5geY6LhRyBpSWDB7Q8al7CJcMKSI6FPqVwluXy4Al/NbdTprQd9QBafv/KUNxdjpY AlNGiJhgZGUVLDZkOfndGls7tiTi93kEfGCDJizknie3MsHQtgJuaDP10DdcqwR/ZE3o Qj9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=GgKMlIDb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n24-20020a056402061800b0051d95b0e270si637892edv.377.2023.06.25.08.09.34; Sun, 25 Jun 2023 08:10:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=GgKMlIDb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbjFYOVo (ORCPT + 99 others); Sun, 25 Jun 2023 10:21:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjFYOVk (ORCPT ); Sun, 25 Jun 2023 10:21:40 -0400 Received: from smtp-fw-80009.amazon.com (smtp-fw-80009.amazon.com [99.78.197.220]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF051B1; Sun, 25 Jun 2023 07:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1687702899; x=1719238899; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MvMgTuAn0uYdFTGp+Tc21ooe+rx3n9Gtbjp0LnEzoh8=; b=GgKMlIDbbeVWYpb8SvoHoqsXCHUOtOPJcGEBCwJ8nexHvGl5hssu3K6P FhiJBn6JPQMhK6vCM7370V7IkFvSKc9HNyIkTRyqPQwG+eOt4tA4Z6mfy 24WNvX1QAylO4QbiWyQU/yG3JYkv7GmfmKqOcmo3P/Zu4rLPF/m6PMgA2 s=; X-IronPort-AV: E=Sophos;i="6.01,157,1684800000"; d="scan'208";a="12280813" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-m6i4x-fa5fe5fb.us-west-2.amazon.com) ([10.25.36.214]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 14:21:37 +0000 Received: from EX19D016EUA004.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-pdx-2c-m6i4x-fa5fe5fb.us-west-2.amazon.com (Postfix) with ESMTPS id F3A3F40D47; Sun, 25 Jun 2023 14:21:36 +0000 (UTC) Received: from EX19D034EUC001.ant.amazon.com (10.252.61.138) by EX19D016EUA004.ant.amazon.com (10.252.50.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 25 Jun 2023 14:21:35 +0000 Received: from EX19MTAUEB001.ant.amazon.com (10.252.135.35) by EX19D034EUC001.ant.amazon.com (10.252.61.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Sun, 25 Jun 2023 14:21:35 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.252.135.35) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sun, 25 Jun 2023 14:21:35 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 1F5066DA4; Sun, 25 Jun 2023 14:21:34 +0000 (UTC) From: Eliav Farber To: , , , , , , CC: , , , , , , , Subject: [PATCH 5/5] pps: clients: gpio: enable pps pulse-width calculations based on device-tree Date: Sun, 25 Jun 2023 14:21:34 +0000 Message-ID: <20230625142134.33690-6-farbere@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230625142134.33690-1-farbere@amazon.com> References: <20230625142134.33690-1-farbere@amazon.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769687798048417012?= X-GMAIL-MSGID: =?utf-8?q?1769687798048417012?= This change adds setting of PPS_WIDTHASSERT and PPS_WIDTHCLEAR modes to enable PPS pulse-width calculation. Width calculation will be enabled if - assert-pulse-width - clear-pulse-width boolean properties exist in device-tree. Signed-off-by: Eliav Farber --- drivers/pps/clients/pps-gpio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pps/clients/pps-gpio.c b/drivers/pps/clients/pps-gpio.c index a61dc1299ce9..ca4b8047e924 100644 --- a/drivers/pps/clients/pps-gpio.c +++ b/drivers/pps/clients/pps-gpio.c @@ -33,6 +33,8 @@ struct pps_gpio_device_data { struct timer_list echo_timer; /* timer to reset echo active state */ bool assert_falling_edge; bool capture_clear; + bool assert_pulse_width; + bool clear_pulse_width; unsigned int echo_active_ms; /* PPS echo active duration */ unsigned long echo_timeout; /* timer timeout value in jiffies */ }; @@ -113,6 +115,10 @@ static int pps_gpio_setup(struct device *dev) data->assert_falling_edge = device_property_read_bool(dev, "assert-falling-edge"); data->capture_clear = device_property_read_bool(dev, "capture-clear"); + data->assert_pulse_width = + device_property_read_bool(dev, "assert-pulse-width"); + data->clear_pulse_width = + device_property_read_bool(dev, "clear-pulse-width"); data->echo_pin = devm_gpiod_get_optional(dev, "echo", GPIOD_OUT_LOW); if (IS_ERR(data->echo_pin)) @@ -186,6 +192,10 @@ static int pps_gpio_probe(struct platform_device *pdev) if (data->capture_clear) data->info.mode |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR | PPS_ECHOCLEAR; + if (data->assert_pulse_width) + data->info.mode |= PPS_WIDTHASSERT; + if (data->clear_pulse_width) + data->info.mode |= PPS_WIDTHCLEAR; data->info.owner = THIS_MODULE; snprintf(data->info.name, PPS_MAX_NAME_LEN - 1, "%s.%d", pdev->name, pdev->id); @@ -199,6 +209,10 @@ static int pps_gpio_probe(struct platform_device *pdev) pps_default_params = PPS_CAPTUREASSERT | PPS_OFFSETASSERT; if (data->capture_clear) pps_default_params |= PPS_CAPTURECLEAR | PPS_OFFSETCLEAR; + if (data->assert_pulse_width) + pps_default_params |= PPS_WIDTHASSERT; + if (data->clear_pulse_width) + pps_default_params |= PPS_WIDTHCLEAR; data->pps = pps_register_source(&data->info, pps_default_params); if (IS_ERR(data->pps)) { dev_err(dev, "failed to register IRQ %d as PPS source\n",