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 X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEC5CC433E0 for ; Sun, 21 Feb 2021 14:00:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2D1564EE0 for ; Sun, 21 Feb 2021 14:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbhBUOAl convert rfc822-to-8bit (ORCPT ); Sun, 21 Feb 2021 09:00:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:52340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbhBUOAf (ORCPT ); Sun, 21 Feb 2021 09:00:35 -0500 Received: from archlinux (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF38264EEF; Sun, 21 Feb 2021 13:59:53 +0000 (UTC) Date: Sun, 21 Feb 2021 13:59:49 +0000 From: Jonathan Cameron To: Nuno Sa Cc: , , Rob Herring , Lars-Peter Clausen , Michael Hennerich Subject: Re: [PATCH v2 0/4] Fix/Improve sync clock mode handling Message-ID: <20210221135949.42a42ad4@archlinux> In-Reply-To: <20210218114039.216091-1-nuno.sa@analog.com> References: <20210218114039.216091-1-nuno.sa@analog.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Thu, 18 Feb 2021 12:40:35 +0100 Nuno Sa wrote: > The first patch in this series is just a simple helper to lock/unlock > the device. Having these helpers make the code slightly neater (IMHO). > > The following patches introduces changes in the sampling frequency > calculation when sync scale/pps modes are used. First, it's important > to understand the purpose of this mode and how it should be used. Let's > say our part has an internal rate of 4250 (e.g adis1649x family) and the > user wants an output rate of 200SPS. Obviously, we can't use this > sampling rate and divide back down to get 200 SPS with decimation on. > Hence, we can use this mode to give an input clock of 1HZ, scale it to > something like 4200 or 4000 SPS and then use the decimation filter to get > the exact desired 200SPS. There are also some limits that should be > taken into account when scaling: > > * For the devices in the adis16475 driver: > - Input sync frequency range is 1 to 128 Hz > - Native sample rate: 2 kSPS. Optimal range: 1900-2100 sps > > * For the adis1649x family (adis16480 driver): > - Input sync frequency range is 1 to 128 Hz > - Native sample rate: 4.25 kSPS. Optimal range: 4000-4250 sps > > I'm not 100% convinced on how to handle the optimal minimum. For now, > I'm just throwing a warning saying we might get into trouble if we get a > value lower than that. I was also tempted to just return -EINVAL or > clamp the value. However, I know that there are ADI customers that > (for some reason) are using a sampling rate lower than the minimum > advised. > > That said, the patch for the adis16480 driver is a fix as this mode was > being wrongly handled. There should not be a "separation" between using > the sync_scale and the dec_rate registers. The way things were being done, > we could easily get into a situation where the part could be running with > an internal rate way lower than the optimal minimum. > > For the adis16475 drivers, things were not really wrong. They were just > not optimal as we were forcing users to specify the IMU scaled internal > rate once in the devicetree. Calculating things at runtime gives much > more flexibility to choose the output rate. Series applied. We may want to revisit this sometime in the future but for now, lets get things working reasonably well. Jonathan > > Changes in v2: > * Moved the lock helper patch to the end of the series. > * Changed all the users of the lock to use the helper functions. > * Added a module parameter to allow users to run the IMUs at lower > rates than the advisable. > > Nuno Sa (3): > iio: adis16480: fix pps mode sampling frequency math > iio: adis16475: improve sync scale mode handling > iio: adis: add helpers for locking > > Nuno Sá (1): > dt-bindings: adis16475: remove property > > .../bindings/iio/imu/adi,adis16475.yaml | 9 -- > drivers/iio/imu/adis16400.c | 22 ++- > drivers/iio/imu/adis16475.c | 118 ++++++++++++---- > drivers/iio/imu/adis16480.c | 133 +++++++++++++----- > include/linux/iio/imu/adis.h | 10 ++ > 5 files changed, 206 insertions(+), 86 deletions(-) >