From patchwork Mon Jul 15 12:55:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733494 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6038C3DA59 for ; Mon, 15 Jul 2024 12:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Yy4EKK2MMNMVFHHJLnbyF0PIFup9QUbwgUbkF8k93AY=; b=R9zGtIwiiQYmHzC4S9fsPkeOIj 4yIu3WHMPmS9SeAV9ISizWDMJclijbptLsjayRlL1fG0+uqQuOig3Hj37qikcGz3uskvKlsJ2BCl3 a00NJPuJRGp0jwMpTX0EyDNuGOdoNN5njJM8R8OY/gkbOlKoyAFoq9kRu8c6ET63wbfN4TBF+ig3j 5yXXtDi1fRKkJRVPjTr+PJbWPgOb9C5MYlOnHB2IiuA9G2ktEKZ7I225/elfwmunGpb19b1Rb0628 9uzKAfL2l8zo6/EbA+9eXaddwAq2FhahGTiIXy+NEEOUgHaNMTzCJvQ9AJHLhbI4GgvZeOYVeWz1M VPvKE8+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLF7-000000076dn-16Fv; Mon, 15 Jul 2024 12:55:49 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEZ-000000076RC-0mwR for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:16 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2eebc76119aso47977971fa.2 for ; Mon, 15 Jul 2024 05:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048113; x=1721652913; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Yy4EKK2MMNMVFHHJLnbyF0PIFup9QUbwgUbkF8k93AY=; b=hbsmZwZJGIltQnfw5FNbiY3RgAXx2fbkiZ2YJ7gnt06zA2FrzpCTj0NzdryPIOJ6Mx KC2i9z+KrPd6+g9870PzNqFnBygUJjBgmduC60fINsVAR5lcyJYvYCZpZtqVcxjhZFB5 2O0QIwv7C4noxomi1jcl3rubf61A1eV9Fka+3XIcKCs8E2kvGO6lcdUH+VJKEv2zmGag A6wArtr77bGb5jXchbI6YuCHT1Jk1FezMUb+bkTm00IV2NVzV2xs7V2K24+ds8djd4Qq WmEDN+DukB71O/MtAvfXfladDM55n3QyP0Jop1IMaa7ADGQsGRwwzkUG4D7qJoCTIC4V FmkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048113; x=1721652913; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yy4EKK2MMNMVFHHJLnbyF0PIFup9QUbwgUbkF8k93AY=; b=ekNDDJj0VCynUykdO2EwSSam8rxvUyBSoKwbhz8K1CNWZFUX1/9cB/j75KGI6jg5fi q6Tdwra52U6zMaTeKHu1ByXNl/ncgDlAbiFeqOW1h0Ap6QoRtcKjGNsa8ihyVf5uHaMX YZQc6nqy4f0TPHTy187ebuItkESdbeCF08dQ1jd0Cij5QlBiBaRMyUpCB697uuiJhdF4 S4NnNbSopwiipd4fQ4kcQasGWT8kAOGcW/VAc2uzuaOp4r2gimglxHc+58qP4yf2oYgY DQYmwZwi18iGmdOhslbFx23b2ev+nAa7+mwvZ8l/nXkCz7ATQt39hiXPVoyMSM7JZ/j1 FWaw== X-Forwarded-Encrypted: i=1; AJvYcCUmXmvi9IN8MruraAIHRhU5dALncWCmsxnxhnR7rKhu98sTju0Zq5vdbDLIB3jodbKc64KVnq1dqAkpFCDoDDODKZ/I49sTpxH5VG9xX0zdgLaX6eY= X-Gm-Message-State: AOJu0YybAj17VtFyhkVzgWd+YDdNSOxuRT2StL5sE/MbDPKwAO8M+lxY AthsZIu5juy7vVsJ147npsu7Ey34n1G1Q50XZE3A03kyCI96c31A X-Google-Smtp-Source: AGHT+IEZ/wluphxBn2a6YcKsiQTSr9JzIe+b2teGX2aiGb1mLWNivX+caxnotyDZOe8tkjXU+WzrGQ== X-Received: by 2002:a2e:9d06:0:b0:2ec:4acf:97dc with SMTP id 38308e7fff4ca-2eeb30bc9eemr126107771fa.11.1721048112386; Mon, 15 Jul 2024 05:55:12 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:12 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:03 +0200 Subject: [PATCH v2 1/9] dt-bindings: power: supply: max77693: Add monitored-battery property MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-1-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1452; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=Sep2YFazyIuwJAAWmtMhPpLW3/gwTfw1XNyWXLhamO8=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwpJjCLdx8HCWez4ml9uY6NIVfmATTP1DiqK sIjVobrj/2JAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aA+OD/wKoQpFNAsUIXuHULAyeJawNlA3bvCuREiYKFG7ppjjBd3+Nx6dCwCUfb1o75KDWzlZ2zp v/r8kICqtqtcoyqKffJfMsaImvev6dq8Bk2hebpwa86QvRiEs+ssMw1eViuJXLmP4nw6r7lku4f q6mbFW5qHLvpxI4CBgeuwY28y9y6NR/OgwcGsTx9CRGNwo/Vf5WGQG5TASW7DskE11ftwWVprv5 6PIWKIg4EYWWwVqTsBPCc9bzk46dYMMO4sk0Q8fvkB4KUGGzI+0HMlj4bSDQdn/ZF2rPpJoow2v ba75TL3UVonJA/gCRZz14y+zdIc3Hpq0YObqOW7xDCa+GfPdc1QNyxd1p8+iyGhTPRk3Ix8kMWz lbH55+nzJ8jM8MGx//51mew6uWa8wzcA4GNA4NQP0pxoptfvcvu6NEBwqlJf/tpIp+eOc4G9OVV eqggCPYcLQuhrX+UuewKbxsigbH49om2D+Y3h+i3YZgZ8VokbmhdStE4aqddEcv9MVAmteM8DWq 6X/KaCOtvopY9MCw57bXHgyitnxbi6kgy9gXa9S/KThHcEXxfJBtXw9l7+XW0UiS+D4czK3M5us 86XTizBWbtRm0MfkNC0eyyx9QB5umLav+YaZLWYhojB6R6a2hmaYpK4AYdjwsmKyGL+8iO2mqS3 PFg7DCJfY4Xde5Q== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055515_266485_4F0AF2AF X-CRM114-Status: GOOD ( 10.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the monitored-battery property, so that its constant charge current property can be used to specify the current limit to use for fast charge (when plugged into a wall charger). Signed-off-by: Artur Weber Reviewed-by: Krzysztof Kozlowski --- Changes in v2: - Switched to monitored-battery property from separate fast charge current property --- .../devicetree/bindings/power/supply/maxim,max77693.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml index f5fd53debbc8..2f4437dafdc0 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml @@ -16,10 +16,19 @@ description: | See also Documentation/devicetree/bindings/mfd/maxim,max77693.yaml for additional information and example. +allOf: + - $ref: power-supply.yaml# + properties: compatible: const: maxim,max77693-charger + monitored-battery: + description: + Phandle to "simple-battery"-compatible battery node. + The constant-charge-current-max-microamps property of the battery + node is used to specify the fast charge current. + maxim,constant-microvolt: description: | Battery constant voltage in uV. The charger will operate in fast From patchwork Mon Jul 15 12:55:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733495 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA196C3DA4B for ; Mon, 15 Jul 2024 12:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=eGuQaKvthqNvOI+/BVZ1qQqCmj4BP1waMYjE3zo8K2s=; b=dhV77MOYhJeQMWyjeyAhNwEk2+ c8BpHU9eUxwMV/OToVw3bJHN8FEmVfdyfn95iTDHsuS148thuiXvM8YQ21BT5qiXtmWyavfYl+6fl tbOu9erZYft3K+IaWkh18I9NIhotIA+eWKI8YIcUfO1LfgijwgynYwUThecmJRwUtRn4zzSzWP6j+ kQ7/lVrO06QLC2ZC/NJP1BbVOP8CTvyj9BOyf20OuYl9qrKXZczC+OeTZQyhlDTcdguNIILRVErb5 oKLIwMBImsarBK2TuZSjjsflSNKmOJxLuJc6LZiPxiX92lzrTZL4FcGba5B1kmIfLk9C2qbCquw+O ho4x6yag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLFN-000000076jx-2V2C; Mon, 15 Jul 2024 12:56:05 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEa-000000076RO-1ZpI for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:17 +0000 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-58d24201934so220790a12.0 for ; Mon, 15 Jul 2024 05:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048114; x=1721652914; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eGuQaKvthqNvOI+/BVZ1qQqCmj4BP1waMYjE3zo8K2s=; b=Mbm7nqzpTfj4bR9gimv7lL1rpKRqpzbc5TLHxy2M+xJwClVdekOTUfx1sgj5V/Aixt ADvv0gGUkq0aq8QaBhRnATZkTO4EUBthtGMZ0uJorTgQSXx35oZnKfSCjlWQF4H866Rm YzoVIXV8OaURvGzhVgtB/1j7UJFU552mJ9a4n1A5vwEKizUUNejUUrDCSYYkW0DT0DBO 91pNusG4w0N0gOBn1+mhjF2Skzeh2pp1Px3akok11sm6MXicZ7K7z5zm1CJzLBS5hEN7 4Vdy6bWMTFUASmZheAgJZ+rR8FgdSuozdMjP57+WPm5MkeiRibAlHVhUfRGH97cgrCX4 0YaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048114; x=1721652914; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eGuQaKvthqNvOI+/BVZ1qQqCmj4BP1waMYjE3zo8K2s=; b=FiefCtfRKKFM1v3xEXsb1BPvBxWMWzctHbnAQALLl9kyfPcHZ7B3hCDH5DwrrCFeEd GWn7v1vxUZ/r/jSnQZAN/EqNo9fUi/5QnAz77OLaW4qMGCQXV7VbXjzQjG2T4VM0NVfX XKAjSbEbLH51JEhbt247VRnnVJpYmcPAafok9lzdwsJKufUgXVn/gBo5EU0upSto4Vmr VMq0eU6S0rdeUBegyI9vD0hjLdjL7+03EaG2SmgM/NViRmvHn/RLUCJAF7dxd8lIQz0p oDa+gxXwzlGRkLS8qqLnklVKyK+yFkpJ5KtceczQjldlRpOkChkJdwqYrq3z9B9ZzvhT m6RA== X-Forwarded-Encrypted: i=1; AJvYcCUJK93WzHHZe6GpZL95Yz7RoWsiF+rVI1JwDFABIYm1XpAWgoClxD3y7IiK85rgKtVZkFIMReZc4QXUEzMqjC8sxuvXH6Gnfq5/lemILczvhV0tB9E= X-Gm-Message-State: AOJu0YwZlQhpE+mTM7xmhKbOxMCjbXspHNNxvmHc1OOjSosx/P5ToYUt 3/WzJuiIdUX5XBjwxUOQGzvdf4OXckeFnWSDi+Cn8OBjtcjgzrlU X-Google-Smtp-Source: AGHT+IF13yLztEYtO3ThN8vyYl93/m4din/5EPKTD6UXsAFnvdhgrZPhA9eeq1XL21Cu8GDzVWSlJw== X-Received: by 2002:a50:ccd1:0:b0:57d:3df:ba2d with SMTP id 4fb4d7f45d1cf-59a71454331mr6318170a12.2.1721048114285; Mon, 15 Jul 2024 05:55:14 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:13 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:04 +0200 Subject: [PATCH v2 2/9] dt-bindings: power: supply: max77693: Add maxim,usb-connector property MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-2-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1063; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=UswaxFgNYGhQxO8i3hDmSgr/CcfH6MewnSR60PWmTJA=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwp6OhrSlHrko5KiBUj7b51bE1zw8tFe6qng QWh1+Lw2OKJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aHigEACEj26TJHPcn6IEXY48/4k+ESHRoKR+3480pvLlXXKJQGt16YcfuChAKdYqUYtGo9Vr306 eklbsSUah/1GgSqBzCRD3UV1bFMyKMPA1k1KJIbz7/WHXah5wjo2g5ScP4+kt3mixKtd2N6DAnm 4R1GR5nrZ19SYOzjax9M2FpZmPf3Ql+H2qx+q3GuCnJqC1eTE4ewnYvFWKKsW5qpsvgUiG5GhAE KH6aCTz+YuIeMx1L4TMtveMPW51JEFTJDuwP1nNb68v2vV0t0FSWMHGVLRQRg+b64kXog1hm9fg g3fW3PF05hf6RaAz0kKERzD1F2VC0/lWhPpXvk36oHacyXxljXQl6dRZ/7pWRTc6ppJQW0GnH0H ep6dgNVULP36kORX44a7nPcegyzQJsNt76aLCzFbjGXV/Bt12VOkZP/cEiu55TfT1moN5C8j62F /Zm8nlCujXp678QpsoqkgjwJirdmsrSL0pZWSvm4jOm3fZDq09X5Vi7CPm+Hgarp5REazgOUOFj D7y8kfQ09t1BNukkcK2yI28MhlG2GThj9ZNm8A8E7z/eJPDSHKp/0bkMl53GN74Z6m3JIkKqPZ+ Jc2PDm4WMmF+DNwXmGrjonEWeXv21Mv6AS20sVs3oLNKiFvqtkc9n3FvLX5PmAenh5JxLI5cSIA G8ml3hlQloOqx6A== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055516_477597_8F58F732 X-CRM114-Status: UNSURE ( 9.93 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow for specifying a USB connector to use for charger type/OTG cable detection. The way this is done is inspired by the rt5033-charger implementation. Signed-off-by: Artur Weber --- Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml b/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml index 2f4437dafdc0..b70c171bd4b9 100644 --- a/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml +++ b/Documentation/devicetree/bindings/power/supply/maxim,max77693.yaml @@ -73,6 +73,12 @@ properties: enum: [4300000, 4700000, 4800000, 4900000] default: 4300000 + maxim,usb-connector: + $ref: /schemas/types.yaml#/definitions/phandle + description: + USB connector to use for charger type/OTG cable detection. Phandle + to a USB connector according to usb-connector.yaml. + required: - compatible From patchwork Mon Jul 15 12:55:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733496 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 76AB6C3DA4B for ; Mon, 15 Jul 2024 12:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Hy8uXIYsKBTu0N7Z2wuBwfh2n1x8LDG4iwV5RA5Sikk=; b=OL2UXd31+LrvBVPAa5MdZQD73Y 9KQyclTWxYFGd15VU0EYdcbA3QuuQymbq502d9IQyQnVCtKsH2WVpWDHyH/IwGxiAlRxs7VCwkSD3 DtQuZABc7+ErLGW64FJWfIZi7MMNCQI0NJ2Efbe+OHeURa4cNWAYyNXzFdI8TnoJJ+fdq/HHVEYZU fvAf/IuVHk2zq6fJ/LH6G/5e+BeiPvJs/fVXxk54U0hKFljpZRYAbt42ydv9HGsz1EONWZBZUt2fu ZEMOCHtlUj3mUYX6DF4L7QRsczXdcmer29Zgat8i6pt642Vgv+OlVQlLe417wG+nIuuId/J7sCNnG 8s4QAD9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLFe-000000076re-3P7a; Mon, 15 Jul 2024 12:56:22 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEc-000000076Rz-1s1i for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:19 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5854ac817afso5322434a12.2 for ; Mon, 15 Jul 2024 05:55:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048117; x=1721652917; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Hy8uXIYsKBTu0N7Z2wuBwfh2n1x8LDG4iwV5RA5Sikk=; b=A45jFe+mMC4Vusn0AvDIZeKiIdMK/59ao/YgRUkl/m6ccBZeHw12KPDoQJ8DFNMXEn 5JZnT+n7t2noyy+CHMkziZgqvGVJIjGxTRt6b1U9JI9hjElvSPLTJpGKqJVlt3eNevXl xEi5nxn0y8aFQH7yjur5cOltciu0N64psE9tn409VXBq5owwCak4MEr/dZcVUX+secgE 12kyHaCQAWd2ujEGLo9PFlu0nGxyHBN2R3QlyhO67sxOgozn4paLhnE06KWTvQqpswGT 6jU0XFW996e8tkSzwM+PEbNE/OFt88oNoh54qvoM1iZMiwmwuRnlPSIL2dsn6Egy6RyP Ajmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048117; x=1721652917; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hy8uXIYsKBTu0N7Z2wuBwfh2n1x8LDG4iwV5RA5Sikk=; b=J1HRM8lSNpThg73ZsxlYYi/CUloKQoa/GwriXNp/QtYwZjlrej4yR9jifyc7yTsIn4 he1Obx9BI7eOWOWncvQeaRVC/hPK9ypMAzXzEE0PPNIw1Qdb9bLSe35X/48QkIfOgtwo sBoM3h5Irs7LeHMxgyq9gnX8bNBa9Sib0NAxMg4cHUewzUY0M3PDlRbWZdqkMJ6K8sdy 3MGmoECDmnLsLy9RWDt2vWxjKMjPMw0GFPQW8PxbCOHnFE8E7OUm6u7PEEkEp1ulk/bx 58nqGoYAiYZfDT9ShSOayWa2LG6Fu/yz+7aSLWj+kRNkTvvsRL5tfkxI7j6THTlBifhg BuSA== X-Forwarded-Encrypted: i=1; AJvYcCXjTP/BnNpLlXcUWcZ9HS7katc49RwhmtqaArH7O+sji8uNjMRl9FgAN4gBebB9/9PRo56+v6RELIjrP1eJPJ2EGmsL8IWpv13s999jkuc4C2rifxU= X-Gm-Message-State: AOJu0YzDjajcUWJ8fiwrEiIMhJQ9yT4MGVYcVIQ1TgazJu9HbkXdOjuM +6OAGVjx8Xl7od1SmTRgtFqseFANKf2k/nQA4iiga7od6ltC7qw6 X-Google-Smtp-Source: AGHT+IFSeOUQ4GQ0JktHokv589tUfaMihwOmd9W2rP3yeBHjQVzPLMNMNZgec2Vx5yIRh3tyCsIOBA== X-Received: by 2002:a05:6402:5bc6:b0:587:2dd0:93ec with SMTP id 4fb4d7f45d1cf-594bc7c7e36mr12494193a12.30.1721048116556; Mon, 15 Jul 2024 05:55:16 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:16 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:05 +0200 Subject: [PATCH v2 3/9] regulator: max77693: Set fast charge current in MAX77693 CHARGER regulator MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-3-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3543; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=sa109WgAcykCnYFwcY2iDwvvtR/mCqo5hBu3QTu8IW4=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwpIpRGh8YMXJ3XQOkQ2hUgOoJw/29UT+Po2 VR5KAyFJ3yJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aLY6EACF7ffTvprcNEbjAy1hgs2bevgEwN4A3e2ItBicKITTLCZFfKxd2+k4A4oXyjZ3N15Ewg3 VKas0dQ03e4EoTGGlT/HTcwhVR8tIkGM3367YU8ZdNXJsOK8O0X5AbQ5m6YEHag6w5hVnICJEGA VUUXnOYofTqM5FkphC/9RrYfSRTmAwDV43Ha71LP+up6hhgZPDZz/MJWhTkfiI29P31gOBQGvhz C9maOTwMswG7NlAmTFofooE/R8jZRQ+tHrPj81cNjI75K5x8rb8vkYOTQphbU5GNnKBOp3llefC C5SjiHEgMfqAj9wV5wKYEee7W4rDkwygXa0deHUjG+ng2+hNJlwmkKSlgYSrmbcR5pA8XWPna3i qqgU7bDA7PxzgCLSzs9SfBu7gzx7dbhfUKA8Z5HG2lCuOu8kkz9QMrDjG6KwGoZ36gxcyAU+t2s PyFm4pBN+P3+OcRG8DKyi5ix9NGO/p0qdyhr9vo1HW/dTPhygvgt8HGBsZxQFYoOb4oAaA5UbKT 7JbQhROiYfHM5L8kjqAc5yldv3OtB9rnKJNUA9DimrwQeAkbMuXK0i2nHfrlLTy0TbtJMFFmuR3 O++w5f3y5GPOMfSDo6/iNb2iWs0SWVBKVJD0F7YAHdjlh8uhEuyHpOnRkXiUrD6B5xh5tmFe8s2 tfe4E4tD1MEgblQ== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055518_525999_900CEA58 X-CRM114-Status: GOOD ( 19.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The MAX77693 CHARGER regulator only controlled the "charge input current", with fast charge current being listed as a TODO. Fix this by also setting the fast charge current when the CHARGER regulator limits are changed. Signed-off-by: Artur Weber --- Changes in v2: - Added this commit --- drivers/regulator/max77693-regulator.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/max77693-regulator.c b/drivers/regulator/max77693-regulator.c index 72a67d0c5f1e..3fee2e255fd0 100644 --- a/drivers/regulator/max77693-regulator.c +++ b/drivers/regulator/max77693-regulator.c @@ -36,6 +36,7 @@ enum max77843_regulator_type { /* Register differences between chargers: MAX77693 and MAX77843 */ struct chg_reg_data { + enum max77693_types type; unsigned int linear_reg; unsigned int linear_mask; unsigned int uA_step; @@ -46,11 +47,12 @@ struct chg_reg_data { * MAX77693 CHARGER regulator - Min : 20mA, Max : 2580mA, step : 20mA * 0x00, 0x01, 0x2, 0x03 = 60 mA * 0x04 ~ 0x7E = (60 + (X - 3) * 20) mA - * Actually for MAX77693 the driver manipulates the maximum input current, - * not the fast charge current (output). This should be fixed. * * On MAX77843 the calculation formula is the same (except values). * Fortunately it properly manipulates the fast charge current. + * + * On MAX77693 there is an additional "fast charge current" register: + * min: 0 mA, max: 2100mA, step: 0.1A / 3. */ static int max77693_chg_get_current_limit(struct regulator_dev *rdev) { @@ -86,6 +88,7 @@ static int max77693_chg_set_current_limit(struct regulator_dev *rdev, const struct chg_reg_data *reg_data = rdev_get_drvdata(rdev); unsigned int chg_min_uA = rdev->constraints->min_uA; int sel = 0; + int ret; while (chg_min_uA + reg_data->uA_step * sel < min_uA) sel++; @@ -96,7 +99,30 @@ static int max77693_chg_set_current_limit(struct regulator_dev *rdev, /* the first four codes for charger current are all 60mA */ sel += reg_data->min_sel; - return regmap_write(rdev->regmap, reg_data->linear_reg, sel); + ret = regmap_write(rdev->regmap, reg_data->linear_reg, sel); + if (ret) + return ret; + + if (reg_data->type == TYPE_MAX77693) { + /* + * For MAX77693 we also have to set the fast charge current + * value. This value has a lower upper limit (2.1A), so we cap + * it at the highest possible value if it goes above the limit. + */ + + sel = (min_uA / 1000) * 10 / 333; /* 0.1A/3 steps */ + + if (sel > CHG_CNFG_02_CC_MASK) + sel = CHG_CNFG_02_CC_MASK; + + sel <<= CHG_CNFG_02_CC_SHIFT; + + return regmap_update_bits(rdev->regmap, + MAX77693_CHG_REG_CHG_CNFG_02, + CHG_CNFG_02_CC_MASK, sel); + } + + return 0; } /* end of CHARGER regulator ops */ @@ -179,6 +205,7 @@ static const struct regulator_desc max77693_supported_regulators[] = { }; static const struct chg_reg_data max77693_chg_reg_data = { + .type = TYPE_MAX77693, .linear_reg = MAX77693_CHG_REG_CHG_CNFG_09, .linear_mask = CHG_CNFG_09_CHGIN_ILIM_MASK, .uA_step = 20000, @@ -219,6 +246,7 @@ static const struct regulator_desc max77843_supported_regulators[] = { }; static const struct chg_reg_data max77843_chg_reg_data = { + .type = TYPE_MAX77843, .linear_reg = MAX77843_CHG_REG_CHG_CNFG_02, .linear_mask = MAX77843_CHG_FAST_CHG_CURRENT_MASK, .uA_step = MAX77843_CHG_FAST_CHG_CURRENT_STEP, From patchwork Mon Jul 15 12:55:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733501 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7334BC3DA4B for ; Mon, 15 Jul 2024 12:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2dnrbGKaoLS2/r35L01fJO0wiCmLb/VBCvJttZm/KZE=; b=AznDnaToV4FrQk2v8c82fZ0rU9 oblw8oXDa6YVk2ejl6Ki3hFxu34/KakIplwYHv7z9TbGfyVyBjfoxpLeYs5ySdkdnX/1XzIEGG18Y iF6FTcl/lDCuaC7zI6IOc9sv/0SX3G0hhdxnAMEsaEJrVuLADo+aQRj50gPvGUpz8alQhUbHs+5RI Ub01UOmkHNp+mNLLse/tkOg7o78yDbYAwE3OAC/mVikcIIKNuLPgo2HANVFLZBuw4MreQoBby/203 h7BtQA+6hwLp54jmQxpYzYKCDzmgc8wWPYRblY3eEUrTFlQL9XhHQoUF/Df0O27ilWYnACmxFTVOY dTWEeo3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLHK-000000077YW-2qh5; Mon, 15 Jul 2024 12:58:06 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEe-000000076Si-3ZYR for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:22 +0000 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-59a47d5c22aso4263627a12.1 for ; Mon, 15 Jul 2024 05:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048119; x=1721652919; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2dnrbGKaoLS2/r35L01fJO0wiCmLb/VBCvJttZm/KZE=; b=NUWDXIA2O3qDBsHOt3ISB2CDit9FVx4klZxPfVfqHHSC8F2qTpFzBcpAvwGdcEsNRO b2gVhfRVouLuF/jP6yYXyCY40kTJ5tqk/LUXPl1VIBNutL+pkgbEMk4ZQKqDCvCeU+yw b6Jxs6RcPCD3x5Xifu0omNrH8KrT6f2Ds72fZ9cPkU/ESlZ4iz1VcpABgkYeldRQH78C y9zCz+Xd7+LkW5ZIiwJJA21V1Pym5a6spSx5sRMPeVmj9zxq6XSSb6CulWvBiMmDbkZg EapD4P36QbDHkih7KkvuMkM8EdEFxZVmnOo31eXBmL3JPjC2d/m4kzDs7/HkzDyBCx8C ftuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048119; x=1721652919; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2dnrbGKaoLS2/r35L01fJO0wiCmLb/VBCvJttZm/KZE=; b=pEdsB8e1CxODoDzpLuIYm0kJQn0HSjTdWHO2LqDHLBGhUPVQ9y+EDpyA4MLzisZYhZ dwt1LlLlGjsCzrazO8RqA1JraayjXyoassaIhZcid12Dt2stopO6ep4L1Ry38WPm4Q/R HAwKN4Zkv1iDG6/qnQkAV/BeUopfhwNQ3X2HI7DDLFUiqFHEKOkpdFUBb2rXvADGj3S2 0H3ccwrZgExiQw6S+3oTytkulz/OCrAkpbyInA/ZoWhhhPYnx8mcIvs6aVNgSCfpNeJO ZzxYIod8OFxs9acDPmhxSKff57ZsONWn9fvKTfB8vuLC8OoaZHKbaZBqFKc7BeatGr+e WTkA== X-Forwarded-Encrypted: i=1; AJvYcCWhB2A6VMi+0OkckGAbOahUqia14qy25zdmzf5hQdMejYEvaV1zDK4DjO3zJcnzSJs8koDoJVSHmZGwvtraA4y9ugtX9BstMN73zqRJb5d9hyqDqg0= X-Gm-Message-State: AOJu0YzPJEjDsHSLSpZK0emDEsHMgGudEcxoge/MV7R1c2AwyZFLxr7v bRjwLep0KglOD/oHyYstXM8mbQ7DjkluvrqpxBmiA+KFAKpEW+QV X-Google-Smtp-Source: AGHT+IGKYmXJeIOPB/b6vl4yOzL3ahdkEu80vW0kNZgFlL4bFu7UcYPpvXzfkUGFqZN0xjUW9B6bFA== X-Received: by 2002:a50:bb04:0:b0:59e:65d1:a573 with SMTP id 4fb4d7f45d1cf-59e65d1a75fmr199688a12.21.1721048118746; Mon, 15 Jul 2024 05:55:18 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:18 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:06 +0200 Subject: [PATCH v2 4/9] power: supply: max77693: Expose CURRENT_MAX property MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-4-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3161; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=1lV+PvQs9RkMQaB50b7Zw5vUCqbzy36VnOEmeBWappo=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwpt1JLmGw3JWwB62NBhkT4suEV7QjKcBC3M zVBlzxGAFmJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aLeJD/9Ef/NUzUm3MsA+/2pPGkUkhL4zfMZx//VessDpHA5cioDs6pX5hk4kbkfKTFwVBiGE9+l EtoTOt7Jjqigf63T6WidXghkyjcY7IZ2KIL8Qr6ZhuJESM0BWmoafPQNmwHO8w0euZHLDknW0T5 M1inRVJynstVx/a1k2yM1peHB/oijHfPRKINmUFleDSURUVhxH0nBmj8eQ5YjV/CwA9p07EZ7MX cG9e8pl1Er379lWOc4NcT88omRw/aFz/znEfmJ8i+/lCm8rJV4LYdTes9Nx3/T+PTzrL9xj3y5s abiRw7f9JpQuuDJr3NVzIc0OxMEUPMFFIY7+ao8O7rmHE1A5bpzED45+VBiDCe1+ydTN9uOQO6f w+mt8u2Hx73aQjfQRymE710Uer8XBajg9hZTt3I27sb+3U8OL0n/+sJeRcOrf/w59rnrsx5j1xf OX1zwrxS5WkHkiaO5cMMcCkTazQmGAoG6/15v4ioJSP60+5fnQCGbkWLRT9EZJ435HWc1GFZWD6 JjhE2KqJ1NV2wzBfyDJxn4IbO0ymKzLikJ1i0lE0oXVHSy1j1Hvp/UVGTgy8kbonCtg4FS+Jzr7 WrLCMN9+Eol+lAmkfVn4DW0fTNicVqY0dnMcCbKs+QkQ6VUICLKz5mj8N4CbH1uC9wU3dXksxAp UnGHu9AqNxsyt7A== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055520_933084_3E4E6983 X-CRM114-Status: GOOD ( 17.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are two charger current limit registers: - Fast charge current limit (which controls current going from the charger to the battery); - CHGIN input current limit (which controls current going into the charger through the cable). Both of them are aggregated in the CHARGER regulator. Add a property that allows for reading the current limit from userspace. Signed-off-by: Artur Weber --- Changes in v2: - Adapted to both current limits being managed in the CHARGER regulator --- drivers/power/supply/max77693_charger.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 2001e12c9f7d..0d53f61d58ba 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ struct max77693_charger { struct device *dev; struct max77693_dev *max77693; struct power_supply *charger; + struct regulator *regu; u32 constant_volt; u32 min_system_volt; @@ -197,12 +199,33 @@ static int max77693_get_online(struct regmap *regmap, int *val) return 0; } +/* + * There are *two* current limit registers: + * - CHGIN limit, which limits the input current from the external charger; + * - Fast charge current limit, which limits the current going to the battery. + * Both are managed by the CHARGER regulator. + */ + +static int max77693_get_current_limit(struct max77693_charger *chg, int *val) +{ + int ret; + + ret = regulator_get_current_limit(chg->regu); + if (ret < 0) + return ret; + + *val = ret; + + return 0; +} + static enum power_supply_property max77693_charger_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_CURRENT_MAX, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, }; @@ -231,6 +254,9 @@ static int max77693_charger_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_ONLINE: ret = max77693_get_online(regmap, &val->intval); break; + case POWER_SUPPLY_PROP_CURRENT_MAX: + ret = max77693_get_current_limit(chg, &val->intval); + break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = max77693_charger_model; break; @@ -680,6 +706,12 @@ static int max77693_charger_probe(struct platform_device *pdev) chg->dev = &pdev->dev; chg->max77693 = max77693; + /* This gets the CHARGER regulator from the parent MAX77693 device */ + chg->regu = devm_regulator_get(chg->dev, "CHARGER"); + if (IS_ERR(chg->regu)) + return dev_err_probe(&pdev->dev, PTR_ERR(chg->regu), + "failed to get charger regulator\n"); + ret = max77693_dt_init(&pdev->dev, chg); if (ret) return ret; From patchwork Mon Jul 15 12:55:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733497 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED3ABC3DA4B for ; Mon, 15 Jul 2024 12:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JepbQc7AbCsn4MwQCws5rv8exDXvYLKDGPZlZpP5vYA=; b=5F6Aji4PbVaIf7QSTtKBpRyr8o DgFBIykI1Q9NcLIqQvRotxQRvfGNWk2nwgmThNt8ZKIrHviW8/r6jTwsRkrZcbwy4Ap7bFguOu0QA 3WR2jzxhSwRDzoCjk1z9OD/3fVi+c1S9LOT2WLQ5eD488QXemCXs3LcmijRR9Vo3CWHnmVu0w50LH fq/bb3f0eQwsAi+UxdrufV2W6r0llW6HG/IDmrkSG0doyB4hLgsB7gru3tp+3rEa8FscLl16rqY2p /U/nYmguiNAPCd39Axb5YcfnV9ZzHwySr1enfsqgg4ZPWowmAxju0gMD01WacjGt0bPSE8kkiVvhw DrpUzFIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLGD-00000007761-2Hxt; Mon, 15 Jul 2024 12:56:57 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEg-000000076Te-0SRh for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:23 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-59559ea9cfdso5403543a12.0 for ; Mon, 15 Jul 2024 05:55:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048121; x=1721652921; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JepbQc7AbCsn4MwQCws5rv8exDXvYLKDGPZlZpP5vYA=; b=V3QjxQMS9pca8T35dDFQIXMxXwrDOXG9x8HEN6qCZ79eyE+LkXZitO04WooJ14lkKQ IqnxOmB7KCZkqyVdY+urrIvN3civ9m72VytJuv3hXCqzO1jPZNePLbfJkaXDu/n/NNe2 55yUZBclrvB5XQSE8UGh8gUwYfRn3K+WnO1GhlWbIjiOXChb9CSzcIFxarO3DHGIc88M p/zu7PbhBlGEQWLKhzxlFRp3tRbCu/6tAEB9G5ee3lpLOYNMPSJsmU21Xl8DytVifl9E 9HfaY4v4lKk2t/PFefSmtAUVAr1ZsxqnoAHq+tU7TfNssFM/1bI/G0l9u1SXC7SH8lsI FdnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048121; x=1721652921; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JepbQc7AbCsn4MwQCws5rv8exDXvYLKDGPZlZpP5vYA=; b=HYP+ghvdDLaw7USyBl4GRPh7KKIchEWgmt1V1pfRb24pSpj3Y9rRaYb+YGwgHgQUhr NDRZCnEOsjL9N03mqxRyBhbN7GYOFPtzugh8jBZGjZqbKr7fb2T7b33aq+Du7T20iRuP wupOKz24TdvfgByyJUpDCSPAwZ3DKPG4YjJ9+eWpT+Npv2WYUMZx6Uh39rdvOS1CCsA2 qldmhr92n6IzAJz4M1/LRH5TVkolyw90AYXz5SnJSvBFjqUXuCmgfrFyd1JwKvNSVrIl uLTiaKq3u14BhQYruyFAe803EDP7doY7n/zqMUHH2pjImTeTEQTrzMKWevZr9GwkFtai JeTQ== X-Forwarded-Encrypted: i=1; AJvYcCUQWm5bGDqCCpGaDyeTfpyIZFgvtq8IXOWdcqqmfZafJn9X0J+U1GfclL3hlk1cJxGs6H/zLhoJ76ehr7e0ZwCtXan5KMgPG+VzldxXjQgoCvk7zoQ= X-Gm-Message-State: AOJu0Yy0AWthRBXzV6ZwDixaC+zQFva3sHvJJPW0+qUuwkxqRbelwimD qDrY3OC0/E1acjUfhTXzp/In6zZcNoPHeojxhgk1C+csJANrNp01 X-Google-Smtp-Source: AGHT+IGIWouH56vOf6Qbnawj6h4Sop+wyVlJV9Nl0ERoET1sC3NknxcHB6X4S/u+v6iC8pqN/5i91w== X-Received: by 2002:a05:6402:33d5:b0:57d:3ea:3862 with SMTP id 4fb4d7f45d1cf-594bc7c9133mr12051429a12.27.1721048120664; Mon, 15 Jul 2024 05:55:20 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:20 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:07 +0200 Subject: [PATCH v2 5/9] power: supply: max77693: Set charge current limits during init MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-5-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5592; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=d9xJyVGdkLb6jVsuC/vB8diOax6NmCIBMwGr2E4GxCQ=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwpgRncJxk6pRZ/FjwXbwkFvP4KP7Pdm10nk WTNeVQukMmJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aJB9D/wNFjY5v1IfChoZvKH+jUttjJ1AP8mE9CbHD9JEEL+mBrKMZzcDzm5hh18kwNHEpOKEu/1 E5vzCjNch4L//UPyRl3e6pYWXEfmpfiEz9d85F5sMq4zNvFw02YzjbMimMtUuNlV1ctR/Nu1Gei gwynsEPFtPbuJVB4VBspHyG280xHQiIDMubg23rmqBu+UTTz5ZyhzVJ15ZqjQbygADxSny7Nimf yLZJWa4dio75WN9sFk2nJKySk763gEjB02GKTtduYdHqWzx3bPBjJ5s3uw3x1R8NenUAOtl0pS1 5lRqtvlgOcfphmt5XRAECMMV5pm8k8ogFQsyRs/HiXHbPynIlLVdo6W4b78whASSgmvUyH2UHZj f8sQgNF/NVycHx5ZIBMM+TDrzIDv5VjYKec2XIAmzCdZELUP6zHUgcIzbYy5r2AdQ+nZSeOsrhc vWDvHgheH5ALFtSMOOdD41DlAi/HTSnMRzO3p8HNj3Ql0umti3IVq2OFtsO692CjGI1L59ADR8T T78fqI+g67R91MPQwbkiXHWM9XiwzuLC2qo9KXxMVRho/2ziVM1szI/A7BJBtA6P9XB84G4grNr s04avBsVnfKSlN6AUk6D7gQJSZ32lblxr9Ej6tyVtG9rxAaztiZVkyF2Ig5KqLtX6eLmM/iTG3A uuZlAiTByDE3fcQ== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055522_212927_30C6E4A6 X-CRM114-Status: GOOD ( 20.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are two charger current limit registers: - Fast charge current limit (which controls current going from the charger to the battery); - CHGIN input current limit (which controls current going into the charger through the cable). Add a function for setting both of the values, and set them to a safe default value of 500mA at initialization. The default value for the fast charge current limit can be modified by setting the constant-charge-current-max-ua DT property of the battery node specified in the monitored-battery charger DT property. Signed-off-by: Artur Weber Acked-by: Lee Jones --- Changes in v2: - Squashed mfd include register additions into this commit - Changed from custom fast charge current property to monitored-battery (devm_power_supply_register call has been moved up as it is needed by the DT init function now) - Changed to adapt to both current limit values being managed by the CHARGER regulator --- drivers/power/supply/max77693_charger.c | 43 ++++++++++++++++++++++++--------- include/linux/mfd/max77693-private.h | 6 +++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 0d53f61d58ba..0ddaa03669a2 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -28,6 +28,7 @@ struct max77693_charger { u32 min_system_volt; u32 thermal_regulation_temp; u32 batttery_overcurrent; + u32 fast_charge_current; u32 charge_input_threshold_volt; }; @@ -570,6 +571,14 @@ static int max77693_set_batttery_overcurrent(struct max77693_charger *chg, CHG_CNFG_12_B2SOVRC_MASK, data); } +static int max77693_set_current_limit(struct max77693_charger *chg, + unsigned int uamp) +{ + dev_dbg(chg->dev, "Current limit: %u\n", uamp); + + return regulator_set_current_limit(chg->regu, (int)uamp, (int)uamp); +} + static int max77693_set_charge_input_threshold_volt(struct max77693_charger *chg, unsigned int uvolt) { @@ -647,6 +656,10 @@ static int max77693_reg_init(struct max77693_charger *chg) if (ret) return ret; + ret = max77693_set_current_limit(chg, DEFAULT_FAST_CHARGE_CURRENT); + if (ret) + return ret; + return max77693_set_charge_input_threshold_volt(chg, chg->charge_input_threshold_volt); } @@ -654,6 +667,7 @@ static int max77693_reg_init(struct max77693_charger *chg) #ifdef CONFIG_OF static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) { + struct power_supply_battery_info *battery_info; struct device_node *np = dev->of_node; if (!np) { @@ -682,11 +696,20 @@ static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) chg->charge_input_threshold_volt = DEFAULT_CHARGER_INPUT_THRESHOLD_VOLT; + if (power_supply_get_battery_info(chg->charger, &battery_info) || + !battery_info->constant_charge_current_max_ua) + chg->fast_charge_current = DEFAULT_FAST_CHARGE_CURRENT; + else + chg->fast_charge_current = \ + battery_info->constant_charge_current_max_ua; + return 0; } #else /* CONFIG_OF */ static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) { + chg->fast_charge_current = DEFAULT_FAST_CHARGE_CURRENT; + return 0; } #endif /* CONFIG_OF */ @@ -712,6 +735,15 @@ static int max77693_charger_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(chg->regu), "failed to get charger regulator\n"); + psy_cfg.drv_data = chg; + + chg->charger = devm_power_supply_register(&pdev->dev, + &max77693_charger_desc, + &psy_cfg); + if (IS_ERR(chg->charger)) + return dev_err_probe(&pdev->dev, PTR_ERR(chg->charger), + "failed: power supply register\n"); + ret = max77693_dt_init(&pdev->dev, chg); if (ret) return ret; @@ -720,8 +752,6 @@ static int max77693_charger_probe(struct platform_device *pdev) if (ret) return ret; - psy_cfg.drv_data = chg; - ret = device_create_file(&pdev->dev, &dev_attr_fast_charge_timer); if (ret) { dev_err(&pdev->dev, "failed: create fast charge timer sysfs entry\n"); @@ -741,15 +771,6 @@ static int max77693_charger_probe(struct platform_device *pdev) goto err; } - chg->charger = devm_power_supply_register(&pdev->dev, - &max77693_charger_desc, - &psy_cfg); - if (IS_ERR(chg->charger)) { - dev_err(&pdev->dev, "failed: power supply register\n"); - ret = PTR_ERR(chg->charger); - goto err; - } - return 0; err: diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h index 54444ff2a5de..4570646e2f33 100644 --- a/include/linux/mfd/max77693-private.h +++ b/include/linux/mfd/max77693-private.h @@ -145,6 +145,8 @@ enum max77693_pmic_reg { #define DEFAULT_THERMAL_REGULATION_TEMP 100 /* microamps */ #define DEFAULT_BATTERY_OVERCURRENT 3500000 +/* microamps */ +#define DEFAULT_FAST_CHARGE_CURRENT 500000 /* microvolts */ #define DEFAULT_CHARGER_INPUT_THRESHOLD_VOLT 4300000 @@ -217,6 +219,10 @@ enum max77693_charger_battery_state { #define CHG_CNFG_01_CHGRSTRT_MASK (0x3 << CHG_CNFG_01_CHGRSTRT_SHIFT) #define CHG_CNFG_01_PQEN_MAKS BIT(CHG_CNFG_01_PQEN_SHIFT) +/* MAX77693_CHG_REG_CHG_CNFG_02 register */ +#define CHG_CNFG_02_CC_SHIFT 0 +#define CHG_CNFG_02_CC_MASK 0x3F + /* MAX77693_CHG_REG_CHG_CNFG_03 register */ #define CHG_CNFG_03_TOITH_SHIFT 0 #define CHG_CNFG_03_TOTIME_SHIFT 3 From patchwork Mon Jul 15 12:55:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733498 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6FDBDC3DA4B for ; Mon, 15 Jul 2024 12:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HnYgYyIzLcEnadxIm9ww2cm2tQhdI4bTzCayN53bjXk=; b=KEfyA/qLqvUL982rpRx2wimTSf 5tMcTibLMBAp7Z0dT1T3VfoV8aWXF+tF5mht4sxnA0UwhhVtXPcUMtt6R3VrogtSsBKSnWtJRLIlJ W5ZPbOMGkbTbhIikSkW4jYZ3Xo0O10pDVaSTnSHs5Lk37JuEHdQ4NkOXD0TKHb0ZTrJ1vBAXEPfM0 tYa2eDs6c5QJiHFsWhg9Gj0vCSC/vZB5Qa2Ed9tqiIBLAIOBiN9he83ZtGVicEtBERqt5it/ZlOEY MTRO5Hm5XXo5GGzpUyLVRkIyc2xC0Dru9go74vSWfGRKnpeaRM9n3paGVXP1R1IM68SXDGHPAKNfA qJSf0gDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLGU-000000077Dp-3nlb; Mon, 15 Jul 2024 12:57:14 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEj-000000076V8-0GtX for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:27 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-58be2b8b6b2so5349858a12.3 for ; Mon, 15 Jul 2024 05:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048123; x=1721652923; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HnYgYyIzLcEnadxIm9ww2cm2tQhdI4bTzCayN53bjXk=; b=EQG0KIv1dS7ZgGfF21ND+2UesSEPj/5qAoOFF6n2F9zc/wLsBwHYZE6wjBvtR40s1K /pshN2WxHIrVHSt92WOQtQS7vDKRvBJtdznhZ3mSgsrXrnZF203thE2l+3BohiJR7x8p ZTxNJwkT+/psqwxMhwxFgXyEFUkxu9TFXszg8uqfg6wbKh9NR1YI8uzVbdMfMg50Oz86 uMwY68NC9zYMVFc6mG0xGIZsAynKnwKi7owuuLsTo8uecHoh023P8+pB7vSCJwvqMqxI lXRReb9wlyi1RwzlODLtn1FAh6B+wokuQz9O952GGN6wFvIXkPMLoefJw4th+7co/TaV Ox4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048123; x=1721652923; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HnYgYyIzLcEnadxIm9ww2cm2tQhdI4bTzCayN53bjXk=; b=HoYzkzSfmBy+mLXfD0KGPdxB8a3ep4ihOO0VAX+cMR0j07O1tx8uF3WwPtbk0DHwK2 +im0EUbmH50gxH1bcmVnR+KkaGI71+JM/hkrd6JpSzpOuF37w+JJcmSTHu5E5zUN05ZU c6I8+39x6OjMP/KXPjianIUgtdSuPwoY3FJMjVXkkYhUmXWa5NnyGDZZAjVeWK4nUQCp 6V0W3xk6uilJVeZiCR01AbLA06DVGQenojAItPsm7mn4GCP4NWoNeDxGoZ96MrY6Z65S dnUBaOeRxrDI52MR9b+ZrJfHqIRjAJkp4be25nrhtrS6uAJc3rjtdoGb95kesa5ydiyW wbIg== X-Forwarded-Encrypted: i=1; AJvYcCUbo4TKYCuIhEKtZH9qOFvp+LjTttbX6O2uXGr6J1GWK2TXbimhYke/PexrrgpQYialcDBGJxY4g1I4svxLz3LkB/mVsMHdFmfjnlEFbuVbLNsItLc= X-Gm-Message-State: AOJu0YwUPDL8wKhwLXcJnlXIXR3Ona2nuKjerllsxMUPeAdIuf1GebPb Gh8/ei2KZuZRUn0qLmzPdGdhRtXbkpjKRYpOmK/b9VFL3UOp3qKd X-Google-Smtp-Source: AGHT+IEyt6/37zigreQe/eBSyKTbMjngFktAPAGaKiuzzl4eqOkTPH3/6/JLn6fPOrQnCCih3MzkMw== X-Received: by 2002:a05:6402:520d:b0:58e:e2a:1b4b with SMTP id 4fb4d7f45d1cf-594ba98f273mr13167907a12.7.1721048123056; Mon, 15 Jul 2024 05:55:23 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:22 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:08 +0200 Subject: [PATCH v2 6/9] power: supply: max77693: Add USB extcon detection for enabling charging MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-6-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6386; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=nORleTpwpWgNuuODzmLnTBwFLWHB5u9wp9/Xe63310I=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwp5hracQTmctVBYewvzeIa4lw99or+rKlKb F//suZwLd6JAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKQAKCRCzu/ihE6BR aGxfD/9CZ7IEig+/B2weBvWrxK95bSBmd3P8A8A2fAp5O+1Nj3UdZa3Ntauaxbmoeg1QWzMmlpV n6dqLK/RysDFKkJBe/h/n6hdi9d6sRnzg5EdC8BYSLu4yXDWaSZKU+tAvvdzqlxtS7wKdQjo7OP 6rl4miwQF4XD/rhK8Acm4g3lyQ+clRwxjg3f1TY3Ympgtq0/rlc5az+CcAMBFpIyaHIDvxp3jLs JNkG2VPqtXfYej6Lli63nUu1FofMMmrPTe8XX9TI25DWrtA7V96T0FmQUxiy0krr3iF6jeAT0u0 VUb6S100hKINN85btRyeZZJEgAOu+H5hU5pNpCdXvyGs1nMneexRyKc5UTaZvYyH1SlmZKHGfzR 6ApcBMmXSiyEmu2OJupq5+jGzqMpG6WQE62ocmJvNnVcIDsm+3xWqU3SPK6xICV37TQ2TguTIF+ Y1Iqk2SUkX6KCPu6EkxjlnzKJ3x87mZb6BnFDNHHFAuqcfmtIvuMwNXRrFLX67j7t90jRTrbCmv VeLCJiGCqLDG+QVwfrKC1u0p1fWApT2g66P5UmTQsX+c/AnF1QQmxzkjouvsUSrwk4SpnIu9i5+ 8lglUXuHa8KaTrUrhBHf1BpZofqCu7+bCHqntqTB710rgoLw/S3er//gy6K7x5OkKPgZkcOL02p rXAwZxzDEOgWfrg== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055525_227335_DA3A4C8A X-CRM114-Status: GOOD ( 24.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a device tree property, "maxim,usb-connector", that can be used to specify a USB connector to use to detect whether a charging cable has been plugged in/out, and enable/disable charging accordingly. To accommodate this, also add an internal pointer to the CHARGER regulator, which is used to enable/disable charging and set the input current limit (which will be done in subsequent commits). The extcon listener/worker implementation is inspired by the rt5033_charger driver. Signed-off-by: Artur Weber --- Changes in v2: - Changed to adapt to both current limits being managed by one function --- drivers/power/supply/Kconfig | 1 + drivers/power/supply/max77693_charger.c | 125 ++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index 3e31375491d5..e4aeff9e7ad1 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -549,6 +549,7 @@ config CHARGER_MAX77650 config CHARGER_MAX77693 tristate "Maxim MAX77693 battery charger driver" depends on MFD_MAX77693 + depends on EXTCON || !EXTCON help Say Y to enable support for the Maxim MAX77693 battery charger. diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 0ddaa03669a2..2dc273dd96ee 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -5,6 +5,8 @@ // Copyright (C) 2014 Samsung Electronics // Krzysztof Kozlowski +#include +#include #include #include #include @@ -30,6 +32,13 @@ struct max77693_charger { u32 batttery_overcurrent; u32 fast_charge_current; u32 charge_input_threshold_volt; + + /* USB cable notifications */ + struct { + struct extcon_dev *edev; + struct notifier_block nb; + struct work_struct work; + } cable; }; static int max77693_get_charger_state(struct regmap *regmap, int *val) @@ -664,17 +673,110 @@ static int max77693_reg_init(struct max77693_charger *chg) chg->charge_input_threshold_volt); } +static int max77693_set_charging(struct max77693_charger *chg, bool enable) +{ + int is_enabled; + int ret = 0; + + is_enabled = regulator_is_enabled(chg->regu); + if (is_enabled < 0) + return is_enabled; + + if (enable && !is_enabled) + ret = regulator_enable(chg->regu); + else if (!enable && is_enabled) + ret = regulator_disable(chg->regu); + + return ret; +} + +static void max77693_charger_extcon_work(struct work_struct *work) +{ + struct max77693_charger *chg = container_of(work, struct max77693_charger, + cable.work); + struct extcon_dev *edev = chg->cable.edev; + int connector, state; + int ret; + + for (connector = EXTCON_USB_HOST; connector <= EXTCON_CHG_USB_PD; + connector++) { + state = extcon_get_state(edev, connector); + if (state == 1) + break; + } + + switch (connector) { + case EXTCON_CHG_USB_SDP: + case EXTCON_CHG_USB_DCP: + case EXTCON_CHG_USB_CDP: + case EXTCON_CHG_USB_ACA: + case EXTCON_CHG_USB_FAST: + case EXTCON_CHG_USB_SLOW: + case EXTCON_CHG_USB_PD: + ret = max77693_set_charging(chg, true); + if (ret) { + dev_err(chg->dev, "failed to enable charging\n"); + break; + } + dev_info(chg->dev, "charging. connector type: %d\n", + connector); + break; + default: + ret = max77693_set_charging(chg, false); + if (ret) { + dev_err(chg->dev, "failed to disable charging\n"); + break; + } + dev_info(chg->dev, "charging. connector type: %d\n", + connector); + break; + } + + power_supply_changed(chg->charger); +} + +static int max77693_charger_extcon_notifier(struct notifier_block *nb, + unsigned long event, void *param) +{ + struct max77693_charger *chg = container_of(nb, struct max77693_charger, + cable.nb); + + schedule_work(&chg->cable.work); + + return NOTIFY_OK; +} + #ifdef CONFIG_OF static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) { struct power_supply_battery_info *battery_info; struct device_node *np = dev->of_node; + struct device_node *np_conn, *np_edev; if (!np) { dev_err(dev, "no charger OF node\n"); return -EINVAL; } + np_conn = of_parse_phandle(np, "maxim,usb-connector", 0); + np_edev = of_get_parent(np_conn); + + chg->cable.edev = extcon_find_edev_by_node(np_edev); + if (IS_ERR(chg->cable.edev)) { + /* + * In case of deferred extcon probe, defer our probe as well + * until it appears. + */ + if (PTR_ERR(chg->cable.edev) == -EPROBE_DEFER) + return PTR_ERR(chg->cable.edev); + /* + * Otherwise, ignore errors (the charger can run without a + * connector provided). + */ + dev_warn(dev, "no extcon device found in device-tree (%ld)\n", + PTR_ERR(chg->cable.edev)); + } + if (of_property_read_u32(np, "maxim,constant-microvolt", &chg->constant_volt)) chg->constant_volt = DEFAULT_CONSTANT_VOLT; @@ -752,6 +854,26 @@ static int max77693_charger_probe(struct platform_device *pdev) if (ret) return ret; + /* Set up extcon if the USB connector node was found */ + if (!IS_ERR(chg->cable.edev)) { + ret = devm_work_autocancel(&pdev->dev, &chg->cable.work, + max77693_charger_extcon_work); + if (ret) { + dev_err(&pdev->dev, "failed: initialize extcon work\n"); + return ret; + } + + chg->cable.nb.notifier_call = max77693_charger_extcon_notifier; + + ret = devm_extcon_register_notifier_all(&pdev->dev, + chg->cable.edev, + &chg->cable.nb); + if (ret) { + dev_err(&pdev->dev, "failed: register extcon notifier\n"); + return ret; + } + } + ret = device_create_file(&pdev->dev, &dev_attr_fast_charge_timer); if (ret) { dev_err(&pdev->dev, "failed: create fast charge timer sysfs entry\n"); @@ -778,6 +900,9 @@ static int max77693_charger_probe(struct platform_device *pdev) device_remove_file(&pdev->dev, &dev_attr_top_off_threshold_current); device_remove_file(&pdev->dev, &dev_attr_fast_charge_timer); + devm_extcon_unregister_notifier_all(&pdev->dev, chg->cable.edev, + &chg->cable.nb); + return ret; } From patchwork Mon Jul 15 12:55:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733499 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AB90C3DA59 for ; Mon, 15 Jul 2024 12:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yplmBPab31T+ENfBznOyfetvZRWw0PUytsuLn61zZ54=; b=2ydLZB43jAw+tA/3RcOhO2ODik Rv1eAo6W3sBw7IQwiFNc5eMKObknm3anKV2UpL0BkiR4pwMP94Q3990FtWNWfEccsnGlZW0YEp1pB eroE9hgZBzsoqkMpxzvlh+q6x995pslDsrGxD2qrKoYxS0junTNOOfIH4i5JF4UdmbWfdGE+V9gCE xsL7vJfU1Xi2sn6R/+xrDStAkFtyk+HV85M5PQ23dFOi917TjO4LRDSOMWh0hReKRmAk0Q13F0F4x eZn/VyC/mu0FpgnIsw9dqD+MLwRGkYUefMAOs7jkBLmm13BHFtPkUBm8P6XjGBo5WHHGAOl6bZzyN +Tf9FLGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLGl-000000077KF-3Rue; Mon, 15 Jul 2024 12:57:31 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEk-000000076Ws-3dUF for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:28 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-58b3fee65d8so4998395a12.3 for ; Mon, 15 Jul 2024 05:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048125; x=1721652925; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yplmBPab31T+ENfBznOyfetvZRWw0PUytsuLn61zZ54=; b=jhr/V6lYafEsAyLiXiXIRDIAOA62LCr8Ifew4HD6aPUPryRYQLxbQw0hC2u9fIHQ6j s4vUlDjRQLCmLrVBTIYJjloQ4l48dEXr5/odNJG3nr+98+yf4yTYAC8X+C+WsTZg3aDT 5XgzmhEGErwtBj93nLVaDBhuEaMW5Cj18gFxODPVmirut/2nbDk1wMsNw5bnhEY+whlH 1ebfK7wtBLOOMa8uomRqVKowOztiH3YdqcrIJsCFleczwivxflML5eKmhoUhlynwHaOx 2kLPofSb9ZGkVdkavT/NzhrIToFFqlUg8J7Bs3wKEUG6J3+Y+/gtT8UYW302uDzy253P qjFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048125; x=1721652925; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yplmBPab31T+ENfBznOyfetvZRWw0PUytsuLn61zZ54=; b=QOMkhfI52K5SPLs4eve3tXkth1h9lETkjXTC6FEoWNIp6nj62YF8QQ0AViEyy0vyaD 4raRUzVRDHVMiuQJa/A5Sn6+UxoetpTYEWuNZJFmdkymPkbzJot8UMlzHxh+kS9aL5h+ wET93I/8PVJ2V8YQ1Hq1ZUOlrZx0d4TW7//wuLutg0oEJsV0z9tZ/4hX9zN64wOgkpCD WoY4vzblZoZx+u7xrC/+FWLkfVexppAWTxsOvUFcMjgvPZYZiZ13SAeboZ4P6OK+vMIZ kPL66aqdfvESD2sZGzY/mNH6pC14LPoC2JeA3vcweYz8RqFHLMgx6QE1BTWyzo6jhcSy D5GQ== X-Forwarded-Encrypted: i=1; AJvYcCXXI6cAp5g5TDa4VjkLMKa7CsbSvDdwkPhN5DFxhddsgwY1AUsVZE4LvFY7qpd3jcX2+YAfrRGFZj5t9tcnA4mn7OE6Ik242NS9VIduw6QZSI8q5W4= X-Gm-Message-State: AOJu0Yx+v3N6ZNUByBoO/ZisqPFK+/GiubiONdjnywOmXKN2bxdWxvSs i8Pz33fKBV1n8p6GV63wbzFLQ8BpR6qnppBjtZt+rKETcEdFHVa0 X-Google-Smtp-Source: AGHT+IEi0rB6grzKm+6JFok97+M2O9K/mc/iV01iqXjDpsx+NrTD6Yh0aFRRjs4CR0X9xR4LS9ghuw== X-Received: by 2002:a05:6402:11cb:b0:58e:4088:ed2 with SMTP id 4fb4d7f45d1cf-594baf8d6e7mr14449097a12.16.1721048125174; Mon, 15 Jul 2024 05:55:25 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:24 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:09 +0200 Subject: [PATCH v2 7/9] power: supply: max77693: Add support for detecting and enabling OTG MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-7-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6011; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=EXZReySANjkAeBrLFiKGCwE8yARrL34C4+BpkRUqMJU=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwqLWuWZaYoe183l0Kev4lM9FuRl+x8JjYe9 DhmziyLvsyJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKgAKCRCzu/ihE6BR aFqqD/9k+4cgfR7QbdCgxHMiTAdYZ6yaMlYJNKYairM6DJecVzZQ9oSl9CvPMC3Y+Mj7V+yDDM1 8uPupF/FP1Ske93xmu36wjbQsAc+6HsqG5Y49oq4pphAO6OKKmJLIlRMoxut9Y4S6cAob1K2l8j e3HKLdOgDxsMS3141wj9AgOxNOtbAzdcxrbpxng59RY3AKGSQU2vvIEvs1OiSvHezgrNZhQWBYa LuuUrGDZsYRChOMDovahmJ0FncmO2GSJSJ1pAbGmkyXJ03q/3a6EN0sEF0sZeHw464raM7I8mMI 5CxZbw7kbrvlZmUZrOfM60EIflph3OADafH1lL1vkV7KsKfLJNES2M4qjJwKNuOy60yKzr7fkz8 FD2tp8AvXjQGRbOhSougbNWjMrCkDhXJ0/dEGlZtgWJCrUetds8gOdU9lUXPq8SdZIk7YMoXjJP d9PL6RZ4r+pgDshMGQ6DJ+yCOQ5nuK+rEygkf32lW7PvdJ0B9Qj1lufEAJk9xUX1yeOdB5+RkCI 223MTVODK1YqRC5CVqnYKpGEGB6ATxrElIV7VzWZBKo4/s8L6K/O16q1K7bezshjOCkEtxd9bp0 6Mge3bn1D0xnpkJ5jQBXodYbxSsXbfyzqoCDT+diuZGwPqjudw1W/DfiznkMpdZnoPYdBkRZFYU I7W0r/aPUFzncuQ== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055527_014832_D6A78F35 X-CRM114-Status: GOOD ( 19.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Building upon the newly added extcon detection support, add detection for USB OTG cables (EXTCON_USB_HOST type), and enable/disable the OTG bits as needed. Signed-off-by: Artur Weber Acked-by: Lee Jones --- Changes in v2: - Added CHGIN OTG current limit value - Squashed MFD header register changes into this commit --- drivers/power/supply/max77693_charger.c | 103 +++++++++++++++++++++++++++----- include/linux/mfd/max77693-private.h | 5 ++ 2 files changed, 94 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 2dc273dd96ee..34d68b1050d4 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -669,6 +669,16 @@ static int max77693_reg_init(struct max77693_charger *chg) if (ret) return ret; + /* Set OTG current limit to 900 mA */ + data = (0x1 << CHG_CNFG_02_OTG_ILIM_SHIFT); + ret = regmap_update_bits(chg->max77693->regmap, + MAX77693_CHG_REG_CHG_CNFG_02, + CHG_CNFG_02_OTG_ILIM_MASK, data); + if (ret) { + dev_err(chg->dev, "Error setting OTG current limit: %d\n", ret); + return ret; + } + return max77693_set_charge_input_threshold_volt(chg, chg->charge_input_threshold_volt); } @@ -690,11 +700,42 @@ static int max77693_set_charging(struct max77693_charger *chg, bool enable) return ret; } +static int max77693_set_otg(struct max77693_charger *chg, bool enable) +{ + struct regmap *regmap = chg->max77693->regmap; + unsigned int data; + bool is_enabled; + int ret; + + ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_CNFG_00, &data); + if (ret) + return ret; + + is_enabled = !!(data & CHG_CNFG_00_OTG_MASK); + + if (enable && !is_enabled) { + /* OTG on, boost on, DIS_MUIC_CTRL on */ + data |= CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK \ + | CHG_CNFG_00_DIS_MUIC_CTRL_MASK; + + } else if (!enable && is_enabled) { + /* OTG off, boost off, DIS_MUIC_CTRL off */ + data &= ~(CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK \ + | CHG_CNFG_00_DIS_MUIC_CTRL_MASK); + } + + return regmap_write(chg->max77693->regmap, + MAX77693_CHG_REG_CHG_CNFG_00, + data); +} + static void max77693_charger_extcon_work(struct work_struct *work) { struct max77693_charger *chg = container_of(work, struct max77693_charger, cable.work); struct extcon_dev *edev = chg->cable.edev; + bool set_charging, set_otg; + unsigned int current_limit; int connector, state; int ret; @@ -707,31 +748,61 @@ static void max77693_charger_extcon_work(struct work_struct *work) switch (connector) { case EXTCON_CHG_USB_SDP: - case EXTCON_CHG_USB_DCP: case EXTCON_CHG_USB_CDP: + case EXTCON_CHG_USB_SLOW: + current_limit = 500000; /* 500 mA */ + set_charging = true; + set_otg = false; + + dev_info(chg->dev, "slow charging. connector type: %d\n", + connector); + break; + case EXTCON_CHG_USB_DCP: case EXTCON_CHG_USB_ACA: case EXTCON_CHG_USB_FAST: - case EXTCON_CHG_USB_SLOW: case EXTCON_CHG_USB_PD: - ret = max77693_set_charging(chg, true); - if (ret) { - dev_err(chg->dev, "failed to enable charging\n"); - break; - } - dev_info(chg->dev, "charging. connector type: %d\n", + current_limit = chg->fast_charge_current; + set_charging = true; + set_otg = false; + + dev_info(chg->dev, "fast charging. connector type: %d\n", + connector); + break; + case EXTCON_USB_HOST: + current_limit = 500000; /* 500 mA */ + set_charging = false; + set_otg = true; + + dev_info(chg->dev, "USB host. connector type: %d\n", connector); break; default: - ret = max77693_set_charging(chg, false); - if (ret) { - dev_err(chg->dev, "failed to disable charging\n"); - break; - } - dev_info(chg->dev, "charging. connector type: %d\n", + current_limit = 500000; /* 500 mA */ + set_charging = false; + set_otg = false; + + dev_info(chg->dev, "disconnected. connector type: %d\n", connector); break; } + ret = max77693_set_current_limit(chg, current_limit); + if (ret) { + dev_err(chg->dev, "failed to set current limit (%d)\n", ret); + goto out; + } + + ret = max77693_set_charging(chg, set_charging); + if (ret) { + dev_err(chg->dev, "failed to set charging (%d)\n", ret); + goto out; + } + + ret = max77693_set_otg(chg, set_otg); + if (ret) + dev_err(chg->dev, "failed to set OTG (%d)\n", ret); + +out: power_supply_changed(chg->charger); } @@ -793,6 +864,10 @@ static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) &chg->batttery_overcurrent)) chg->batttery_overcurrent = DEFAULT_BATTERY_OVERCURRENT; + if (of_property_read_u32(np, "maxim,fast-charge-current-microamp", + &chg->fast_charge_current)) + chg->fast_charge_current = DEFAULT_FAST_CHARGE_CURRENT; + if (of_property_read_u32(np, "maxim,charge-input-threshold-microvolt", &chg->charge_input_threshold_volt)) chg->charge_input_threshold_volt = diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h index 4570646e2f33..313fcc3173f9 100644 --- a/include/linux/mfd/max77693-private.h +++ b/include/linux/mfd/max77693-private.h @@ -209,7 +209,10 @@ enum max77693_charger_battery_state { /* MAX77693 CHG_CNFG_00 register */ #define CHG_CNFG_00_CHG_MASK 0x1 +#define CHG_CNFG_00_OTG_MASK 0x2 #define CHG_CNFG_00_BUCK_MASK 0x4 +#define CHG_CNFG_00_BOOST_MASK 0x8 +#define CHG_CNFG_00_DIS_MUIC_CTRL_MASK 0x20 /* MAX77693_CHG_REG_CHG_CNFG_01 register */ #define CHG_CNFG_01_FCHGTIME_SHIFT 0 @@ -222,6 +225,8 @@ enum max77693_charger_battery_state { /* MAX77693_CHG_REG_CHG_CNFG_02 register */ #define CHG_CNFG_02_CC_SHIFT 0 #define CHG_CNFG_02_CC_MASK 0x3F +#define CHG_CNFG_02_OTG_ILIM_SHIFT 7 +#define CHG_CNFG_02_OTG_ILIM_MASK 0x80 /* MAX77693_CHG_REG_CHG_CNFG_03 register */ #define CHG_CNFG_03_TOITH_SHIFT 0 From patchwork Mon Jul 15 12:55:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733500 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04596C3DA4B for ; Mon, 15 Jul 2024 12:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8XYGMuF1Px9oyTqZPSe/yTfw7ie0wV1T6OCEdpBxL0w=; b=T5oyhFW6ZVbiJsTbINz7hvqf9A ReJmtBdm/Nx2CW0aXIUwuke7P338DzQHWGnJgLj+0hG1o4CuEq+sOoViHdttq8K5/OA3FtMTXxcDq AbmzTsJ+0iJeOhw+GgzZS4PVzwcc8e6la0d9kaSKs4LxdKwtIP7RvFA3v897GRo/O8BIjTOWggbav TwRvJ1DW442T98rN1ge4QMeA+rkxy6Mixzd/kDXnl34A5l/jZwmAmFhUZIxa6N1yAlbsyS+us+ppj Bxj+lv7W8jk1wQQFz7+by4Np1ErvBmxPWreT8A5U0vwbiPTbDBHyUO2579reIxGZXsOBo3JI3sBiQ 63oz6ohA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLH3-000000077Qw-0JYQ; Mon, 15 Jul 2024 12:57:49 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEn-000000076Xl-1HT0 for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:30 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-58b447c519eso5690989a12.3 for ; Mon, 15 Jul 2024 05:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048127; x=1721652927; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8XYGMuF1Px9oyTqZPSe/yTfw7ie0wV1T6OCEdpBxL0w=; b=INy34MWM9XZGq8r8BFBMlnPMA4BmdJScdcd9mVhmcpQzI84/IjbT4g/mNszpmHUW4J rDg4j77AJzjqIFZK1pTLQzjznqGcR7eocKrGgrhdTFqjH5PAb0dzbLMXKmysWspFM6vM tt3b+qckscwfXdG7lm3dgg8dk4Wyzr/fXrvH+b9Q2Cmn/9zI77fQp8xhZDy/l94aH2EZ x/vCqTOKAkYISx/30x2qsaNxAaEFmDFL6KC6dRyCv3wQjYIeG4xNr/pHUrYU2ky1UQLE PaDKe8GbE0kLWK6xsKyFPhEAlDhIPMiXUNn1Ag5d9YxQiLm7WBO0dEHvWx2z4C79hwtV PIRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048127; x=1721652927; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8XYGMuF1Px9oyTqZPSe/yTfw7ie0wV1T6OCEdpBxL0w=; b=nTD9SB1scujeRtT6azQy/Da8l0BDp/NAuQiGRThbjqFgcI3kJSPCP9zL6e5WWHkjXC nJu7j8276YrO/SLLWLBuKJiB5V9b1BhZJ2WSkzUwba1pyRmj9BLEVTjKJyJHQHUreTFY zkka6eCaILyVLFE6FwjImtBnnVpuPISUz4eRs4IdCGnvSfj63hvu643G9yUlpjl/1BJO kCIEzqk2vYfttuaE4vHP6WCfSH5Tty2sBERtcZgCYxVq5j27z9gTOS0kfH5jYPb1bDqM JKXsE5pHGK4fGrprNT6I30Ky05qfvMyreo/c2aZ//zB5jW1eOIbQ/NiSvLpPS92ayqQr /oBw== X-Forwarded-Encrypted: i=1; AJvYcCUhItjl01umigen1ma9SC8LzWK/G9S1hr/nj8IQSG4S6rhiGOs/n97AQYGcw/pRG6uus35tl0Te1J76hYOcwsqOpS6duYu/1uVV21nyu/lWdiUccpA= X-Gm-Message-State: AOJu0Yy7odCHMPKfPjKrSGPuzaTPanI/PhDbLZj638LeSZ5y4QJdqj9P Bvq5jkR0WGfoM2SH6TAc9VsI5B3WVX8IHR0sQ30h7CegqdShI0W1 X-Google-Smtp-Source: AGHT+IFmHSVvcKYIfet4Vd+j7mQCt11AG4ZGYcRC6ZqhWGgENzJ92CnMf6jnirVTsXjCdmjb0Rdetg== X-Received: by 2002:a05:6402:2353:b0:58b:1737:1143 with SMTP id 4fb4d7f45d1cf-594b9b047d4mr16175281a12.9.1721048127126; Mon, 15 Jul 2024 05:55:27 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:26 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:10 +0200 Subject: [PATCH v2 8/9] ARM: dts: samsung: exynos4212-tab3: Add battery node with charge current value MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-8-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1385; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=qWV+h/xYbFz0ncn8qK2kKImU9+PgmBKdHlR1+5460gc=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwqz/mNBhtmHMjP9x0SegLgvHeyjSasKP4io /Ot65+rEcWJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKgAKCRCzu/ihE6BR aE2xD/0XcYfzNUnxcW31v4agx+YsQLMSCJvVejsHdSOgFuf+5W50fQwce8+oElnO+jms5rNOAxr bkU3c5zJOd7nuM695tJTUJ+1Kh0v3Gf57jhb86dHgiYq0fXIteWyGyX2jRGU2pSNg9gH/Zz1eCH IWXUV/eoXvZk75f+O17QgoX2W/noowMHOwwlNFM9CukLbCoE7t1a8pTRvIlgKg7l+5HQRe3JghA GJVfHucjWQx9+4KjOolKOJg/Vozo6ansJrmD0vsEPGD8E16Ob7vXk9aDt4xuvyqELKEqB2J6zHm 3528VHJ8tYBV/U/tQ+fV0jXveYUJdRQxi6sCWMtXSdOWka8M3cfjQfuyqO0tljBa3R3ZAdnRS/v d+7ZwyEkv1g5XtdfxfYCXq9qbOFvf15BBZ9BCMtHWYwI0qhTiHUinnxw5flSLJgmXprV26JPLyf LjR2IfOUoLqN6SW1NouTOfIn9uUw+3YdUs6obQgu39FhnUva16GL/2xVevNf7wlrlvflFPfJRKY ZdK8ZaeUTcW37nwNBvKqs7ZEZXRGYovByT2w3SLe2ASEwRdbbEsxOtvW45G5V1HjJi+ydpiPKQ3 Spw14yinRB1wu/6zmMBDWgfUXT3UdS022XroseU6wIENBoebyHjSIv+zeNyDt07Gkf9+/tzWdET Wcg0439UjsJcHEA== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055529_380235_C39A5701 X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This value was verified by comparing register dumps of the MAX77693 charger with on mainline with a downstream kernel under Android; the value on downstream was set to 1.8 amps when charging with a proper charger. Add it to a new battery node and pass it to the MAX77693 charger so that the fast charge current setting can be used for charging. Signed-off-by: Artur Weber --- Changes in v2: - Switched to monitored-battery --- arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi index e5254e32aa8f..7905e33234f2 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -153,6 +153,7 @@ charger_reg: CHARGER { charger { compatible = "maxim,max77693-charger"; + monitored-battery = <&battery>; maxim,constant-microvolt = <4350000>; maxim,min-system-microvolt = <3600000>; @@ -294,6 +295,11 @@ submic_bias_reg: voltage-regulator-5 { regulator-max-microvolt = <2800000>; }; + battery: battery { + compatible = "simple-battery"; + constant-charge-current-max-microamp = <1800000>; + }; + sound: sound { compatible = "samsung,midas-audio"; model = "TAB3"; From patchwork Mon Jul 15 12:55:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13733502 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DB39C3DA4B for ; Mon, 15 Jul 2024 12:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g142l+1Rp8I4V1ReaaLX7dN3MJPiIMAN9KWL++3gC6o=; b=dQk1T6io2D0Y5cG1EpRdHUw6pk 98eKFq91vfKPCrLZ7PU7tsgwW4kPDqJGeNM24JH3RmP7L9mT82R/cmkkbjxp8TAPswIMHdnJBlg1T C0sgfJ1OpuO/stvbVBI13z3dSHqk8I+e/lJgpb8SBQh/s3WJx+5voBqxbwcGee9KQOYadVHgpMTqA cKxoSuZzX0yqgfaq+1QBUK1JvuSnqVZ3msvb6KUXyAGNe5wD1PJX6525wAFJpHTRwASsPcc8lLEIm /UCLhnnYvLudfV74OAvtzWUpGzfXids3VDR6dRUbux6dTg/rgPrVdsd8tA19H2XwgZY+R4x5tZGSd LbE9mkuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLHb-000000077ff-330s; Mon, 15 Jul 2024 12:58:23 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTLEo-000000076YB-4B37 for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 12:55:32 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52e9a920e73so4753677e87.2 for ; Mon, 15 Jul 2024 05:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721048129; x=1721652929; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=g142l+1Rp8I4V1ReaaLX7dN3MJPiIMAN9KWL++3gC6o=; b=WxT599SmmnEM8kz6QJTBg/Avn4eAAN1WTYyZXQi0knvgJnBtVR+AusKmgreTJ7Wy9p mneeXkCYm1+pvDDqFxmS4PwA14e2Baf3tuVvaRUbaSyg4g+Y70oUqHzGpcgIqu+iE9QU ESfNn3stBKoSnxNyWz58wDnXeeeOVooOA8SJiNCS64hpmgFyDY+mSzqDW1dSD4MVD8Gd GbBF6/neCKvWx38QY+rtuGERUjCRz8bIenDpoLg/Z7JaH62/BitN/lUoM71XMxHCrC6F Zb9fPju3ew8hLNK/DDQ4QjaQ3Lmf2IG+RluNin4kKCjobwt8nd4+SyW7Ad+WSn9hcRbd qnPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721048129; x=1721652929; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g142l+1Rp8I4V1ReaaLX7dN3MJPiIMAN9KWL++3gC6o=; b=IQPu8a2Xo3yvT2vQXgbwQXkgCU0cmyH+wRS99X81qqxLPcRekxniiM5g2MuopTNfky J/plTcDQDTn159OAmt8MCZjEGJAJgps8PBVDurBJ6dAiAQhhCJ+KOx2Q29JDa36xnuD2 vo0Korazopq/hnjhB0NZDnI+GwBfWksk6KgxKf/X+O+QhLkg03mSKMTQxjHdYlkbeGwh Gf6mG0By5xrGV/4JAmdbqeRWzA8557DAocI0Tn3X/GPyQUzfdZFGLc4+zzXXlr/mx03G 8lz+Ttm7GKDVHv8sInlWr03yvPH0M81eZJ0nof/qS/WygKNvXahLbzTNHW82m0Up/be5 hPBw== X-Forwarded-Encrypted: i=1; AJvYcCUPrLFg70UzIV7GpzpV5D1c6DplD3p+kmtnzNJJHzbanxp83Ncas4UOg0hW4w/0lzXT0/nM3MEt/vu8LPjYfsbdqtYuFZzdBrXEgDTLnzSqlhushHQ= X-Gm-Message-State: AOJu0YywWjqUktdGwRjBcnryXsmogevEtBtqFGLQ7RR0P7tNfr2bVzmd 7u62pXTD857isIB50gKkdjd990T0/sX2Us5Isj7+Twes0IpgGrjg1RwjGxET X-Google-Smtp-Source: AGHT+IFx8MQcTRzx3JN+U8ZxghUQcdnvTgYnKydFLvaBZKUXf4eaprXj8MMYOE+oITfaurUMxJRBMQ== X-Received: by 2002:a05:6512:2247:b0:52c:dec1:4578 with SMTP id 2adb3069b0e04-52eb99d3d82mr11609664e87.60.1721048129043; Mon, 15 Jul 2024 05:55:29 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-210.multi.internet.cyfrowypolsat.pl. [37.248.157.210]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-59b26f62165sm3333307a12.87.2024.07.15.05.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 05:55:28 -0700 (PDT) From: Artur Weber Date: Mon, 15 Jul 2024 14:55:11 +0200 Subject: [PATCH v2 9/9] ARM: dts: samsung: exynos4212-tab3: Add USB connector node MIME-Version: 1.0 Message-Id: <20240715-max77693-charger-extcon-v2-9-0838ffbb18c3@gmail.com> References: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> In-Reply-To: <20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com> To: Krzysztof Kozlowski , Chanwoo Choi Cc: Sebastian Reichel , Rob Herring , Conor Dooley , Lee Jones , Krzysztof Kozlowski , Alim Akhtar , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Henrik Grimler , Wolfgang Wiedmeyer , Denis 'GNUtoo' Carikli , Artur Weber X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1245; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=JPvmuWMb9Cv6qRz3cEGIn/kWuF1SOLW1hi0UXwnEzKQ=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmlRwqnFSOEjC8QWSCPslauoOTiO933O3gvdDEc e3gOsFdVleJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZpUcKgAKCRCzu/ihE6BR aFmxEACYfKH/GNZtUBx1ayE51+WDZH8Lsh7YCHzX0J0u0GIF7sy4e52YDmnH48GfzystWyPPaXX 4tChxghI0ZSVFts1vH67Iqd3zBRaDCJkHERejtV5sMP6QIX5hSlqD8pj4OAFPecpgcJG3dT+pLj IK330kJ2pKG36NHMRti2HiX1GtLzdG4YL7EakFGVo79x2s0V1dLXYrUz8BGFpeEDT9sHnYVA/0x wKkvzRnSWK+aGj0Hj8AQHaC6z3+0J0sJin+VltFKpxLIIFuQtVZJzz9YXH+bpaHPg2oBBf6ixhE jReLMZEDFWSyt+bStQBUW6pp3ZB7vTx89JFQh1l9eIzLwufABxHIWWcKBcK1pBPGaWE5T42vLcr tfLeyEG9XJiypKn6b9SPCVsEvulMQ4y/zjhOZhiLht7qe3EtHkEEex0SAOKD1IGsR01bVhnOtfJ f4ojHCmJMu58yv0PLcKYW9JzCEW4zVp3rePVQngPLpYhCbM+iskfDyhP3z/d0aiBU05GojgWItf j6YyJEC0wpDsLiLDZF48LEMBb6sT3LjQtHXcME4t6fJeox3Nw9KPh6Dh9s40VGQxSzETgSd+i17 dB8Pf1NRrzuZ0lGjYPXjfPTh8Vo2SMTqsGlijr2xWVcWYxXZN0cKKoIix6fRrngVy79JzpYP1FL tULnfR+O6VXKZxw== X-Developer-Key: i=aweber.kernel@gmail.com; a=openpgp; fpr=E663000EAC1DECCD6AD2890DB3BBF8A113A05168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_055531_069912_07A1307D X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a subnode to the MAX77693 MFD for the MUIC and connect the USB connector node to the charger to allow for charger type/OTG cable detection. Signed-off-by: Artur Weber --- arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi index 7905e33234f2..f5ee3640a940 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -151,6 +151,17 @@ charger_reg: CHARGER { }; }; + muic { + compatible = "maxim,max77693-muic"; + + usb_conn: connector { + compatible = "samsung,usb-connector-11pin", + "usb-b-connector"; + label = "micro-USB"; + type = "micro"; + }; + }; + charger { compatible = "maxim,max77693-charger"; monitored-battery = <&battery>; @@ -160,6 +171,8 @@ charger { maxim,thermal-regulation-celsius = <100>; maxim,battery-overcurrent-microamp = <3500000>; maxim,charge-input-threshold-microvolt = <4300000>; + + maxim,usb-connector = <&usb_conn>; }; }; };