From patchwork Tue Sep 15 17:36:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gene Chen X-Patchwork-Id: 11777431 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D6C636CA for ; Tue, 15 Sep 2020 17:38:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DCDD20678 for ; Tue, 15 Sep 2020 17:38:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oR/iRuzV"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FaDdYcrR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DCDD20678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=sqAgriODatIclQXVhdDxrYbUkTgk1l7Xyxe3Bg4uHao=; b=oR/iRuzVnfH7R6xFRMR+Hiigy4 nN5T+uzR/QAuulULdAuRlyAk7/68SM5dG1uJnNbh0deDY/t9J6478Q6PIXLYJ1pBR24ZKCCB/bAT2 7Oo+5zw/fwWAB/r0+Pfbco4BvreflCLRKmjaY66VtF9G7KVu9Uq3NUPMfDgBcqOHhU7co3EpcYjmg iPdVo5260x56YUKrqHZEwsN2nNkSOJQdbOwrv6E1ebCBnstI7Fcn3owXeNyVBpJRV93clpamWrmGP GBgs5gyWgPbPJFX0R1l9QRFyxVJXR5IjiqVHimtTDnjVoZFCNhSJeqsiWSMM+8E3/U/JMEMvY5VfT H9KmhJUQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIEsb-0003j9-5U; Tue, 15 Sep 2020 17:36:36 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIEsP-0003fT-CF; Tue, 15 Sep 2020 17:36:22 +0000 Received: by mail-pf1-x442.google.com with SMTP id c196so2396899pfc.0; Tue, 15 Sep 2020 10:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9+aE1ELAzgYKqHHzeFiypxalT4hgfY/xIUQkiDN+va0=; b=FaDdYcrR0aifpyTmq+TIfvqHdxcsTDpOBU2FMOsc7dG9l61ku8FivcMgAUhnQW2hA4 xmkubi7hfP5sUbH7Nu9St0cci4gzseHoNbijYT17Z4dr5E/6nQlUgouOFY4sx6RnvT7r yHJCm3Ktc9iGTRKcxGV58f5zFF5JbGBzRzlBJw6SwF7DoebbS+7uUVPhQQmDKGIdZErY +GflYC0nMP5p4Wvrp+n6kYVoFaBnA5ATDPSRKiuxHOm3eW4qWgbj/424Q8mab6T//7YD ccxT3VztIFFl9+e94on1Rd/zS9DMp8WJSbVUStASPhbKsQu7+GPdIMLnoWJYfPPSp2Tq QoKA== 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:in-reply-to :references; bh=9+aE1ELAzgYKqHHzeFiypxalT4hgfY/xIUQkiDN+va0=; b=d9W+f2i/4IKJgdXz7h/3/uAaNmxnLfj4ejab9FdiKqqcNO51nDGqxWmeuSxG6z/D7W D5UpZqtTr2cl0jH36CVtbK1t8vksHmx29ObQwAbkDLsTqC/oBpxnjl7jwQvAy1PlFnFy x5hqLXvmXdcd5oQRHhOpZJ9h7HNopN0EjrPDFR+lUC2TsFILGFEupOXpUu56FLFEMpn+ V10eHwRAlpAOgYqCh3xmUyZPUwnMy1U+AoFoSlKqAH0aYapkVIiWD1S4081YIKn7Vvxh Rr7dIf0wPpGOmdCf/0Ih9bKOU3ch+kvMlBjjqyacjPMX0m1EvVLhQpnGz4pbqoaTCNin WpeQ== X-Gm-Message-State: AOAM532lMoWCD7mrkitIpgH4KmCFWp3qFUiFNxrRUuQ2g8p0YqE2/pRW hupOcX0Xd+DspHMfQxT//m8= X-Google-Smtp-Source: ABdhPJxVyXSCl2RPLvVB5n4rRYLsOtrFkc1vvGg0hXwSIaOeSQ0tF5wwWOR83BrjvzlI+LzXUrVe2w== X-Received: by 2002:a63:4559:: with SMTP id u25mr15052932pgk.162.1600191378923; Tue, 15 Sep 2020 10:36:18 -0700 (PDT) Received: from localhost.localdomain ([123.110.251.138]) by smtp.gmail.com with ESMTPSA id x3sm14025926pfq.49.2020.09.15.10.36.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 10:36:18 -0700 (PDT) From: Gene Chen To: jic23@kernel.org, matthias.bgg@gmail.com Subject: [PATCH v4 1/3] dt-bindings: iio: adc: add bindings doc for MT6360 ADC Date: Wed, 16 Sep 2020 01:36:07 +0800 Message-Id: <1600191369-28040-2-git-send-email-gene.chen.richtek@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600191369-28040-1-git-send-email-gene.chen.richtek@gmail.com> References: <1600191369-28040-1-git-send-email-gene.chen.richtek@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_133621_507363_A5D9DEAB X-CRM114-Status: GOOD ( 14.87 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:442 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [gene.chen.richtek[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gene_chen@richtek.com, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, cy_huang@richtek.com, benjamin.chao@mediatek.com, linux-mediatek@lists.infradead.org, pmeerw@pmeerw.net, knaack.h@gmx.de, Wilma.Wu@mediatek.com, linux-arm-kernel@lists.infradead.org, shufan_lee@richtek.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Gene Chen This change adds the binding doc for the MT6360 ADC. Signed-off-by: Gene Chen --- .../bindings/iio/adc/mediatek,mt6360.yaml | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/mediatek,mt6360.yaml b/Documentation/devicetree/bindings/iio/adc/mediatek,mt6360.yaml new file mode 100644 index 0000000..2fa2fe7 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/mediatek,mt6360.yaml @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/mediatek,mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek MT6360 and similar ADCs + +maintainers: + - Gene Chen + +description: | + Family of simple ADCs with i2c interface and internal references. + +properties: + compatible: + const: mediatek,mt6360-adc + + "#io-channel-cells": + const: 1 + +required: + - compatible + - "#io-channel-cells" + +examples: + - | + adc { + compatible = "mediatek,mt6360-adc"; + #io-channel-cells = <1>; + }; +... From patchwork Tue Sep 15 17:36:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gene Chen X-Patchwork-Id: 11777433 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC45C6CA for ; Tue, 15 Sep 2020 17:38:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A9D6B20678 for ; Tue, 15 Sep 2020 17:38:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eJzBe6e1"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eW+2TlyI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9D6B20678 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=su1mFkxMPLw4VXAqv4ApaUtt7R/LleT4aEmAT2mBkYQ=; b=eJzBe6e1V453YXzG9F96CF1j3B 264N09Chv/UWQYE5qk4wq9fgqxul1zOAsrZuxxmgx5ISRXNKfFSgfDN5t4qH27rtvVOHpIdmLZJrW GaArakDnbdRhUSc2WEfLCLhlp71uIFgIRBrnsXv+q9phJ2xbZm0TPN6yh3JFF7/1gg2Smftx4i1Yg OFxlO0t8WaUgScrFfIzBBzszAnP3mAxycMyorxqVmJha83ilO7gQZuqKZY0DqqT+vX1pFFwU1/XJO be6/1JzPMrdyqOnBsjiHBCyniAO1ANSJXL0ViPJikZVcEMwX/1trCm6utOeORwdEGcxjWQu/N1eRY 12ZbzrXQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIEsu-0003nc-3z; Tue, 15 Sep 2020 17:36:52 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIEsR-0003gK-V0; Tue, 15 Sep 2020 17:36:27 +0000 Received: by mail-pj1-x1043.google.com with SMTP id md22so273588pjb.0; Tue, 15 Sep 2020 10:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2sltQ7OKUQCVV9G6bV9rSI99zwdlgVY44oFadVRn2CI=; b=eW+2TlyI52Z2+6zFckoS9vSKzJQkTC8U3eGSz6j9TYGbXFJOkHEAuoCYJGN3+JxY0b XoNwtfI6M8RaJU+B1imCAwaKqH11dmXfKa/Oqm1dQlrXOHdPzYDo6bo68WwB+k0FnHqa R0oLQ6al9qZvD/Zje34CJUuoihUl0SWdn+W77zqydjpQZHVkeB06LBgashDJxz1dKSw2 lIsPy20LfMPxKqMoRp2Y8+EOgNbGd2mT6aDrtG/O7eOqHBs5wvejGjFetZ1YKpXoEmla 4EHPv1mFhUKNjzpYTe+9/C/uMb67VGZ8w4gviB26VVe+xtJTaPX9Fk+3lDV86911mtpP Hijg== 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:in-reply-to :references; bh=2sltQ7OKUQCVV9G6bV9rSI99zwdlgVY44oFadVRn2CI=; b=ujv9fwj3wtrll0+SO98qAwyzfvtVcJideF/JcqKokBwTmnbH1fBQ7m2gsO1o/R7NI7 9AIddr1WQpA9wRuoYDxBG3RWZoxGWed/DPvfkTtoLe82OhHQl6Nu7qeAeepqkJq6pN2g YBojsNLYOch3S1t3fonBuoILWYDu6PCgJxeXhor3/CUPLzMNuBzcru0FbMeCN9fAQtd+ dSe6IbsWPl2M2daTT/HBV8S+T6l7Ykb/NVUue/U3RCsaQTFDhoi5gt6Pq4xdrxFeTQOu Lro7ceg7EHBjqCEXGgRmC+wJ993AgDkyYJxBZ29m38A+ri4Cz0WskuVHhM8LwrHUrkly XcBw== X-Gm-Message-State: AOAM532bHyXQngLj/kQfPOnXRdAlP7T0KvB0WNZleCq8uSj17D3rvWAS n/x7gciy2pLpWTD4H5P2wzs= X-Google-Smtp-Source: ABdhPJxae65aUF7nfySsPxANLHHZDhUaN/afvD7KfK3E+LliiIToUIYO7E15PckHd4LN3F4q7vFYtg== X-Received: by 2002:a17:90b:198:: with SMTP id t24mr407317pjs.107.1600191381819; Tue, 15 Sep 2020 10:36:21 -0700 (PDT) Received: from localhost.localdomain ([123.110.251.138]) by smtp.gmail.com with ESMTPSA id x3sm14025926pfq.49.2020.09.15.10.36.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 10:36:21 -0700 (PDT) From: Gene Chen To: jic23@kernel.org, matthias.bgg@gmail.com Subject: [PATCH v4 2/3] Documentation: ABI: testing: mt6360: Add ADC sysfs guideline Date: Wed, 16 Sep 2020 01:36:08 +0800 Message-Id: <1600191369-28040-3-git-send-email-gene.chen.richtek@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600191369-28040-1-git-send-email-gene.chen.richtek@gmail.com> References: <1600191369-28040-1-git-send-email-gene.chen.richtek@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_133625_372831_1FF98C8C X-CRM114-Status: GOOD ( 14.11 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1043 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [gene.chen.richtek[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gene_chen@richtek.com, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, cy_huang@richtek.com, benjamin.chao@mediatek.com, linux-mediatek@lists.infradead.org, pmeerw@pmeerw.net, knaack.h@gmx.de, Wilma.Wu@mediatek.com, linux-arm-kernel@lists.infradead.org, shufan_lee@richtek.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Gene Chen Add ABI documentation for mt6360 ADC sysfs interfaces. Signed-off-by: Gene Chen --- Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 diff --git a/Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 b/Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 new file mode 100644 index 0000000..4b1c270 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 @@ -0,0 +1,83 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_USBID_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 USBID ADC which connected to connector ID pin. + Reading returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_VBUSDIV5_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VBUS ADC with high accuracy + Reading returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_VBUSDIV2_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VBUS ADC with low accuracy + Reading returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_VSYS_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VSYS ADC + Reading returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_VBAT_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VBAT ADC + Reading returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_current_IBUS_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 IBUS ADC + Reading returns current in uA + +What: /sys/bus/iio/devices/iio:deviceX/in_current_IBAT_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 IBAT ADC + Reading returns current in uA + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_CHG_VDDP_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 CHG_VDDP ADC + Reading returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_temp_TEMP_JC_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 IC junction temperature + Reading returns temperature in degree + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_VREF_TS_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VREF_TS ADC + Reading returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_TS_input +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 TS ADC + Reading returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/timestamp +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 timestamp + Reading returns current timestamp in ms From patchwork Tue Sep 15 17:36:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gene Chen X-Patchwork-Id: 11777425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3BFC6CA for ; Tue, 15 Sep 2020 17:37:15 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6CA1A2193E for ; Tue, 15 Sep 2020 17:37:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WsICWQ6x"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KxtHn4Bp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CA1A2193E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=v8f3xULP5/RHZpJbz6SFt+qFn4RqkrDgJ05Uk1op7Qc=; b=WsICWQ6xs3lpdboGUhresKytoy n92pJcZK/kFw2DrFyY6uXHxrZ3bcsWIYql+/dn3HLah4szhYlJhGDZdGg7AUkeXremown4nYHdpij vAbR8UWr+1+pG+1E63AQFVKPq2SeMae3MDki3evOwShP71pm/xjphVhf1jC+t+2+zVPhbCDm1k5oM YuSlLVhEq5t2dlBdIGFtDqZ87zdMIpMAKqHy18N8oIC3L1kQOx4hS1flvGq8VEe0dwU9xHAkEceyl K83By8msDJWVKlYkW3sNltQz65PXe4U7PcsRCYm6x10aHNEDP/hVTOt8c3I/XqCouIU8vfxjB14bG ZbOHTW6Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIEt1-0003rJ-Fq; Tue, 15 Sep 2020 17:36:59 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIEsW-0003hA-Lw; Tue, 15 Sep 2020 17:36:31 +0000 Received: by mail-pj1-x1044.google.com with SMTP id mm21so152725pjb.4; Tue, 15 Sep 2020 10:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EZpaJy+eVZz8Zx7f1Sp6TL0BpxAimVWK2qha8KHGSW8=; b=KxtHn4Bp/P1iUByN/6QJJ6ViinQQKIGp4ORo5PbJX3jKLX+fC3nnQ9v/F/Idw4oSzR P+KGUYMB7/O63Rjz/gvVg5T3dKeB5va+/hyjlaD5TKyrBEJckC9A7+UCQAFoOIOTnX1i GcDVrp5G1ml1hU0W3QFO4Cl3sbxIHdFgeueFGL0JN3ItqIqUYrfPGAold+5zyTyN1oym s2Cr6zq/tRpLaE6PUiD3ViRS+B+uY8uBrpJAfJcEVClp1ciWxz6L01ZFMytEu10Ugu8W AYCUaDecnBNk8p4KLwdcSHvcX5Qbis9SIvdn9f9pr/Srqm4A8R0iqd63RJpfKU3hco4u E8HQ== 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:in-reply-to :references; bh=EZpaJy+eVZz8Zx7f1Sp6TL0BpxAimVWK2qha8KHGSW8=; b=VguLOX/jc2Z/ATN18fg+JFWdf3sMT4WazvXt4Si1DSjgbXNeVaLc9luQYjrqd1ndrn X+nqv/xIpxIOTjRs6737Pp95RskZ2ftFnVXT3P2TEk3iYvQeCDqbJhpQ7pPR5dAu0/C3 SEAaRkFyvV0e8CWtyXcf/nUA8ASlIdqujRNx3LTvnKxhI8XxrA6ughjx4xxx582PoGKf PSMuO9wan3ia+4+eNyeX8O2qzwe+bwa08aa15Qv7lL/7VlWZ9CvjXuqZmX1bGgFX3sPR ESMAxDQPg7/3vKdf1qSVLl10zWoMWayE/kTH+s7lWn0/seqyjmJ+dr19xpGugZKf/Fni 0NKw== X-Gm-Message-State: AOAM532BKhmAjDtwvuKg2N7ghap9kxZT4y42ibIQ5orP6f8ecvxiXvHG 3+5ClPdQrKVkhGBC86Zj0L4= X-Google-Smtp-Source: ABdhPJxd3a/uX3P3IXohuv78T/PRNEQynLTpFMbiL2B3pRuIO59qNOJE1nrDSD0ajLqX9XugSMKapA== X-Received: by 2002:a17:90a:77c1:: with SMTP id e1mr396084pjs.39.1600191384890; Tue, 15 Sep 2020 10:36:24 -0700 (PDT) Received: from localhost.localdomain ([123.110.251.138]) by smtp.gmail.com with ESMTPSA id x3sm14025926pfq.49.2020.09.15.10.36.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Sep 2020 10:36:24 -0700 (PDT) From: Gene Chen To: jic23@kernel.org, matthias.bgg@gmail.com Subject: [PATCH v4 3/3] iio: adc: mt6360: Add ADC driver for MT6360 Date: Wed, 16 Sep 2020 01:36:09 +0800 Message-Id: <1600191369-28040-4-git-send-email-gene.chen.richtek@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600191369-28040-1-git-send-email-gene.chen.richtek@gmail.com> References: <1600191369-28040-1-git-send-email-gene.chen.richtek@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200915_133628_845093_FADC0302 X-CRM114-Status: GOOD ( 32.00 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [gene.chen.richtek[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gene_chen@richtek.com, lars@metafoo.de, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, cy_huang@richtek.com, benjamin.chao@mediatek.com, linux-mediatek@lists.infradead.org, pmeerw@pmeerw.net, knaack.h@gmx.de, Wilma.Wu@mediatek.com, linux-arm-kernel@lists.infradead.org, shufan_lee@richtek.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Gene Chen Add MT6360 ADC driver include Charger Current, Voltage, and Temperature. Signed-off-by: Gene Chen --- drivers/iio/adc/Kconfig | 11 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6360-adc.c | 357 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 369 insertions(+) create mode 100644 drivers/iio/adc/mt6360-adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 66d9cc0..8d36b66 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -703,6 +703,17 @@ config MCP3911 This driver can also be built as a module. If so, the module will be called mcp3911. +config MEDIATEK_MT6360_ADC + tristate "Mediatek MT6360 ADC driver" + depends on MFD_MT6360 + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say Y here to enable MT6360 ADC support. + Integrated for System Monitoring includes + is used in smartphones and tablets and supports a 11 channel + general purpose ADC. + config MEDIATEK_MT6577_AUXADC tristate "MediaTek AUXADC driver" depends on ARCH_MEDIATEK || COMPILE_TEST diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 90f94ad..5fca90a 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -65,6 +65,7 @@ obj-$(CONFIG_MAX9611) += max9611.o obj-$(CONFIG_MCP320X) += mcp320x.o obj-$(CONFIG_MCP3422) += mcp3422.o obj-$(CONFIG_MCP3911) += mcp3911.o +obj-$(CONFIG_MEDIATEK_MT6360_ADC) += mt6360-adc.o obj-$(CONFIG_MEDIATEK_MT6577_AUXADC) += mt6577_auxadc.o obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o obj-$(CONFIG_MESON_SARADC) += meson_saradc.o diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c new file mode 100644 index 0000000..b256d0a --- /dev/null +++ b/drivers/iio/adc/mt6360-adc.c @@ -0,0 +1,357 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define MT6360_REG_PMUCHGCTRL3 0x313 +#define MT6360_REG_PMUADCCFG 0x356 +#define MT6360_REG_PMUADCIDLET 0x358 +#define MT6360_REG_PMUADCRPT1 0x35A + +/* PMUCHGCTRL3 0x313 */ +#define MT6360_AICR_MASK GENMASK(7, 2) +#define MT6360_AICR_SHFT 2 +#define MT6360_AICR_400MA 0x6 +/* PMUADCCFG 0x356 */ +#define MT6360_ADCEN_MASK 0x8000 +/* PMUADCRPT1 0x35A */ +#define MT6360_PREFERCH_MASK GENMASK(7, 4) +#define MT6360_PREFERCH_SHFT 4 +#define MT6360_RPTCH_MASK GENMASK(3, 0) +#define MT6360_NO_PREFER 15 + +/* Time in ms */ +#define ADC_WAIT_TIME_MS 25 + +enum { + MT6360_CHAN_USBID = 0, + MT6360_CHAN_VBUSDIV5, + MT6360_CHAN_VBUSDIV2, + MT6360_CHAN_VSYS, + MT6360_CHAN_VBAT, + MT6360_CHAN_IBUS, + MT6360_CHAN_IBAT, + MT6360_CHAN_CHG_VDDP, + MT6360_CHAN_TEMP_JC, + MT6360_CHAN_VREF_TS, + MT6360_CHAN_TS, + MT6360_CHAN_MAX +}; + +struct mt6360_adc_data { + struct device *dev; + struct regmap *regmap; + struct mutex adc_lock; + ktime_t last_off_timestamps[MT6360_CHAN_MAX]; +}; + +static int mt6360_adc_read_channel(struct mt6360_adc_data *mad, int channel, int *val) +{ + __be16 adc_enable; + u8 rpt[3]; + ktime_t start_t, predict_end_t; + unsigned int pre_wait_time; + int ret; + + mutex_lock(&mad->adc_lock); + + /* Select the preferred ADC channel */ + ret = regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK, + channel << MT6360_PREFERCH_SHFT); + if (ret) + goto out_adc_lock; + + adc_enable = cpu_to_be16(MT6360_ADCEN_MASK | BIT(channel)); + ret = regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, + sizeof(__be16)); + if (ret) + goto out_adc_lock; + + start_t = ktime_get(); + predict_end_t = ktime_add_ms(mad->last_off_timestamps[channel], 2 * ADC_WAIT_TIME_MS); + + if (ktime_after(start_t, predict_end_t)) + pre_wait_time = ADC_WAIT_TIME_MS; + else + pre_wait_time = 3 * ADC_WAIT_TIME_MS; + + msleep(pre_wait_time); + + while (true) { + ret = regmap_raw_read(mad->regmap, MT6360_REG_PMUADCRPT1, rpt, sizeof(rpt)); + if (ret) + goto out_adc_conv; + + /* + * There are two functions, ZCV and TypeC OTP, running ADC VBAT and TS in + * background, and ADC samples are taken on a fixed frequency no matter read the + * previous one or not. + * To avoid conflict, We set minimum time threshold after enable ADC and + * check report channel is the same. + * The worst case is run the same ADC twice and background function is also running, + * ADC conversion sequence is desire channel before start ADC, background ADC, + * desire channel after start ADC. + * So the minimum correct data is three times of typical conversion time. + */ + if ((rpt[0] & MT6360_RPTCH_MASK) == channel) + break; + + msleep(ADC_WAIT_TIME_MS); + } + + /* rpt[1]: ADC_HI_BYTE, rpt[2]: ADC_LOW_BYTE */ + *val = be16_to_cpup((__be16 *)(rpt + 1)); + ret = IIO_VAL_INT; + +out_adc_conv: + /* Only keep ADC enable */ + adc_enable = cpu_to_be16(MT6360_ADCEN_MASK); + regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, sizeof(__be16)); + mad->last_off_timestamps[channel] = ktime_get(); + /* Config prefer channel to NO_PREFER */ + regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK, + MT6360_NO_PREFER << MT6360_PREFERCH_SHFT); +out_adc_lock: + mutex_unlock(&mad->adc_lock); + + return ret; +} + +static int mt6360_adc_read_scale(struct mt6360_adc_data *mad, int channel, int *val, int *val2) +{ + unsigned int regval; + int ret; + + switch (channel) { + case MT6360_CHAN_USBID: + fallthrough; + case MT6360_CHAN_VSYS: + fallthrough; + case MT6360_CHAN_VBAT: + fallthrough; + case MT6360_CHAN_CHG_VDDP: + fallthrough; + case MT6360_CHAN_VREF_TS: + fallthrough; + case MT6360_CHAN_TS: + *val = 1250; + return IIO_VAL_INT; + case MT6360_CHAN_VBUSDIV5: + *val = 6250; + return IIO_VAL_INT; + case MT6360_CHAN_VBUSDIV2: + fallthrough; + case MT6360_CHAN_IBUS: + fallthrough; + case MT6360_CHAN_IBAT: + *val = 2500; + + if (channel == MT6360_CHAN_IBUS) { + /* IBUS will be affected by input current limit for the different Ron */ + /* Check whether the config is <400mA or not */ + ret = regmap_read(mad->regmap, MT6360_REG_PMUCHGCTRL3, ®val); + if (ret) + return ret; + + regval = (regval & MT6360_AICR_MASK) >> MT6360_AICR_SHFT; + if (regval < MT6360_AICR_400MA) + *val = 1900; + } + + return IIO_VAL_INT; + case MT6360_CHAN_TEMP_JC: + *val = 105; + *val2 = 100; + return IIO_VAL_FRACTIONAL; + } + + return -EINVAL; +} + +static int mt6360_adc_read_offset(struct mt6360_adc_data *mad, int channel, int *val) +{ + *val = (channel == MT6360_CHAN_TEMP_JC) ? -80 : 0; + return IIO_VAL_INT; + +} + +static int mt6360_adc_read_raw(struct iio_dev *iio_dev, const struct iio_chan_spec *chan, + int *val, int *val2, long mask) +{ + struct mt6360_adc_data *mad = iio_priv(iio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + return mt6360_adc_read_channel(mad, chan->channel, val); + case IIO_CHAN_INFO_SCALE: + return mt6360_adc_read_scale(mad, chan->channel, val, val2); + case IIO_CHAN_INFO_OFFSET: + return mt6360_adc_read_offset(mad, chan->channel, val); + } + + return -EINVAL; +} + +static const struct iio_info mt6360_adc_iio_info = { + .read_raw = mt6360_adc_read_raw, +}; + +#define MT6360_ADC_CHAN(_idx, _type) { \ + .type = _type, \ + .channel = MT6360_CHAN_##_idx, \ + .scan_index = MT6360_CHAN_##_idx, \ + .extend_name = #_idx, \ + .datasheet_name = #_idx, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + }, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ +} + +static const struct iio_chan_spec mt6360_adc_channels[] = { + MT6360_ADC_CHAN(USBID, IIO_VOLTAGE), + MT6360_ADC_CHAN(VBUSDIV5, IIO_VOLTAGE), + MT6360_ADC_CHAN(VBUSDIV2, IIO_VOLTAGE), + MT6360_ADC_CHAN(VSYS, IIO_VOLTAGE), + MT6360_ADC_CHAN(VBAT, IIO_VOLTAGE), + MT6360_ADC_CHAN(IBUS, IIO_CURRENT), + MT6360_ADC_CHAN(IBAT, IIO_CURRENT), + MT6360_ADC_CHAN(CHG_VDDP, IIO_VOLTAGE), + MT6360_ADC_CHAN(TEMP_JC, IIO_TEMP), + MT6360_ADC_CHAN(VREF_TS, IIO_VOLTAGE), + MT6360_ADC_CHAN(TS, IIO_VOLTAGE), + IIO_CHAN_SOFT_TIMESTAMP(MT6360_CHAN_MAX), +}; + +static irqreturn_t mt6360_adc_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct mt6360_adc_data *mad = iio_priv(indio_dev); + struct { + u16 values[MT6360_CHAN_MAX]; + int64_t timestamp; + } data; + int i = 0, bit, val, ret; + + for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { + ret = mt6360_adc_read_channel(mad, bit, &val); + if (ret < 0) { + dev_warn(&indio_dev->dev, "Failed to get channel %d conversion val\n", bit); + goto out; + } + + data.values[i++] = val; + } + iio_push_to_buffers_with_timestamp(indio_dev, &data, iio_get_time_ns(indio_dev)); +out: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static inline int mt6360_adc_reset(struct mt6360_adc_data *info) +{ + __be16 adc_enable; + ktime_t all_off_time; + int i, ret; + + /* Clear ADC idle wait time to 0 */ + ret = regmap_write(info->regmap, MT6360_REG_PMUADCIDLET, 0); + if (ret) + return ret; + + /* Only keep ADC enable, but keep all channels off */ + adc_enable = cpu_to_be16(MT6360_ADCEN_MASK); + ret = regmap_raw_write(info->regmap, MT6360_REG_PMUADCCFG, (void *)&adc_enable, + sizeof(__be16)); + if (ret) + return ret; + + /* Reset all channel off time to the current one */ + all_off_time = ktime_get(); + for (i = 0; i < MT6360_CHAN_MAX; i++) + info->last_off_timestamps[i] = all_off_time; + + return 0; +} + +static int mt6360_adc_probe(struct platform_device *pdev) +{ + struct mt6360_adc_data *mad; + struct regmap *regmap; + struct iio_dev *indio_dev; + int ret; + + regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!regmap) { + dev_err(&pdev->dev, "Failed to get parent regmap\n"); + return -ENODEV; + } + + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*mad)); + if (!indio_dev) + return -ENOMEM; + + mad = iio_priv(indio_dev); + mad->dev = &pdev->dev; + mad->regmap = regmap; + mutex_init(&mad->adc_lock); + + ret = mt6360_adc_reset(mad); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to reset adc\n"); + return ret; + } + + indio_dev->name = dev_name(&pdev->dev); + indio_dev->dev.parent = &pdev->dev; + indio_dev->info = &mt6360_adc_iio_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = mt6360_adc_channels; + indio_dev->num_channels = ARRAY_SIZE(mt6360_adc_channels); + + ret = devm_iio_triggered_buffer_setup(&pdev->dev, indio_dev, NULL, + mt6360_adc_trigger_handler, NULL); + if (ret) { + dev_err(&pdev->dev, "Failed to allocate iio trigger buffer\n"); + return ret; + } + + return devm_iio_device_register(&pdev->dev, indio_dev); +} + +static const struct of_device_id __maybe_unused mt6360_adc_of_id[] = { + { .compatible = "mediatek,mt6360-adc", }, + {} +}; +MODULE_DEVICE_TABLE(of, mt6360_adc_of_id); + +static struct platform_driver mt6360_adc_driver = { + .driver = { + .name = "mt6360-adc", + .of_match_table = mt6360_adc_of_id, + }, + .probe = mt6360_adc_probe, +}; +module_platform_driver(mt6360_adc_driver); + +MODULE_AUTHOR("Gene Chen "); +MODULE_DESCRIPTION("MT6360 ADC Driver"); +MODULE_LICENSE("GPL v2");