From nobody Sun Feb 8 08:27:31 2026 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 4745BC83F15 for ; Mon, 28 Aug 2023 21:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233716AbjH1Vdt (ORCPT ); Mon, 28 Aug 2023 17:33:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233679AbjH1Vdj (ORCPT ); Mon, 28 Aug 2023 17:33:39 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C1D8FC for ; Mon, 28 Aug 2023 14:33:35 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F05FB2F4; Mon, 28 Aug 2023 14:34:14 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB5F03F740; Mon, 28 Aug 2023 14:33:33 -0700 (PDT) From: Andre Przywara To: Lee Jones , Chen-Yu Tsai Cc: linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Shengyu Qu , Martin Botka , Matthew Croughan Subject: [PATCH v2] mfd: axp20x: Generalise handling without interrupt Date: Mon, 28 Aug 2023 22:32:29 +0100 Message-Id: <20230828213229.20332-1-andre.przywara@arm.com> X-Mailer: git-send-email 2.35.8 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" At the moment we allow the AXP15060 and the AXP806 PMICs to omit the interrupt line to the SoC, and we skip registering the PEK (power key) driver in this case, since that crashes when no IRQ is described in the DT node. The IRQ pin potentially not being connected to anything does affect more PMICs, though, and the PEK driver is not the only one requiring an interrupt: at least the AC power supply driver crashes in a similar fashion. Generalise the handling of AXP MFD devices when the platform tables describe no interrupt, by allowing each device to specify an alternative MFD list for this case. If no specific alternative is specified, we go with the safe default of "just the regulators", which matches the current situation. This enables new devices using the AXP313a PMIC, but not connecting the IRQ pin. Signed-off-by: Andre Przywara Reviewed-by: Jernej Skrabec --- Changelog v2 .. v1: - drop reordering approach, use separate cell lists drivers/mfd/axp20x.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index c03bc5cda080a..239e7f18956ae 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -1133,6 +1133,8 @@ int axp20x_match_device(struct axp20x_dev *axp20x) struct device *dev =3D axp20x->dev; const struct acpi_device_id *acpi_id; const struct of_device_id *of_id; + const struct mfd_cell *cells_no_irq =3D NULL; + int nr_cells_no_irq =3D 0; =20 if (dev->of_node) { of_id =3D of_match_device(dev->driver->of_match_table, dev); @@ -1207,14 +1209,15 @@ int axp20x_match_device(struct axp20x_dev *axp20x) * if there is no interrupt line. */ if (of_property_read_bool(axp20x->dev->of_node, - "x-powers,self-working-mode") && - axp20x->irq > 0) { + "x-powers,self-working-mode")) { axp20x->nr_cells =3D ARRAY_SIZE(axp806_self_working_cells); axp20x->cells =3D axp806_self_working_cells; } else { axp20x->nr_cells =3D ARRAY_SIZE(axp806_cells); axp20x->cells =3D axp806_cells; } + nr_cells_no_irq =3D ARRAY_SIZE(axp806_cells); + cells_no_irq =3D axp806_cells; axp20x->regmap_cfg =3D &axp806_regmap_config; axp20x->regmap_irq_chip =3D &axp806_regmap_irq_chip; break; @@ -1238,24 +1241,8 @@ int axp20x_match_device(struct axp20x_dev *axp20x) axp20x->regmap_irq_chip =3D &axp803_regmap_irq_chip; break; case AXP15060_ID: - /* - * Don't register the power key part if there is no interrupt - * line. - * - * Since most use cases of AXP PMICs are Allwinner SOCs, board - * designers follow Allwinner's reference design and connects - * IRQ line to SOC, there's no need for those variants to deal - * with cases that IRQ isn't connected. However, AXP15660 is - * used by some other vendors' SOCs that didn't connect IRQ - * line, we need to deal with this case. - */ - if (axp20x->irq > 0) { - axp20x->nr_cells =3D ARRAY_SIZE(axp15060_cells); - axp20x->cells =3D axp15060_cells; - } else { - axp20x->nr_cells =3D ARRAY_SIZE(axp_regulator_only_cells); - axp20x->cells =3D axp_regulator_only_cells; - } + axp20x->nr_cells =3D ARRAY_SIZE(axp15060_cells); + axp20x->cells =3D axp15060_cells; axp20x->regmap_cfg =3D &axp15060_regmap_config; axp20x->regmap_irq_chip =3D &axp15060_regmap_irq_chip; break; @@ -1263,6 +1250,23 @@ int axp20x_match_device(struct axp20x_dev *axp20x) dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); return -EINVAL; } + + /* + * Use an alternative cell array when no interrupt line is connected, + * since IRQs are required by some drivers. + * The default is the safe "regulator-only", as this works fine without + * an interrupt specified. + */ + if (axp20x->irq <=3D 0) { + if (cells_no_irq) { + axp20x->nr_cells =3D nr_cells_no_irq; + axp20x->cells =3D cells_no_irq; + } else { + axp20x->nr_cells =3D ARRAY_SIZE(axp_regulator_only_cells); + axp20x->cells =3D axp_regulator_only_cells; + } + } + dev_info(dev, "AXP20x variant %s found\n", axp20x_model_names[axp20x->variant]); =20 --=20 2.35.8