Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2796559rdb; Mon, 4 Dec 2023 07:48:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHD+QAVMSFUwu50XiBZCOPjEMhbHQQ6V0DFwA8ejsPHpfOZhbv/GIclgpJ8XLwmu+kHaLYz X-Received: by 2002:a05:6a20:8f10:b0:18f:97c:6142 with SMTP id b16-20020a056a208f1000b0018f097c6142mr5314101pzk.63.1701704911340; Mon, 04 Dec 2023 07:48:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701704911; cv=none; d=google.com; s=arc-20160816; b=BEmBDV3eEtTQBaaLyXFueCwPxu6sdb2TmuHaLekRLUrcToPancNtFGB+VF4PJgTzrf sNlE7u0qL5NrDYVLdwcT6GrONsbuVWR9pjbsZRw7PUPZGyd+95K88S6luUFeoKYInPxp EY7f5fBLGYDb7khi3VGeG3LfUcnQhatOTKpox3My9rWps46M6/y1bFi3dL2W75R2KxWX fNhiJm5FoylAKvCMSwx618129FjGlAsww6nsj3aa8XSNFUkLCBpBdeUhSXa/TCwz4WCq wUyHaeFo2S7PZA8t6Wxkbuiwr8DBZ2479sr6EjkR7n0o8I0Dthtugk9hPWZLWHu/gZ1N 9c1Q== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=X+hYFNzArOpSKdv+zAHDx6/GU4Fuhwd852qlkPz+bV4=; fh=sqieTvBxhfIVwhknj5TTCKn6UI71QdImv9DAT3Xqv4g=; b=AzBiGn0rUOGulFvFoEoMud7/fptBrykD2S9Hp3H9SL8+aTvx5W7Orj2m9h+OOlBYtd UjPQVQh9TOAz4MxZzt5inYZVcAPg/MixexeWB+LfgP8uDlIM4QqBlNMBKBGG/2VH9iyd KFoa2rqFqI4TvEIJhuljQaVYBqxrYrs4V/kzRMbFooh1J8opIIjYFQZPSP1n02hVX9mV Y5ua2HLnoxcHNGas+p2X1sKaAWxh4aLo+WxMFIohj34wowSomlD2cojOwKVOG7/D/LPS 95EUyUbynRWmr3zpZQtiyrTX8UtZyUwa2v8vY8PzXriI2I+a14Vwjhci747JTazgKUwJ qjYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IDHjTb+M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ca3-20020a056a02068300b005c67708a076si3129647pgb.406.2023.12.04.07.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:48:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IDHjTb+M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 74C1A804C65A; Mon, 4 Dec 2023 07:48:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234757AbjLDPsO (ORCPT + 99 others); Mon, 4 Dec 2023 10:48:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234119AbjLDPsN (ORCPT ); Mon, 4 Dec 2023 10:48:13 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A25E1A4 for ; Mon, 4 Dec 2023 07:48:19 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B83D7C433C7; Mon, 4 Dec 2023 15:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701704899; bh=poIexEtWzDjxIb1louewjCxKLfMDPcfvONt+RHDyPS8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IDHjTb+Meoe/ODMChOrhxVq7/CpZfckhLACFK6WmeArBYCsQNFST8sC6kaV9/2SQO FEdGFDlofC0rZT+vLAeDmtsNsO4wkrl+ubR84YHihD3ZN/0fLAYCpRFROxr9V3co1I M+YmhGDG1pRLPvEV2PTKafIQVNL0wfF453vkY93QXMEQ/s0CsD3g7n5I3pR7ZpcTfQ 3JO9MNyvO/HrW7GXbPOEhlyuSVw1JxICG3ECvApZCwAFdulwm01TlBRA6AuYIb+3Kp 6hDvq8P7kAtT27BnrwLEqoKuUMDFehZo2FPt83kTgbuYi+3jexJgCK8qdgIEJ7+Oj7 JoA6TfyYbIKKA== Date: Mon, 4 Dec 2023 15:48:10 +0000 From: Jonathan Cameron To: Nuno =?UTF-8?B?U8Oh?= Cc: David Lechner , nuno.sa@analog.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Olivier MOYSAN , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Lars-Peter Clausen , Michael Hennerich Subject: Re: [PATCH 10/12] iio: adc: ad9467: convert to backend framework Message-ID: <20231204154810.3f2f3f83@jic23-huawei> In-Reply-To: <026fa80d29054750937cd077b7f4f689de4e18f2.camel@gmail.com> References: <20231121-dev-iio-backend-v1-0-6a3d542eba35@analog.com> <20231121-dev-iio-backend-v1-10-6a3d542eba35@analog.com> <026fa80d29054750937cd077b7f4f689de4e18f2.camel@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 07:48:28 -0800 (PST) On Fri, 01 Dec 2023 10:08:27 +0100 Nuno S=C3=A1 wrote: > On Thu, 2023-11-30 at 17:30 -0600, David Lechner wrote: > > On Tue, Nov 21, 2023 at 4:17=E2=80=AFAM Nuno Sa via B4 Relay > > wrote: =20 > > >=20 > > > From: Nuno Sa > > >=20 > > > Convert the driver to use the new IIO backend framework. The device > > > functionality is expected to be the same (meaning no added or removed > > > features). =20 > >=20 > > Missing a devicetree bindings patch before this one? > > =20 > > >=20 > > > Also note this patch effectively breaks ABI and that's needed so we c= an > > > properly support this device and add needed features making use of the > > > new IIO framework. =20 > >=20 > > Can you be more specific about what is actually breaking? > > =20 > > >=20 > > > Signed-off-by: Nuno Sa > > > --- > > > =C2=A0drivers/iio/adc/Kconfig=C2=A0 |=C2=A0=C2=A0 2 +- > > > =C2=A0drivers/iio/adc/ad9467.c | 256 +++++++++++++++++++++++++++++---= --------------- > > > =C2=A02 files changed, 157 insertions(+), 101 deletions(-) > > >=20 > > > diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig > > > index 1e2b7a2c67c6..af56df63beff 100644 > > > --- a/drivers/iio/adc/Kconfig > > > +++ b/drivers/iio/adc/Kconfig > > > @@ -275,7 +275,7 @@ config AD799X > > > =C2=A0config AD9467 > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tristate "Analog Devices A= D9467 High Speed ADC driver" > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 depends on SPI > > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 depends on ADI_AXI_ADC > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 select IIO_BACKEND > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 help > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Say yes here t= o build support for Analog Devices: > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * AD9467 16-Bi= t, 200 MSPS/250 MSPS Analog-to-Digital Converter > > > diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c > > > index 5db5690ccee8..8b0402e73ace 100644 > > > --- a/drivers/iio/adc/ad9467.c > > > +++ b/drivers/iio/adc/ad9467.c =20 > >=20 > > > > =20 > > > +static int ad9467_buffer_get(struct iio_dev *indio_dev) =20 > >=20 > > perhaps a more descriptive name: ad9467_buffer_setup_optional? > > =20 >=20 > Hmm, no strong feeling. So yeah, can do as you suggest. Even though, now = that I'm > thinking, I'm not so sure if this is just some legacy thing we had in ADI= tree. I > wonder if it actually makes sense for a device like with no buffering sup= port?! > =20 > > > +{ > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct device *dev =3D indio_de= v->dev.parent; > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const char *dma_name; > > > + > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!device_property_present(de= v, "dmas")) > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 return 0; > > > + > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (device_property_read_string= (dev, "dma-names", &dma_name)) > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 dma_name =3D "rx"; > > > + > > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return devm_iio_dmaengine_buffe= r_setup(dev, indio_dev, dma_name); =20 > >=20 > > The device tree bindings for "adi,ad9467" don't include dma properties > > (nor should they). Perhaps the DMA lookup should be a callback to the > > backend? Or something similar to the SPI Engine offload that we are > > working on? > > =20 >=20 > Oh yes, I need to update the bindings. In the link I sent you we can see = my thoughts > on this. In theory, hardwarewise, it would actually make sense for the DM= A to be on > the backend device because that's where the connection is in HW. However,= since we > want to have the IIO interface in the frontend, it would be hard to do th= at without > hacking devm_iio_dmaengine_buffer_setup().=C2=A0I mean, lifetime wise it = would be far from > wise to have the DMA buffer associated to a completely different device t= han the IIO > parent device. I mean, one way could just be export iio_dmaengine_buffer_= free() and > iio_dmaengine_buffer_alloc() so we can actually control the lifetime of t= he buffer > from the frontend device. If Jonathan is fine with this, I'm on board for= it.... It is going to be fiddly but I'd kind of expect the front end to be using a= more abstracted interface to tell the backend to start grabbing data. Maybe tha= t ends up being so slim it's just these interfaces and it's not sensible to wrap i= t though. The argument for the IIO device (you control) being associated with the ana= log/digital front end is that is what happens with a consumer interface today. We think of the analog com= ponents (consuming device) using the sevice of the ADC it is consuming to measure their state. You can flip the whole thing and make the data grabbing engine the IIO devi= ce but I guess that's just not how we did it and I'm sure I had many good reasons = at the time (one of them being that it needed to work for other cases such as a touchsc= reen driver consuming the IIO device) I that case it's the touchscreen driver that is = responsible for data scaling etc not the ADC. =20 In my head, data acquisition is a service - what is interesting is what is = being measured and so I put the IIO device as near that as possible. Jonathan