From ee297a31b539bbe82b3fb76bd4daed2010d9be93 Mon Sep 17 00:00:00 2001 From: cyril279 Date: Wed, 8 Nov 2023 12:30:21 -0700 Subject: [PATCH] rev1350: Add backlight support --- .../boards/shields/rev1350/Kconfig.defconfig | 12 +++++++- config/boards/shields/rev1350/rev1350.conf | 5 ++++ config/boards/shields/rev1350/rev1350.keymap | 4 +-- config/boards/shields/rev1350/rev1350.overlay | 30 +++++++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 config/boards/shields/rev1350/rev1350.conf diff --git a/config/boards/shields/rev1350/Kconfig.defconfig b/config/boards/shields/rev1350/Kconfig.defconfig index fc50219..db224ef 100644 --- a/config/boards/shields/rev1350/Kconfig.defconfig +++ b/config/boards/shields/rev1350/Kconfig.defconfig @@ -6,4 +6,14 @@ if SHIELD_REV1350 config ZMK_KEYBOARD_NAME default "rev1350" -endif +endif # SHIELD_REV1350 + +if ZMK_BACKLIGHT + +config PWM + default y + +config LED_PWM + default y + +endif # ZMK_BACKLIGHT diff --git a/config/boards/shields/rev1350/rev1350.conf b/config/boards/shields/rev1350/rev1350.conf new file mode 100644 index 0000000..e4467f5 --- /dev/null +++ b/config/boards/shields/rev1350/rev1350.conf @@ -0,0 +1,5 @@ +CONFIG_ZMK_BACKLIGHT=y +CONFIG_ZMK_BACKLIGHT_ON_START=y +CONFIG_ZMK_BACKLIGHT_BRT_START=11 +CONFIG_ZMK_BACKLIGHT_BRT_STEP=5 +CONFIG_ZMK_BACKLIGHT_AUTO_OFF_IDLE=y diff --git a/config/boards/shields/rev1350/rev1350.keymap b/config/boards/shields/rev1350/rev1350.keymap index eaa90e9..e24bbc5 100644 --- a/config/boards/shields/rev1350/rev1350.keymap +++ b/config/boards/shields/rev1350/rev1350.keymap @@ -5,9 +5,9 @@ */ #include -#include +#include #include -#include +#include #define DEFAULT 0 #define LOWER 1 diff --git a/config/boards/shields/rev1350/rev1350.overlay b/config/boards/shields/rev1350/rev1350.overlay index 3ecd43a..3415b2d 100644 --- a/config/boards/shields/rev1350/rev1350.overlay +++ b/config/boards/shields/rev1350/rev1350.overlay @@ -10,6 +10,13 @@ chosen { zmk,kscan = &kscan0; zmk,matrix_transform = &default_transform; + zmk,backlight = &backlight; + }; + backlight: pwmleds { + compatible = "pwm-leds"; + pwm_led_0 { + pwms = <&pwm0 0 PWM_MSEC(10) PWM_POLARITY_NORMAL>; + }; }; default_transform: keymap_transform_0 { @@ -50,3 +57,26 @@ RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(5,0) RC(5,1) RC(5,2) RC(5,3) ; }; }; + + +&pinctrl { + // Other pinctrl definitions for other hardware + pwm0_default: pwm0_default { + group1 { + psels = ; + }; + }; + pwm0_sleep: pwm0_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_default>; + pinctrl-1 = <&pwm0_sleep>; + pinctrl-names = "default", "sleep"; +};