From: Thomas Bonnefille <thomas.bonnefille@bootlin.com>
To: jszhang@kernel.org
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org,
guoren@kernel.org, krzysztof.kozlowski+dt@linaro.org,
linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org,
linux-riscv@lists.infradead.org, robh+dt@kernel.org,
thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de,
wefu@redhat.com, Miquel Raynal <miquel.raynal@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v3 2/2] pwm: add T-HEAD PWM driver
Date: Mon, 15 Apr 2024 13:48:48 +0200 [thread overview]
Message-ID: <9f8a584c-03a7-437e-96a7-56484523b2e4@bootlin.com> (raw)
In-Reply-To: <20231005130519.3864-3-jszhang@kernel.org>
> T-HEAD SoCs such as the TH1520 contain a PWM controller used
> to control the LCD backlight, fan and so on. Add driver for it.
>
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org > ---
Hello,
I've just tested your driver and it works flawlessly on the
BeagleV-Ahead with the last mainline kernel. However, I had to modify
some portion of the code to comply with the last kernel needs.
> +static const struct pwm_ops thead_pwm_ops = {
> + .apply = thead_pwm_apply,
> + .get_state = thead_pwm_get_state,
> + .owner = THIS_MODULE,
Since commit 384461abcab6, the owner of a pwm_ops structure is implicit
and so, you can (must) remove this last line now.
> +};
> ...
> +static int thead_pwm_probe(struct platform_device *pdev)
> +{
> + struct thead_pwm_chip *priv;
> + int ret, i;
> + u32 val;
> +
> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, priv);
> +
> + priv->mmio_base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(priv->mmio_base))
> + return PTR_ERR(priv->mmio_base);
> +
> + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> + if (IS_ERR(priv->clk))
> + return PTR_ERR(priv->clk);
> +
> + priv->chip.ops = &thead_pwm_ops;
> + priv->chip.dev = &pdev->dev;
> + priv->chip.npwm = THEAD_PWM_MAX_NUM;
> +
> + /* check whether PWM is ever started or not */
> + for (i = 0; i < priv->chip.npwm; i++) {
> + val = readl(priv->mmio_base + THEAD_PWM_FP(i));
> + if (val)
> + priv->channel_ever_started |= 1 << i;
BIT(i) ?
If the bootloader starts a PWM channel for some reason, it will not be
referenced by the PM usage counter, I added this line in the if
statement to counter this problem :
pm_runtime_get(&pdev->dev);
> + }
> +
> + ret = devm_pwmchip_add(&pdev->dev, &priv->chip);
> + if (ret)
> + return ret;
> +
> + devm_pm_runtime_enable(&pdev->dev);
> +
> + return 0;
> +}
Thank you for your work. With the above comments addressed:
Tested-by: Thomas Bonnefille <thomas.bonnefille@bootlin.com>
Do you plan to send out a new iteration of this patch soon ?
Best regards,
Thomas Bonnefille
next prev parent reply other threads:[~2024-04-15 11:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 13:05 [PATCH v3 0/2] pwm: add driver for T-THEAD TH1520 SoC Jisheng Zhang
2023-10-05 13:05 ` [PATCH v3 1/2] dt-bindings: pwm: Add T-HEAD PWM controller Jisheng Zhang
2023-11-13 21:37 ` Uwe Kleine-König
2023-10-05 13:05 ` [PATCH v3 2/2] pwm: add T-HEAD PWM driver Jisheng Zhang
2023-11-13 21:56 ` Uwe Kleine-König
2024-04-15 11:48 ` Thomas Bonnefille [this message]
2023-11-06 14:49 ` [PATCH v3 0/2] pwm: add driver for T-THEAD TH1520 SoC Jisheng Zhang
2023-11-06 15:43 ` Uwe Kleine-König
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=9f8a584c-03a7-437e-96a7-56484523b2e4@bootlin.com \
--to=thomas.bonnefille@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=guoren@kernel.org \
--cc=jszhang@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=robh+dt@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wefu@redhat.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 read-only IMAP folder(s) and NNTP newsgroup(s).