Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1388825ybt; Sat, 20 Jun 2020 09:00:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI02CQqfUUSU+SaphsTwOlRGYh7nzElpNPMkFee7hD6U42pjoxhiOBZW9XbDJLItl7aUna X-Received: by 2002:a05:6402:1d82:: with SMTP id dk2mr8467958edb.75.1592668835287; Sat, 20 Jun 2020 09:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592668835; cv=none; d=google.com; s=arc-20160816; b=hv3amOy+aYXQGhUP6GCfWg7u26uxEzKbgCTFyADmTh+LkJyLUhh3dlHJWLFxNEoCkh 9gw4xt0OxJfiLLZbKRBqvhlT4LNBtmYGDiFtNV7A4fB/xRMBG+67v5GhLZwgxdWUyXLK Alh0XtpuH87pGDQsk4wCO4zEnkxgkvYAd9OWOgqE5kQorkxMBVpf1VQmr4jbUp8wBqQI esUcS2SboRx/yaleHqjd8hXZkaPTy6D+ELStB3zw/ZCdaXY9D0bQiAiyGElPi3bquLIi Dcmw2Z/pZ7WNKO0+XuksiQu+ym5VLwSB2KnG1a94LvRmD7GMDOdXghv9MG6sYQQ9QfKK 8Ppw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=AP5p7we5nSeNMTRaPJzXlQ2ejrtzu7HPN2vrZt4QvtY=; b=iMZ7JenEQRw1EBv1Ri/u+0jYsov/EbXq7Cmf5S24e2PEjjfnw2/Cf3IKKJXMqn2cT6 slj0ZUDUWv8osB6CiqueuhjDKdel/FXHrhUrp8fPRzaI3Z9KdBlPQhJyugeefWTi/jrH oWXMQJgkZlhvQgVVVkhsd7w03dAuENtgbFi3+zw4EpWLOQnR+37Bm8zVdn84sRZRbF9o nZZZKMJQp3HF5JBdKYrCxCsOFUu+2whJcR5GH/iVcoivmrrO0UDcCp1jnaslXwZd9s6c Xj3s/A1Pr8H1kN3dxBEdWadxwzSkviRY+H2CbnDgSk5JvD2oiOhRuZs5T9OoZM9as/XS LMHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pP6GKyBH; 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 dn17si8461413ejc.556.2020.06.20.09.00.12; Sat, 20 Jun 2020 09:00:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=pP6GKyBH; 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 S1727866AbgFTP5q (ORCPT + 99 others); Sat, 20 Jun 2020 11:57:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:56962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgFTP5p (ORCPT ); Sat, 20 Jun 2020 11:57:45 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 AB85823D6A; Sat, 20 Jun 2020 15:57:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592668664; bh=D8fKktaZdo0jD0i4fAQUF+z6/90romTLM3ZgSwzvpY8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pP6GKyBHjzZRcJx+iJFjVnoR2m7N67RQfT0Bm48HzxTwn/NPvrKJennJn5qtMW7A6 XWs9wB6b/eUtJcm1UKKlpAcNqOMDywl+aCTbaTc9WvlyB3E/UomafaAif3mEpR1rGF BplKzw7hKoY66Q6EEC9wx43AN2/CjzSQOs+w4xz4= Date: Sat, 20 Jun 2020 16:57:39 +0100 From: Jonathan Cameron To: Jean-Baptiste Maneyrol Cc: Lars-Peter Clausen , "robh+dt@kernel.org" , "robh@kernel.org" , "mchehab+huawei@kernel.org" , "davem@davemloft.net" , "gregkh@linuxfoundation.org" , "linux-iio@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 06/13] iio: imu: inv_icm42600: add temperature sensor support Message-ID: <20200620165739.29694b9b@archlinux> In-Reply-To: References: <20200608204250.3291-1-jmaneyrol@invensense.com> <20200608204250.3291-7-jmaneyrol@invensense.com> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 14 Jun 2020 20:35:13 +0000 Jean-Baptiste Maneyrol wrote: > Hello Lars, >=20 > for the temperature data, the problem is that temperature in the FIFO (us= ed in buffer) is not in the same format than when reading the register. >=20 > Reading the temperature register return a full precision value on 16 bits= . I am using a PROCESSED attribute for it. > Temperature data in buffer (coming from the FIFO) is on 8 bits in lower p= recision. It is reported as raw data, thus the need of the offset and scale= values. >=20 > So offset and scale values are only for transforming the temperature data= from the buffer, and direct read is a full precision already processed in = m=C2=B0C. That is a problem. We have no means of describing it in IIO. If the channel is processed via sysfs the assumption would normally be that it is processed in the buffer as well. We don't really have any means of describing the two separately. In cases where we've seen this before the way around it was to change the data in the fifo so that the scaling was the same as the sysfs channel (usually it's just a bit of padding). Can we do that here? Looks like the ratio is 1:64 so should be possible.=20 >=20 > Thanks for the review, > JB >=20 > From: Lars-Peter Clausen > Sent: Sunday, June 14, 2020 17:10 > To: Jean-Baptiste Maneyrol ; jic23@kernel.org <= jic23@kernel.org>; robh+dt@kernel.org ; robh@kernel.org= ; mchehab+huawei@kernel.org ; = davem@davemloft.net ; gregkh@linuxfoundation.org > Cc: linux-iio@vger.kernel.org ; devicetree@vge= r.kernel.org ; linux-kernel@vger.kernel.org > Subject: Re: [PATCH v3 06/13] iio: imu: inv_icm42600: add temperature sen= sor support=20 > =C2=A0 > =C2=A0CAUTION: This email originated from outside of the organization. Pl= ease make sure the sender is who they say they are and do not click links o= r open attachments unless you recognize the sender and know the content is = safe. >=20 > On 6/8/20 10:42 PM, Jean-Baptiste Maneyrol wrote: > > +=C2=A0=C2=A0=C2=A0=C2=A0 case IIO_CHAN_INFO_PROCESSED: > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 ret =3D iio_device_claim_direct_mode(indio_dev); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if (ret) > > +=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ret; > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 ret =3D inv_icm42600_temp_read(st, &temp); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 iio_device_release_direct_mode(indio_dev); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if (ret) > > +=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=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ret; > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 *val =3D temp; > > +=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 IIO_VAL_INT; > > +=C2=A0=C2=A0=C2=A0=C2=A0 case IIO_CHAN_INFO_SCALE: > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 *val =3D 483; > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 *val2 =3D 91787; > > +=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 IIO_VAL_INT_PLUS_MICRO; > > +=C2=A0=C2=A0=C2=A0=C2=A0 case IIO_CHAN_INFO_OFFSET: > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 *val =3D 25000; > > +=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 IIO_VAL_INT; =20 >=20 > If the data is returned processed there is no need to specify scale and=20 > offset. >=20 > But since the transformation to turn the data into standard units is a=20 > simple linear transform the preferred way to handle this is to return=20 > RAW data and specify scale and offset.