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: 13765684 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96089C3DA4A for ; Fri, 16 Aug 2024 08:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OuFOTwnVfJo3Y5EGzlmZmw/h1XsJN7qD5nElULC2qxw=; b=h0NvO8ngBuUhT+FWi2DsbOazJd SNVSnyBr/BQ9V6+z9tKCmKByaGLMCHXCpSAYL7dQTKNBYQ5Rq8373YeIH3OVeDNrwPydRK573qGaA wLMy+8zFBievf2kx7FFCjmV2xkl9gSmZWOICnlJ6+o+8dNIhc4JhGC6QCZSSZHbX4e7X3Dm8yZm21 VjuPiwmn71vGMGF4QM39e7SYAWwkJXKpH2C+lU0WmenqesUc4oA9QsHMumIyhL04WHEkNH+PqigGm +wCsDA/4EJh7ccZd3q1IGoPqX3Gp38HtJkJ+UZb51Q2YtRL+ybE2Fzr8ISDcVwHAvKTE52RCmGZDz vQNv8/xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesCP-0000000CFLS-0sbR; Fri, 16 Aug 2024 08:20:41 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesB3-0000000CExh-11Wa for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:18 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-37186c2278bso965993f8f.1 for ; Fri, 16 Aug 2024 01:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796356; x=1724401156; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OuFOTwnVfJo3Y5EGzlmZmw/h1XsJN7qD5nElULC2qxw=; b=grPDaGvVGRuj/XY0TENrJDFZ2BheaqMUuXRP88K+guZDlnG5x49E7hPTJnKEk+Vpq6 a/YM+dSb0jyXHeuWW5/Hlpqt5ji/d5VnPJcncxg5LUPhhe/9kemi6dOeIZgBFwHwTbb3 ZT8/9P9eTybGXMAHp8VZryi+koPNkwCTgJON1GW8/UdVS11iaoLv7TIP5LB4PcH13sgp fCuyDVGasa2nfJcYQ1G5TsSqTsPohrFUCBFJr2MJ6uZcVt02AOXHEgtJxVtRwmKqsFMF 2FVbNfdY158BSWOnUZ5s/eJ+/OSuA/oxiFy4C5Nb7A1wn+hbG2hikzyKA7ZG5q/FLh1K YRLw== 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=Ociv9Z8/o05ArsEeN8A023bBYvtir3Zme9lXQxmDJadvHxKJ0HZluA709LVQby5eK0 HTlXnpAdvH1T71nEcJeqYtEXPJtLa7wfFNNAgnQ4ZH4Q3687QKmjw62H1RutX+k5zrjm ouE9tfEe1ZrC3jExWWVKSP6slopaJGXZE7SjrgXNKwjq/TKWtGPlfGtGUkfyJlcmFYzn q5CoPi2fnERONdn4x0x+Zn3B5BUOg/4VEIf11YTja7UmEji3h7YT9aVsn/SRkHJzUP4C Aol3oEfoBZxvrMoI0xGPdUv4S8Yemz5XFj5ctXIPwWdqL4y9WrrEXhho1EfLwEelqZDM BIGQ== X-Forwarded-Encrypted: i=1; AJvYcCXxn7pUnZXpMmFkXaesQBOQrPQs9euR787pCPJzULo+YXBF0qqX5CXimJk4gWTPfjnSfLkfObuYy4QhfU1KlSPYg9FmEnjrhE2kbQkYlXBQVy0HcrU= X-Gm-Message-State: AOJu0YwRmyjza/BcNCHTgGjjACbQhV+WeUY1LOCblPOYU00YDlrkRgIP 8kocVCiZcj3UJghGAoJ2VypAP64SspCcplBHJqnLpZAdmp6dDN4k 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011917_440495_42CABD70 X-CRM114-Status: GOOD ( 10.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add the monitored-battery property, so that its constant charge current property can be used to specify the current limit to use for fast charge (when plugged into a wall charger). Reviewed-by: Krzysztof Kozlowski 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: 13765685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EEC67C531DC for ; Fri, 16 Aug 2024 08:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=i5GGelLjYWwSvPbwd1YOlnT/u3Ig9vn8D+D3f7YMN/w=; b=48kiAdSN6GHJoqHkohGUBLGWr6 26lBY0xDLxBA+dXXslrlSMEaE3bqrAYUPLNh5Lcf19kbkiuJ/FkB/4Aiudi9cL4Lgvw4D6W2Qbz7o q1FAc5GXaIsbJ8zJjtIxOJP5zxVtUzcV414U6sBiPFQSiI7mO0iO4vWFFp0+5mYltEvwlZ3XDyFhu HSyW2WuRvk5mEqEFfU9YUw7po4TQvP3ZfR4IpruxBa/LvPetT5zBPVP+VG73bume417a5B7agPhCL iziB4H0WtDhj2eyreaJjWSAMZe58e350ffjsvx4mTLj11a4UE6KIy+r+owB8BW0AeWz2Za9rn/Nsh DfnLWOFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesD2-0000000CFY6-0kxx; Fri, 16 Aug 2024 08:21:20 +0000 Received: from mail-wm1-f48.google.com ([209.85.128.48]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesB5-0000000CEys-1u0M for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:20 +0000 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-428141be2ddso11552885e9.2 for ; Fri, 16 Aug 2024 01:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796357; x=1724401157; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=i5GGelLjYWwSvPbwd1YOlnT/u3Ig9vn8D+D3f7YMN/w=; b=OmCbg9ZYQcDxWlruaAf7axYbd0MwyfgHH2nZ65PqahsouUR6tEH7sz/KXB7R2aOyZg hj4SMmbz+xWpWWSVAIHg1+StWgw3q/Sg4ZKcz6YMVXzSY1HUXSdwHNSVh41kmd4BRQKi 4WPwghX2+jIGRDMxgIRs38CT23p9eUP3lb/bgD/iZM5gJunHvHMoZe36PQoYmUXGfftO sj3tdfOCbBgDqiVVMC7qL6+4UEM+hkk94F59EOJM1Nwe4ubZx6Hy1C2sPwV03vwjhKyY 3ywfdBG6YmPMwsqFBRVZUGC+lU/JD5br6AKjTJxR4qDMKchuU4g23JyVfFQKtX3aGuQL 3qng== 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=HzKWFOMkuAvjGeA2e7HahCELCV3wC4sASj8HqKPxiSxE0dB1n83oU57GWF3RmmAJhy jZXbj4tnSzjHB8Dh4U508pNhS7peTVBVgXcXxoyksyeks/RLCwNyj3XhK0aSOhrBEIj9 fY7duq/1lkXu7i8D+mzRkKH2XG8LD+TmDfEpBCm98ZkIae7VwBTJNs828mrT8MprnWL8 144x+cRQsmdU422FOmQviNTbqgqHMOeG9vbDScK/4Rb9ANmDPMa8ENYJYgj1cA1IjcAh tIevRAMHRJ1Y9fjZiPUImOPCiqHcTdAXYoJGJ6udji/Q4csXZKn/ZAOgeA/hmYje8Rsl +1/A== X-Forwarded-Encrypted: i=1; AJvYcCX5uv+5nl8krwO3juNzVpz2GLdukHjRRBf3A8wsgP/jRQGkvGfp52IhOyBK6cEw0R+bh7kK5Ny2wpibS6vJjf1npYTViXyKcK35BO9t7wkrjGffgaM= X-Gm-Message-State: AOJu0YwgJ9nOrHXvstcVpIeHYBwxzb8og2qaJKJsFv6PAVOeTu19iQqO LQBVRDA6S4n+CmLCiRiFdxYDY/g6mMGjUPW9WYfQC/TOQ1towYg8 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011919_533581_0536F120 X-CRM114-Status: UNSURE ( 9.68 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow for specifying a USB connector to use for charger type/OTG cable detection. The way this is done is inspired by the rt5033-charger implementation. Reviewed-by: Krzysztof Kozlowski 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: 13765686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10A4EC531DC for ; Fri, 16 Aug 2024 08:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ATiloHsMDaf4CMk8cdUWOTXJanYqTe2+ZJJOm0eYxfI=; b=MAw15zaUp7Fzqjsut9XR4u2JE1 KqZUCHqLb2PXAEzdvajFgByqtGOBrOk+/GnVy6vSe6g3c3MbdiglUGfsE3IVxT7xfAgH9TF5kPVK/ JGmXf6b0/emoOE+YJAwSEMbCICtG6zORlm7hh4j6fgjSmktUCekZdvt+3lflkfw5cD8vAsU+k4O/l 42DLd8kwlum+6P1APg43+3k1XcGlgxtTCBZ5sNgxLF79Bqtq4k4iQTsXbPSzJAPt39raimc0z5AJS MaWB3DUohhcBXykIHPme3v/g4zNK9KizhUMGqUO8xuSyPjdXhTf796FxFnnQxTSiBZI1+KQoBlhJX 6ObD5Krw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesDf-0000000CFjo-0L0n; Fri, 16 Aug 2024 08:21:59 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesB6-0000000CEzi-3fNn for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:22 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-429ec9f2155so6356795e9.2 for ; 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ATiloHsMDaf4CMk8cdUWOTXJanYqTe2+ZJJOm0eYxfI=; b=DVCMVwZ1aAGhtKeS8vr/hzbU9PLj0tgU2NuTNCmriedPZfZvu99qgBmJn7qr5qCRDd 2TpKNch0GmZ6ZnQG67Lu1ZrR5S4lfYJC27/nqb/bbo60vuYSDKCsyDauwa1zyPVIt82e rZ6GdxdwlU0kasvkAk5Ry1L1TrHIC3sHCJMcAjiEHjePKDUqxCvVVPHuW4ADOBDdhbEC l4twAFoAe6jtZGtKmfCIJO2fKootsk/HYU0+1T5d3+NpS5wGKPUtRX7wx5jyMI96ce85 Rw1prZjWmEDqX/lG6gD8A9R1PoVsrh7SzixYH8wj0yaILBmtZ3cEt8jopDe6hTAhua6n qqaQ== 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=Nr4gLaeSO/xu/dwjRYw+ZY6jrb1Qp9BWbms/hiiji9QEPvse0HbathAgn1ojGG+rqy xX+DxeHctphXNAxBhtEaUltqRfBjrE/kN6vaKDNVKy8PsLiTlGgrMZlkz/KVsi03pPq6 eV23WlZFgpNddnoN2Y4piYmw6FswF8RcHKFPDQgVp2zdLvV6tXUDtdNzSlOXDEB7WZl6 K0mxONqngUYKRTglN1/glJ/CMrs3WQ4TxwrK3FAbciXbABiLbSYbfgBO+kNSS6zRqWSq gbAYY/jcL65x9F5R0ye6fX18WmWsMg2KWvy/cqKMglK78/e6BRJJnsum4FeylgoAaIu7 10Aw== X-Forwarded-Encrypted: i=1; AJvYcCWAOxJo4HX1nD3ytqcfwXgoMwo+7N3hOM1xtu0Foo4eBPTABswSTEfQ+Doc5PqRsTKxeYPBPOSPew/qEuzcrID/g9AB4ijTvtGMuxDFl7zH2ljsuyI= X-Gm-Message-State: AOJu0YxRVYI6quJEA1CkqaoF4mvKFUkhKw97T8T5LKzLIUafPXpJwbIM y0fp/t1hvrjqJcoD/Vn2LRVt3df6rw8t/M9iyTEmYBUlgGrG88Ea 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011920_959321_6C56A4D9 X-CRM114-Status: GOOD ( 16.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are two charger current limit registers: - Fast charge current limit (which controls current going from the charger to the battery); - CHGIN input current limit (which controls current going into the charger through the cable). Add the necessary functions to retrieve the CHGIN input limit (from CHARGER regulator) and maximum fast charge current values, and expose them as power supply properties. Tested-by: Henrik Grimler Signed-off-by: Artur Weber Reviewed-by: Krzysztof Kozlowski --- 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: 13765687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD5D4C531DC for ; Fri, 16 Aug 2024 08:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1WWrU/IhZI7ilrsVlKcVr6cPaQA4CGMInWjIGFs7Ke0=; b=2TeSx6uo7VHfFNn8BT8GO3rOjO Q9oLN65f0KMPPLkL/G+R4hN1SnM0kJ//Z2IlrjhZVTHjzAHxG6fBggUoSS1iTk/Ulp9OjVOIy2IKC o0xLvxlCZyZfvxWKz+UtVgfXHJUI3AhEI7X27dTWrDgYKx7HbFsVR88NIwkmRV59TzC68GHRTc0N4 tRFSPm+jWjJ82zzHEFsdho413e0hmOzydxe+RmuZ7k/T+Xj3h95jVlq4/OLvead1rDMKuDTFc2PdH Ry3nJK0rikfERphcl8MmGAw1rj90VcM3ai7M4I8yHF/MCjpa5AshE0lnYQWsuJCUMGKzcQylP0ahC ayl5M2bA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesEH-0000000CFuU-3KZE; Fri, 16 Aug 2024 08:22:37 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesB8-0000000CF0M-48xI for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:24 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4281faefea9so11804205e9.2 for ; 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1WWrU/IhZI7ilrsVlKcVr6cPaQA4CGMInWjIGFs7Ke0=; b=cMR5uUdMhhsYMZ9pq+SjBCWhuvBBcelmJz41oZtDSZ2M/2czxtzfFh1+wawPsFJaop 12w62CAxLAHJRIJ1qM9Hwc1uKQdMSwjmco03Kc4NAEsO9D0V0WZANk3T3qSuEi5muWSF Ns5lIoATo1BvKPFQQI3PApWdMQJcQbKgU9eck74/ooJVv7/Pn2eGa+gE/ldmS92PlUNn 1bPpo6iPym0g8k94d3V6VgUbuPjdDXfiaTjYh+Zt2AYdaERvpfbHtZdHn1spqpvmGkkY PlvXzUhQ7ZW0OQte0bR6youHsrU4rBJx2l5HVVQtr1IPo6ZhF9xDmfVUoAQKb+yFsaDB CU5Q== 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=nPX19tSrp7jE8xQlZNfty3HmztViwduALWTgC3Oolr6fZK9ZLUs4OStwHIxVc3ge03 sJrTMYDS8fDRKheJZxx8E1vnxaWfGxPhbvKaZ0HnT1VMg/Va1PNu4gtk9CzGYvzvbplU b9ApnY0zSwrpZWTtqKqhUw5FjVIUJ6cJF7wPgiEMZPJ9Tqc0Q3ZeKsSQCnNnviHL6pP5 Dqw6KuvViVA7hGUAFin8MElSTxh01YmY1mcdt3/9t6HqBAh+/3+dxz9cbCWxVbz4Vp0s Zjs1JFu6HQtzBD0rjvrdMPeGh9wauZNhPEN5ac9su0qt8D5tIAEEsh4QVeTxcv5lTi7/ F9wA== X-Forwarded-Encrypted: i=1; AJvYcCWOJO4dWzjPhUodBqmMds5Rr6kWNeT1NhBI2X+/HyMu5MKqFGYEe/1tXff8gAuPFjnxvlaXiVEzW9tuSlXnZGb/ZNgMOUUqRTlSKWYgGCpB0qgv4K4= X-Gm-Message-State: AOJu0Yw8LLBGmfUW6lqv4JlKSiFOvsvimXTjMck7W+e8wB/y0Kz1wpnK O5o6EkrcsG3vAGa6CCTzs1NMZPdq57JXEor4FXIMAnRQEqIQGWEorS/m5Q== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011923_069741_FDCD1AD9 X-CRM114-Status: GOOD ( 23.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are two charger current limit registers: - Fast charge current limit (which controls current going from the charger to the battery); - CHGIN input current limit (which controls current going into the charger through the cable). Add functions for setting both of the values, and set them to a safe default value of 500mA at initialization. The value for the fast charge current limit can be modified by setting the constant-charge-current-max-ua DT property of the battery node specified in the monitored-battery charger DT property; the CHGIN input current limit will be set up later in the charger detection mechanism (in the future, the INPUT_CURRENT_LIMIT property could also be made writeable for userspace control of the current limit, while keeping the actual current limit from the charger to the battery intact so that users don't accidentally blow up their batteries with a bad value). 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: 13765688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 193B4C3DA4A for ; Fri, 16 Aug 2024 08:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=H0VjY7601kLqnVRjaSR87BnlCssrimW4yWJjrae9bpg=; b=4DaqpM4CV1a0IvvH+u/GwW1NOP +66SeB74GS50rWHcwpziwEPwVRbFvO0f43FQ5xC5PB07JQ+Riw/0BKrQeUBAfKyAchWfH8+U8kONG ES4jiLFZtkZlMwYyVHv37hTaRO5JtPDf667D3gN7g00IyZHqfIG2tXG4tQ4AoSATxYYxo5EQLPO5m EojdrfKEI93e6vVV/I6nHnSJ4kmk6sgfOy3B5VhsNxhp6OpdzFWDpxNBRW13OxdAI37KSIH1C6fEn Y23j6O3RV4RtpdvZedTfb2+WViUWl2Hg811eF6ZtJ+yfPQGKfM32E/dAvde5tKAJYyxyExEXsWI2V 3W+61W2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesEu-0000000CG85-3cXA; Fri, 16 Aug 2024 08:23:16 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesBB-0000000CF0l-2d55 for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:27 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-428ec6c190eso12783375e9.1 for ; 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=H0VjY7601kLqnVRjaSR87BnlCssrimW4yWJjrae9bpg=; b=LruY5X9dKOD7eogP9lb3vR4G0QT9RbCqBPyurGXey3W0avFVmksLhjbyhPbfg9oK2z Oa3/VeQ9HunR0RUNKaP7nCM4r7yWr82NIBulDwBke0C+S6QPc3WrwI5Lq+CYjyMKCCrw tfgqo3bojLwDIAzyPNLJtNysxjiuwG2LZywSZoGYkcFoVBTgsvFeCZ5TdYKTnA9VxYNc 0OlFwdT65wRQFZ/q2K9ofk2V5hMo6qsyAi2DAAg4LjQXzSx0wcRGY0NsgVYGm5Y0nI0C gPYccP2hfitjfRB+Z2Hb3d1Z1vo2nTGV+8oUTcXuMDz1jenlV+najy84jk4yh62L9Che Z7kg== 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=ts70WQWzVfgfOd9X/fhmFrvy/1R+A1Mk4Y6SyIG8T0tcuNI9ow6p3MVn/UES305IAv NObMxebed7/wQ/hBqGYIVZkz/VfWcpGUuMb+6UKixu6ZLPzCNGC84wrpfEzbaGADVkOv z7WCUrXHxWWYcOgBhwQX3QCSdCX2nLl/upXZhuPTkJlnC/jBYZxdhNOtr7kJdcvvAqxI JHCLjSbwy0QU1HtqwI8b+u74Bi3UDFHUKyHnoFahVzg3TjhcwWktoXiREK04qbkIkz6n OByGNISao8NqMZ5kp2BGa0paGrbqbhKka0dVfkNMER6i7lxF66x1wCgCSAkYL8Px/Rbf F59Q== X-Forwarded-Encrypted: i=1; AJvYcCW41e2C0INxxKhujGOJPG6HuGgHkDpDNQsiH91FVUVNiUHUOrm4X3vVZIaFjgLzhYSAyu3y2O7HAMNAWZlkHjxEyCL4nX8c2Rvfy3dVT5wKh0echLk= X-Gm-Message-State: AOJu0YzdAGzfzvPQuRUNzLv5lufBr9G/4V9oVid71vkIIQIxOA3ycGMq LctiMxl33B77zlo4r8bpQXJ1CyozKjc5sH90EPC8fr7HIhbP4FO0 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011925_718906_CCA2BA6F X-CRM114-Status: GOOD ( 22.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 1. Add a function that allows for enabling/disabling charging. 2. Add a device tree property, "maxim,usb-connector", that can be used to specify a USB connector to use to detect whether a charging cable has been plugged in/out, and enable/disable charging accordingly. The extcon listener/worker implementation is inspired by the rt5033_charger driver. 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: 13765689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E262AC3DA4A for ; Fri, 16 Aug 2024 08:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qaOD3rKusxi0zQqgiaHpgdf4b2i/F2QB75S2grdzC44=; b=KOiZ36iUrFulSowKGygGPuAMAB nCYYhV7PUGSq3byElUcGCfEtbamIeBmaagg6zh0V6l98IKL/YJiStN0AQoQbEI2uTXJnLHIVScrHr IN3gCyPXwdXTaibHwhIF09pZ2FH5X1tPm8YMX5y+pz1pZMR89pEAQmiOGH3e6V96N8OvNS4NvWe9w QD+GtcS+GGXDg8jRPWk7hUzTixq6w3TDMV1vwpBzSewK7JvPcFekjKGRHVBCQ6arKgQGKEX5nxz2h qeXvLIG3/T1iJ+pzOp41EGVwDGWtfbZqZoODgNsXXKift3ofX+2QPYye5WHvNdpNW4UAAeW7BLX6u dCbHxMew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesFX-0000000CGJy-2LTH; Fri, 16 Aug 2024 08:23:55 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesBD-0000000CF1d-0WwT for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:28 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-428243f928fso17389095e9.0 for ; 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qaOD3rKusxi0zQqgiaHpgdf4b2i/F2QB75S2grdzC44=; b=DRvSTryuR7hU3i8cr5xHA9Nh0TgfnaG6UKKdUKTYVvS3aJZI2vRH/x+AKNBF2kEqRN j13zualpN+ywoAQpeb7PuZGSfZRmbGU84cah+yABi8kdmTUjVwzIxQhCI/0+hoCX2aaV 9k08WC3IP5367PCHT4mCCW9EiEXiz0CTZW1Sd2jD/VW2Xzub9Wp1K5i13eUk8nqwjQ4z 1wbvC2j71Qbm2nldlFWvTKrQWwHcUfVwLnpHu/9ZwuI25KMCSiRSc6Gc2mnIouhkDZJN XhEFeOuaVQAxv5X1l1IgvflXIPGtZ8iKgPVSJkIgZVZM5j0mbTrb+JvxypXGFApAfAe/ Fn4g== 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=JLYPA1v3kaRWIOMgBCIZSaD3ypF3kRB5PtDSc1Xohc45s2g1GTEaQd4LSmy634jqMk kNey1Iw0ExGT+UYP0TH6XMdqab9qTcpNsjbzwBuu+8Xg68CtliFcDH/kgspYFbgLbmR9 AkizJYBQ1b3aZZoM3hHOOUHX0K59qu41MfhFczt7OHP1vEfZxHNaSJQtTmrYWjPNk5jG fAh+GAm+dMOdDJZ2L461QgQ73n0+UFvdo4KdfXUYxXTVkWA7yVAL5+9jJ585CuPtfpjx qHVCaodh3dfFfNTJADus6ZdXOsRPxuyMa5pghA0bh21Lwh6Zx8GSXtktEDp/gmEyWohs 0ZUw== X-Forwarded-Encrypted: i=1; AJvYcCW/Uv525hNY1GmYoqzoKCJVA0kiorPxI4W2ZE54bOUM86oPpxcPeWdlYg7sHjGsi7qL3427zWA3efL0LlSvUb6KKTBMtVW51dT6q3oqnNcvU50crDE= X-Gm-Message-State: AOJu0YxFBNyXQIrJEMLimtUZHWqWFGDWdvScmAXatzErW/cc4DNXG+B7 7SS0GblmfHyay5+E6Td9aOqHL9RcOZ9+IjDJRx6oK29sTYfAmcpp 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011927_234621_240F8346 X-CRM114-Status: GOOD ( 17.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Building upon the newly added extcon detection support, add detection for USB OTG cables (EXTCON_USB_HOST type), and enable/disable the OTG bits as needed. Acked-by: Lee Jones 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: 13765690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB72CC531DC for ; Fri, 16 Aug 2024 08:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vXcN+4MSX/QcUPqVj1wMQhGhi1WKb399yNI1f64c3To=; b=jwXT9gJ03HuoSq4MoHEqTjPoXw P2OF2UCH2JLGWB/V7uMaeAm8hRBH289ykFYVEkI5lDTEICFX76oML7V1I02QWFmLrgtqliLZFj0Bf foOYdE8jQ1VyYpSMYSWBXiWQoVk/13TflCRszG/JHBA1lYuPNnnn86wxebRADvJ25H+sbZPyf2+wN CjywmQiEIcIl+KEoIvXyYhe0uVPzaOhEaYWuo8rMvNK+7V5dvPIMy+M1ger9Grv4xnXQDXuCOfajI XggEJ2aeVgkoBv2rH4T4/2tko8quuLBW287tx5froG7U3gzLGVggldeZUlp/FdbWB5gk3zL697XeJ SBlT+rqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesG9-0000000CGSo-13dX; Fri, 16 Aug 2024 08:24:33 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesBF-0000000CF2X-1Fjd for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:30 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-428e3129851so12417505e9.3 for ; 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vXcN+4MSX/QcUPqVj1wMQhGhi1WKb399yNI1f64c3To=; b=nEbx4ZXnpw86v4ny6oCcwuJt1Q4kgsFwJDwfEGFTeyy1FWtAD5qjTib8f9TUUAAveD UpESvLvUFyDJVe/Vdc2xN1dtg20yXl/41pnqPHddArHBWvqNCp7Tp69dpLR1avBxMa01 xW8h7pJs2uGENmwY8RKYKiu8YLOvb+aZlr2vx93bSd/MJN8JKXzkH1p37X+6NtywAeYn pZfWl2CPFC1HCK9e+Zo2Zj4K0wEkMCPuTi88AcbeFGkebeZqGprrtYmKQdO2bWJ0syC+ xwa+sQ42R2MsPddoCklfWN6lvJtQgGGWdCIIjceP9NWWyiP8jouRbo91lSoBDxzqfCqI HhbA== 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=Hd0llqvVK23aroC5s1TkA+3BVTh92cddCCI3WbveoJWkMShSD+nYzo4KCSzpkA2Ggw cHjDh5UWqmpBF0C+tOENZqDE6XQUmpQk7+a7zAzOJC/MATkmuBo5T/FfHiu8DhuxokDe qBoLJmSXP6iXwoR92si+oFdP3c07h86tqkmePhf1rBVVbwE43FH5SDJuhpw+zNrRWDC7 4qEgoWahlR+UnWzcmJYC3aFGQPdHdGpIYaNKTRjfIV+MoCCLH1NgYnE9OoF56MSjXuKS ffswGvNuKVMvC/mL8Sbqbfd9bBJwy7kInr9LsqYcsuMOLWAc29WRyj4Ob5v/0JPfbI6l 5UeA== X-Forwarded-Encrypted: i=1; AJvYcCW4MGMC0C2pBh68tSeIv0N1XI2Pt2gFRvl6hG/GUqOZLZDVUvRdtxf9hEovIaUfrfGAdYqygXx3hbi7acGCB4be+3MVet9myVj9lohA1fjjJKuIeaY= X-Gm-Message-State: AOJu0YxBQVYlLY0uHjtVazephdRuf3itwyJ5TqLGjyagqbIGNV6XYfmB NH6p7JIZ5sPlzC38bv3TBilmeWe74+c5hjED1JUS53XvU++U4Jig 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011929_379875_29B3AF1F X-CRM114-Status: GOOD ( 15.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13765691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 978A6C531DC for ; Fri, 16 Aug 2024 08:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EXg+lB1Y9hiiUwuYsdnzVumsOx9EvCzW9KQFQaaXx58=; b=OeFCq1vT4mvX8DTmA7s24LICY1 T74p9wN7bb4RquO1eng8RGjuuMYRU16O1d7qIn95ZqFBWdfWIGxiCyCObxzwK0TCAn9DW2ARo2Nnc TPFY8UIqP6WLvqS2u8GwGW2/oeo9E+sfu4UXcEhl0nGZDlBMZaZJSBf54HDzFK35nyjDbfSaGayQr j17sQd9eIGsVoJOymF1K2WaeK3mevv5Le+/Rdf9TzJ/iIxc8grhlAT2m7s1NMOvZ3920gkzhQOAbR +pINbC0SU580CfdaVb0SiUTmLT+4FvbpMB2wx12eDzZhJonk7LCTkBsgyXFYrwRnGZ5MwvMZK2Ykl dPsFIH9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesGm-0000000CGeF-0ILg; Fri, 16 Aug 2024 08:25:12 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesBH-0000000CF3L-2oaY for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:33 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52efd530a4eso2809902e87.0 for ; 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EXg+lB1Y9hiiUwuYsdnzVumsOx9EvCzW9KQFQaaXx58=; b=e9dAdfLRpe0rpZkJyuivUrzOsIqTGpfdbspdyPoDrQduu69syyOhy/4CjP3Q6T/wy9 Rf22H522WRcfBNcHSkP+a6I1/PpdeCHo1scj3hj/WkSOgMMsLyQscf3VBK6l5AsOTNvO hCbUrfSZvgedxxuk/0H9VK68KCGXhaLSn3yFNg36dc4nSeyySbjunepOexOQlt3cfoey nUyZeWTRQetRSGswq06+9e2KcGkg+7fTcWWSwMoDFw1wMq8i0WV0T1EPCXg5Dr4VJV20 DsLQJj+gO2BQw/qInanjbyAuTjP+7++tE2ao99xqeq2lwD2QpvVvufqvpXr2KDOSH/wQ v3hA== 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=kvkeXpoGvLr/cwH6hECl+9DCqwa5JpY63LKAe5Uvbx/ZSbJGMX6S+SClgxElU1U1FA rWnFQ62UCFcyTkNlyXStBVWKnxigT3DIF9zJer/0nBXzVhbCgjG/h3zRCccQJLCQPN3k jnWzQglDW5EFIJYGoUqnORVwg+pfgXB0S6ra/C278suZpaNrT88SVqYqmU4COoyoEupH EO/5jYaZ1HDiTX0kVSkPyvRIZjxQnHZef/jXd+aAEN0AmpFE0mLeplDEhTmN0iRuTJTo FmfLesQlJ5WtbLaQpL6A4gN04okonciBMgNahDgHymo9Ri3XpPVQhoGAxEBfCN7Cmt20 Vw+g== X-Forwarded-Encrypted: i=1; AJvYcCU83+8KN1it3MZdNMmQKXrUy/Wv/UDsZ1P84mrT6HgwV3yc2s3h9LSix6TkNo/zeYBJuZnVJj2dKDQqSqAhOGgMQyr5BIgzTqtrVAIt/dAhu70iO4Q= X-Gm-Message-State: AOJu0YzVgWdp8cm2LDCGHUbSTad07eY5GF/bpyOMpwmMsPCNisWQBqTO LFMS38DfynwyBiq4OdLVN6egPok/krqpB6/9AW3BbG47Ot/AjoW2 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011931_750654_9DB4F1AE X-CRM114-Status: GOOD ( 12.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13765692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B716C3DA4A for ; Fri, 16 Aug 2024 08:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yoRhb00V3b2YHQgd98mtv4KUJ8LC4IwuReaO+Jmg960=; b=nVh8HBme9rbWXp4X7O4kp2m4cM MmFZxiByVRqKx50dDK4i8hkDUwn6w4KH0gyC+lIEAY4MnXVx/yd63w42qxKX5QDm3k1+vNXmwyJOU B8ODPSJ4ZYBNlY2oOwBfeMvNIepo49Re+o6ZzXo4UgixBjhp1eP8+zK2T4de6ZiWsoTgQI7Z6NgFo 0yp5/WmYMOIBGoQ5YVJN1n9+ohAJs5p07p2LNlYz85nyAN2Om9PBz74j2Fw1jqwAo/3G0WwBwmL9H rUZzrK21ItlYXVAFrAfrAta0cF1vN48bxcxMR6jVpmp1hnS3yRvkCFGAwYtuwLJeIsu5tMBdad4s5 CzOe9JHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesIo-0000000CH7t-0OlE; Fri, 16 Aug 2024 08:27:18 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesBJ-0000000CF3z-1PMA for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:34 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4280c55e488so8835285e9.0 for ; Fri, 16 Aug 2024 01:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796371; x=1724401171; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=yoRhb00V3b2YHQgd98mtv4KUJ8LC4IwuReaO+Jmg960=; b=nG8mfXuWSUzd2mFggPUKdY1Ir//j08HHMbB+mzAm1Jt03uUlHBqIlRp6uY/HMeVae5 xhikhn+++G7Wv/7eKhuj9fGAFT5rhy3Fu7cL2uXit1hUoQ5Pfp74HTE/PIU/ECGECEN3 6VdNr1TkdQZ0UBGB3/oOcPCahC3hvTWM2REuqQbm/WGw7LZEeKuDMuJQhBidxi0ONo63 I4IIn0r4Tjm/+LT2fxWl7x56K0Insq9wwwpQLHFXt5xU2O+lOjBg3n0qMYMXYrkF/yfx CalrWjppwgZjK8M0c14kTLG8KWINqmz7xOK7KFe6lbuTNhoFtoZq41To0DJcvs4DtyZa 7IzA== 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=apyS12Yqx+mLibGdprmV2pcYJlfpPzrmn+6zJ8Co9t1UarLDI1vfS8JkVp+IBEc9Fg mcgWcLd+BY21l8ypQcoriP54tyQ+LEY55joQzoKllE0WSmejrpl2+Cm//de9wo9Md0fW gN3EqZvUguKf9Y1A6mHHeZ7PCL1Zzfpuinf4zGSeGBEdkBIxp6zQSftk519oMobd5Na9 ygLUFTeVgX/l15/CSJqrqJvqJ8v2znNUGXgv+fFbVoXZOSrxSgqdBmNUroTPFH52CGVl XTLKmuei1Yb9kdJFf4E1VIpoHGlNdSEbSLZmPuYE0pX7q5Ogdtzni9AhnK3SQsIQTgnF dXVQ== X-Forwarded-Encrypted: i=1; AJvYcCX0BOenfbo2cOmtj8bQvZnWTJI4Ssm5WS5mlb2/DDYFdGHWuprHuR7W+cLPEpP86pNOcMOumcaMi2gQAjcVO5SdZ1pjU92jrm0STn5wcWmgTIMhoh8= X-Gm-Message-State: AOJu0YxRpCFQbzVt3AE0SpOFdgryJ1pXM6cRjU6+6943aNCpDuUYnVI1 4PPZNhPxtGD8v4Fm3Me7JtdH/dsVn+DwddYu1hLZgMhBFH+oH34p 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011933_413529_BF324460 X-CRM114-Status: GOOD ( 12.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: 13765693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4965C3DA4A for ; Fri, 16 Aug 2024 08:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=p5udT0n/Uqzr1KlRUtr7rqEFm30NSV47i2ezdGcvvF4=; b=aPy55G9e75rMXQ/UdEScbC93RX tisR0PzM2Y5HLGv7+Xk5KWRZ3Ss1/OaFDT3l/ILHbAoLiLOvpBQ0exxtXLO/XatXFNbJGOQrOQa1F NTFzDoHq3ZslgqnplF6WcaxgMynl8WekJqCVnVsaUhkZGoUL+oHJUMu381ffR8nhZhsrQ0baecv5W 8MWh82xQIcULAycT/BpIT5x5tSd5OZ4Gwp585Sg/SOD1qrWVUT3vOAaUvHHWJ9Ih996LwwmQydJvT k1Dx7bQj2zThK5/Od+TLAR9d9sLgXpzTDUdmiV+MIG8X49qsAZG5t8PMmp5/gKjQju/SeEfJlpS4a sz9h5hDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesJQ-0000000CHQj-3Tfn; Fri, 16 Aug 2024 08:27:56 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesBL-0000000CF4s-3Iym for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:37 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-428243f928cso12314325e9.3 for ; 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=p5udT0n/Uqzr1KlRUtr7rqEFm30NSV47i2ezdGcvvF4=; b=gxbLbqT7wPQHceb12zm9PQPW6BeOLWYsc5RhcVgDlxTOu3qBhltwgZumKAvjpaQmm2 lCIfoLz4CNpb/7MDhJr66hnygr/ZNmNBYv7ldbC1uIIzq3Qi7/vDGiMlNqoUYs+6UMTI JERDZnS0PZ27BVGSI8QAnkOBpbJuzZThxi6G4UGac5K5A4da0xu46LuEiTzWrAsrih2I zfd09GKQ0s9qExlcSGNLDX9zfTqv5s9GvjugD+IcYGhDjJyWOgpwgQqn2a2As4G0b8Xd HDOFHEasnbBA0YfqO6YIitWM+UNdl3FFHA9I7MOWbwcVeoosMqbm4vFUyfo0pigmKUdW KSaQ== 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=KauMdVtlJe63EoOdMxDIXeN1mZV7bItoaHQX8KqGuyDq60SLsfI+NxypEzMeS5YKS5 PExxr1AKt3aeSbdUmwrO1SXAVHwCjuSFgfH+oITw9krGn/JgG5P7zXh+KuSVAy8fYLwB vnEmH3wTKA0+sIQB3Zk2YY8pgjGo0zjWrdRvd2rGypQQyASL3ae78nC4e4WPW7l/Qs/c HKJeJY6sPUlaMVrthJWVHO1cX0+RdEQWXn6VRuSN9t2EzngYCRCffN95zG6iKSZY9rnY cTlZBwLcqlu5bc9Fm9qc5tOGt+MiakEQBBo7DCcUXFHNxpbw1PXc8/b8nSqPWBOF83ob 4amQ== X-Forwarded-Encrypted: i=1; AJvYcCU0PI7iT5CZXh09XmB1EfSFe8ojN9kMR+7nBmD4hLbagexKwls2eE8B5gDUfAWlM2DUcvnU/+F1paSFrUaN0ADWhurFIYdEb+E0wu7Uc8oveTSEwIU= X-Gm-Message-State: AOJu0YwbyIpfpzHeLoJeZ86mWVGW3c8NEFoXX2Rldr+Oum63Vs8gsl9q R098g6Wjg1i8jBR3WcrlAJJJ1pJRzlyMZA/Mc5GszD6DzsqQHMwl 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_011935_870689_370EED9F X-CRM114-Status: GOOD ( 10.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We don't use it for managing charging, and it interferes with the extcon-based charging mode switching. 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 {