From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, linux-pwm@vger.kernel.org,
DRI mailing list <dri-devel@lists.freedesktop.org>,
lee@kernel.org, danielt@kernel.org, jingoohan1@gmail.com,
Richard Weinberger <richard.weinberger@gmail.com>
Subject: Re: PWM implementation in HWMON and backlight
Date: Wed, 11 Feb 2026 11:46:11 +0100 [thread overview]
Message-ID: <aYxaXmguGRk1pWpT@monoceros> (raw)
In-Reply-To: <CAFLxGvyhdpQMnW6VqyXjLPKyZSQvrV-+GFdUogV4JX7DiGePyg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2031 bytes --]
Hello Guenter,
On Wed, Feb 11, 2026 at 10:28:55AM +0100, Richard Weinberger wrote:
> The backlight of a board I am working with is controlled via PWM.
> Naturally, I thought this would be a straightforward task using the
> pwm-backlight driver.
>
> However, the PWM in question is implemented using an NCT6106D chip.
> The associated HWMON driver, nct6775-core.c, does not implement a
> standard PWM device interface but rather its own custom one.
Looking around in drivers/hwmon made me a sad. There are four drivers
that handle parsing #pwm-cells:
$ git grep pwm-cell drivers/hwmon/
drivers/hwmon/adt7475.c: ret = fwnode_property_get_reference_args(fwnode, "pwms", "#pwm-cells", 0, 0, &rargs);
drivers/hwmon/amc6821.c: if (of_parse_phandle_with_args(fan_np, "pwms", "#pwm-cells", 0, &args))
drivers/hwmon/emc2305.c: ret = of_parse_phandle_with_args(child, "pwms", "#pwm-cells", 0, &args);
drivers/hwmon/nct7363.c: ret = of_parse_phandle_with_args(child, "pwms", "#pwm-cells",
instead of using the pwm subsystem. Also the driver mentioned by Richard
above has some self-made PWM handling including a set of driver specific
sysfs files to control the PWMs. I stopped looking at the output of
git grep pwm drivers/hwmon/
after finding some more sad things. (My "favourite" so far was:
dev_dbg(dev, "chmod -w pwm%d failed\n", nr + 1);
.)
> I am a bit puzzled, is there a specific reason why HWMON does not
> utilize the standard PWM framework in this case?
Yes please!
I think that the PWM waveform API that exists since v6.13-rc1 is
flexible enough that hwmon chips should be able to both implement and
use it properly.
Can you please make sure that the next hardware driver for a pwm capable
chip uses a proper PWM chip? Feel free to send patch authors in my
direction for that.
And if I'm wrong and using the pwm subsystem in these cases is a burden,
I want to hear about that and discuss how this can be made better.
Thanks
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-02-11 10:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 9:28 PWM implementation in HWMON and backlight Richard Weinberger
2026-02-11 10:46 ` Uwe Kleine-König [this message]
2026-02-11 15:47 ` Guenter Roeck
2026-02-11 17:10 ` 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=aYxaXmguGRk1pWpT@monoceros \
--to=ukleinek@kernel.org \
--cc=danielt@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=lee@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=richard.weinberger@gmail.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