[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8dd1fe2d040db3e79ef94a5b2c70c51108e56c39.camel@pengutronix.de>
Date: Wed, 31 Jan 2024 14:41:41 +0100
From: Philipp Zabel <p.zabel@...gutronix.de>
To: Aleksandr Shubin <privatesub2@...il.com>, linux-kernel@...r.kernel.org
Cc: Brandon Cheo Fusi <fusibrandon13@...il.com>, Uwe
Kleine-König <u.kleine-koenig@...gutronix.de>, Rob
Herring <robh+dt@...nel.org>, Krzysztof Kozlowski
<krzysztof.kozlowski+dt@...aro.org>, Conor Dooley <conor+dt@...nel.org>,
Chen-Yu Tsai <wens@...e.org>, Jernej Skrabec <jernej.skrabec@...il.com>,
Samuel Holland <samuel@...lland.org>, Paul Walmsley
<paul.walmsley@...ive.com>, Palmer Dabbelt <palmer@...belt.com>, Albert Ou
<aou@...s.berkeley.edu>, Cristian Ciocaltea
<cristian.ciocaltea@...labora.com>, John Watts <contact@...kia.org>, Marc
Kleine-Budde <mkl@...gutronix.de>, Maksim Kiselev <bigunclemax@...il.com>,
linux-pwm@...r.kernel.org, devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
linux-riscv@...ts.infradead.org
Subject: Re: [PATCH v8 2/3] pwm: Add Allwinner's D1/T113-S3/R329 SoCs PWM
support
On Mi, 2024-01-31 at 15:59 +0300, Aleksandr Shubin wrote:
> Allwinner's D1, T113-S3 and R329 SoCs have a quite different PWM
> controllers with ones supported by pwm-sun4i driver.
>
> This patch adds a PWM controller driver for Allwinner's D1,
> T113-S3 and R329 SoCs. The main difference between these SoCs
> is the number of channels defined by the DT property.
>
> Co-developed-by: Brandon Cheo Fusi <fusibrandon13@...il.com>
> Signed-off-by: Brandon Cheo Fusi <fusibrandon13@...il.com>
> Signed-off-by: Aleksandr Shubin <privatesub2@...il.com>
> ---
> drivers/pwm/Kconfig | 10 ++
> drivers/pwm/Makefile | 1 +
> drivers/pwm/pwm-sun20i.c | 380 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 391 insertions(+)
> create mode 100644 drivers/pwm/pwm-sun20i.c
>
[...]
> diff --git a/drivers/pwm/pwm-sun20i.c b/drivers/pwm/pwm-sun20i.c
> new file mode 100644
> index 000000000000..19bf3f495155
> --- /dev/null
> +++ b/drivers/pwm/pwm-sun20i.c
> @@ -0,0 +1,380 @@
[...]
> +static int sun20i_pwm_probe(struct platform_device *pdev)
> +{
[...]
> + sun20i_chip->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
> + if (IS_ERR(sun20i_chip->rst))
> + return dev_err_probe(&pdev->dev, PTR_ERR(sun20i_chip->rst),
> + "failed to get bus reset\n");
> +
> + ret = of_property_read_u32(pdev->dev.of_node, "allwinner,pwm-channels",
> + &sun20i_chip->chip.npwm);
> + if (ret)
> + sun20i_chip->chip.npwm = 8;
> +
> + if (sun20i_chip->chip.npwm > 16)
> + sun20i_chip->chip.npwm = 16;
> +
> + /* Deassert reset */
> + ret = reset_control_deassert(sun20i_chip->rst);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret, "failed to deassert reset\n");
Consider using devm_add_action_or_reset() to automatically assert the
reset control again on error or driver unbind ...
> +
> + sun20i_chip->chip.dev = &pdev->dev;
> + sun20i_chip->chip.ops = &sun20i_pwm_ops;
> +
> + mutex_init(&sun20i_chip->mutex);
> +
> + ret = pwmchip_add(&sun20i_chip->chip);
.. and devm_pwmchip_add() here. Together, this would allow to drop
sun20i_pwm_remove().
regards
Philipp
Powered by blists - more mailing lists