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: 13745534 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 727D015FA68; Mon, 29 Jul 2024 17:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275272; cv=none; b=m1+ppU35UoZeKXlWmKxxA77LxXxSbgXUcHBwSbGLZmV3/AgwlNPT83WxtMKe8cHuGIDl8trsfGiJP69VNGG5dnIlmDT7ZjPS8sX84lvF/kFJx559qFsobMKTkjGx3cP8v9Vj44kPfBx6jLAq+s8wiHEEKPHGrp+uz3wo3sty+Qw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275272; c=relaxed/simple; bh=XiA66QrY1cKpyMYoVlkQgoD3V8kx0+u1J/F4sMqHt7Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FRHuz/wlATzl+vF3P4yQwBMLdgW/oyotzx2i0y53M2txQqtCoUcdVIW8LAIFmFxA+7B5RBl5UdKDkB2SDUjQxhJEiXOeyXZd2ON/cErwGFiDrdb5D8/JvUCkAtAupA3MQmBi+Q4aqBX5HlRuh315zpqbgqVHAIFIurDKdVU+T/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=I6ZEg9mu; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I6ZEg9mu" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4280bca3960so19634085e9.3; 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=vger.kernel.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=I6ZEg9muA0MZM2d9RXtDPdrlgP5On34sKZW3wR5mZd+PJNesUnmtCdt1e6wwzldgYc HR8DO2yeo2BhV6TRWD/cwWWIntMRA4SU+GctBDzavEzt4NM6KyG5ig7DyqV8IMLvpx/E 5uaD8THrmUqZZS4suqFw3k9YxmKD4WfH7+nAGTWvevOPvwuq6n19RuK/GYfAw0NCkIPB o25iCc4OjJUElwVo2w+woWJhfxbk711bVGbJMhMiI0jped20+execOJzX8BPrx1Xcbpo pIbECyn+Gm6wGDwqwrp5EleH2VSY+jIIFc09IBa2qN9Q69bcxn6nNe8pymAeFtGzHfxp 8Lrg== 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=Ul+d9qZztZCdSxBFQVlJoTolqfoeYtskugJ4SbscBxBf4pkzwZRtTlEnBwMcf9GmVo H0XVY2QTGgKwYOSeCJ17SqkAlenKYLUZagjGVJh30doGENpAGkmmDicAhzaLmtQWBxyo ZhddR+wN4tkrAwtkvd/YRv6xuKOTutPfsG4nK3nxMzu2loITUtxjTg8vJWMJI9zFyHoO UEwXGbYRyC3Ayh5gSZErsgrmPBi64PIkioFZY7Y7gb6YVidSl8wH6eUXXmHB+43mtfMH 5BTjRUmeciF5pvHLuHlSW34+F9gGWt6dkDY4trE9cAvSlOOnaDmT1nMDXVD+EgJkA3+B GtyQ== X-Forwarded-Encrypted: i=1; AJvYcCXJ5qlbqvYtEEpXseHIJDyi7Hca4WV9YTTayOdFEDw2Y5ToY3CBzsEe1LuG2dr7Uv6VDq9PAg6z7plwxM5HDOQ/dztwjgnQ/pFbi6riW1uhP6gLs9j0cDdO5SuHibm0GFGMsxhz30uq2yQA2IZdm1YdDd+uhw1WIkxFNKHOl3X+twTA3KUGSIi9+fyeSHHs4SN+NBu57wjZGRAsdStcHyYGajfwlco= X-Gm-Message-State: AOJu0YxB8ldUBTB3F924HWBx6T8/mtx6MtexYlJe4GhE13nFLglVS8K6 tSwl6s8/zldOzyiFPX/r4KN6oqP8LW0672rcx8uoeGfbfVCr/gd3 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745535 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABE401862A9; Mon, 29 Jul 2024 17:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275274; cv=none; b=u8r56SkYZzGe9C4/dEvsUU2lRNcrSkR8pWIi8wR81SSJdtvR8eRNlEYLmRT0uoHMxL3xHwrbIHYm5W99HzTyLXXIORejLs0rqgotgAPX2UIoLeeii3hsZxXDTR4JA3TPkxMPfy7If8SF9C51mLuRdyMKBM6tp4Xa/XO42pyUMgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275274; c=relaxed/simple; bh=yzTgncn3XdYXI4m/F4375wxDu8sKiX7IBaYFauYToLo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KQkpD26xJXfG13EV431+abQBJqHwb+Sh/DVUAUluwog4lAhEcIXhlPId0ftmDG+SAFRPgX37lWQWq2zFHmnIjTK+Pxu43zPn8/mzpJKxfPM3jnJjIkeDaCUNPYiHo84/OHLdud8zmwXA1eR/MvnWNlq9dfb8aHrtgW3vGCSUGbs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HcVWm2xA; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HcVWm2xA" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4280ca0791bso17688435e9.1; 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=vger.kernel.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=HcVWm2xA6Xha67GRBseynmNiueQjD4MQMYxQApxCFrt5BhSeEUSFryYTbvJahAJ6nX q01Ei32sdCyhwJ0rqIXN9hBPDe8bU79MNUJOPNXx/dWhlJG8SvfDZw1Fqm0Xhpp28HuK nLbqWr4YMvpDs1wHkIgH7Lydc1nHc3KL61XQM7lD5jEuQ0dWnuRI7FDhFUr5nh4jGnOf mtHxDzHMVoHu56EGq2ECJ/WM5K63kOo+YYQBqUixYdIZ7sspcIb3kqYrrUe8Ga+ZtXy6 Ue/Dgic0+VqMHfYABOMQaMRLl8njf3lq91Viw8rJMqwHsjWWN1NLkDG5aLHzisfkUoP8 Sk1g== 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=XjXO+s4Q/1BldcPBAqFrvZqDrRdNflLBpuMEsQN+G+CmA1GsJ8OL0colSO+xSpJamp cCviiPaIZqP+qKJsOsbGlji5Oxh17orfWL2odSgQxtgMFHvSwKvln84uhUsKVH26toXE y7qhIjpoGllXRylFMllHk4GolcyvsNzFgGCX50jQ6QExs3ARy1o4f+z8dMx8W0Ii5xad DH9ICmnPWluD/S3FvwJzPEZm0eGJ0HgAClXB1JcHJKAKTV4jxK7g3U6ViW6p+Q5KAXCt yVDfgF6FdTpROU4F9JUvYY5JHIByI6IQ9FGjZBh2GHUzH4KbNiDxR18OPc/C1gDWPzlf 9R5w== X-Forwarded-Encrypted: i=1; AJvYcCU0vWj4SefTrEKLbel0Mve0xb2Phz2R8YddwFOrVt+gPOjurlCvYhKydFG+Bb0LP++MJ7jd9Kzzem++ODf9ndwIaVqAeMedAEvhqEbBm2erCDFQlg+72MhnjoZxaSw7uVfH+L+lUvb5GPI9QMTcodCYgOwTytwurjbB8rijCQeuFwHAtQMKz9pHec/ZQVnBU3Z3db9lRLJSa7Ewt9tAG3CPstto5HQ= X-Gm-Message-State: AOJu0YxIDsGthF4GoysJ1Ni1qUP09wuDyiMWbbAcmCmBDMsYe3o/lO+T 6Oe3ccAWZAdMVVnjDe03Iz+eP5MJo/XRMYS8vQuWRsqA0BN932Nx 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745536 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CA1E186E57; Mon, 29 Jul 2024 17:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275276; cv=none; b=BZhKN037YHOexJWa+gEr8IrQonFbQIRLozXDmXJmRxEl6Cbk8VHRqwm0d85x5g+hXAEtgEh/Vr7o1Fno/SjKq7PurnDePIbaPAjYDCaOu0LA99OeAl2ZPawaY909OAbM6JgBt7h8YRIBF4zc3KQ6g1vQR3pn00Q2EXmHivJz6FY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275276; c=relaxed/simple; bh=64p2zb/TO0sOXA+lVtMC+Y+6Z6xHMlhCGgkfq2NJimA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uM42/FXXXkezqP9Wn/YRsFqS0V9M/81LbKaSbt24Fwa1mALm6kJeESv4mF3E9k5qRQmQaG9MIljQx8rJ2Wepm1NoSA0DNrRbQikJ/4f/DZ958xOSJhNypRTBHaszuqueuRSHsnIYonmsbIDnwtvUkOTJ/Iwo/oueKXCqjhVZaiU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=P8HhJ/rb; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P8HhJ/rb" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4280b3a7efaso19608215e9.0; 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=vger.kernel.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=P8HhJ/rbb/L1HQ/DocgEVv0XVljCmcrK+qKu9bvNWOVQaddtEBYrXMtJ7U8NZYP6Mr OEiT8nynx7pQZgY3TSdzm6nY5rhoPqaLX215K/3wF280/9WRK+6uPHXIhwNhjplfLiSR cZ0cTWLW3HArZbcPLGxnAxXVgezEpmYxfzL+2pah6c6+AD4cnuR9S3m1OM0PM7dkuBqT pXc9i+xlqN9qstrKWLOw7sQUqEiOjYAesQ9aaguYCbS5PCUJU3Y6LS4hFbQE/zXju1nH EKjptM7A11aPjQ4FV2G29y4GkMWZMODyYjp1hUy51t6ZyS9eK82Nn53Yb0ayPQGLXWxq 1Tqw== 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=Y/r2xVC8st3DpYCY05+m8mzQqQBxn948dD8I5Fl/si8e7F6hRjNsl9a84bSAM9h5Fp MYT4BcoCdfC45oOV48Azm0nZGZLtAx9W8qZ4u46a0lJVIhHOm08EM4jsdSCLOHww8QDQ HRuKvLLya9Ck32OqPY3xolid4UKwI+6SKv2bf/eS3R0btlOIBqSyXfH3s4XoMWm8iAlE 5f3VwGlzx6I2aBqk7TZg4OkiaWKvLM1lom2NhltHgz6v5T+EqDr8Br9oOxILXElWm1jJ 4tw9x+9s73MnvOlXSw6rupjD+pTnwfNeJEdTuXjxM/RtFGVOcDSXCYg7/UiOYmqLgGD8 3joQ== X-Forwarded-Encrypted: i=1; AJvYcCUTL2rag+7/Q6FAjvlchCmWgbRxEQyxo//BhcXrTN49mjOPetL2RyX6zc+ehEkSYhXncl7e5H62HwkLmLCZiTmTQ/yzoimJYPDHVqs7Nr6j3qzwmHS32kVcl1ZIF+4j5jPK+pAoc9apwNoMytS9I9c7pPkfpYaqWWV3k5/oqxVV3ad1zJi9abpOGCkG9c80iv2W1JC/mTiKF/ljYOrMP2WpnI7ut4s= X-Gm-Message-State: AOJu0Yzf57webDq/6J+m3CmBhPA10lprACi+M4/3X6sMElvCwiM6zZ4R HG8p96f0wpmD+v/8axSZ5IuzGDY+Z/F5UvJUFLHr371bzP0UGlX1 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745537 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CBA0187552; Mon, 29 Jul 2024 17:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275278; cv=none; b=f5EUB1lLBOIDQ/3Cw4VSJMkVKN0RJz4VBUzmmcP9FUAkOQND6sFwmEArkLPWxU1Nx1YQ9o7zMlXfKSkfP5gF6YqcTQi+vi/U7LP4IveoVWTHy6l5LCqFsfHiYch/e6ifIoC/ULTfNyxi1T4d/NDaTA4o4UdL88DJrFScPj4S99c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275278; c=relaxed/simple; bh=ugq53xLBW+pgJurSinC5JizQ+Kguu470RHyzKlOfZec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DJUN/y9P5WCD5wFbzF5IO/MAnhpDd9kPtCxc0At0eN1W6TebBZpFcMovRQQZwsCLr3BqwkyVMoHFCGDaec6m6H/znf0Y+MkiAP5WAommdgG0PD5mIq8sKCFElFHUC3ZjJSV7yyxPUsGmwNLX+g5ZKQ0b7TjR1WL5pE4afWLQI/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eJPKEBOO; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eJPKEBOO" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3685a5e7d3cso1802453f8f.1; 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=vger.kernel.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=eJPKEBOOTN5l5Uien7scGUh0kKx8wkyYDx8VM/t3OswWyfMfJQBOftABDveoL33Xb4 X0UQM4rEBjgViA0+HdBS39sEbOW9/LGZSt6hHldXi06beOEl7WfMpE0/Mv2O2DvXIImu GWIVOd+Ri1GWLuMK8QgDr1++3t6+tEnrXaQNw+lZo1VqcV4QjJVaqURpk/WGSQDCFEfD hOSS1RPZW4UK1VsjwEWzp/U8us4sPCnjr7ZdxYe2vAVulbzujLM2vI547z4RePpMADYJ zt9fxGn+YjxQQnJQIYqd/sqJcqbijn89xb2aHtN79xBn9O/4ARNAuHAeCNVQBNDGf1tJ 8fIA== 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=sq5LOQOj++hd06EcMI35dKgaxYX07tVza61RWetagho33k3ntGjPYUakmlZzHY5ukB F9zs8W0DAbLPBTOX9CtTt7NMYVxBtfmyvS7mZ4mm1ovVMJpJWCPM4ocmqJKrto8zzhkW tGi2n+loA7qYaIkM33REENVaK6s2nm/OEWWxgjTA2waaIXQdQkiz3eXTHtAdGhBynMCO wtlRJH7Szo0Qb15apVOrKyOSOw3rYL2+VOgbiQ+z+PtiVQMyTIVu6y3cwdcFH7yB76te MpA6kxv7KyuFPyGr8McsQN+8fcKf0p7Xb3jVD/yCOz+dxcb0iBG1glCgr1+mXnXm1mY/ bp0w== X-Forwarded-Encrypted: i=1; AJvYcCUBkzRo0XT1KglHObwueOdjD2lhuuE3yXxu2f/J8S05CN3Z6kUhaHlb78JMgYxCYChg3NP8SbrnTodWvbfYD/yTeG3N6tnyVkeFNCy7rlz7VGhjNrXNTtYvwkq/Ozv5dWLc7MUiHnDsx4WV+006n4XvRws53UWhekAwBcGHVpLNKpyZgesIG47Ml3fjED4rOdlfeYeVJPRR+lKRceTmK+vMyMRJGyQ= X-Gm-Message-State: AOJu0Yx82bYA0kyUf8pOJCiVkOxf841VEoCYF2+awAAtykNKWFxuo+WA T6HExbdqKpORoS+T4jo5hVBGcyjcoR8dmL9kX+ZmgGNOasCRRzpX 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745538 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46CDC187871; Mon, 29 Jul 2024 17:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275280; cv=none; b=cyzeIf5Kjg2BojmMb5X1P3EhRgMzxnyVoYHRLmI1TOZVpxGPf3+msqGHwoy1B5lUTE6gaCARAcYHQhvvKEkyI4+5mLgnqcUaQBDI17OoyueBAEdIwJ+wYr2ycmWIeMw4+6+IHZ6ixL63CYlg+O2VeThfGP7KvGAVGvw42bKOjXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275280; c=relaxed/simple; bh=hUFm5zgvxacpJc23mhT7FrKD3yHbBhmDgpcXdgKmXlQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ietBbTGzY+hlMT4BRkTiW80qAg7uvTbZRg5/iTtvJSn6gAnUfCI/MPpCNqRbQPDr5FmwUl4zLqxuSPIuWN9LQr2uLYCReGAgLxoqH7vDjKZSR7sDtrPSefz0tnodA8a+uNCLNRSvpoMBKZo4cmoddWeav1RAMR6hQsMfmKgCVmM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NyNNf0Ry; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NyNNf0Ry" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-368584f9e36so1524278f8f.2; Mon, 29 Jul 2024 10:47:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722275277; x=1722880077; darn=vger.kernel.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=NyNNf0RyxPUCZwzdx+F0exyK6gvvdSchCigf358x5i08Tkb4dz3iySp4p10f565mUR Bg/mbgvTFytec3HmCVuWKpAf4hNHio2lH4J6LxJ1b7z0320Uvq1QWU+ZiC6+cyKxv0FE /VziVZvU/ZAhvDjzt6gXMqcpEcS//FUd/dCq6Ff64aIw8aznrtb5FJ+6TnsqzYEbNeYs cnHOcaqnbvMc7lb8ctPB9BDRSiFm6H6B75eDC2rcpIzBsvXt7DaYztJ66mwljtIWJI9p abq+wt2C0a5Db9h3sOXQJ2rn44DInYpvXwiSuldPnoZbbRThpIcASWtE+XeYkUALYlGl 9RQQ== 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=vGos0I/2y3WOk5THdvoJjOQWK64gZE1ypUrWvBoCAAghFVECtluiL+PRknzQRe8kIB 67C41vzMMTWcJcj06nagb4ZCokXwDbcCztjl119Pjy1RgKq3GxIP/SJtsAAwZa/cVILU tRT8f1zbCZ1mIuljUtSHI7tzVHFMJ4kHqAS9ATP4dJv/mMRPWMPN1x01G+aiyJTziZah 9rwzbiaE+VpBU7KzKqeeRVNYOpisOhIhLXJtuBcXBLZ7T2kAzP100EyE6bUOCk52T7ms j86wKh2h43RLJ7mkcU7/l8njCUqiH3HAzmFlbXSbklTISLfU0XOelAPNu4Xa3r0vDnTb Ingw== X-Forwarded-Encrypted: i=1; AJvYcCVkV88d+CMYRvKOcl9KybPHeBmhjo3Y5JP7Gjo5LN/xXtr0nENMGgfL964sJz/AwkAgjmuF2dFZioq80fBXui02UQ+J6kFeZW1180cihD8+SizfWMD2hvx1zikeqNuwNXfdoGwnubcMZVENEii6JIbxRsB2UE7GVSeH9hoTMau0mI3Rfh5pjUsA9nYXSX8kHi+XTqDxCffXoXUXFq1B7JHTVSo+p5Y= X-Gm-Message-State: AOJu0YzYeCARodTeQAZnNavkP1XiAAOwWQ1znRFMdmASUYIUkVRfP1W/ i5LzaYsWMa236QC/ekpzAJQXtM3a17c/xdl+NtvNVtI2tlJzo/cGdDMHbg== 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745539 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FC4F188CB8; Mon, 29 Jul 2024 17:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275282; cv=none; b=KZVib97k846zqO7zc/7xgU+9M7ygX4GmoFarH5iF4q0/lHjgleJa5UfdFB1BVXOoYN0QUq+jX/3ZFXiWBDz0KX4ds/7wIrlPukmwUt0L3xti//EY2DrdWc30DXMhD+L3Z6yd7F1CJoTkWv3e+qk4rMVmLDckdqEFvVxEwptW/z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275282; c=relaxed/simple; bh=024yPNon1poyVphR8keDLRzye+FGmZPcxiMYS+/Gw4c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ai3CgEkTDtgUeUw45gchaT6iQ/PYVcas64bpYPjzFwAJ+UuR09glXm6cXTyBM7IvQvyNznPrcUpbmOj0CKkmBS8AtUnxswC75mf+jljtbZUEVz4oVoly1xKHJ+zkFdR56j++eN0HmlYBhhRGH59AKLa0GlWgYwfJN4XzM4bTZvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AIKHaRFv; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AIKHaRFv" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-368380828d6so2089440f8f.1; 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=vger.kernel.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=AIKHaRFvT0yFvdKCLaQeJ6ZL5y3si/8rgEfNmcP3plXTy/MPwZYUZpO/vO1pyr/7dd WPwoBQRi7m2biYgSd8OBviwYtt39ZOS53TxhuMoqDZ8E6Bu4gtkoVwMcws4aW3rJHpbM LBfvHc7aGQ5q7AeqND7/KSE89+B2YR5Vvl97bzrZYkJviMqhXd48HKuZdoUF0fwWtKEq AAAPHVwr3G4F5jYy4HTXGSLcrk/8o+4EdCNUnFBKts6bOCRT/np4WW+uUH4oB7ISjw8B 8h7p6gr7qoryOcE6tOLol7m0CUa3BGX5R3x0zm33L7RnnQ7BvhkDnS8BFvFtmZuzsxcF lJUQ== 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=WCrPHaCrojVi0mZjs3k1dkXh3u7YpGK0yYnO5LjQ8KuBOn6ofMiWt5DnHQDeEjHjAv vZzRKP4thlBuOkJjUqKZJBSPevHMtLM73W2xvqfpixt6pMrnnEzCpNtTa18P4RctpzIx w68wbIzyoUKEhZ/88ZJWvzPCmWXxCQhJA8T588RmKMHLTW/4zhWo8q9NpwBdhCyZSkFl uP7PTsrFvacVkEHGzae2+pApL2/SqVWt0yKC3JkXtEJ5kDmj3+F11lY6g7QO+xPW0ZSt 6FYNBAq504kumDARqQyLwX16VWDajCkz4UfsO2a6D6iwcVeTc6W9C0f7YvOoCs9kV0ZV 30RQ== X-Forwarded-Encrypted: i=1; AJvYcCVAORCCHiegz4ef1EgidXSBOwhr72nN0XWMIDC5EUrxmv3jI0WC4g7Fh2A/KCNuN9t4KYpXzNtHX8UKzHDYmqB/idodffuwQTvZaL4Q/ZKKDA7U1HHMKaLK/ZyKeu2ezAer2i6DqjdbVJlC6Koc4OzNaKdE6csaISp1AT7DF0/DzxhztPo6e4+dWDrNmYmzVtKZQVuJKI0mx1US+c7EyaVNljazYXc= X-Gm-Message-State: AOJu0Yy8EuEnk30OzqhzQqkGCsfAjgqh1r2kC93kQQGvE6Y6N1O3KFA9 x3fbpcS4n1c4aZa8eWHK1rXxLurIthAQbFCGjjbT2HCUPe2lEqG/ 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745540 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3632E1891C3; Mon, 29 Jul 2024 17:48:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275283; cv=none; b=DsER/MozBO5dftl3raDYNrJmUDu+/nGxvmaKOR0FMtJ49k/kyEba7NpLAC3UEjEvZxIBBJ0fd9mtImwqK/TpDMzBJ4rGKd1VvdwtCeGOj2rZ5KscJgoWlS0xP/8FzO9v0T0gb8OrCB/AG/msTruN2Ra9AftY2T4RNzzih1/yERA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275283; c=relaxed/simple; bh=tNiZCBQ9vI1N19lL0qdAjIhq26icJW5eSTf6NBMnkgo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uk3JrWs2mECQwFIVkUg55Ykjr+jqueAC4Zi1ACDgoALSRm0/dgPBbQyY+xkFo9vgX34xX4A8MAdrwGGGWOKXndr5KBsl4Rc6Sv4tC0RmY/e2JPoMaV9AdePW8n+zUKNrEsdHoCiodzQT/cnGJnaemJOBIzo8IDaT0NnsDtQRquo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SjDZrpmP; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SjDZrpmP" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-368f92df172so1606802f8f.2; 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=vger.kernel.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=SjDZrpmPRqZU4F1Avg2qNj1hhZuR5QO3ZCgEOfZGU6XJXUZ6nTJKo30b029rTP9D4A wJUD5Ask+ks3i0AyDqBdp+5DFWgqBSENVqh7FHYf3NYnc4RAguAwYg4jGg9ZYaisEvaK WdoW9+Wu9P2E3y1ojidU/PnzC02Jm0Tq8MCLeF+TEdkMvHZEFha+q5ia+NGbO6Jxr6zT oix3iY8lxP70Q4XBrhrBRFcWZslztaP1h/Mxr+dSBJyisxvSmAk4nY545ZfGB894gTvN CchkDzqLdGvEjwLKXXQAxX7JI+Z9t406By81zsNF+wkZSp03ohOz+60JB+tobf8Xue1T KQVA== 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=NLd1jsiuR2tE61db8m96VO5qNaPBKN5C9wPzEXr2RVbemHIyMNm6Ix/SBJpjl53+ZO 4Trg4ZgYEWMC1Hp4GeOkNppcLgmLyO/4eV4WQIHyfqGeaa1JWxYR34L1hcDzWMWDw4Jh n18gr75pvJpv8WBSPQ+ZUtUCHOAu+pkrCUrLsqRymp+3sFxypZwm7VNmpiD0MFngVFUt tgOmeDkaLBTE99A7i8Zz+sJT4Gj3ym5UeojkvP4WiaNVxwMxAvTzep5CPYeBsN5H/Att xTPzLwqRSevsgFt9WWn07kJEbs0UZ5ssvZYaS2ZM59gsjujfvfz6RBncUFOtF42USU6+ gQJQ== X-Forwarded-Encrypted: i=1; AJvYcCVZBjWhNEveNZNPna4+kiD06gSrKMzfQyhSthaugK1HMArQuvH7eSJJmC/hOEBrEMyJgTxkMDZgE+vGkAF0rbOtXtk0rny6wBRcvT+42FGS5Cm9GLqrExIJHJlsyTFoEPLUXyx+4KSJ0lX7L9g0iKMImISRu0i45cASzD7O3tL4G926YwQB9xxLDL+KihO/AfPD4h+eEl8BdavfwX+m/w83TzliG5c= X-Gm-Message-State: AOJu0YyfaY2ndGUm9xo8tjSvFXqw0Szp6iT0lrRZatpiPVvcmD7uUybR 1cBqZ24sI+5pfzNBkq43zKSiE2QAgYJRh31zfdUImM/vABVHrPp4 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745541 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF85D189F3F; Mon, 29 Jul 2024 17:48:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275285; cv=none; b=KGLb0DdqGjNovB9GXNBlkTr3cATTbwv/AFZK35vH2ZRIZqB93xTxlcYC8DMnEld4EvUlc5LUgUW1vpijZW7nJB83cton7UmTt5wc+WEEkVbh94dvFubY5zEcJsvxhDARfU867zyvtlSmbv4u401x6xoLVRI5qRXMJHVR04GkOIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275285; c=relaxed/simple; bh=8B1kt8AWmIpBQPncG9dfhlWKEjLZT84Kr302Znpylas=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=a482yByoJwBV0HiuJ9Q/ZAqff9iNLh3os15tSylnMjPzix9XJxVzqbnOXbQTdGGIebIr7VgD7cvlrLbl29uMeqkivK0uqfYHKS/5f9lXcLnwkGdWe1g/jHg7QZp23h5RKA9LyxQevz1RPw2bhAKmnE9YtFYLLX63d6/0iN1f258= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HDyC7+pR; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HDyC7+pR" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3684407b2deso1545473f8f.1; 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=vger.kernel.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=HDyC7+pRwhK9F77CSG+weYlHulS5UiGni59LUML9WFhDBzN44AIiHAsbJW8v/vKleN 1QvlcLshGwQLjbES78lhuJXRTvoHErquUw0bbMytfLpgG/J/KHL/sEGGcjNsX1RFIbUL LfiHtOHQQUq9I1/V9FkeRo4UkaMl51wWyUv2uZrI1YGQI7EcwbK/4kABgHJWXG3Rb/Pw /PBtDZ2P7bglu7lSYT5FhVosbDzC+FSJhwRsJl1iprEIxUV1yz2J8Hjr6EXHBT56LZJZ GXbtTT16hyS8Dntsfc1yr2FzXchUUHW/vVLNCk5jnjZylqwnW0C8i6FVrnmkQ+wokIKG 7drQ== 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=UX3sx2RTkbB5zl+gt9mNYWTFkZ8btawtuFBHK7LwUhQm4pF8I/hmMuqWE3eA2jLt4R W2gCQkmNKeNkVg6MsS3SjwhgjiVS70YCCvsNOTe04yluhgpUnAtg+JjRCrkaakPAFs5W Ic31oDW6LuV1kkNhp4m2zctk6VOzIs2senfroDkLioy8aiGUEVHtjOpSYwwMJnkB/hfP H891Qh1PlLJ7bs19lMoGBGS653QSofNfbKpWQ+tEq5Ph5LSAkqyUnp2gn2hOOdtwFQ7U vTUJgFGB9zxuDoDX03TPK7YfiOVFwoyBs714DWwLUoljyPLlmgn5cmfASZCuhtSiNB1n 8HEA== X-Forwarded-Encrypted: i=1; AJvYcCV/Ge5pf0hNIqyS0b2dobBxBefnpIckVnmHmXikOj+GGboJwhgx0ZZlwJnwRRYS4QOi5mm0Iz1j30nAUQIkqYMzuy6xrOB0crPmz+4/3jEyBN8/MUFbHR0oHVXXPwukoUAi5XaqW8YwaqcOIpiDmDiDSO43bXBUvB7KvOxl0B/3ANZ7ANnx0nMlH8Ys/pRc0c0rh/IFhJbWLOpXZZWSbOfqL88CgaM= X-Gm-Message-State: AOJu0YzFZa/AxFoin8aL8LPDWuBshJzlF7IfYh0jitEujxETNtF3y/8W 9ddjzZGc6D+mYREWrzyQCtlqpEB81HotX1s6/YJJMCf2TjVy8oe+ 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745542 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C40D18A957; Mon, 29 Jul 2024 17:48:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275287; cv=none; b=U5VDj/mlD5ahCZ0WiSRCCRCln9qKIhFVJcy/vp8Vl70B5JCac2zzYJkEJNAiXZn9rRLr/BztLW5Am6TIdn226EH0FanoI0UWqgxDkaRLwT886Xfd0pKu5i6hoK9MWUH55sIq3XbpEXxCaI1ns8SWkaTy+K3+xy87bpnDxWzIcjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275287; c=relaxed/simple; bh=9RZit0ywU+LgXYJREclxZIzCm96R2ILsMrecyNIUIjE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FofP0dMeQcAsRM5CBEBpGVPe/MC1zXyuNlj6epK7g/iWvE6H2FykLBwh+lPOAHXWKkkwPYxM8AlxhKysuFHqNq3AHQbFvmrfZeITlFCiwuYQn9PIOP8WZfCEIgx320tmESeCxPSNox4uzTguhjkEwHyDNq54w5jRihSFILgAbho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Gd+jF2iV; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Gd+jF2iV" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-42816ca782dso17234275e9.2; 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=vger.kernel.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=Gd+jF2iVX/n9ofNcnSKgPMBiK+97jRQkKWdfG6ejqKhFKav754P4MEq7oyGpH3KqnY A8s2CrINMTstlL7mCVRlmzYUI9iFD7g48m2T5qHOJ3fPe6yxsw4lXS2wNjoLKVAdvNGS AzLMVfQAYOn1+ivSu1HcarnAQYEII3/uBlUxpDlw9vAjRYq/e1B2EQcQdHYg3ymMp35a qgzf7anqhpYgFkm4x1Tie+5H56Kh1xe5cZDrbmqmTMW38qOaKANM36BFSTh7lQNfUNc8 1oflD7RQI5o9SyG3zLvK3+1mtXWjLf/2iVOi8GTxuah9jGxUaTfikBjoqM/5WcIMO2VE exKA== 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=J6oveobSIkxtgaPC+XITWmIpoeq8KRLjxEQrPYGyqiS6Y9NMkqFe5O44PXy8GHq9+Y oFgGeRkEnlNecqdQrCMpgjQgK8+9QbUdElEVgxdyfsIzDPHSiJRuPYm4uVRG026T+15H UeSsiNDS9NP8RAViTxSZpd6YGIyXMdILgFSyE4ck0dt9BKQBIYgWERGfp4QYqgRIuYx7 DvhQdwD6ObfrDhli4Bg9/1CDL4/fqEu3xaIq13RxlT8OGnX1+s0q7MJAzY9vbZsVclyu 6Od2CGl6tyNFIG1g2iPXe1UrVJvmlDgDwN5ocXZGCeQIX5TwSMkSjebCx1lewo9mtdND oYeg== X-Forwarded-Encrypted: i=1; AJvYcCW5QyWfHTXmR/ZgQX4CX7O5j3mzeWMexVnpVHnzFruuvsTsZlPOJBSI+/StYeyYTEUZGvaXZ+m2UdWi0fMVJrYFD1ylOAx8f3lMf8Ebz6HcEzZp48QmQpDnIKu2JOpqaHnGgwPjvigmfZsq4ciad5luo1gdAc7aQGpC1VA2KUyWsOWs7gCNy1aeXGk0A6oX+ZhTSOlbjb0K7YAo7oLtwQr4dYVih5U= X-Gm-Message-State: AOJu0YxD+9zsjHBHSTpH1XMYz2D49EljdZ6JTawyDPLGDvrbpAcSlhOv UUA8XX+AdnWpoKE8ALx7j7atyu8444ViSANGGRA8F+C5qqcTYHQU 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13745543 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2C7418C353; Mon, 29 Jul 2024 17:48:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275290; cv=none; b=LoPlXWneQ3yupVbJwBDQDeHGuiEi/yrAl8SGC9ZQAo+LpGHb8/mgiScyGQ1hmWv18o1Qup/J+B7R4FlShGYCg8V0WW8/32HDfbmP/9bO1WkGyDzLEDksWnxoBvzvafyQkc7kKS95fS2AgWsk8TQxgSBG2sfZW4p1MJybuSyEpsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722275290; c=relaxed/simple; bh=caLjgArHqT0iX4aNbMz7ThFMSlU4O/1uHusrmF0QQ/8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W8xYdQvRQ77KsY8pVP3RELR++Z+5kU9EQlzhwY3AnRS13Lq82eJzV6JxmVZoIlW1JOTqhNmVYA+msl80JipauydWXpKGvrd9ig7L7k+qY9ztuFx7Nq2PT28AK6BP2933AWZqX9pOn3Jg6sKbT45wJA477mFJg5kGJW9lgXYiMiA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JCsUWP4d; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JCsUWP4d" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-368712acb8dso1525981f8f.2; 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=vger.kernel.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=JCsUWP4dsV9Lq6lDmbtXQhmSuIfZVWGI7N8ZcUq4W9LxOrE+mFrjSSXPJe6NGTjbp+ haeYwOo2jTrvdHtjnN6mI/R5otoak7fdPAENTkAzXMRo4U7vcFhUeaexFQhLG+gHAzQ3 DeClsuQ3Fnv4HK0ArVtXXggmd6ctsg+CPdptYUPYIqpcbVO8NiUzWBx8hmfr1oV1PjMN vj+9sVKYVGhqVcR4e0f13S3yJfBEQGq9FQOD9nDExlTJp89HevsY9wUS7lxR6KhJuCbv s1w8pp/tDJwu6NtfqvXBInbFzfz4vtL9NvuAbKuhY4TKMjjCIREM9Sf5wzcDU4BFTABJ XJ6w== 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=o8QKX3XT7OnAJCtqULbYCCTjmKFGkStLgSoqp80u0roxom9EUAuhwoZVZ0yHqK2YKG 1b6gNxIFvtuVguqP3xE6Nb5q/BBRLjFPiF/smjo3WCEPp2jjBf19sEGGryFJ0hVvVdiO QrYP7lCx7vgtQOlG4Ad8HAzuT+jz6MPmyp9WTjOc+BiJyl5jkqofPMxtvm3ME72sdlNG yUY6JEGSINNeYv/SUO/Up1QEIsm/MSSen6R+1luL6hr/3EL6NranLPuDD5Oi+vjyaHyi PUGMYYIKJu+TfCK9NBJBAmZWBdLHXDfUugADY+RjRc//LJSnwc0LKnkIOj7H8mSMUP76 875Q== X-Forwarded-Encrypted: i=1; AJvYcCXwGL5vZkWGxdseOnuXBim+MeQVQGf7FmdXWWO+YEmaPpILFMiId1IqXNJYZhgdmHuFm0Bb/fjDZi3kYKGp8VLJ/PthtgSOeAzfvMrgfc8R//lN7WGHdLQWs8pwYlmcm2JLJ3n0VNJWiJLIgRbrIdBbGGY5/HYUHGwC4RdWuUIH6bVeLkyCbNA8/AwQJRd8pZ4Khf+iKV6l6iTwXUKhht8PHhFfsts= X-Gm-Message-State: AOJu0Yy0C5o1xJOGm6keGDGGHu0cNwyAkz6hzYRGahPXIDsPTivajr0b /5bNJ33oJVlbxqMCZd7KfTRmz35+wobVkBHnCq9WBY801V6tIkac 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 Precedence: bulk X-Mailing-List: linux-samsung-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 {