Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7408494pxb; Thu, 18 Feb 2021 09:17:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxy5rog0USRYTpiMxQ27L0+hXcDWUljXZYPyEGYgJZZcT3oOf7HsUTPQOO5ODFhWdqOMbGv X-Received: by 2002:a05:6402:26d5:: with SMTP id x21mr5133497edd.50.1613668663333; Thu, 18 Feb 2021 09:17:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613668663; cv=none; d=google.com; s=arc-20160816; b=Eb6ZLNDBTdJlIAl/9ndzUQ3zmML3OMTc+7EgDaTNO7VHI9yRsn2UX3ahXRtkQsK4s8 qtgMEsBJUKNEtITk2Y+HRhY79O2VjRL9Sbt+kxmUpNZS91nuv/qBvS8Gv7rTNT9sv73q tfk4q65rhpf43vPf+qZ1+1fSi20vWz2ooYkU3zAX7apLCvHv8WLfjzPtnkp1kkgXy/IS zBFJIbj9+nkJfrAioOpOlkLk+n8563La+dhREuSHlI1bF2CmBR4lCtf35ZDDrPOLiEPT Kfxu7B3/lMPh5soUS94MFX3iaIQcHczouOhXnX2OHbGGSPLnswoYnMxmlDwcqoEXQr5C c/GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rzOFfoL3Tt4Je8/bmFWfhnaeEzyTjzZa4p1qLszJ+VI=; b=D9SgjQ0+lzRmbagSuVmtbY+iRWHrRhfDftoVZ2RTKZkYSuGByyXThsRucGvt1Qh5Gl +x/+ezbWJ9cDWiBJ3Nuax16H/z5Gw8ZUIz1aeRT4xv/MNZliCvptV/QXQ+2SkVrSQclE 1g/ho28jOM4/23qAcouoNdEcu43Y+LtA+9BtBj+kjhvYOYY4aw2Q6mJEjNsAMUMG1ce1 UTJDKY8WJsMo460fRghyrSfz2H8mBWgD0Jz9tBoKpPB139wUlkLDquZd+tGGojJBVfEo /aqiJQO2zlC3ACyIpI4MLZtqLhDPuOIgOuBi9bcsaQA+ahp2nQxiQqVn8jHt2ftMzaN6 KgOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VdtxJkCD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j17si4462594edw.10.2021.02.18.09.17.10; Thu, 18 Feb 2021 09:17:43 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VdtxJkCD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232364AbhBRROZ (ORCPT + 99 others); Thu, 18 Feb 2021 12:14:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:36898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232484AbhBROg0 (ORCPT ); Thu, 18 Feb 2021 09:36:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A198264EAE; Thu, 18 Feb 2021 14:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613658941; bh=8/1IqR6HXIUyOdXA/aJwouek9ZMCkL1nIp5uOO/mlec=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VdtxJkCDa414iNNczvI7Pi3GVTJRxp1jNYSFFSE22IypA82LbGS+Gj7swBPnHlGX4 19w/J+hFpGGex9FcmazoYT2Ju4kLYh6vFF6A4+m3N9RPrKZJb0VYI5w3PJOUH5uVfe 4SPGmQoMcAbKauLBn/0qcKrJuxhRPhKxUY1LRJ7c1wDh1dwriR9y9eGMRqjA/gd9cN Rh7ukmzW+M1ZHpJfSoSfAc2g6TRF6DQbcMApbkuni3uxbZZW55EewQ1BEfeG9YgCVW Mu5ASdew+vlAkTHnBa/CIH0vzqt3pR7YRoMRXfFKjnsNGCVTKicnQTdEtAHSwy5PWX InCbs5v1Umqrg== Received: by mail-ej1-f45.google.com with SMTP id lu16so5897001ejb.9; Thu, 18 Feb 2021 06:35:40 -0800 (PST) X-Gm-Message-State: AOAM530f/SzvN47CwebCKrnjqkoYoijoS00FAJhqJkTZo2WMtFvxhF0x rnW4ia3rVVeIJA+juxk1n8v1X7CriPLPpC9E8g== X-Received: by 2002:a17:906:25c4:: with SMTP id n4mr4299436ejb.359.1613658939091; Thu, 18 Feb 2021 06:35:39 -0800 (PST) MIME-Version: 1.0 References: <20210217083438.37865-1-alexandru.ardelean@analog.com> <20210217083438.37865-6-alexandru.ardelean@analog.com> <20210218140506.02b28d8a@archlinux> In-Reply-To: <20210218140506.02b28d8a@archlinux> From: Rob Herring Date: Thu, 18 Feb 2021 08:35:27 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 5/5] iio: dac: ad5686: Add PWM as a trigger source To: Jonathan Cameron Cc: Alexandru Ardelean , "linux-kernel@vger.kernel.org" , "open list:IIO SUBSYSTEM AND DRIVERS" , Lars-Peter Clausen , Michael Hennerich , =?UTF-8?B?TnVubyBTw6E=?= , Dragos Bogdan , Mircea Caprioru , Mihail Chindris Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 18, 2021 at 8:05 AM Jonathan Cameron wrote: > > On Wed, 17 Feb 2021 10:34:38 +0200 > Alexandru Ardelean wrote: > > > From: Mircea Caprioru > > > > A PWM signal will be used as a trigger source to have a deterministic > > sampling frequency since this family of DAC has no hardware interrupt > > source. > > > > This feature is made optional however, as there are some board setups where > > this isn't used. > > > > So this is taking a very generic setup, but then implementing it > as a bit of a hack within the driver. > > It's effectively a PWM connected up to an instance > of iio/triggers/iio-trig-interrupt.c > > Now, I've not looked at that trigger driver for a while, so you may well > need to figure out how to add a binding to instantiate it. > (looks like no one has used it since board file days, or via instantiation > from another driver). > > It's a slightly odd corner case as what it reflects is that we have > an interrupt available that is intended to drive some sort of data > capture or output (it's a trigger signal) - but exactly what is done > is a runtime configurable. In this particular case that interrupt > is hooked up to a PWM and we also want to represent that. > > The fact it's being driven via a PWM is interesting but we should be > able to extend that trigger driver to optionally accept a pwm provider > and if it has one provide frequency control. > > Binding might look something like the following.. > > interrupt-trigger { > interrupts = <>; > pwms = <&pwm 0 4000 PWM_POLARITY_INVERTED>; > }; > > @Rob, what do you think of this odd beast? So a PWM routed back to a GPIO interrupt? It needs a compatible, but otherwise I wouldn't object to the binding if that's what the h/w looks like. But from an OS perspective, I don't think you need it. > So all in all, this generic facility needs a generic implementation, not > one buried in a driver. > > Another open question here is whether you really can't just use an hrtimer > to get similar precision? Way back at the dawn of time in IIO we had > code to use the RTC periodic ticks as a trigger with the theory that they > would give very precise and even timing. In the end it turned out that > hrtimers worked just as well (and RTCs drivers emulated the periodic > ticks via hrtimers, dropping their use of the hardware periodic timers). +100 A hrtimer is likely going to be more precise. IIRC, timers are serviced first. Either way, you're going to have some amount of interrupt service latency, so any precision you think you are gaining by 'doing it in h/w' isn't really there. Rob