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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 46B6EC433ED for ; Mon, 19 Apr 2021 10:08:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1424061362 for ; Mon, 19 Apr 2021 10:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238179AbhDSKIk (ORCPT ); Mon, 19 Apr 2021 06:08:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232055AbhDSKIb (ORCPT ); Mon, 19 Apr 2021 06:08:31 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC38AC061760 for ; Mon, 19 Apr 2021 03:08:00 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id a1so38680171ljp.2 for ; Mon, 19 Apr 2021 03:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m4Ge4/OLRJ/QZEOtOI7jH3j6NMP0dgPEYr8cn2cVZdA=; b=Z5QIwT2CkNBKAhSpoqk55bCneVZpjmu4swI4eBVN9EkcGmktWGlFGXKTXiNVvu/WQt uyC9SblpJSM3EYE+9Sjwvta345bGjkLiM3zw/TQQJhbrN63RrhdSJx1+56l+1D2hPdpG USihPdD3gjbiR/z8wBB5vYmmQZZz34ShTa0mlb+QeBdsfskPceVzHWceaPYGjsXyMunm AsnGJDenTzRzGEqiiwStNnp+vXj246DjKxTLG6USZiREgmNqpAznsKJsp5MNhd3Q6bag AG/iZm7T7EalvmBGJHgL3GmMXYir+umXlADYmONnk0XUHNMcpJSsNamzvm8noKDx2n5L vDiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m4Ge4/OLRJ/QZEOtOI7jH3j6NMP0dgPEYr8cn2cVZdA=; b=N9hnbhmtqBcN6IevMJ/+la0D7fCfSSm9T7xQRIfgQQkRX0+W613jspHcuy1Zn2hfrW 5j0K5kp5VhL4vHPppUsWe8CeDtcUEfTOjK51mjEDVFTaIWTC5sZAB0EcypFoq1Dr5fKm kCNtDM9VFnsZRiObGtiJvyQr3m7fh8rHIBfCINLlLqrkJ6dfm3M+nhC9/jCfMDLpPUn4 6bVt5iKkU5Cqg8N+nmTtRt5vlme4fJgVY/aSUJuiiwE9FN6/N6iVQ05U6UZ2IXhY026h 1YJtpr2fphskp2pycuBz+862ZmHmDU573qIIFqPbdb6DrIhcrzF8kGtAh2FRKvhrtYmj 1shg== X-Gm-Message-State: AOAM532/YUZr97NjdDEQj49v3/YylbrszJoIF2Oi1aztqHIj7LsgVhUu qFFojqSQbBr/K3vYDaBCA+SvHFTMo1g3VeLySPOcaQ== X-Google-Smtp-Source: ABdhPJwstFUJyFsJF3O59qzplzSCx37u2qJMHf9wCIFo89KRCfj2WprbxTCJIwQf62k+aJyOaLHd2lz2Mv/JtqVJ3mU= X-Received: by 2002:a2e:555:: with SMTP id 82mr10616897ljf.200.1618826879285; Mon, 19 Apr 2021 03:07:59 -0700 (PDT) MIME-Version: 1.0 References: <483ac17b-705a-38c3-54ee-7f0089262c03@gmail.com> In-Reply-To: <483ac17b-705a-38c3-54ee-7f0089262c03@gmail.com> From: Linus Walleij Date: Mon, 19 Apr 2021 12:07:48 +0200 Message-ID: Subject: Re: BUG: iio: mpu3050: Wrong temperature scale To: Dmitry Osipenko Cc: Jonathan Cameron , "linux-iio@vger.kernel.org" , Linux Kernel Mailing List , Svyatoslav Ryhel , Nathan Royer , Jean-Baptiste Maneyrol Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 19, 2021 at 8:06 AM Dmitry Osipenko wrote: > The driver uses > (x+23000)/280 formula for the conversion of raw temperature value, which > gives 82C for x=0, thus apparently formula is wrong because x=50000 > should give us ~25C. > > I tried to search for the datasheet with the formula, but couldn't find it. There is no public datasheet. I have never seen a non-public datasheet either. As the initial submission of the driver says: "This driver is based on information from the rough input driver in drivers/input/misc/mpu3050.c and the scratch misc driver posted by Nathan Royer in 2011. Some years have passed but this is finally a fully-fledged driver for this gyroscope. It was developed and tested on the Qualcomm APQ8060 Dragonboard." Nathans submission: https://lore.kernel.org/lkml/1309486707-1658-1-git-send-email-nroyer@invensense.com/ (you find the threads at the bottom) This submission came from inside Invensense so it is the closest authoritative source we have. > Linus, will you be able to check whether the formula used by the driver > is correct? Thanks in advance. Sadly the code is the documentation when it comes to Invensense stuff, I am CC:ing Nathans Invensense address in the vain hope he is still working there and could help, also CC to Jean-Baptiste who was there last year and maybe can help out. I don't anymore remember exactly how I found this equation, but it wasn't from any datasheet. I vaguely remember browsing through some Android userspace sensor code. What I tend to do is dig around in old mobile phone Android trees, and there you sometimes find this information in different GPL code drops. I bet I got it from browsing some of those. Here is an example (Tegra): https://android.googlesource.com/kernel/tegra/+/dba2740d025c8e7e7e3c61d84a4f964d2c1c0ac9/drivers/misc/inv_mpu Worst case what one *can* do is to calibrate the scale, like put the device in a controlled environment of some two reasonably far apart temperatures and measure, assuming it is at least linear. Some professionals use controlled environment chambers for this. But I hope there is a better way. Yours, Linus Walleij