Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5089148rwr; Mon, 8 May 2023 18:11:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6dPLkIL4/DqZFSkQI0MfiqwQ5a7uAc/REiRjI/KxhsqBoZ1nm8sIIM5ivZzZLX+eTNPxqQ X-Received: by 2002:a17:90b:19ce:b0:24e:1177:f467 with SMTP id nm14-20020a17090b19ce00b0024e1177f467mr12800969pjb.12.1683594692794; Mon, 08 May 2023 18:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683594692; cv=none; d=google.com; s=arc-20160816; b=kWdmFw4upckrzPmSQlEhhqlbRmSVFgPp+xjgu6FbLn/CX5Aq4SGfn17sHp/QLXRfme ackD6iiIquR0vWCGYDzO1CI3XQtX6lqdDoZYYNdKRqRa/wdRfa77wL3xliBeb+HvAro1 2juf7ChTIzUrGNx02VTonvKeRMaQxpyckzaRXrh5lo6E7KVRbgTQEzDNCVbhR+I7vawQ sVz3oEl+zn/GRY88+3URXzMQi40dt9tO+NOM1Yr+pkJ53BkhIdfqnDQlsONdWeB19kMZ KbvAcl8zUVJYXhC+WZzPG5+pbOVuq16VGBJ7gl7ItbQ+kYpxE9CUVLosMw3LQ4bdS2My obog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=XZkwtW0u4vlso9cBKVw2n7DK5kOM5HPTovVW04FEo00=; b=SOmhqyvgEodlr6XuLUDejPWXPPLmTT+BniHPPgR3XdDNjxRH0mD//hWWb00MXYAvPE UZVizxX2lq0tS7D45ypT/xJbzicCGlOGK2N4KhzOtBbCVDTAzqZoT3+uGXBIFd6dfQW5 oZXbftJZqxw9eu3yWXo+IHa3grT4f3CISIPCCEoIwpet78fX37uGiLXKPRdlUjhidbPd jUyafm4jAepMhwqxIdK32yFSuWBW7jDLMtsnyDxpt+WremfntSS/XlUJKAgkLo1zIvyD 2p/cX2jSiwXxFGUEJiX3w34eVaE5RIHmMWom+lr5TOK3xsa6qsx42gBfyvUu9oG5L87r z4Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rocketmail.com header.s=s2048 header.b=AwfGVOOo; 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=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i15-20020a639d0f000000b0051b313bdebesi299645pgd.1.2023.05.08.18.11.19; Mon, 08 May 2023 18:11:32 -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=@rocketmail.com header.s=s2048 header.b=AwfGVOOo; 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=REJECT sp=REJECT dis=NONE) header.from=rocketmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjEIBBp (ORCPT + 99 others); Mon, 8 May 2023 21:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbjEIBBn (ORCPT ); Mon, 8 May 2023 21:01:43 -0400 Received: from sonic307-7.consmr.mail.ir2.yahoo.com (sonic307-7.consmr.mail.ir2.yahoo.com [87.248.110.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E2E226B3 for ; Mon, 8 May 2023 18:01:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rocketmail.com; s=s2048; t=1683594099; bh=XZkwtW0u4vlso9cBKVw2n7DK5kOM5HPTovVW04FEo00=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=AwfGVOOotX883i+WXzgrq7KHucOo81Ufg5IoeIFWfpFBIK/NIHNWNV2j091K5j7iIHMIwWdK01jYkaWCUPc4lZFUTxVQFkiD3NZ3yGfdCNyqQfX258+cFdcVaU4pulmSOg7hcjO9IOuFbvI5cVzh52uxOsaX60MM76YmVFnbvkewuLOsoxUxHM9cS2pwO9JRodFXO19SEOloHzbEMRYE2/maqJ+UObXJeZgFNOqsL8P0k9L1rtS6ULLh8v9mlFrs3/ntKOiLz7roqmdcdaUQGKTBRO2TruS114OlYJdDZyiRVLhEMUcbkXgRb25jiXEEQ9AzJeg5/Z0/7g2TygG5fA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1683594099; bh=HFTdkLJk4shlQuPS0rdRDeEiD8oh2qhB0+DRkDhThW9=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=gHso3PbgMO4LnnkTicxPFtM7gAUjTXZbioyPMyVTrqy2/xfosvkaVJdlAsAmCNNsXDS8Sj4tVusynNTn/Kc4tg/pvc7v7ylp11xlqAWgpmPnqMO89gTubmS4ZhaaFNPe2MYUhdNhyP61UumrVOTafK+bY3fZWqxqwvQo3F66vhqSdv222Kjz3sxqO4zLjAn/1HB0Had/qLpHiTiSGPQfcd0rL54IV/Nqpe0oSwmNvFx0WyeDNDXpeyGYo3YjtNysei6X2RS+PRNz7Y1purPfEkFs+d2rzPjz3IBOvdYrKbREQWP+LdQz9Fne+ZcnIgbPDZElo/E4LOE3k66NfFG9+w== X-YMail-OSG: 1_hNPywVM1nTL7PbYVkmg2L6rc6BT0lZtoH_kr.DF6NQD06IouxMUg68n3uNdi9 hzV1RcWFaYdrZpTlp6GP6Wjzrx578qp0AfatE1u6LX7Hrl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.kb_rGixNz4Abe_UU oMXHGZHrsS4qSeXWCAdAb_fmUObkavfvz45NR6mNofJkSv.NNTVjF27.asbEhkmGI6J9IkUyUS7q EdDU- X-Sonic-MF: X-Sonic-ID: 89fb71b9-7047-47cd-8ce5-db1cef7dbb64 Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ir2.yahoo.com with HTTP; Tue, 9 May 2023 01:01:39 +0000 Received: by hermes--production-ir2-74cd8fc864-msrld (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID e39504d2ac763bd7ad95b4e52adf3d61; Tue, 09 May 2023 01:01:34 +0000 (UTC) Message-ID: <55fd9835-4246-00e8-b641-c8b0ee3f7e22@rocketmail.com> Date: Tue, 9 May 2023 03:01:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v4 7/8] power: supply: rt5033_battery: Adopt status property from charger To: Sebastian Reichel Cc: Lee Jones , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , 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 References: <20230506155435.3005-1-jahau@rocketmail.com> <20230506155435.3005-8-jahau@rocketmail.com> <20230508113518.nfwchl5wusmnkjp6@mercury.elektranox.org> <899d6604-7b15-ac37-c624-987a2bb7875e@rocketmail.com> <20230508220605.kderc3nihhezouit@mercury.elektranox.org> Content-Language: en-US From: Jakob Hauser In-Reply-To: <20230508220605.kderc3nihhezouit@mercury.elektranox.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.21417 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 Hi Sebastian, On 09.05.23 00:06, Sebastian Reichel wrote: > Hi, > > On Mon, May 08, 2023 at 11:18:28PM +0200, Jakob Hauser wrote: >> On 08.05.23 13:35, Sebastian Reichel wrote: >>> On Sat, May 06, 2023 at 05:54:34PM +0200, Jakob Hauser wrote: >>>> 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; >>>> + } >>> >>> struct rt5033_battery *battery = i2c_get_clientdata(client); >>> ret = power_supply_get_property_from_supplier(battery->psy, POWER_SUPPLY_PROP_STATUS, &val); >>> if (ret) >>> val.intval = POWER_SUPPLY_STATUS_UNKNOWN; >> >> I don't think this works. There is no direct relationship between >> rt5033-charger and rt5033-battery. They operate independently from each >> other. > > That should be fine as long as the supply dependency is properly declared. > >> I had a short try and the status property of rt5033-battery was "unknown". >> >> Just for the record, the full function I tried was: >> >> static int rt5033_battery_get_status(struct i2c_client *client) >> { >> struct rt5033_battery *battery = i2c_get_clientdata(client); >> union power_supply_propval val; >> int ret; >> >> ret = power_supply_get_property_from_supplier(battery->psy, >> POWER_SUPPLY_PROP_STATUS, >> &val); >> if (ret) >> val.intval = POWER_SUPPLY_STATUS_UNKNOWN; >> >> return val.intval; >> } >> >> Later on I added a read-out of the "ret" value. It is "-19". I guess that's >> the "return -ENODEV;" from function >> power_supply_get_property_from_supplier(). [2] >> >> [2] https://github.com/torvalds/linux/blob/v6.4-rc1/drivers/power/supply/power_supply_core.c#L397-L421 > > I suppose your DT is missing the connection between the charger and > the battery: > > rt5033_charger: charger { > compatible = "rt5033-charger"; > ... > } > > fuel-gauge { > compatible = "rt5033-battery"; > ... > power-supplies = <&rt5033_charger>; // you are probably missing this > }; > > See also Documentation/devicetree/bindings/power/supply/power-supply.yaml ... Thanks for the hints. This leads to updating the dt-bindings because adding the "power-supplies" property is important to be aware of. Btw. first it didn't work. It took me quite some time to debug. I needed to add "psy_cfg.of_node = client->dev.of_node;" to the rt5033-battery probe function. Now it works. However, there is a new problem. The battery driver gets probed first. The charger driver a bit later. In the meantime the battery driver spams dmesg with several "Failed to register power supply" because the charger driver isn't available yet. Once the charger driver is there, it works fine and dmesg becomes silent. With the current state of the patchset: dmesg | grep rt5033 [ 13.628030] rt5033 6-0034: Device found (rev. 6) [ 13.633552] rt5033-led: Failed to locate of_node [id: -1] [ 13.790478] rt5033-charger rt5033-charger: DMA mask not set With the changes discussed here: dmesg | grep rt5033 [ 15.741915] rt5033-battery 4-0035: Failed to register power supply [ 15.752894] rt5033-battery 4-0035: Failed to register power supply [ 15.795458] rt5033-battery 4-0035: Failed to register power supply [ 15.910760] rt5033-battery 4-0035: Failed to register power supply [ 15.913187] rt5033 6-0034: Device found (rev. 6) [ 15.914341] rt5033-led: Failed to locate of_node [id: -1] [ 15.920052] rt5033-battery 4-0035: Failed to register power supply [ 15.927262] rt5033-battery 4-0035: Failed to register power supply [ 16.017131] rt5033-battery 4-0035: Failed to register power supply [ 16.017401] rt5033-charger rt5033-charger: DMA mask not set The message is comming from the rt5033-battery probe function, it's the power_supply_register() that fails. Any ideas what could be done about this? Kind regards, Jakob