[PATCH v2 2/2] pwm: Add a driver for Chrome OS EC PWM

Simon Glass sjg at chromium.org
Mon Sep 28 06:24:40 CEST 2020


On Sat, 26 Sep 2020 at 14:09, Alper Nebi Yasak <alpernebiyasak at gmail.com> wrote:
>
> This PWM is used in rk3399-gru-bob and rk3399-gru-kevin to control
> the display brightness. We can only change the duty cycle, so on
> set_config() we just try to match the duty cycle that dividing duty_ns
> by period_ns gives us. To disable, we set the duty cycle to zero while
> keeping the old value for when we want to re-enable it.
>
> The cros_ec_set_pwm_duty() function is taken from Depthcharge's
> cros_ec_set_bl_pwm_duty() but modified to use the generic pwm type.
> The driver itself is very loosely based on rk_pwm.c for the general pwm
> driver structure.
>
> The devicetree binding file is from Linux, before it was converted to
> YAML at 5df5a577a6b4 ("dt-bindings: pwm: Convert google,cros-ec-pwm.txt
> to YAML format") in their repo.
>
> Signed-off-by: Alper Nebi Yasak <alpernebiyasak at gmail.com>
> ---
> I'm testing on a rk3399-gru-kevin with a lot of other patches to get it
> (and it's screen) barely working, but using something like the following
> in a rk_board_late_init() added to gru.c gets the backlight to change:
>
>     struct *udevice panel;
>     uclass_first_device_err(UCLASS_PANEL, &panel);
>     panel_enable_backlight(panel);
>     panel_set_backlight(panel, 50);
>     panel_set_backlight(panel, 100);
>
> The actual tree I'm testing and how I'm getting it to chainload from the
> vendor firmware (see commit message there) is available here:
>
>     https://github.com/alpernebbi/u-boot/tree/rk3399-gru-kevin/wip
>     (currently at commit 4b5a8441303facb6e419da9f5e86980de3eb090a)
>
> Changes in v2:
> - Add device-tree-binding/pwm/cros-ec-pwm.txt adapted from Linux
> - Return ec_command() errors correctly in cros_ec_set_pwm_duty()
> - Add newlines before last returns in cros_ec_pwm.c
>
> v1: https://patchwork.ozlabs.org/project/uboot/patch/20200923165231.18188-2-alpernebiyasak@gmail.com/
>
>  doc/device-tree-bindings/pwm/cros-ec-pwm.txt | 23 ++++++
>  drivers/misc/cros_ec.c                       | 17 ++++
>  drivers/pwm/Kconfig                          |  9 +++
>  drivers/pwm/Makefile                         |  1 +
>  drivers/pwm/cros_ec_pwm.c                    | 84 ++++++++++++++++++++
>  include/cros_ec.h                            | 13 +++
>  6 files changed, 147 insertions(+)
>  create mode 100644 doc/device-tree-bindings/pwm/cros-ec-pwm.txt
>  create mode 100644 drivers/pwm/cros_ec_pwm.c

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list