Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp224522rwb; Wed, 10 Aug 2022 07:21:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR4tEpYkvO78YoT6FMs2O7TarZv68Fkam9Vd8hMLmkNckSkTWeN4CMx7HZqwnvUPVFOhpIXF X-Received: by 2002:a17:90a:8808:b0:1f7:4bd3:3760 with SMTP id s8-20020a17090a880800b001f74bd33760mr4051522pjn.170.1660141304033; Wed, 10 Aug 2022 07:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660141304; cv=none; d=google.com; s=arc-20160816; b=hMVSo4xy5vxO43DO9+Qv3wGS0AH33dl2rV/AhAhIJtKfn5dbmH54EkhOdOJPZgr4Br kiIGBi0xt6y7PtLGAOvnoT9XCyfzBqYnV0tlT9k0sFxx9xgFStk+OvvWS+CNKLGqJb1o PzkkQZTnBGWPydL98TBiISTthvAK/UpXwycR6Ij7fON8NKBCS4zhaq4BgYIzF+HmBD9k 9ZvJ57WlXWp1b6wmh0U39DNhPY0G5P5qnKlbX4O3XKKjnNRYjPHICwPrAAVti+r89lJy L6ICF5MO4F12oJ7qeQT2t2hq4LADLY+RNGkr3jUOlBIyZtQHw5BrolHh8phKAM2UaRy5 rPVA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=+X/pid24gIjSOOJVEmO9iW9i2TMfPX6OSEZMbd1Ah4A=; b=Rg1S5BpYk7Ic4qSpatFP/+frcqYJwdz06S3Ic4RSc4Rhzp3wPByR8XlTp1dN8a1fIQ DxTxEDkE/UKYJ4agbtzzqypQUTbYq/uThYYiqJtJBTeQ++/OWx3CYWdKSX9gP4KWt1Oy LmW0kYAaHA4OyxO585IYaJhDbEZPRyPJZOhc7dxVotTqXf4XMzh2GcciuX2vqsTNYQAF i8x/aOLdtnAhr//7dAkUes+vLqH9jVv88jILu1n1OCwgqUyakfgVQUibdsXNzlZYWWo4 WIziyiEMNW6f+xo6h8QytHZQkKvXcfa0ht7Du9uuTAim54+TBArRH5YCkb0ClWrGGW32 0Ydw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=gnyGClV2; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l1-20020a635701000000b0041a75809619si15644464pgb.650.2022.08.10.07.21.25; Wed, 10 Aug 2022 07:21:44 -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=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=gnyGClV2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232942AbiHJOHr (ORCPT + 99 others); Wed, 10 Aug 2022 10:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232907AbiHJOHp (ORCPT ); Wed, 10 Aug 2022 10:07:45 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CA0B6E2CD for ; Wed, 10 Aug 2022 07:07:42 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id j7so17920412wrh.3 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=mWfqwR/dsm9VHqO5yCJ3HDwFWHGdluGm04nndcQa3eVrbsJY5ljXfidBSg4ZoFM0PN lHtRfUuut9IdsnrLEh0tMWSQQJgO+mZmRDLiADRStVq0TSawjojUu3rkXHoPVHx3LRvZ XemLV6MN90HFNTZthjI5l4bYO7dyODfHdVjcKAxT1ckF5Eg5Axw4j/b1TfDgxs/XCzvv xpJqq0fx9F/jWBxKRgaJ2IzPDGbvD+nnP8gLa4LH5Cl7Wpubh3w2bnywu3AeSiGNDmLV SCKl98H0Eq98U0XBwgA2hc0H0QRcfYGTgvI3PfD9m21RH67Ear1cs+TEbYR5aiVzgaoA P/FQ== X-Gm-Message-State: ACgBeo0hfq38tHrc8U9xORKmR04sJe1eq55dEUAraEahk6BjGiz1fc8x WTDBbi1+hL+ryMpPDTKabb9vbw== 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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