bcm27xx: sync 5.4 patches with RPi Foundation
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0419-overlays-add-hdmi-backlight-hwhack-gpio-overlay.patch
1 From c6e4343e441558f45df2685b9ed7c13daf7988be Mon Sep 17 00:00:00 2001
2 From: Michael Kaplan <m.kaplan@evva.com>
3 Date: Wed, 5 Feb 2020 10:27:23 +0100
4 Subject: [PATCH] overlays: add hdmi-backlight-hwhack-gpio-overlay
5
6 This is a Devicetree overlay for GPIO based backlight on/off capability.
7
8 Use this if you have one of those HDMI displays whose backlight cannot be controlled via DPMS over HDMI and plan to do a little soldering to use an RPi gpio pin for on/off switching.
9
10 See: https://www.waveshare.com/wiki/7inch_HDMI_LCD_(C)#Backlight_Control
11
12 This was tested with a clone of the Waveshare "7 inch HDMI Touch LCD C" where I soldered two mosfets to override the backlight dip-switch.
13 When the overlay is loaded, a sysfs backlight node appears which can be used to modify the brightness value (0 or 1), and is even used by DPMS to switch the display backlight off after the configured timeout.
14 (On current Raspbian Buster Desktop, it's also possible to wakeup the display via a tap on the touch display :-) )
15
16 Signed-off-by: Michael Kaplan <m.kaplan@evva.com>
17 ---
18 arch/arm/boot/dts/overlays/Makefile | 1 +
19 arch/arm/boot/dts/overlays/README | 14 ++++++
20 .../hdmi-backlight-hwhack-gpio-overlay.dts | 47 +++++++++++++++++++
21 3 files changed, 62 insertions(+)
22 create mode 100644 arch/arm/boot/dts/overlays/hdmi-backlight-hwhack-gpio-overlay.dts
23
24 --- a/arch/arm/boot/dts/overlays/Makefile
25 +++ b/arch/arm/boot/dts/overlays/Makefile
26 @@ -51,6 +51,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
27 gpio-poweroff.dtbo \
28 gpio-shutdown.dtbo \
29 hd44780-lcd.dtbo \
30 + hdmi-backlight-hwhack-gpio.dtbo \
31 hifiberry-amp.dtbo \
32 hifiberry-dac.dtbo \
33 hifiberry-dacplus.dtbo \
34 --- a/arch/arm/boot/dts/overlays/README
35 +++ b/arch/arm/boot/dts/overlays/README
36 @@ -883,6 +883,20 @@ Params: pin_d4 GPIO pin
37 display_width Width of the display in characters
38
39
40 +Name: hdmi-backlight-hwhack-gpio
41 +Info: Devicetree overlay for GPIO based backlight on/off capability.
42 + Use this if you have one of those HDMI displays whose backlight cannot
43 + be controlled via DPMS over HDMI and plan to do a little soldering to
44 + use an RPi gpio pin for on/off switching. See:
45 + https://www.waveshare.com/wiki/7inch_HDMI_LCD_(C)#Backlight_Control
46 +Load: dtoverlay=hdmi-backlight-hwhack-gpio,<param>=<val>
47 +Params: gpio_pin GPIO pin used (default 17)
48 + active_low Set this to 1 if the display backlight is
49 + switched on when the wire goes low.
50 + Leave the default (value 0) if the backlight
51 + expects a high to switch it on.
52 +
53 +
54 Name: hifiberry-amp
55 Info: Configures the HifiBerry Amp and Amp+ audio cards
56 Load: dtoverlay=hifiberry-amp
57 --- /dev/null
58 +++ b/arch/arm/boot/dts/overlays/hdmi-backlight-hwhack-gpio-overlay.dts
59 @@ -0,0 +1,47 @@
60 +/*
61 + * Devicetree overlay for GPIO based backlight on/off capability.
62 + *
63 + * Use this if you have one of those HDMI displays whose backlight cannot be
64 + * controlled via DPMS over HDMI and plan to do a little soldering to use an
65 + * RPi gpio pin for on/off switching.
66 + *
67 + * See: https://www.waveshare.com/wiki/7inch_HDMI_LCD_(C)#Backlight_Control
68 + *
69 + */
70 +/dts-v1/;
71 +/plugin/;
72 +
73 +/ {
74 + compatible = "brcm,bcm2835";
75 +
76 + fragment@1 {
77 + target = <&gpio>;
78 + __overlay__ {
79 + hdmi_backlight_hwhack_gpio_pins: hdmi_backlight_hwhack_gpio_pins {
80 + brcm,pins = <17>;
81 + brcm,function = <1>; /* out */
82 + };
83 + };
84 + };
85 +
86 + fragment@2 {
87 + target-path = "/";
88 + __overlay__ {
89 + hdmi_backlight_hwhack_gpio: hdmi_backlight_hwhack_gpio {
90 + compatible = "gpio-backlight";
91 +
92 + pinctrl-names = "default";
93 + pinctrl-0 = <&hdmi_backlight_hwhack_gpio_pins>;
94 +
95 + gpios = <&gpio 17 0>;
96 + default-on;
97 + };
98 + };
99 + };
100 +
101 + __overrides__ {
102 + gpio_pin = <&hdmi_backlight_hwhack_gpio>,"gpios:4",
103 + <&hdmi_backlight_hwhack_gpio_pins>,"brcm,pins:0";
104 + active_low = <&hdmi_backlight_hwhack_gpio>,"gpios:8";
105 + };
106 +};