aboutsummaryrefslogtreecommitdiff
path: root/test/dm
diff options
context:
space:
mode:
authorAlper Nebi Yasak2020-10-22 23:49:26 +0300
committerAnatolij Gustschin2021-04-10 16:07:12 +0200
commitfefa713b1843cf13d3132bfe0cf27710938c5d92 (patch)
tree4ae09212a60da99436d30eb24b3f9d041553cdbe /test/dm
parent9749d2ea29e1a535c9ea8f850db8b6abe6df7b15 (diff)
video: backlight: Support PWMs without a known period_ns
The PWM device provided by Chrome OS EC doesn't really support anything other than setting a relative duty cycle. To support it as a backlight, this patch makes the PWM period optional in the device tree and pretends the valid brightness range is its period_ns. Also adds a sandbox test for a PWM channel that has a fixed period, checking that the resulting duty_cycle matches on a set_config() even if the requested period_ns can't be set. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm')
-rw-r--r--test/dm/pwm.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/dm/pwm.c b/test/dm/pwm.c
index 0de6dba1ba6..b624cf3d655 100644
--- a/test/dm/pwm.c
+++ b/test/dm/pwm.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <dm.h>
#include <pwm.h>
+#include <asm/test.h>
#include <dm/test.h>
#include <test/test.h>
#include <test/ut.h>
@@ -14,6 +15,10 @@
static int dm_test_pwm_base(struct unit_test_state *uts)
{
struct udevice *dev;
+ uint period_ns;
+ uint duty_ns;
+ bool enable;
+ bool polarity;
ut_assertok(uclass_get_device(UCLASS_PWM, 0, &dev));
ut_assertnonnull(dev);
@@ -24,6 +29,12 @@ static int dm_test_pwm_base(struct unit_test_state *uts)
ut_asserteq(-ENOSPC, pwm_set_enable(dev, 3, true));
ut_assertok(pwm_set_invert(dev, 0, true));
+ ut_assertok(pwm_set_config(dev, 2, 100, 50));
+ ut_assertok(sandbox_pwm_get_config(dev, 2, &period_ns, &duty_ns,
+ &enable, &polarity));
+ ut_asserteq(period_ns, 4096);
+ ut_asserteq(duty_ns, 50 * 4096 / 100);
+
ut_assertok(uclass_get_device(UCLASS_PWM, 1, &dev));
ut_asserteq(-ENODEV, uclass_get_device(UCLASS_PWM, 2, &dev));