Devicetree
 help / color / mirror / Atom feed
From: "MINETTE Alexandre" <contact@alex-min.fr>
To: "Lee Jones" <lee@kernel.org>
Cc: "Bjorn Andersson" <andersson@kernel.org>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"MyungJoo Ham" <myungjoo.ham@samsung.com>,
	"Chanwoo Choi" <cw00.choi@samsung.com>,
	"Guru Das Srinagesh" <linux@gurudas.dev>,
	"Linus Walleij" <linusw@kernel.org>,
	"Rob Clark" <robin.clark@oss.qualcomm.com>,
	"Kees Cook" <kees@kernel.org>, "Tony Luck" <tony.luck@intel.com>,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	phone-devel@vger.kernel.org
Subject: Re: [PATCH v5 4/6] mfd: qcom-pm8xxx: register PM8921 USB ID extcon
Date: Sun, 30 Aug 2026 22:18:50 +0200	[thread overview]
Message-ID: <646d46b1-7c59-4d73-b033-f4afaf19bdd7@app.fastmail.com> (raw)
In-Reply-To: <20260812122900.GQ1072730@google.com>

Hi Lee, 

Thanks for the feedback!

For the v6 series, I'll add a proper define for the 49 IRQ and use the devm api indeed.

About using the MFD api: I looked at it, but devm_mfd_add_devices()  
doesn't seem to let me reuse the parent firmware node, which I need here  
because the DT consumer uses extcon = <&pm8921>. 
So I kept  platform_device_register_full().
Let me know if I missed something here.

Thanks,
Alexandre
-- 
  MINETTE Alexandre
  contact@alex-min.fr

Mer 12 août 2026, à 14:29, Lee Jones a écrit :
> On Tue, 04 Aug 2026, Alexandre MINETTE via B4 Relay wrote:
>
>> From: Alexandre MINETTE <contact@alex-min.fr>
>> 
>> PM8921 reports the USB ID pin through interrupt 49 of its interrupt
>> controller. Unlike PM8941, this path has no separate addressable misc
>> block to represent as a devicetree child node.
>> 
>> Register a child platform device for the existing Qualcomm USB extcon
>> driver after creating the PMIC IRQ domain. Pass the USB ID interrupt as
>> a named resource and reuse the PM8921 firmware node, allowing consumers
>> to reference the PMIC node directly as their extcon provider.
>> 
>> Unregister the child device and dispose of the IRQ mapping when the
>> PMIC is removed or probing fails.
>> 
>> Signed-off-by: Alexandre MINETTE <contact@alex-min.fr>
>> ---
>>  drivers/mfd/qcom-pm8xxx.c | 78 +++++++++++++++++++++++++++++++++++++++++++++--
>>  1 file changed, 76 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/mfd/qcom-pm8xxx.c b/drivers/mfd/qcom-pm8xxx.c
>> index 0cf374c015ce..884fc99a1488 100644
>> --- dangerously/mfd/qcom-pm8xxx.c
>> +++ b/drivers/mfd/qcom-pm8xxx.c
>> @@ -7,6 +7,7 @@
>>  
>>  #include <linux/kernel.h>
>>  #include <linux/interrupt.h>
>> +#include <linux/ioport.h>
>>  #include <linux/irqchip/chained_irq.h>
>>  #include <linux/irq.h>
>>  #include <linux/irqdomain.h>
>> @@ -64,12 +65,15 @@
>>  
>>  struct pm_irq_data {
>>  	int num_irqs;
>> +	int usb_id_irq;
>>  	struct irq_chip *irq_chip;
>>  	irq_handler_t irq_handler;
>>  };
>>  
>>  struct pm_irq_chip {
>>  	struct regmap		*regmap;
>> +	struct platform_device	*usb_extcon;
>> +	unsigned int		usb_id_irq;
>>  	spinlock_t		pm_irq_lock;
>>  	struct irq_domain	*irqdomain;
>>  	unsigned int		num_blocks;
>> @@ -492,6 +496,13 @@ static const struct pm_irq_data pm8xxx_data = {
>>  	.irq_handler = pm8xxx_irq_handler,
>>  };
>>  
>> +static const struct pm_irq_data pm8921_data = {
>> +	.num_irqs = PM8XXX_NR_IRQS,
>> +	.usb_id_irq = 49,
>
> Magic numbers should be defined.
>
>> +	.irq_chip = &pm8xxx_irq_chip,
>> +	.irq_handler = pm8xxx_irq_handler,
>> +};
>> +
>>  static const struct pm_irq_data pm8821_data = {
>>  	.num_irqs = PM8821_NR_IRQS,
>>  	.irq_chip = &pm8821_irq_chip,
>> @@ -501,11 +512,60 @@ static const struct pm_irq_data pm8821_data = {
>>  static const struct of_device_id pm8xxx_id_table[] = {
>>  	{ .compatible = "qcom,pm8058", .data = &pm8xxx_data},
>>  	{ .compatible = "qcom,pm8821", .data = &pm8821_data},
>> -	{ .compatible = "qcom,pm8921", .data = &pm8xxx_data},
>> +	{ .compatible = "qcom,pm8921", .data = &pm8921_data},
>>  	{ }
>>  };
>>  MODULE_DEVICE_TABLE(of, pm8xxx_id_table);
>>  
>> +static int pm8xxx_add_usb_extcon(struct platform_device *pdev,
>> +				 struct pm_irq_chip *chip,
>> +				 unsigned int hwirq)
>> +{
>> +	struct irq_fwspec fwspec = {
>> +		.fwnode = dev_fwnode(&pdev->dev),
>> +		.param_count = 2,
>> +		.param = { hwirq, IRQ_TYPE_EDGE_BOTH },
>> +	};
>> +	struct platform_device_info pdevinfo = {
>> +		.parent = &pdev->dev,
>> +		.fwnode = dev_fwnode(&pdev->dev),
>> +		.of_node_reused = true,
>> +		.name = "qcom-pm8xxx-usb-id",
>> +		.id = PLATFORM_DEVID_NONE,
>> +	};
>> +	struct resource resource;
>> +
>> +	chip->usb_id_irq = irq_create_fwspec_mapping(&fwspec);
>> +	if (!chip->usb_id_irq)
>> +		return -ENXIO;
>> +
>> +	resource = DEFINE_RES_IRQ_NAMED(chip->usb_id_irq, "usb_id");
>> +	pdevinfo.res = &resource;
>> +	pdevinfo.num_res = 1;
>> +
>> +	chip->usb_extcon = platform_device_register_full(&pdevinfo);
>
> Why aren't you using the MFD API for this?
>
>> +	if (IS_ERR(chip->usb_extcon)) {
>> +		int ret = PTR_ERR(chip->usb_extcon);
>> +
>> +		chip->usb_extcon = NULL;
>> +		irq_dispose_mapping(chip->usb_id_irq);
>> +		chip->usb_id_irq = 0;
>> +
>> +		return ret;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static void pm8xxx_remove_usb_extcon(struct pm_irq_chip *chip)
>> +{
>> +	if (chip->usb_extcon)
>> +		platform_device_unregister(chip->usb_extcon);
>> +
>> +	if (chip->usb_id_irq)
>> +		irq_dispose_mapping(chip->usb_id_irq);
>> +}
>
> Why not devm_*
>
>>  static int pm8xxx_probe(struct platform_device *pdev)
>>  {
>>  	const struct pm_irq_data *data;
>> @@ -570,9 +630,22 @@ static int pm8xxx_probe(struct platform_device *pdev)
>>  
>>  	irq_set_irq_wake(irq, 1);
>>  
>> +	if (data->usb_id_irq) {
>> +		rc = pm8xxx_add_usb_extcon(pdev, chip, data->usb_id_irq);
>> +		if (rc)
>> +			goto err_domain;
>> +	}
>> +
>>  	rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
>>  	if (rc)
>> -		irq_domain_remove(chip->irqdomain);
>> +		goto err_extcon;
>> +
>> +	return 0;
>> +
>> +err_extcon:
>> +	pm8xxx_remove_usb_extcon(chip);
>> +err_domain:
>> +	irq_domain_remove(chip->irqdomain);
>>  
>>  	return rc;
>>  }
>> @@ -582,6 +655,7 @@ static void pm8xxx_remove(struct platform_device *pdev)
>>  	struct pm_irq_chip *chip = platform_get_drvdata(pdev);
>>  
>>  	of_platform_depopulate(&pdev->dev);
>> +	pm8xxx_remove_usb_extcon(chip);
>>  	irq_domain_remove(chip->irqdomain);
>>  }
>>  
>> 
>> -- 
>> 2.43.0
>> 
>> 
>
> -- 
> Lee Jones

  reply	other threads:[~2026-08-30 20:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04  6:34 [PATCH v5 0/6] Add Samsung Galaxy S4 support Alexandre MINETTE via B4 Relay
2026-08-04  6:34 ` [PATCH v5 1/6] dt-bindings: arm: qcom: Add Samsung Galaxy S4 Alexandre MINETTE via B4 Relay
2026-08-04  6:34 ` [PATCH v5 2/6] pinctrl: qcom: Register functions before enabling pinctrl Alexandre MINETTE via B4 Relay
2026-08-07  8:32   ` Linus Walleij
2026-08-10 11:09   ` Bartosz Golaszewski
2026-08-30  7:52     ` MINETTE Alexandre
2026-09-02 10:32       ` Bartosz Golaszewski
2026-08-04  6:34 ` [PATCH v5 3/6] ARM: dts: qcom: apq8064: Fix USB controller clocks Alexandre MINETTE via B4 Relay
2026-08-04  6:52   ` sashiko-bot
2026-08-04 14:24   ` Antony Kurniawan Soemardi
2026-08-04  6:34 ` [PATCH v5 4/6] mfd: qcom-pm8xxx: register PM8921 USB ID extcon Alexandre MINETTE via B4 Relay
2026-08-04  6:54   ` sashiko-bot
2026-08-12 12:29   ` Lee Jones
2026-08-30 20:18     ` MINETTE Alexandre [this message]
2026-08-04  6:34 ` [PATCH v5 5/6] extcon: qcom-spmi-misc: match PM8xxx USB ID platform device Alexandre MINETTE via B4 Relay
2026-08-04  7:01   ` sashiko-bot
2026-08-04  6:34 ` [PATCH v5 6/6] ARM: dts: qcom: Add Samsung Galaxy S4 Alexandre MINETTE via B4 Relay
2026-08-04  6:53   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=646d46b1-7c59-4d73-b033-f4afaf19bdd7@app.fastmail.com \
    --to=contact@alex-min.fr \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gpiccoli@igalia.com \
    --cc=kees@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@gurudas.dev \
    --cc=myungjoo.ham@samsung.com \
    --cc=phone-devel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox