From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Chi-Wen Weng <cwweng.linux@gmail.com>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
linux-arm-kernel@lists.infradead.org, linux-pwm@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
cwweng@nuvoton.com, Trevor Gamblin <tgamblin@baylibre.com>
Subject: Re: [PATCH v4 2/2] pwm: Add Nuvoton MA35D1 PWM controller support
Date: Thu, 16 Jul 2026 17:29:37 +0200 [thread overview]
Message-ID: <alj1UapHAq9f_MiF@monoceros> (raw)
In-Reply-To: <20260617025925.2539334-3-cwweng.linux@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2450 bytes --]
Hello,
On Wed, Jun 17, 2026 at 10:59:25AM +0800, Chi-Wen Weng wrote:
> +#include <linux/bits.h>
> +#include <linux/clk.h>
> +#include <linux/io.h>
> +#include <linux/math64.h>
> +#include <linux/mod_devicetable.h>
Please don't include that file, <linux/platform_device.h> should pull in
the things you need from that file.
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/pwm.h>
> +
> +#define MA35D1_REG_PWM_CTL0 0x00
> +#define MA35D1_REG_PWM_CTL1 0x04
> +#define MA35D1_REG_PWM_CNTEN 0x20
> +#define MA35D1_REG_PWM_PERIOD(ch) (0x30 + 4 * (ch))
> +#define MA35D1_REG_PWM_CMPDAT(ch) (0x50 + 4 * (ch))
> +#define MA35D1_REG_PWM_WGCTL0 0xb0
> +#define MA35D1_REG_PWM_WGCTL1 0xb4
> +#define MA35D1_REG_PWM_POLCTL 0xd4
> +#define MA35D1_REG_PWM_POEN 0xd8
> +
> +#define MA35D1_PWM_CTL1_CNTMODE_MASK(ch) BIT(16 + (ch))
> +#define MA35D1_PWM_CTL1_OUTMODE_MASK(ch) BIT(24 + ((ch) / 2))
> +
> +#define MA35D1_PWM_WGCTL_ACTION_MASK 0x3
> +#define MA35D1_PWM_WGCTL_ACTION_LOW 1
> +#define MA35D1_PWM_WGCTL_ACTION_HIGH 2
If you make this:
#define MA35D1_PWM_WGCTL_ACTION(ch) GENMASK(2 * (ch) + 2, 2 * (ch))
#define MA35D1_PWM_WGCTL_ACTION_LOW 1
#define MA35D1_PWM_WGCTL_ACTION_HIGH 2
you can drop the static inlines below.
> +
> +#define MA35D1_PWM_WGCTL_ZERO_HIGH(ch) \
> + (MA35D1_PWM_WGCTL_ACTION_HIGH << (2 * (ch)))
> +#define MA35D1_PWM_WGCTL_CMP_UP_LOW(ch) \
> + (MA35D1_PWM_WGCTL_ACTION_LOW << (2 * (ch)))
> +
> +#define MA35D1_PWM_CNTEN_EN(ch) BIT(ch)
> +#define MA35D1_PWM_POEN_EN(ch) BIT(ch)
> +#define MA35D1_PWM_POLCTL_INV(ch) BIT(ch)
> +
> +#define MA35D1_PWM_MAX_CMPDAT 0xffff
> +#define MA35D1_PWM_MAX_PERIOD 0xfffe
> +#define MA35D1_PWM_MAX_PERIOD_CYCLES (MA35D1_PWM_MAX_PERIOD + 1)
This is irritating with similar names and different values/semantic.
> +#define MA35D1_PWM_NUM_CHANNELS 6
> +
> [...]
> +static int nuvoton_pwm_probe(struct platform_device *pdev)
> +{
> [...]
> + nuvoton_pwm_init(nvtpwm);
This clobbers what the hardware is doing. The idea here is to not modify
the hardware settings at probe time to keep e.g. a backlight configured
as it was setup by the bootloader and only modify on explicit calls to
.apply().
> +
> + chip->ops = &nuvoton_pwm_ops;
> + chip->atomic = true;
> +
> + ret = devm_pwmchip_add(dev, chip);
> + if (ret)
> + return dev_err_probe(dev, ret, "Unable to add PWM chip\n");
> +
> + return 0;
> +}
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2026-07-16 15:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-17 2:59 [PATCH v4 0/2] pwm: Add Nuvoton MA35D1 PWM controller support Chi-Wen Weng
2026-06-17 2:59 ` [PATCH v4 1/2] dt-bindings: pwm: Add Nuvoton MA35D1 PWM controller Chi-Wen Weng
2026-06-17 2:59 ` [PATCH v4 2/2] pwm: Add Nuvoton MA35D1 PWM controller support Chi-Wen Weng
2026-06-17 3:09 ` sashiko-bot
2026-07-16 15:29 ` Uwe Kleine-König [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=alj1UapHAq9f_MiF@monoceros \
--to=ukleinek@kernel.org \
--cc=conor+dt@kernel.org \
--cc=cwweng.linux@gmail.com \
--cc=cwweng@nuvoton.com \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=robh@kernel.org \
--cc=tgamblin@baylibre.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.