From patchwork Sun Jun 7 14:41:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591627 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54563175A for ; Sun, 7 Jun 2020 14:46:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B2422076A for ; Sun, 7 Jun 2020 14:46:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CQlv8Atv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726663AbgFGOpV (ORCPT ); Sun, 7 Jun 2020 10:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbgFGOpU (ORCPT ); Sun, 7 Jun 2020 10:45:20 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 082A6C08C5C3; Sun, 7 Jun 2020 07:45:19 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id n24so17282773lji.10; Sun, 07 Jun 2020 07:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ke1Nk6rN9w+vzVhHvqubAjAEPlQYN8nHibugQnM0Ib4=; b=CQlv8AtvDQXs/6SB51nCxr6V5fN3KyVllmhXO698ZSNy/DSddiiGG1WthUe4EzSLYe rkmN8yU0XM2KaF9lzzbhjvfAf5iID0MOkVpascNgMYwZAK1ucotb7KLhMLqxNoOhkqQX U8A+5AvD1czJm9H9JhadSPxsY5qIz0B0pZao9zHmwxcukLO+gg3qVMJZ1hbIfLunUBPx MU4RGAn6IKqjv4c7j4YPLBVw5N7LRotzuTt4mie1gTQWjWGaVfvMEGwQ7RSFZZV1x724 gnPwx3XK2C1p+PgOXZDpLhvKTvNQMZNKAeEf7pfH7QnahcKfXWSVVJ6sX3FM+mMrXxBR IjUA== 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=ke1Nk6rN9w+vzVhHvqubAjAEPlQYN8nHibugQnM0Ib4=; b=GIQEz4tK2SwAdw8siXpUQ/fqqo42dWu7hGVJcaf1tvFE9UP+5AZz9qRSxZeMANLgKj xneidEmsRxM/8hV5a0AFiMg7h+1gWMLbH87j2uaGSd8Lynu4uBK7Mc03nW+HaFcxtY/s fk5BNox2FNzarJZoT+3Nn44XeIX2/J2ezVTEQ99IGQKKa4GNcC/Enb3YGAknxgsTtSah CCIFqzXxfBcyG2Q5nedJ7qIQm6qf/crtos9PsuPL6fHZUWB0gElTTVjLvv78BtRhaaTP iOUsUnhPuV3qmktB8UE22lUpB48dXVVjYZwC1mzGdtvXuKILZIbxKPKhQQfekScAy+FY 9DFg== X-Gm-Message-State: AOAM533BNC2GAQ6SLHFqRcaeZ39Fhe85x5692f6fQmNRu8pYGtGsY8vZ z+EVvB+szk+N9AUZT7nbRJE= X-Google-Smtp-Source: ABdhPJyQY9d/3iBO0r2PJwjKyp3gglJQ/42UJDdh5rA8aZeT1NvcyHbWknOIaaBwIRj4X7ESjaa6cw== X-Received: by 2002:a2e:2e0b:: with SMTP id u11mr9167840lju.281.1591541117449; Sun, 07 Jun 2020 07:45:17 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:16 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 1/9] dt-bindings: power: supply: Add device-tree binding for Summit SMB3xx Date: Sun, 7 Jun 2020 17:41:05 +0300 Message-Id: <20200607144113.10202-2-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: David Heidelberg Summit SMB3xx series is a Programmable Switching Li+ Battery Charger. This patch adds device-tree binding for Summit SMB345, SMB347 and SMB358 chargers. Signed-off-by: David Heidelberg Signed-off-by: Dmitry Osipenko --- .../power/supply/summit,smb347-charger.yaml | 165 ++++++++++++++++++ .../dt-bindings/power/summit,smb347-charger.h | 19 ++ 2 files changed, 184 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml create mode 100644 include/dt-bindings/power/summit,smb347-charger.h diff --git a/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml b/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml new file mode 100644 index 000000000000..eea0a6398c95 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml @@ -0,0 +1,165 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/power/supply/summit,smb347-charger.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Battery charger driver for SMB345, SMB347 and SMB358 + +maintainers: + - David Heidelberg + - Dmitry Osipenko + +properties: + compatible: + enum: + - summit,smb345 + - summit,smb347 + - summit,smb358 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + monitored-battery: + description: phandle to the battery node + $ref: /schemas/types.yaml#/definitions/phandle + + summit,enable-usb-charging: + type: boolean + description: Enable charging through USB. + + summit,enable-otg-charging: + type: boolean + description: Provide power for USB OTG + + summit,enable-mains-charging: + type: boolean + description: Enable charging through mains + + summit,enable-charge-control: + description: Enable charging control + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: + - 0 # SMB3XX_CHG_ENABLE_SW SW (I2C interface) + - 1 # SMB3XX_CHG_ENABLE_PIN_ACTIVE_LOW Pin control (Active Low) + - 2 # SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH Pin control (Active High) + + summit,fast-voltage-threshold-microvolt: + description: Voltage threshold to transit to fast charge mode (in uV) + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 2400000 + maximum: 3000000 + + summit,mains-current-limit-microamp: + description: Maximum input current from AC/DC input (in uA) + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + + summit,usb-current-limit-microamp: + description: Maximum input current from USB input (in uA) + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + + summit,charge-current-compensation-microamp: + description: Charge current compensation (in uA) + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + + summit,chip-temperature-threshold-celsius: + description: Chip temperature for thermal regulation in °C. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + enum: [100, 110, 120, 130] + + summit,soft-compensation-method: + description: Soft temperature limit compensation method + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: + - 0 # SMB3XX_SOFT_TEMP_COMPENSATE_NONE Compensation none + - 1 # SMB3XX_SOFT_TEMP_COMPENSATE_CURRENT Current compensation + - 2 # SMB3XX_SOFT_TEMP_COMPENSATE_VOLTAGE Voltage compensation + +allOf: + - if: + properties: + compatible: + enum: + - summit,smb345 + - summit,smb358 + + then: + properties: + summit,mains-current-limit-microamp: + enum: [ 300000, 500000, 700000, 1000000, + 1500000, 1800000, 2000000] + + summit,usb-current-limit-microamp: + enum: [ 300000, 500000, 700000, 1000000, + 1500000, 1800000, 2000000] + + summit,charge-current-compensation-microamp: + enum: [200000, 450000, 600000, 900000] + + else: + properties: + summit,mains-current-limit-microamp: + enum: [ 300000, 500000, 700000, 900000, 1200000, + 1500000, 1800000, 2000000, 2200000, 2500000] + + summit,usb-current-limit-microamp: + enum: [ 300000, 500000, 700000, 900000, 1200000, + 1500000, 1800000, 2000000, 2200000, 2500000] + + summit,charge-current-compensation-microamp: + enum: [250000, 700000, 900000, 1200000] + +required: + - compatible + - reg + +anyOf: + - required: + - summit,enable-usb-charging + - required: + - summit,enable-otg-charging + - required: + - summit,enable-mains-charging + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@7f { + compatible = "summit,smb347"; + reg = <0x7f>; + status = "okay"; + + summit,enable-charge-control = ; + summit,chip-temperature-threshold-celsius = <110>; + summit,mains-current-limit-microamp = <2000000>; + summit,usb-current-limit-microamp = <500000>; + summit,enable-usb-charging; + summit,enable-mains-charging; + + monitored-battery = <&battery>; + }; + }; + + battery: battery-cell { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <1800000>; + temperature-min-alert-celsius = <5>; + temperature-max-alert-celsius = <40>; + }; diff --git a/include/dt-bindings/power/summit,smb347-charger.h b/include/dt-bindings/power/summit,smb347-charger.h new file mode 100644 index 000000000000..d918bf321a71 --- /dev/null +++ b/include/dt-bindings/power/summit,smb347-charger.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: (GPL-2.0-or-later or MIT) */ +/* + * Author: David Heidelberg + */ + +#ifndef _DT_BINDINGS_SMB347_CHARGER_H +#define _DT_BINDINGS_SMB347_CHARGER_H + +/* Charging compensation method */ +#define SMB3XX_SOFT_TEMP_COMPENSATE_NONE 0 +#define SMB3XX_SOFT_TEMP_COMPENSATE_CURRENT 1 +#define SMB3XX_SOFT_TEMP_COMPENSATE_VOLTAGE 2 + +/* Charging enable control */ +#define SMB3XX_CHG_ENABLE_SW 0 +#define SMB3XX_CHG_ENABLE_PIN_ACTIVE_LOW 1 +#define SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH 2 + +#endif From patchwork Sun Jun 7 14:41:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591619 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 010B2912 for ; Sun, 7 Jun 2020 14:45:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D977F2075A for ; Sun, 7 Jun 2020 14:45:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V7kp/p+x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726991AbgFGOp4 (ORCPT ); Sun, 7 Jun 2020 10:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726653AbgFGOpV (ORCPT ); Sun, 7 Jun 2020 10:45:21 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5ED0C08C5C3; Sun, 7 Jun 2020 07:45:20 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id n23so17312093ljh.7; Sun, 07 Jun 2020 07:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V8hjnl7J75TBgREseCnpTfKZ6/8vTSO0YfrzAMW8j+Y=; b=V7kp/p+xPOSk54FW5XDENYYJc+8Qx20gXPfkMSmzghYsBUUTrlxXCLadiUbkhxNc9e LDLQjbXmppoBzZ2FwG+4Li9IqK2P7D37NT5x1oDpS09YPtatqEnoR/85Z40PIo8ge1gz rUJivIKQ7jVqketlbWKnjTxTpBqfwpXeJQUgiqTVee45sh+uWUQL82GcIj49/ytTrurk BbzNnRn5rAvEOT1KhknMhyarJNtFRrS8rvyYew2KpOT+Ql/H3Z8WC6z2Ni0+Fnm/dmoI nz0M8DjKwY8Hnkgwge857HAXEpX8hvWfC4Byx+u+B2M0qM41FZgvbfzEMWQmugJBcQFJ GEyQ== 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=V8hjnl7J75TBgREseCnpTfKZ6/8vTSO0YfrzAMW8j+Y=; b=tBtzCcFc7zZ4ScHkdpnO617uGWHh9dOyoDJ5cQmqfxCxC9v+dRVlEzgtEgHEQDTTEr pmql7Hu0ybNfB7ZnkRZzH9WrPTjgdjcQisXvf9WWGfMgoY9r4CuQE9VGjNlaBeyndTaI WAPLqAPLYeZSdCZDk3NiOE+MWORg5cXzTeYSD5paZ101Sm9TBMCVd8gigQ1kwIUzXA9x FFjmqeFcEU3NAAThBZvkvrwZPUmtQV3UwvNgSXUEC0d1a0qSx6uPmjdusTCllxRuyfeL PY5GBL1T/60t6AgBRcEsFzcfS1D7JSso1AigYnFEYOZx8mAnlEFnNiBEwrlRhN0a7vLt AfrQ== X-Gm-Message-State: AOAM532KP3W4HVeP9Jgf9Qy2iRvTdhI80dRDUfwBUbLAdyqE02fLVOox P489y13JCpYrQGEcp2a5vNISScoJ X-Google-Smtp-Source: ABdhPJxXZTroNVbRUnMl3S1YzL5uiXiCRxFtKp+WYoSbeN19JRapbT8ug/UFO3P+Jl+6r6PJ8DMb1A== X-Received: by 2002:a2e:7011:: with SMTP id l17mr9769977ljc.424.1591541118774; Sun, 07 Jun 2020 07:45:18 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:18 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 2/9] dt-bindings: battery: Add temperature properties Date: Sun, 7 Jun 2020 17:41:06 +0300 Message-Id: <20200607144113.10202-3-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Document generic battery temperature properties. Signed-off-by: Dmitry Osipenko --- .../devicetree/bindings/power/supply/battery.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/battery.txt b/Documentation/devicetree/bindings/power/supply/battery.txt index 5e29595edd74..e0c35eff9d3f 100644 --- a/Documentation/devicetree/bindings/power/supply/battery.txt +++ b/Documentation/devicetree/bindings/power/supply/battery.txt @@ -45,6 +45,16 @@ Optional Properties: and corresponding battery internal resistance percent, which is used to look up the resistance percent according to current temperature to get a accurate batterty internal resistance in different temperatures. + - temperature-ambient-min-alert-celsius: Alert when ambient temperature of a + battery is lower than threshold value. + - temperature-ambient-max-alert-celsius: Alert when ambient temperature of a + battery is higher than threshold value. + - temperature-min-alert-celsius: Alert when battery temperature is lower + than threshold value. + - temperature-max-alert-celsius: Alert when battery temperature is higher + than threshold value. + - temperature-min-celsius: minimum temperature at which battery can operate + - temperature-max-celsius: maximum temperature at which battery can operate Battery properties are named, where possible, for the corresponding elements in enum power_supply_property, defined in From patchwork Sun Jun 7 14:41:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AD5A912 for ; Sun, 7 Jun 2020 14:46:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10F8A206C3 for ; Sun, 7 Jun 2020 14:46:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h5k/BpkW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbgFGOpz (ORCPT ); Sun, 7 Jun 2020 10:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726684AbgFGOpV (ORCPT ); Sun, 7 Jun 2020 10:45:21 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E86EC08C5C4; Sun, 7 Jun 2020 07:45:21 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id x18so838764lji.1; Sun, 07 Jun 2020 07:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FBWrwuGDYKLF1vOWbwPhfzrgLBpIGQxKlTKbvNiY2ss=; b=h5k/BpkWLZlZJyeH4iWB7dTj3NqUreNyP4nokCg0nqCnreEhjJQ37Mb8Uyr62J10p0 ZU/5EGzD1sXYrsRf2HNkMVl0jB/FsKYbGJ6nbHKOnnKde7WCrBFaSnISynVP/2+NbqWO wNBmkRJiX1pcXaHm9KH0CqNZjCslESM2m61q16NXhNQk/SFK0zlPz9FvvOiXtj484lWR AkEw0kLHgKN5p12imeG+ZpziGh47a/8VjAh+E2vsq7Y1D759p2pBODb+Sxt1wF3Kgsfl H6dKsrTJqF61qLsasH/KT5zhL8/LkCQi2sQ4NAe4jD4vqpSjsBP7jLMsxKhUtFUda78Y RGmg== 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=FBWrwuGDYKLF1vOWbwPhfzrgLBpIGQxKlTKbvNiY2ss=; b=g8Jk/68Iig6WoALRiAXQv3wNmbGKXCw2I8dnaO+pFgCzhceLtx1zPtaayeVwAHPBEd YGji49DOilAUg2ppCdsu63x/jrG0A6zEjgB2jLpoi+6FkH9rd4QQIJKG5drOnyf3FRr1 OXFGvld6x4lds7emAGbgjTLEaEoxIGscaTp+hYnpaUv8k4tLi8dpCdEYz4AWVSjN26Ct ScH2n56rnLYhX2ejh2p7SWnIroZ1y/uLRquZ0Y/uhXP3J7ZpqT1aAEyj8hzakey82mmg BI9Lyg2zPnWe7cu85+dwCzaR+gu6kuhuxIPhgInjC4hmak4qX9ae21wQSpRefSsgdeSE 8PNQ== X-Gm-Message-State: AOAM532Sz31eSESMcMWR+POuNzdnAUMR52oCBq6GycbhGzhzzhbOFHGA oz3JfVYn29MsDbuK4j/TU18= X-Google-Smtp-Source: ABdhPJwduQ6Mg5XXVMUnf5kjLG+sCaJFsEsnZP6qobIVMm1rtA3asW69nA6EPCERg0uVYiLDxboYsg== X-Received: by 2002:a2e:8747:: with SMTP id q7mr8329350ljj.459.1591541119855; Sun, 07 Jun 2020 07:45:19 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:19 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 3/9] power: supply: Support battery temperature device-tree properties Date: Sun, 7 Jun 2020 17:41:07 +0300 Message-Id: <20200607144113.10202-4-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The generic battery temperature properties are already supported by the power-supply core. Let's support parsing of the common battery temperature properties from a device-tree. Signed-off-by: Dmitry Osipenko --- drivers/power/supply/power_supply_core.c | 18 ++++++++++++++++++ include/linux/power_supply.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 02b37fe6061c..8b54a5a107d7 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -579,6 +579,12 @@ int power_supply_get_battery_info(struct power_supply *psy, info->charge_term_current_ua = -EINVAL; info->constant_charge_current_max_ua = -EINVAL; info->constant_charge_voltage_max_uv = -EINVAL; + info->temp_ambient_alert_min = INT_MIN; + info->temp_ambient_alert_max = INT_MAX; + info->temp_alert_min = INT_MIN; + info->temp_alert_max = INT_MAX; + info->temp_min = INT_MIN; + info->temp_max = INT_MAX; info->factory_internal_resistance_uohm = -EINVAL; info->resist_table = NULL; @@ -638,6 +644,18 @@ int power_supply_get_battery_info(struct power_supply *psy, &info->constant_charge_voltage_max_uv); of_property_read_u32(battery_np, "factory-internal-resistance-micro-ohms", &info->factory_internal_resistance_uohm); + of_property_read_u32(battery_np, "temperature-ambient-min-alert-celsius", + &info->temp_ambient_alert_min); + of_property_read_u32(battery_np, "temperature-ambient-max-alert-celsius", + &info->temp_ambient_alert_max); + of_property_read_u32(battery_np, "temperature-min-alert-celsius", + &info->temp_alert_min); + of_property_read_u32(battery_np, "temperature-max-alert-celsius", + &info->temp_alert_max); + of_property_read_u32(battery_np, "temperature-min-celsius", + &info->temp_min); + of_property_read_u32(battery_np, "temperature-max-celsius", + &info->temp_max); len = of_property_count_u32_elems(battery_np, "ocv-capacity-celsius"); if (len < 0 && len != -EINVAL) { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ac1345a48ad0..31fcadd81d63 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -361,6 +361,12 @@ struct power_supply_battery_info { int constant_charge_voltage_max_uv; /* microVolts */ int factory_internal_resistance_uohm; /* microOhms */ int ocv_temp[POWER_SUPPLY_OCV_TEMP_MAX];/* celsius */ + int temp_ambient_alert_min; /* celsius */ + int temp_ambient_alert_max; /* celsius */ + int temp_alert_min; /* celsius */ + int temp_alert_max; /* celsius */ + int temp_min; /* celsius */ + int temp_max; /* celsius */ struct power_supply_battery_ocv_table *ocv_table[POWER_SUPPLY_OCV_TEMP_MAX]; int ocv_table_size[POWER_SUPPLY_OCV_TEMP_MAX]; struct power_supply_resistance_temp_table *resist_table; From patchwork Sun Jun 7 14:41:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591595 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E288913 for ; Sun, 7 Jun 2020 14:45:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5673320801 for ; Sun, 7 Jun 2020 14:45:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ot4EUtsP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726528AbgFGOpY (ORCPT ); Sun, 7 Jun 2020 10:45:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbgFGOpX (ORCPT ); Sun, 7 Jun 2020 10:45:23 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C9ADC08C5C3; Sun, 7 Jun 2020 07:45:22 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id 202so8644763lfe.5; Sun, 07 Jun 2020 07:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y8Cu9juxYNFZC2z0hTA24pcBzRFIIFKT2GRI02KZjfs=; b=Ot4EUtsPYfXjE8+Ykn9xXH6MgLhqxOAXc1rwB12oNHaHemWntn9+WIkCtvWJza1JuQ R/10HqjsM865LG/N0nfAKAK3rEnIgKELqOeqeKGdCPCpbsJS0WG8v/dSIl3hQJsQk4dD 4oX8LcQ0h4TOLVB3vUWYrFsZk7fnunCb0JTIgYFEG0hbygQ6NdXAilpG6CpNgrpYlSWX rcIJNEnUfXxviG1PeNWV3uZmz22v/m/TgO5ZJOHLMS2KiBwsPgUgAc9yPrjA4YTYwTSe kuvRozgNNxtqG6eIV7kjTiB9dHp31E/pLxl7i6ZPWf6rUglbazND8MfyPRTBVULAZO77 vbSA== 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=Y8Cu9juxYNFZC2z0hTA24pcBzRFIIFKT2GRI02KZjfs=; b=bemjClezu8SJs/XQ8QwjlzAOGHDlhfo9kj6CkUmMty/4bvds9hjtNTzPITOMBDfuZl 9CRX6Q0/dxilgpZig4ssRBDJIbOemYYo9ofjNjEJomqcudKTxtX+46yJ7FscwZ3lgTgQ s/VxQg5tyeDIE3ognAGhRCK0dCjapo4ZI7JDRZdOOHzMJVaaN2MC87yeS5pEEos1u7gn nUA7bvFp9RWq8YTVF1NgMg8LSTNdC9nJmD6naGYPOMhGs+XNmzHzsKVsLLXF6pOZYAiS 0gq/79RSUIAAk5SkJezm3TfCbiv3yb95mwOrqcjX6cvHhwWQFS45Zls+aMfbdOZRt/Wh d7tQ== X-Gm-Message-State: AOAM530pSRdYJ1T8i558PvCqkM87arVPszXb5DeNo3qlyyQX1HkprUTG riiuIzDQ88LtbZWHYb5YAP8= X-Google-Smtp-Source: ABdhPJwphUUrahUtVUqL+i+apuVy8jMi8VlW9DoLZAsgClvEpyuManKqwgS/kE4GLZ8pDEEf9DppUQ== X-Received: by 2002:a19:6e0e:: with SMTP id j14mr10320178lfc.155.1591541120964; Sun, 07 Jun 2020 07:45:20 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:20 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 4/9] power: supply: smb347-charger: Use resource-managed API Date: Sun, 7 Jun 2020 17:41:08 +0300 Message-Id: <20200607144113.10202-5-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: David Heidelberg Simplify code, more convenient to use with Device Tree. Reviewed-by: Dmitry Osipenko Signed-off-by: David Heidelberg --- drivers/power/supply/smb347-charger.c | 75 +++++++++++---------------- 1 file changed, 29 insertions(+), 46 deletions(-) diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c index f99026d81f2a..60894105fcbd 100644 --- a/drivers/power/supply/smb347-charger.c +++ b/drivers/power/supply/smb347-charger.c @@ -836,21 +836,31 @@ static int smb347_irq_init(struct smb347_charger *smb, struct i2c_client *client) { const struct smb347_charger_platform_data *pdata = smb->pdata; - int ret, irq = gpio_to_irq(pdata->irq_gpio); + unsigned long irqflags = IRQF_ONESHOT; + int ret; - ret = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name); - if (ret < 0) - goto fail; + /* Requesting GPIO for IRQ is only needed in non-DT way */ + if (!client->irq) { + int irq = gpio_to_irq(pdata->irq_gpio); + + ret = devm_gpio_request_one(smb->dev, pdata->irq_gpio, + GPIOF_IN, client->name); + if (ret < 0) + return ret; + + irqflags |= IRQF_TRIGGER_FALLING; + client->irq = irq; + } - ret = request_threaded_irq(irq, NULL, smb347_interrupt, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - client->name, smb); + ret = devm_request_threaded_irq(smb->dev, client->irq, NULL, + smb347_interrupt, irqflags, + client->name, smb); if (ret < 0) - goto fail_gpio; + return ret; ret = smb347_set_writable(smb, true); if (ret < 0) - goto fail_irq; + return ret; /* * Configure the STAT output to be suitable for interrupts: disable @@ -860,20 +870,10 @@ static int smb347_irq_init(struct smb347_charger *smb, CFG_STAT_ACTIVE_HIGH | CFG_STAT_DISABLED, CFG_STAT_DISABLED); if (ret < 0) - goto fail_readonly; + client->irq = 0; smb347_set_writable(smb, false); - client->irq = irq; - return 0; -fail_readonly: - smb347_set_writable(smb, false); -fail_irq: - free_irq(irq, smb); -fail_gpio: - gpio_free(pdata->irq_gpio); -fail: - client->irq = 0; return ret; } @@ -1251,32 +1251,24 @@ static int smb347_probe(struct i2c_client *client, mains_usb_cfg.num_supplicants = ARRAY_SIZE(battery); mains_usb_cfg.drv_data = smb; if (smb->pdata->use_mains) { - smb->mains = power_supply_register(dev, &smb347_mains_desc, - &mains_usb_cfg); + smb->mains = devm_power_supply_register(dev, &smb347_mains_desc, + &mains_usb_cfg); if (IS_ERR(smb->mains)) return PTR_ERR(smb->mains); } if (smb->pdata->use_usb) { - smb->usb = power_supply_register(dev, &smb347_usb_desc, - &mains_usb_cfg); - if (IS_ERR(smb->usb)) { - if (smb->pdata->use_mains) - power_supply_unregister(smb->mains); + smb->usb = devm_power_supply_register(dev, &smb347_usb_desc, + &mains_usb_cfg); + if (IS_ERR(smb->usb)) return PTR_ERR(smb->usb); - } } battery_cfg.drv_data = smb; - smb->battery = power_supply_register(dev, &smb347_battery_desc, - &battery_cfg); - if (IS_ERR(smb->battery)) { - if (smb->pdata->use_usb) - power_supply_unregister(smb->usb); - if (smb->pdata->use_mains) - power_supply_unregister(smb->mains); + smb->battery = devm_power_supply_register(dev, &smb347_battery_desc, + &battery_cfg); + if (IS_ERR(smb->battery)) return PTR_ERR(smb->battery); - } /* * Interrupt pin is optional. If it is connected, we setup the @@ -1299,17 +1291,8 @@ static int smb347_remove(struct i2c_client *client) { struct smb347_charger *smb = i2c_get_clientdata(client); - if (client->irq) { + if (client->irq) smb347_irq_disable(smb); - free_irq(client->irq, smb); - gpio_free(smb->pdata->irq_gpio); - } - - power_supply_unregister(smb->battery); - if (smb->pdata->use_usb) - power_supply_unregister(smb->usb); - if (smb->pdata->use_mains) - power_supply_unregister(smb->mains); return 0; } From patchwork Sun Jun 7 14:41:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D22C0913 for ; Sun, 7 Jun 2020 14:45:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B03192075A for ; Sun, 7 Jun 2020 14:45:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jf9MDeYL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726738AbgFGOp0 (ORCPT ); Sun, 7 Jun 2020 10:45:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726707AbgFGOpZ (ORCPT ); Sun, 7 Jun 2020 10:45:25 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACC96C08C5C4; Sun, 7 Jun 2020 07:45:23 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id z206so8645557lfc.6; Sun, 07 Jun 2020 07:45:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WYBp5mdBBM45oktTGbo9qOZLxSTcqGm9flsVN5koDd4=; b=jf9MDeYLmc2QRwrxS7fy0a4/qSC35Y6CJMhsXJRSayPYSth8ulEhOydEHe3ey/xf+f fro+2MhHfbABzI3EOA7SDmF0vO+2Xm/kFAJb9a0HlGE/ST/S2RjMFhkkDBQzVoI5ITbF ww7LLADLBx3ocynWzag2NRGLO0kh9WgdGYSU8CPS/ywlWQEY9Y07T0Bx6rBegqY7qvAX 0BNbo0vZ4gUNlJ6ctP/P89fYlky/Hwt5C0mlh2xzLcoPJ4ImBt58Z6rFntFmpjfbiEVT 8h7jCR8yvqJXd95wjIrHWMdlZmmYoHYzyW8y82+6MkFEHzkDKXBABPzJL0xKrD7C5GUW Y3uw== 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=WYBp5mdBBM45oktTGbo9qOZLxSTcqGm9flsVN5koDd4=; b=Tywd42JswMPbh3MSEOEnqJItKjxltL9oc1NhFXUwJTimkBCt8eBf9WJRiZq9+k+3eT 4eZkfI9eqrDsvUTexx9a6ERpe8BBdefB3t1j/drMrbgTnzji/nmDw24BCmfzW6kNdp+9 9YF3v6fPPEa8agpoCCpG2m9FE3hZxva843AfXEdBZ+edCXf/obDdqdrhiU025t87rQ2O i3CMDNVk/a59up4h5Jp84wJmejlXKXfv8RqzJizmMmGnm7+yFpz1o74m6U/WM2yTPolN JqpHK4mZMUxrR78/2s9q496wkB2uCvAQAZx7UsLFPDR09ESBnEvJfZ/eHl3aqEJD83DQ 8y4w== X-Gm-Message-State: AOAM533GpvdsRxj+77en4ROj9cg4173HM5Vu/30DE1fVYsoGKwnx+2uO EvodivFY/Jwc/tozAbxmbGf0grAZ X-Google-Smtp-Source: ABdhPJy9PFzzHIEC3INDNYtNswkra1T4M+Q1kuQUzvzI3E2svyPdo3GGthpK/IQM+bV6S7a+a2CaIA== X-Received: by 2002:a19:150:: with SMTP id 77mr10297190lfb.71.1591541122076; Sun, 07 Jun 2020 07:45:22 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:21 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 5/9] power: supply: smb347-charger: Implement device-tree support Date: Sun, 7 Jun 2020 17:41:09 +0300 Message-Id: <20200607144113.10202-6-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: David Heidelberg This patch adds device-tree support to the SMB347 charger driver. All legacy platform data now can be parsed from DT. Because of that and since SMB347 is an I2C client driver, the IRQ number can be passed automatically through client's IRQ variable if it's defined in DT. There is no need to map GPIO to IRQ manually in the case of DT. This patch is based on the original work made by: Jonghwa Lee Link: https://patchwork.kernel.org/patch/4284731/ Signed-off-by: Dmitry Osipenko Signed-off-by: David Heidelberg --- drivers/power/supply/smb347-charger.c | 151 +++++++++++++++++++++++--- 1 file changed, 137 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c index 60894105fcbd..da2c337107bf 100644 --- a/drivers/power/supply/smb347-charger.c +++ b/drivers/power/supply/smb347-charger.c @@ -1180,6 +1180,119 @@ static bool smb347_readable_reg(struct device *dev, unsigned int reg) return smb347_volatile_reg(dev, reg); } +static void smb347_dt_parse_pdata(struct device_node *np, + struct smb347_charger_platform_data *pdata) +{ + pdata->soft_temp_limit_compensation = + SMB347_SOFT_TEMP_COMPENSATE_DEFAULT; + /* + * These properties come from the battery info, still we need to + * pre-initialize the values. See smb347_get_battery_info() below. + */ + pdata->soft_cold_temp_limit = SMB347_TEMP_USE_DEFAULT; + pdata->hard_cold_temp_limit = SMB347_TEMP_USE_DEFAULT; + pdata->soft_hot_temp_limit = SMB347_TEMP_USE_DEFAULT; + pdata->hard_hot_temp_limit = SMB347_TEMP_USE_DEFAULT; + + /* Charging constraints */ + of_property_read_u32(np, "summit,fast-voltage-threshold-microvolt", + &pdata->pre_to_fast_voltage); + of_property_read_u32(np, "summit,mains-current-limit-microamp", + &pdata->mains_current_limit); + of_property_read_u32(np, "summit,usb-current-limit-microamp", + &pdata->usb_hc_current_limit); + + /* For thermometer monitoring */ + of_property_read_u32(np, "summit,chip-temperature-threshold-celsius", + &pdata->chip_temp_threshold); + of_property_read_u32(np, "summit,soft-compensation-method", + &pdata->soft_temp_limit_compensation); + of_property_read_u32(np, "summit,charge-current-compensation-microamp", + &pdata->charge_current_compensation); + + /* Supported charging mode */ + pdata->use_mains = + of_property_read_bool(np, "summit,enable-mains-charging"); + pdata->use_usb = + of_property_read_bool(np, "summit,enable-usb-charging"); + pdata->use_usb_otg = + of_property_read_bool(np, "summit,enable-otg-charging"); + + /* Select charging control */ + of_property_read_u32(np, "summit,enable-charge-control", + &pdata->enable_control); + + /* Interrupt support is optional */ + if (!of_find_property(np, "interrupts", NULL)) + pdata->irq_gpio = -1; +} + +static int smb347_get_battery_info(struct smb347_charger *smb) +{ + struct smb347_charger_platform_data *pdata = (void *)smb->pdata; + struct power_supply_battery_info info = {}; + struct power_supply *supply; + int err; + + if (smb->mains) + supply = smb->mains; + else + supply = smb->usb; + + err = power_supply_get_battery_info(supply, &info); + if (err == -ENXIO || err == -ENODEV) + return 0; + if (err) + return err; + + if (info.constant_charge_current_max_ua != -EINVAL) + pdata->max_charge_current = info.constant_charge_current_max_ua; + + if (info.constant_charge_voltage_max_uv != -EINVAL) + pdata->max_charge_voltage = info.constant_charge_voltage_max_uv; + + if (info.precharge_current_ua != -EINVAL) + pdata->pre_charge_current = info.precharge_current_ua; + + if (info.charge_term_current_ua != -EINVAL) + pdata->termination_current = info.charge_term_current_ua; + + if (info.temp_alert_min != INT_MIN) + pdata->soft_cold_temp_limit = info.temp_alert_min; + + if (info.temp_alert_max != INT_MAX) + pdata->soft_hot_temp_limit = info.temp_alert_max; + + if (info.temp_min != INT_MIN) + pdata->hard_cold_temp_limit = info.temp_min; + + if (info.temp_max != INT_MAX) + pdata->hard_hot_temp_limit = info.temp_max; + + /* Suspend when battery temperature is outside hard limits */ + if (pdata->hard_cold_temp_limit != SMB347_TEMP_USE_DEFAULT || + pdata->hard_hot_temp_limit != SMB347_TEMP_USE_DEFAULT) + pdata->suspend_on_hard_temp_limit = true; + + return 0; +} + +static struct smb347_charger_platform_data + *smb347_get_platdata(struct device *dev) +{ + struct smb347_charger_platform_data *pdata; + + if (dev->of_node) { + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (pdata) + smb347_dt_parse_pdata(dev->of_node, pdata); + } else { + pdata = dev_get_platdata(dev); + } + + return pdata; +} + static const struct regmap_config smb347_regmap = { .reg_bits = 8, .val_bits = 8, @@ -1216,40 +1329,35 @@ static int smb347_probe(struct i2c_client *client, const struct i2c_device_id *id) { static char *battery[] = { "smb347-battery" }; - const struct smb347_charger_platform_data *pdata; struct power_supply_config mains_usb_cfg = {}, battery_cfg = {}; struct device *dev = &client->dev; struct smb347_charger *smb; int ret; - pdata = dev->platform_data; - if (!pdata) - return -EINVAL; - - if (!pdata->use_mains && !pdata->use_usb) - return -EINVAL; - smb = devm_kzalloc(dev, sizeof(*smb), GFP_KERNEL); if (!smb) return -ENOMEM; + smb->pdata = smb347_get_platdata(dev); + if (!smb->pdata) + return -ENODEV; + + if (!smb->pdata->use_mains && !smb->pdata->use_usb) + return -EINVAL; + i2c_set_clientdata(client, smb); mutex_init(&smb->lock); smb->dev = &client->dev; - smb->pdata = pdata; smb->regmap = devm_regmap_init_i2c(client, &smb347_regmap); if (IS_ERR(smb->regmap)) return PTR_ERR(smb->regmap); - ret = smb347_hw_init(smb); - if (ret < 0) - return ret; - mains_usb_cfg.supplied_to = battery; mains_usb_cfg.num_supplicants = ARRAY_SIZE(battery); mains_usb_cfg.drv_data = smb; + mains_usb_cfg.of_node = dev->of_node; if (smb->pdata->use_mains) { smb->mains = devm_power_supply_register(dev, &smb347_mains_desc, &mains_usb_cfg); @@ -1270,11 +1378,19 @@ static int smb347_probe(struct i2c_client *client, if (IS_ERR(smb->battery)) return PTR_ERR(smb->battery); + ret = smb347_get_battery_info(smb); + if (ret) + return ret; + + ret = smb347_hw_init(smb); + if (ret < 0) + return ret; + /* * Interrupt pin is optional. If it is connected, we setup the * interrupt support here. */ - if (pdata->irq_gpio >= 0) { + if (smb->pdata->irq_gpio >= 0) { ret = smb347_irq_init(smb, client); if (ret < 0) { dev_warn(dev, "failed to initialize IRQ: %d\n", ret); @@ -1302,9 +1418,16 @@ static const struct i2c_device_id smb347_id[] = { }; MODULE_DEVICE_TABLE(i2c, smb347_id); +static const struct of_device_id smb3xx_of_match[] = { + { .compatible = "summit,smb347" }, + { }, +}; +MODULE_DEVICE_TABLE(of, smb3xx_of_match); + static struct i2c_driver smb347_driver = { .driver = { .name = "smb347", + .of_match_table = smb3xx_of_match, }, .probe = smb347_probe, .remove = smb347_remove, From patchwork Sun Jun 7 14:41:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591613 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA07B912 for ; Sun, 7 Jun 2020 14:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A3672075A for ; Sun, 7 Jun 2020 14:45:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ClVNPEnj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbgFGOpt (ORCPT ); Sun, 7 Jun 2020 10:45:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726714AbgFGOpZ (ORCPT ); Sun, 7 Jun 2020 10:45:25 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5332C08C5C3; Sun, 7 Jun 2020 07:45:24 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id 82so8633536lfh.2; Sun, 07 Jun 2020 07:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n0p8Sk1v7EeJDCHft8mVeiI6+sfI1r+oyOxQ4USZEDU=; b=ClVNPEnjNB01G7uusxaoL90k7Dm0mOyLbOYWqm7N89Fx8E/xtRUuyC+7Dv/K60nj0W nDiMwrN2xG2/d3cJW+U3+xMQdmg9YpI1ikW8FkhxyoU8lsIU/ki1arzjB/iiY3+/bBi/ R8q4XUO0QfSWL1ld+Fm+O0pKxIxRTSd97ZFKYAI5u+EzFl5KpRO0bMWzHmSdDNcl6a6W /MghdryGpY1Il+5H6zgpMk/OnximLVxItuW10MhnzutcNEK3A2rnYTx90jmbz6eGPkoN LHqbkM71kH7RN16wgp+uIKxiwXLSEUK+imXfnXYLqeLoGUQGEqHsbx8bwy34IwzDWweV oCkw== 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=n0p8Sk1v7EeJDCHft8mVeiI6+sfI1r+oyOxQ4USZEDU=; b=hf3kAxn6dYh/SomgjuoEV42/vZic8EWQw18elkK5pEDvFYNF/srn02wlC5LX3DMgeZ 6YxelzJoYXlBQn+EddIMWeq3F8sSL/5Xxr1QG9xi0UeQNgtouurXGSNNxYnZkf9nCFab YQbWQ2pQUB+N36ZFIbAE8bCGPFfsUolTl7hc5XZ8hp16LabndEAHrVxGrXfnqfY2g/ME 2DKzXv++70vo6Mq5yxltdAMfP43Qc/RUVK/7A+bR3+OnK7RV3B4GbgnX61d59FUmMXOk wplKj8E3YL8onR49K4U8p/jm1Xx5d1upgpDpL2nZYjTA2c0zEQ8yp5eyAPTB0lz38kKa UIcw== X-Gm-Message-State: AOAM532tjC+TYAVkLI/xDYTpozwdSDwIjE6fRMmVasphnfxlMU/W6Ivy aktHIWh1pXaHBbmccTIB7j4= X-Google-Smtp-Source: ABdhPJz2AOTaQs6OuXZwcYaQpx+OJfiI7T7A5lltH12OTjjUlG/SfqAcAKIw+LXtYhz5rPtZYmeMdQ== X-Received: by 2002:a05:6512:691:: with SMTP id t17mr10571189lfe.85.1591541123197; Sun, 07 Jun 2020 07:45:23 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:22 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 6/9] power: supply: smb347-charger: Support SMB345 and SMB358 Date: Sun, 7 Jun 2020 17:41:10 +0300 Message-Id: <20200607144113.10202-7-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: David Heidelberg SMB345 tested on Nexus 7 2013. Based on: - https://patchwork.kernel.org/patch/4922431/ - https://patchwork.ozlabs.org/patch/666877/ Signed-off-by: David Heidelberg --- drivers/power/supply/Kconfig | 6 +- drivers/power/supply/smb347-charger.c | 109 ++++++++++++++------------ 2 files changed, 62 insertions(+), 53 deletions(-) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 5dde0e2de232..3ace33b116a8 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -626,12 +626,12 @@ config CHARGER_BQ25890 Say Y to enable support for the TI BQ25890 battery charger. config CHARGER_SMB347 - tristate "Summit Microelectronics SMB347 Battery Charger" + tristate "Summit Microelectronics SMB3XX Battery Charger" depends on I2C select REGMAP_I2C help - Say Y to include support for Summit Microelectronics SMB347 - Battery Charger. + Say Y to include support for Summit Microelectronics SMB345, + SMB347 or SMB358 Battery Charger. config CHARGER_TPS65090 tristate "TPS65090 battery charger driver" diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c index da2c337107bf..90a87e0624a6 100644 --- a/drivers/power/supply/smb347-charger.c +++ b/drivers/power/supply/smb347-charger.c @@ -128,6 +128,7 @@ * @mains: power_supply instance for AC/DC power * @usb: power_supply instance for USB power * @battery: power_supply instance for battery + * @id: SMB charger ID * @mains_online: is AC/DC input connected * @usb_online: is USB input connected * @charging_enabled: is charging enabled @@ -140,64 +141,61 @@ struct smb347_charger { struct power_supply *mains; struct power_supply *usb; struct power_supply *battery; + unsigned int id; bool mains_online; bool usb_online; bool charging_enabled; const struct smb347_charger_platform_data *pdata; }; -/* Fast charge current in uA */ -static const unsigned int fcc_tbl[] = { - 700000, - 900000, - 1200000, - 1500000, - 1800000, - 2000000, - 2200000, - 2500000, +enum smb_charger_chipid { + SMB345, + SMB347, + SMB358, + NUM_CHIP_TYPES, }; +/* Fast charge current in uA */ +static const unsigned int fcc_tbl[NUM_CHIP_TYPES][8] = { + [SMB345] = { 200000, 450000, 600000, 900000, + 1300000, 1500000, 1800000, 2000000 }, + [SMB347] = { 700000, 900000, 1200000, 1500000, + 1800000, 2000000, 2200000, 2500000 }, + [SMB358] = { 200000, 450000, 600000, 900000, + 1300000, 1500000, 1800000, 2000000 }, +}; /* Pre-charge current in uA */ -static const unsigned int pcc_tbl[] = { - 100000, - 150000, - 200000, - 250000, +static const unsigned int pcc_tbl[NUM_CHIP_TYPES][4] = { + [SMB345] = { 150000, 250000, 350000, 450000 }, + [SMB347] = { 100000, 150000, 200000, 250000 }, + [SMB358] = { 150000, 250000, 350000, 450000 }, }; /* Termination current in uA */ -static const unsigned int tc_tbl[] = { - 37500, - 50000, - 100000, - 150000, - 200000, - 250000, - 500000, - 600000, +static const unsigned int tc_tbl[NUM_CHIP_TYPES][8] = { + [SMB345] = { 30000, 40000, 60000, 80000, + 100000, 125000, 150000, 200000 }, + [SMB347] = { 37500, 50000, 100000, 150000, + 200000, 250000, 500000, 600000 }, + [SMB358] = { 30000, 40000, 60000, 80000, + 100000, 125000, 150000, 200000 }, }; /* Input current limit in uA */ -static const unsigned int icl_tbl[] = { - 300000, - 500000, - 700000, - 900000, - 1200000, - 1500000, - 1800000, - 2000000, - 2200000, - 2500000, +static const unsigned int icl_tbl[NUM_CHIP_TYPES][10] = { + [SMB345] = { 300000, 500000, 700000, 1000000, 1500000, + 1800000, 2000000, 2000000, 2000000, 2000000 }, + [SMB347] = { 300000, 500000, 700000, 900000, 1200000, + 1500000, 1800000, 2000000, 2200000, 2500000 }, + [SMB358] = { 300000, 500000, 700000, 1000000, 1500000, + 1800000, 2000000, 2000000, 2000000, 2000000 }, }; /* Charge current compensation in uA */ -static const unsigned int ccc_tbl[] = { - 250000, - 700000, - 900000, - 1200000, +static const unsigned int ccc_tbl[NUM_CHIP_TYPES][4] = { + [SMB345] = { 200000, 450000, 600000, 900000 }, + [SMB347] = { 250000, 700000, 900000, 1200000 }, + [SMB358] = { 200000, 450000, 600000, 900000 }, }; /* Convert register value to current using lookup table */ @@ -352,10 +350,11 @@ static int smb347_start_stop_charging(struct smb347_charger *smb) static int smb347_set_charge_current(struct smb347_charger *smb) { + unsigned int id = smb->id; int ret; if (smb->pdata->max_charge_current) { - ret = current_to_hw(fcc_tbl, ARRAY_SIZE(fcc_tbl), + ret = current_to_hw(fcc_tbl[id], ARRAY_SIZE(fcc_tbl[id]), smb->pdata->max_charge_current); if (ret < 0) return ret; @@ -368,7 +367,7 @@ static int smb347_set_charge_current(struct smb347_charger *smb) } if (smb->pdata->pre_charge_current) { - ret = current_to_hw(pcc_tbl, ARRAY_SIZE(pcc_tbl), + ret = current_to_hw(pcc_tbl[id], ARRAY_SIZE(pcc_tbl[id]), smb->pdata->pre_charge_current); if (ret < 0) return ret; @@ -381,7 +380,7 @@ static int smb347_set_charge_current(struct smb347_charger *smb) } if (smb->pdata->termination_current) { - ret = current_to_hw(tc_tbl, ARRAY_SIZE(tc_tbl), + ret = current_to_hw(tc_tbl[id], ARRAY_SIZE(tc_tbl[id]), smb->pdata->termination_current); if (ret < 0) return ret; @@ -397,10 +396,11 @@ static int smb347_set_charge_current(struct smb347_charger *smb) static int smb347_set_current_limits(struct smb347_charger *smb) { + unsigned int id = smb->id; int ret; if (smb->pdata->mains_current_limit) { - ret = current_to_hw(icl_tbl, ARRAY_SIZE(icl_tbl), + ret = current_to_hw(icl_tbl[id], ARRAY_SIZE(icl_tbl[id]), smb->pdata->mains_current_limit); if (ret < 0) return ret; @@ -413,7 +413,7 @@ static int smb347_set_current_limits(struct smb347_charger *smb) } if (smb->pdata->usb_hc_current_limit) { - ret = current_to_hw(icl_tbl, ARRAY_SIZE(icl_tbl), + ret = current_to_hw(icl_tbl[id], ARRAY_SIZE(icl_tbl[id]), smb->pdata->usb_hc_current_limit); if (ret < 0) return ret; @@ -463,6 +463,7 @@ static int smb347_set_voltage_limits(struct smb347_charger *smb) static int smb347_set_temp_limits(struct smb347_charger *smb) { + unsigned int id = smb->id; bool enable_therm_monitor = false; int ret = 0; int val; @@ -587,7 +588,7 @@ static int smb347_set_temp_limits(struct smb347_charger *smb) } if (smb->pdata->charge_current_compensation) { - val = current_to_hw(ccc_tbl, ARRAY_SIZE(ccc_tbl), + val = current_to_hw(ccc_tbl[id], ARRAY_SIZE(ccc_tbl[id]), smb->pdata->charge_current_compensation); if (val < 0) return val; @@ -883,6 +884,7 @@ static int smb347_irq_init(struct smb347_charger *smb, */ static int get_const_charge_current(struct smb347_charger *smb) { + unsigned int id = smb->id; int ret, intval; unsigned int v; @@ -898,10 +900,12 @@ static int get_const_charge_current(struct smb347_charger *smb) * and we can detect which table to use from bit 5. */ if (v & 0x20) { - intval = hw_to_current(fcc_tbl, ARRAY_SIZE(fcc_tbl), v & 7); + intval = hw_to_current(fcc_tbl[id], + ARRAY_SIZE(fcc_tbl[id]), v & 7); } else { v >>= 3; - intval = hw_to_current(pcc_tbl, ARRAY_SIZE(pcc_tbl), v & 7); + intval = hw_to_current(pcc_tbl[id], + ARRAY_SIZE(pcc_tbl[id]), v & 7); } return intval; @@ -1349,6 +1353,7 @@ static int smb347_probe(struct i2c_client *client, mutex_init(&smb->lock); smb->dev = &client->dev; + smb->id = id->driver_data; smb->regmap = devm_regmap_init_i2c(client, &smb347_regmap); if (IS_ERR(smb->regmap)) @@ -1413,13 +1418,17 @@ static int smb347_remove(struct i2c_client *client) } static const struct i2c_device_id smb347_id[] = { - { "smb347", 0 }, - { } + { "smb345", SMB345 }, + { "smb347", SMB347 }, + { "smb358", SMB358 }, + { }, }; MODULE_DEVICE_TABLE(i2c, smb347_id); static const struct of_device_id smb3xx_of_match[] = { + { .compatible = "summit,smb345" }, { .compatible = "summit,smb347" }, + { .compatible = "summit,smb358" }, { }, }; MODULE_DEVICE_TABLE(of, smb3xx_of_match); From patchwork Sun Jun 7 14:41:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591605 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52459913 for ; Sun, 7 Jun 2020 14:45:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3460D20748 for ; Sun, 7 Jun 2020 14:45:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="trHAMxcE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbgFGOpe (ORCPT ); Sun, 7 Jun 2020 10:45:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbgFGOp0 (ORCPT ); Sun, 7 Jun 2020 10:45:26 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF1D8C08C5C5; Sun, 7 Jun 2020 07:45:25 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id i27so6363719ljb.12; Sun, 07 Jun 2020 07:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VXE4lBOODapYr9LH1elDIiR9HeDoap/PYoJe31d+vUI=; b=trHAMxcEajrBshFTId0H92JS1zkovwJgK/8iZ7GEbkCCTmsOmDg+1OV5mg1tS1RBUQ T170v1fKY9Yu+h0qItT86SEr70aD/fdaF3uu03PxSTXN5CVoZAAc87vbyqHLit1MwZma JMcD9ukXp2jYHeO8D09zY3ARwR+RzU4jXlDpmefBNPptcXvCdLc8QR6P12EgjjTRKTM7 cnt8E29R6sc35kZT98Vsi789ctBnaZS7aWIyBBQdAY06TJ/+R96Bkb7je0TWT+DPmaH1 kq9GO6D/M95nl8eYoDHfO4DGieugwv9vHFUVRrOitHznc+i12O7mEVi780DR2q7vAJmY Ub9A== 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=VXE4lBOODapYr9LH1elDIiR9HeDoap/PYoJe31d+vUI=; b=f/RTJSKFReih7R4bazrnn1nWREIdXWRlnx2QcDqMj6+ENgn0er/lyiM+iOQkPdrAa7 nCh+gDI9PAtvcLw1UWjDjJvQOtkavVfbfkB63uvxhFbXMklAlzO20ZG+vtLfaIYftkvk gqPmZmnhlcqt6hpKrj928qoEEKaDWBwxjVUHVOQElhMd2H5MqjsFdCVNlLCyl4C5TAVU pWzA/TsANofgMADcfWt/F5uyJNEqatunRlv954GV5HiHQ0KBM9zYIEvlmgOVG3gD+t7f fLcyuf2Q6hChPFJ0jUOoyrrdYp7mEn+wWd6c7VC1zqfC5si9O3XjAKGDMBfNEYH8NMwO pw/w== X-Gm-Message-State: AOAM532MrxRVcMsEG+dav0Co3iPg2AOIs2pHBDlQEqOkHYa6S1afUTx9 TQc3VCFiMf7qUoamTZXmRaU= X-Google-Smtp-Source: ABdhPJwTHL/+8wo5bG0EF7b2WX1RNAOmgsy4PE8lQnd/mdNmas7mJRxbIqHuG78oZAQtoviLrSUvMw== X-Received: by 2002:a2e:81d4:: with SMTP id s20mr9116331ljg.184.1591541124437; Sun, 07 Jun 2020 07:45:24 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:23 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 7/9] power: supply: smb347-charger: Remove virtual smb347-battery Date: Sun, 7 Jun 2020 17:41:11 +0300 Message-Id: <20200607144113.10202-8-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: David Heidelberg SMB347 is a charger and not a battery driver. Secondly, power-supply core now supports monitored-battery. So the 'fake' battery doesn't do anything useful for us, and thus, it should be removed. Transfer smb347-battery functionality into smb347-mains and smb347-usb. Reviewed-by: Dmitry Osipenko Signed-off-by: David Heidelberg --- drivers/power/supply/smb347-charger.c | 206 ++++++++------------------ 1 file changed, 60 insertions(+), 146 deletions(-) diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c index 90a87e0624a6..335b6ee494e4 100644 --- a/drivers/power/supply/smb347-charger.c +++ b/drivers/power/supply/smb347-charger.c @@ -127,7 +127,6 @@ * @regmap: pointer to driver regmap * @mains: power_supply instance for AC/DC power * @usb: power_supply instance for USB power - * @battery: power_supply instance for battery * @id: SMB charger ID * @mains_online: is AC/DC input connected * @usb_online: is USB input connected @@ -140,7 +139,6 @@ struct smb347_charger { struct regmap *regmap; struct power_supply *mains; struct power_supply *usb; - struct power_supply *battery; unsigned int id; bool mains_online; bool usb_online; @@ -743,7 +741,10 @@ static irqreturn_t smb347_interrupt(int irq, void *data) */ if (stat_c & STAT_C_CHARGER_ERROR) { dev_err(smb->dev, "charging stopped due to charger error\n"); - power_supply_changed(smb->battery); + if (smb->pdata->use_mains) + power_supply_changed(smb->mains); + if (smb->pdata->use_usb) + power_supply_changed(smb->usb); handled = true; } @@ -753,8 +754,12 @@ static irqreturn_t smb347_interrupt(int irq, void *data) * disabled by the hardware. */ if (irqstat_c & (IRQSTAT_C_TERMINATION_IRQ | IRQSTAT_C_TAPER_IRQ)) { - if (irqstat_c & IRQSTAT_C_TERMINATION_STAT) - power_supply_changed(smb->battery); + if (irqstat_c & IRQSTAT_C_TERMINATION_STAT) { + if (smb->pdata->use_mains) + power_supply_changed(smb->mains); + if (smb->pdata->use_usb) + power_supply_changed(smb->usb); + } dev_dbg(smb->dev, "going to HW maintenance mode\n"); handled = true; } @@ -768,7 +773,10 @@ static irqreturn_t smb347_interrupt(int irq, void *data) if (irqstat_d & IRQSTAT_D_CHARGE_TIMEOUT_STAT) dev_warn(smb->dev, "charging stopped due to timeout\n"); - power_supply_changed(smb->battery); + if (smb->pdata->use_mains) + power_supply_changed(smb->mains); + if (smb->pdata->use_usb) + power_supply_changed(smb->usb); handled = true; } @@ -936,95 +944,19 @@ static int get_const_charge_voltage(struct smb347_charger *smb) return intval; } -static int smb347_mains_get_property(struct power_supply *psy, - enum power_supply_property prop, - union power_supply_propval *val) -{ - struct smb347_charger *smb = power_supply_get_drvdata(psy); - int ret; - - switch (prop) { - case POWER_SUPPLY_PROP_ONLINE: - val->intval = smb->mains_online; - break; - - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: - ret = get_const_charge_voltage(smb); - if (ret < 0) - return ret; - else - val->intval = ret; - break; - - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: - ret = get_const_charge_current(smb); - if (ret < 0) - return ret; - else - val->intval = ret; - break; - - default: - return -EINVAL; - } - - return 0; -} - -static enum power_supply_property smb347_mains_properties[] = { - POWER_SUPPLY_PROP_ONLINE, - POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, - POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, -}; - -static int smb347_usb_get_property(struct power_supply *psy, - enum power_supply_property prop, - union power_supply_propval *val) -{ - struct smb347_charger *smb = power_supply_get_drvdata(psy); - int ret; - - switch (prop) { - case POWER_SUPPLY_PROP_ONLINE: - val->intval = smb->usb_online; - break; - - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: - ret = get_const_charge_voltage(smb); - if (ret < 0) - return ret; - else - val->intval = ret; - break; - - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: - ret = get_const_charge_current(smb); - if (ret < 0) - return ret; - else - val->intval = ret; - break; - - default: - return -EINVAL; - } - - return 0; -} - -static enum power_supply_property smb347_usb_properties[] = { - POWER_SUPPLY_PROP_ONLINE, - POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, - POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, -}; - -static int smb347_get_charging_status(struct smb347_charger *smb) +static int smb347_get_charging_status(struct smb347_charger *smb, + struct power_supply *psy) { int ret, status; unsigned int val; - if (!smb347_is_ps_online(smb)) - return POWER_SUPPLY_STATUS_DISCHARGING; + if (psy->desc->type == POWER_SUPPLY_TYPE_USB) { + if (!smb->usb_online) + return POWER_SUPPLY_STATUS_DISCHARGING; + } else { + if (!smb->mains_online) + return POWER_SUPPLY_STATUS_DISCHARGING; + } ret = regmap_read(smb->regmap, STAT_C, &val); if (ret < 0) @@ -1063,29 +995,29 @@ static int smb347_get_charging_status(struct smb347_charger *smb) return status; } -static int smb347_battery_get_property(struct power_supply *psy, - enum power_supply_property prop, - union power_supply_propval *val) +static int smb347_get_property(struct power_supply *psy, + enum power_supply_property prop, + union power_supply_propval *val) { struct smb347_charger *smb = power_supply_get_drvdata(psy); - const struct smb347_charger_platform_data *pdata = smb->pdata; int ret; - ret = smb347_update_ps_status(smb); - if (ret < 0) - return ret; - switch (prop) { case POWER_SUPPLY_PROP_STATUS: - ret = smb347_get_charging_status(smb); + ret = smb347_get_charging_status(smb, psy); if (ret < 0) return ret; val->intval = ret; break; case POWER_SUPPLY_PROP_CHARGE_TYPE: - if (!smb347_is_ps_online(smb)) - return -ENODATA; + if (psy->desc->type == POWER_SUPPLY_TYPE_USB) { + if (!smb->usb_online) + return -ENODATA; + } else { + if (!smb->mains_online) + return -ENODATA; + } /* * We handle trickle and pre-charging the same, and taper @@ -1104,24 +1036,25 @@ static int smb347_battery_get_property(struct power_supply *psy, } break; - case POWER_SUPPLY_PROP_TECHNOLOGY: - val->intval = pdata->battery_info.technology; - break; - - case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: - val->intval = pdata->battery_info.voltage_min_design; - break; - - case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: - val->intval = pdata->battery_info.voltage_max_design; + case POWER_SUPPLY_PROP_ONLINE: + if (psy->desc->type == POWER_SUPPLY_TYPE_USB) + val->intval = smb->usb_online; + else + val->intval = smb->mains_online; break; - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: - val->intval = pdata->battery_info.charge_full_design; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: + ret = get_const_charge_voltage(smb); + if (ret < 0) + return ret; + val->intval = ret; break; - case POWER_SUPPLY_PROP_MODEL_NAME: - val->strval = pdata->battery_info.name; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + ret = get_const_charge_current(smb); + if (ret < 0) + return ret; + val->intval = ret; break; default: @@ -1131,14 +1064,12 @@ static int smb347_battery_get_property(struct power_supply *psy, return 0; } -static enum power_supply_property smb347_battery_properties[] = { +static enum power_supply_property smb347_properties[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_CHARGE_TYPE, - POWER_SUPPLY_PROP_TECHNOLOGY, - POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, - POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, - POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, - POWER_SUPPLY_PROP_MODEL_NAME, + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, }; static bool smb347_volatile_reg(struct device *dev, unsigned int reg) @@ -1308,32 +1239,23 @@ static const struct regmap_config smb347_regmap = { static const struct power_supply_desc smb347_mains_desc = { .name = "smb347-mains", .type = POWER_SUPPLY_TYPE_MAINS, - .get_property = smb347_mains_get_property, - .properties = smb347_mains_properties, - .num_properties = ARRAY_SIZE(smb347_mains_properties), + .get_property = smb347_get_property, + .properties = smb347_properties, + .num_properties = ARRAY_SIZE(smb347_properties), }; static const struct power_supply_desc smb347_usb_desc = { .name = "smb347-usb", .type = POWER_SUPPLY_TYPE_USB, - .get_property = smb347_usb_get_property, - .properties = smb347_usb_properties, - .num_properties = ARRAY_SIZE(smb347_usb_properties), -}; - -static const struct power_supply_desc smb347_battery_desc = { - .name = "smb347-battery", - .type = POWER_SUPPLY_TYPE_BATTERY, - .get_property = smb347_battery_get_property, - .properties = smb347_battery_properties, - .num_properties = ARRAY_SIZE(smb347_battery_properties), + .get_property = smb347_get_property, + .properties = smb347_properties, + .num_properties = ARRAY_SIZE(smb347_properties), }; static int smb347_probe(struct i2c_client *client, const struct i2c_device_id *id) { - static char *battery[] = { "smb347-battery" }; - struct power_supply_config mains_usb_cfg = {}, battery_cfg = {}; + struct power_supply_config mains_usb_cfg = {}; struct device *dev = &client->dev; struct smb347_charger *smb; int ret; @@ -1359,8 +1281,6 @@ static int smb347_probe(struct i2c_client *client, if (IS_ERR(smb->regmap)) return PTR_ERR(smb->regmap); - mains_usb_cfg.supplied_to = battery; - mains_usb_cfg.num_supplicants = ARRAY_SIZE(battery); mains_usb_cfg.drv_data = smb; mains_usb_cfg.of_node = dev->of_node; if (smb->pdata->use_mains) { @@ -1377,12 +1297,6 @@ static int smb347_probe(struct i2c_client *client, return PTR_ERR(smb->usb); } - battery_cfg.drv_data = smb; - smb->battery = devm_power_supply_register(dev, &smb347_battery_desc, - &battery_cfg); - if (IS_ERR(smb->battery)) - return PTR_ERR(smb->battery); - ret = smb347_get_battery_info(smb); if (ret) return ret; From patchwork Sun Jun 7 14:41:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591609 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54A511752 for ; Sun, 7 Jun 2020 14:45:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 359072077D for ; Sun, 7 Jun 2020 14:45:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QpYBWalf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726815AbgFGOpe (ORCPT ); Sun, 7 Jun 2020 10:45:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbgFGOp2 (ORCPT ); Sun, 7 Jun 2020 10:45:28 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CB12C08C5C4; Sun, 7 Jun 2020 07:45:27 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id e125so8647179lfd.1; Sun, 07 Jun 2020 07:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dnm55LPV4I5FaW0ETeal110l8gkWvJ9UEI6lX4aXrUQ=; b=QpYBWalfdm5/U6Ur/lcg4N9+sdN7t7fH7BFQEBVN8wsfLfebeL921zAbP0LE9xLf4n cfMZ174f7Oe5QgNqy6gAR2ajugQYiPMq/nO1paaqkd8a1rrIaIsBNRj+Q+nffWEs/tO7 yXb1URlEtuasgwaUttHWeMSMtEDw7U9Ck/chAQ/OGDG1asfUsBUOvvUPZgrl9DvaTwAh PzFf4JgqiZvGLrgKXF6TngOiqV8Cb1Cz9fCzy6DvGjv6UjeEY7DPJ051dCuaVFjaHHR3 PtnAA7xC0C0sM6uDt/1DNLJHSRGo61ZGoTzqaA3SG9pD17E4VXS5MqsGF+8p1fkF8TPK 58Pw== 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=Dnm55LPV4I5FaW0ETeal110l8gkWvJ9UEI6lX4aXrUQ=; b=nDBwiZyWCffl7ebe/2FOFClBc9u7RumNZf1caTofn4/3b+uQg2R0u7UO8jmObDL/B8 ZYxuavcHOZF/juBzh4LpjdLy8AKm+/8mu9JXzn1H5NlRhVkGZKZbYBla5CHCOWRmqpq5 QiL8c8i/AGwIIRMws+heeWsBJGaX3XQhc6DDzVg8RuQDYppC6vL7btyxmA9Jug7h+X7v HeVhpH6T80OmlTboBYShvviz5NnJEGtg+37vu9lNsfpfYy31AFQWQykpfufZTKGQ+5kH gymm5E2clTcNR0iFaOKxyJ55P80fSX90GooeymqXo6z+dp1dsQ0ZwHfhHYHSB2ufgmBq lPxw== X-Gm-Message-State: AOAM53187iGyZHrbIUuh/mTt9cMfAFAsht4NAyu+vK0bXkPdBHj0Pprn /4pEJUrYmpGPdM2/DuvvTtw= X-Google-Smtp-Source: ABdhPJxqCGXwRdxWgmMPXBJqbVQoqQWNpsVdnmWACplaY39+Pj63+V4566bcBdpp1zweqrUMSos6Gg== X-Received: by 2002:a19:2250:: with SMTP id i77mr10392557lfi.133.1591541125560; Sun, 07 Jun 2020 07:45:25 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:25 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 8/9] power: supply: smb347-charger: Replace mutex with IRQ disable/enable Date: Sun, 7 Jun 2020 17:41:12 +0300 Message-Id: <20200607144113.10202-9-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's simply disable/enable IRQ rather than use a mutex that protects from racing with the interrupt handler. The result of this patch is that it's a bit easier now to follow the driver's code. Tested-by: David Heidelberg Signed-off-by: Dmitry Osipenko --- drivers/power/supply/smb347-charger.c | 38 ++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c index 335b6ee494e4..ec68ab2bce27 100644 --- a/drivers/power/supply/smb347-charger.c +++ b/drivers/power/supply/smb347-charger.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -122,7 +121,6 @@ /** * struct smb347_charger - smb347 charger instance - * @lock: protects concurrent access to online variables * @dev: pointer to device * @regmap: pointer to driver regmap * @mains: power_supply instance for AC/DC power @@ -134,7 +132,6 @@ * @pdata: pointer to platform data */ struct smb347_charger { - struct mutex lock; struct device *dev; struct regmap *regmap; struct power_supply *mains; @@ -243,11 +240,9 @@ static int smb347_update_ps_status(struct smb347_charger *smb) if (smb->pdata->use_usb) usb = !(val & IRQSTAT_E_USBIN_UV_STAT); - mutex_lock(&smb->lock); ret = smb->mains_online != dc || smb->usb_online != usb; smb->mains_online = dc; smb->usb_online = usb; - mutex_unlock(&smb->lock); return ret; } @@ -263,13 +258,7 @@ static int smb347_update_ps_status(struct smb347_charger *smb) */ static bool smb347_is_ps_online(struct smb347_charger *smb) { - bool ret; - - mutex_lock(&smb->lock); - ret = smb->usb_online || smb->mains_online; - mutex_unlock(&smb->lock); - - return ret; + return smb->usb_online || smb->mains_online; } /** @@ -303,14 +292,13 @@ static int smb347_charging_set(struct smb347_charger *smb, bool enable) return 0; } - mutex_lock(&smb->lock); if (smb->charging_enabled != enable) { ret = regmap_update_bits(smb->regmap, CMD_A, CMD_A_CHG_ENABLED, enable ? CMD_A_CHG_ENABLED : 0); if (!ret) smb->charging_enabled = enable; } - mutex_unlock(&smb->lock); + return ret; } @@ -995,9 +983,9 @@ static int smb347_get_charging_status(struct smb347_charger *smb, return status; } -static int smb347_get_property(struct power_supply *psy, - enum power_supply_property prop, - union power_supply_propval *val) +static int smb347_get_property_locked(struct power_supply *psy, + enum power_supply_property prop, + union power_supply_propval *val) { struct smb347_charger *smb = power_supply_get_drvdata(psy); int ret; @@ -1064,6 +1052,21 @@ static int smb347_get_property(struct power_supply *psy, return 0; } +static int smb347_get_property(struct power_supply *psy, + enum power_supply_property prop, + union power_supply_propval *val) +{ + struct smb347_charger *smb = power_supply_get_drvdata(psy); + struct i2c_client *client = to_i2c_client(smb->dev); + int ret; + + disable_irq(client->irq); + ret = smb347_get_property_locked(psy, prop, val); + enable_irq(client->irq); + + return ret; +} + static enum power_supply_property smb347_properties[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_CHARGE_TYPE, @@ -1273,7 +1276,6 @@ static int smb347_probe(struct i2c_client *client, i2c_set_clientdata(client, smb); - mutex_init(&smb->lock); smb->dev = &client->dev; smb->id = id->driver_data; From patchwork Sun Jun 7 14:41:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11591601 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6C6801752 for ; Sun, 7 Jun 2020 14:45:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45E8C206A4 for ; Sun, 7 Jun 2020 14:45:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="F2mKAwuz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726784AbgFGOpd (ORCPT ); Sun, 7 Jun 2020 10:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbgFGOp2 (ORCPT ); Sun, 7 Jun 2020 10:45:28 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1543FC08C5C3; Sun, 7 Jun 2020 07:45:28 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id a9so13751195ljn.6; Sun, 07 Jun 2020 07:45:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lfL/r1htdP9PiIBaZcQxVZ6voLKiwdEQ8IbCOeWza6A=; b=F2mKAwuzjxAgedp/+YsmHWSd/69jzNNmCqJbuVTXk5OZFvOBQ2uxLjW/SdgzELRfaH 8onq9IUyf6hOkjsCWURnrDfC/ltXl8Qv3iwoa98AN3eSueCbgWOGhmA4X4p0tN478dXX U+m8CwOZmLhPmjzwqA17KZn+h1whAaB+5zOYIV4UM7y9zLbbf45naMpbpIEkq5KD10xQ 0TcMRj88h/2OFul3mbMqqcRXrBR17F7YnqUGg17E79Q+y3rEjcP5vFyQPqvvwPFSVun/ 3o1oexIGGbz0YElqBWWLvov52XuwsRFuEvKToCOAgSyufte5awTv2jkVTW19oUc9UMCQ J0iw== 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=lfL/r1htdP9PiIBaZcQxVZ6voLKiwdEQ8IbCOeWza6A=; b=b4EAnJgnYuta7t/Lfz6303qPuQX/orkfYHBNLa4OfOE770zQJHh5img4+TGENTARIQ TnymuUmSvpdetfv8itFk+YWhD7KDHWLV/8qq5mPeWhAYdI9MRcl3+MZB548SN4WclcE2 /9xaKY85g4JnFLpNTzuGExxdWuUh/d8MAXaVx4chaqWWckrSfFn7BcoCQb4nj4AMXcsJ 5cxx53ejD8WdntN0k+f0QIOsuRxQQVnatzfpdZolZuhe1fhIBEJihIB4Werpy4F10vQL jEKyiDKl6mG8QsoxNepWjSNNNR1dwDQ/QE/BfDJ+r8p6ZNrADHDQfUJMk7LrLGcaxjNF 80qw== X-Gm-Message-State: AOAM5322i3uXs6GYOnwPfKxXr55ND7oQq80JOWHZ+vs4w4cI6NQzC715 zTDNZBsW9+1yAXsxpvUIKzE= X-Google-Smtp-Source: ABdhPJw2hnkRZpEz3xvP42UA6MOStGsDyxqyIF/rxMxPa659kz9A/8+dqsknHvl1DT4uiVe2y6zzeA== X-Received: by 2002:a05:651c:233:: with SMTP id z19mr9481431ljn.428.1591541126619; Sun, 07 Jun 2020 07:45:26 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id g24sm4059724lfh.90.2020.06.07.07.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 07:45:26 -0700 (PDT) From: Dmitry Osipenko To: Sebastian Reichel , Rob Herring , Andy Gross , Bjorn Andersson , David Heidelberg Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Jonghwa Lee , John Stultz , Vinay Simha BN Subject: [PATCH v2 9/9] ARM: dts: qcom: apq8064-nexus7: Add SMB345 charger node Date: Sun, 7 Jun 2020 17:41:13 +0300 Message-Id: <20200607144113.10202-10-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200607144113.10202-1-digetx@gmail.com> References: <20200607144113.10202-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: David Heidelberg Add SMB345 charger node to Nexus 7 2013 DTS. Proper charger configuration prevents battery from overcharging. Original author: Vinay Simha BN Signed-off-by: David Heidelberg --- .../boot/dts/qcom-apq8064-asus-nexus7-flo.dts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm/boot/dts/qcom-apq8064-asus-nexus7-flo.dts b/arch/arm/boot/dts/qcom-apq8064-asus-nexus7-flo.dts index a701d4bac320..7a7784206dd8 100644 --- a/arch/arm/boot/dts/qcom-apq8064-asus-nexus7-flo.dts +++ b/arch/arm/boot/dts/qcom-apq8064-asus-nexus7-flo.dts @@ -3,6 +3,7 @@ #include #include #include +#include / { model = "Asus Nexus7(flo)"; compatible = "asus,nexus7-flo", "qcom,apq8064"; @@ -56,6 +57,11 @@ volume_down { }; }; + battery_cell: battery-cell { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <1800000>; + }; + soc { rpm@108000 { regulators { @@ -296,8 +302,25 @@ eeprom@52 { bq27541@55 { compatible = "ti,bq27541"; reg = <0x55>; + power-supplies = <&power_supply>; + monitored-battery = <&battery_cell>; }; + power_supply: charger@6a { + compatible = "summit,smb345"; + reg = <0x6a>; + + interrupt-parent = <&tlmm_pinmux>; + interrupts = <23 IRQ_TYPE_EDGE_BOTH>; + + summit,chip-temperature-threshold-celsius = <110>; + summit,usb-current-limit-microamp = <500000>; + summit,enable-charge-control = ; + summit,enable-usb-charging; + summit,enable-otg-charging; + + monitored-battery = <&battery_cell>; + }; }; };