From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DC4BC25B07 for ; Wed, 10 Aug 2022 14:07:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232958AbiHJOHq (ORCPT ); Wed, 10 Aug 2022 10:07:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232902AbiHJOHp (ORCPT ); Wed, 10 Aug 2022 10:07:45 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B23E6E2CB for ; Wed, 10 Aug 2022 07:07:42 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id n4so16121382wrp.10 for ; Wed, 10 Aug 2022 07:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=+X/pid24gIjSOOJVEmO9iW9i2TMfPX6OSEZMbd1Ah4A=; b=gnyGClV2Eo+ylgbSznKAc5xS0/tmKZAO4UhCDTCl41U/p55TPKgwPR205jZ/5T0NNe mY3nqNo1qLOKluMW3UrnNj8ixMO4DPxNfeG78dWzCFlMpZwy0An3nPbqnMH/Pu3k3jHe K6GZFuvkoavj36ycCk9OyOKuS8RV7Hz+XfMN4mWzTEoU6bVjwG+pectg5fg8LeXHYfj+ bvKrrxRZuCt+QCZmTWQeXmDgN9yYvDHPiFy4eo6rhPjVWfARxcEdDk7WVDHB5ZnWP2er IZQRHo7eE3F4P/gUv3jyBC86Buv49fczLcrVszX/rb860r6Li9Nh0mPfO7PrlPsMhvOq Usgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=+X/pid24gIjSOOJVEmO9iW9i2TMfPX6OSEZMbd1Ah4A=; b=zwNh64iTfH847Q8263QZda5XdJgutREPG4DEAP71OIB5C7uePd3M9abLQ1NPz56e64 0shppw/FahWnNIv30+bRxZgcfe4WgatVoKxF/c6TyH7MlHGMQFLlG/oAjj7mHY1uR5cM RE/pWR/EZqqNVwqtbzHD+r4N5JpHbEeWoyuzsKaVyI3fTF6cf8c3WCNrw6LclufovQXl 7lad+66NjfNpTq7eds0Ww5Iti4ZFB0ERWQHjOabi/IZajHrXWi8ff5e3CZRq805j2Jri Mb0wnU/m3kh6S6KUtqiDGmeG/4AW4QjClasuGwa5YOEK0OUHUNWI+vS40EPsYYFZSsmY rXMg== X-Gm-Message-State: ACgBeo15upET5RGy96rmFsus3EXZvgFta9ZyRrVmaEE1Q3HtzreGSF9a wUxAEhkettM+FCf1ABrAbAUlJA== X-Google-Smtp-Source: AA6agR568HfoJRNkXemPCbfg6p3C2Czwqa7Z3xR7SRRYgOaUQkt3jPpCLL397aCfk2kqvqSLfbNdaQ== X-Received: by 2002:a05:6000:2a4:b0:220:687a:cda9 with SMTP id l4-20020a05600002a400b00220687acda9mr17324057wry.187.1660140460789; Wed, 10 Aug 2022 07:07:40 -0700 (PDT) Received: from localhost.localdomain (32.31.102.84.rev.sfr.net. [84.102.31.32]) by smtp.gmail.com with ESMTPSA id o15-20020adfcf0f000000b0021d6a520ce9sm16258229wrj.47.2022.08.10.07.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 07:07:39 -0700 (PDT) From: Julien Panis To: vilhelm.gray@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, mranostay@ti.com, Julien Panis Subject: [PATCH v4 0/3] ECAP support on TI AM62x SoC Date: Wed, 10 Aug 2022 16:07:21 +0200 Message-Id: <20220810140724.182389-1-jpanis@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The Enhanced Capture (ECAP) module can be used to timestamp events detected on signal input pin. It can be used for time measurements of pulse train signals. ECAP module includes 4 timestamp capture registers. For all 4 sequenced timestamp capture events (1->2->3->4->1->...), edge polarity (falling/rising edge) can be selected. This driver leverages counter subsystem to : - select edge polarity for all 4 capture events (event mode) - log timestamps for each capture event Event polarity, and CAP1/2/3/4 timestamps give all the information about the input pulse train. Further information can easily be computed : period and/or duty cycle if frequency is constant, elapsed time between pulses, etc... Modifications since v3: - Migrate driver from IIO to Counter subsystem - Minor modification in yaml ($id) to match Counter subsystem - Add ABI documentation Userspace commands : ### SIGNAL ### cd /sys/bus/counter/devices/counter0/signal0 # Get available polarities for each capture event cat polarity1_available cat polarity2_available cat polarity3_available cat polarity4_available # Get polarity for each capture event cat polarity1 cat polarity2 cat polarity3 cat polarity4 # Set polarity for each capture event echo rising > polarity1 echo falling > polarity2 echo rising > polarity3 echo falling > polarity4 ### COUNT ### cd /sys/bus/counter/devices/counter0/count0 # Run ECAP echo 1 > enable # Get current timebase counter value cat count # Get captured timestamps cat capture1 cat capture2 cat capture3 cat capture4 # Note that counter watches can also be used to get # data from userspace application # -> see tools/counter/counter_example.c # Stop ECAP echo 0 > enable Julien Panis (3): dt-binding: counter: add ti,am62-ecap-capture.yaml Documentation: ABI: add sysfs-bus-counter-ecap counter: capture-tiecap: capture driver support for ECAP .../ABI/testing/sysfs-bus-counter-ecap | 64 ++ .../counter/ti,am62-ecap-capture.yaml | 61 ++ drivers/counter/Kconfig | 14 + drivers/counter/Makefile | 1 + drivers/counter/capture-tiecap.c | 634 ++++++++++++++++++ include/uapi/linux/counter.h | 2 + 6 files changed, 776 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-counter-ecap create mode 100644 Documentation/devicetree/bindings/counter/ti,am62-ecap-capture.yaml create mode 100644 drivers/counter/capture-tiecap.c -- 2.25.1