Re: [PATCH v6 2/2] pwm: Add Nuvoton MA35D1 PWM controller support

From: Uwe Kleine-König

Date: Fri Nov 20 2026 - 10:45:20 EST


Hello,

just some nitpicking left ...

On Mon, Sep 14, 2026 at 07:07:39PM +0800, Chi-Wen Weng wrote:
> +#include <linux/bits.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/errno.h>
> +#include <linux/io.h>
> +#include <linux/math64.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/pwm.h>
> +
> +#define MA35D1_REG_PWM_CTL0 0x00

The manual calls this EPWM_CTL0, so I suggest to name this:

MA35D1_REG_EPWM_CTL0

> +#define MA35D1_REG_PWM_CTL1 0x04
> +#define MA35D1_REG_PWM_CLKPSC(ch) (0x14 + 4 * ((ch) / 2))
> +#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_CTL0_CTRLD(ch) BIT(ch)

I like it if the register this bit field is defined for is a proper
prefix of the name, so please rename to MA35D1_REG_EPWM_CTL0_CTRLD().

> +#define MA35D1_PWM_CTL0_WINLDEN(ch) BIT(8 + (ch))
> +#define MA35D1_PWM_CTL0_IMMLDEN(ch) BIT(16 + (ch))
> +
> +#define MA35D1_PWM_CTL1_CNTTYPE_MASK(ch) (0x3 << (2 * (ch)))

The reference manual calls this CNTTYPEx, so please rename to

MA35D1_EPWM_CTL1_CNTTYPE(ch)

> [...]
> +static int nuvoton_pwm_config_channel(struct nuvoton_pwm *nvtpwm,
> + unsigned int ch)
> +{
> [...]
> + nuvoton_pwm_rmw(nvtpwm, MA35D1_REG_PWM_CTL0, ctl0_mask, 0);
> + nuvoton_pwm_rmw(nvtpwm, MA35D1_REG_PWM_CTL1, ctl1_mask, 0);
> + nuvoton_pwm_rmw(nvtpwm, MA35D1_REG_PWM_WGCTL0,
> + wgctl0_mask, wgctl0_val);
> + nuvoton_pwm_rmw(nvtpwm, MA35D1_REG_PWM_WGCTL1,
> + wgctl1_mask, wgctl1_val);

I think these lines are short enough to not break them.

> + return 0;
> +}

Best regards
Uwe

Attachment: signature.asc
Description: PGP signature