From patchwork Sun Oct 28 12:26:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10658537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C62E13BF for ; Sun, 28 Oct 2018 12:26:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02565299E0 for ; Sun, 28 Oct 2018 12:26:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4C8D299ED; Sun, 28 Oct 2018 12:26:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79EA329603 for ; Sun, 28 Oct 2018 12:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbeJ1VLL (ORCPT ); Sun, 28 Oct 2018 17:11:11 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:34725 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbeJ1VLL (ORCPT ); Sun, 28 Oct 2018 17:11:11 -0400 Received: by mail-wm1-f66.google.com with SMTP id f1-v6so7495488wmg.1; Sun, 28 Oct 2018 05:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8AJJyZDq3udxC/IKYcG/Gnw5Odh8TfSJfX+oiOSt490=; b=mJOvzItjQm9BrtFFDwu9SovRa+RRPRqa7/l2lxam0zLCgr3VOc5HEsDVT5TibGf5k8 ijpqhTokWhjLoSp7+R3z087J8bKq1thmAsFCA4NduGhGU69/nlXzVj4mysD07Lv4GnTo QHRzio6MRT50/L//PnKWbRdQsIok26pBGysDcEwk864eyGf5w/+WGNSSK3fG20dXUHkS M70DX2+oiKyvuX1VR2z47gdKzaW0nuf1cyLwpg+NZVMrkivUdvEUJJEGC142ROjfswpC NxlnjZHlg0xJJUq5bmmRkrkZWzJBg1RI017UWvpglCEm3DbF6fkTlaUMtHe9D+1ivx42 crcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8AJJyZDq3udxC/IKYcG/Gnw5Odh8TfSJfX+oiOSt490=; b=JtRqTzBV8p8JhenGkUO2qFOlWlmOFUY7wVJHdDvQ7yxB41kYxakpEbzIVUHA5+FENE JdV/19sutjNvYPtlskbXmtUhdtjDN1ereCBS5DeiYkNj5dDBB0U3l/jPy13kBv2yFjKi xaQqZ/Vm5P93ddQEnNzeFOjUVv/3nImuEC92D6PHNrUiD7VclpI3iy6RLVwSOfqU2roa Re0OYdIAfQbI8O60J9dNIEEMORLSD1z/ZzcNvb1psmUPT5XeG4pcy+aZm0wRZoTaCuy4 AlnSgfxARXwq6TEQrpa+t0ycjmbI4KcxqZEDAAmtSpLlvG7VG+XO5i0CdL1vu76fKspz R2lA== X-Gm-Message-State: AGRZ1gL0yMDGxIUWBkHyjrsJC248ULqXrwCEHttUw5wZIVxYSF6jX1U0 cewYECQIU1b7i8okkj3xSLw= X-Google-Smtp-Source: AJdET5c7b1eflXhZ8Y2RS6tqKxg50VSSDdXAk6Y8Xcp64UASGab/JqeTQ1ij/1MutCg1HE3pWshKRg== X-Received: by 2002:a1c:7dce:: with SMTP id y197-v6mr11363171wmc.78.1540729599492; Sun, 28 Oct 2018 05:26:39 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD7072200691979D1FB980407.dip0.t-ipconnect.de. [2003:dc:d707:2200:6919:79d1:fb98:407]) by smtp.googlemail.com with ESMTPSA id z185-v6sm19334091wmz.47.2018.10.28.05.26.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 05:26:38 -0700 (PDT) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, robh+dt@kernel.org, pmeerw@pmeerw.net, lars@metafoo.de, knaack.h@gmx.de, jic23@kernel.org Cc: khilman@baylibre.com, carlo@caione.org, Martin Blumenstingl Subject: [PATCH 0/7] meson-saradc: add chip temperature support Date: Sun, 28 Oct 2018 13:26:22 +0100 Message-Id: <20181028122629.10144-1-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The meson-saradc allows switching the input of channel #6 between an actual ADC pad and the SoC's internal temperature sensor. On the 64-bit SoCs the SCPI firmware reads the chip temperature using the SAR ADC. Thus the 64-bit SoCs simply expose the temperature through the "arm,scpi-sensors" interface (and so Linux doesn't have to program the SAR ADC for temperature readings). The 32-bit SoCs however don't have any SCPI firmware. Thus we need to configure the SAR ADC in Linux to get the chip temperature. To make it work we need two changes to the existing dt-bindings: - we have to get the TSC (temperature sensor calibration coefficient) from the eFuse (where it has been programmed to the correct value in the manufacturing process). the SAR ADC needs the TSC value, otherwise it returns only garbage readings - we need to get a phandle to the new HHI syscon region because on Meson8b and Meson8m2 the TSC is five bits wide (on Meson8 it's only four bits wide) but only four bits are stored inside the SAR ADC's memory region. The upper most bit (not all five bits, only one out of five) is stored at a seemingly random register HHI_DPLL_TOP_0) in the HHI register area. Dependencies: The SAR ADC changes are completely independent from anything else. However, the arch/arm/boot/dts changes from this series depend on my other series "Meson8/Meson8b: introduce a HHI syscon node" from [0]. I decided to send them all together to give a better overview how the end result looks like - I can split the dts changes into a separate series when requested (in any case I would like Kevin to take them through his linux-amlogic tree). [0] https://patchwork.kernel.org/cover/10658527/ Martin Blumenstingl (7): dt-bindings: iio: adc: meson-saradc: add temperature sensor support iio: adc: meson-saradc: add support for the chip's temperature sensor ARM: dts: meson8: add the temperature calibration data for the SAR ADC ARM: dts: meson8b: add the temperature calibration data for the SAR ADC ARM: dts: meson8b: ec100: add iio-hwmon for the chip temperature ARM: dts: meson8b: odroidc1: add iio-hwmon for the chip temperature ARM: dts: meson8m2: mxiii-plus: add iio-hwmon for the chip temperature .../bindings/iio/adc/amlogic,meson-saradc.txt | 10 + arch/arm/boot/dts/meson8.dtsi | 8 + arch/arm/boot/dts/meson8b-ec100.dts | 5 + arch/arm/boot/dts/meson8b-odroidc1.dts | 5 + arch/arm/boot/dts/meson8b.dtsi | 8 + arch/arm/boot/dts/meson8m2-mxiii-plus.dts | 5 + drivers/iio/adc/meson_saradc.c | 274 ++++++++++++++++-- 7 files changed, 289 insertions(+), 26 deletions(-)