linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Samuel Kayode <samuel.kayode@savoirfairelinux.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: devnull+samuel.kayode.savoirfairelinux.com@kernel.org,
	Frank.li@nxp.com, abelvesa@kernel.org, abelvesa@linux.com,
	b38343@freescale.com, broonie@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org, dmitry.torokhov@gmail.com,
	eballetbo@gmail.com, imx@lists.linux.dev, krzk+dt@kernel.org,
	lee@kernel.org, lgirdwood@gmail.com, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	robh@kernel.org, sre@kernel.org, yibin.gong@nxp.com
Subject: Re: [PATCH v8 2/6] mfd: pf1550: add core driver
Date: Thu, 10 Jul 2025 10:08:18 -0400	[thread overview]
Message-ID: <aG_JUhEQaiYQfJmz@fedora> (raw)
In-Reply-To: <0406698c-6534-4aca-8994-e8a69ecee2b2@wanadoo.fr>

On Tue, Jul 08, 2025 at 08:46:48PM +0200, Christophe JAILLET wrote:
> Le 07/07/2025 à 23:37, Samuel Kayode via B4 Relay a écrit :
> > From: Samuel Kayode <samuel.kayode-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
> > 
> > Add the core driver for pf1550 PMIC. There are 3 subdevices for which the
> > drivers will be added in subsequent patches.
> > 
> > Reviewed-by: Frank Li <Frank.Li-3arQi8VN3Tc@public.gmane.org>
> > Signed-off-by: Samuel Kayode <samuel.kayode-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
> 
> Hi,
> 
> some nitpicks and a few real questions.
> 
> CJ
> 
> ...
> 
> > +	/* Add top level interrupts */
> > +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap, pf1550->irq,
> > +				       IRQF_ONESHOT | IRQF_SHARED |
> > +				       IRQF_TRIGGER_FALLING,
> > +				       0, &pf1550_irq_chip,
> > +				       &pf1550->irq_data);
> > +	if (ret)
> > +		return ret;
> > +
> > +	/* Add regulator */
> > +	irq = regmap_irq_get_virq(pf1550->irq_data, PF1550_IRQ_REGULATOR);
> 
> Same as above.
> 
> > +	if (irq < 0)
> > +		return dev_err_probe(pf1550->dev, irq,
> > +				     "Failed to get parent vIRQ(%d) for chip %s\n",
> > +				     PF1550_IRQ_REGULATOR, pf1550_irq_chip.name);
> > +
> > +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap, irq,
> > +				       IRQF_ONESHOT | IRQF_SHARED |
> > +				       IRQF_TRIGGER_FALLING, 0,
> > +				       &pf1550_regulator_irq_chip,
> > +				       &pf1550->irq_data_regulator);
> > +	if (ret)
> > +		return dev_err_probe(pf1550->dev, ret,
> > +				     "Failed to add %s IRQ chip\n",
> > +				     pf1550_regulator_irq_chip.name);
> > +
> > +	domain = regmap_irq_get_domain(pf1550->irq_data_regulator);
> > +
> > +	ret =  devm_mfd_add_devices(pf1550->dev, PLATFORM_DEVID_NONE, regulator,
> 
> 2 spaces after =
>
Will drop.
> > +				    1, NULL, 0, domain);
> > +	if (ret)
> > +		return ret;
> > +
> > +	/* Add onkey */
> > +	irq = regmap_irq_get_virq(pf1550->irq_data, PF1550_IRQ_ONKEY);
> 
> Same
> 
> > +	if (irq < 0)
> > +		return dev_err_probe(pf1550->dev, irq,
> > +				     "Failed to get parent vIRQ(%d) for chip %s\n",
> > +				     PF1550_IRQ_ONKEY, pf1550_irq_chip.name);
> > +
> > +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap, irq,
> > +				       IRQF_ONESHOT | IRQF_SHARED |
> > +				       IRQF_TRIGGER_FALLING, 0,
> > +				       &pf1550_onkey_irq_chip,
> > +				       &pf1550->irq_data_onkey);
> > +	if (ret)
> > +		return dev_err_probe(pf1550->dev, ret,
> > +				     "Failed to add %s IRQ chip\n",
> > +				     pf1550_onkey_irq_chip.name);
> > +
> > +	domain = regmap_irq_get_domain(pf1550->irq_data_onkey);
> > +
> > +	ret =  devm_mfd_add_devices(pf1550->dev, PLATFORM_DEVID_NONE, onkey, 1,
> 
> 2 spaces after =
> 
Will drop.
> > +				    NULL, 0, domain);
> > +	if (ret)
> > +		return ret;
> > +
> > +	/* Add battery charger */
> > +	irq = regmap_irq_get_virq(pf1550->irq_data, PF1550_IRQ_CHG);
> 
> This calls irq_create_mapping().
> Should irq_dispose_mapping() or another helper be called in the error
> handling path and in the remove function, or is it already handled by a
> devm_ function?
> 
This creates a mapping for the allocated `irq_data` runtime controller by
devm_regmap_add_irq. The `irq_data` is for the top level interrupts. Since it
was allocated with a devm_, I think irq_dispose_mapping is called during a
remove.
> > +	if (irq < 0)
> > +		return dev_err_probe(pf1550->dev, irq,
> > +				     "Failed to get parent vIRQ(%d) for chip %s\n",
> > +				     PF1550_IRQ_CHG, pf1550_irq_chip.name);
> > +
> > +	ret = devm_regmap_add_irq_chip(pf1550->dev, pf1550->regmap, irq,
> > +				       IRQF_ONESHOT | IRQF_SHARED |
> > +				       IRQF_TRIGGER_FALLING, 0,
> > +				       &pf1550_charger_irq_chip,
> > +				       &pf1550->irq_data_charger);
> > +	if (ret)
> > +		return dev_err_probe(pf1550->dev, ret,
> > +				     "Failed to add %s IRQ chip\n",
> > +				     pf1550_charger_irq_chip.name);
> > +
> > +	domain = regmap_irq_get_domain(pf1550->irq_data_charger);
> > +
> > +	return devm_mfd_add_devices(pf1550->dev, PLATFORM_DEVID_NONE, charger,
> > +				    1, NULL, 0, domain);
> > +}
> > +
> > +static int pf1550_suspend(struct device *dev)
> > +{
> > +	struct pf1550_ddata *pf1550 = dev_get_drvdata(dev);
> > +
> > +	if (device_may_wakeup(dev)) {
> > +		enable_irq_wake(pf1550->irq);
> > +		disable_irq(pf1550->irq);
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int pf1550_resume(struct device *dev)
> > +{
> > +	struct pf1550_ddata *pf1550 = dev_get_drvdata(dev);
> > +
> > +	if (device_may_wakeup(dev)) {
> > +		disable_irq_wake(pf1550->irq);
> > +		enable_irq(pf1550->irq);
> 
> Should this 2 lines be inverted?
> 
I don't think it matters. disable_irq_wake is 'completely orthogonal' to the
enable/disable(irq). See function irq_set_irq_wake.
> > +	}
> > +
> > +	return 0;
> > +}
> 
> ...
> 
> > +#define PF1550_CHG_LINEAR_ONLY		12
> > +#define PF1550_CHG_SNS_MASK		0xf
> > +#define PF1550_CHG_INT_MASK             0x51
> 
> Space vs tab
> 
Will make changes.
> > +
> > +#define PF1550_BAT_NO_VBUS		0
> > +#define PF1550_BAT_LOW_THAN_PRECHARG	1

Thanks,
Sam

  reply	other threads:[~2025-07-10 14:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-07 21:37 [PATCH v8 0/6] add support for pf1550 PMIC MFD-based drivers Samuel Kayode via B4 Relay
2025-07-07 21:37 ` [PATCH v8 1/6] dt-bindings: mfd: add pf1550 Samuel Kayode via B4 Relay
2025-07-07 21:37 ` [PATCH v8 2/6] mfd: pf1550: add core driver Samuel Kayode via B4 Relay
2025-07-08 18:46   ` Christophe JAILLET
2025-07-10 14:08     ` Samuel Kayode [this message]
2025-07-10 14:54   ` Sean Nyekjaer
2025-07-10 17:11     ` Samuel Kayode
2025-07-07 21:37 ` [PATCH v8 3/6] regulator: pf1550: add support for regulator Samuel Kayode via B4 Relay
2025-07-10 14:49   ` Sean Nyekjaer
2025-07-10 17:01     ` Samuel Kayode
2025-07-10 17:11       ` Sean Nyekjaer
2025-07-10 17:29         ` Samuel Kayode
2025-07-11 10:04   ` Sean Nyekjaer
2025-07-07 21:37 ` [PATCH v8 4/6] input: pf1550: add onkey support Samuel Kayode via B4 Relay
2025-07-11 10:29   ` Sean Nyekjaer
2025-07-07 21:37 ` [PATCH v8 5/6] power: supply: pf1550: add battery charger support Samuel Kayode via B4 Relay
2025-07-11  9:02   ` Sean Nyekjaer
2025-07-11 16:27     ` Samuel Kayode
2025-07-07 21:37 ` [PATCH v8 6/6] MAINTAINERS: add an entry for pf1550 mfd driver Samuel Kayode via B4 Relay
2025-07-10 17:06   ` Samuel Kayode

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=aG_JUhEQaiYQfJmz@fedora \
    --to=samuel.kayode@savoirfairelinux.com \
    --cc=Frank.li@nxp.com \
    --cc=abelvesa@kernel.org \
    --cc=abelvesa@linux.com \
    --cc=b38343@freescale.com \
    --cc=broonie@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+samuel.kayode.savoirfairelinux.com@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=eballetbo@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sre@kernel.org \
    --cc=yibin.gong@nxp.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;
as well as URLs for NNTP newsgroup(s).