Closed pyavitz closed 1 year ago
Apparently something like this could fix it (I'll test and report separately):
diff --git a/drivers/pwm/pwm-gpio.c b/drivers/pwm/pwm-gpio.c
index 6707a5dbe..b82a94430 100644
--- a/drivers/pwm/pwm-gpio.c
+++ b/drivers/pwm/pwm-gpio.c
@@ -134,11 +134,43 @@ static void gpio_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
gpio_pwm_off(gpio_data);
}
+static int gpio_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+ const struct pwm_state *state)
+{
+ int err;
+ bool enabled = pwm->state.enabled;
+
+ if (state->polarity != pwm->state.polarity) {
+ if (enabled) {
+ gpio_pwm_disable(chip, pwm);
+ enabled = false;
+ }
+
+ err = gpio_pwm_set_polarity(chip, pwm, state->polarity);
+ if (err)
+ return err;
+ }
+
+ if (!state->enabled) {
+ if (enabled)
+ gpio_pwm_disable(chip, pwm);
+
+ return 0;
+ }
+
+ err = gpio_pwm_config(pwm->chip, pwm,
+ state->duty_cycle, state->period);
+ if (err)
+ return err;
+
+ if (!enabled)
+ err = gpio_pwm_enable(chip, pwm);
+
+ return err;
+}
+
static const struct pwm_ops gpio_pwm_ops = {
- .config = gpio_pwm_config,
- .set_polarity = gpio_pwm_set_polarity,
- .enable = gpio_pwm_enable,
- .disable = gpio_pwm_disable,
+ .apply = gpio_pwm_apply,
.owner = THIS_MODULE,
};
See also 0829c35dc5346e90f428de61896362b51ab58296 and ec00cd5e63f05461ab48128775c73c851c3c2b18
Welp, at least it builds.
Good job. I can verify not only does it build but it also works.
odroidn2plus: ~ $ dmesg | grep "Linux version"
[ 0.000000] Linux version 6.0.5 (marvin@martian) (gcc-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #1 SMP PREEMPT Wed Oct 26 12:43:52 EDT 2022
hitting the following