aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.15/950-0665-dtoverlays-Add-pwm-backlight-option-to-vc4-kms-dpi-g.patch
blob: 5b0243472c1f4f1ba77bc44368e086648f303252 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
From 7ec32023e6ad31c242e2acc179fd35084fa9cea5 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Fri, 21 Jan 2022 14:22:01 +0000
Subject: [PATCH] dtoverlays: Add pwm backlight option to
 vc4-kms-dpi-generic

Adds the option of a PWM controlled backlight on a generic
DPI display.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/README             | 17 +++++++
 .../overlays/vc4-kms-dpi-generic-overlay.dts  | 51 +++++++++++++++++++
 2 files changed, 68 insertions(+)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -3644,6 +3644,23 @@ Params: clock-frequency         Display
                                 value. NB also overridden by rgbXXX overrides.
         backlight-gpio          Defines a GPIO to be used for backlight control
                                 (default of none).
+        backlight-pwm           Defines a PWM channel to be used for backlight
+                                control (default of none). NB Disables audio
+                                headphone output as that also uses PWM.
+        backlight-pwm-chan      Choose channel on &pwm node for backlight
+                                control.
+                                (default 0).
+        backlight-pwm-gpio      GPIO pin to be used for the PWM backlight. See
+                                pwm-2chan for valid options.
+                                (default 18 - note this can only work with
+                                 rgb666-padhi).
+        backlight-pwm-func      Pin function of GPIO used for the PWM
+                                backlight.
+                                See pwm-2chan for valid options.
+                                (default 2).
+        backlight-def-brightness
+                                Set the default brightness. Normal range 1-16.
+                                (default 16).
 
 
 Name:   vc4-kms-dsi-7inch
--- a/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts
+++ b/arch/arm/boot/dts/overlays/vc4-kms-dpi-generic-overlay.dts
@@ -80,6 +80,52 @@
 		};
 	};
 
+	fragment@4 {
+		target = <&panel>;
+		__dormant__  {
+			backlight = <&backlight_pwm>;
+		};
+	};
+
+	fragment@5 {
+		target-path = "/";
+		__dormant__  {
+			backlight_pwm: backlight_pwm {
+				compatible = "pwm-backlight";
+				brightness-levels = <0 6 8 12 16 24 32 40 48 64 96 128 160 192 224 255>;
+				default-brightness-level = <16>;
+				pwms = <&pwm 0 200000>;
+			};
+		};
+	};
+
+	fragment@6 {
+		target = <&pwm>;
+		__dormant__ {
+			pinctrl-names = "default";
+			pinctrl-0 = <&pwm_pins>;
+			assigned-clock-rates = <1000000>;
+			status = "okay";
+		};
+	};
+
+	fragment@7 {
+		target = <&gpio>;
+		__dormant__ {
+			pwm_pins: pwm_pins {
+				brcm,pins = <18>;
+				brcm,function = <2>; /* Alt5 */
+			};
+		};
+	};
+
+	fragment@8 {
+		target = <&audio>;
+		__dormant__  {
+		    brcm,disable-headphones;
+		};
+	};
+
 	__overrides__ {
 		clock-frequency = <&timing>, "clock-frequency:0";
 		hactive = <&timing>, "hactive:0";
@@ -107,5 +153,10 @@
 		bus-format = <&panel>, "bus-format:0";
 		backlight-gpio = <0>, "+2+3",
 			<&backlight>, "gpios:4";
+		backlight-pwm = <0>, "+4+5+6+7+8";
+		backlight-pwm-chan = <&backlight_pwm>, "pwms:4";
+		backlight-pwm-gpio = <&pwm_pins>, "brcm,pins:0";
+		backlight-pwm-func = <&pwm_pins>, "brcm,function:0";
+		backlight-def-brightness = <&backlight_pwm>, "default-brightness-level:0";
 	};
 };