From patchwork Thu Apr 27 23:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Hauser X-Patchwork-Id: 677652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15F6DC77B73 for ; Thu, 27 Apr 2023 23:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344308AbjD0XgR (ORCPT ); Thu, 27 Apr 2023 19:36:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344335AbjD0XgN (ORCPT ); Thu, 27 Apr 2023 19:36:13 -0400 Received: from sonic301-22.consmr.mail.ir2.yahoo.com (sonic301-22.consmr.mail.ir2.yahoo.com [77.238.176.99]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAADC3C01 for ; Thu, 27 Apr 2023 16:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1682638568; bh=TVyy9/b03N8nbazd1B41Q2wdYfTHpwuv2C4n1t0mm1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=EaLOn+/XmXNN5NFCL8n1L944a6/vsnMqagPbWxd3/nPRBB0Sr+FBxCNoUpDKFCSlol+8tmPnk8R1wmRhUHTcm61YbSuez31WXeKWNbqr8ys7iavHwydNKplNoJeR3cNFCuh9Ga+bh2e4U0C1ySK9iJUBQpluNExPZPHFv1an3WGHCggPiWfFPBn8E+0Lgr0S2NuRNCPi52/DfVCtJNzC+KEVdFdRKCmMifeKBxSEIMI7fgIlCXIplnuyjPMdDvf4GBgVDdSz0mOTrvVJFWmKG35ShCDv6eM+HrqQ9Q5FzrHOcOjQOsNjucDIVgg+Sht754s54geGZRtQY3zKzusTSA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1682638568; bh=H6QAeUAfPU8qA9SFl4JWKCkwkojo3613EmzTYADDT/f=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=i2P8RaevaCe+BjtX/tY7kyCt6QvD65fNG5WjQ4wW7SPdcYhVZkEa1UlSyRRgOL7truX53tZA5XI+mpr8x/AYwsQaCqqt1YiCGhGPEu5Y26lEe0aZq8jntWgrmuWWoKySz/xj8lawjprmMYGENWhBILiN/Di1JzkADLzdJLxieRbJUMowbtElV9AssxTzySCKYs31YdOyd05xqMrup+Sep3hLt8UXC7RG/dFqHFyvByviYfHwPhnLgyGHND9UE1NaYyvgox6u09gZ2anCpyspZOaTulErtjS1vXNnaO84egpIEMOTX7exjJJ1JmlKx7mzFlqqPyHCvK8IB+hiK5JpQQ== X-YMail-OSG: GxSgUtUVM1mDps3zNb2GewA1aDRc7SuXvavYTqd8fqOfd3pmslChq0hsY4SAgPZ szi1nfGO89PxaeJDdmcuco7XrLzn_vb6fQUWyMfYu5Jp04RvNbHCc9KlLXzZONzP3OhYB09QjPLe 1.ylwdZH0L0rDNLh9Y_dyYsKZB6ThvwON3rQahCpQdu57KYbHO_IXujOr.6wSyxanze.lu6ilFIr QSzirJ5HuZeaZRLh3tLEASd4yHyuhLaQeplZRAWfnKokd8CHRLT95Qsv5i_I6wWTyWKWvQ9QBkCP OcpuVFnX8uLYs33xoWKFKdR5uw5jq0mUJhJOtstkJEuxinurELp6LGWrk1zvo0oKQ9Ze54khgzXR .Sqt6wd2hIRSMJq_xOv5097gQ1QlH9jJ2RF1QEEqJki_ejsI8Cwg5YlTMlCDWC6Q6gRYBB6IXl_j XVQWBZcq5qxnc4.DmgI3eqa.hUrScCTtzmPepLG21dmHC6H8zsoWg0qcmLlMpcYWzdvlti_v2Yfd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4c0Ept9_ZG4C6tCplBwimG3rRmaT6a8AQttdPnr4LXhOFxDyR4Gtj3bh9XLP0cWF26bONa.ksxO XfXleSMJ3yFDJSFOvpvAuqb301ai2vioS05Y8Ke.qS2rR_m2GNI5Aw84F0vIN8GrLcGCdgTuNCfI NW0PejYQrMKiN4KygFHgSiDoDX1kzfWhD_6608hURIyjE93sFbFoeIZhEcnZRs0jqCzPVZLyy4fg x.J5p0MgY4Fmll5BJTGMmGFVWedKnhUQPCgDjWWfoLVjX5l2z6rkcRv8UF1VtR_ZWcUHj8afvW81 TGTokowmSJF0eHmMqvNywbMIP0ZmZYISvEIRU2TyVCZQlPnpK.K3tNE3DWuyCJD18uiTC2ok9mJ0 nE_9anX5ewbjV_kxyEuPsQdDUJ48YeFdQkBWCcnwtx_NsTP65rC5eBJ5SCcMKVjR0vJ_xZEZdg0x 9tBm547gKJiIZN.UMgcZUedYsXqbOPvuLLhoSC0MN_7pIGNscdOUn5xCjTdEZx.5Zg5LgxLdiQFC W3HYxQI9KC4D5adsoOdbBhz3mRuuW4eFVznLqVoMSSp4mlcPDwguWtpal7iiUj9Pfc6e356lWJm7 e6cRa4tfxbfGj3mioOk4LIzw_3EzZ5HThE0fL6qagUT91K3zuvwPvesl.mlp9dzBtWsK1qPof98O X7lSM8Cy2v9be_ALe1Xl9S.0ckFyJKkUYXCmq_eDdY56UGVuA_7wSYcCSGmhMIQ_B_9ngqbqaibD etHGEMGkrvGf4cc2bG16a7R97.6Aq X-Sonic-MF: X-Sonic-ID: 8394d146-4d61-4725-9ab6-e269909a2dbd Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ir2.yahoo.com with HTTP; Thu, 27 Apr 2023 23:36:08 +0000 Received: by hermes--production-ir2-74cd8fc864-d5c78 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID b559be960ee93a958c6ba15207aea559; Thu, 27 Apr 2023 23:36:03 +0000 (UTC) From: Jakob Hauser To: Sebastian Reichel , Lee Jones , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: Beomho Seo , Chanwoo Choi , Stephan Gerhold , Raymond Hackley , Pavel Machek , Axel Lin , ChiYuan Huang , Linus Walleij , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Jakob Hauser Subject: [PATCH v3 7/8] power: supply: rt5033_battery: Adopt status property from charger Date: Fri, 28 Apr 2023 01:30:10 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The rt5033-battery fuelgauge can't get a status by itself. The rt5033-charger can, let's get this value. Tested-by: Raymond Hackley Signed-off-by: Jakob Hauser --- drivers/power/supply/rt5033_battery.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c index 5c04cf305219..a6520716d813 100644 --- a/drivers/power/supply/rt5033_battery.c +++ b/drivers/power/supply/rt5033_battery.c @@ -12,6 +12,26 @@ #include #include +static int rt5033_battery_get_status(struct i2c_client *client) +{ + struct power_supply *charger; + union power_supply_propval val; + int ret; + + charger = power_supply_get_by_name("rt5033-charger"); + if (!charger) + return POWER_SUPPLY_STATUS_UNKNOWN; + + ret = power_supply_get_property(charger, POWER_SUPPLY_PROP_STATUS, &val); + if (ret) { + power_supply_put(charger); + return POWER_SUPPLY_STATUS_UNKNOWN; + } + + power_supply_put(charger); + return val.intval; +} + static int rt5033_battery_get_capacity(struct i2c_client *client) { struct rt5033_battery *battery = i2c_get_clientdata(client); @@ -84,6 +104,9 @@ static int rt5033_battery_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CAPACITY: val->intval = rt5033_battery_get_capacity(battery->client); break; + case POWER_SUPPLY_PROP_STATUS: + val->intval = rt5033_battery_get_status(battery->client); + break; default: return -EINVAL; } @@ -96,6 +119,7 @@ static enum power_supply_property rt5033_battery_props[] = { POWER_SUPPLY_PROP_VOLTAGE_OCV, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_CAPACITY, + POWER_SUPPLY_PROP_STATUS, }; static const struct regmap_config rt5033_battery_regmap_config = {