From patchwork Sun Jun 27 23:45:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 467822 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3493532jao; Sun, 27 Jun 2021 16:47:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTZuI7N0dARvYFTCuCBp6sYBRfFY6jlUuyBPzl0+q/OR6ZqZ2OiDVBiXunMjaHX0Rl7o1/ X-Received: by 2002:a02:866b:: with SMTP id e98mr20714831jai.48.1624837653820; Sun, 27 Jun 2021 16:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624837653; cv=none; d=google.com; s=arc-20160816; b=Huozq+zXzB87INJ6Krqxx6GuWTKf8eBgWUDYn6mXyvwwORqHcNhRtq0hQDWOnzPion Y+JxG493bzrf49m71fPUN1bcR7/85PgYQeEi7/SgoKZK8wkozWJueBqJM3nNlFihlSXL 80np9mBAQ2P7Vz7w44sgEDCs8TdCEa0nEWdGwwXE873BmTvTvAWUVfLs7lD6PPGwk+L5 v/Hwn1zbBxcP698YhT2gKUZPzGxs3+52AVO+hlxedCjJXIfu/7gN0gcmYtGkJ16Ud2ES xYyJI5AHYGuT8MjUiGYBddGZtg94BSDXRvLIOJBORvOoZ2+u2bZOJTRG7of+Mh55Bzcb cs4Q== 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=7a1C3uQS+jx46SRoQWLs/UbnX/sjfDf/csgTDG6Gjik=; b=gNUjCDVmRw1oqQlN6zymQNwGTgzw+DCHnV7XgSh0stULIaqQUxOknAXMtSpiQiAucr wi3eWxDqMWco9efY2dKH+xS1AxKOQSTo6RYJ2TTnQr/2UtINpNu1Fs62OjvWW3Kwmw7U zQNmD0mWRHwQyVv78zWOBmoLS1ul93s1gEzc/IHkDuaMZu9J2aZucFslolca1QWE5Gnt qrhuy51Q03m90PmPF6Fu3w6+HG5jyETvj8IUgk/wF7J+6H8U+uhrpheWpZECsRuhfb3B 5scuFoq6P6paYzQsn8v0CevK7jWi1zTGXWsg+eEVXybeFH8bS0FCb2s2VnI0WbTmI531 rq1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PdOU3SWk; 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 y66si15600084jah.10.2021.06.27.16.47.33; Sun, 27 Jun 2021 16:47:33 -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=PdOU3SWk; 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 S231679AbhF0Xt5 (ORCPT + 8 others); Sun, 27 Jun 2021 19:49:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231508AbhF0Xt5 (ORCPT ); Sun, 27 Jun 2021 19:49:57 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81791C061574 for ; Sun, 27 Jun 2021 16:47:32 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id a16so22568344ljq.3 for ; Sun, 27 Jun 2021 16:47:32 -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=7a1C3uQS+jx46SRoQWLs/UbnX/sjfDf/csgTDG6Gjik=; b=PdOU3SWkOLHxKuMbrYLVlBiFCjRUYP7zx4VxN2udZTMDEaDdu+aoRmfnclC2k07icr UIJgL6Ws1B++mkghEinLWBLhxN2Uol+TqJuaDxVUEiFN3AWIiDubNPxwanYNG9QaijSD e5M8B7Npjn3dJw5IrBhA5/5QA+TmxyOWCy0LkzW2Uwdh0LWU35qCQiTsBcNE3xXP4n6X +QXlrBE7wrbxUwvHvw5sr0BqqA+OcDMTh9jDL6Zg8eZ28yT/sdvkj1iLqAee7OFt7c77 DceEHJNaRgc9tuKDRp6lVGPuJbCdf7V91o5KCZ2TFxPjYbgIr8iIVNVXaLqczna78XP1 Ehgw== 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=7a1C3uQS+jx46SRoQWLs/UbnX/sjfDf/csgTDG6Gjik=; b=VmHMf2WfSQxNOgFEMq6/qWF8M6F/qdkRFhjOANAmG7vcOeGl16omNOo5QvXPr06Fgm hYU/9G71NRZploGS7/qS7MTA2zr+TzDO8NVYfH8M/b60RUtzrHlHU7o9J/uW7UiHBD/z eSgyvVO4RnAATVo8MpUwhUNMk7C/9NLoAD+YzCGsNpjS3wVuCO2TnivKFG6Bdsw5NsJZ salZYtSBD0zuFX7OmIKeX4tp3bbAo/QJR796U+EUmXVXqWndKBEFrLgIpAf4n05FzuLG IZsNGspG7F5fM5KTBzPrYLFFL6aWa0bsNPe0MkZ+w8pEukKOWlKj8K3BWKOCbAgIiXTJ YyuQ== X-Gm-Message-State: AOAM531PbdR/XVSAJ5mfJMAZ1ykCiCMJzAGGTBtfCYw/VBHlHXR3SupY NC4GMsk8ZFYPMN7/IllGflv9UR3oUxWRbw== X-Received: by 2002:a2e:3310:: with SMTP id d16mr17815510ljc.494.1624837650828; Sun, 27 Jun 2021 16:47:30 -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 l14sm1151890lfg.221.2021.06.27.16.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jun 2021 16:47:30 -0700 (PDT) From: Linus Walleij To: Sebastian Reichel , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 1/2] dt-bindings: power: Extend battery bindings with type Date: Mon, 28 Jun 2021 01:45:14 +0200 Message-Id: <20210627234515.3057935-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. Signed-off-by: Linus Walleij --- 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 diff --git a/Documentation/devicetree/bindings/power/supply/battery.yaml b/Documentation/devicetree/bindings/power/supply/battery.yaml index c3b4b7543591..3561ae2c1d58 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 + battery-type: + 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 Sun Jun 27 23:45:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 467823 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp3493588jao; Sun, 27 Jun 2021 16:47:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWBLSVji6dwGfW2++vRomM6hvuwNceEroEVtieNbrvpTO6PjZNDgqRN5+epcyjJurKhRZC X-Received: by 2002:a5d:8d16:: with SMTP id p22mr18786539ioj.90.1624837663634; Sun, 27 Jun 2021 16:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624837663; cv=none; d=google.com; s=arc-20160816; b=LjK4+xBOEwtlLtXIGVRrKH9rI5vdEGVcLjrEvyrqlYC27TGrsrwiXl5q9pCnTEkVJu qiokYvgd9qz9e9tDtXr4tim/auwHCvIPa/akzlO3dEYpWYlIsuANYDyvDVsu83XUAhF2 EFfZO9OS5cF4Ck08lURihrtQ6dSMyDcTP5K8m74Fr/IJBF/gISvDL475gDBWpHIgwyM/ +R+UyhENB4PXBxr4ghfjfD4/+72IYzc0ClcWt7/ytGVwMYBlHjb8htqnPG7OCkrNCJYB MKsyLI32dMuMDiOjBDAkqUlaSqHPzToKyhh+4qQsqUm6gYRtLzyzpV6+aP23f3A0xNdp tuFw== 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=glA9TK5P5iHSShuGWIVMW4Eq1VPD8SNYNXKEfMbnS78=; b=0zZSzvsGnqZ9XugU4Eydoi4MDReNBntOPArGyRdzr3mLoAYbbkJEUuNi4ub+6vfqfi RR7R1hUsdKEYm2g8SaBDJhJPFgzRgy52f+Uibkm1FuLwhiOyXY4IfkWYgkfJEq34RyGw A8Zm9ieuVhameFeO/NKj2E/xtSt2hX9fViD8+2eVUpRj6nJ5yHMCCjRMujr3yhhveN3r 3GKKI2+PQA3TvQgTsQKyucb1aKiIRdMMfBSoI+K6C7wPHf5QH4Y4zs+TOzWj2VryhcJM Q19s99tt3meBSlKM6Dx/DIBzHPaHF2MKPhYWA3ubyVOIQ2OMo58NtiCpqUCW0cXGj1i0 GFdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RN1McoY0; 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 y66si15600084jah.10.2021.06.27.16.47.43; Sun, 27 Jun 2021 16:47:43 -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=RN1McoY0; 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 S231680AbhF0XuH (ORCPT + 8 others); Sun, 27 Jun 2021 19:50:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231508AbhF0XuH (ORCPT ); Sun, 27 Jun 2021 19:50:07 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65D91C061574 for ; Sun, 27 Jun 2021 16:47:41 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id t17so28827810lfq.0 for ; Sun, 27 Jun 2021 16:47:41 -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=glA9TK5P5iHSShuGWIVMW4Eq1VPD8SNYNXKEfMbnS78=; b=RN1McoY0FeX+jvsdvzIgN1C5YfIngRnTw6/j0eq8zvWscvoLeLygd9+9DK3HrsxgL2 IxyOjyY+y3T/S8PDqcAuBzqbZEJFkdO673aDHBOTnhUBYICUT4nN9HiChFkihn/ycMq9 yP8miFmqW8EpyzaoUwEgjnAkP7wOOsiE2MyfmpHGCR432aprE/dnWUFvLT3gKWhsi2By oERBjMC8cC4m1OfKFT/T47t+YuTAznIQFO2Za6u+jceS9ID85JvIDrm5FyAaRYlcAHgo JWOWn6quCp05T9SnDjGjGjXwWbVJ0vq7DTNlYafRi0X+73EkvWOt8cgLOWb9GPTCcDf4 rPLQ== 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=glA9TK5P5iHSShuGWIVMW4Eq1VPD8SNYNXKEfMbnS78=; b=enrdQEHFyDZYiRCaKC+kxFECgybyghN/nn1yKAmx13Qd8/txAC5aRU1BsF292KL/Uj 2hZRjDSxlw9PwU++v1hvJYvWkgbYR6fN3nDxg7MG8W5FPtTxtUlAd9fg19iElaicgyFS xx6l+PbdtaJDgjdU95vbW6kwmfoLMAfXXbMzGzMfzX6GVhQEBqlhcCZGJlZHzUqwmYSe m1u62/AzcjEoZi94IpQcKhGbNHTWTj4H8gjlIxjkVGeHg3tELNl9VzAGYCLgQQgykAbN 3gXkps+pdyMVjg1nn6ke0WCKae9BfcbMDm0d0soBoynZv6iu8LqC/gtAKzNDI2hLXIrJ qkmQ== X-Gm-Message-State: AOAM532NGgYi1Cd0xpx1Cc3ytv4W49d95uV/Kmqp67XoMIaapHw9VhGz qIkGq3YIn1caLJr08EdBC/0ixw== X-Received: by 2002:a05:6512:219:: with SMTP id a25mr17631395lfo.295.1624837659765; Sun, 27 Jun 2021 16:47:39 -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 l14sm1151890lfg.221.2021.06.27.16.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Jun 2021 16:47:39 -0700 (PDT) From: Linus Walleij To: Sebastian Reichel , Marcus Cooper Cc: linux-pm@vger.kernel.org, Linus Walleij Subject: [PATCH 2/2] power: supply: core: Parse battery type/technology Date: Mon, 28 Jun 2021 01:45:15 +0200 Message-Id: <20210627234515.3057935-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210627234515.3057935-1-linus.walleij@linaro.org> References: <20210627234515.3057935-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 --- 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 Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index d99e2f11c183..9771a3236932 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 = err = of_property_read_string(battery_np, "battery-type", &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 */