Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp783001imu; Tue, 11 Dec 2018 07:31:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/XahpOljuJX0Iy6cDhQG01OgABxErJarfMWMUd/TxgDvftjB43PXKaBFS3SQEE1UvQTWxfI X-Received: by 2002:a63:e001:: with SMTP id e1mr15082883pgh.39.1544542281168; Tue, 11 Dec 2018 07:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544542281; cv=none; d=google.com; s=arc-20160816; b=hGTkear7gPuj0Vk8fwqHwyVFnG6TjDHssJMoLQhWyYqbRpmbR+Dupt++fL2KBLmSZk g1GO2LhCQ6GSlX6HZuwvUOUS5hM5Z1fw0wfuDd7Bi1VLo6SvSWihhfYspWWFNrNl9Hmd HKKt+FIHQUZxGPFozdzdYXP0xcdrjShLykV2bpfALbcBmYBa7gS6WIkKN9JZJB2eNjCT pl7RRrIqnVzdnyvKviN5I9yWutHdOXswxUzmnhWhBDPzOnCFUA8MkbhW3+Zp3R6Sk91n fn5oVDyJ2p5m205ksR92KOZan2wzGPm5LQEOeRnYTEIvqdsERFBJOpHmUgDS4wQRGNVh hWQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=w+P68BJM+mndLnrN08r8f9prR2Rft8Q09PuVUfVmCyw=; b=reLlx/4tCaV0y1xWXheBm1X3B5Ab//8TyuBAUT3RGWFV1TSMFrRDEsxw9TZxm6bOTw Ff2/fhbSyilOezAvhoaPvSZvDs0txc1w6wXrHlHemDuPYKuFnyh9jgcF9mI9uglFpOdI uW1RR8AvVDQfnpaonCNJLEWL2oxChV8ew2wyHzFavJ+taf+uEcJG68ULRsHuEbmJVnQy lPBXTT27PdG49Z/HH0bEeRCe6NzC5BtSlR/N8R3PfefvmkPk9agM0O4yCdxHC6bYu92/ 9cEh1jOU1dzW9P7UrpnmUpaDi7f197oSQH3ToBWQOQnrVJLr2EYxx8g6tph+mJ/oolHR D8jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pSVKxJBn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d9si11909626pgb.105.2018.12.11.07.30.43; Tue, 11 Dec 2018 07:31:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pSVKxJBn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727028AbeLKP3T (ORCPT + 99 others); Tue, 11 Dec 2018 10:29:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:49094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726417AbeLKP3R (ORCPT ); Tue, 11 Dec 2018 10:29:17 -0500 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C5FCF20851; Tue, 11 Dec 2018 15:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544542156; bh=AtUMkIE4IETPqnqTkclVVj9L1zrkVt/67Wobo+vfbpI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=pSVKxJBnhAtz00o6VydTK1HsfKZWVQikgIQsiLBcHvJYGiawM4KRjEE3mY+NMr4a6 xTRHE8yI1k9OhaAZrKGe0yFYxZHtS8YZtESUNBHM8DEWql0cNKLCUr9j0S+jMguyiQ Yb24JDs/qy8UFDkDMlEvcoWrHxd8drqSpvwYjY/I= Received: by mail-qt1-f171.google.com with SMTP id l11so16839308qtp.0; Tue, 11 Dec 2018 07:29:16 -0800 (PST) X-Gm-Message-State: AA+aEWagc/zIC066uFTyrec5NTQqMeXQrwOrCa1cKlIkYPjEARN52C6c hA/vJ8urFBAZHdmQBH6N0AG/GG7BncBPeGTxQA== X-Received: by 2002:ac8:2d2b:: with SMTP id n40mr15802303qta.38.1544542156001; Tue, 11 Dec 2018 07:29:16 -0800 (PST) MIME-Version: 1.0 References: <20181122094602.5156-1-tom@aussec.com> <20181122094602.5156-2-tom@aussec.com> <20181122094602.5156-3-tom@aussec.com> <20181122094602.5156-4-tom@aussec.com> <20181127150629.10795h1esqtc53ut@aussec.com> <20181211131716.931947v9gya4ajos@www.aussec.com> In-Reply-To: <20181211131716.931947v9gya4ajos@www.aussec.com> From: Rob Herring Date: Tue, 11 Dec 2018 09:29:04 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 3/4] dt-bindings: pps: pps-gpio PPS ECHO implementation To: Tom Burkart Cc: "linux-kernel@vger.kernel.org" , devicetree@vger.kernel.org, lukas@fridolin.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 10, 2018 at 8:17 PM tom burkart wrote: > > Quoting Rob Herring : > > > On Mon, Nov 26, 2018 at 10:06 PM tom burkart wrote: > >> > >> Quoting Rob Herring : > >> > >> > On Thu, Nov 22, 2018 at 3:49 AM Tom Burkart wrote: > >> >> > >> >> This patch implements the device tree changes required for the pps > >> >> echo functionality for pps-gpio, that sysfs claims is available > >> >> already. > >> >> > >> >> This patch was originally written by Lukas Senger as part of a masters > >> >> thesis project and modified for inclusion into the linux kernel by Tom > >> >> Burkart. > >> >> > >> >> Signed-off-by: Lukas Senger > >> >> Signed-off-by: Tom Burkart > >> >> --- > >> >> Documentation/devicetree/bindings/pps/pps-gpio.txt | 9 +++++++++ > >> >> 1 file changed, 9 insertions(+) > >> >> > >> >> diff --git a/Documentation/devicetree/bindings/pps/pps-gpio.txt > >> >> b/Documentation/devicetree/bindings/pps/pps-gpio.txt > >> >> index 1155d49c2699..e09f6f2405c5 100644 > >> >> --- a/Documentation/devicetree/bindings/pps/pps-gpio.txt > >> >> +++ b/Documentation/devicetree/bindings/pps/pps-gpio.txt > >> >> @@ -7,10 +7,15 @@ Required properties: > >> >> - compatible: should be "pps-gpio" > >> >> - gpios: one PPS GPIO in the format described by ../gpio/gpio.txt > >> >> > >> >> +Additional required properties for the PPS ECHO functionality: > >> >> +- echo-gpios: one PPS ECHO GPIO in the format described by > >> ../gpio/gpio.txt > >> >> +- echo-active-ms: duration in ms of the active portion of the echo pulse > >> >> + > >> >> Optional properties: > >> >> - assert-falling-edge: when present, assert is indicated by a > >> falling edge > >> >> (instead of by a rising edge) > >> >> - capture-clear: when present, also capture the PPS clear event > >> >> +- invert-pps-echo: when present, invert the PPS ECHO pulse > >> > > >> > Why do you need this? Can't you just make the echo gpio GPIO_ACTIVE_LOW? > >> > > >> > BTW, using the flag probably should have been done for > >> > 'assert-falling-edge' as well. > >> > >> The hardware I use expects a positive-going echo pulse, however, it > >> was really easy to give users the option to have it inverted in case > >> they use different hardware that expects a negative-going edge. > > > > It will be even easier to implement if you use GPIO_ACTIVE_LOW or > > GPIO_ACTIVE_HIGH as appropriate. If the flag is set appropriately, > > then gpiod_set_value(gpio, 1) asserts the pulse and > > gpiod_set_value(gpio, 0) deasserts it no matter which way the h/w is > > wired. You can then get rid of invert_pps_echo in the driver. > > Hi Rob, > I have looked at the appropriate changes to my code to implement the > above. However, there is no GPIO_ACTIVE_* as part of the gpiod_flags > enum (include/linux/gpio/consumer.h). > > What am I missing? You don't need to know in the driver. You set the gpio state to 1 for active, 0 for inactive and that does the right thing based on the flag in the DT. IOW, if the DT defines the GPIO as active low, then setting the gpio state to 1 will result in the GPIO being 0V. It's a bit annoying and confusing at first until you realize the driver can just handle either polarity transparently. Rob