From patchwork Sat May 6 15:54:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakob Hauser X-Patchwork-Id: 679692 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 36276C7EE2D for ; Sat, 6 May 2023 16:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233049AbjEFQBC (ORCPT ); Sat, 6 May 2023 12:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233119AbjEFQAk (ORCPT ); Sat, 6 May 2023 12:00:40 -0400 Received: from sonic307-54.consmr.mail.ir2.yahoo.com (sonic307-54.consmr.mail.ir2.yahoo.com [87.248.110.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F0441386D for ; Sat, 6 May 2023 09:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1683388834; bh=TVyy9/b03N8nbazd1B41Q2wdYfTHpwuv2C4n1t0mm1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=cIEPWwpXOlt1jTqYWCsC4oCdtRewMPi6jLSaoNbXpB8wBoi9J6KyghdaGgsVPuBqc09/BlR5a8pEWx4Y7WObYoHkco48nHJpN2qEm3i7a16TMfRCBKggEZ2fcdqcCU52juGM+3+Mr+VNaGYd/474O4QebXByS5kesTtCDKUKGfDaTf3NZMo5jescGJAjFGrDwDSgLL+sgTx3Yaf2bqmXYw6SyQrApAtdn2dWeRDkoZABqKWKrPlwfIAy77+cOEywxfUompPAEaPTaQMWXsjurG4ipIXzDydM3RDjONNjJcQ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QzhDP0LOMPxQhv_nRJpuMpXyBlQsvWtWL0vLxzCqfJJtOsJbMG3CL.d.C3WltPNEqo ihiEQ5s.KsWipEW3Bk.USx_G0kjDflQzG3EAfydVlbGe2dYxaf6BKCwINWS4njnGJ0sk6cOWsUNf 6ucDdv2ScaQEOK242FlM5Ialu8jPvDOPAjj6oAt29soV6Tvg4DTjZJDNApAZRe7LH88iZvYFq4bU X44TfdjKGhwEjHxyxjKXesN1Sq.V7lWJ3uHzOGp8D7E.X6Vty8tjI__aj33cdgWoGH1nJ2lmwlvj mKeAv4_p5fRiQvhaU.w5BWeMa0vHuSaR2xC_foNsAjMaSSApQh_wHMAZrm1PdylIknk64NP9FqEx jE0vmWsHfQSLB9Lq.rArkCvxEDRMOscsO_GM4L2xvMNTgF7ZQTLrG2G8PJqow6rCTo1oZzVbXfgR pyIoUAmlaE0gCUBbfOM7fTmF6u0_ZQfzz7Hjdp5Fils2JOcy0SbfutH8gLiibP_F.a4XyNG3poke BxntG0pXz5EfbH0MFQqqwQwjK6iOJJHU2rJM._i9n5PEMskSLnvKAh12YHXlA2WWBek0T7lsQ.Zg AiXJchcqBGpAJDktPxExf_0xVhyuubGyH_yzm66UMzAaxc1HnorAdw.ZJEVzrejyYGX0VrAXDthq 0PF2HKb1F7K1vSOH.QZf9e.ke5p0_RXWAq1c5nVQgqC87VTEF.BYOy1j7fBrgo4k1wQQUmksdy0s 5JcP3Ypp37ItH3uldIPUS6DViIIGK X-Sonic-MF: X-Sonic-ID: 4c1167fc-06de-4df9-8b24-0f0d3fc2a041 Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ir2.yahoo.com with HTTP; Sat, 6 May 2023 16:00:34 +0000 Received: by hermes--production-ir2-74cd8fc864-j696l (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID b71ff572232817f95ac730737b6b2406; Sat, 06 May 2023 16:00:30 +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 , Henrik Grimler , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH v4 7/8] power: supply: rt5033_battery: Adopt status property from charger Date: Sat, 6 May 2023 17:54:34 +0200 Message-Id: <20230506155435.3005-8-jahau@rocketmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230506155435.3005-1-jahau@rocketmail.com> References: <20230506155435.3005-1-jahau@rocketmail.com> 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 = {