Skip to contentSkip to conversation

exynos: pwm: Deal with a PWM at 100%

PATCH In review Simon Glass 2 participants 2 messages Nov 3, 2021 – Nov 9, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exynos: pwm: Deal with a PWM at 100%

At present the counter never hits the comparitor in this case. Add a special case.

This ensures that the snow backlight works when at full brightness.

Fixes 76c2ff3e5fd video: backlight: fix pwm's duty cycle calculation

---

 drivers/pwm/exynos_pwm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pwm/exynos_pwm.c +4 -0
index 1afaf784dab..609025d680d 100644
@@ -43,6 +43,10 @@ static int exynos_pwm_set_config(struct udevice *dev, uint channel,
 		tcnt = period_ns / rate_ns;
 		tcmp = duty_ns / rate_ns;
 		debug("%s: tcnt %u, tcmp %u\n", __func__, tcnt, tcmp);
+
+		/* Ensure that the comparitor will actually hit the target */
+		if (tcmp == tcnt)
+			tcmp = tcnt - 1;
 		offset = channel * 3;
 		writel(tcnt, &regs->tcntb0 + offset);
 		writel(tcmp, &regs->tcmpb0 + offset);
Signature · 1 line
2.34.0.rc0.344.g81b53c2807-goog
#1 lore raw

Dear Simon Glass,

2021년 11월 4일 (목) 04:21, Simon Glass <[email protected]>님이 작성:

Quoted 30 lines

At present the counter never hits the comparitor in this case. Add a special case.

This ensures that the snow backlight works when at full brightness.

Fixes 76c2ff3e5fd video: backlight: fix pwm's duty cycle calculation

---

 drivers/pwm/exynos_pwm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/pwm/exynos_pwm.c +4 -0
index 1afaf784dab..609025d680d 100644
@@ -43,6 +43,10 @@ static int exynos_pwm_set_config(struct udevice *dev,
 uint channel,
                tcnt = period_ns / rate_ns;
                tcmp = duty_ns / rate_ns;
                debug("%s: tcnt %u, tcmp %u\n", __func__, tcnt, tcmp);
+
+               /* Ensure that the comparitor will actually hit the target
 */
+               if (tcmp == tcnt)
+                       tcmp = tcnt - 1;
                offset = channel * 3;
                writel(tcnt, &regs->tcntb0 + offset);
                writel(tcmp, &regs->tcmpb0 + offset);
Quoted 5 lines

--
2.34.0.rc0.344.g81b53c2807-goog

applied to u-boot-samsung.

Thanks.

Signature · 1 line
Thanks. Minkyu Kang.