From patchwork Sun Jul 30 17:26:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svyatoslav Ryhel X-Patchwork-Id: 128278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1655523vqg; Sun, 30 Jul 2023 13:40:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFipeAmnIEA8eZ+cTeNOReQv39zljRT5UcJsokb+OJ6PjsxGOhNu3uZtp5sq/qHW2xjF4+x X-Received: by 2002:a05:6a20:1043:b0:139:fe4b:e2d2 with SMTP id gt3-20020a056a20104300b00139fe4be2d2mr8123401pzc.56.1690749631879; Sun, 30 Jul 2023 13:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690749631; cv=none; d=google.com; s=arc-20160816; b=geKywTznMgz6GXuIr3mrEZJoUXgAQBcxdUH0Pi0I2amZELiTFf0o6nQtpgFnPXz84i 4R3OcbHSS94yhIwq4FfmmOdwC2dpO33vIVloryclKyOKVUmlEyN10p9GqyKZvC14s4ll I5joZ9f8Z5yLbivyDc66gpKde04QO29026AnIoJa9WgcKVaeqc9ONdCD/2xJBoZpCwJe 554dylZZp5344BCLMQ4iUK5SXrgZv39KGIq9DYRz4EDIN2cFRlUUEcwsRDd/MlsH7WsK ADXv6vVgr9YuF/qvyS6SAtMe+RqSwucaNvgt8LluRwCgcyG4pBTWmns9zQ4U+ZSUn/pR sq2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z8kWVxhD71IIdy/AgMqM2tISpTPB47LaxO4vVrxguZc=; fh=6EttwLj8TkcYgYcXwCN3+c7mDFZsrHr1IQ/n7Iq5Tzc=; b=TWtLIXQ+G23FOmyg/g6Is2vxLeuOWKPaKNpA+wiiQxqqqm2YppOH+6HZBjljzjC/jt R3UKTe+8ggSLPerNXOX+UhzlOtUZJUjwHTHikgW5j7sxIg3v/1uNiSjJ+ldNBqZFNESu R2DLgtwhIZ3bw91+HZ7GgQCuWSgDzsCQaMzWJjS45Oezs0jINsRTMF8aSw+NOhPYOVMQ CYudG3OdAkpwb+Lm4dAtLxSOr9I9OA/CFv+sHZYWBVBNNTAl2lq10y6kN2e5AM7QwuS0 aB3U8mLVvysHKxKS+Gs6t/tPLycj93wv/yi6tEOSUC0cJhBH2H3ny2DpZAyNrH13TuWA QQ1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MC8TCH9C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a6540cb000000b0056424625528si3534019pgp.656.2023.07.30.13.40.19; Sun, 30 Jul 2023 13:40:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MC8TCH9C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbjG3R1U (ORCPT + 99 others); Sun, 30 Jul 2023 13:27:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjG3R1P (ORCPT ); Sun, 30 Jul 2023 13:27:15 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4EFE126; Sun, 30 Jul 2023 10:27:14 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-4fe27849e6aso1819377e87.1; Sun, 30 Jul 2023 10:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690738033; x=1691342833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z8kWVxhD71IIdy/AgMqM2tISpTPB47LaxO4vVrxguZc=; b=MC8TCH9CgDZVR576uMzXETmgTfuqE1VYop4dVcLL3LjAJn0Soyg/bs+FdaRgmxj9BV H5vL0/N391Q+Iu6rsGvdgxSi/XSv62QmNoiUxJ8FO4N3t7KUqR/59AX+JqO877BUXMp7 qauTQVxNpkd8qiLvE5vGLo9tV2nuLrw/H8Mrb5FIrOQbpK1vGge0139O0b91vQv5BcEh CXM3gaBUgnuY3aPQlTtgEVy+aPQVQHV1Ry4JECCwvlrag14ldQtdAioVDs3TUJCx1mBX bW1hjM5ZcTdRAKc103GwOpYgKR5ZePwf/e3IQ6mnK/NlyzDy9rfsMYvGTKdC8AyWrTse 5n5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690738033; x=1691342833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z8kWVxhD71IIdy/AgMqM2tISpTPB47LaxO4vVrxguZc=; b=VzDYA6qeZBu+bMU4o+tMDNnpoYe2WlpEjX32IM4RoIVar2DIEF9/JkUVknIcSowu+V mhXoC10ybdvPtow1dgnrxqMkqLbcywUf1ZgJZOKxI749kRO543gkWoYm8l3hLRXhUsps t0VINaZaTCWrU1/oqd2DsOWt6YMPuRWMXPsZpc24pUz0Xn+DUndk/aSQ9pC/vjn0Op5S 4RImjh/t3QIAmgP4iCBRShHhmkO+DlKzIV7j2cen0+xMWNbfsoFdHWYkc38Vh186Uyea v0XlpD6mCB28ul1YyDvdXQYNdStsKPVMWwjmOh1OKogpwm8L3Ql8iY8CIG2vdyIitMtW czMw== X-Gm-Message-State: ABy/qLaiErryyepXffNpnV7XjEfK4xjvX5jeoxjo3SDf4/swsbBWANQp d93DC7L/Ov1Z96oA1fDk+qo= X-Received: by 2002:a19:8c09:0:b0:4fe:1e74:3f3a with SMTP id o9-20020a198c09000000b004fe1e743f3amr4108295lfd.58.1690738032723; Sun, 30 Jul 2023 10:27:12 -0700 (PDT) Received: from xeon.. ([188.163.112.48]) by smtp.gmail.com with ESMTPSA id x6-20020ac24886000000b004f8555f7aa1sm1737117lfc.52.2023.07.30.10.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 10:27:12 -0700 (PDT) From: Svyatoslav Ryhel To: Iskren Chernev , Krzysztof Kozlowski , Marek Szyprowski , Matheus Castello , Sebastian Reichel , Rob Herring , Conor Dooley , Svyatoslav Ryhel Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] dt-bindings: power: supply: maxim,max17040: update properties Date: Sun, 30 Jul 2023 20:26:46 +0300 Message-Id: <20230730172648.71578-2-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230730172648.71578-1-clamor95@gmail.com> References: <20230730172648.71578-1-clamor95@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772872996647659201 X-GMAIL-MSGID: 1772879485650852264 Add status and temperature properties. Signed-off-by: Svyatoslav Ryhel --- .../bindings/power/supply/maxim,max17040.yaml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max17040.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max17040.yaml index 2627cd3eed83..4bccf25a111c 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max17040.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max17040.yaml @@ -55,6 +55,14 @@ properties: interrupts: maxItems: 1 + io-channels: + items: + - description: battery temperature + + io-channel-names: + items: + - const: temp + wakeup-source: type: boolean description: | @@ -95,3 +103,26 @@ examples: wakeup-source; }; }; + - | + #include + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + fuel-gauge@36 { + compatible = "maxim,max17043"; + reg = <0x36>; + + interrupt-parent = <&gpio>; + interrupts = <144 IRQ_TYPE_EDGE_FALLING>; + + monitored-battery = <&battery>; + power-supplies = <&charger>; + + io-channels = <&adc 8>; + io-channel-names = "temp"; + + maxim,alert-low-soc-level = <10>; + wakeup-source; + }; + }; From patchwork Sun Jul 30 17:26:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svyatoslav Ryhel X-Patchwork-Id: 128256 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1610729vqg; Sun, 30 Jul 2023 11:11:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlGZAzUvm9iNERfRdWgrDLMz6uiL8TTl06yB/WoPGsPSyScaTyQcBi/p03HiM8Zv47fSO9fe X-Received: by 2002:a05:6a20:419:b0:121:fd18:4b51 with SMTP id a25-20020a056a20041900b00121fd184b51mr7241708pza.36.1690740677935; Sun, 30 Jul 2023 11:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690740677; cv=none; d=google.com; s=arc-20160816; b=Exzxtb1Amo9+/BzGJn3SzVA4A6WAXpuGw6+MC3ZV2f6fSjEyYgM1nhYPQkkVfZA1zX CAH5NUL5AG48acb7AdS9489ZnHTZP8Tk0g/1xJklFIwjmd0EB9mXWpv516cqnJ8aI9HO e0wZ8vJxBmCBy9BB1+G+x8QSTiRZE4hJCnaxRYbRRTTiDaN0PBNSBvGcX9WkhHItYwLl oHqSAGL6NIR53D7zYQ3G3fsNuYZ2ftvFSP6XPCSMh6zVj8W0EbyTl18fKrcZ8Rfrc06/ XnGioKcv+t2Ft86hiq9lP8DVI6n7EwDc+NhpjBoqoqH7gWbrB8Oue2WVa8Knyks1I9XA FnJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JEyRUtIvngdn2xYibH+4khtHK+n4dlGEHPyQwJGcHe4=; fh=6EttwLj8TkcYgYcXwCN3+c7mDFZsrHr1IQ/n7Iq5Tzc=; b=cKyRHlPxq4mEUmdSgUfezdoeL5zx1ix5jH0SKWUB7ylMB1QyEaJrnvnYt/v9n1z1bq 3CJE2of/h8Q35Tts1MXlEW9zD49T8wpIA/6aGUGq9fAXAGY/LDjQHxjjQ1ip+pFJwDVk uYIXWx00XZr9GQeP3OR0G4NjDHArGbuBlSb22S7qrZ6fYC436I/ECw64pX1d2AlaExK1 AM4L6bRdKBHjWpJWnCLcYYZb+huisVFYpGihrlQEwBxfe7nx3yYKsWBjtxQ/2BaJj1LB aIfjoYn14OIbPNOwyEDgeNAdiD79YEiAya7drn57pvzFX3bPFUmAXudIgGkHvAbyoNmW QlWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MHPsXj5q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a63e113000000b0056427788d96si3027108pgh.70.2023.07.30.11.11.05; Sun, 30 Jul 2023 11:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=MHPsXj5q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229820AbjG3R1X (ORCPT + 99 others); Sun, 30 Jul 2023 13:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbjG3R1Q (ORCPT ); Sun, 30 Jul 2023 13:27:16 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7E4B10FE; Sun, 30 Jul 2023 10:27:15 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4f954d7309fso4654922e87.1; Sun, 30 Jul 2023 10:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690738034; x=1691342834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JEyRUtIvngdn2xYibH+4khtHK+n4dlGEHPyQwJGcHe4=; b=MHPsXj5q7Idb/kmmujI2ZV/2M4sHrPu9zJOx6PwCeT7eaqPcQHn+SPHcBq5/yRfSIe 3OtRAhFMbcy5gNQ2T7NfvgDCuILi4bWmd4RylFN1Y0sfguKKRhG5DR52hiH+OzpAnzke uZaEKQw5ARL+zn82kODJwP7+99KVGByZfYozGG/ucOUgaE6xj8RXxB/QmrLNNJNZDiuA /lHaWuPSK4d0PCi20t08FaP819doG4qixUBaPq+tEB7tsSGr2bk3UJJXQkNP0tmzZO1m p7pnPcytzY892KOP5F8fLmr/4Q15xYUV45GV+6D6vA274kg8AjYSyPsRoizlrBlbupwZ joOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690738034; x=1691342834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JEyRUtIvngdn2xYibH+4khtHK+n4dlGEHPyQwJGcHe4=; b=kIj3Eyg89lDmuPpaM2Of05RRT9WmNhjaBNBcg7TE5P2X4L95r7GSEo0yp+ACG1Mxfg 49Ds+3swO1b12rK6yvply1VOqMzAW7NRnzlKgoBXfva9hfJ4Vv/xjPqfK77tNj0rsA4y vRq6J2cpoDDhPxnbkXRcWFlgE/Vp5/SY1Ebt4D3OqR6shRa8iOdHJaHekAp0/wQyJbsW HfDXi4AAeOs84jtHnQOMU7ZflEyS+sY2XX0NBjQuDevyCjsStVbIzX8ocB1HwTJkO4k1 0m22zJIy1xRQxymKvORSjvpOHo7kf/rexRWb23Or+e+S4WX6q5+1wk2nmUsEnHcLWb7b Qgqw== X-Gm-Message-State: ABy/qLawD6sqyvNQSqWoEYiV1EZxCnf3Bqz42MJHPv3ZeMRowpmnugpP +GNEXP2A/Wba5rBhElQn9vE= X-Received: by 2002:a05:6512:ac8:b0:4fe:2b39:f3d6 with SMTP id n8-20020a0565120ac800b004fe2b39f3d6mr1070244lfu.34.1690738033849; Sun, 30 Jul 2023 10:27:13 -0700 (PDT) Received: from xeon.. ([188.163.112.48]) by smtp.gmail.com with ESMTPSA id x6-20020ac24886000000b004f8555f7aa1sm1737117lfc.52.2023.07.30.10.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 10:27:13 -0700 (PDT) From: Svyatoslav Ryhel To: Iskren Chernev , Krzysztof Kozlowski , Marek Szyprowski , Matheus Castello , Sebastian Reichel , Rob Herring , Conor Dooley , Svyatoslav Ryhel Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] power: max17040: pass status property from supplier Date: Sun, 30 Jul 2023 20:26:47 +0300 Message-Id: <20230730172648.71578-3-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230730172648.71578-1-clamor95@gmail.com> References: <20230730172648.71578-1-clamor95@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772870097100765833 X-GMAIL-MSGID: 1772870097100765833 Optionally pass status property from supplier if has support for it. If cell is online assume it is present as well. Signed-off-by: Svyatoslav Ryhel --- drivers/power/supply/max17040_battery.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index d1075959dd46..3301e8a4b16c 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -389,6 +389,7 @@ static int max17040_get_property(struct power_supply *psy, switch (psp) { case POWER_SUPPLY_PROP_ONLINE: + case POWER_SUPPLY_PROP_PRESENT: val->intval = max17040_get_online(chip); break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: @@ -400,6 +401,9 @@ static int max17040_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN: val->intval = chip->low_soc_alert; break; + case POWER_SUPPLY_PROP_STATUS: + power_supply_get_property_from_supplier(psy, psp, val); + break; default: return -EINVAL; } @@ -415,9 +419,11 @@ static const struct regmap_config max17040_regmap = { static enum power_supply_property max17040_battery_props[] = { POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, + POWER_SUPPLY_PROP_STATUS, }; static const struct power_supply_desc max17040_battery_desc = { From patchwork Sun Jul 30 17:26:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Svyatoslav Ryhel X-Patchwork-Id: 128269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1638750vqg; Sun, 30 Jul 2023 12:43:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlEKmOPGJFpa7ackgk6ndAxvUfvLeP0B0Wcu65TuCAtTb6k+o3fXbXqFXXTqBqO2xzujFe2v X-Received: by 2002:a17:906:7a08:b0:988:9621:d85f with SMTP id d8-20020a1709067a0800b009889621d85fmr4875068ejo.58.1690746184978; Sun, 30 Jul 2023 12:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690746184; cv=none; d=google.com; s=arc-20160816; b=K7qRnYwJcVzG9GMXiwWiVvaksyRUUViXhN5AIxW+UbVNFNBLb/KdL87uVInOFztgnG 2YEEdKMymU8Ar76r2j2s24AmI7VUEG4BLT11pbKatkN8dA3eKaCnq7pmMPtKGH4ZOFnr AETu6KaViShtUNNl47/g/5an1kTRusLPNWRecSdvmDZQBszWQq61Fs9xTpCcNA8mDqqz FFwx1IyYoLK40u3pCeQEUz26Izo0AcAjJZRD+WmfF/Gx3BbzRUo9FbrQ+vA66kiLubI9 awvbCFC2Qtsy6MNoNg8OIJVfpbbhvasDfgCmX2hkGO9ZyIc/NeFZCBxLrW2iukXH7jCO vkLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LCibpJFPe7+Y3gfoirmVHXZU0UMpLMY1bCCkwz1GdIg=; fh=6EttwLj8TkcYgYcXwCN3+c7mDFZsrHr1IQ/n7Iq5Tzc=; b=tTu0cfBK/WX0jGmLDhxFi4QMy68vNixX4ZIUbCH4O6E0Oz+56ZdZupX5sDJYw6+us3 9eHMxSc3d5TjJMnZEz0k2VcYmg4mQQUBMyKVhBNXw3+m9T6kNwWoUoqhYmPRSiOVjmU5 jV3rPRXsL5NmZWthZbhgYLkhsYpbTF5omLkzgJ7GwoDzW9rugMLdGeE61LE8b82IZS0l adwHqF7stpPx65ZHjEKizivv+XmZnfgvT2hVeJN038XC9XuB0ANur0XqkIUnKQHmrUny 584YGF1dqNMDfxbbhfIRO1GzP+1dt4bEd3REREivmSx6nuZBE7d4YqZYwcOAqOyPdO1g YHeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=YgmwaCdD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a056402005000b005222065ee63si2205635edu.384.2023.07.30.12.42.38; Sun, 30 Jul 2023 12:43:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=YgmwaCdD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229764AbjG3R10 (ORCPT + 99 others); Sun, 30 Jul 2023 13:27:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbjG3R1S (ORCPT ); Sun, 30 Jul 2023 13:27:18 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB606126; Sun, 30 Jul 2023 10:27:16 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4fe3678010eso300339e87.3; Sun, 30 Jul 2023 10:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690738035; x=1691342835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LCibpJFPe7+Y3gfoirmVHXZU0UMpLMY1bCCkwz1GdIg=; b=YgmwaCdDVaqwRxcXmX09BtBu0LLUNDGymwZpoaNhyj7UZwjxpun3w6hwdoNJ6GC3hh WvAPKYtQ18hKzsPmLBthILLnaH/79BQby+MQGy+Rltjowbtc1ULuWvkc/vybzXBJ6Ub+ BALb2E38Fj1VOaZapw7REBlB4sOCFojR/lTUJVH4UurbU1Dl932pgv6yRO2ahT0IYmBB s4K3foqxAE3eSITBiepmcpeGPi3LPTIf9/4UusROAhXPWWtjENErbBFSAyVZ6B4z1IcC mTO6R07nhUqpDfHD3J9+mIWa3m367vJfVhifUy7nJMR1ebymxXrVQwXQhYcObGcPZOeb yReQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690738035; x=1691342835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LCibpJFPe7+Y3gfoirmVHXZU0UMpLMY1bCCkwz1GdIg=; b=INtvGNuI/6WWYSS6qNlKT5ee0x/8k8PFxQ94p0rAzXjt44uMO3dlcFmL3I9+03ofLw dbhdxYvRJM8iFFHisIPGrZevxmvCIUHodV2h4VrzqaQ0mUWNTnj1NRvcS4BJX9ODwtha uXf+RVL+qVo//zCciIT0x/+7cACAdVFLMPkQGH4wV2N+l2z3/kecUKpUWvuTVyjQH9yj /THSS8BkwjuchFeYrSAHLVHcsYBB54437rYOTIE/RF4XYQaJc0D7MxKMbhjhUqZP1xMN eiSUlQpZ5yGycEhSBDwl1WFcbDCkLiZD6NngAPnvk+h2v7W5L+Yb78nXyyPtIvmvM7xu LV9A== X-Gm-Message-State: ABy/qLY95bct0TaVfrXecbFGlpghD/5F1hm2H1PLw3QAeIYyFT+Bupbw mNdocrAaWpV+YxzWkSZK4TvT7SWnePFn2A== X-Received: by 2002:a05:6512:1286:b0:4f8:5c90:f8a4 with SMTP id u6-20020a056512128600b004f85c90f8a4mr5626799lfs.33.1690738034935; Sun, 30 Jul 2023 10:27:14 -0700 (PDT) Received: from xeon.. ([188.163.112.48]) by smtp.gmail.com with ESMTPSA id x6-20020ac24886000000b004f8555f7aa1sm1737117lfc.52.2023.07.30.10.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 10:27:14 -0700 (PDT) From: Svyatoslav Ryhel To: Iskren Chernev , Krzysztof Kozlowski , Marek Szyprowski , Matheus Castello , Sebastian Reichel , Rob Herring , Conor Dooley , Svyatoslav Ryhel Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] power: max17040: get thermal data from adc if available Date: Sun, 30 Jul 2023 20:26:48 +0300 Message-Id: <20230730172648.71578-4-clamor95@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230730172648.71578-1-clamor95@gmail.com> References: <20230730172648.71578-1-clamor95@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772875871874137305 X-GMAIL-MSGID: 1772875871874137305 Since fuel gauge does not support thermal monitoring, some vendors may couple this fuel gauge with thermal/adc sensor to monitor battery cell exact temperature. Add this feature by adding optional iio thermal channel. Signed-off-by: Svyatoslav Ryhel --- drivers/power/supply/max17040_battery.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index 3301e8a4b16c..54db20637c87 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -18,6 +18,7 @@ #include #include #include +#include #define MAX17040_VCELL 0x02 #define MAX17040_SOC 0x04 @@ -142,6 +143,7 @@ struct max17040_chip { struct delayed_work work; struct power_supply *battery; struct chip_data data; + struct iio_channel *channel_temp; /* battery capacity */ int soc; @@ -404,6 +406,13 @@ static int max17040_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_STATUS: power_supply_get_property_from_supplier(psy, psp, val); break; + case POWER_SUPPLY_PROP_TEMP: + if (!chip->channel_temp) + return -ENODATA; + + iio_read_channel_processed_scale(chip->channel_temp, + &val->intval, 10); + break; default: return -EINVAL; } @@ -424,6 +433,7 @@ static enum power_supply_property max17040_battery_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_TEMP, }; static const struct power_supply_desc max17040_battery_desc = { @@ -469,6 +479,17 @@ static int max17040_probe(struct i2c_client *client) i2c_set_clientdata(client, chip); psy_cfg.drv_data = chip; + /* Switch to devm_iio_channel_get_optional when available */ + chip->channel_temp = devm_iio_channel_get(&client->dev, "temp"); + if (IS_ERR(chip->channel_temp)) { + ret = PTR_ERR(chip->channel_temp); + if (ret != -ENODEV) + return dev_err_probe(&client->dev, PTR_ERR(chip->channel_temp), + "failed to get temp\n"); + else + chip->channel_temp = NULL; + } + chip->battery = devm_power_supply_register(&client->dev, &max17040_battery_desc, &psy_cfg); if (IS_ERR(chip->battery)) {