Message ID | 20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com (mailing list archive) |
---|---|
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 14B92C3DA4A for <linux-arm-kernel@archiver.kernel.org>; Fri, 16 Aug 2024 08:20:17 +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: Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jtDygU8gueGwJ3Zdqpj2DOV0h4FMxFQXx/h+FOpbWvI=; b=fMzZ8NpaJ82aYn dOWz7zhVtev2viM42qpKTpIaS39eUFW9kvfkSsS8QKFXvUEayyCa9zXlD3Pm55txHgrqTHwCjXapV RJZajCt1hA4A3pY5zN/okst5knuiUJFz29PrEg/Ru+1Lb2BQF/lhWa77aVAvU0kJdtscC/ziWaVAd B49MQNTY5vKtmK+6YVFfNC2gwJwM/Q0+kpzH7j3fZiVz27C0li/rFUZ2DRgz0/6AhUR1b1fsvgol7 WT3oEvkQmoU8IkCaFEpRS2KrY7xqe0/y6ueboaQMjRMauJxfA3BzH+abcoZRW3hvDsRW95FvAHbfv wpWYovkXZBlBaU0KkhNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesBn-0000000CFDW-136y; Fri, 16 Aug 2024 08:20:03 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sesB1-0000000CEx7-1ImF for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 08:19:16 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-427fc97a88cso12855335e9.0 for <linux-arm-kernel@lists.infradead.org>; Fri, 16 Aug 2024 01:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723796354; x=1724401154; darn=lists.infradead.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=jtDygU8gueGwJ3Zdqpj2DOV0h4FMxFQXx/h+FOpbWvI=; b=l57x5mfI/UugrwR64nT13tAU/MZ+UhY7a4BMYz5RnRc1d8K0S4FULpIM+10GECjQhu VR0IUncU/vNdZm7saXZdH2hzI2FoYLCTta55TwX8+dzTfdOwuxnRP91ldd7PtWT0UBrG qU5n7r1LRALUT6eGaDsibOLsC1vbbZ6uEdCfjgCb3w49xN5P/tQtb3T3JmvXoRykKcAr 01RN4FIVbHedbkZ+OIcz4ABCLVakbpexy87iTzdo8siDgg68qGrNtNO7O3jqeUg9cOph q6WCatQoJhuy6PBrHA296UpGkERmEIvtp8mNKkdgp8pOPffC8JGvLd9MQDuBL5kupIMx FBwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723796354; x=1724401154; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jtDygU8gueGwJ3Zdqpj2DOV0h4FMxFQXx/h+FOpbWvI=; b=O78TFtczsEIrZG3FmwBrV9wB2o2k5UUvvSZJ9ve5OV8wisRoLGcLdQlniW4OreVPYl h1LILY6wXmdM1w6x8zO7lIYUtO49yWa2vaMCDxV8IW6fy+7tNW0MH08R9wmlImSoix+d M/GB6vH389WC330vTd0oAyESziweOBC/8LOsBo0eucl51aNFIqXOQFQM1TxRJ410c04u 8/1PAj8xOU9vH+LuR9lng8rClNVuQTmSO+qyO5MnrfAAUZDUNVl1VjHgJ3YIy1r+HvQo F+5PceRrxerTplozksCJWx6U4eqr69kFcAYa43mIrNNvKxfdWdzjL+dPl7Qi3W4p8h6B zOGw== X-Forwarded-Encrypted: i=1; AJvYcCWGzrOp4Wc/QFohy0R3/4bhiPtZwQ1H0doMjaZJhft7S/5pL8Z2usYwGfdrKqHXugg/GWYMU3uH0HlJiQ0oLhULrZC/Kksd13Jy5fPahN2zT7WrVLI= X-Gm-Message-State: AOJu0Yyu9njUyZmSZQmm90hKM01LR/rblsAfIjAN0z/Qc5wpZnBM0uaY HwuTZi3tuahi9foqHBan1Noe5Gvc1zfIJmQIFVXzQXhcLnKW3KFQmOFBBA== X-Google-Smtp-Source: AGHT+IGNbg3I7QZJheZdQ8rGnj17FDcQiRIrDUrcZBBxXAtfo3ghCe3iY1GPVaXX7Lx+R26mA8BcUA== X-Received: by 2002:a05:600c:45d1:b0:426:5cee:4abc with SMTP id 5b1f17b1804b1-429ed7b69e7mr15546325e9.20.1723796353283; Fri, 16 Aug 2024 01:19:13 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 01:19:12 -0700 (PDT) From: Artur Weber <aweber.kernel@gmail.com> Subject: [PATCH v4 00/10] power: supply: max77693: Toggle charging/OTG based on extcon status Date: Fri, 16 Aug 2024 10:19:06 +0200 Message-Id: <20240816-max77693-charger-extcon-v4-0-050a0a9bfea0@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAHsLv2YC/3XOywqDMBAF0F8pWTclyfhIuup/lC7yGDVQtUQJF vHfG6VQKbi8M9wzM5MBg8eBXE8zCRj94Psuhex8IrbRXY3Uu5SJYCJjuchpq6eyLBTQtA41Bor TaPuOKjSmNNpJsEhS+xWw8tMm3x8pN34Y+/DeDkW+Tr8msEMzcsqos0IrzI2rgN3qVvvnxfYtW c0ofk7Jj3+LIjlMgqwqY7i08O/AzhHq2IHVEcBzXchCuWzvLMvyARRNLopOAQAA To: Krzysztof Kozlowski <krzk@kernel.org>, Chanwoo Choi <cw00.choi@samsung.com> Cc: Sebastian Reichel <sre@kernel.org>, Rob Herring <robh@kernel.org>, Conor Dooley <conor+dt@kernel.org>, Lee Jones <lee@kernel.org>, Krzysztof Kozlowski <krzk+dt@kernel.org>, Alim Akhtar <alim.akhtar@samsung.com>, 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 <henrik@grimler.se>, Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>, Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>, Artur Weber <aweber.kernel@gmail.com>, Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4991; i=aweber.kernel@gmail.com; h=from:subject:message-id; bh=6h9z8ocfL2XATSNX1s5d9pI5+s+N88N6/riFX1N5zSI=; b=owEBbQKS/ZANAwAKAbO7+KEToFFoAcsmYgBmvwt9/xI5SBsf/+z7dMXn1agclu2xIMH1MNshx xKSiQPwujSJAjMEAAEKAB0WIQTmYwAOrB3szWrSiQ2zu/ihE6BRaAUCZr8LfQAKCRCzu/ihE6BR aMr4D/9uiT5kwxvbyjh6f+350O+wBpl/dc/tthZezeLzvz/ovq0TjYpXN7A/OOmFVdQWk8mo5Jb jv0QRYyppxvIsmxbK2zvbV7KmlHH19v8482DSCFUYybk8zNYrvEXN7RgtWw5YHyuUKd/4biKOBL 1BUMw47CmpmyctbIgemvtfW/1oRflvzkq1adhqTdCwWv+oLqXStH8PP3BJnh6lDkqMiw07moNhF oXigDotDgRuve0+jn4DZD3fQTiFqo618GnTxN0xEFBMhKPI0wowJi9aOoXG0gFGECWmhijw6I4D I5U8rhIMD5R2bFD17A1EEOWwobjevNE+h6fxO4Wuee5e/zaRb6VKBkSzK+aThpLG/GmTDfH2zak nd1AUiOTfqQRlG8rvnXzQRJJ+nz5kytxQQjHAR9HWDtAaKIe+7tMTNL5OkCEuseO+cSt0Rx712p vP3hfOmpeds/gHlT1uM02sU0CNXR5v4vOa055FtIu64/Lcfny2YNYQleajAZTDgJ2lQPjsfHt6E Yy9scDrvd66VPxZkBcCJ7hDX1BH1+F/vey7DpcCv2MSPYrDERFjaGjvs/EhgICRk5Cb4/JNj2kq isWU86FIe4H7SQJps/LVRZlSUtEv3+/+/HySRSc/21yr7Z9RPSlYAo+6GJWwpRihTx4WW6prNPn t9oycjk0T2zeShw== 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_011915_388660_028A75CC X-CRM114-Status: GOOD ( 20.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
power: supply: max77693: Toggle charging/OTG based on extcon status
|
expand
|
On Fri, 16 Aug 2024 10:19:06 +0200, Artur Weber wrote: > This patchset does the following: > > - Add CURRENT_MAX and INPUT_CURRENT_MAX power supply properties to > expose the "fast charge current" (maximum current from charger to > battery) and "CHGIN input current limit" (maximum current from > external supply to charger). > > [...] Applied, thanks! [03/10] power: supply: max77693: Expose input current limit and CC current properties commit: ba7e053ec89f61be9d27bfb244de52849b5138aa Best regards,
This patchset does the following: - Add CURRENT_MAX and INPUT_CURRENT_MAX power supply properties to expose the "fast charge current" (maximum current from charger to battery) and "CHGIN input current limit" (maximum current from external supply to charger). - Add functions for toggling charging and OTG modes. - Add an extcon-based handler that enables charging or OTG depending on the cable type plugged in. The extcon device to use for cable detection can be specified in the device tree, and is entirely optional. The extcon listener implementation is inspired by the rt5033 charger driver (commit 8242336dc8a8 ("power: supply: rt5033_charger: Add cable detection and USB OTG supply")). Signed-off-by: Artur Weber <aweber.kernel@gmail.com> --- v3 no longer uses the CHARGER regulator to manage the power status, and that's for two reasons: - Regulator enable/disable behavior was interfering with how the power supply driver worked (we occasionally got "unbalanced disables" errors when switching charging state, despite checking for the regulator status with regulator_is_enabled() - the CHARGER reg would report as enabled despite the enable count being 0). This broke OTG insertion if the OTG cable was plugged in first, and sometimes caused warnings on unsuspend. - Changing the charging values directly in the power supply driver is less opaque and lets us avoid bringing in a dependency on regulators. It also splits the current limits back into two properties: INPUT_CURRENT_LIMIT and CONSTANT_CHARGE_CURRENT_MAX. Again, there are two reasons for this split: - They are two separate current controls, one for USB->charger and one for charger->battery, and they have different limits (0-2.1A for CC vs 60mA-2.58A for input). Given that the power supply core has the properties for both values separately, it's more logical to present them as such. - It's safer to keep these separate; CONSTANT_CHARGE_CURRENT_MAX is pretty explicitly only set *once* - at probe time with a safe value specified in the DT. This way, INPUT_CURRENT_LIMIT is safer to modify since in the event of an invalid value the CC current will hold back the extra current thus preventing damage to the battery. The latter is relevant as I'm working on a follow-up patchset that allows for controlling the charging parameters using power supply properties/sysfs properties rather than the CHARGER regulator. Note that the CHARGER regulator gets disabled automatically if it's not used, which will disable charging if it was auto-enabled by the extcon code. This can be worked around by re-attaching the cable, or more properly by removing the CHARGER regulator from DT for devices that use the extcon-based charger management, as has been done in the Galaxy Tab 3 8.0 DTSI. See v1 for old description: https://lore.kernel.org/r/20240530-max77693-charger-extcon-v1-0-dc2a9e5bdf30@gmail.com --- Changes in v4: - Fix probe deferrals on missing maxim,usb-connector property - Link to v3: https://lore.kernel.org/r/20240729-max77693-charger-extcon-v3-0-02315a6869d4@gmail.com Changes in v3: - Drop uses of CHARGER regulator, manage registers directly in power supply driver instead - Link to v2: https://lore.kernel.org/r/20240715-max77693-charger-extcon-v2-0-0838ffbb18c3@gmail.com Changes in v2: - Changed to use monitored-battery for charge current value - Both current limit variables are now set by the CHARGER regulator - Link to v1: https://lore.kernel.org/r/20240530-max77693-charger-extcon-v1-0-dc2a9e5bdf30@gmail.com --- Artur Weber (10): dt-bindings: power: supply: max77693: Add monitored-battery property dt-bindings: power: supply: max77693: Add maxim,usb-connector property power: supply: max77693: Expose input current limit and CC current properties power: supply: max77693: Set charge current limits during init power: supply: max77693: Add USB extcon detection for enabling charging power: supply: max77693: Add support for detecting and enabling OTG power: supply: max77693: Set up charge/input current according to cable type ARM: dts: samsung: exynos4212-tab3: Add battery node with charge current value ARM: dts: samsung: exynos4212-tab3: Add USB connector node ARM: dts: samsung: exynos4212-tab3: Drop CHARGER regulator .../bindings/power/supply/maxim,max77693.yaml | 15 + arch/arm/boot/dts/samsung/exynos4212-tab3.dtsi | 22 +- drivers/power/supply/Kconfig | 1 + drivers/power/supply/max77693_charger.c | 304 ++++++++++++++++++++- include/linux/mfd/max77693-private.h | 12 + 5 files changed, 339 insertions(+), 15 deletions(-) --- base-commit: 0c3836482481200ead7b416ca80c68a29cfdaabd change-id: 20240525-max77693-charger-extcon-9ebb7bad83ce Best regards,