From patchwork Sun Apr 16 12:44:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Hauser X-Patchwork-Id: 674057 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 9FF97C77B79 for ; Sun, 16 Apr 2023 12:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbjDPMun (ORCPT ); Sun, 16 Apr 2023 08:50:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbjDPMul (ORCPT ); Sun, 16 Apr 2023 08:50:41 -0400 Received: from sonic301-21.consmr.mail.ir2.yahoo.com (sonic301-21.consmr.mail.ir2.yahoo.com [77.238.176.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA63430ED for ; Sun, 16 Apr 2023 05:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1681649436; bh=t2fvyYZS7Chh40ho3TEbOh4/xUHgvfaETlyY4tmywTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=OOQ1PErd5vd8UQBpNxVM/+o1su7VLFHpeVTHjoFaEI/k6269DK9UvDTPxwQ4+zAvhbb+vNihoXqLpfsEpi68JifWkP1Y86UsXGFZLCfwHsLeWLNVHMJFwOTX5d0/qu/xsN7vN2+QDTOG1kQkLX7uO16k22jvKd6FKxIyC6az485KViJQKH4+1bjgRgmEE7ko77Y3DKiknLD0gX9PVA6olpqmBRmK8hGIhWh8iEMc0xnhOqbHACLuR0MCnnsrwhsWDqQX/3I8hE5DchN8JZtRAsTHNTJZ5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09gjXvWtYOjQ1QnpT6X6jo31gc Aa7H0ir2L_8VjhlBbGJLIs5Os0e_Q2mXw.867RSUF2LopS7cS7cFjUNL_HVrBwobF_EyCrTomH9C JUMH6oSx2csgmSJXDHx8UiKlsdd0IZMumbQ1vS0oa5RY9JPdyFaTreMCb9i1BU3NjxSfNLMpWcWP pjQYHWHTgNAmK5BbKzY.i5tnj4aLBPLBNEqCv9DwgyJWmNjfcJM_IFNQaEVYujmV8ONxQkhg6ypB .pQ7zfXLyS2VmFxgDRyUW1PYH.ZTGj5cH35xzoLvSSV_YldkMi6LdtilEMEVHFl_aV7ihtAGqkue LQtMbMXggSqoFdfOZZgpswwgqxbnkJ5pibvgO.UBUhjK3iCQyAPW1clHZhD1RkJwvLEKZzFOoCXY ELxSViGxreHLTj.d_mXhQZEIUI3vB8GfOx5uurdySxcmUTeDxYSPZmpD5aPOXnT7dLFKrWQcmt_l FeVGShetNNRo2q5ZgMyA2jSq9HonuUcbEGnr4jwbttbcMY0UoGvr_j4rxkb6vEHhZGPKbvP_GsB7 bcUMxrDPcDeBeEU92ZmZKC67884F0c3JyUYK9xpPIq59wFts4RHjqXO4_Y_anyAcjvwPNCljvJdS _klnB8Y6l2F3Jh0mJ1SN63_OeI9vPnNN.6KeP9.VElIFb4XFYQwlnZQ47n6gaha45Fz5tirNFN_o 6ibVKE2uVv2iOzbxvcXFvbGRrHcccHO9AWbRXW73.zre_YzufJg9.ELSihlXpVdVxu_jTQmGWCIR KUIYGBsZrN9tzKp4vqPy8TXGdCn7.oyDAfodXPCNkGjraeOVNFdkc3g-- X-Sonic-MF: X-Sonic-ID: 37b66e74-6baf-4456-be0a-5c9429113131 Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ir2.yahoo.com with HTTP; Sun, 16 Apr 2023 12:50:36 +0000 Received: by hermes--production-ir2-74cd8fc864-9w846 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID e1e6b4a18b1a30b9efb33afa6a04eb6c; Sun, 16 Apr 2023 12:50:33 +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 , 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 v2 8/9] power: supply: rt5033_battery: Adopt status property from charger Date: Sun, 16 Apr 2023 14:44:35 +0200 Message-Id: <23260904aab2566faf86d2ac01a31e7f1e024e66.1681646904.git.jahau@rocketmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@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..48d4cccce4f6 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 -ENODEV; + + 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 = {