From patchwork Thu Aug 5 08:58:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 492251 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp84964jap; Thu, 5 Aug 2021 02:00:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB3jPNSyxXtyXncUb249hgxULwZdGVh2fvTrLYQMkFlupChWZQuZxBW7GAii5csT8k2i+u X-Received: by 2002:a92:d84f:: with SMTP id h15mr13601ilq.12.1628154035938; Thu, 05 Aug 2021 02:00:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628154035; cv=none; d=google.com; s=arc-20160816; b=kBoowxYkksc4mCAAnlMWFvsRm6pZTBvCk9/o0QdpL5U3xksXBHwUy8OHIH34UjHeUT TJoShDzsqy+xglZgpP4m+3q6yBN4+1shDIGo7vY6P0lHtdsyZ3EQcZXAGB83PH32VcLK IGlkMZ/IMMYRpaZkdK0W785qgsLJJ1NH4EihuybUNA6kJ0Jaf/GbftfBQtdh+73v6E55 uvcrNlyDvlP3c7HqaaAhVHeKp3I0c5zj0wrcvviQr5AH+q2s5m3iA2WiDKLA9Llt3SP3 EdtFvh8qFG2h78BqyfV68/vfj2nF4GTs35LDUWHqajJKEje6OP90Q19zQFCRLv99ijRh WKMA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=JM9iCScYCnpkFv75a57i9R1ggfwz9cSCItbTqo7em1Y=; b=AsOjS/X3nt0gdLahZIo5vb8M6fYXru1KlajFG0c0VUcEmYP4V2kwQ0WFyG2DEExCMm 0FSMtdvAi5+BMQExjAtgBPnbm8+dS2srcg7VHDe6wWk/mnwYSBb8BvWSDjYsqMjy2yWa cXH6pWVyNmLkI20hWwK06V880dW2wsinqDpuQf34sgF5WHsSfBswyi01J9HoaQVbxiD8 W87ech/pbkFCNKPv0owmTys8iNjr7Fnlr3KZkkjqgM4oUlJpuhql6Im1j9fSUPWHXd9A Ri9UY5vQEydKWb21jVHh5t52Buw/MnLqq4t9jJPbxRDGFTPY6LMV9glbDhf86nP5BIJr 5a1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y3DFpIbo; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si6406469ilk.136.2021.08.05.02.00.35; Thu, 05 Aug 2021 02:00:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y3DFpIbo; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232182AbhHEJAs (ORCPT + 7 others); Thu, 5 Aug 2021 05:00:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbhHEJAr (ORCPT ); Thu, 5 Aug 2021 05:00:47 -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 31B76C0613C1 for ; Thu, 5 Aug 2021 02:00:33 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id y34so9640283lfa.8 for ; Thu, 05 Aug 2021 02:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JM9iCScYCnpkFv75a57i9R1ggfwz9cSCItbTqo7em1Y=; b=y3DFpIbood6Z8HVNcmCAlTaEot6Fbw5o7WJl9eWitbrL8+PfBGI5MKkMbX1RwMyIdY okgh1DYBe51yAea82bYFMeOaAAawG+Vsz6PZ2KFYAq4+Nf2mPue4mcekooPQjbRxQZ4Y w/kjp82jR91Gm6dIlV70daROhz1ftlt3LYgSkktdBCUSVYQQTdHA/gtAEzQf6rtw2HG0 ZBpmwwafLVQr1eLEYnPtqmF33FOORr5Ea9VEblKDZT7m3Db33+653xOdMcl0bs2diGpO 4szt2EwU/V4z2wiB9ejUXeDw0SGdxbvNgqPve199hqwhSbqBFx6eAe8gONxd/fZrBkb+ m65w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JM9iCScYCnpkFv75a57i9R1ggfwz9cSCItbTqo7em1Y=; b=CUpgK1lgqdZ89h2EwpfhD16IL2A1E7FPsVTTQTQT64bvwI5zqerDuFI1LuVMTGyGyi uFbdzIZWHmcRGJ/k7WeGMXkagskGNVvV/GnFr81ncHfnCR2in7jbOhJRU1l4GL6chkb2 ut4vbpaFyKhdAbqydSiEgDucsUb3p7lnCjQ9FF5vBMyKsa3vGCOh1+KE2l59+DHeHbba /sU9rlGJUWXupuQV1SiGBW1lJq+99rnlab7K5gtqX0+FRivvcE9M5pRJcWk47/JZkKcH e+kuAPLJNuZ01fx3zkKm6zhouE8l8cvquoCzVs122yCN04WFpRGB3bo0AWltd+9gK/AV QM8w== X-Gm-Message-State: AOAM532JlGDepK51okc3/bo2zGkjFleYLs+qNThEl7vgJDDJOF7rj3TS dlrE0LAZyaVDGQHmHM40YoTbuA== X-Received: by 2002:a05:6512:53c:: with SMTP id o28mr2925415lfc.641.1628154031495; Thu, 05 Aug 2021 02:00:31 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id z1sm447901lfu.222.2021.08.05.02.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 02:00:31 -0700 (PDT) From: Linus Walleij To: Sebastian Reichel , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij , devicetree@vger.kernel.org Subject: [PATCH 1/2 v2] dt-bindings: power: Extend battery bindings with type Date: Thu, 5 Aug 2021 10:58:27 +0200 Message-Id: <20210805085828.3451909-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This adds a battery-type property and bindings for the different "technologies" that are used in Linux. More types can be added. This is needed to convert the custom ST-Ericsson AB8500 battery properties over to the generic battery bindings. Cc: devicetree@vger.kernel.org Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Add devicetree list to Cc - Use "device-chemistry" instead of "battery-type" as this has precedence in standards. I need a bunch of new bindings for switch the STE AB8500 custom bindings out, but I need to start somewhere, this is as good as any place to start. --- .../devicetree/bindings/power/supply/battery.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.31.1 Reviewed-by: Rob Herring diff --git a/Documentation/devicetree/bindings/power/supply/battery.yaml b/Documentation/devicetree/bindings/power/supply/battery.yaml index c3b4b7543591..d56ac484fec5 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.yaml +++ b/Documentation/devicetree/bindings/power/supply/battery.yaml @@ -31,6 +31,20 @@ properties: compatible: const: simple-battery + device-chemistry: + description: This describes the chemical technology of the battery. + oneOf: + - const: nickel-cadmium + - const: nickel-metal-hydride + - const: lithium-ion + description: This is a blanket type for all lithium-ion batteries, + including those below. If possible, a precise compatible string + from below should be used, but sometimes it is unknown which specific + lithium ion battery is employed and this wide compatible can be used. + - const: lithium-ion-polymer + - const: lithium-ion-iron-phosphate + - const: lithium-ion-manganese-oxide + over-voltage-threshold-microvolt: description: battery over-voltage limit From patchwork Thu Aug 5 08:58:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 492252 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp85000jap; Thu, 5 Aug 2021 02:00:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2+HGNgWe5pKM+pOTprlm7Fs7eQXXnX9HkJ4pXmGj1sG5LzCB9WOd1HfEAJ25HsjrgUubz X-Received: by 2002:a92:d2c1:: with SMTP id w1mr96350ilg.280.1628154038907; Thu, 05 Aug 2021 02:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628154038; cv=none; d=google.com; s=arc-20160816; b=JQJufi/uhMye/qTfvP61FxPdBgoNg4BVOY3Xfrn8QnNC9FJtZ793UGlDCguimlJHHq 4w/RLZTjbXDeHiW1rtumvnqLtkXi69TQfqPm1nt+T+Or9eyV+jM1TqakbvqCLMRfMZ9M mlvD6cU/xXYxQLIe6wFyEUyA51l7KXz5l4wHhdg7Y4j82CpwojgAJ+XQv9C8z15B4Nbf DkzeFLAE3x/LezbfP35qg6xa2A1N8w9bHpUNPrZtOTGumsBOGW/OAzuLEAla82ofg1db pyBzS9AfxYwnMuXWI2CxAmJ+u4ZFkM6F/3hv3EykmL/Oup2fDF/jWK/Kt/Ojz1cbqEDy kpCQ== 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=0jPitpwrLWs8upJmUfHM9pLts94cUU2HAf+gduXaN9c=; b=bfTeTmYtsoRMWWjZdOR+ZtoqIklZAOIzUMpdEjdVj+kJbrHAMPR3FoSu1tIhz1R2aw CExYBJS1l2zdjKbuZoxOQYy/GYtUCYVNeqNRAY2wkFxhB3h2ecsr6SwkKV+EXZPwhrOJ pwuLUgrZQoO2nfpEY1mM5QeuzZ53mLWTPT1IWeHpEO0yMXRlgVOW/yw+tS1E5fbswgGz cfbiUeJH82aHJmVfXoshgvX8bx+gs/Jyzw5lYPCOkHhYWdFEOeyHMz9OJGoyq8eb7w3E PIMqQLkG0ORmdU9fu4kGZEMgiqXvglt8Ab65NSN2WDc20GupjyUdcfAtaCp3AEQZ/7bz hMIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FhH63W2s; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si5168356ill.114.2021.08.05.02.00.38; Thu, 05 Aug 2021 02:00:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FhH63W2s; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232365AbhHEJAu (ORCPT + 7 others); Thu, 5 Aug 2021 05:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232046AbhHEJAt (ORCPT ); Thu, 5 Aug 2021 05:00:49 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D3FDC061765 for ; Thu, 5 Aug 2021 02:00:35 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id t9so9672519lfc.6 for ; Thu, 05 Aug 2021 02:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0jPitpwrLWs8upJmUfHM9pLts94cUU2HAf+gduXaN9c=; b=FhH63W2sAvg06MqYrl7Sds2Xf+WGV8f8I8AC5Ywr2/o1Qv6OgeEHsIwW6F68BKRpmP +x8Ctxj1hIQVKUBPVRIOyPXO6oSAWj+w+vI94AP+HByjbaGd84/bY2SF2AUJOIl94k+3 DZAKaBIvFtFxTSLFGxiqIi9sV7SdmeTn4ALBxcgO+huQLVXFqDJiL29vziAMoNoR0FbI /wxRM4fxAcfFbgHpyAw8GrVx5Ifqw8XcOysxfnAQqlh460pawsyzlVs3o/ZMi136F0FZ 45q5wyaB9MyZCeIXnN1dKBB8Y6zyP8Rejfhzj76v81VfNdCjc7I7mC18L82k9UX3Ju2k AF+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0jPitpwrLWs8upJmUfHM9pLts94cUU2HAf+gduXaN9c=; b=P/PECFaC7rL1wyvshNI6FZxuwAY0O5FFu5zperIInjD0D9KXsJgmvTzDXXL5p3El7/ Wpu4FLn925GtGjnruAjiYxoaqcA7fQWGC5K+0bBx5nrU7tvOzXmjuS45kXpG9iNK6S0P mIvobHW3+8/OK8bnu4ddsXDaLLnXJTHIDQXyBNLVIWnOrwF23HqoXNzW7TtSE8BXH4TC nOA34V/5gW7Es9HOaYlkcqftI0kUOHkYIi1jijRl0A/8FIWURxJ+HPIJlLZReTsFOdO+ oirk0QAaeFVm14b489GJe5BkgkvovDmdu8Zi4VXA5zqah3z9v3HsU79xTUIpelT2EIBq DGVQ== X-Gm-Message-State: AOAM532xSRtw3YDcpyY0VdiEBdoHnN9f0uB2ojL+Izc3WMpLzAX3Qin0 erSIsT6FZI3WVTYKCDDr/sd23g== X-Received: by 2002:ac2:4a7a:: with SMTP id q26mr2831992lfp.582.1628154034027; Thu, 05 Aug 2021 02:00:34 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id z1sm447901lfu.222.2021.08.05.02.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 02:00:33 -0700 (PDT) From: Linus Walleij To: Sebastian Reichel , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 2/2 v2] power: supply: core: Parse battery type/technology Date: Thu, 5 Aug 2021 10:58:28 +0200 Message-Id: <20210805085828.3451909-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210805085828.3451909-1-linus.walleij@linaro.org> References: <20210805085828.3451909-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This extends the struct power_supply_battery_info with a "technology" field makes the core DT parser optionally obtain this from the device tree. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the accidental double assignment of err as reported by the kernel test robot et al. - Switch to "device-chemistry" instead of "battery-type" to indicate the type. This is needed to migrate the STE AB8500 custom battery bindings and parser to the generic parser. --- drivers/power/supply/power_supply_core.c | 20 ++++++++++++++++++++ include/linux/power_supply.h | 1 + 2 files changed, 21 insertions(+) -- 2.31.1 Reviewed-by: Sebastian Reichel diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index d99e2f11c183..dd62c871b2b5 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -571,6 +571,7 @@ int power_supply_get_battery_info(struct power_supply *psy, int err, len, index; const __be32 *list; + info->technology = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; info->energy_full_design_uwh = -EINVAL; info->charge_full_design_uah = -EINVAL; info->voltage_min_design_uv = -EINVAL; @@ -618,6 +619,25 @@ int power_supply_get_battery_info(struct power_supply *psy, * Documentation/power/power_supply_class.rst. */ + err = of_property_read_string(battery_np, "device-chemistry", &value); + if (!err) { + if (!strcmp("nickel-cadmium", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_NiCd; + else if (!strcmp("nickel-metal-hydride", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_NiMH; + else if (!strcmp("lithium-ion", value)) + /* Imprecise lithium-ion type */ + info->technology = POWER_SUPPLY_TECHNOLOGY_LION; + else if (!strcmp("lithium-ion-polymer", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_LIPO; + else if (!strcmp("lithium-ion-iron-phosphate", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_LiFe; + else if (!strcmp("lithium-ion-manganese-oxide", value)) + info->technology = POWER_SUPPLY_TECHNOLOGY_LiMn; + else + dev_warn(&psy->dev, "%s unknown battery type\n", value); + } + of_property_read_u32(battery_np, "energy-full-design-microwatt-hours", &info->energy_full_design_uwh); of_property_read_u32(battery_np, "charge-full-design-microamp-hours", diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index be203985ecdd..9ca1f120a211 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -352,6 +352,7 @@ struct power_supply_resistance_temp_table { */ struct power_supply_battery_info { + unsigned int technology; /* from the enum above */ int energy_full_design_uwh; /* microWatt-hours */ int charge_full_design_uah; /* microAmp-hours */ int voltage_min_design_uv; /* microVolts */