[openwrt/openwrt] ramips: 6.1: pwm: rewrite mtk_pwm_ops to fix pwm driver

LEDE Commits lede-commits at lists.infradead.org
Sat Feb 10 04:09:16 PST 2024


nick pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/eeeb0b53494ec08da8b5c746890158834b5ff263

commit eeeb0b53494ec08da8b5c746890158834b5ff263
Author: Nick Hainke <vincent at systemli.org>
AuthorDate: Thu Feb 8 15:08:18 2024 +0100

    ramips: 6.1: pwm: rewrite mtk_pwm_ops to fix pwm driver
    
    Upstream dropped support for legacy driver [0]. Rewrite the driver like
    the renesas pwm driver [1].
    
    Fixes erros in the form of:
       make: *** [/__w/openwrt/openwrt/openwrt/include/toplevel.mk:232: target/compile] Error 1
      ====== Make errors from logs/target/linux/compile.txt ======
            |                   ^~~~~~~~~~~~~~
      drivers/pwm/pwm-mediatek-ramips.c:107:19: note: (near initialization for 'mtk_pwm_ops.free')
      drivers/pwm/pwm-mediatek-ramips.c:108:10: error: 'const struct pwm_ops' has no member named 'disable'
        108 |         .disable = mtk_pwm_disable,
            |          ^~~~~~~
      drivers/pwm/pwm-mediatek-ramips.c:108:20: error: initialization of 'int (*)(struct pwm_chip *, struct pwm_device *, struct pwm_capture *, long unsigned int)' from incompatible pointer type 'void (*)(struct pwm_chip *, struct pwm_device *)' [-Werror=incompatible-pointer-types]
        108 |         .disable = mtk_pwm_disable,
            |                    ^~~~~~~~~~~~~~~
      drivers/pwm/pwm-mediatek-ramips.c:108:20: note: (near initialization for 'mtk_pwm_ops.capture')
      cc1: all warnings being treated as errors
    
    [0] - https://github.com/torvalds/linux/commit/0829c35dc5346e90f428de61896362b51ab58296
    [1] - https://github.com/torvalds/linux/commit/ec00cd5e63f05461ab48128775c73c851c3c2b18
    
    Signed-off-by: Nick Hainke <vincent at systemli.org>
---
 .../patches-6.1/845-pwm-add-mediatek-support.patch | 30 +++++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/target/linux/ramips/patches-6.1/845-pwm-add-mediatek-support.patch b/target/linux/ramips/patches-6.1/845-pwm-add-mediatek-support.patch
index 06074d6031..15c7cf39a2 100644
--- a/target/linux/ramips/patches-6.1/845-pwm-add-mediatek-support.patch
+++ b/target/linux/ramips/patches-6.1/845-pwm-add-mediatek-support.patch
@@ -41,7 +41,7 @@ Signed-off-by: John Crispin <blogic at openwrt.org>
  obj-$(CONFIG_PWM_NTXEC)		+= pwm-ntxec.o
 --- /dev/null
 +++ b/drivers/pwm/pwm-mediatek-ramips.c
-@@ -0,0 +1,175 @@
+@@ -0,0 +1,197 @@
 +/*
 + * Mediatek Pulse Width Modulator driver
 + *
@@ -146,10 +146,32 @@ Signed-off-by: John Crispin <blogic at openwrt.org>
 +	iowrite32(val, pc->mmio_base);
 +}
 +
++static int mtk_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
++			 const struct pwm_state *state)
++{
++	int err;
++	bool enabled = pwm->state.enabled;
++
++	if (!state->enabled) {
++		if (enabled)
++			mtk_pwm_disable(chip, pwm);
++
++		return 0;
++	}
++
++	err = mtk_pwm_config(pwm->chip, pwm,
++			     state->duty_cycle, state->period);
++	if (err)
++		return err;
++
++	if (!enabled)
++		err = mtk_pwm_enable(chip, pwm);
++
++	return err;
++}
++
 +static const struct pwm_ops mtk_pwm_ops = {
-+	.config = mtk_pwm_config,
-+	.enable = mtk_pwm_enable,
-+	.disable = mtk_pwm_disable,
++	.apply = mtk_pwm_apply,
 +	.owner = THIS_MODULE,
 +};
 +




More information about the lede-commits mailing list