From patchwork Mon Jul 29 17:47:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745512 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 87652C3DA4A for ; Mon, 29 Jul 2024 17:48:52 +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=pkEdD4X8B8T7oknY6aCSNjWcx7qQc569zwNW9DTeGn4=; b=Vh46qFaIK/XVtOdN23n4hOF3Ap kJ0Dwmuhr04TaqBXxr2skCTu1WcoMYEdErqWh7b9YXvJu8GrxtGM6O4vx6Z3x7WtCYSy5587fiZbw W6pawKwBfjQnwOHB02xC8Gg2tpFw0SSHOGLKNz5osbN2bEcCA3WJyv6gX8yHVvqZ7mERgIpjEbBbK f8kI8mgbcBzNB7wyNnlr3Re7TjzbvR32VG0F8rnn70Hjd/oEs8At0BwI5SCWuVFYC2sL5iTvvXQnz Zvcbqy9Lvm64EL8/0WNVlPcRUWGh5ESSu1b+7srZyG96TdepSm+juKn2RvPt+9M0E7L2SvWnPhvUm zRnImO6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUUD-0000000CFS3-1jDL; Mon, 29 Jul 2024 17:48:41 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTP-0000000CFD2-0Kkz for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:47:52 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4280bca3960so19634095e9.3 for ; Mon, 29 Jul 2024 10:47:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275269; x=1722880069; 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=pkEdD4X8B8T7oknY6aCSNjWcx7qQc569zwNW9DTeGn4=; b=AfM3+wCBLmQenqiGGP1Q4BUjzki2MCtIbqHwmVbgV9aI/dq3alpQ1kCudfEjKhX0yX J/iehlWF9Iyl+fqL5eSGOtro2lesdPdT4nomJlNHU70Jozy7SzjdwQIHlG2VLbxFQcb9 RJDNFhlB41Q+cxTItGW1vOB8BFwDSao3WzAk8/GGx27Oz20GhGb7WnGoQ2+O7D9XvHwh GI8K4HdRbyIc6qVzaXrPeJ9jnbim5ouw9Mfr3XBx16Vp94ZPwefJKLkCojZrL3G+fPfI u2EDhdANFHe/4aGCSIsYfMLwuIq7We0kp4L9gljdpB4JlNR+JZvhIkkysneAZG6ZSDQY VOAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275269; x=1722880069; 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=pkEdD4X8B8T7oknY6aCSNjWcx7qQc569zwNW9DTeGn4=; b=iNz3LQJZoGrTQfoCUnphAsyxllREngAtODMsMZh9G3HlWepIIUiIosFKhb1ufz6faY G8eZXSSUdPZ3IICOorApkWeQ6KazWl5vjW5AOek4tiUtJHHzimjIO3QZEZ+s5pEuglgx mCVzXxb6IGvIJ0aAyIU8ea037NYtHJLDXqx+sS7KFw4SRWSCk2kDPUyNgX9nabo5+9ia sKW6Owf3tF7He8IgwVMkiQSj53BeDtL/H6Jo1RAX2swp368t0Bw+3KwyDtkFyY924HxL IweD8o1WS3CIgqu1bAknpFSfUY34QMLntXkRtCB2eraWcls5hPNkgFre8YW9B/lUz0QL cEXg== X-Forwarded-Encrypted: i=1; AJvYcCVRAgJu5ybrc2AfRAkRiMBRR8C+5zVGncVrE34piO1l7ZM2QnHSf2OqqXi3Cl9mDrrIl9VG/RtbL5Gr/AmRTEa6nGKtlkmxttNk/bZxN39UFlpADbc= X-Gm-Message-State: AOJu0Yy+WhfICnreYGiuVEsvZkoBy4FT1mrHTg/ZaKO4IiniboBmXMAz efikhV7WUy27r6U+MUiS4L/pAEEinZN+H7F/llOnGPCKbx/mmgdioNz4WQ== X-Google-Smtp-Source: AGHT+IHFzA3benq6KmvJSdWIZUCEBHfwHUXl0n3vqkbeclIfATIrtxzc4QgIEKoGiKCBOyXFMfqm7A== X-Received: by 2002:a05:600c:3111:b0:428:151b:e8e with SMTP id 5b1f17b1804b1-428151b1210mr49714045e9.10.1722275268565; Mon, 29 Jul 2024 10:47:48 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:47:48 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:35 +0200 Subject: [PATCH v3 01/10] dt-bindings: power: supply: max77693: Add monitored-battery property MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-1-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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 , Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1519; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=XiA66QrY1cKpyMYoVlkQgoD3V8kx0+u1J/F4sMqHt7Q=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W+hyYirrvSUUSF/Ig46ckgslOodqZNCsTXs HIu6j1uHgyJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvgAKCRCzu/ihE6BR aKdLEACEQ9fwZeu3U1x9GzFDQA1ODMTVTblEzeQV40qOmlcuUnUymB1ZCfwC9jtoV6D0YMFm6dQ WGScggQQzjgIIpnY8M14jStpnw8AndMqgNJaU//aH5veKVjH0QFRCsp7Z9aSFxuJHJlt+tTwhC4 n+bOFdOOzwHFHJe02AKohvRLQxb2/EvWGlOMXnxVJJ57SoPBoLgpZGKGOWp2MWd+lI516sHiSD9 xzUtI6YkUN92UqD3Vllno85lhJYjtHBt9L6XvmWlHiUSjVn4x7uSlWQjNy5QJH9AITNHpF7RMcu +Kx7rKm+2gyhmUnBVFVFzJqjcorolgjQ1zDpjTiKhHPFqcJPH/9XcPxXrvrOKyADBMosdgAkG6a TnTR7D68egq+iIntelaLLKQ7z2ha53ToJi4Lj9XTH84OWpU93pMq4tFhyASZYZHV51OJQOH1TQO 6xYvl1bXJ3o7IFCPe67ITcB9W5Q6bslun+sPvii9Nb0TM8MJOk/ggPi1JlG/OyXPToUNoWWmDOT Qsx5VRrsEFGB/Q45VAo2gNXlx8hhSJQGZ6msiq4u9SEn2qvyJSD14ooCys9v1ICgcHQF0U1ItU7 Exuo42lFDdtVb03bg8dLoUJ7zO9ZBiKhFle6I19/G/gZHoPosmJPtaNu+c5alDerneGhPI4nbBR LRajcvaq+/TmC1Q== 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-20240729_104751_177545_9D654B34 X-CRM114-Status: GOOD ( 10.76 ) 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). Reviewed-by: Krzysztof Kozlowski Signed-off-by: Artur Weber --- 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 29 17:47:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745513 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 5B71EC3DA4A for ; Mon, 29 Jul 2024 17:49: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=q8A9U9U2zXyxIhJ8IYiTm4hZOre3ql1iZbJoL53+qxY=; b=tQLXx+XTUQDHLKdC5j3dy7UPH8 uqY7DG3E9xgbqXQ8CnD89x8jSSH48VUyUXbZT88z2T/Rn1D7z7l518Cx0w7GZIgs9oLWz5bMNTdPy GACM3z9/mg/YPHwbnsG+KiGEyVOMPEc/NNycQyAqLLBUNNMJHQ06/GOFSm+wly950B7uo/Y4HUv76 CopBY1iqVAXvEfGiTw6klo5CyW8I9eWr08Xr/A9ij3LKVFePebtGDlisPn4NTui9BCCUx8F9mMBcr MiMQKrRH4wYB7+btCrvOs1sQ7WFMlmOdlxK+R48LT7W0RuZSqn3GLH0SzBFaovpZ5P7hy+OOqqhCC VHgQpu5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUUb-0000000CFaS-35pi; Mon, 29 Jul 2024 17:49:05 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTQ-0000000CFDe-1TqP for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:47:53 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4266dc7591fso17748025e9.0 for ; Mon, 29 Jul 2024 10:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275271; x=1722880071; 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=q8A9U9U2zXyxIhJ8IYiTm4hZOre3ql1iZbJoL53+qxY=; b=Qt1mLj02BOok5Z5x8f53nErdgjxWA9Syd5Gt7vlIWs2G/GHtsdspFA6RcYdCtRjE6c TXdS1SGepwxzaMSnnlJB9Fxay7qeZJKbRDUZkENpto8Fog0lPhBp5cQ6z6xO2LkzQjYZ KuEY+k1VXM/6kcqiUU8Uw40YeqNh5ZxtPMLFCOMmtZb7fq55RMeMHfbEYBYEZ0Ajumz3 AEhCzLDYO9FIRZZ6jxS2dzjetzxSQayDpfBqUf8kB9xPcZDnfHCmgF2FVmqiwvm9gmcM RfXJ9yOmVjgLT03GjLdIFr6qRqov1oDBgPCWdP89jd0o8xbQ6W8xm0ndvZIV6f1B/gjK w2+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275271; x=1722880071; 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=q8A9U9U2zXyxIhJ8IYiTm4hZOre3ql1iZbJoL53+qxY=; b=fmFnRhFI74MBzRMEeYTtAtFTOCRF3oI0RPfng4Rf/LWOVlG27Kh0p3TlLWfsAIFgcw uXXQ5UHoduKlQjnZpqw1HNHiGVHce47g6ghxN7+BF4ipg1sWWzglMWBF3TwH1M+oGW3/ wEM0GdIjBdjaLRjCmomsRVkxJGEspdeFlkiBOKvOtdIZ5Fh82CKmnxExOmnaV6QWavM0 tA25hwNZkxaixn6+99kZBJ+sN4/vOh9sgubqUVKwJmmSRQ+VMxFs9l8FEheS+5kaOe/o 1AwlzHEvt84lnNRvs87eMsuroCPXApURWMJfXw/Dwu/IYc9y6MFTzScMKNsEhr1fD1gC S+wA== X-Forwarded-Encrypted: i=1; AJvYcCVigBtWKRnAXpuuOcyzUAgSmjwjKSGu9L7SiKdtuxoSZK3sp2lPDFQ/tyA9FP+3CooEE0t6+vcdEkRmIJDyz+FQiMltY74Ghk8zCfA1WCpakr7UhzQ= X-Gm-Message-State: AOJu0Yz1AD8yx7GC8gPfA0LvDsg/l/n4C2SEaqHyFod6M1rfOemhE/h1 K6JMgHa0V1UIMV9Rf272s3jNLQGvqw2uiKHTwIPwp2AkeeeDkU3zOl1+Nw== X-Google-Smtp-Source: AGHT+IHPnUSYUUKoKD1giWKdNsD6VWlt+JEHo0COx0IE3UNhdpfTFufcmAo/Dq8KAy3Q7SNPCquEfA== X-Received: by 2002:a05:6000:1187:b0:367:9b22:28cb with SMTP id ffacd0b85a97d-36b5d0cd7fcmr5073453f8f.59.1722275270802; Mon, 29 Jul 2024 10:47:50 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:47:50 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:36 +0200 Subject: [PATCH v3 02/10] dt-bindings: power: supply: max77693: Add maxim,usb-connector property MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-2-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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 , Krzysztof Kozlowski X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1130; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=yzTgncn3XdYXI4m/F4375wxDu8sKiX7IBaYFauYToLo=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W+sawbz8cJ5RE6MNrwl6jBilwZCozFV9tWJ UhRapd0AtSJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvgAKCRCzu/ihE6BR aLXqD/9tfY6O+3BaP1LQ5Y1zm9dJLXER6C0JByIsD7IiDknaYifkHoUQgeCtx+xOYkUv6EkH/Jd u0glo9QAhhR33VMkoHNaJmO6ZXxwEpvabNWr8HvAeD+xoKVCjzoURPElsTtJkQPSD7W8Aw0Fz+6 NHxC/xitsseduCLoi+smFnVSFTc/YdmCxCFKJaIvFFKeWlD9i5hC5vh4U0bgxTWB+1NCRPJZmTE lE4ZoQi86w3PjCAFJ2iK1N4RKTtYcGZzMl5P5ijkJz2mYhEXJ/bqrv7UyBdc95AtUC6ymPqRyND 0+17UT8xFVVWp/Di+3JQiaSQBMUoScQBcJunU/OMra2gN+lneZHooOkm5eBgR/YGcUGhJdDyzjl NPB5w9oOtQo89mDsQqiIZzqbzC3mvQW4LGPW4ssdoCVnkyH9dM57Fn66njrf9eQSbmVjTACCFKB lGaatkEadZOPSr8M6aQ9V3svNQz+Rzd3bTpx4XGLbfS9DqoGupLI416BtGe76CL7p12ojxmxa1J /l3bjbIDnPCc7kzW2ZjF+UrT62gekq3NuccuMje3tlLjvNDwsH7LDYQYFKkJbT06ZT05pZuk6en 9pYe8uBO0ydaffRAR4M8jD0OqjGI9p/QVN0xSaIFKmDbJNV5rIy8vm0/B80NlANNPU/H3s91Ves 4OUXGKYFzxD4nnQ== 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-20240729_104752_440228_2564AFC3 X-CRM114-Status: UNSURE ( 9.73 ) 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. Reviewed-by: Krzysztof Kozlowski 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 29 17:47:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745514 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 C13D0C3DA61 for ; Mon, 29 Jul 2024 17:49: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=V78HK7/KjvVm6vb5sHb4eAgphXUZC6leMWsDQBJkLes=; b=ZurCMfxuBcOPZPa9nmLjz66eCp l0aQXGBBtNmZIBfRWIdkLQeddziZaF7KBnTw6CMlPZO9NQuJZs0JPKA702IBhgp25l6yzQKFJT2Gl 0Dt6kf3ZVK3ALLbgAHgkgFp+FY4bTL6KTOBfYgl+ST2W6RVmOksX+RaJ/z7mhH/fpZIOV2EnzMVsU HJw3jYul01NupCfIOObOkPmrTk/QKx81J5RTN6/6pSufXSRr5OPmrWgg+Z1h66Q8siN3xWZjNtY+L 0S2WVgWGip9q+VoQrb1pFGxi3VBf5WjTJsI3CGt16QHAMVuGlKsvzWMG6FkdtiS/nBDXHfiEhrf31 KUyH+eFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUV0-0000000CFk5-1BlL; Mon, 29 Jul 2024 17:49:30 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTS-0000000CFDz-3jo3 for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:47:56 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4281faefea9so7055005e9.2 for ; Mon, 29 Jul 2024 10:47:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275273; x=1722880073; 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=V78HK7/KjvVm6vb5sHb4eAgphXUZC6leMWsDQBJkLes=; b=NKYK2LtfxPbE8F1HWRzib0NY/t+n9GfpM6dtG+zGnmJVIejWQFOlrhEgoZ5m6Q79Su XTdD415/hwTry9TnX2KP2/n9oBn/+PQA/aO+49eQu2OGaXB2TDPa/uETDP72pKBgR5zg s3SkTcaEzlwvvu6N88ZpH8hviM9zE+Xg6joadv5kP4gkb92Rv0UShTYtylHs0mjWzhSN yOx3Rqa+8RRBBM5XaLHkvF3Jdo8dEvjTrMwuC7ZYpll8SUlqrw6n3A/4Elffy/Ufdw59 eXnfPLIHuOx/j1dTsA9BtxVUYniFUoYxIVMZjW/G9A9dPQM3vip2tNwo0SCyBFqXDRhg 2Jow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275273; x=1722880073; 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=V78HK7/KjvVm6vb5sHb4eAgphXUZC6leMWsDQBJkLes=; b=XqGZX/AiCzNEzXP39vJftIyvnB0yCjhW4tE1ccBrWqay0F15JZDqRD+oPVxoh99F4N 3qRj/N40RP25fRRkegje77OEm9hufyOfB6mun1WSaxpxc7mkWo0hUmuXsDZ8I3LgrNpO 3uCzb6Nm7epNz1Pexi77avjhQOIMLHjkKNu9GHZJRY4qumyNuj8H9oe+eXIyM4UExasH I3dcQSADelh8oOVHY683XePXiesbBPbTuCPEhIdjCUau4KMEsISV6ZsExtZaUvBcteqM YFDlYkawNaAQXMuiUkFDI0SEI572JUIuxQK/LxG8IhClN3cZE5mDZd34j4znObU+nuTC JpnQ== X-Forwarded-Encrypted: i=1; AJvYcCVMou1Try9L3ap+ReNqG2lbqBSVG6rkAYfn9y4SaWKCR4hfW27XmmOLG2X8Zhsc3B8lIdJ43VMJxAL6a5TtLnSfcLN4kyS+QFd8sFrjKewDYdAufwI= X-Gm-Message-State: AOJu0YwEjI89+nwhFTrabij6ry6C5nxcNonCVxi81SwouryOvkCFvbts yxbVZur0ufEl/8m8kM3WFKfhvw9C3LVzJ+igXxzzdIieCRDbklEo X-Google-Smtp-Source: AGHT+IEzVP76gvohlXqS0k65XYNrnFnMn8umFHlR6ZRiwhlX5TiYE3+UjMPQEbMDs5Lg4ZBPFvjCvw== X-Received: by 2002:a05:600c:444d:b0:426:65bf:5cc2 with SMTP id 5b1f17b1804b1-42811d83c38mr55420585e9.1.1722275272600; Mon, 29 Jul 2024 10:47:52 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:47:52 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:37 +0200 Subject: [PATCH v3 03/10] power: supply: max77693: Expose input current limit and CC current properties MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-3-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4220; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=64p2zb/TO0sOXA+lVtMC+Y+6Z6xHMlhCGgkfq2NJimA=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W+FIRTZ3IhbI66s8PrQ4IXSptDHnNOxsMyV WSLOBGxHBOJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvgAKCRCzu/ihE6BR aHZMD/9gIYbg0pjl+8dd0ysmLc8mn2G6E4B0A6WBIyXtqxy+os7tJFlstZV0b5U4PjpH5vc0Bhr XTn3vMyF57qrKl2l9GUdF8EuCLT3nzORYFY48FpzDF52LYbv0ILSHQbtLm9AqimfiXO1kLyDGM3 DRX5Sip3GNeTtx2c1jJ2gT5GvqhaZMbq4HcLdZoIka/dcf18KYp2SfxouD+KZMNJ1mFS46wsl+Y 1b+BW8eYRA7nk+961BeltF2Nc1R1tpvXYEIL8HfwS8mliQg4qHVc5+gd11RRtF340N3SCqINLF6 hn+4uHnwqe+o5ZNOymmWAwn1YIVdE+FykoSw2Mi+8SN/ObmY0CcEpL7klcNarlv/mDbAvE3maEy 8C7uJTZi52qFMX6U24DZvAfirl8QJQUXQT93UTNXwxiVsW/mcZ0E/WNurBi6FYP8Rwx3C9vxGS6 wHcPGV3uAAQDT0X2w0xB3eql53cMg4Tiu6iIM7f5cBO5nlCnr/j6LydNDqh89NJ6lmJNJSVDJ6u nEwWI49+yFtJP3pfPqrGyV1EIrqEGH62my6BDszcGPL1sI/1yWc0HSNqHUFW5SQH0n/qPmauXYr phj9eYaxa0v0+figTaItoGzJIV5nktYGzh2zVEqjRtfGpe7gE7Vii5biPuDKwY9I7bE7WSkOhUY k5vLYrei31ScZ1A== 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-20240729_104754_971515_C5D1B85C X-CRM114-Status: GOOD ( 16.28 ) 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 the necessary functions to retrieve the CHGIN input limit (from CHARGER regulator) and maximum fast charge current values, and expose them as power supply properties. Signed-off-by: Artur Weber --- Changes in v3: - Dropped CHARGER reg reference in favor of managing the registers directly - Changed to use CONSTANT_CHARGE_CURRENT_MAX instead of CURRENT_MAX for fast charge/CC current property Changes in v2: - Adapted to both current limits being managed in the CHARGER regulator --- drivers/power/supply/max77693_charger.c | 52 +++++++++++++++++++++++++++++++++ include/linux/mfd/max77693-private.h | 5 ++++ 2 files changed, 57 insertions(+) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 2001e12c9f7d..4caac142c428 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -197,12 +197,58 @@ 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. + */ + +static int max77693_get_input_current_limit(struct regmap *regmap, int *val) +{ + unsigned int data; + int ret; + + ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_CNFG_09, &data); + if (ret < 0) + return ret; + + data &= CHG_CNFG_09_CHGIN_ILIM_MASK; + data >>= CHG_CNFG_09_CHGIN_ILIM_SHIFT; + + if (data <= 0x03) + /* The first four values (0x00..0x03) are 60mA */ + *val = 60000; + else + *val = data * 20000; /* 20mA steps */ + + return 0; +} + +static int max77693_get_fast_charge_current(struct regmap *regmap, int *val) +{ + unsigned int data; + int ret; + + ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_CNFG_02, &data); + if (ret < 0) + return ret; + + data &= CHG_CNFG_02_CC_MASK; + data >>= CHG_CNFG_02_CC_SHIFT; + + *val = data * 33300; /* 33.3mA steps */ + + 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_INPUT_CURRENT_LIMIT, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, }; @@ -231,6 +277,12 @@ 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_INPUT_CURRENT_LIMIT: + ret = max77693_get_input_current_limit(regmap, &val->intval); + break; + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: + ret = max77693_get_fast_charge_current(regmap, &val->intval); + break; case POWER_SUPPLY_PROP_MODEL_NAME: val->strval = max77693_charger_model; break; diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h index 54444ff2a5de..20c5e02ed9da 100644 --- a/include/linux/mfd/max77693-private.h +++ b/include/linux/mfd/max77693-private.h @@ -217,6 +217,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 @@ -244,6 +248,7 @@ enum max77693_charger_battery_state { #define CHG_CNFG_12_VCHGINREG_MASK (0x3 << CHG_CNFG_12_VCHGINREG_SHIFT) /* MAX77693 CHG_CNFG_09 Register */ +#define CHG_CNFG_09_CHGIN_ILIM_SHIFT 0 #define CHG_CNFG_09_CHGIN_ILIM_MASK 0x7F /* MAX77693 CHG_CTRL Register */ From patchwork Mon Jul 29 17:47:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745515 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 03E83C3DA61 for ; Mon, 29 Jul 2024 17:50:06 +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=GkU9a6/40Cq2sewbpThfjNNBiDffMX2eljgdYf4VDTE=; b=kyisfuzD8rJLh6j5Jak/ZxH08A hCZb5oIhMewWs1cpg2Qwqvaf300IwI6f7DHp+l1Qemn107E7aigAIGCB/E05ewQmW+xR68QBbIOgn jhPwcSI0UxqDW/XLdR3CUqNwGbOmlf5NU7lYUNb0Zwtr95uj3dZ4f0RHAiou3IsO5Litep9t3Ijcs RKso5URmzVtN9eeofbVJXK78ub+A2YIxWFcPteruMSkGHO4dBYPGtmv/kgNEzjjU0dTigdJoQQ4di R+CsRtb7IMa2ENkyqzDPyaeYTq83uXORNG7Jw2MMjbOG4M+ed8Bj1pbNLlGdW+UkBqTPEL/Y1VPve epqkZg5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUVP-0000000CFtQ-3kTS; Mon, 29 Jul 2024 17:49:55 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTU-0000000CFEN-3uSp for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:47:58 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-369cb9f086aso1760753f8f.0 for ; Mon, 29 Jul 2024 10:47:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275275; x=1722880075; 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=GkU9a6/40Cq2sewbpThfjNNBiDffMX2eljgdYf4VDTE=; b=AAfT4t2Qjykn1qEF7XDOdVAxBhkgsD3BdnECY0CZMq8HEx/KN/6oifoRrKj4Tcxfpl kV0QEaCVYlLmBRlxkiXVTom+VRGY+lHWBmeAGH+0Jf7OJSS/92Kz7vwd0DJvjjghgBnz XlUB1Ctyc9fer2LYZam9kc+SP0Thr7CXxqQgR9+6YePkCV0IScz6AH6cOD6UPokKQb3g 6puOwypgUdWZkw1G4B4Pl6kOtylpuj9638/Tx1g+GNYTq8WK6cXNkWC5O9aLACNdnaAd Vi4JMSo26UfER5flgryhy1P9CLfP09x6FI5oYXhWYUrKrF9K3fdtd443yMYYhnk1tRl/ Tt4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275275; x=1722880075; 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=GkU9a6/40Cq2sewbpThfjNNBiDffMX2eljgdYf4VDTE=; b=gAPg2ErRuN+l9AZO3cR65qUbKREATg4oNqf0P9UZ0I3XFPnkxmUH+5j32XM70gPNuf /xL/kqbtsPPTCwCKYU0N9JLEhlnWpXJti5TfZkp1dPHnNDQlZhG422/1FjFT65F+HLBn NRKKAGGRdblyJV8O52Zh2cTK9PkN4l8ocFYAfyPXBiA+Ptfs7jxsYxL56Ts6h3nGJ64N DpFdW1qF8nR5roUAirfTGSZPMHLe93v/7eMglEHIMrfv0zPhmU6Ii2RLrcJu01uRZo93 lPmnXDlOOrLLD3qkpa4dvl0v1clHw/TvRtKZKMEjdtHDJFheUh/MipZ0A8rPHsz0lMBy 7yZg== X-Forwarded-Encrypted: i=1; AJvYcCVhsbL9Iny/zolECQ8yFpNa+qw10n0JzjEKsHGrf7dwoxg90LRQpRm8Mm4z7oMd9U52hbOe9tgC+lppZrWEtJ1S2t4YByvz98LUJT00j5KNHJXMXAA= X-Gm-Message-State: AOJu0YzwXGLk5rKJ18Wg+y/Fdl6SEjjfmc+A61xbryM++XYhSETNriTa aEL/rmdH54II92adPFhajbsuuMNXe2OymxSLcSPILPBFw+tTzgF/896fnw== X-Google-Smtp-Source: AGHT+IFR0TVKExWXma+/RVH2Y8BefejhPHw2MxvPw1w+jlu3FgBtpwoZt/l3seNE2pZrcGq+PbICBQ== X-Received: by 2002:adf:eb92:0:b0:368:3789:1a2 with SMTP id ffacd0b85a97d-36b5d0c4142mr5560839f8f.21.1722275274418; Mon, 29 Jul 2024 10:47:54 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:47:54 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:38 +0200 Subject: [PATCH v3 04/10] power: supply: max77693: Set charge current limits during init MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-4-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6537; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=ugq53xLBW+pgJurSinC5JizQ+Kguu470RHyzKlOfZec=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W+wto0WFuOBsXjfJOILo5Flv86sexqYSEUb w5DvgRtowmJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvgAKCRCzu/ihE6BR aBmqEACd4IsWbI8B7tt1kvV+vx5DFYZVlNL7uNDruuLy06xhk4KcIhXkRKxWtpqw2UkRUgG7LOk o3vdAA+uNfNhwKsOgPB+XPXbDI8vU96wE+UZYtU5VT/fUyUYeSJ3UveBB4AfDS2j6boQQD2ZRkL lyJI7lcH6kLG9qZpbeZBDSLmhvhZAwBYty3uTZSh/UZguJcEghFLsl0QEIGiKdOoV2jIu45AIg4 A6sG7gZzwQDQYBMDod7qk/hJiLjo0l7th5yJRDP/io2thKkICtXkBm9QMXOd9GbA9UanD7CJQea aiyaouFJ9zQECJUcau3WTglJBKXZKvTadBUpHmaVwnSLt+hLnG9mEJWssQMtnG4ZdczdREwjQjj 1aiqfL36LhLXusta28qkxvDNlxEUarXienld3b2l0V8lHfXFLIRiLe8d6kbxFeVWw3iWyovR4Cc Jl1IT9A/Z+BbimsqT0MsTsfajRJWP+zyg/4aj1WPiziVYg/bWLp5OfKkQiu6DUDNUyGmxVHAJRL 7RCYyt0LTcK+UgIuA1/lZbvKSsKzrryDilD9tdjImWjyj25L5N37UEdCgEAM8Mp11pfcXuxDtOF PrtdPfAt9bllG/J7Kc4Bs5J353wH045gbzuCgtKEmUtFhwJ2bQkJ2QmNYfNrgmg2loazprzKQp7 knyPhu1gI8meZAg== 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-20240729_104757_012500_6C5EE68C X-CRM114-Status: GOOD ( 23.41 ) 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 functions for setting both of the values, and set them to a safe default value of 500mA at initialization. The 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; the CHGIN input current limit will be set up later in the charger detection mechanism (in the future, the INPUT_CURRENT_LIMIT property could also be made writeable for userspace control of the current limit, while keeping the actual current limit from the charger to the battery intact so that users don't accidentally blow up their batteries with a bad value). Signed-off-by: Artur Weber --- Changes in v3: - Dropped CHARGER reg in favor of managing the registers directly 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 | 82 ++++++++++++++++++++++++++++----- include/linux/mfd/max77693-private.h | 2 + 2 files changed, 73 insertions(+), 11 deletions(-) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 4caac142c428..17975ec69a6a 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -26,6 +26,7 @@ struct max77693_charger { u32 min_system_volt; u32 thermal_regulation_temp; u32 batttery_overcurrent; + u32 fast_charge_current; u32 charge_input_threshold_volt; }; @@ -596,6 +597,48 @@ static int max77693_set_batttery_overcurrent(struct max77693_charger *chg, CHG_CNFG_12_B2SOVRC_MASK, data); } +static int max77693_set_input_current_limit(struct max77693_charger *chg, + unsigned int uamp) +{ + unsigned int data; + + if (uamp < 60000 || uamp > 2540000) { + dev_err(chg->dev, "Wrong value for input current limit"); + return -EINVAL; + }; + + data = uamp / 20000; /* 20mA steps */ + + data <<= CHG_CNFG_09_CHGIN_ILIM_SHIFT; + + dev_dbg(chg->dev, "Input current limit: %u (0x%x)\n", uamp, data); + + return regmap_update_bits(chg->max77693->regmap, + MAX77693_CHG_REG_CHG_CNFG_09, + CHG_CNFG_09_CHGIN_ILIM_MASK, data); +} + +static int max77693_set_fast_charge_current(struct max77693_charger *chg, + unsigned int uamp) +{ + unsigned int data; + + if (uamp > 2100000) { + dev_err(chg->dev, "Wrong value for fast charge current\n"); + return -EINVAL; + } + + data = uamp / 33300; /* 0.1A/3 steps */ + + data <<= CHG_CNFG_02_CC_SHIFT; + + dev_dbg(chg->dev, "Fast charge current: %u (0x%x)\n", uamp, data); + + return regmap_update_bits(chg->max77693->regmap, + MAX77693_CHG_REG_CHG_CNFG_02, + CHG_CNFG_02_CC_MASK, data); +} + static int max77693_set_charge_input_threshold_volt(struct max77693_charger *chg, unsigned int uvolt) { @@ -673,6 +716,15 @@ static int max77693_reg_init(struct max77693_charger *chg) if (ret) return ret; + ret = max77693_set_fast_charge_current(chg, chg->fast_charge_current); + if (ret) + return ret; + + ret = max77693_set_input_current_limit(chg, + DEFAULT_FAST_CHARGE_CURRENT); + if (ret) + return ret; + return max77693_set_charge_input_threshold_volt(chg, chg->charge_input_threshold_volt); } @@ -681,6 +733,7 @@ static int max77693_reg_init(struct max77693_charger *chg) static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) { struct device_node *np = dev->of_node; + struct power_supply_battery_info *battery_info; if (!np) { dev_err(dev, "no charger OF node\n"); @@ -708,11 +761,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 */ @@ -732,6 +794,15 @@ static int max77693_charger_probe(struct platform_device *pdev) chg->dev = &pdev->dev; chg->max77693 = max77693; + 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; @@ -740,8 +811,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"); @@ -761,15 +830,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 20c5e02ed9da..0819cf0a4f5f 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 From patchwork Mon Jul 29 17:47:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745516 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 848C3C3DA4A for ; Mon, 29 Jul 2024 17:50:34 +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=2HtdwOmpjBLvOS2fpbCrpGHSAyy+FDyT8B72kclys+E=; b=BbjM8vSBACOlyMd5XDRXd6DlF+ E77M+4Hr192Ea3OGUzQqSa7wO0Rk7Ty5sBSyNA9tR+OTjvwZIp3vzdF2KltPhWYaFiAGLFmo+6AnY 5DVft4HbKix8Lj5KuKPbj1pQSA1XpV8JUOpOIQ4aur9v1wQCZMFH9lIcbSgWXAp31VEd4MZBflghM RkD5SOifwUc0EM68ll0AgjuabykRnljNra4BbpvS6+8CpNhgod0IJ2zSvCAg9boDex8SU6vcyPbMa PEtljhnBBkxfMcwuo9c62PMgFsvO2yiyLwlKhh2uDEudk1cUPEAs8iru5nhyrTS0P5iNYjVD/PqGU oNv/6U5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUVp-0000000CG43-2krP; Mon, 29 Jul 2024 17:50:21 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTW-0000000CFEw-34xJ for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:48:00 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-368584f9e36so1524277f8f.2 for ; Mon, 29 Jul 2024 10:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275277; x=1722880077; 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=2HtdwOmpjBLvOS2fpbCrpGHSAyy+FDyT8B72kclys+E=; b=EJX6spnJ1zI+z1tRY4OakB+ieiCboBb7sEno5qZs14E5HKFqw4PoNsp+Nd4qBgVfYz Y0ku3Frpr3Ypmsn6aCBfvxQluNZ0lijOs35IC674fLjZ5Ia8Bb5HYxRey0pq8jAflNsC SomqufeaK39Tb5mvRJCiqUkC+gQAEYlG43r6ywc+vcN64DPcz+OPC7fXqDJmm8gU9r6e QB7rKgS7fzvcWpngSYhzpRa9eDIJiuztBME7GQxhXwhBrkMiB661rWf7QW468WarswsL qe/E0wxOoKQtBE0TjLatHFPd0MHDwBXF3/1bqmZabIuVg6zhGi7xS7Tf9ibecoBPhFrW ruZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275277; x=1722880077; 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=2HtdwOmpjBLvOS2fpbCrpGHSAyy+FDyT8B72kclys+E=; b=EAQpFZMI8EW+fgeAjWPxsVmyzB42ChLPtf20wgyvIn6TEyr9dmTbchgWraAtPLvH05 6FqUbew2PL0BHXqBOXFbNZhncq+Oq/B0dJQAKwfOVy9OCLgcPwiuRQKEDm8KWyD0j4P+ Kh1hjhcbnAHfSDMOJtQbucLSWSqvWpOqpkHcAygetRPFpPXvu1/ByvCbXJNpAMtHmLUi MvM0hwlbALpvugpeUwAtqpG/zLM8yhhLWLV4jSd8cpbxrytP+oljaRtaKU/YPE6TsnCO rQaDU1kpYl4i+yVdK1gS0jeUsJWfJdeVIaPqAz5K4gWUxXBxtZEbHBWPE/4odsy6hWlV 5pdQ== X-Forwarded-Encrypted: i=1; AJvYcCVdRg8ZeW+WrTN31G2AUmGP4b652JGiVf6P7k5uoSyiCq67h5medw9HRLT6/t/VyAfC4jCvBLgeVgvDoD0gHtQ3nH4TRHdrD33BXPzX436Aasoegsc= X-Gm-Message-State: AOJu0Yzo9D0xH5o/iR2gJ0dpukIeiCuMBPwBZmc5pjjDxfVqaqKqeVH5 zmYYK+dSEXGy7+Sb7/h1KIMe96c4cXBOxLvYdlZsO0tVoHb8hm9T X-Google-Smtp-Source: AGHT+IEXPCegsb/usx+QhYeqYMMMnQDYD7PFJLzBQ4V90OraTh3ivSEvYAHegwPJXZctgby0WCXN1w== X-Received: by 2002:adf:ed46:0:b0:368:3717:10b3 with SMTP id ffacd0b85a97d-36b5cecf2efmr5965729f8f.8.1722275276558; Mon, 29 Jul 2024 10:47:56 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:47:56 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:39 +0200 Subject: [PATCH v3 05/10] power: supply: max77693: Add USB extcon detection for enabling charging MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-5-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6240; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=hUFm5zgvxacpJc23mhT7FrKD3yHbBhmDgpcXdgKmXlQ=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W+94e4wiWpIzTsI3Ij6g5IB0Ibemjb17sUL behwtd5aLmJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvgAKCRCzu/ihE6BR aBtJD/40NYyUkN0rn818ZUKsEVWXzmko7y+3JmjRKrqf1Gujma+xpC+c1aNdp3MSJtNCoG34BVi WdyFxG6L/pyXrC5+wKQLN+LojMJ8eef1XLZUgkc+u5Z2AEHuhbgm5vQKnM3TTf8U7nt3JmFJyw9 pMWqY9k+am5Bh4wGZWqtwrDEfMPMHeqW91E5gQUK/WLtompl/fL1McSZNUnQdZlza+PpPgEkdFj k86tAxij2P70JVvhH71su3muxbe15Y+dep6QwTE8QMLc3qyr6CjwUtcBcfIsRHkM9I8cWCOZib9 mFfjGZM/sBXHlwitm0IlsLpadSHpIYkifRyhfO5QuhAosbTOF99gnpzpDwDKVqCtTjDV+b9VT4L lMYsO5PjOJMT/6mWMuo6qj2PTrqKHtDjlDLs7Pkvb+sogKVbD4MD3Ym0Fnlm1L8hfUiiy1kuiZX SAftfW9ALzvrLibHdCaVFTCuHsN3AVBNU31PbvOyLJZKj69DjGKYZBs0O/cUHNxpEmLFjUCrfbj wujVGglzh6+h5O744JV313NkiPleJfFZf39a5NydySD6Jrl2TUBFdTyq/0VbzEh2CjfnTHHAdis lyi1yMQ6simdTL2ksElq2EavOsd8XsOm4XQOK3h8TfD+lrlM+gPFjLP6LiUkn99JhXz9Y9Rkpry 0eeuBFFO+Nf5AEQ== 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-20240729_104758_812306_23834159 X-CRM114-Status: GOOD ( 22.34 ) 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 1. Add a function that allows for enabling/disabling charging. 2. 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. The extcon listener/worker implementation is inspired by the rt5033_charger driver. Signed-off-by: Artur Weber --- Changes in v3: - Adapted to both limits being split up again - Move charging/extcon work functions above reg_init - Drop unnecessary extcon unregister from probe error path - Change disconnect message 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 | 120 ++++++++++++++++++++++++++++++++ 2 files changed, 121 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 17975ec69a6a..2e05467c682e 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 @@ -28,6 +30,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) @@ -668,6 +677,77 @@ static int max77693_set_charge_input_threshold_volt(struct max77693_charger *chg CHG_CNFG_12_VCHGINREG_MASK, data); } +static int max77693_set_charging(struct max77693_charger *chg, bool enable) +{ + unsigned int data; + + if (enable) + data = CHG_CNFG_00_CHG_MASK | CHG_CNFG_00_BUCK_MASK; + else + data = ~(CHG_CNFG_00_CHG_MASK | CHG_CNFG_00_BUCK_MASK); + + return regmap_update_bits(chg->max77693->regmap, + MAX77693_CHG_REG_CHG_CNFG_00, + CHG_CNFG_00_CHG_MASK | CHG_CNFG_00_BUCK_MASK, + 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; + 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, "not 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; +} + /* * Sets charger registers to proper and safe default values. */ @@ -734,12 +814,32 @@ static int max77693_dt_init(struct device *dev, struct max77693_charger *chg) { struct device_node *np = dev->of_node; struct power_supply_battery_info *battery_info; + 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; @@ -811,6 +911,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"); From patchwork Mon Jul 29 17:47:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745517 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 22924C3DA4A for ; Mon, 29 Jul 2024 17:50:55 +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=KVY1jXrpCpuLnTI+cr7IUvSFt5/r6cGcoEVasJ6ji9A=; b=mvw5fFIJBnQwmK3SiU6aOX1M+v SRu6pX1ToxdDEXHZ962LYxPoS7VraPjFJfkg0XtK0FUXvR8ptYb3/DKnL5sFN+i3ZAT88CaJ3vmB1 Y5Rspq6IlgY4cUEh3dB85ueeflXOcnO4r7uXgOfpThpTDzvoOAwfShvtjCoTyOO1FFdMPvtE8VpsD AZUk/bd6Nvod4K/kr5tGY5ULY8psvisQbv7l4yRy/7/XvMDn33iRmGMRyFH62tJQL72R+u26JR3mO l3L2NSMNsJ5MXJfCfTgjifJyzl5RocVUk3A5pm1l4pte1uio67J2BNNZU0GdImUyI9bAem5K5aQ36 xF3L3sGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUWD-0000000CGCW-4Afk; Mon, 29 Jul 2024 17:50:46 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTY-0000000CFFf-2GmE for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:48:01 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-368712acb8dso1525890f8f.2 for ; Mon, 29 Jul 2024 10:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275278; x=1722880078; 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=KVY1jXrpCpuLnTI+cr7IUvSFt5/r6cGcoEVasJ6ji9A=; b=WKhTuIlJwDlyQQZJQbiIkDjElASR31pgHK/UIkDFaA2/ZBr7KtjaQTBG74tyq+8p0N ldbAlHnZ4lFaW7heGZoTk42ggRa2uOL9FtfGQItHPMknqHl9Nd0Z6rEW4ijsQ/EKwbjh LrLDSpW0m5iSQJFJS+m3olbXKDhpxATDkQPQrdyC+Bnh7vAkK1ZtZQ+56XWNKXOwIqgY H/7torGx4s5t/tAzzG4ht0BQhME/aXGf4+yaTdZzJFqXcpAM5o8ZOiJDJWDC0CBTWHcM 0wHdGrlmLEym3FNyhy5wV78xCHd/SPKaAM80sp8vzW2vsGsMTe98dDg4l3GgOQax8rIY 3OsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275278; x=1722880078; 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=KVY1jXrpCpuLnTI+cr7IUvSFt5/r6cGcoEVasJ6ji9A=; b=E+bjTA52lc8EDWqapk3MT5MIdFoz5D9iKjSBB+sISSliWAJL25LNBwnegumlGGDvA6 JlTwDQ6o5PTU4xaAfP2WE0E6tcyAm/OEdd2hUSjeCUDHaR+SCduGMVsWXMgJD+ZVlEyM pfu7YLBjjBrIpx1m3emMPD0WDnzsb84FYljGPUwlBc5t35JInX2NciQ+hLlsi0y4q/vY FSgMST8hgYcz0yaGQnhhRp0ZkAva4wjje7+xVBLVw6eg17zEpYjziROrwOvfilsXnpf3 x35i1+fkXi+F2ERj0nmtdF6e/Vfj4tOpnzBAONu7mGgh7Mj2HnObbIBFlLUSXtciQzwj 8lkw== X-Forwarded-Encrypted: i=1; AJvYcCXQpAVUlIN/7OyPLF7A6zxFasCC1f7IBwMRzjBbX+01COiOHpdjgYc8rP6TbbPRlb4jYVq/0Da4GyTDvO7b0GEP2zfnooNFQTzQaa1LaS3DJAfdOno= X-Gm-Message-State: AOJu0YwjEE96SYV5Iy71os6iVo50QsrkWudJixpCpXVNcF5w8sREwUmF sFlQfHtF8gg+x1hAbJPSC6DomogKI22En2wCivIuID1ly/0iGUHO X-Google-Smtp-Source: AGHT+IESUKIOz9EOD4bMAEVsQ1c3gyu5wcJumGnQDHtsVxQCfe0b14lkjpjGizmWJSNEPwvpeg6yqw== X-Received: by 2002:a5d:5f8f:0:b0:368:6b29:a551 with SMTP id ffacd0b85a97d-36b5cee9840mr6605792f8f.1.1722275278275; Mon, 29 Jul 2024 10:47:58 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:47:57 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:40 +0200 Subject: [PATCH v3 06/10] power: supply: max77693: Add support for detecting and enabling OTG MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-6-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3976; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=024yPNon1poyVphR8keDLRzye+FGmZPcxiMYS+/Gw4c=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W/Lu3SRHqrCllRimkJgkfsCB052nicnaGby 3fEjo5pLcCJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvwAKCRCzu/ihE6BR aFShD/9WBNp5/ufqDpQ7Ogg4q0KyeCU9xsAXW84ooiCrfS0a5SX8ZzT2jc5ScfhgU1ZyYuUl7+/ jYUxJzlwD9BdjwSavVI9AH1nBq+wLgV/KNFDy0Iu5flOwydmikW42LdfamtU8VL0JW+sAaY67EH Rr0doikJvv8XipnqngyCW1SI0jgTUsssYFmy6a0ZpitqOH3Wf52+JbOLZPsaIR/FFfi87RY2ZVQ jcuaLioPgV5ATsg37+pDeEMIiwQ5JavFUm48eiaLgjy6naHJ4TdJqj54raQNTzITnhegr6pQOit JPE9XKf0DWqkdMUQTRUyjrrd5QP6QS5CILANFIQ5nOr5PpF/uQOKBnqoN0Mx76nqB8iXStg971k rPF7CxarpHy/95mn7TNEEOnddw5w1/UIN+o9thvdlLtNDekcj9Du0y3MOaDC0Zj0I+ivWwYPu2o 2Q1dXNQpg4N+qQj4QpssFSZgqp5v4MUgnnIHZQUVa/KVlxjMcIDY1jyf3ihgH8LRytX0ev2fnZE Vw3U4H2NMqtUGQoaWzNQmejf+g3SZbZfGsyDNHkI0Jw5dp8dbbsd6TmAkmoIVM7sfss3ibUA2xl 4QaVv2EC8fXZ078HA/xH2qQzt4qFudoKDxXHhYICp6xcXa6OUq17o5ZAKuZJot7UYUV3n1b4ygB 9ZJPzKcSI4ZCXuA== 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-20240729_104800_619213_D2775B98 X-CRM114-Status: GOOD ( 17.27 ) 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. Acked-by: Lee Jones Signed-off-by: Artur Weber --- Changes in v3: - Dropped CHARGER regulator in favor of enabling charging directly Changes in v2: - Added CHGIN OTG current limit value - Squashed MFD header register changes into this commit --- drivers/power/supply/max77693_charger.c | 53 ++++++++++++++++++++++++++------- include/linux/mfd/max77693-private.h | 5 ++++ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 2e05467c682e..4ff402941d72 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -692,11 +692,30 @@ static int max77693_set_charging(struct max77693_charger *chg, bool enable) data); } +static int max77693_set_otg(struct max77693_charger *chg, bool enable) +{ + unsigned int data; + + if (enable) + data = CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK | + CHG_CNFG_00_DIS_MUIC_CTRL_MASK; + else + data = ~(CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK | + CHG_CNFG_00_DIS_MUIC_CTRL_MASK); + + return regmap_update_bits(chg->max77693->regmap, + MAX77693_CHG_REG_CHG_CNFG_00, + CHG_CNFG_00_OTG_MASK | CHG_CNFG_00_BOOST_MASK | + CHG_CNFG_00_DIS_MUIC_CTRL_MASK, + 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; int connector, state; int ret; @@ -715,25 +734,39 @@ static void max77693_charger_extcon_work(struct work_struct *work) 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; - } + set_charging = true; + set_otg = false; + dev_info(chg->dev, "charging. connector type: %d\n", connector); break; + case EXTCON_USB_HOST: + 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; - } + set_charging = false; + set_otg = false; + dev_info(chg->dev, "not charging. connector type: %d\n", connector); break; } + 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); } diff --git a/include/linux/mfd/max77693-private.h b/include/linux/mfd/max77693-private.h index 0819cf0a4f5f..1fd93bfbf3dc 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 29 17:47:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745518 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 B0C82C3DA4A for ; Mon, 29 Jul 2024 17:51:22 +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=VpdY2w7Ol8tWjnklayT84Hbch6eCd/qeKmcHW5pT54o=; b=kRIbcay3hEEPFX+0nUzClTVBdd R/VDNZcNy6wAwV55Mj2XSYu0zlOnkH2bX7+bzsgQ0CGrRM8q9a0GqosqI3BteDPPIt4W9uW528w8q k1D58jWtVHhn01BLZCxJMbPRcWpFLD3flHo2PBJGOwQ7qGJ1OXuhMTGbG34O5voDVUIBLMPWxFSWL J7Dy5VgKhKAYKumJ9SEEgUoJHsUdzo7W+bkZhnhnIDsmj9NQuoyapyAKZqfjXczwCuWsJ6/qErBYP JBT3wFcqws37z4T6TgQ4uM4s0QV+LijxkomWpZbXuO2WaHx+cdVW7sl2ooJRqAhMftStTaJpHvfof ZyGzRg3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUWd-0000000CGKL-2RPG; Mon, 29 Jul 2024 17:51:11 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTa-0000000CFGQ-2lUt for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:48:03 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-427fc97a88cso19492395e9.0 for ; Mon, 29 Jul 2024 10:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275280; x=1722880080; 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=VpdY2w7Ol8tWjnklayT84Hbch6eCd/qeKmcHW5pT54o=; b=AwJ0hpNhRr1lbtDB6sy4/1zp7652Tz6a7oy8Cq6aD/mkfNE2M8EtkNTjYS+1FMQcIo gLiCNLac6pk8Hm2dPomDopY0Ag7yR8VC+7RSCUnGgtaIii1/2j6zYQ87svMWaaz3P75b sicYIT8c4+loNuLo4947QkVAGTy1czuLc8HrQxTod2QeUOt779AYSESUbbERmaVqdBfg D1HrIAZcxlfiejru48RfeQm7kX+2GFyolYoXH9uEU9s7m468DiSeGkoYky8Uwa3VlFFF MYePeL1grv6hmKVMkEHLcPWRxSVl0HlMNPPWzi6Q+ZUL1bA2jt/VodoNC6Q00evxXQ6s jpVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275280; x=1722880080; 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=VpdY2w7Ol8tWjnklayT84Hbch6eCd/qeKmcHW5pT54o=; b=qlpmQc19f60K9PAhiVw1w/S1aJIek2agIp4ezflWYW7DeTbwyumQKRPPDBdhf+bsUt G9JaPprZJuO6Njc5HlHHv7740co2WTnuKDCmI1ucJ/efJZOBjtAnn8/mHgWVDAKiy2vC RmnfFjpfmHf8m8gJHFdkMqDnPxPQoUOFIOPxpbZPzUyXchFc/UYUs9VW9uYodKjtRv01 Az/LHiMtzMk3VJfaSUvpnM1e03wMlo+CvMQi4y3c4WlYUG+YW/YXqIKnMkRhd9ienYEz AhPiCi1TtxrnkZGYrHj/uaWmYTbrm2lkqYMoRajf7jt4qTDBWvxOJTZEFBDZOpYJUbuf QuIg== X-Forwarded-Encrypted: i=1; AJvYcCUWteSaIpf2vRJqG34wLqIvrIGQi22uIER232f+piq+UbLc2PZyt6HkFqwjKh0QlLFDCQVu8p5mnqdN27oEim7ZPq+zutjFn4XRiq7QAzEpaF6h2Jg= X-Gm-Message-State: AOJu0Yxiw56mFefXV9FzBrzzuma1By/MWCvlhSDY55u+gTLYsmT6HjOK HQQ1Jd6SDzedFKvyGd6e1rFAXW/TslU0a3PdV/flzmNTdSLV5yPW X-Google-Smtp-Source: AGHT+IG/etUYMRG6EQg3R1Ca5UxAVuYa4JhLhQk6wFKPKMSpy23CLMxyZ6mlKsFnXrd8dFDFYq+WEA== X-Received: by 2002:a05:6000:bc8:b0:368:7883:d14a with SMTP id ffacd0b85a97d-36b5d0444c5mr5780214f8f.33.1722275280385; Mon, 29 Jul 2024 10:48:00 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:48:00 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:41 +0200 Subject: [PATCH v3 07/10] power: supply: max77693: Set up charge/input current according to cable type MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-7-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2747; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=tNiZCBQ9vI1N19lL0qdAjIhq26icJW5eSTf6NBMnkgo=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W/eTAFqhVcvrxPcQ+i1t+kITIAHn3E7QU9A CeM1wmLctSJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvwAKCRCzu/ihE6BR aDvyD/wNx5ko3xSL7orlI3cGVCD7U32mrcClUQ68x7NQswffpG0Xf42NfKJ8oRTLad7pBGhNMBS VeljVGA0BFvNoydBZEcxuoQok5SaS0V/dQCQfCYNmy7HskdQ98iyLl2GJnjKsumqHGpvmUnLgoA GoDSfu9hYvLNIfySqjyTdA7l7+FGS9o90jhszRGoyA/z66fhIvaz45oNM1nzWTBiIsTRjh2KPS7 7+0HIiFDBwO5z88Xc4dMYZNDg/T4lWImqom440DIcBexUlI7QYYHywaY/sb48GmZaYfj6To/o+T V/MwFb/7YCAVhfGJ9Ks/tS92cKe6MNanINbFKJpRPIdA4dByoe9PDg5KHauA5yONue1JWIKPHuk uD36E1hP38Vqgpg3JexTR0ftothf6Skw2U7EVNM1rpQuIMHg5rtKly0pQb1Y+xmcpJmxfxxZ4E+ y33Gcwt6y6Y36cnKrCAKTYvDL8Q/TfNlKncnbhWpy4s1eAXwRdonGlfUWvANnYmVApYkflTBo6E R8r0JOQ8PwZYUvg7iIWtQMU9cSX823LV2P5JIzH7A3KoqxBdRg66NXl9+HTEwNcpp/tJIzSutdd BZ835HurQGvaCglBdfyT0eOQOQw9DBHqKC1ezht/u50LgujCzsMox/GoaqUVN5jv2/QqdeM8C3t luoi1jeXZvpb48w== 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-20240729_104802_737256_016CDC64 X-CRM114-Status: GOOD ( 15.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 This behavior was observed on a downstream kernel - for chargers, the current would be set to a fast charge current value, and it would be bumped down for all other cable types. If we leave only the fast charge current value applied, peripheral mode stops working. If we stick to 500mA, charging becomes too slow. So, set the charge input current limit accordingly to the cable type. Signed-off-by: Artur Weber --- Changes in v3: - Re-introduced this commit from v1. It seems to have been accidentally rolled into the previous commit in v2. --- drivers/power/supply/max77693_charger.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 4ff402941d72..a3aeaba77309 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -716,6 +716,7 @@ static void max77693_charger_extcon_work(struct work_struct *work) cable.work); struct extcon_dev *edev = chg->cable.edev; bool set_charging, set_otg; + unsigned int input_current; int connector, state; int ret; @@ -728,19 +729,28 @@ 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: + input_current = 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: + input_current = chg->fast_charge_current; set_charging = true; set_otg = false; - dev_info(chg->dev, "charging. connector type: %d\n", + dev_info(chg->dev, "fast charging. connector type: %d\n", connector); break; case EXTCON_USB_HOST: + input_current = 500000; /* 500 mA */ set_charging = false; set_otg = true; @@ -748,6 +758,7 @@ static void max77693_charger_extcon_work(struct work_struct *work) connector); break; default: + input_current = 500000; /* 500 mA */ set_charging = false; set_otg = false; @@ -756,6 +767,12 @@ static void max77693_charger_extcon_work(struct work_struct *work) break; } + ret = max77693_set_input_current_limit(chg, input_current); + if (ret) { + dev_err(chg->dev, "failed to set input current (%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); From patchwork Mon Jul 29 17:47:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745519 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 615A0C3DA4A for ; Mon, 29 Jul 2024 17:51:43 +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=WnVUt1AGc9AqCAUSKdpREqmxFC97kSldsuL6yvP0RyA=; b=scXFvuLD1bMXXrzFi296JPE9wF lnWqeYI3IYALCJJBc6nifg1OaGHwQwyjNlsNv7OU1fuuxIkBgUmt3B4/jAHvEe650JPLEaA2HNrAx IIr1hjIJSRXwKr7+amljMnWQBGtoG30751LCWCwvpukhWqoL/Z7s8G1Zj6ObSuSU5RJiok54h+z9H O/TQuQIblluM2iXNKBkG+rnNAyk64u6j9A1ZO6uhYIDkVLrfHkkG2vmDDCeq2EuGj6/wxc8T6sp8X xzny57rarPJaviZep1Umux7GT9KxC2qec0q67/BpWyZOke3mlQwqljLkKAfL5Oj3PV4i8zz0eyZGv NG8c4Ttw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUX0-0000000CGOb-3XTE; Mon, 29 Jul 2024 17:51:34 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTb-0000000CFH1-2hzH for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:48:04 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3687f8fcab5so1509839f8f.3 for ; Mon, 29 Jul 2024 10:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275282; x=1722880082; 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=WnVUt1AGc9AqCAUSKdpREqmxFC97kSldsuL6yvP0RyA=; b=V2FADyIQsNtBH8Tabm2CEW3T6f2snbJqUWjffzFTaZCDOXsDpROtmOsSsPff6/Fo1D HDUkP+7kBQ8T76oZZJxZwGol6NEuqiYYhZ5BZm9PKvU+JzAbyuQTiGLCV8Vp7t+vbE3H NyVnZGvIFA990iB6+kzHr4bZuK9zNirIVSaQjBC+9g/VqnpKkpxvxxaQ45ywit2oUsM6 5kUYITFtggm/ylRPokgmZnJ6FU6ICOtWCjaLlYHf+eTazhacK4ts8swBJX0m89LBzDyV kdk9DBqHpEVFt4NuRrJHgTCxXEEs8lfwrNIIdj2L5ZI3Khk5biXzmE5PYobDNG1CoiLT 5bBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275282; x=1722880082; 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=WnVUt1AGc9AqCAUSKdpREqmxFC97kSldsuL6yvP0RyA=; b=Q8TOQT5JTI4W0sOqWCojXyeCU9VzEwGk9zZvUddRcIbEWlTCpsjZJDVk75KzcTud+l SI6FQfPxYu8nhtKvvmesluqP2uKUBVNzuiU/YssBEGlkddxNEQX6nbwqMGqjynHx/unS tJm5VRQ/e7KsZMjp6S/WkYaJO2eti9EveSO14ZkdDfECtEe3qSjEWcSJUospZ2FbOWrp sNl6coayD8IcZjHqXLJi9JsJikLh7Y7KxfU+AAWSyDjpAuCE/qpdg35bXZECiEqjYGHs bl04PAFtVZRIuKk5bRSW09saVoAyZi+K3b4rnlnapDw337Rns+dFHV2Dc/mV0kiSApvQ RpcQ== X-Forwarded-Encrypted: i=1; AJvYcCXFjXuIEZLuJfrb4YaQu91zPDW+0GbazY/eZQK+0z15vPrUvGRuelmp3y8DBBe8Qaeg4TEF3X7RPMZVRO/qYYR3U/Q+YBHtnGpMcidfB1qEswsWbOQ= X-Gm-Message-State: AOJu0YxJ2MqF8qorPbEZw1NFLeuraYySzVoi7AOYt/wP5mnDXosZGf8y KZVopLjzPY8gplPmaAf32tKb+48n3Mne8MauztLWnS8v2CItz4aM X-Google-Smtp-Source: AGHT+IHNyFmYhpG/++yMrpkuRc2XYprU40Zz9/3C+49zl/kR3iongSZ4buzWgKt0FzzTDvZcE6BgZg== X-Received: by 2002:a5d:63c1:0:b0:367:9516:ffb4 with SMTP id ffacd0b85a97d-36b5cee21a2mr5812478f8f.19.1722275282210; Mon, 29 Jul 2024 10:48:02 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:48:01 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:42 +0200 Subject: [PATCH v3 08/10] ARM: dts: samsung: exynos4212-tab3: Add battery node with charge current value MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-8-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1385; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=8B1kt8AWmIpBQPncG9dfhlWKEjLZT84Kr302Znpylas=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W/6MLFXnaSOcMkyzmUQa2TpYwPaa03T2gQd VHEdtI6YyGJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvwAKCRCzu/ihE6BR aEnXD/9LZurHLtb9yxoipoT46Gc0pSlhbAAFltMTws9gW7PF0xBpQHj+RJUwrIxFxsvts0i6MYc eWRx5cPuJYjwdftPZm7FPa/J99Pie5Ob2TWGQuiAqDITmKPOgaN4tgCwgsKw4Qg5dbNjqwxDfO8 tkEj5wbKjpUOYvBXDB33xzXmtyOOWTcpD5mtQSmM9jYwZT/8TbZyurZj/OCA71fNfstNFWaRYuV YFe4ae/c+g+51J9CSTaOQO1xCQ/igRcu+k3z3vAK66Z5Y6rGG0z3A9+cWLdo/nI+YnnCDX2ArcR kjUFAs/n8+Ku5x54lXivQ6bLvzMxl6AEUczZPoG+2/Lm+yt4Q6GctGxTu+Gk1RitAIxzVrZhLbM w3P8lh+rU6QSzLMJmPhaXc2kMyHhJVof2tO05h1DGb4i4VTjVH5EDLF8Pd0tOAu1KTl2S9BND8L p4TX4DHpI3VNtCU5fnMsLV4UCIVYkuSN1V5gmefHuURBIrw/cfY2z43r3d+w0vAEif9w9WSGxjJ fr8GQU4Rg77Jne4EV74m0OJhxN66zpCZarrG4IeOGUY1aT2UB+vOsGFD5Mm8OfbOUYLfim6h0iO Ao0OO7jFPmkZgEYMC3WbButGbhyVVCO49bGb17Rq61sL0uFnECsntOmjqgmnibxrX1thfk6A1MB sZclK9Q5N2Vb7yA== 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-20240729_104803_723598_E4E5F085 X-CRM114-Status: GOOD ( 12.59 ) 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 9bc05961577d..3c905bfedd96 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -159,6 +159,7 @@ charger_reg: CHARGER { charger { compatible = "maxim,max77693-charger"; + monitored-battery = <&battery>; maxim,constant-microvolt = <4350000>; maxim,min-system-microvolt = <3600000>; @@ -300,6 +301,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 29 17:47:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745520 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 5011CC3DA61 for ; Mon, 29 Jul 2024 17:52:10 +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=wyvnu66sWcNIBHuBSqyZilcpj0nKWP7q5mWgQAuw53s=; b=D9Y1DTGvvDUAbgxThOxV2LpdJI o5EJyE/H6MgENaE2+hgDtUEMG6iPfj8H/wkb7V3i1ls5SqttemXKIUuzXt1nUPuNcizz3pGONJjRX xm9K+5zTUxi1BCE8VUb6JmYcvyHWYjfPwQeKOuutB+T7+coKzwdDU7CcaeCXkJz4DcGWXJJ+lgw2O +K/E2pCgqpyPvTeHGkM49gHc88X3l3WQ1VH82wW958cc9Lr1ZoBE2mTv4MXSbwtfgyOA9ol2x19iQ QjaLb1vZwzWM2ocsfmFZ3x3BMmdvRtT63dovL4E0LasRd58PnnEyP2gRAfaghaoy97kdJLS32ZCfm MvNLM73Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUXP-0000000CGTa-0KQ8; Mon, 29 Jul 2024 17:51:59 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTd-0000000CFHl-45la for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:48:07 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-427fc97a88cso19493025e9.0 for ; Mon, 29 Jul 2024 10:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275284; x=1722880084; 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=wyvnu66sWcNIBHuBSqyZilcpj0nKWP7q5mWgQAuw53s=; b=C2zjSxLoIkv8QleuQXV/7LhuskM53a3yAiU9br7xaz+3T4xOG9D3b1X78eoQ32m8sR iLfUyZLU8JNtV+qGI5FoOVFJIYdYb6d2tef+9C8CwhDDVdo/mVldcji46hO213+hepIG +oHHI2qe6kTdUTA0rAD5geqH1Hgz7VPwEaIUT7L91cHQARoKfky0CJ4y1OcD8YtzIGxA jHP4sJsIxEZu9HxHJrwM/WSeGawe4HaVjgLe8Vhhhp2PX+fwBoRbcYcOy6Ro6v+FQGgD EDzbcw5Pwjgij75hKvID4X8FdSAB4riLYOkW021S41lVvxJckknhlPpkGWPrZvCyfKUX +m5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275284; x=1722880084; 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=wyvnu66sWcNIBHuBSqyZilcpj0nKWP7q5mWgQAuw53s=; b=hMp3+uEZ2E2WN2nVgV7OUzGxpbdPAU0FpM5n+s/vBlWXliSqO1rAuBce+fBlvx/evy W2EzZqd6qxPtBqI8a9pKU6UbgUKqYl6gAFUn09Xg2zR3BciHa8vbDE+lKIdOMrsPKyA9 XMpig3DKz6a2WhAzO+iY1VzNvcUGe+OiFLR8YC0F9YyT0nCPGk/cMaySKOrw/aZb03SX mxtWary/eA7nNBuiGOvRj9drg9kYEWbOWfxRwE4ZFm0nAsTVjb8lOT0rNJOasK7eE29u mskEduq41nkYh0iUQBbDahrvVVZI8mEFjQhQWnMgVFSj+FZDjVn6ERDheRXKpns+Sg6p wdEg== X-Forwarded-Encrypted: i=1; AJvYcCWjVsA/HlHejGwzPjoC/Zm1qJk96dDCtm+atBisZfaNCIc/T6THPIBaHkOjcSxEfIp/2+IJiLg1xxaSzCvzdi9oiK4NrM/dYRwbG1rrCk6+gspxNH8= X-Gm-Message-State: AOJu0YwDpNhC8aPCgOoJAEDNqpS1YoFg2jmwOQZRaAipdx1jhLZuGrSh FOYFaXuwBXjdjp8nZ/0Thd/oHhuh6H5LqMHSV8fWaJp9Z6Y0x3IQ X-Google-Smtp-Source: AGHT+IHbq94wdyrtZpENkrilKax9bwCk8OWQRo40k6RV87e26CshVbjqr2TeVfo1dARJco7mmmoLBA== X-Received: by 2002:a05:600c:3505:b0:426:67ad:38e3 with SMTP id 5b1f17b1804b1-42811d73aa0mr59536925e9.3.1722275284340; Mon, 29 Jul 2024 10:48:04 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:48:04 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:43 +0200 Subject: [PATCH v3 09/10] ARM: dts: samsung: exynos4212-tab3: Add USB connector node MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-9-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1245; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=9RZit0ywU+LgXYJREclxZIzCm96R2ILsMrecyNIUIjE=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W/Y8o9dDElXSehvfvPuAOvEJ/fVGJd/Jg6J qJYSkTgi4uJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvwAKCRCzu/ihE6BR aMNKD/9OUVhvTG5ybHdGPNei8p3wQhAke2A2b73j7omwzlfJ4cmssrk/yY9s804hpeMxjMhm5Ys sn9xyjJXM8O2c82OOuF29jUmGwX+re7aitSlJos7L4bbY4SgpMYilWdUolC0HRyac4Qe06IaS6M 3SX0jjzJ3K//yVtuUBY+8r8RVVHfkstiORdBp+P8f/fhQmSrtPgNHB3/SNu5CbFE3VdRQI8V/Jx kUjhkZ0jvF/FCw8r1PcRsFKpE4JQjqhVefvdJ3CiyYtG/d3c24admjms7ggDSqlOZM+q8kYgdcH 7d52yCGY9a31vSFAwkz+pzvtnzFpTtPJWtPmQ7GxtkDkwYHsOInzKT0DjCV1HHCgE5RYgjTEb0C bfdKYO2B0f1XBMF5NFQCln3hdM9AP6UQ4EW5PzMtAimlC9RjbqtdG4EMbDAcU9PBqxV3HuucL98 GinIN1j+5GH25f8d/gs5AJfiQhKPFvTc8xys6kUCMAeOoY858q0O2bW0dOet6FppiHZlUwkiVag Gl49IjgrwAuS7WSkB5/beYv9+YdzSmvsjoq71kx7WBI7WPF9vFw8Dz/ObN0mVbSIjqc4H1pU7SF l8sc7ZKq2xtSdusaT6siBjuB4z0K2HsDYaBWol/g/muvbJpiyFLc+DI1fWZfXEcx1DhQmlYjiIp +nB5RPkipsyhW7Q== 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-20240729_104806_049238_B1FF7C88 X-CRM114-Status: GOOD ( 12.25 ) 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 3c905bfedd96..7309b4e1cc3d 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -157,6 +157,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>; @@ -166,6 +177,8 @@ charger { maxim,thermal-regulation-celsius = <100>; maxim,battery-overcurrent-microamp = <3500000>; maxim,charge-input-threshold-microvolt = <4300000>; + + maxim,usb-connector = <&usb_conn>; }; }; }; From patchwork Mon Jul 29 17:47:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 13745521 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 D3B75C3DA61 for ; Mon, 29 Jul 2024 17:52:32 +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=PHSCo9OtmlT0uXzVvp8H+25FMgbSAgLEpICh0lbC9n8=; b=iQC3Oz89+mFCYm1PrHXUei0Z/D p9pEkwu+gISMBxoQfexKHsLu/dI9fSz2rrh6IOzXQ8e90pPI4hjNFfDKcRPekqJZgcAAws5iN0oV5 2eMc1xcJNqpweA0wr1ulo5sst3+0O5TCK4RMfBKPaVf4DMF498/jzHrdIljxNLQqwTOcmROm7fUfu RrU8Q9Yt/iARywBsYWJT0xX98qWTr/1WYP3iM9CFieX69oWin0dOsNNjyziWbiVsnKkc4DDdd6FPt fdSSa/vcN+EnSMwDDf32ORuAyHvQsRyvneMmr2Nzgp6dkrubRXvtdvilJI5yO8gGDO8NVnntMuVPp Bq9MBP7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUXn-0000000CGYt-2P77; Mon, 29 Jul 2024 17:52:23 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYUTh-0000000CFIs-2hmF for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 17:48:11 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4280c493719so17630005e9.3 for ; Mon, 29 Jul 2024 10:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275287; x=1722880087; 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=PHSCo9OtmlT0uXzVvp8H+25FMgbSAgLEpICh0lbC9n8=; b=Gyj9JSbRE7LQG1fAXGZHyVDDTKyxPkTWO846bqfCmoNkUJnbI0fyBr2TOdQcJUS7JO uTGwdPgcCiP7ASfkUHwQUAmrPtPF6KOlf1V9ugna2XRPv4X1Gic+G9gk1Dn9BSAtn3T9 2FXY5fb8Lp8PCgy5MTYQ2nylt2I4qC95aWuZCK4Y/exG6+ggicjSTB+MAZ5x6BQBVsj9 9NYRhuRJqQjSfdIT9gXOLPZt4muc8+gQHJykFaTMXtOvnYtJJdNDGkrNxTb73e79OlU7 PdM/e0nO/9jIdRfWISRBemJqrs6ZNqjLxVUXOXzarRY2lJmIvv8uqRUZb2ZAVTV1BM25 iyLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722275287; x=1722880087; 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=PHSCo9OtmlT0uXzVvp8H+25FMgbSAgLEpICh0lbC9n8=; b=o7enR5AdjqyEfhKeU0kJ6gJtOtBiBlMFOf5SmGh0wMMLB/KwpQhVCoVYFKJWxl05AA jREmLwaMI1AYv43eQt4Vfl9LUH6ES/vVmB0U3fGbzHqiIstuWuTt5Ai0rlmKE2E/dDW4 w5X7PznT4xrTUElhfRjGCe3tgG2IWwX9vBjZUiyxHBARSs3TxRCiNWgDYf5qWnTn2F2C NdRDx9RqzqS4tyUYVyGW8ia39sTpw26D2LatQ9d1GxdtG9rNBHPXXqV3JMPEJdVuiFvk LbejqlIlOVZbdXrmTFoNLkVmVft6Fv3PIChtYrgO5xeM012WcY+crWAbetNM0Z0dS/GY J89A== X-Forwarded-Encrypted: i=1; AJvYcCWjhS7YGPyDzv17qNlyPsoG+LObqMpPWyPOxtqzvsLgl5Nh2HBJ9KBDxuy+hV3k0QXlVyTbIWe2QBS+gGdRlUFoHZU7PkTvq4cSOG4LpO81Qo4L1Kc= X-Gm-Message-State: AOJu0Yx9Kv6AfKRdZ21UKHW8YBnPVjdJywVCA+hRCjoOSzQeS4fjWjDd y9gNDee6lV1hhtUA7p6YIKIitNh82COeoYq1dVbbT+a0FoD/l2H+ X-Google-Smtp-Source: AGHT+IGwptssli/bPxkEfWvX7Isew7g3cblPii2OfQfYYq8mJymlTY5DXHn5VDrv9RDKBYkdgnCFrg== X-Received: by 2002:a5d:460e:0:b0:360:96d8:ab7c with SMTP id ffacd0b85a97d-36b5cee9dc6mr6137919f8f.11.1722275287312; Mon, 29 Jul 2024 10:48:07 -0700 (PDT) Received: from tablet.my.domain ([37.30.0.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367fc8a7sm12716550f8f.59.2024.07.29.10.48.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 10:48:06 -0700 (PDT) From: Artur Weber Date: Mon, 29 Jul 2024 19:47:44 +0200 Subject: [PATCH v3 10/10] ARM: dts: exynos4212-tab3: Drop CHARGER regulator MIME-Version: 1.0 Message-Id: <20240729-max77693-charger-extcon-v3-10-02315a6869d4@gmail.com> References: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com> In-Reply-To: <20240729-max77693-charger-extcon-v3-0-02315a6869d4@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.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=916; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=caLjgArHqT0iX4aNbMz7ThFMSlU4O/1uHusrmF0QQ/8=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmp9W/WGax3Jobdmy7vUBKLwCxJvPKRgZI5znqk 7rkTrRhG3GJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZqfVvwAKCRCzu/ihE6BR aLZrD/9pqcbCSRs8SwBt76KCrY+d6MUKKK+BMgFJcj6I/MS6ta2DQWlccNns9Tpqzls+ZvMa/Gu xlgSxIePd6CaRl03IsdW8e+OsoBHsdoVqDitjYChSOKpCfTZPcI87FinaxOFvJWmFDrdVvQBoXm 9M2YhJY3ozq20eJ0lZscBXOw4uJ3rneXZ8rtYBRuQfYLSlAZc+8zk4o3gOjVnD3PlJ/HUBgA9hg GlDV2/yzuCYR1Mcw6KGXLUYu7VqF8pfDp461Bdo4WlUcZ1JEKVQl51kF32MRjqLXYyUVQ7VxM5W yDGtZW4EXGHKmkbmVORTC4vGszMKjavhr+tDcK+pPAFpZC5hHIygtyW1PduQbThS5Gw/VtaCK30 uhiUN0YgQM13nkCdN3f34rXlHA1sAYOa8jQ83Zut4Co05NnSuB98Ewf+rO9OZ1EJF3bQU0v4L0s fP+WIUyqutDEzcoV2krQWkYDUJBvx6aSTuEfpmrrvcCuVwbV5eWBwRGmLBQ+tTT1MFE//kF3OP6 rt41RF9y9OLF1s3fuMjoMYPvdcP/OCaygRRxILFAgC3yGjHS4ZYEozTkPLvr3VNNX3kZPxVgJTo NkEMPwLKabX9b1ir0OBhVp7DFuvWrxZNyKxQuycffyMotbqLaorahQPBrhqn55AjQKFH6l2Yf6E ZFiV/WWlfApXfjw== 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-20240729_104809_721636_564AD91A X-CRM114-Status: GOOD ( 10.69 ) 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 We don't use it for managing charging, and it interferes with the extcon-based charging mode switching. Signed-off-by: Artur Weber --- Changes in v3: - Added this commit --- arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi index 7309b4e1cc3d..2006cdcf3909 100644 --- a/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi +++ b/arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi @@ -148,13 +148,6 @@ esafeout1_reg: ESAFEOUT1 { esafeout2_reg: ESAFEOUT2 { regulator-name = "ESAFEOUT2"; }; - - charger_reg: CHARGER { - regulator-name = "CHARGER"; - regulator-min-microamp = <60000>; - regulator-max-microamp = <2580000>; - regulator-boot-on; - }; }; muic {