From patchwork Sat Jul 3 08:42:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 12356929 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 4482BC07E98 for ; Sat, 3 Jul 2021 08:42:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 262A1610A2 for ; Sat, 3 Jul 2021 08:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbhGCIpR (ORCPT ); Sat, 3 Jul 2021 04:45:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbhGCIpQ (ORCPT ); Sat, 3 Jul 2021 04:45:16 -0400 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a01:238:4321:8900:456f:ecd6:43e:202c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B0EEC061762; Sat, 3 Jul 2021 01:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xLwbIydJ/1+GsatuQCc4utjxtl8RBJMHU2IpjZQ0Cis=; b=CHAl8F+nQos1V0SL7OXB2F4aEJ BAIJ205KxTwOYyuaLFK9sN3r8YZ5kx/LW6xKSu/0s/oI9tcLWO1iLeJyzM/9RWdPWfE9p79VShTtY +y9Z9N/LW3V4GrVU5xRjS6YaHvgdKHkTRLxJa4jRDkl1RI6yW3QHwmZde04kf7PfnY9s=; Received: from p200300ccff37da001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff37:da00:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1lzbEU-0006Nh-At; Sat, 03 Jul 2021 10:42:38 +0200 Received: from andi by aktux with local (Exim 4.92) (envelope-from ) id 1lzbET-0008HB-QE; Sat, 03 Jul 2021 10:42:37 +0200 From: Andreas Kemnade To: lee.jones@linaro.org, robh+dt@kernel.org, jic23@kernel.org, lars@metafoo.de, sre@kernel.org, andreas@kemnade.info, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, leonard.crestez@nxp.com, letux-kernel@openphoenux.org Subject: [PATCH 1/4] dt-bindings: mfd: ricoh,rn5t618: ADC related nodes and properties Date: Sat, 3 Jul 2021 10:42:21 +0200 Message-Id: <20210703084224.31623-2-andreas@kemnade.info> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210703084224.31623-1-andreas@kemnade.info> References: <20210703084224.31623-1-andreas@kemnade.info> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add ADC related nodes and properties. This will allow to wire up ADC channels to consumers, especially to measure input voltages by the power subdevice. Signed-off-by: Andreas Kemnade --- .../bindings/mfd/ricoh,rn5t618.yaml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/ricoh,rn5t618.yaml b/Documentation/devicetree/bindings/mfd/ricoh,rn5t618.yaml index 032a7fb0b4a7..185f87a14a54 100644 --- a/Documentation/devicetree/bindings/mfd/ricoh,rn5t618.yaml +++ b/Documentation/devicetree/bindings/mfd/ricoh,rn5t618.yaml @@ -73,6 +73,48 @@ properties: description: | See Documentation/devicetree/bindings/power/power-controller.txt + adc: + type: object + + properties: + compatible: + enum: + - ricoh,rn5t618-adc + - ricoh,rc5t619-adc + + "#io-channel-cells": + const: 1 + + additionalProperties: false + + required: + - compatible + - "#io-channel-cells" + + power: + type: object + + properties: + compatible: + enum: + - ricoh,rn5t618-power + - ricoh,rc5t619-power + + io-channels: + items: + - description: ADP Voltage Channel + - description: USB Voltage Channel + + io-channel-names: + items: + - const: vadp + - const: vusb + + additionalProperties: false + + required: + - compatible + regulators: type: object @@ -96,6 +138,17 @@ examples: interrupts = <11 IRQ_TYPE_EDGE_FALLING>; system-power-controller; + rn5t618_adc: adc { + compatible = "ricoh,rn5t618-adc"; + #io-channel-cells = <1>; + }; + + power { + compatible = "ricoh,rn5t618-power"; + io-channels = <&rn5t618_adc 2>, <&rn5t618_adc 3>; + io-channel-names = "vadp", "vusb"; + }; + regulators { DCDC1 { regulator-min-microvolt = <1050000>; From patchwork Sat Jul 3 08:42:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 12356931 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 809F6C07E9D for ; Sat, 3 Jul 2021 08:42:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F0DC6142F for ; Sat, 3 Jul 2021 08:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbhGCIpT (ORCPT ); Sat, 3 Jul 2021 04:45:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230042AbhGCIpQ (ORCPT ); Sat, 3 Jul 2021 04:45:16 -0400 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a01:238:4321:8900:456f:ecd6:43e:202c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A0BFC061762; Sat, 3 Jul 2021 01:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gmpqjeb2FQLuOjby3N4bw5cNgvYtJfKhiZNowCwzojg=; b=AE6c81egYRW8uAmvlFYcDMKz+O bx4qtEIwooQs4T9WrZesilrCH0qI7hzQpkNzE5e5B+rtyPru08FrJyTzZVRJJJK0WLsSHSC7MVpsK 4ux5EaKK2dUVrUH2WE3AoyOuPPyQsyvVjD30YJGinYZWbE8bQtd1TKBbxL6p2c+c5uuo=; Received: from p200300ccff37da001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff37:da00:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1lzbEV-0006O0-S0; Sat, 03 Jul 2021 10:42:40 +0200 Received: from andi by aktux with local (Exim 4.92) (envelope-from ) id 1lzbEV-0008HQ-HY; Sat, 03 Jul 2021 10:42:39 +0200 From: Andreas Kemnade To: lee.jones@linaro.org, robh+dt@kernel.org, jic23@kernel.org, lars@metafoo.de, sre@kernel.org, andreas@kemnade.info, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, leonard.crestez@nxp.com, letux-kernel@openphoenux.org Subject: [PATCH 2/4] mfd: rn5t618: Add of compatibles for ADC and power Date: Sat, 3 Jul 2021 10:42:22 +0200 Message-Id: <20210703084224.31623-3-andreas@kemnade.info> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210703084224.31623-1-andreas@kemnade.info> References: <20210703084224.31623-1-andreas@kemnade.info> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This allows having devicetree nodes for the subdevices. Signed-off-by: Andreas Kemnade --- drivers/mfd/rn5t618.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c index 384acb459427..b916c7471ca3 100644 --- a/drivers/mfd/rn5t618.c +++ b/drivers/mfd/rn5t618.c @@ -24,8 +24,10 @@ static const struct mfd_cell rn5t618_cells[] = { }; static const struct mfd_cell rc5t619_cells[] = { - { .name = "rn5t618-adc" }, - { .name = "rn5t618-power" }, + { .name = "rn5t618-adc", + .of_compatible = "ricoh,rc5t619-adc" }, + { .name = "rn5t618-power", + .of_compatible = "ricoh,rc5t619-power" }, { .name = "rn5t618-regulator" }, { .name = "rc5t619-rtc" }, { .name = "rn5t618-wdt" }, From patchwork Sat Jul 3 08:42:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 12356933 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 82CAEC11F66 for ; Sat, 3 Jul 2021 08:42:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 731FF6143F for ; Sat, 3 Jul 2021 08:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbhGCIpU (ORCPT ); Sat, 3 Jul 2021 04:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbhGCIpR (ORCPT ); Sat, 3 Jul 2021 04:45:17 -0400 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a01:238:4321:8900:456f:ecd6:43e:202c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D656C061762; Sat, 3 Jul 2021 01:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PcaF3iNFdy45vSe79yOejDShPKLFK8srNP61lqCrY68=; b=W5rLdN/qve2ZVAttZWWbzruvhy BUWzTY8oI62itwlpxylIVQZDZWAn6HPjDrZsnC2OX4hPsrjIsBk+WMk4GQFZlPrl5yN4pjmCqgXyE 4vnpQmAALPktsGKr+5Ylm5Od75ELpBLDV9pQmiAlZrth4hSoISQiuucalmkMmvVUNSeA=; Received: from p200300ccff37da001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff37:da00:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1lzbEW-0006OC-QL; Sat, 03 Jul 2021 10:42:40 +0200 Received: from andi by aktux with local (Exim 4.92) (envelope-from ) id 1lzbEW-0008Hf-FE; Sat, 03 Jul 2021 10:42:40 +0200 From: Andreas Kemnade To: lee.jones@linaro.org, robh+dt@kernel.org, jic23@kernel.org, lars@metafoo.de, sre@kernel.org, andreas@kemnade.info, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, leonard.crestez@nxp.com, letux-kernel@openphoenux.org Subject: [PATCH 3/4] iio: rn5t618: Add devicetree support Date: Sat, 3 Jul 2021 10:42:23 +0200 Message-Id: <20210703084224.31623-4-andreas@kemnade.info> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210703084224.31623-1-andreas@kemnade.info> References: <20210703084224.31623-1-andreas@kemnade.info> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add devicetree support to be able to easily get the channels from another device. Signed-off-by: Andreas Kemnade --- drivers/iio/adc/rn5t618-adc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/rn5t618-adc.c b/drivers/iio/adc/rn5t618-adc.c index 7010c4276947..feba19f91574 100644 --- a/drivers/iio/adc/rn5t618-adc.c +++ b/drivers/iio/adc/rn5t618-adc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -218,6 +219,7 @@ static int rn5t618_adc_probe(struct platform_device *pdev) init_completion(&adc->conv_completion); iio_dev->name = dev_name(&pdev->dev); + iio_dev->dev.of_node = pdev->dev.of_node; iio_dev->info = &rn5t618_adc_iio_info; iio_dev->modes = INDIO_DIRECT_MODE; iio_dev->channels = rn5t618_adc_iio_channels; @@ -242,9 +244,19 @@ static int rn5t618_adc_probe(struct platform_device *pdev) return devm_iio_device_register(adc->dev, iio_dev); } +#ifdef CONFIG_OF +static const struct of_device_id rn5t618_adc_of_match[] = { + { .compatible = "ricoh,rc5t619-adc", }, + { .compatible = "ricoh,rn5t618-adc", }, + { }, +}; +MODULE_DEVICE_TABLE(of, rn5t618_adc_of_match); +#endif + static struct platform_driver rn5t618_adc_driver = { .driver = { - .name = "rn5t618-adc", + .name = "rn5t618-adc", + .of_match_table = of_match_ptr(rn5t618_adc_of_match), }, .probe = rn5t618_adc_probe, }; From patchwork Sat Jul 3 08:42:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 12356935 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 89F15C47E48 for ; Sat, 3 Jul 2021 08:42:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66C5E61442 for ; Sat, 3 Jul 2021 08:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbhGCIpT (ORCPT ); Sat, 3 Jul 2021 04:45:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbhGCIpS (ORCPT ); Sat, 3 Jul 2021 04:45:18 -0400 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a01:238:4321:8900:456f:ecd6:43e:202c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12185C061762; Sat, 3 Jul 2021 01:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20180802; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PFCM19IYyhz7jH3VrV8Q9fkUeAhfoXHRT3367WSPUVc=; b=D6+pjJDGxiqOuFTDwu62WS7x7O XacLijYjvp+DBB9APz5mEGC8TO3rYv/Oki/zn9/+MAeOpapdWONIp15/3ip8rGHfVP6yiMNcGL+Cg hTNgT7ABQtIIRI8sHuppY9lWRHgFJlYGeIqVrA8VB6uAwzy7JnkxYq3G8iCS+qk2YwAs=; Received: from p200300ccff37da001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff37:da00:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1lzbEX-0006OU-DJ; Sat, 03 Jul 2021 10:42:41 +0200 Received: from andi by aktux with local (Exim 4.92) (envelope-from ) id 1lzbEX-0008Hu-2W; Sat, 03 Jul 2021 10:42:41 +0200 From: Andreas Kemnade To: lee.jones@linaro.org, robh+dt@kernel.org, jic23@kernel.org, lars@metafoo.de, sre@kernel.org, andreas@kemnade.info, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, leonard.crestez@nxp.com, letux-kernel@openphoenux.org Subject: [PATCH 4/4] power: supply: rn5t618: Add voltage_now property Date: Sat, 3 Jul 2021 10:42:24 +0200 Message-Id: <20210703084224.31623-5-andreas@kemnade.info> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210703084224.31623-1-andreas@kemnade.info> References: <20210703084224.31623-1-andreas@kemnade.info> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Read voltage_now via IIO and provide the property. Signed-off-by: Andreas Kemnade Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/power/supply/rn5t618_power.c | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/power/supply/rn5t618_power.c b/drivers/power/supply/rn5t618_power.c index 819061918b2a..b062208c8a91 100644 --- a/drivers/power/supply/rn5t618_power.c +++ b/drivers/power/supply/rn5t618_power.c @@ -9,10 +9,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -64,6 +66,8 @@ struct rn5t618_power_info { struct power_supply *battery; struct power_supply *usb; struct power_supply *adp; + struct iio_channel *channel_vusb; + struct iio_channel *channel_vadp; int irq; }; @@ -77,6 +81,7 @@ static enum power_supply_usb_type rn5t618_usb_types[] = { static enum power_supply_property rn5t618_usb_props[] = { /* input current limit is not very accurate */ POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, + POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_ONLINE, @@ -85,6 +90,7 @@ static enum power_supply_property rn5t618_usb_props[] = { static enum power_supply_property rn5t618_adp_props[] = { /* input current limit is not very accurate */ POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, + POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_ONLINE, }; @@ -464,6 +470,16 @@ static int rn5t618_adp_get_property(struct power_supply *psy, val->intval = FROM_CUR_REG(regval); break; + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + if (!info->channel_vadp) + return -ENODATA; + + ret = iio_read_channel_processed(info->channel_vadp, &val->intval); + if (ret < 0) + return ret; + + val->intval *= 1000; + break; default: return -EINVAL; } @@ -589,6 +605,16 @@ static int rn5t618_usb_get_property(struct power_supply *psy, val->intval = FROM_CUR_REG(regval); } break; + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + if (!info->channel_vusb) + return -ENODATA; + + ret = iio_read_channel_processed(info->channel_vusb, &val->intval); + if (ret < 0) + return ret; + + val->intval *= 1000; + break; default: return -EINVAL; } @@ -711,6 +737,28 @@ static int rn5t618_power_probe(struct platform_device *pdev) platform_set_drvdata(pdev, info); + info->channel_vusb = devm_iio_channel_get(&pdev->dev, "vusb"); + if (IS_ERR(info->channel_vusb)) { + ret = PTR_ERR(info->channel_vusb); + if (ret == -EPROBE_DEFER) + return ret; + + dev_warn(&pdev->dev, "could not request vusb iio channel (%d)", + ret); + info->channel_vusb = NULL; + } + + info->channel_vadp = devm_iio_channel_get(&pdev->dev, "vadp"); + if (IS_ERR(info->channel_vadp)) { + ret = PTR_ERR(info->channel_vadp); + if (ret == -EPROBE_DEFER) + return ret; + + dev_warn(&pdev->dev, "could not request vadp iio channel (%d)", + ret); + info->channel_vadp = NULL; + } + ret = regmap_read(info->rn5t618->regmap, RN5T618_CONTROL, &v); if (ret) return ret; @@ -778,9 +826,17 @@ static int rn5t618_power_probe(struct platform_device *pdev) return 0; } +static const struct of_device_id rn5t618_power_of_match[] = { + {.compatible = "ricoh,rc5t619-power", }, + {.compatible = "ricoh,rn5t618-power", }, + { } +}; +MODULE_DEVICE_TABLE(of, rn5t618_power_of_match); + static struct platform_driver rn5t618_power_driver = { .driver = { .name = "rn5t618-power", + .of_match_table = of_match_ptr(rn5t618_power_of_match), }, .probe = rn5t618_power_probe, };