From: Xianwei Zhao <xianwei.zhao@amlogic.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: "Uwe Kleine-König" <ukleinek@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Kevin Hilman" <khilman@baylibre.com>,
"Jerome Brunet" <jbrunet@baylibre.com>,
linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org
Subject: Re: [PATCH 2/2] pwm: meson: Add support for Amlogic S7
Date: Tue, 31 Mar 2026 10:48:34 +0800 [thread overview]
Message-ID: <59b5c878-dad8-4ce3-9864-f4706c993d4d@amlogic.com> (raw)
In-Reply-To: <CAFBinCD-4dwp7pmM_GHK_N1kag_5VBZbP9VAwQOxcyg6aquj3w@mail.gmail.com>
Hi Martin,
Thanks for your review.
On 2026/3/31 05:44, Martin Blumenstingl wrote:
> Hi Xianwei Zhao,
>
> On Thu, Mar 26, 2026 at 7:35 AM Xianwei Zhao via B4 Relay
> <devnull+xianwei.zhao.amlogic.com@kernel.org> wrote:
>> From: Xianwei Zhao<xianwei.zhao@amlogic.com>
>>
>> Add support for Amlogic S7 PWM. Amlogic S7 different from the
>> previous SoCs, a controller includes one pwm, at the same time,
>> the controller has only one input clock source.
>>
>> Signed-off-by: Xianwei Zhao<xianwei.zhao@amlogic.com>
>> ---
>> drivers/pwm/pwm-meson.c | 32 ++++++++++++++++++++++++++++++--
>> 1 file changed, 30 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
>> index 8c6bf3d49753..3d16694e254e 100644
>> --- a/drivers/pwm/pwm-meson.c
>> +++ b/drivers/pwm/pwm-meson.c
>> @@ -113,6 +113,7 @@ struct meson_pwm_data {
>> int (*channels_init)(struct pwm_chip *chip);
>> bool has_constant;
>> bool has_polarity;
>> + bool single_pwm;
> At first I wasn't sure about this and thought we should replace it
> with a num_pwms (or similar) variable.
> However, I think it will be hard to add a third (or even more)
> channels to the PWM controller (not just from driver perspective but
> also from hardware perspective). So I think this is good enough as the
> choice will only be 1 or 2.
> > [...]
This is not a third channel added here.
Compared with the previous controller having two channels, here the
control has only one channel. It's equivalent to the first channel
before, while the second channel is reserved.
>> +static const struct meson_pwm_data pwm_s7_data = {
>> + .channels_init = meson_pwm_init_channels_s7,
> I think you can use .channels_init = meson_pwm_init_channels_s4, if
> you change the code inside that function from:
> for (i = 0; i < MESON_NUM_PWMS; i++) {
> to:
> for (i = 0; i < chip->npwm; i++) {
>
> [...]
The method you suggested was exactly what I did in the first version,
but after my subsequent optimization, it's what you see now.
Since initialization only involves obtaining the clock, I modify the
code less in this way and the logic is also simpler.
>> @@ -650,9 +674,13 @@ static int meson_pwm_probe(struct platform_device *pdev)
>> {
>> struct pwm_chip *chip;
>> struct meson_pwm *meson;
>> + const struct meson_pwm_data *pdata = of_device_get_match_data(&pdev->dev);
>> int err;
>>
>> - chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson));
>> + if (pdata->single_pwm)
>> + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*meson));
>> + else
>> + chip = devm_pwmchip_alloc(&pdev->dev, MESON_NUM_PWMS, sizeof(*meson));
> I don't think this code is too bad for now.
> However, I'm wondering if you want to make "channels" from struct
> meson_pwm a flexible array member in a future patch. In that case it
> will be helpful to have an "unsigned int npwm = pdata->single_pwm ? 1
> : MESON_NUM_PWMS;" (or similar) variable to future-proof your code.
> What do you think?
I considered this, but chose the current implementation. I will switch
to your suggestion in the next version.
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-03-31 2:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 6:35 [PATCH 0/2] Add PWM support Amlogic S7 S7D S6 Xianwei Zhao via B4 Relay
2026-03-26 6:35 ` [PATCH 1/2] dt-bindings: pwm: amlogic: Add new bindings for S6 S7 S7D Xianwei Zhao via B4 Relay
2026-03-27 8:25 ` Krzysztof Kozlowski
2026-03-30 21:58 ` Martin Blumenstingl
2026-03-26 6:35 ` [PATCH 2/2] pwm: meson: Add support for Amlogic S7 Xianwei Zhao via B4 Relay
2026-03-30 21:44 ` Martin Blumenstingl
2026-03-31 2:48 ` Xianwei Zhao [this message]
2026-03-30 21:54 ` [PATCH 0/2] Add PWM support Amlogic S7 S7D S6 Martin Blumenstingl
2026-03-31 7:10 ` Xianwei Zhao
2026-03-31 7:33 ` [DMARC error]Re: " George Stark
2026-03-31 7:59 ` Xianwei Zhao
2026-04-02 11:46 ` George Stark
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=59b5c878-dad8-4ce3-9864-f4706c993d4d@amlogic.com \
--to=xianwei.zhao@amlogic.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hkallweit1@gmail.com \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=robh@kernel.org \
--cc=ukleinek@kernel.org \
/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
all inboxes | Powered by JetHome®