mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Michael Grzeschik <m.grzeschik@pengutronix.de>,
	barebox@lists.infradead.org
Subject: Re: [PATCH v2] PWM: imx: pwm-imx-tpm: Add driver support
Date: Tue, 28 Jan 2025 16:27:32 +0100	[thread overview]
Message-ID: <99fd4b6d-2350-4616-8fe5-1afbb490afd9@pengutronix.de> (raw)
In-Reply-To: <20250128151444.1141018-1-m.grzeschik@pengutronix.de>

Hello Michael,

On 28.01.25 16:14, Michael Grzeschik wrote:
> +	for (i = 0; i < npwm; i++) {
> +		struct imx_tpm_pwm_chip *tpmc = &tpm->pwm[i];
> +
> +		chip = &tpmc->chip;
> +
> +		tpmc->tpm = tpm;
> +		tpmc->tpm->base = base;
> +		tpmc->tpm->clk = clk;
> +
> +		chip->ops = &imx_tpm_pwm_ops;
> +		chip->devname = xasprintf("pwm%d", i);

You're not registering different PWM controllers here, but channels
of the same PWM controller. If another PWM controller is enabled
and probed, it will try to claim pwm0 again for itself and the
later probe would fail.

Until we have PWM channel support in the core, you will need to
take care of this here yourself by using e.g. pwmXchY as name.
See drivers/pwm/pwm-stm32.c for an example. You'll likely want
to drop the + 1 there though, because TPM channels start counting
from zero (as seen in imx93-pinfunc.h)

Thanks,
Ahmad

> +		chip->id = i;
> +		chip->dev = dev;
> +
> +		ret = pwmchip_add(chip);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "failed to add PWM chip\n");
> +	}
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id imx_tpm_pwm_dt_ids[] = {
> +	{ .compatible = "fsl,imx7ulp-pwm", },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, imx_tpm_pwm_dt_ids);
> +
> +static struct driver imx_tpm_pwm_driver = {
> +	.name = "imx7ulp-tpm-pwm",
> +	.probe	= pwm_imx_tpm_probe,
> +	.of_compatible = imx_tpm_pwm_dt_ids,
> +};
> +coredevice_platform_driver(imx_tpm_pwm_driver);
> +
> +MODULE_AUTHOR("Anson Huang <Anson.Huang@nxp.com>");
> +MODULE_DESCRIPTION("i.MX TPM PWM Driver");
> +MODULE_LICENSE("GPL v2");


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2025-01-28 15:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-28 15:14 Michael Grzeschik
2025-01-28 15:27 ` Ahmad Fatoum [this message]

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=99fd4b6d-2350-4616-8fe5-1afbb490afd9@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.grzeschik@pengutronix.de \
    /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