From patchwork Thu Oct 26 05:53:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 738400 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7339EC25B48 for ; Thu, 26 Oct 2023 05:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233277AbjJZFyM (ORCPT ); Thu, 26 Oct 2023 01:54:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232431AbjJZFyL (ORCPT ); Thu, 26 Oct 2023 01:54:11 -0400 Received: from box.trvn.ru (box.trvn.ru [194.87.146.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E73E115; Wed, 25 Oct 2023 22:54:09 -0700 (PDT) Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id A5F3F408DC; Thu, 26 Oct 2023 10:54:05 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1698299646; bh=cGxQVt+NVbaQIsSjfqmJUKIMf/PR6FSgo/FLAfIdsik=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cMRIFO8iR4u7ni/wvP438REG8eTCIjhISo4W+J8afGG095biNsazGkd3IxX/2OpzP UgqXL2BK6uYzdSUyAMf99oLS2lDCOPDAJdZSz6LJOQd7AQ9sSx9nT9fA4uhG30xgFy r+PZnZO7jXke7YAq9uyoRKYxpHCncdBVSdHtj33SS7/+a50+qoBg9x04aVJdf04vN/ J4qc8+LKyOeejHBAv5iuh6+jA3jfyUZAELDzqtPFZYQZlj0c3eSTO2YHd6cDmP8384 DOkpqFTWxlIGXgRKjjITwuYV2b8CDjovsncWrG4ybgr+fCWkzSKnCbIrqJEfPGMdqj q2yN+n9Yf/CWA== From: Nikita Travkin Date: Thu, 26 Oct 2023 10:53:44 +0500 Subject: [PATCH v3 1/2] arm64: dts: qcom: pm8916: Add BMS and charger MIME-Version: 1.0 Message-Id: <20231026-pm8916-dtsi-bms-lbc-v3-1-fad1ff22306e@trvn.ru> References: <20231026-pm8916-dtsi-bms-lbc-v3-0-fad1ff22306e@trvn.ru> In-Reply-To: <20231026-pm8916-dtsi-bms-lbc-v3-0-fad1ff22306e@trvn.ru> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: ~postmarketos/upstreaming@lists.sr.ht, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nikita Travkin X-Developer-Signature: v=1; a=openpgp-sha256; l=2360; i=nikita@trvn.ru; h=from:subject:message-id; bh=cGxQVt+NVbaQIsSjfqmJUKIMf/PR6FSgo/FLAfIdsik=; b=owEBbQKS/ZANAwAIAUMc7O4oGb91AcsmYgBlOf786mSA7Fd6gRwKZ9lU+BF+J3LEVXlUCvRPl GQO5qfR/H+JAjMEAAEIAB0WIQTAhK9UUj+qg34uxUdDHOzuKBm/dQUCZTn+/AAKCRBDHOzuKBm/ dVGoD/9bDMivDCFrNYXKGHF181bxTzkVoolGqOSJbmR1N8eXHP/wD0uj69lmVNV4CxxJAgLhFaI D//aPiG20VqZ7pWzkvHxg1TfWOL5ICw4XDt2SigFjUluTPHTwisUjk2aNbyk6TnSqukvmwwN+Nn QUWYpRSzDddytCbqP1yBPSRsbrH5Gor/hQr0hD5BHcYk6h75YSu92cHjBypFAoG68rXo9gPzvUy 8gBAlWLWq+eZIms9FOiGEBnWU7s3HX7lCohLvWuncxIb5aD6pFyEnLKHYbqW7dP5W9Zl3b9sfi5 HSEo7q3oiQbIkBOt55q8+JF7al3Bs0yilZM6zfeyqXc5PODWFL161SK1onuA0bNs7ZTCCPnXM7I BGh3iP62DLy8zdK5n9eEEksu7sHgyetk1kTMP1BwazASDvgfuQubAO1RRYltdc6zKEevoiga7/a ytqebVIVhPQVATLq/v74KZCrfbquDpY9HkQFrBfg1Ww4QNcM8e+dq9J/T7LQ1k0FaJEdO7qbCft zleBtYSy7qKGJMxANOceaBake48Vvkv62DxQ8rEg2uvWBZ5lboMV75CClfQiKRZgNgZdQ6uGg6D i3nyFITPhJbK+R6UZhIb9qjwVtLP7B+9k+iOUwyxKcUVRZ4wujDhfskvt6WdWdXnC1cKypwNJmW DtO998XZeDJDA/g== X-Developer-Key: i=nikita@trvn.ru; a=openpgp; fpr=C084AF54523FAA837E2EC547431CECEE2819BF75 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org pm8916 contains some hardware blocks for battery powered devices: - VM-BMS: Battery voltage monitoring block. - LBC: Linear battery charger. Add them to the pmic dtsi so the devices that make use of those blocks can enable them. Signed-off-by: Nikita Travkin --- arch/arm64/boot/dts/qcom/pm8916.dtsi | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qcom/pm8916.dtsi index f4de86787743..4b2e8fb47d2d 100644 --- a/arch/arm64/boot/dts/qcom/pm8916.dtsi +++ b/arch/arm64/boot/dts/qcom/pm8916.dtsi @@ -41,6 +41,35 @@ watchdog { }; }; + pm8916_charger: charger@1000 { + compatible = "qcom,pm8916-lbc"; + reg = <0x1000>, <0x1200>, <0x1300>, <0x1600>; + reg-names = "chgr", "bat_if", "usb", "misc"; + + interrupts = <0x0 0x10 0 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x10 5 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x10 6 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x10 7 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x12 0 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x12 1 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x13 0 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x13 1 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x13 2 IRQ_TYPE_EDGE_BOTH>, + <0x0 0x13 4 IRQ_TYPE_EDGE_BOTH>; + interrupt-names = "vbat_det", + "fast_chg", + "chg_fail", + "chg_done", + "bat_pres", + "temp_ok", + "coarse_det", + "usb_vbus", + "chg_gone", + "overtemp"; + + status = "disabled"; + }; + pm8916_usbin: usb-detect@1300 { compatible = "qcom,pm8941-misc"; reg = <0x1300>; @@ -91,6 +120,25 @@ channel@f { }; }; + pm8916_bms: battery@4000 { + compatible = "qcom,pm8916-bms-vm"; + reg = <0x4000>; + interrupts = <0x0 0x40 0 IRQ_TYPE_EDGE_RISING>, + <0x0 0x40 1 IRQ_TYPE_EDGE_RISING>, + <0x0 0x40 2 IRQ_TYPE_EDGE_RISING>, + <0x0 0x40 3 IRQ_TYPE_EDGE_RISING>, + <0x0 0x40 4 IRQ_TYPE_EDGE_RISING>, + <0x0 0x40 5 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "cv_leave", + "cv_enter", + "ocv_good", + "ocv_thr", + "fifo", + "state_chg"; + + status = "disabled"; + }; + rtc@6000 { compatible = "qcom,pm8941-rtc"; reg = <0x6000>, <0x6100>; From patchwork Thu Oct 26 05:53:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Travkin X-Patchwork-Id: 738760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6670C25B6D for ; Thu, 26 Oct 2023 05:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343915AbjJZFyN (ORCPT ); Thu, 26 Oct 2023 01:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233203AbjJZFyM (ORCPT ); Thu, 26 Oct 2023 01:54:12 -0400 Received: from box.trvn.ru (box.trvn.ru [194.87.146.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A808184; Wed, 25 Oct 2023 22:54:10 -0700 (PDT) Received: from authenticated-user (box.trvn.ru [194.87.146.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.trvn.ru (Postfix) with ESMTPSA id 32A5943024; Thu, 26 Oct 2023 10:54:06 +0500 (+05) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=trvn.ru; s=mail; t=1698299646; bh=m2R8nwNx74fi7ZyA9GViMO/2RFQPpiuD8601klTAY8Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uA1oWc/i6nHNB1eoaqz/5EtSoqhREpX4vYPINveJWPSxDrgsKvPtfWXb28ZDAYUCY jKrX+s0JK2wF8xrnxGs3p5KfKbVmMxkKFdYuox+6rgSjE25tKuJ8GOJf3Ft1O2IBmm oPTB3jKPRKgPG9WLI9AYmNobwTjVPfYL7yHzOxEF4cBKR+My1ZtmHw0RCZ1cePPeaf 82SKsG7wTimH6yY1IEkyVDC4VVxG7S0wq94QutIRPJM14Ee/NGUU3cHrJKMKDLLrpj 7DtMldlY+TXZyZMGzs1AT52vPHZOgBuz9sYGcuCH5rhtNuKGZTCnX5ETp7YOclNL2J 8Fa1Q/MkSa8JQ== From: Nikita Travkin Date: Thu, 26 Oct 2023 10:53:45 +0500 Subject: [PATCH v3 2/2] arm64: dts: qcom: msm8916-longcheer-l8150: Add battery and charger MIME-Version: 1.0 Message-Id: <20231026-pm8916-dtsi-bms-lbc-v3-2-fad1ff22306e@trvn.ru> References: <20231026-pm8916-dtsi-bms-lbc-v3-0-fad1ff22306e@trvn.ru> In-Reply-To: <20231026-pm8916-dtsi-bms-lbc-v3-0-fad1ff22306e@trvn.ru> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: ~postmarketos/upstreaming@lists.sr.ht, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nikita Travkin X-Developer-Signature: v=1; a=openpgp-sha256; l=2477; i=nikita@trvn.ru; h=from:subject:message-id; bh=m2R8nwNx74fi7ZyA9GViMO/2RFQPpiuD8601klTAY8Y=; b=owEBbQKS/ZANAwAIAUMc7O4oGb91AcsmYgBlOf78t9B+W4YKSvV7oqzbkAguV9xEVdI3quokP D9+7iU1IMaJAjMEAAEIAB0WIQTAhK9UUj+qg34uxUdDHOzuKBm/dQUCZTn+/AAKCRBDHOzuKBm/ dYJqD/9Ch+W0ZvItovOMaQrb2cwtSEVbcTdGK789rKwTb1y/Zsa1mr9o7b4U9JvS5mWJMrovhHd R6w8RtZm2lcVbVfhg0LAPjZXmwXz1RnuM5QI0wfvbKAvuLRqNZ+kZYXzJXXBK7JoEES08bN/8oO dHTEff4cK+dTW1rJ4c9d0h/43jLBNW0Zun/gzGARzpTnPLMbFaj8Ml8hIFbf0DO3PCXgD87COD8 9fDz2p4/qu98Ez2cKKIPmhTOtVC7brLPEmNpPMAZw1AsdrqGy5HI5uZVlSLX7gZshDy79dSXBJa EcUXd8d/8bMLpIgBooRwS6eDHesKkJxSF5HnHAOM5T8ikUMB2tXOPAxZwpYcAwdQn7mrGTEL/nz Lem83BVLSknGbOhd9ZyiiFh84hhaRfvmA/1Ijj21xEHZe3ilCsJWwhJpcnT5ZXAOocxjQ07+TD3 jIRQ3e9lr8jy6k9oh/Dtet7/0l0VIwkhPQ0eyCimQ2o6rrMSrC6IGgfvhW9czjRwj0wNfDSmZ2r pWwWZ0ymK9KywbXP/hTMCANpDK2K4AIlcgWbasQYQVFZ4569t//Mz8bDvEdiHcWCJgr3erKdNUE WBiEnDQu4gYckusPB7+/R/A/kVYG+uI/Mb/s/3TT6htrwr+/VmpJDzwq20jI/Kwhgmpo5LIFygD JbfGh4D7qDdtkVw== X-Developer-Key: i=nikita@trvn.ru; a=openpgp; fpr=C084AF54523FAA837E2EC547431CECEE2819BF75 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Longcheer L8150 doesn't have any dedicated fuel-gauge or charger, instead making use of the pmic hardware blocks for those purposes. Add pm8916 bms and charger, as well as the battery cell description that those blocks rely on. Signed-off-by: Nikita Travkin Reviewed-by: Konrad Dybcio --- .../boot/dts/qcom/msm8916-longcheer-l8150.dts | 43 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/msm8916-longcheer-l8150.dts b/arch/arm64/boot/dts/qcom/msm8916-longcheer-l8150.dts index 37fa55166918..8e4c77003109 100644 --- a/arch/arm64/boot/dts/qcom/msm8916-longcheer-l8150.dts +++ b/arch/arm64/boot/dts/qcom/msm8916-longcheer-l8150.dts @@ -49,6 +49,25 @@ mpss_mem: mpss@8e800000 { }; }; + battery: battery { + compatible = "simple-battery"; + voltage-min-design-microvolt = <3400000>; + voltage-max-design-microvolt = <4350000>; + energy-full-design-microwatt-hours = <9500000>; + charge-full-design-microamp-hours = <2500000>; + + ocv-capacity-celsius = <25>; + ocv-capacity-table-0 = <4330000 100>, <4265000 95>, + <4208000 90>, <4153000 85>, <4100000 80>, <4049000 75>, + <4001000 70>, <3962000 65>, <3919000 60>, <3872000 55>, + <3839000 50>, <3817000 45>, <3798000 40>, <3783000 35>, + <3767000 30>, <3747000 25>, <3729000 20>, <3709000 16>, + <3688000 13>, <3681000 11>, <3680000 10>, <3679000 9>, + <3677000 8>, <3674000 7>, <3666000 6>, <3641000 5>, + <3597000 4>, <3537000 3>, <3457000 2>, <3336000 1>, + <3000000 0>; + }; + gpio-keys { compatible = "gpio-keys"; @@ -236,6 +255,22 @@ &blsp_uart2 { status = "okay"; }; +&pm8916_bms { + status = "okay"; + + monitored-battery = <&battery>; + power-supplies = <&pm8916_charger>; +}; + +&pm8916_charger { + status = "okay"; + + monitored-battery = <&battery>; + + qcom,fast-charge-safe-current = <900000>; + qcom,fast-charge-safe-voltage = <4300000>; +}; + &pm8916_codec { qcom,micbias-lvl = <2800>; qcom,mbhc-vthreshold-low = <75 150 237 450 500>; @@ -255,10 +290,6 @@ pm8916_l17: l17 { }; }; -&pm8916_usbin { - status = "okay"; -}; - &pm8916_vib { status = "okay"; }; @@ -282,11 +313,11 @@ &sound { &usb { status = "okay"; dr_mode = "peripheral"; - extcon = <&pm8916_usbin>; + extcon = <&pm8916_charger>; }; &usb_hs_phy { - extcon = <&pm8916_usbin>; + extcon = <&pm8916_charger>; }; &venus {