From nobody Tue Sep 16 23:11:52 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05D80C3DA7A for ; Wed, 28 Dec 2022 16:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233728AbiL1QcF (ORCPT ); Wed, 28 Dec 2022 11:32:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234726AbiL1Qbj (ORCPT ); Wed, 28 Dec 2022 11:31:39 -0500 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13DE11C113 for ; Wed, 28 Dec 2022 08:27:55 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 253D632002FB; Wed, 28 Dec 2022 11:27:55 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 28 Dec 2022 11:27:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t=1672244874; x=1672331274; bh=k1jw7prIecCK9PqphsN3qWRlG ngXIbmWqvs3m/zFc78=; b=JzE+szhB/q3OHjuOXgjukbGQve4Ad50vdmnw19NuC eunjp0gTYik63zu2/Z/Ms5QlTfmJ5pLKhLfwGl1Rjr4L5wBEGD0SHnTHKKtEp79D PHxwppXMyY4ZQU0jIEYBOkf9Pu+R1eMs5aH5bJBAsEv6uLSk9sA2/rrS3et1EJM8 +B1vkg1XcT86TxYMUTZNJobzBtQ+aGv59uD5S9ONRthf8vHPUVq9nzCU/ilvvbw9 T0HwLQO3yPZwcu0m0FBbuQBLcLbhyjXTvRHywqFN6nebEy6L58tUaCY3ljIoqoNP 5mxKoNxeZdgWVHqkgbORTi3O7iGAs6PSDgL0ccvOtdo4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1672244874; x=1672331274; bh=k1jw7prIecCK9PqphsN3qWRlGngXIbmWqvs 3m/zFc78=; b=GTrwt7emst8sYUEVNRfZdZOAzN3a6NLnqkGZ8szSn0nB7FVRzaA 8sOZUtHz03dVgUcb8oSAMVAHzuanjicl54VwWwhedHrfolbHDz5Fjx4pk6RIuFru ts1j9GhdJUs9Idw6QYpnx7RO5qfQdCSwWjKVzXCI6hRoug9gnqU+XSKDOFxdPQFO S3vuV6CfLBDhZEh7eb/k81vVsuW8KMF5ZEQO9cMUMY12OSlMgxOIb0bZ9F/mTvrn dTDswTpOid75th2nRVrdWmIx16cstxyKd9V2KyL1qXxcBOdint06hiCJcq8w87qY tD0DgaYgXSjVuzOLXBLGYkczfBJY1KMia5A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedriedvgdeltdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgggfestdekredtre dttdenucfhrhhomhepufgrmhhuvghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhho lhhlrghnugdrohhrgheqnecuggftrfgrthhtvghrnhepkeehffethedtteffgfefteetje dvfeelueevudffgfeutdejvdehledvvdffhfevnecuffhomhgrihhnpehkvghrnhgvlhdr ohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 28 Dec 2022 11:27:53 -0500 (EST) From: Samuel Holland To: Chen-Yu Tsai , Lee Jones Cc: Samuel Holland , linux-kernel@vger.kernel.org Subject: [PATCH] mfd: axp20x: Switch to the sys-off handler API Date: Wed, 28 Dec 2022 10:27:52 -0600 Message-Id: <20221228162752.14204-1-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This removes a layer of indirection through pm_power_off() and allows the PMIC handler to be used as a fallback when firmware power off fails. This happens on boards like the Clockwork DevTerm R-01 where OpenSBI does not know how to use the PMIC to power off the board. Move the check for AXP288 to avoid registering a dummy handler. Signed-off-by: Samuel Holland --- Note: this patch depends on updating the PSCI driver first[1] to keep the existing callback priority. [1]: https://lore.kernel.org/lkml/20221105214841.7828-1-samuel@sholland.org/ drivers/mfd/axp20x.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 47fd700f284f..58f82f1f4b43 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include =20 @@ -825,17 +825,17 @@ static const struct mfd_cell axp813_cells[] =3D { }, }; =20 -static struct axp20x_dev *axp20x_pm_power_off; -static void axp20x_power_off(void) +static int axp20x_power_off(struct sys_off_data *data) { - if (axp20x_pm_power_off->variant =3D=3D AXP288_ID) - return; + struct axp20x_dev *axp20x =3D data->cb_data; =20 - regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL, + regmap_write(axp20x->regmap, AXP20X_OFF_CTRL, AXP20X_OFF); =20 /* Give capacitors etc. time to drain to avoid kernel panic msg. */ mdelay(500); + + return NOTIFY_DONE; } =20 int axp20x_match_device(struct axp20x_dev *axp20x) @@ -1002,10 +1002,11 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) return ret; } =20 - if (!pm_power_off) { - axp20x_pm_power_off =3D axp20x; - pm_power_off =3D axp20x_power_off; - } + if (axp20x->variant !=3D AXP288_ID) + devm_register_sys_off_handler(axp20x->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + axp20x_power_off, axp20x); =20 dev_info(axp20x->dev, "AXP20X driver loaded\n"); =20 @@ -1015,11 +1016,6 @@ EXPORT_SYMBOL(axp20x_device_probe); =20 void axp20x_device_remove(struct axp20x_dev *axp20x) { - if (axp20x =3D=3D axp20x_pm_power_off) { - axp20x_pm_power_off =3D NULL; - pm_power_off =3D NULL; - } - mfd_remove_devices(axp20x->dev); regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc); } --=20 2.37.4