aboutsummaryrefslogtreecommitdiff
path: root/arch/sandbox
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2021-05-19 19:33:31 +0300
committerSimon Glass <sjg@chromium.org>2021-07-06 10:38:03 -0600
commite712245d08d95fac6467fd0d05a12d6506aeda2d (patch)
treeaceedee89f30d6b0a9dc7bbdc25fbd65d647e4de /arch/sandbox
parent98c14ff019515ffcb1b40b550e56fe1dfbede51b (diff)
downloadu-boot-e712245d08d95fac6467fd0d05a12d6506aeda2d.zip
u-boot-e712245d08d95fac6467fd0d05a12d6506aeda2d.tar.gz
u-boot-e712245d08d95fac6467fd0d05a12d6506aeda2d.tar.bz2
sandbox: cros-ec: Add tests for the Chromium OS EC PWM driver
This patch adds a limited pulse-width modulator to sandbox's Chromium OS Embedded Controller emulation. The emulated PWM device supports multiple channels but can only set a duty cycle for each, as the actual EC doesn't expose any functionality or information other than that. Though the EC supports specifying the PWM channel by its type (e.g. display backlight, keyboard backlight), this is not implemented in the emulation as nothing in U-Boot uses this type specification. This emulated PWM device is then used to test the Chromium OS PWM driver in sandbox. Adding the required device node to the sandbox test device-tree unfortunately makes it the first PWM device, so this also touches some other tests to make sure they still use the sandbox PWM. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/dts/test.dts6
-rw-r--r--arch/sandbox/include/asm/test.h10
2 files changed, 16 insertions, 0 deletions
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 8e7eaf2..d85bb46 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -139,6 +139,12 @@
size = <0x10000>;
};
};
+
+ cros_ec_pwm: cros-ec-pwm {
+ compatible = "google,cros-ec-pwm";
+ #pwm-cells = <1>;
+ };
+
};
dsi_host: dsi_host {
diff --git a/arch/sandbox/include/asm/test.h b/arch/sandbox/include/asm/test.h
index 1cb960a..dab1a4e 100644
--- a/arch/sandbox/include/asm/test.h
+++ b/arch/sandbox/include/asm/test.h
@@ -275,4 +275,14 @@ void sandbox_set_enable_memio(bool enable);
*/
void sandbox_cros_ec_set_test_flags(struct udevice *dev, uint flags);
+/**
+ * sandbox_cros_ec_get_pwm_duty() - Get EC PWM config for testing purposes
+ *
+ * @dev: Device to check
+ * @index: PWM channel index
+ * @duty: Current duty cycle in 0..EC_PWM_MAX_DUTY range.
+ * @return 0 if OK, -ENOSPC if the PWM number is invalid
+ */
+int sandbox_cros_ec_get_pwm_duty(struct udevice *dev, uint index, uint *duty);
+
#endif