Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp358815pxb; Wed, 18 Aug 2021 04:13:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwP6xkS9PGhSA0oxqMiC54dL0VQXLTFDr/cz315EpIzuBfDKqTs9IUOzdmcoBdtLJ2QqS1y X-Received: by 2002:a17:906:3c0a:: with SMTP id h10mr3541045ejg.307.1629285214510; Wed, 18 Aug 2021 04:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629285214; cv=none; d=google.com; s=arc-20160816; b=PzpOyIPerMI7qwwhT/ayNBYkPjwpHLNO6eoU8VDRaVN/1Zk+2mBCFB4QBQZsvDLbJx zjR6pi5TiyPnM92krn6UiOTBmwoxat8xYUfnoXdF+6reEvGlDlVL8zVDhRfHhktI/Uzp XoCBaooXf5vbtPMqu+iS59DQzstJhlpcHPKrFnnybdS3IPj2B4LFZpnpUb5E4wdMEx1M zwwLLzLxmC/K8WwU1Jvl+Fcb755aItrtFcPg+j4D0XZ/NFpG4obSuYD2PCuve5Os1LAz OyBzewUEW2Y+sGGvoWwbkoMoHVVES2l50Gy7gJyxgUyrPDU9z5x6eCBo50XCczGMiC+x dFJA== 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; bh=hxmNzn6Ki7qHfqofalQtvoJ4ig6Rz+bB/wsd/GqAbEI=; b=SjHapihmkkYF5p7EvKF4aRpA7yOf14MJKYw1LsQnW7E02AHpDArR/fvJGP+3JRmiBF 0+FJ208oTrR44l6FWuXarFcxYRCfpRa8t0vK1fYHx7Is++jx+B62t1AZpizWebqW389M VIzAYVFWOWyilBZwSek79kzBgzSXfmrfjpnOUCMkQNT1CQsEnyK2Mtee5Jg8S9M8IQD9 TmdS83Yi+XHYLNeMNpbTUOPWOXuelkOfqraaFeMM96RBIM9Tq1QLFFLjbdM41gX/w2sJ O7LS+bu9qlX8zLvTZkgf4BklcOr+0atTSkPplUnDYked+OMffItuGcCIN/IhpN3enOhV sCBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si5638194ejq.621.2021.08.18.04.13.09; Wed, 18 Aug 2021 04:13:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235105AbhHRLMR (ORCPT + 99 others); Wed, 18 Aug 2021 07:12:17 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:36347 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235166AbhHRLMQ (ORCPT ); Wed, 18 Aug 2021 07:12:16 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id A23EF60002; Wed, 18 Aug 2021 11:11:39 +0000 (UTC) From: Miquel Raynal To: Jonathan Cameron , Lars-Peter Clausen Cc: Thomas Petazzoni , linux-iio@vger.kernel.org, , Miquel Raynal Subject: [PATCH 00/16] Bring software triggers support to MAX1027-like ADCs Date: Wed, 18 Aug 2021 13:11:23 +0200 Message-Id: <20210818111139.330636-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Until now the max1027.c driver, which handles 10-bit devices (max10xx) and 12-bit devices (max12xx), only supported hardware triggers. When a hardware trigger is not wired it is very convenient to trigger periodic conversions with timers or on userspace demand with a sysfs trigger. Overall, when several values are needed at the same time using triggers and buffers improves quite a lot the performances. This series starts with two small fixes, then does a bit of cleaning/code reorganization before actually adding support for software triggers. This series has been developed and tested on a custom board with a 4.14 kernel. I then rebased the series on top of a mainline kernel (v5.14-rc1) but unfortunately after quite some time debugging it I was unable to get all the necessary blocks running in order to properly test it. Anyway, there was very little changes in that series when rebasing it from v4.14 to v5.14-rc1 so I am pretty confident it will smoothly work with a more recent kernel. How to test sysfs triggers: echo 0 > /sys/bus/iio/devices/iio_sysfs_trigger/add_trigger cat /sys/bus/iio/devices/iio_sysfs_trigger/trigger0/name > \ /sys/bus/iio/devices/iio:device0/trigger/current_trigger echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltageX_en echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltageY_en echo 1 > /sys/bus/iio/devices/iio:device0/buffer/enable cat /dev/iio\:device0 > /tmp/data & echo 1 > /sys/bus/iio/devices/trigger0/trigger_now od -t x1 /tmp/data Cheers, Miquèl Miquel Raynal (16): iio: adc: max1027: Fix wrong shift with 12-bit devices iio: adc: max1027: Fix the number of max1X31 channels iio: adc: max1027: Push only the requested samples iio: adc: max1027: Lower conversion time iio: adc: max1027: Drop extra warning message iio: adc: max1027: Rename a helper iio: adc: max1027: Create a helper to configure the trigger iio: adc: max1027: Explain better how the trigger state gets changed iio: adc: max1027: Create a helper to configure the channels to scan iio: adc: max1027: Prevent single channel accesses during buffer reads iio: adc: max1027: Separate the IRQ handler from the read logic iio: adc: max1027: Introduce an end of conversion helper iio: adc: max1027: Prepare re-using the EOC interrupt iio: adc: max1027: Consolidate the end of conversion helper iio: adc: max1027: Support software triggers iio: adc: max1027: Enable software triggers to be used without IRQ drivers/iio/adc/max1027.c | 236 ++++++++++++++++++++++++++++---------- 1 file changed, 177 insertions(+), 59 deletions(-) -- 2.27.0