Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1254958rdb; Tue, 30 Jan 2024 12:37:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEV9NBZsKfjdKpK5MW93CCGeDd9wJJSzKUjUBazu2iXYW5jh6rHzx81Eq2wdvgy3WC9pKHh X-Received: by 2002:a05:6402:274b:b0:55e:f866:30dd with SMTP id z11-20020a056402274b00b0055ef86630ddmr5532705edd.12.1706647072520; Tue, 30 Jan 2024 12:37:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706647072; cv=pass; d=google.com; s=arc-20160816; b=GojQU6BQ8y2R2tqsX+i6i0bl7zXMfKnSZs8IQbfZBRd7Z5DV/C2FmZLROD+HMi1DkT G8RWkTE4HlD16xRrHY8dyGlbFMWB1BeijV8Nyf+FRoV0uSV7q52V2JfmRPvr22pDNQk9 8YaMyhGIOmnrYzmadZBLyTsyDirOfL/3bVsoImP4/ns+R5hQoifQin+VNc/CjG2QcPx5 80WsMp9OVIaFx/wjNr/WY3q/JESfKc6FrWYEOaKvKkyTZTmIut73tA03itUnpc2kmBPO Eeg1xdz6Yk/Yxt/SHwNkCT43O67dAPDRmty3qemvPIBj1MjY9b2p07twImiZQE23eDVB WajQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=dkim-signature:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=CnBNCViJHvy4cEKLBSR8JFJniQcbGnFyzpaAFuYyqxw=; fh=CS8UjFWQd4C89aVAWtaFYgKrfPFQKsOq4yc2cb5p77k=; b=iL/J4dAOOPryCCvB3lUVQlyH8ZH+1uq12tbiVj/CXj+8+CLQsJdvKI8+qrsJ2LqRho pIIoMTDj22rzH690sWQffeMrCbfo/b+CtRnL9LUYdCTLijLP06MuILCxKcWBuYAx8w8o 4kDXL5BU8oA7N10ElZihLfJTJc3tTpKs4ixl5b9oXnOyIjjg+7y4VUPNWlbMaO4Uzl3z PnKFgkitz4whSuEk0az378oA/Tj+otrmHQqjuoOuDbHPXDiOzJ8aP0hMJADcOHygEkCB 45/E52m8DXTfLXtbb9vpsAxDlUMT9gPXBax46kVDBW32TE4qeJ8Nm1DtNiwo/uX87k/H AqPw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@peacevolution.org header.s=dkim header.b=FCdLf2bF; arc=pass (i=1 spf=pass spfdomain=peacevolution.org dkim=pass dkdomain=peacevolution.org dmarc=pass fromdomain=peacevolution.org); spf=pass (google.com: domain of linux-kernel+bounces-45275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45275-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=peacevolution.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l18-20020a056402231200b0055d2dd8b85asi4991560eda.230.2024.01.30.12.37.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 12:37:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@peacevolution.org header.s=dkim header.b=FCdLf2bF; arc=pass (i=1 spf=pass spfdomain=peacevolution.org dkim=pass dkdomain=peacevolution.org dmarc=pass fromdomain=peacevolution.org); spf=pass (google.com: domain of linux-kernel+bounces-45275-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45275-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=peacevolution.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 47DAE1F23C33 for ; Tue, 30 Jan 2024 20:37:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54F1F69E19; Tue, 30 Jan 2024 20:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="FCdLf2bF" Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6879D79DDB; Tue, 30 Jan 2024 20:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706647063; cv=none; b=B5VjpBf0dW5tEexYPXSxFM+MNqIDFsB5rrClLep/CCHZa4bi5aZn38RXEjAZZqasFOdqbZZq9Ny2FwJgXEkXzf0lqqFmuKRD9OJGPlU3vkRRs1izQ6Bi/EaFwV1tEenBpvUxL+j6eeDFbp6SW5xapo1REugMmmWYNVxxrD99Uio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706647063; c=relaxed/simple; bh=42VdHmLmZuT5O6V8Q0K2GarSQjq3zsRvTNhsMQjm5BI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=DRUvygh1qP6mycdWKFluM6ewOzUkhhDOUfJpMh2BaDK1By7xHO0aExO5nFLfaLPzEfUpt3KPtmSzNUTbrLsn2HA/2N6kHvoRXj/lytOm/R0GIcNoEVX7IPNH6bdOsUyhnmXe3jc4OVJFBsAH1RGzfQPdtdSr9evcWVdpM6nuem0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=FCdLf2bF; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id 6F80046B74; Tue, 30 Jan 2024 20:37:32 +0000 (UTC) From: Aren Moynihan To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ond=C5=99ej=20Jirman?= , Hans de Goede , Aidan MacDonald , Aren Moynihan , Chen-Yu Tsai , Quentin Schulz , Sebastian Reichel Subject: [PATCH v2 0/5] power: supply: axp20x_usb_power: cleanup input current limit handling Date: Tue, 30 Jan 2024 15:27:56 -0500 Message-ID: <20240130203714.3020464-1-aren@peacevolution.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Bar: / Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1706647053; h=from:subject:date:message-id:to:cc:mime-version:content-type:content-transfer-encoding; bh=CnBNCViJHvy4cEKLBSR8JFJniQcbGnFyzpaAFuYyqxw=; b=FCdLf2bFSk3L24ys482teOv4NVoVkgp4hXsRIVyC5BUHZ8cG2nFh55b0ScOuKuZFTJvYvl xx6gGB7eSX+NQ5R92XAVdibbCIxBAoA0yk8f07JvMTRtTxxohiNwkeW3E7ZqJ7zYOYUDvX uXb6y4TWC3K6SHhtEurSClxGvtrPkZo= Proper handling of the input current limit will be necessary to implement usb power delivery on the Pine64 PinePhone. The PinePhone has a separate chip (anx7688) that handles usb power delivery (among other things), so we will need a way to apply the current limit which that negotiates. The new logic to get/set the input current limit, and get the usb type is originally based on code Ondřej Jirman wrote[1], but I have significantly refactored it. While working on this, I also discovered that the axp803 pmic sets a current limit of 3A on the usb port without any negotiation if it doesn't detect a battery. v1 of this patch can be found at: https://lore.kernel.org/lkml/20240121014057.1042466-1-aren@peacevolution.org/ 1: https://xff.cz/git/linux/commit/?h=axp-6.7&id=3dcd33dfd1ae58db159427365dcb6d0d2b12f06d Changes in v2: - Values less than the lowest supported limit are rounded up instead of returning -EINVAL when setting the input current limit. - Rename existing current_max logic to input_current_limit. This also makes it possible to reuse some of that logic. - Split current limit register and bc race condition fixes into different commits. Aren Moynihan (5): power: supply: axp20x_usb_power: replace current_max with input_current_limit power: supply: axp20x_usb_power: use correct register for input current limit power: supply: axp20x_usb_power: fix race condition with usb bc power: supply: axp20x_usb_power: enable usb_type reporting power: supply: axp20x_usb_power: set input current limit in probe drivers/power/supply/axp20x_usb_power.c | 160 +++++++++++++++++++++--- 1 file changed, 144 insertions(+), 16 deletions(-) -- 2.43.0