From patchwork Fri Aug 16 08:19:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 819996 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 7B9CE12C465; Fri, 16 Aug 2024 08:19:17 +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=1723796359; cv=none; b=ZLV7VAj33sT7tn2+DD+wkozESHNz1JM1/8sN6N04FJQyetg9ujgOzn+90wcFhlcY2vdUTfQSIHoWb3KH5Y9gWlSHu/khJt12v7hnxx12/MvQQr1stftx8FzINJAc5kZd4Jkpfz7zhNMkTwvo0+9W5twCw2HHKVAVbZfqsoOgexA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796359; c=relaxed/simple; bh=hw9bscDFCN3vQXC6NtThwBJyizDt4UmRCGdr2F/CUvE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ttP709IFDdXHWcMhYMxG+MnY7bevGYu46wDGXA3byudCi5iA5WNbp0jraanV00VTyUh2mWj5EsZzeasxcubAm8SAsZzFVnYGmeQNby4pRx9e93MGswnGSltZJl+RSPKXbtEAqBToTKnpLpFqG62crSYw4rbzrPlXf/cqt/wjViU= 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=M3dk1ZJS; 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="M3dk1ZJS" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-368313809a4so1429775f8f.0; Fri, 16 Aug 2024 01:19:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796356; x=1724401156; 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=OuFOTwnVfJo3Y5EGzlmZmw/h1XsJN7qD5nElULC2qxw=; b=M3dk1ZJSboFVTJu3ob1+m++WC6CKJhDJkVVNPXELlI65YlQSuBqfegG8ur8C5bXCst BkRi2B3k8Gu4c8Fre6lvyg5qHtz9PLlvzlOq9nlF864H5d7rC7T4doEaSQShkCi7CEU8 ky2bnSG8HPCH5v/QLkLASCbjuHPh77cEksh2fC0PV7Z9GwmiLJGNUoiw/SRkNN9+4Isu 5Vs2u4hSCpyBmYN98qI0R99grkJCtp3kvUBsyI0lSqkN6uuptaJYXGg5sG9kY+302uYw Mb0rQsR0g0p47KAT1oCm3AKLsZlfUyKXKB/iMhNN1BERaXRqoNViL5OAvNbAjXhqWcC7 G/Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796356; x=1724401156; 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=OuFOTwnVfJo3Y5EGzlmZmw/h1XsJN7qD5nElULC2qxw=; b=HVU/dX4VqpiFApJFSWrhidi/GDAyrKBLdWRaVWbpRuMPHTAc+i20vDkPMZ/k8eRBhI onaUPNUQYQM0qxF9Ydi7EQXQavQ3eYhZGd604m3Kf4HCegTsTtKVzZh+DmMTLxLIWUoM 0vw1+9G5avFv+5vYZtrbppNxOSW6FxxL92bfYrEo+3o9PnCamkNah089BwAAaQWKggja HXHbaQ25IAVA3LaYZCSnWVwH0WVSK5TZwtczS5Sn8tPf43FPMs5N5IZlHZQ9AAQPouvS psRr22zvAwdxN/kj2DScfiWwfWfhIOfDtUY4qBj+qhPZMdemPx66Bz4ZFEodMje+baor K1mQ== X-Forwarded-Encrypted: i=1; AJvYcCXdMFzMA37sBeEbyvySxaiP8VB9Ivr69SWHNUB+i2AWObgz4ceCCSKPrYFS6ze4Lz72Latmh4fVogG260WlyhCl27BsVwRtR+zGnr8QTBkr8utifEKT8Itx/tO4ucfUtIRpSqurd7Dto8ft4nUlNEFBq8Kk+oXmcyEEiFho174FksIkzV1igL8Sc+gMcDRPBl8amjQI/tOJHAHjJVMbeOn/tgA//b8= X-Gm-Message-State: AOJu0Yx3zSDEtGkk3NJdfVLrd8LK30Tza6Dk4ZSpBZh3wavwqQij+pf/ obdMoFtfEIFS47Bt9+RSVvm5KimYE1BZV1mEPmA6v+eEJ9Har77l X-Google-Smtp-Source: AGHT+IGGVQuQ8zMyFMMGEoBO6ujH/sr/qCBYErhFw8TbTMZzGRD67A0Q/9o2jMrWQj5olGsuXutEBQ== X-Received: by 2002:a05:6000:4a:b0:36b:ea2d:fd5a with SMTP id ffacd0b85a97d-37186d7b2e8mr3437830f8f.22.1723796355464; Fri, 16 Aug 2024 01:19:15 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:15 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:07 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-1-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=1566; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=hw9bscDFCN3vQXC6NtThwBJyizDt4UmRCGdr2F/CUvE=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt9rAhxytB9Lc18vnFg3zgPPljMqkf50Mp6b NdBnWipLeeJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfQAKCRCzu/ihE6BR aPJhEACdsnef5g67ckXGS2TQ1QCDItHM8qP/BfBh5lcEFmL1LK8IoE4VSxLhJn03/O0hTSEoOU7 l29k1yLv+vulxktdeuAbrVoobqjnQlhHk1IQg4Ek3eDOI/JOr+zWL6l+WblJjuhPliQgBvSm8xM dKOpoiBmQaCg4vn0cNsMNaUANFZvOFuLm774j7B8uWE3FdvqjuZ82/WMeDQTVrJX7EN689sVu2H ZQWgupx4QwWP7Q8y5QWkEWqT2QNc7w2k8fHdoQm4NTPsHeM86j0SLxHLuWjMKyi4TN+szpvaibR k8I/peX7DmiU60ewbBzbPja+HBcLoL9HXpEnwZvG2XPK2My/1jvBj+8m2mYsgd9tJpCLACeAgxQ MvXvrnuat/rOpMgYVqPHC0w/wL7oPGcgx2YQ55DYabvAmaWPmg1Y6puh5djkZWL0C0xAF3z1xNL TWhVrFUtUCZqTrFRADf7iVDibBpuhVBBjqgzJ3EYks1HrmEbS1OY6FGtrZdyRgJhzA7UITgxzXC wW/0+Tce2/7lmDTP93r6b1irWAo20GGBMSLFLCzQAKWVamsx8wfm+OdehYJAD5gUiu8YwQzXth/ cHz+Q1Hi5DTudsTlIStQmDEhc/f50nUxy4aaFDc/ruptQ+of5eLuySK+y10MhAum85nZYgYJvMn a3r4Xj8BmCqoKAg== 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 Tested-by: Henrik Grimler 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 Fri Aug 16 08:19:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 820888 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 26B5513A276; Fri, 16 Aug 2024 08:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796360; cv=none; b=s2oiC07xXRFsQp7YogQjNlMqsSJPqOT7Jxs7AhZYp3bvY6wZ9Ml8QRjmTfHbFoYVWefNBfGO3QUNQjBviK5SeTWOBxWhRMt8bOdHcCuUF/CBbHgPgJZdMahIMd4lXdAy7BJSbMiM2s2YTXMMA/xGXuOyac5VQpVo81j+nG84S4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796360; c=relaxed/simple; bh=oLtK+rl/xh8MKLhG48HPNKV+158PkAGnfAvRTrZidfU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qiE/2cf/fHxoqksTR2JFX8mkvFaRRLNjG0UPBCFUdazsDtVPtReKedWPkTrZdHYc2E42KBQzGInjPZ2VDsaDkyQ+22rP8hXqtkeB0u5kwxCVqGazSQQeqOL4dr6RqRGW3VxME/a+l2++FBAKL6mbn7PdaTc4AkZcAVR/cFMf+us= 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=lA8rz0S6; arc=none smtp.client-ip=209.85.128.48 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="lA8rz0S6" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42819654737so11597205e9.1; Fri, 16 Aug 2024 01:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796357; x=1724401157; 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=i5GGelLjYWwSvPbwd1YOlnT/u3Ig9vn8D+D3f7YMN/w=; b=lA8rz0S6cUQxWCtQD8hEfC65g3/p8Osz2Qd7wpU/mSNdNVn7AujdO6h4Dkp7cdlS8n aULWwhKpwKNP/N2eUeAOfXQvmezo5J1twyyCw1+PxBr+4ZPFoTTGqjhJBsjtJJjNgd4H iqwOGIS0TFuv1S9gxS9plreGBF5plNkpbjk1AXxKKSRy4h02Y7MNMhNBBUXlJaY7WDL2 LmsvnJJ5cIk4cUk0tQRZ0EyCF/fmQXw+Nz6te/SA952+kP2erbEWEtlxqMxasF8un+YO /G+wSY5HrL/O1ldCjW/LKoI0eBaxJP9cFoEVbFbWJD9qmU56H1Jd6RB9gzFeKepXmzOS 0UAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796357; x=1724401157; 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=i5GGelLjYWwSvPbwd1YOlnT/u3Ig9vn8D+D3f7YMN/w=; b=I2oxzjpo8R/TpwcqlGkIQhYY9qlgvZ719sMlJye2A8lRfY8IucS46K6VW1h/lSkOkv Spl7pa9q2mS6kM2PQvX3QZixbM+KvnIHTQNiX1z4gHOdlXSv9R2d1m5wEJHFCHEBy75B 4VBoW91/z4cIS/p18cSJhfPVpwC0j/Eqqwi6/KbEgmF7ckSyyggyk9khVoAPtOfSDVTd uD0J6UDqxrYyyhy1lgnwM22JUxFXWoy2O1A5uNAA9nyzRJJ61RE/BzKHJ4Lmt46UtGyj khnDwWaU/Al99dXp0LRWlGMK+5HJeqF2QAgnKHr/VyOM1OZK6rdVruEsW1Ie61eLgMGQ PuIQ== X-Forwarded-Encrypted: i=1; AJvYcCVGeeqUyc+dzqF5WeLVhHCNPPngzvH6R8I1BWIbH9y8UpNOjGzg3QNBlZHt0h1ELC9Wz7EKMbtlQm5LMzfKZRDP9wlddJ+eB5bZx11SB+NSgbai6Njdy9w5metzMKTwBxFG8IHuR0UE03vcwPC0V6G0IvkJbtmjcGxXJIv5QqyUgvKI1teC3jaJ49qbr5/9oEuLnPzuYDlPHQcWfrR0X4Y6yUjRU/Q= X-Gm-Message-State: AOJu0YxJqbub2GjoqGlBXBnMfQk5PW7UyjcRqEO5RVTGCtoPXjoUfQGz zqdgVCf5Gc+WanLXfN0hxKArXuD4KSrd8ecLAPoEz9DxRI3QInVO X-Google-Smtp-Source: AGHT+IG+Uz/T5oTdVQui1Mq2wyi/zZtWBpLViG8h7lZW49iHDcyaQtP7H3xLp1xh2IZsa0WBRX1u7A== X-Received: by 2002:a05:600c:470a:b0:428:3b5:816b with SMTP id 5b1f17b1804b1-429ed785f71mr11868585e9.3.1723796357298; Fri, 16 Aug 2024 01:19:17 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:16 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:08 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-2-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=1177; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=oLtK+rl/xh8MKLhG48HPNKV+158PkAGnfAvRTrZidfU=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt9+Ha/AoAqXfYc3dWFaQW09z6DS7oTYtY3C y7Bk1Eh+/GJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfQAKCRCzu/ihE6BR aLbGD/9ytkW76lJ1Y7PNFfIEcx6RH2wKgUqiNbsDfsbHinrY/kozgUOSEKfCTr+HZ9BWSsS+H8s tavLYd+CwYoof3p64J90xQI9+XCWJ1sX3ICvkjtxIRP1mJfDa+hWZ9eyIGUuNHRoGOKiF2eWBva DLzkqq8HbQX3p8oGjAMKiHpKMAjvAzyVaxgppnmrKcgJCW25A2JEC4Fzmo2qtPpwBd6I4Nl3sqr dud6O+x8QqifYgQo2OmROqAalbg9nBT2m66uyhqWJgnhKiWeWeh7SI/+xHNxpRHDWo8XyuQNVnD bRJ7vK4otQmVmer807sptQVk34GFzzi5DiMdeeyr3K1OlvZ4RpFjCj31/V+/eEBm6/+PHwcGfsY c4ilvB7SSHr2Fah/unnXj0g0gdq0GcAPRF/qM4ph1qNyn0dDpLZ93O98CzUzUSNBOOgt0Vn8wRW 3Dy3rscTo6cjoNXkYqQnFB/BvCSIdXyVeHRZ0PgeJ8wid3AZwH2ueClPInXcRvKlGSiF3bdHWeT 1aILGfsrr2Oxnso3aACavX8q+mpnwZfepOWFVmGHm6/NYFzzrjRSZIzyLizm46n68aMPHkbOjUE S6hLSwYhdIG1XhcVaKITS3rJaM2f3s3YZmLTSifS4zQdZDkaEh2cz8xMwyB0Vjdze3pWr0zU9kR otFxrpN+LOjxwcw== 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 Tested-by: Henrik Grimler 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 Fri Aug 16 08:19:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 819995 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 0D8AE13B5B3; Fri, 16 Aug 2024 08:19:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796362; cv=none; b=Awt7Um2ncp2fTAYXDPgUu1w4XVPR84hEy6Fa6vBoUqxdRJWnvEC5Lo9aPJeBGiAic2cEVrAOVLaBrg2gnrCUAfPzoBicX8/JppX9ax9Ku5J+bITYFoilgXu64DxsPtRM8W7tuNDRBbyhDRB7XRXXSBrt4Lc06pu89wcJLqQfpho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796362; c=relaxed/simple; bh=9IYOJ5Si+LfLkVCi/KMBWfaO4SAQ49FCSsDSX2k02RU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GUcEF3UdI+lYbeu14mTS1jybYubgjgVDmspbaMZkC7EPVA2bCYKuoEpA+F1xrwKp3WOafjZYjFj5Ab2S+XrIQnCDvU2K0/3KJPyV8f0Ki3H1P6mMEZndA84uAQPE2jRMNt1wqrXydNFxo9ULzlhhR5+hiRkuXQqgOLVM2x5lVF0= 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=E2jLvzgi; arc=none smtp.client-ip=209.85.128.43 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="E2jLvzgi" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-428243f928cso12312855e9.3; Fri, 16 Aug 2024 01:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796359; x=1724401159; 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=ATiloHsMDaf4CMk8cdUWOTXJanYqTe2+ZJJOm0eYxfI=; b=E2jLvzgiBUIGYc56aM9oJ8U0USO0B30xfOjacVzxFJL854sf/mr0rpDk20iyEQKPaW pp9uXmFSnVbM49m0UHrGrKfUh+S0RTcjxafVxcQvVI3l3ijVan1B/YiLUrnKkLUocqgc cL73XV8LLOPXLZM8fA5g8T5bu75WDzR3lChUv+VT0A9/EXVlZvgddlv+tWoMGQWL9oQ+ OAlaL14DdI6QoNbp42jhzuhbl3YsDepTyrGZu6H8+mkzEC1hvQYbQaoeq9OdVjG3LTWk U7WZnGG23qLnpGMfF9yJ2Rm+xuNiFEzs2j4/nGbWQ/9LSjMDTpE6hGz/0jKxFUysiZ6B yBLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796359; x=1724401159; 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=ATiloHsMDaf4CMk8cdUWOTXJanYqTe2+ZJJOm0eYxfI=; b=uAbENiQKJNDv69/UgMsgPtIH0abD17q7JkyEgaKnIYh/jnO4Ra6w8OphsWekiasRUQ g/gjGOK5NOEk1QSGvrTnEZv9rRXtrV5s7u6EDZ4XE+vfE+/SuHyLHxbAh6tIPge7eo21 2BRWsKBuP9lxGaZ2sK6g758cb2J+X83qtb1ptQcFGGZEITuiLrxYaXAbP64chTcFZjXZ pEAwPeQ1fw+qhUkTQVU6aBFVFiScoPqR7NENuar4lqqAfZyNNH7T9MEG8p1tTA7mRNOx ggTikK1Dx+5ptiXHfvFOm7paXH62nS3QPj9PmwStpbO0Sk5FO0rsmzWG7ONhsQ6IdHe5 M5Rw== X-Forwarded-Encrypted: i=1; AJvYcCUEj9fkQYZdO0bgLdeHfh3aXxao1/9+ntL8JJYE8SleVOOUcqkgCHVnjprS9Ml1PF2uvIkgaHzoUiIPu0fayBg7A0J4hBnCHnZJigr01Vg8YsHG9cbxlVzqCwJ1tnvJllRjv4FdO2huX3Jxf5KuNmhARkd2HCiKMGHwceF0PoGNiK5p4mrdXuc76At5uqylrvwESiajhF+AP6M5osQMP3ZiFuHWv30= X-Gm-Message-State: AOJu0YwUakQRFOflWgQ/si3L9c/1R6MxldWpdhB2ZSQQBDc/SK9aCgLA bD2KwtckWrPgpff4NbKwj+Wf5E+sD0XixteVRvWdzvurqWSxFedk X-Google-Smtp-Source: AGHT+IFZVBfIxeRRQQdYKBVbIL/LlcK8Xckk0mrM3X9pjm13/8U5f09VuGWp1dTEiDNUiNzFSTW+1w== X-Received: by 2002:a05:600c:5254:b0:426:622d:9e6b with SMTP id 5b1f17b1804b1-429ed7cce32mr12561705e9.23.1723796359212; Fri, 16 Aug 2024 01:19:19 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:18 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:09 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-3-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=4267; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=9IYOJ5Si+LfLkVCi/KMBWfaO4SAQ49FCSsDSX2k02RU=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt+B9dItojtyq9JMOVXfTV0Y4E6HJELeVrGz 5L6JIMqdPaJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfgAKCRCzu/ihE6BR aN/1D/44BbqpiUrmya2u3MQKsTMDcLUdMN1u7gjA0nVafkmQycc9654R/GBZ2Qc8fC6eLbFVvsB dhn7slD9g8dHpE4drqkTLFnceu70q519uo0ZXz/Jzv9EqYGOsHsGUjaqbolJeiWrYsqOlNxjV7X 2QdHze/Szy+NbdYxDTKzc6osxPLV49CylDodw8SDt6+xUNZDSRmC591KLSBtKjcHQMIJ2W0nluG YI47KKnt2gIMlpv4DjM33BRKVSlC129QunHtWLyDkVLdVjyU/ZKE4BAbkKLegvrcxWaA2TwD+Ar KtHiMx80shyu0bytyFB9BomXdFkRcI+FnQh0EpbzaupxcUA9EuGgcXV0isZ58CZrtI4iNSI0355 js19HfYVkZet2KcBO2+1eSZfC5V/5Tqk7xbbFisItCHDCmypocICWAOaVoXSHa1vCCIrMDbgz8V Mc4EVG61GuLi7dgDebwmagpTLDNrEuLnMf7X8iNiNEM5hFUdiuUn7YIOiR4lV/Csj9tfwJD/vmy 8fnO89flT2asT+YGPp9K9piIEf51CD9Otv/e1ZreqjM/5VcQnK4chCWE/9z0L25aJTWqtLAOMXJ xP+kkoiYYQFENRzGThOaVu4gG24BnA4amHOmgOMhan8AlvzOBUaFsLgOpP4vnbnttdrjg/TNlAr ipZLSuvMlGMuL6w== 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. Tested-by: Henrik Grimler 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 Fri Aug 16 08:19:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 820887 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 5F30213DBB1; Fri, 16 Aug 2024 08:19:23 +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=1723796365; cv=none; b=e2+h+oObXcvLGh4XILxYwICXa52kGbEC1M+mZ5tahDW54rvhEPhrQcL4FbF8nhi/YAzMqlAcoRRwIB9EeDzAKpVKFpNvVlpKnBNg3WCSOGxQ52g5cEJOgKAS/M+hgI/NCYCWJXU8QZBq9RKZ/RdYaKTPL50lHTV4obSa9RXlzZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796365; c=relaxed/simple; bh=O9gPJjPhBFB6wY6JOoyF2PfCabTLSsjOOHWK2XU8fpA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sVlHx0FZ2KWwSPM4fkRmNoysIlDX3U04Pb/zVX2sLZc/LegOvuINMDXAXoatDSVCaHlzgbJl6rWUQFhFTOU1agB8JWVJjL+w3BnMQC6fSRJ17uYfe6zd7u+t5CNjuZUxj9x04yHp0xZmq7gIy4mLlO8ABPp3MMCWxry5D5CfazI= 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=PG7XcH5d; 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="PG7XcH5d" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-428e0d18666so11793255e9.3; Fri, 16 Aug 2024 01:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796361; x=1724401161; 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=1WWrU/IhZI7ilrsVlKcVr6cPaQA4CGMInWjIGFs7Ke0=; b=PG7XcH5dd2B98567UnHWklcI/mLghguwjBhj+CgsbBBNMU4QY08sSndclwQ8NLz9p+ M4l7PUaImETd6SM16y7cWDGWwfUfqIjGG6B33fgo6GskC/vF5qQ13E1y244Ei7aL2kGP xmn+aqSjqkZ9DYGPAWQgl0qu7D3EZwFOMz11kNY9bVZFqIS6U/+h5+LUDcFeHo3sbGhi efBZXyNikJ8mbbpG+CSRIuOQlgOxCB6uHVrgMeCd6amSZLV2rj4c3Lqdk5xa3T9jzCZS Yx7AY+AUKAQKcsVpnLJ/TZk9USYkEyn326p1h3R9vPd9eYW6itTyRAbdyMfoqP1K4KiK tE/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796361; x=1724401161; 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=1WWrU/IhZI7ilrsVlKcVr6cPaQA4CGMInWjIGFs7Ke0=; b=KDDYhpAZmp0MguTkWNU23eABR9D7eo2dOy7Xb4mjvZW0Lbp23KysK1QW/KiohIdGdT TU96FmPyAAoKiNbspy8TOvDEK1pqqKD6f3ur0mB/Ri9ia+KbvfwWM/0xHhaaF5/0EzOR lRnOsZdNxocAtXSbf2pOKtjgDEFCJhlyuTRmrZm7URXLpWUnhfCUJX26ef6pFKa17Nmy QMj7/uLrXwbh06IwGkoiad3S9awNzwdINJKn0Kl5ivUZ8K+g+D2ftk2ejP/aspSzbd+o jOrJ5Q55K8Ohu0Wz5wfIKqrQ+8Le0ua2wxc2NY8Ih81FswGLu0w4s1QYwx0mYSUqP2a5 hFUg== X-Forwarded-Encrypted: i=1; AJvYcCWVaPleLy9uhxN+yBMlDC6+HN1xv7mKiOg6DPevU91Q8VeyMaylqSZhdI45Zzzhig7sd3rYAL1Y7u1b3LrV708dEqKKSA0zfkFqY/yaW4PgwLyuusbZmCSnO+b09E2We7NUHMz9BkW54ipOgy/R6dddztcylhg+erHyxPdPDYxylpQXePIivyPOdudSbOSQSL5dISiTIxgiWDs0CbrCvfDfzZbrf4c= X-Gm-Message-State: AOJu0YycLkXKW/cYQxilrPWkIGHdx1NlvKRLwkuh5dB5t1Xdx2jypmLA T2qVMu9Cohh8AQi8IX9emjrMcCBLLV6PBNJapJ2VSlqHismEaSJR X-Google-Smtp-Source: AGHT+IHZEwmPcEwGMYSPrvNQrSpzwEB8NrVEx6QaPgbgtcHMLWLLrST5VTOPheD4XXDO21urabek5w== X-Received: by 2002:a05:600c:314d:b0:428:18d9:9963 with SMTP id 5b1f17b1804b1-429ed7af165mr13909755e9.22.1723796361274; Fri, 16 Aug 2024 01:19:21 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:20 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:10 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-4-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=6622; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=O9gPJjPhBFB6wY6JOoyF2PfCabTLSsjOOHWK2XU8fpA=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt+rPUakPqDDCGIs8ZJ8QcWzhNDAs+vmcxAP svzhcZgo0aJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfgAKCRCzu/ihE6BR aJ5hD/90NIWNX1ccu43LK3y/OwbWeDT2FKDFRk0LhT0wgPl4V2Lr0nyP7zAhA8w9SMPIM2SlAuC Ohz0ZumUfuzpgKC2UUaVYqMlTy5tPb4L6f8fzOw9e6z4FUq3Q6/xwWE+FKxmD1UvcauB0S5+hYr L4sZrrk5mo30hYsEmOLPuv92T2zuHx0q3iEuKj2JVusmj+nGZuVuiEXBVKhCJ3yiVfF79Ve3dm5 oPGt3mFDOW0oBCahx9RlWn0NsNVOpvA+eMED+3/go/3CeV44YzAUxSqXR+7rNfVF7w8SzXVpBq+ 7K/e2NHi/zlpbSzOt0MsZkCgpUK9uvauQm9oP+Q6WEqUIa6IxfRPl/ExjdEbjzAN5ZfGlCrDc0v l/hcWCNcIgxRYVIlwAUe6dhiCbNWf4F0XZvTzqBOKwxC28U4liQ8SEmhqUo5k5tDIbDxglFcLWC JUkFllKmOOKtg8OBTtR8iBxJ1D/Rl3a0qCMQHXhgximy0dcjVU23fDCrm5037eUHT44XbWGnjBk 3VWiMKZsGJ9XrVDnXFdG41zMMr4FcWPIeXOssy4fKmD/NBj/Er8qbrJof8YZfDfZ43/TBbvBZGe c7CGJSsY8D0Hm7ALYiZ3za25VacFBiPmkVDStIWRusQIFnESxAWqluQxm4KaTC0tNcD675L3I/v vTbVtWc3xC+Tr/w== 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). Acked-by: Lee Jones Tested-by: Henrik Grimler 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 Fri Aug 16 08:19:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 819994 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.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 AA47F140360; Fri, 16 Aug 2024 08:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796367; cv=none; b=cOTrgGJq9CS7K4gSl4lY/cFkJ8YxqKrn3kwT/2comcsb76Zedc8pDGdAZ0N+zmkrViDDpyspBVFvYbvrKzirbo+3lh1VhXbgC26GvUitxvWggWQDbDnuPbnJWdnpgvluIMYXy2MJwIgWFQWlSUCmafoikxVYnew1E9Iw2wHZ3cw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796367; c=relaxed/simple; bh=6pUEa/z1LpG4I1N0jklLMxkabmUriMb9vquyocxTwTg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VaB7fPJRkUGMc8dyP+/WqXxn53UuroOXa3ob2OckeTNounaxm6juLJp3vpaoi3+JY9DOPQb/lAoOfIyUDZ90mCWK96Kv+0ZXOxwKuUUUUG3I4aSh1DU0whIY1rPb2lgNAKBDJvKowamDLKc3eEdhKuTvaaM6k4QbUyIGUYvAEPc= 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=O1qMfOK+; arc=none smtp.client-ip=209.85.128.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="O1qMfOK+" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-42816ca782dso12730945e9.2; Fri, 16 Aug 2024 01:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796364; x=1724401164; 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=H0VjY7601kLqnVRjaSR87BnlCssrimW4yWJjrae9bpg=; b=O1qMfOK+/NOUGeOVlnuX2IM47m3G/05JViQwElXeLCkp4gnYyTcc5Ed7VmCfxaoqvC mrHHOTYa6wI844RBkNeZKE/SMyqvjimVhx6GPECPm85KQMo3jUk5E0dYF08HXfvaxFo0 DZH7rEFTYZBPqoSnL7n0+VSd9EhpcqWJzHYdkvGTwfWCNM/vaxtgS9c99GGlItC9rh+p rmkJ5WgpCLBZYWeXRVMR3rECHAfpvhEtDuzaVus1W5Ma8Nx/kXWlXRcSNz3cWTam48zI vfBJ76prVa/NVafyoqqNCL4xUufCr4zkPi/XgY9slNwABBJ+AMclAy4BqEOE970Mwm2Q njUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796364; x=1724401164; 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=H0VjY7601kLqnVRjaSR87BnlCssrimW4yWJjrae9bpg=; b=FyyiOM2qq2sTn39Zjr+huWcz5h2qo5+cCp819qIFVLTe8kwh/z0N8zQU2mJ9qkpprl hrZCyMQ+5FHbLmpRYyTl/VJViD6B71DzPv3qo+m98LvRovqjslJ0nbS4esx+6IlY/g7k 1nJ+/yqbEfgHNUAJIUFS8mtmf4/4x61LH9f7wT40yj3rXtbkd4Vf5lo2x5cfKBLuTd9Y lPbrF1Eu0Q6QHqLWu9hiX3knNXnh0/1pdAUgPceu746p9JnSLKY21xxASHEtHoMvAhw2 pvhrbc4kXsTKfigv1jQRdqyFnIRfea3XaXJGSq+gAcFtqyo99z2SXJQ/tTBCcRY6GccX mZiQ== X-Forwarded-Encrypted: i=1; AJvYcCXbUy4u797k4PRAc4QeTT+w337o+LwX2Mkef7Ca0qaKUS391b0mH+32Ym4T5CYwDT7Ih5Fpm0HJnM3It+NN/qnmViBi25E71EZ00bmFd0yjL2CF0sBbZrfMyXbSyO8p43cYXeLPsLplsx1p+h/oKO4UC5/rpR5GcR2FE/4rc8qw9LGU/ILLUCT43g7B5JFg6cJ3yoYOirzGSu7UzK0ERVY4Qbp+oik= X-Gm-Message-State: AOJu0YxFLbo2BajmJoGmiOBcdVoAaUDGL/HpZRVFHh3o5RNRXMm695kT dNUFKfet3U32StRSK0fGGjz+TxhAMgqIKfLKdylUI+YvqKXAttRk X-Google-Smtp-Source: AGHT+IEiFFDQqMF8QgPyT0z9ZHgrr2uIL5HHhcaOJ5FP3rUqg97S4HoRfBM4xlWnm5CoJ0V8/bA7AQ== X-Received: by 2002:a05:600c:3547:b0:426:647b:1bfa with SMTP id 5b1f17b1804b1-429ed780642mr12963605e9.8.1723796363711; Fri, 16 Aug 2024 01:19:23 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:23 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:11 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-5-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=6402; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=6pUEa/z1LpG4I1N0jklLMxkabmUriMb9vquyocxTwTg=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt+8h9TAdRRpp+MYN+z1MTgfK4MwdezAyecY L0tGGVUHyOJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfgAKCRCzu/ihE6BR aCwHD/4+5OtgAWYW5evgF17zGQOGWQ+0ZWdUpL6NXjN5ntkmEMjjRHP5Wzcs/hzVGeWRrXva2QK jW79NxVHo04f+/n/Gd4AzvlaBlIE7Xcx5YDwE0bW0DMoHyObESv8ixIorAQ4qwHFDcdsC4ocUBd Hcvj23ARvHQsmAQ+sIPAepKMKAJNIJc1kexeXL6+8e00ZiNO1b5JImBGDZURAPO2wwonioyaXqh sduh7t1jFmH9slClur5QuekezehIQjoj+MoLTc+7/lVgse3kCIHuT78+QKt/7hhEsgBo3jSvyg+ B+uuxBl8FtJPoisizdv+hfaOVjiBvMUs+N6gi8qZHoWwdTfvFqb6biM4XPhUSmL+Q0pVzVyHRcL GEEjf32UviPLAXAyySMGb0BIy2A2ictFLux7bM6ogWpHUhW0facibLpp9+kFjAExYeEXDwHExfk ybQsr/QIiJoPuU9ytZM51hi78yt47P3k8z2K/Nem5rHOPJTmZCMP+5IRjrDx7ZCrP05yNe3bZs/ 6IOYbv2QwFlqlJ+bWYczrbgLxlKNNMXeRet33W7P9459LGN2dJy/cQxopqiO3n5ofNIW3vPTPvf LQwytwLGlcKblw3oDdY0xyLGQow7BqAKzc66fYrHtxdFv8wlCr8qs6jDHxZh83TSQo1Z059sQKT RftZqJJgdjrsKSQ== 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. Tested-by: Henrik Grimler Signed-off-by: Artur Weber --- Changes in v4: - Fix missing connector property causing probe deferrals 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 | 122 ++++++++++++++++++++++++++++++++ 2 files changed, 123 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..d67857d2aa0b 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,34 @@ 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); + if (np_conn) { + 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 +913,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 Fri Aug 16 08:19:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 820886 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 732C313B5B3; Fri, 16 Aug 2024 08:19:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796369; cv=none; b=H4rkETnOZNxTfnszFVnj8Nb8mNKY/IKLePA9ePlZmwgsuQhxoIBAkMCtvnWTdcw0wPRRVhKJ+go4liuG2ldUhlSDnZYxWD/v4wEE9aIRWJMeZbVzJdr9L0pyeIf37Y2xonKUx24ihMn1O/mvSj+wu4YlPJ5xZjOzkQQtRJmJIwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796369; c=relaxed/simple; bh=9tKk8IBY8YUSIH0ECZT8vZVS+bk8IwZ/nsbmqbh0O0A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xe1GMUFSqedeqoEojNPv4UexnevlL9HBYE/EIGCKne1MCHI9pp5zFY55M+iY6rwNPrxFPaLsZYaWqqVfZlIAh8TQN4VzZyIXuHKqy+TvWex33J+dmPIWLynxsvwwe4qr6MGgqFuuWuw3DJZA0QDNzyA6kQPM/2VlDkuIpbQuitc= 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=ES6lcZfS; arc=none smtp.client-ip=209.85.128.51 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="ES6lcZfS" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-42803bbf842so17290545e9.1; Fri, 16 Aug 2024 01:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796366; x=1724401166; 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=qaOD3rKusxi0zQqgiaHpgdf4b2i/F2QB75S2grdzC44=; b=ES6lcZfSZKWaK+GthUFsArt2775eisvMTjvmAe6oY6Dkjy7c2DCxHY+T1einoayKui 7/8O8/P21tggZi2A7HMRfktCY40HPMmcMhdg2pUcoA3k0s12MmaDDWAOB0CNDyXXGLZl +wDU1ZaG1acY/kwQ7tSITnlL6bER3a4L6bCG7HdklhT8MxSknBjEOHUUR9PvNuvl/znm 5gKjmbP8FsQCCXfh6zwy0GopaeN1rZ4Sx12bvvj0ujhgBhm0W2FDeOih+fzvDG/FEtL5 RsH4s/aEsvlmDA49ngF6GJuZXmYRWzBHoBkrmGS0CfBnsyqHWcrxAYobAQ32NrNj4YMU ieNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796366; x=1724401166; 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=qaOD3rKusxi0zQqgiaHpgdf4b2i/F2QB75S2grdzC44=; b=JAnNQhH1etqNtRUxbUP8YAq4m7vaz0wlH6Dp0dZuJo88+fie+/66xXohB2hod51fZB AkRPVhPAhnj4aabPAyrVlUqTvYYSXFVnleeqgJRw+E15V1Fs2e0+HggTHQEZLP1EAhAr t2UmzRYUKk1FYKkBOOi744Pi4W4X7t4r0BUGpvDFTY9gr+cq1OPrLOgPThtl1o4C6FFu ZzAT71Qmo7qyzcqdaZntk1rcWo4iS5a6kJg26R1byTueSrA48kQH0Mkfy+gzwy8UvT0k 32roaCrmXPBbkz6vDRFSB1aefu7ETqo1cfWDyHTXkVw+ufw8WlpcJbItdTJarrlrX8z3 6ylA== X-Forwarded-Encrypted: i=1; AJvYcCV6TdXbOcEJpBB7Ri0CR2guXxcXfBSYpDEHUGVe+jT23HU5H9t3XM4UcwCkD1y09gZ5qtBS7IwkBVlu1Ra8W3g8yvZQId7X4slZ87Qi6EIfcw7WSgy/71lRuwegQHN7UQoaWgLMahX45dSLahO1b77b8kbOMjGTT38au6NbozRR2ZygxPRDRYhITh8+weNfv0Xq7jb5hF4DOfS127Ec0dZoeS4wQmM= X-Gm-Message-State: AOJu0YwMqZPuglkq5sb0DCBUWWRPW2iblzKwkyYA+7Q0hVTOdeA6ZiaI iyztUvAABd6b4UT1cbVCwqXH++9FTEz+wH8WBoNZz3dvTR8BSwDN X-Google-Smtp-Source: AGHT+IGqwtVcXQKNh8O0fbem1eWcZ1w8RFD4cuHCIdxMrfHUkdXEj31Hz43gXqKgPdNZM9R7oJ2C5Q== X-Received: by 2002:a05:600c:1394:b0:426:5f09:cf53 with SMTP id 5b1f17b1804b1-429ed794da8mr14540675e9.15.1723796365560; Fri, 16 Aug 2024 01:19:25 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:25 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:12 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-6-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=4023; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=9tKk8IBY8YUSIH0ECZT8vZVS+bk8IwZ/nsbmqbh0O0A=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt+vqva+BUdawrIWvIhu5Ymj2S8KArA+aJpi ZgwlobFry6JAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfgAKCRCzu/ihE6BR aI83D/9G8dZ+ucjhexcdplvfoufCG6KhhAaDCFIUp726bzqD5GVi+fZs4B79aN/Mb64+uQ3kLOi 4AGNaVVUYQUQSlbbpSdBVApMt87xdZ0z97SPD2EVICrpnF9fQvPT5eRRC+sMvDyFjt+8zaGFNOr Mry4BHCr/Gg/hWOo0BQf8mNt+Gwx9JJ5vbMUcXu7fZczfJ9Yp8XzuCZXvbR+LFLlql+5mhoFWx3 vajC6Vqelc0EyTG6oDn9tVv2EdDd4MSH0sSQykAl/Ga5xRq+uRERJIp5ghHdIi71AkHBYDN6AeT apQh4kWhFQSKGV4iYBzqwRN1PdTo3gIsfDuZDl4XpWa5ywFUUh2C2LY8RBDsHtc7Fh9a4BpHWfR cE7lFyIovOIkVsPncshvXV66P1yeZ7SVqhVtnIgPonGSLpeunYdngSu5XcWtAcvZoqq5eBuGlpY yikxUEH1zSGpociurXOnBHI0xVv/nXfrlSLu7nhCQJ9ubxpyND3sAsB7Vgt/0qsqcbz6svA8/51 e6kXpVr3VP75rl7dfgu5vffEXRfk7drftWvk1/ukI8b6AZ2cOvLBnG7Gssq3PzEKaKlwV19qu/P M9kfJPQzDHKDFZF+K8ijapLYsahc48JGkO9zbG7TP7dD5u2WypM4GxD9PVF/3c6wOCTQ+PX/ije hy3lLpIabe/i8QQ== 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 Tested-by: Henrik Grimler 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 d67857d2aa0b..bf156544fe1b 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 Fri Aug 16 08:19:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 819993 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 7A60A1448C9; Fri, 16 Aug 2024 08:19:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796371; cv=none; b=qheJOj9tluqYRAv304HJalg09a8ced2ZXxI+w+fyXZGvromq1BSDChTC/xrdazk7F3tPZMCSTYvF8nxMAZOA4OqPX8zlJefaC9DhCIieIjB3qg561tXSs6K5c/n40l64ddTltAwF/39EMk/jliI1fXKHPf8rfojO5vK2hz2SrIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796371; c=relaxed/simple; bh=OEUMcNEwb5KpCYbBVGa/9sqAXNJSzG3pMkHYL8I03Hs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BYd/BRIe/E8RS77oCve5PJNFY7d/eH6bATiPuXbi8AElrG/4JtyZLWDYpYwshsmPe4DFHY9PaAhhuK+EUAv3wX/09VUAPMbLXYaYHwIgSB67X7y77/iGXt+Xdfua4UMnUHBzfFogFFD4hL+aYzQ8HIyvBLdG3DSjm8zeR2lDHc8= 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=Q+QUHHvp; arc=none smtp.client-ip=209.85.128.54 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="Q+QUHHvp" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4280ca0791bso12476165e9.1; Fri, 16 Aug 2024 01:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796368; x=1724401168; 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=vXcN+4MSX/QcUPqVj1wMQhGhi1WKb399yNI1f64c3To=; b=Q+QUHHvp61FRoGBiiqksPTSG9V+m1rpEW16yP1XtEVHFnfi7d7g5m9FZkU/bLgx5Ei toAXKArJwfdxnBMKXdxcLT9pWgVWG5CEZZY3si6edzdeeVDmFPqXVSoWFFGuJ4ZmClUm MXHgYNX0ZrS0KVIyZlqt8HvJ9DZQDMMudWfmcHEFC1DFOMiPwvlcG1+ED7OGvFrOwvBz 66SVBP6wHnDkOYct3wJpth/t/6FE/W5ZEkRKinnAeQj+JT/4nuyAjsb0yfl7LYzmC3wg ZGC9uU5GHBzEZX3rh+l/7MKXzRuOm/zXpXRHMxp1eKKxsCACBmUAUkM1nlonGJxNiCad Lt2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796368; x=1724401168; 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=vXcN+4MSX/QcUPqVj1wMQhGhi1WKb399yNI1f64c3To=; b=dhhKxSN/+3ZFXMO4/TzeRjTIzY9m/4bfLjWeIcI/JsyY1q/Hj8qaDn7eYv4cEyUlHd akx/Jrnw8+nrpp3pGcr6/inNsY5TYUUrrRd/nw7wf0LObAGLKCdIxBtoHgAsohgXvL2Y mziTSH5QtBqp6iht/qPlpgpyUYKhAloYxgDu8EkfgirCJIVdBJCYAXYl0Nwm4W9xC9Oo uWIM3g4M47Ti2uV1zoo6ZjefZ7dE11XU0DDgiBmsRNWaygptApM9dGRM1y7rUvjHzJFv M0koc2hewZtVNfnnd+mOTpAWSau7yJWVZG6waTvPo1uzP/EqHcepjQxAbFiSafsZGka/ FCSA== X-Forwarded-Encrypted: i=1; AJvYcCV5fWJKqEubPLL4JT0ESAACjMGQozB/O/XmRg1BcNBbWmmuZdNUd35T8eamEtpS+bpJ7Ijn5sBJ+d0TEMxnKBTDAmFPYcvkC2/a+2Ugn4cjW0H7njDd86aVDLK+2XyzaKlGl7xAhfCcaVcHGhPn5qId9VGDkJ1LMfafMuEFYGTE2Je+/hTWg/8WAg7esnau7WPxp2zJ6Wy5nfPH338Bbi/NR+ybwes= X-Gm-Message-State: AOJu0YwjTiYkERkhwMCXqvFQ/IM9UXLTvbnnKnkvcWjJUMZAiEitHPS+ KgFxA9yrxUHwd+Za/w3sd0PIr8WUZoUkxdoED2Jf85PYgAc05F/9 X-Google-Smtp-Source: AGHT+IHcp7XnLYvNLhbNQnLEg3KjGHkjXNOAnHLq2tZHnyLDVXPWGzMQ/tM7Ng9t/D3Pn35IE9GwdQ== X-Received: by 2002:a05:600c:3c9e:b0:427:98b4:624b with SMTP id 5b1f17b1804b1-429ed7e4314mr13528225e9.24.1723796367650; Fri, 16 Aug 2024 01:19:27 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:27 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:13 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-7-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=2794; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=OEUMcNEwb5KpCYbBVGa/9sqAXNJSzG3pMkHYL8I03Hs=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt+pTyoecftSlWocNm7S26aezVV4rEMO+uPW 6mo/bs4DKKJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfgAKCRCzu/ihE6BR aPA9EACUf+9CzArgSMlfX70XD47zElr1ycVHjU3iVpni38eeLaboCWaOWLue0lUp8vJc+z72T2A l73u4b4NAsTtECVS7yt5TGx351I4glu00VE0m6+3Ia10dPOos/IEcl7fgYYcZbwusGlqBdOUs8P 0Vpox3q33iJTI51mwM1TULoUkJ0cC8j1P/Ca7WCL8/+G0j9cUBI7PY2+nz1aYKqhLuJ2LsTGFz/ eDRZVBkC9uAeG93rfr9m4+HCmtFs7EjNrCa64aIjJb92JNeuDGXs+N8De/pA7BQ7V9/BdnJ1FAk eMp5Oeddtnipbd/1xRH6Gk+yBWHaY6wZTITPnqxhvkT+SjK2D9ItoVZ6jvNbWn7ml+BT9HmXFPV Os4WUQ7otla0t2IiYWVlMMp1UQ6XaYDCNMEQX9IYf124mMhJIXAc1iJnFt//SwG3Cdx7e5KOhiZ vMNRJhz779zLSo+/LpCXFL4Pr8URHMfDDnZHgX+EW9e3Ay0YkBl76+pV6iar8s6DZ/ka6C4SRpf 4LMmudret0Nn/sogjbBkLJl1s6aiGOTT5xi9P5QrzjuhbfOB1dKd90HtlEEZQGVsz5zGAxP3WIm /dTutI6AoeolshZSPXSwh6W25o9Yy2a9FzVeO6uMv96T+JfDOQMRMFssG2SizCy5AAvwFZZbwGA W80OZ31JEeXliRQ== 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. Tested-by: Henrik Grimler 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 bf156544fe1b..908fd2a178ee 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 Fri Aug 16 08:19:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 820885 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 9169A145A16; Fri, 16 Aug 2024 08:19:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796373; cv=none; b=EhxKrMqpN9sckDgKPp15Hp9t7O6ntv4K4z1KlZCjXlSO4cVY+m1LqSn3EAwbnWEVF3jTEB1m7yt83d3tQ/O9E1jC2aPHCgbYfoTYXH82YjpKUGYmLA5tWTpd3samA4JhypGMeqz2P/cAXqI3aKTOs6XjdLP2sc/JFJfOIohr+H8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796373; c=relaxed/simple; bh=A37c37izrYWJf0Fe0JOtEKWVSivq+OwwBBfAr+DI200=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KjiHRdrNzbXNoEoLyk46XZ4Q4NfSa7Y0gwXEGvWGUoSUMd4ekyk5IglAGia11Y2t8bEg0kY4keCjEoIP8sKcQKGBBvhH3UOAXMR0EuEYYSakfDi/MvpkjA+MHMxJDiELmKr+iGGycAHidRsnAhgkReYssST6rMMz5mqGV0GA42M= 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=PELvuj0I; arc=none smtp.client-ip=209.85.167.50 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="PELvuj0I" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52efd530a4eso2809901e87.0; Fri, 16 Aug 2024 01:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796370; x=1724401170; 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=EXg+lB1Y9hiiUwuYsdnzVumsOx9EvCzW9KQFQaaXx58=; b=PELvuj0IiUfahDfX18x14JM6czM8gIo+wTzUpm8o8idk2gkzxR2Mzl9FIndnxNM5rs 4F1f6D/yBOGEURfDzlRed/bEyhWGQTwcGWGHOD3sB6JUXSF4yOSEY+2mE9CnxYTcj4bN tKJiGQNxZGqvt5WXVnw8kbB10camfuiN/cKKM9sLRKBS5bjTjGiCYYywrRXOW0plRrMp fK/7pQUlB4ynvdaJ/jT08JkiCM5sX5SuwTODkGoxCnL1qa9304CqJpbsG+IRaWNmyFEJ yge/RN+7Fkg7exBg0mJic8BZd9lcE7jyPi1VvPzvcyN7kFsIQn6oX7lRnm/JnyFLbOEX KzBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796370; x=1724401170; 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=EXg+lB1Y9hiiUwuYsdnzVumsOx9EvCzW9KQFQaaXx58=; b=lqlZ4dMFx9O+T0W4NzRVqv8dB0ITvvRKuVi20YXA8bSOn858rBerSI36wtH+pyjC76 e3oPYxfj58kDHuF9w3Mlzv+zBGVvfByJeJIc7XNUmIygUuu3IbegQNLNNWL4Tt2fSCLu 05QRqU0Dff2Y7MFc5ViHaN/rc2SYwAMDMYdnPEFyt3seqgb7ITMM/E0g65bNxGsJOKnX 9QjUPqqcH28sfPJ50C715UC5vnYWXWwIylf6f9BMmgTHzVGlOjfdyb3d+13MqvdJlvcG WruQ0SYKiFHSQp35KGsHcV2cecwcmEfL21RFtoUyUj/tPnYGOBFhzasKtfN6D/AA6D5u N+Ig== X-Forwarded-Encrypted: i=1; AJvYcCUwWrX+2baykxUM93b4AGpcpYL82LHKRoGKBOE/L7N3L0kMJTd50nNc6/oZcx0tmZh2lKIC8lGZM7kWkOK7qTUx/yV6cNj4bVKC1dW1ytR39lLqHMa6qhzU8/g2CR9xK7wvw4cCBV4l1nscgJmk7e9bt+8oQmWZGSdAlLnwgkzg4aZiOOeN2EgE3Ly9Wl9SrZJa/+o/x6mQq+rZ8VmuwTqjuUxY4RU= X-Gm-Message-State: AOJu0Yz0fDrWInShW3L7KR5okWbYfGEaU/K9zgPUwXa/V7ZIH4aHhAnD ZoMYvETIYLT05GOtXiV5DIF8runXsIU3vRM1Wi2QsrFnr4FlnJ7U X-Google-Smtp-Source: AGHT+IEif3KkPF+pYJhrYQnOK2rzYGUNQn3Fv77PzHZu5B3nVFW9cXf2Uj6+vGaelWOExKB06fZyTg== X-Received: by 2002:a05:6512:31d6:b0:52e:fd53:a251 with SMTP id 2adb3069b0e04-5331c6f599dmr1250098e87.59.1723796369539; Fri, 16 Aug 2024 01:19:29 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:29 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:14 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-8-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=1432; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=A37c37izrYWJf0Fe0JOtEKWVSivq+OwwBBfAr+DI200=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt/X4j09SNcjo4JpyDsxm/BTFk7K+YQVfhD7 dCdD5cZu6qJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfwAKCRCzu/ihE6BR aO13D/9PAHdTYJSu7OeR0eeBISaX0R0zccU3OMZaRAxxL+BZlYNWaxfnTZJNp6M7/Jr0cxK7jw4 qBHqTGjHHfCe3zdIEeiEwXfqMx0HuUbKwl8wxXKtTtkwt8xjERSU6ubzhKojPzKyR/ZBVVB/Eaq cqI0WjhvEtZLbDicYnOyWF2zD8NXPJ2lc4LCDwtTV50WgSXjXjzUNUsqs7y5ve1xKD+kB3DahDE VtwlAK83fpShEvWLowtNDJ+flomZvBkAfrPTzdxwcj34P6upPgo605wd+/HXnwLkF091cVcF9Mj mqVNzySXKKnX9Ic/9cyP6yvspoBvTkwiQ6cjcC7bu7zkyJqRlluTUlpMLVb9fS57YFZaLinT+LZ rl1lzAilD7A/8FJKRsgmZqIKxXGt3vF8bntE2vd6N9AqhOIqPz7D3buRX3peWJ2QcL54f28MlD1 6j734AMwstNQKp1vmuOYzyRr7eGJcYw0JLLKW2bDC7ljZh+uzsY9lNc5ACBqYvbSIfBZznw9ikk 1TJ6v5VQdlBrRNEZdlRdE430NQgJGI5N97cL1v8uOwaPsJAV6lIxyw5IMGPz1nVgX5MJTtyW1nM c3HzeoS1IFFKQtUgqow66VoW8envcrJgf5sk1Uqy4z255g8JoWj8cauV6E3Hkz6GCrg1dIpA5D4 iODH1YT05P9otpw== 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. Tested-by: Henrik Grimler 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 Fri Aug 16 08:19:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 819992 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 3F96E145FEE; Fri, 16 Aug 2024 08:19:33 +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=1723796374; cv=none; b=iRZRt/FIYWNxY3mqqbossZvhtCgW6kflKGlJEPFulU2EKLZCVzzDDp3QFGCmfo/Rq0K5W7HiI+wDlcWl4qI0iaaGJno1DarPfuL6DDYxEJPVITim6SR/RXAQktMvZtjc6Fbj2FYuI/k59FzQh7v9lx1TO5z5niDPkN2hie4wNE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796374; c=relaxed/simple; bh=tVXqBcPeo+G6mj6298MiM54OrNViarOkoHHogiR/EXo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ljQ5Q8bbu72gusVJ49Q3EsigBX0yteYrTKShX/ERSMXnYvwyFBaYacaQBLh54vmy2A++b6CvK0F5DOhqjcAvJyaN592iRq8qihamesV3yM3G/cvh8udSS+ZZpk9rY7X3fMIpcN7HE99LxKckVEuo41aGTy0gyLQ6v0Y1dVIjXtg= 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=HO/W3jlr; 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="HO/W3jlr" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4280c55e488so8835305e9.0; Fri, 16 Aug 2024 01:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796371; x=1724401171; 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=yoRhb00V3b2YHQgd98mtv4KUJ8LC4IwuReaO+Jmg960=; b=HO/W3jlrsZYqvkYrtwgGAxroB8ep1d+0EehVaE0ejyBqpqYsOzYZpQ7H7VUa1Cs4ks TKqKOrrEwQxxac596yg6TDWu7kGU0AbUEvIya2IWAGqNs/VCTh0fePoG8tn/oId7x8px 1HZpcibdJfpRDwG/nRpfNapIs6AHp2uouzwMCjKBAnYXcZaQnrU1++qUSrigjFciFBLH A13pR5YULrbnExlAJiASx3Pt6jNXCPPFizONM0UtMREPggdbk+5priZHB3X61RPmtdX2 i/PGgdCIYaR1ftWEZDyzoZe/idxAK14VoncroHtrq5aKyyNpNu82WNTfZue64x3k0Ixo e0Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796371; x=1724401171; 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=yoRhb00V3b2YHQgd98mtv4KUJ8LC4IwuReaO+Jmg960=; b=gYge/5fjjNMYDKwFWaTT0fJQoJ96rHQSZ8xQoN1TpRFFWzURg7gC2JiYSbcKEO2q4T CW6TlWL5RN6nBE92ZFUf8iWXd+SdUKS3XuxfDkayGxPvNSCye3fuPy2Vk2jaO0npI25K X6GhcwI33LK5tgQkE14pvrrzXOO9T0n5bTQ/um+IYZmwTPkqJfYOdt7qC9c+1y5BF/TG KzID9p/nK4B9CQnL6y7j6owY769bon5hE6F0LntjVGTphmVeWCfr9otA5eLf+3r1J3q5 dTkXBUlcBxJ7CAsGup9TIc3AN+GWQQszI1OyARq31ErExlEjOh/c+5hQz3KLmd1M66ZB qqTw== X-Forwarded-Encrypted: i=1; AJvYcCVmYpnzBBMmioFHSU8XstZiwL/rGhmDqW7H4FeptrP5QKhO9SeUKDNo9LAi/iMtUFvP5o2L6BwyIHq+WbuNNeU7RJnLQ1rVuSnc0r+nyyeTUpv6DM3NHKNeGVAIyTw2+a3JmX6r9NCr80vu/Bh9r423z18YDUJoj5HXZESRMA5msRFm6vfeF8btv91k5V690sdy77evIkjRrB7dNk6e0rN4SE1wuc8= X-Gm-Message-State: AOJu0Yw1YUqbMlXh9UOveE6v+lSSOBSeI6sgqsbkMPeSB0O/cvMPXQMw 1EOSWrxjIDQeYIaWpxG33y+4ob60+E3Q/wHOZVaYz7m1blbV6UIx X-Google-Smtp-Source: AGHT+IF1E656TFpK2w4q5TDlMbLKFRWBD1HiXg+Mtkab768Qqq3+epDpvZYs/3x5inQx5XaV1Rl6FA== X-Received: by 2002:a05:600c:1d0e:b0:426:62a2:34fc with SMTP id 5b1f17b1804b1-429eda1f0ebmr12227085e9.11.1723796371414; Fri, 16 Aug 2024 01:19:31 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:31 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:15 +0200 Subject: [PATCH v4 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: <20240816-max77693-charger-extcon-v4-9-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=1292; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=tVXqBcPeo+G6mj6298MiM54OrNViarOkoHHogiR/EXo=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt/QhHtj7N5Zin99gbo1sxWukqNmO5BWXe+w GvTxBPZAJSJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfwAKCRCzu/ihE6BR aDsbD/9qil+0jJMgb3pMowZYLtMLmZgqtHPWkr6hQ2Kay5TvaKFioVXLcyKTUksySXmaOYQddep 1iytEBc3dw16bB8xdkfLSM8b4n7ejE2/lnpBEfCghyQoUtlKHwdhiynmeYugiToudvZV9gtMJAx Ev7iFOYcxkZV4coYrUocOCGNi/TfZVGOUAEJy8fQpvjol9kDi6RfjSQyg/KcZd/JL0/qNcxL9y0 wq1Msrcjp+wfGBIztP2EnZNnNVAjjEkUrwywouRkA4KAqSDXoEJ2Y5SxKnc6BwVR6hTGOufkRWE TaBeWEHvhCqY98MOJ3sjbCDl2sbkBEhxxp98BaLD54Z+rF26R20zuBizwmaJGF6BjvT8cBDk7gY 1b1SfGSPJq8Tp5rbkaLC+oLKAfLqF9XYxSt4Dz5hCoOfaPbfhfiCOw6FyngQvBo0m/sayEBTv2X iW7yn36PzJ46x46H4rvk6dQtW/ZtzTCFGq1TIseruNUSuGocsjVj+QnPLe1ESezu68IRhPnwBLX A2GUEovvuyNcyU0Sq6S8ZWbxMt9xdOW5SOwxa7u5etYVn4+R3aN/q8PMlqFDJLx31w9xQpjEWh3 uhemeeA1c4K4YJkXjw6NXUc0cV89x+/WO7ALqQfViGDr0zSvttD0eZ+wQuU1MpSOAVcxJjoIFXF He1o9VwzZ0Z5LWw== 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. Tested-by: Henrik Grimler 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 Fri Aug 16 08:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 820884 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 36B59148315; Fri, 16 Aug 2024 08:19:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796377; cv=none; b=PYulz0fxtlqWGxrd97KYwYSUTtQXfmKPUO6NnCd07cjFsgkL+iwDQjnFpV18Z9xpljogtOAQOE2L6I2Ussk650YScv4q+bkWlQ7fgdz5mz4h3I7qeFWpGexp/GgfOOJ5S+fJy7bGMoCbazl8oiCrDprKIjaQ85pvbRivbT48aZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723796377; c=relaxed/simple; bh=pjgYD11c54exrZ8m269TLJVT43T5YCmqEN99/6iD93k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KcvxXtRti5jxlwedLqTEGayMfjbwoiFZMjtVsijF8aIjeSZQrHQ7QfVhozxdpC1MJ3t0ZxTkDjgEsdhc3C2i1rU41MoX5IBu2q5ld3HXeMX7XPOAUjXyT5shBPybzz2Db84DioeHbNYJ5YbkPztRd8Krztr51WscIUVoN3qbBuc= 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=QbTbKBYd; arc=none smtp.client-ip=209.85.128.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="QbTbKBYd" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-429ec9f2155so6358225e9.2; Fri, 16 Aug 2024 01:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796374; x=1724401174; 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=p5udT0n/Uqzr1KlRUtr7rqEFm30NSV47i2ezdGcvvF4=; b=QbTbKBYdfIVuLTDi6H8pRjCAOzFVRnl8bZeX5ZVTXbszglTfyKq8NwGszf4ZCbAW1D AorjD8u7gOFJ7ZO0uDlBzjWLnIG6p7wlAMU/luk/qP/kgYXtpemrUJDIT9PLNPPfWsip jnsG6yvHKU97pY0ExxTnHunZEOprYJ5L/9vPzbnE3EJzB/719Jl9yMetd7fyvMTIzQVr amwmwOeG2TW1/E4WkmCSUtdTNwnnzh/hlUBdvhGFWyQoxFq0QJnIMB4QJg82km8I3nLF APZeomxaSlATxogM7JoZgzraQ7EmrCRSD2LaUJDenxZ8BeTW1OHuhzqRTqULanyTdEMO 1hFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796374; x=1724401174; 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=p5udT0n/Uqzr1KlRUtr7rqEFm30NSV47i2ezdGcvvF4=; b=d+NeicB8GXio2HRV2PpJkZis6Uo6TP1uIxuXlB+DakPg0bvMQ/KQlewe0bapDojv2X Rx69ulvVBnN1rW9z+qo2gq7+f4JoVrI7Fv9yqjT6n+q0PJ6UQ8MrYBzBZ8lo8cT7O5Zm DJOX8OIo7Fd82Bmq20g9BMnAmY4naFUOupFYTnWxGOVNcBLSFGfbk92+fIU0dRV8ZHCQ c+EeOA3od0ChVjwNsDY2YyIDpQMLr/HR47nv6I25DC51oP4aupeYKV+EWQIOytsw81Ki 4Qzm1MOYwL69uIhpaX4tvBh+TzhTLzk+JlH9rPekymRBNj0xPDxipTrsQIl8d+Iah2fI cpsg== X-Forwarded-Encrypted: i=1; AJvYcCXEb1VKAS8LU0yLufeVY+V1yEyIklO7moe8+eArNUHSCrjSrq1Je+AlYHQaQRnRYYKttfkzbrsDQ50hUkePCf7qk/Z8OWTy0tUASAKlEMWScHLdjIgE0Uix9zgrvh4QDjLDWWJxHm1aCLjY4fKzp3WIddY4Jgu5EuHLE1CQdJypnXmtIuySY4kq8Dz1LjN+VA/KyiE48wb30W3b/Jo2t3IWTclZlDg= X-Gm-Message-State: AOJu0YzEV8v3qbitzuli+f2ufyMaObC3zJFeL9bpTFu7IJLFkiFiNa9n xIxt5AIdPoV8m1mhA87TrLLUcMtdpm36c7+wqvnFL36jamFLbHyx X-Google-Smtp-Source: AGHT+IGVihTx7DF9CA3WeQUqGyrU1McVynpK1eOqsyz+lrrkdgotxkn0n0Eid0Zaq5twCQuOzduvxQ== X-Received: by 2002:a05:600c:458b:b0:427:d8f2:550 with SMTP id 5b1f17b1804b1-429ed789223mr13392715e9.14.1723796374248; Fri, 16 Aug 2024 01:19:34 -0700 (PDT) Received: from tablet.my.domain ([37.30.8.221]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded35991sm69732645e9.21.2024.08.16.01.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:33 -0700 (PDT) From: Artur Weber Date: Fri, 16 Aug 2024 10:19:16 +0200 Subject: [PATCH v4 10/10] ARM: dts: samsung: 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: <20240816-max77693-charger-extcon-v4-10-050a0a9bfea0@gmail.com> References: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> In-Reply-To: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@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=963; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=pjgYD11c54exrZ8m269TLJVT43T5YCmqEN99/6iD93k=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt/XPOgNOeA0/kB1uYI9Owyq0vvyqkI41oxe LuOWXtGQ/uJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfwAKCRCzu/ihE6BR aI5oD/4wqf4ZXhZPpaDYnhpxMAUxmWILeIu9ZpgVjitfkFDgQ6qFd2N4yrL+GzegGOji3q9wg5r TMSMARGd7Lx2L0MmQ6Eu0MsuJivZ7C6h9K944cpSRGqi57AtWiUksN/6bm8qVh/OCfPngFejQvf dCygLCx4kgcDw100dylqEcpgNeY7iGwvWWvZ73fhNnE+DjIZLN++V4TndNyTEluH2/i8kJ3tAkq h7js357Q1xVEXKBJhGCzlo/3moIgljMRUsT4vr/2Pj6ytZfeqP1wJp32o86UqRFDWSE4Qwn1bHK diMHHLEt8SnMGy6bROV5vkZ5pvym4DO/7DMBn/9as8AaVpQY32tsL2nKIaQ64dems/43fKoE0xo P9wclpE6gfy4Dyze2MFAOG6NvPf386mGx/zD09gZHSvUi7BqyCz8XA1/YAbqb8CcqPyLN6uJAgT 27iYLa6bn8FhBGIxgivT7awnXLwEaDrwP7il/XV6P75cQW2fnlRVoStiw+4QMlZxi6QHVNVUViZ 6k8OM6RxH3Eiu47JhFKbC0e0ujOq9zIJlR+LSBaSGCKaQEEnffsnIfepdKsMlWDTazrMZxVt73g lcfKktJ6Ps2o9CGHzjYIBBeeJ1zPRpSN6vTpYUE4UvB0AwbSzqPzqPnZqDlpvUZOfRSQRwxCOI+ /1pO9F/k9CzpERg== 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. Tested-by: Henrik Grimler 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 {