Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp2198219rdb; Thu, 17 Aug 2023 13:46:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqAKPoT4bVZtN4i/NxvTMYLpq3Ndqjfvch6r63aje2wsbqhrYVHqWsJM4JyEBGztrYikDO X-Received: by 2002:a05:6a21:78a5:b0:132:d09f:1716 with SMTP id bf37-20020a056a2178a500b00132d09f1716mr551170pzc.2.1692305213947; Thu, 17 Aug 2023 13:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692305213; cv=none; d=google.com; s=arc-20160816; b=Mh0IUpcaH6Bx5j1VP6/2Gp5Ue1295CSvAJMEVfsocYl6A4pZW/MbI1t2axueizbCIx g/YwyBsgmwb5WkUCLu99eeztK3qArO5I3aho9a9q7p6hvJPw5n5Z24o+UK0ldskAKcQK cCvU1oYRu32/2NRVo9B069YT8s2gBjx8mh8YF1n395HB9HTe4NDii2gs1AN24JhMdDik A9smHzI5UCZNc6L6mLDBBvyiU8Fxrj+b3O4AruIqHTISneeg9yHZTRlttYciY4wbWocc jc0zOIO2vcRP3jSiodjGqP35FSTQmzyKSjIvj02wZnrham0mKwo2rSu2IgZ2lMWjQwog MQOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BS2frWReLMzbzvoAnHQlO/WzIL7OYX8a6nZV6V+AUdY=; fh=fk3pEaO+tDj1xBnUK8cwJq9HpcUlCHw1NRqLeoZ05n4=; b=V6+lEogItpWXGo7MFgXrWmxFzbbIRFjCMC/AgSzw/0imT5nEG/45MqbSgoojPEaMhY 7GwcbIBfmVIgrrfQLAhJIDgunr2x8u2mqrn9caUqS8l1r8JtfS6/2tsqXrSWmEtZ495S jKLxUpxDRSOTItdLWwJX1T7UEjsyl+RazPnDl03HNk3xbEvaFG/Gu98tiEhHOJFuLRFw h6I9fwQMsrGtCm1QzJOV2XDWlXotMkPkbLdWpNI//DSE2xJkyhrf4ZKe8pMX1Uo2h2UL 54K2uHXf/gqVc94PdNfRajtRJrLL6HBrdwX9GPJQmZXGzJkT/zXxBI3WfcB6iss1tire lfRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jnF6W+dj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br11-20020a056a00440b00b006871983a97dsi239523pfb.33.2023.08.17.13.46.41; Thu, 17 Aug 2023 13:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jnF6W+dj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350552AbjHQL4F (ORCPT + 99 others); Thu, 17 Aug 2023 07:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350585AbjHQLzm (ORCPT ); Thu, 17 Aug 2023 07:55:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DFE4198C for ; Thu, 17 Aug 2023 04:55:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F40D6114C for ; Thu, 17 Aug 2023 11:55:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5C8CC433C8; Thu, 17 Aug 2023 11:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692273337; bh=lwRGCQxS7V341MNzcO29I+Xzrq5jPbIfG8Nga71Dd74=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jnF6W+djk+ezgv9PuShQPBR/Y0eweF9LKPmEQBwwXb5F0eC6k2hOM8UH9Qd5rMqfJ G7nJCxpF8GnWscI20xsiW0L7+Sqyj3vcQJ7L5e931ZII1/wrieNuH7IXfmCzMePrqD Eg+iA537x9AAOedVX9FWKDCVEoNMSCEKmX/iR1R+K0x9MIZMTDZPzlnHSS9tDC3u4Y zL7ofoSn32vxGnanq2jBK/pm5O/jcbcZCeimtg/+vsv+1LkpoUopiG4l364byearvw z75gP4Yy6wmBZmKDX2MM75q09BFNo3sd4K9Pq6rHdF5IJEo/QTowSQHmt/9znO012L Jj9ZnOIxwGp4g== Date: Thu, 17 Aug 2023 12:55:29 +0100 From: Lee Jones To: Andre Przywara Cc: Chen-Yu Tsai , linux-kernel@vger.kernel.org, Jernej Skrabec , Shengyu Qu , martin.botka1@gmail.com, Matthew Croughan Subject: Re: [PATCH] mfd: axp20x: Generalise handling without interrupts Message-ID: <20230817115529.GD986605@google.com> References: <20230807133930.94309-1-andre.przywara@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230807133930.94309-1-andre.przywara@arm.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 07 Aug 2023, Andre Przywara wrote: > 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, for instance. > > Generalise the handling of AXP MFD devices when the platform tables > describe no interrupt, by putting devices requiring an IRQ *last* in > the MFD cell array. We then can easily cut short the number of devices > to be registered in this case. > > This patch just enables that for three PMIC models for now: the two > already handled, plus the AXP313a, for which we now have mulitple examples > of boards without the IRQ pin connected. > To stay consistent with the current behaviour, we still (try to) register > all devices for the other PMICs, even though this will probably crash > without an interrupt specified, if those problematic drivers are loaded. > But this new approach can now easily be extended to other PMICs with more > devices, should the need arise: currently all in-tree users are fine. > > This fixes operation on the first boards using the AXP313a, which do not > bother to connect the PMIC's IRQ pin. > > Signed-off-by: Andre Przywara > Reported-by: Shengyu Qu > --- > drivers/mfd/axp20x.c | 48 +++++++++++++++++--------------------------- > 1 file changed, 18 insertions(+), 30 deletions(-) Relying on the ordering of static struct elements is fragile. Please separate into new structs. > diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c > index c03bc5cda080a..c9623604bf6c1 100644 > --- a/drivers/mfd/axp20x.c > +++ b/drivers/mfd/axp20x.c > @@ -1031,12 +1031,12 @@ static const struct mfd_cell axp803_cells[] = { > }; > > static const struct mfd_cell axp806_self_working_cells[] = { > + { .name = "axp20x-regulator" }, > { > .name = "axp221-pek", > .num_resources = ARRAY_SIZE(axp806_pek_resources), > .resources = axp806_pek_resources, > }, > - { .name = "axp20x-regulator" }, > }; > > static const struct mfd_cell axp806_cells[] = { > @@ -1090,19 +1090,11 @@ static const struct mfd_cell axp813_cells[] = { > }; > > static const struct mfd_cell axp15060_cells[] = { > + { .name = "axp20x-regulator", }, > { > .name = "axp221-pek", > .num_resources = ARRAY_SIZE(axp15060_pek_resources), > .resources = axp15060_pek_resources, > - }, { > - .name = "axp20x-regulator", > - }, > -}; > - > -/* For boards that don't have IRQ line connected to SOC. */ > -static const struct mfd_cell axp_regulator_only_cells[] = { > - { > - .name = "axp20x-regulator", > }, > }; > > @@ -1133,6 +1125,7 @@ int axp20x_match_device(struct axp20x_dev *axp20x) > struct device *dev = axp20x->dev; > const struct acpi_device_id *acpi_id; > const struct of_device_id *of_id; > + int nr_cells_no_irq = 0; > > if (dev->of_node) { > of_id = of_match_device(dev->driver->of_match_table, dev); > @@ -1191,6 +1184,7 @@ int axp20x_match_device(struct axp20x_dev *axp20x) > break; > case AXP313A_ID: > axp20x->nr_cells = ARRAY_SIZE(axp313a_cells); > + nr_cells_no_irq = 1; > axp20x->cells = axp313a_cells; > axp20x->regmap_cfg = &axp313a_regmap_config; > axp20x->regmap_irq_chip = &axp313a_regmap_irq_chip; > @@ -1207,14 +1201,14 @@ 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 = ARRAY_SIZE(axp806_self_working_cells); > axp20x->cells = axp806_self_working_cells; > } else { > axp20x->nr_cells = ARRAY_SIZE(axp806_cells); > axp20x->cells = axp806_cells; > } > + nr_cells_no_irq = 1; > axp20x->regmap_cfg = &axp806_regmap_config; > axp20x->regmap_irq_chip = &axp806_regmap_irq_chip; > break; > @@ -1238,24 +1232,9 @@ int axp20x_match_device(struct axp20x_dev *axp20x) > axp20x->regmap_irq_chip = &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 = ARRAY_SIZE(axp15060_cells); > - axp20x->cells = axp15060_cells; > - } else { > - axp20x->nr_cells = ARRAY_SIZE(axp_regulator_only_cells); > - axp20x->cells = axp_regulator_only_cells; > - } > + axp20x->nr_cells = ARRAY_SIZE(axp15060_cells); > + nr_cells_no_irq = 1; > + axp20x->cells = axp15060_cells; > axp20x->regmap_cfg = &axp15060_regmap_config; > axp20x->regmap_irq_chip = &axp15060_regmap_irq_chip; > break; > @@ -1263,6 +1242,15 @@ int axp20x_match_device(struct axp20x_dev *axp20x) > dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); > return -EINVAL; > } > + > + /* > + * Skip registering some MFD cells if there is no interrupt > + * line, as IRQs might be required by some drivers. > + * Those components must be the last in the cell array. > + */ > + if (axp20x->irq <= 0) > + axp20x->nr_cells -= nr_cells_no_irq; > + > dev_info(dev, "AXP20x variant %s found\n", > axp20x_model_names[axp20x->variant]); > > -- > 2.25.1 > -- Lee Jones [李琼斯]