From 465a75a727ae5eb4c94859bfac4742cb14e38b3e Mon Sep 17 00:00:00 2001
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Fri, 3 Apr 2020 17:13:55 +0200
Subject: [PATCH 179/183] arm64: dts: allwinner: pinephone: improve device tree

On PinePhone, the headset mic bias resistor isn't populated on the
schematics (R811), therefore we need to enable the codec's internal
resistor. Additionnally, the jack detection IRQ's are inverted due to the
connector wiring, so the necessary property is added to the codec node
to made the driver aware of this fact.

We also stop LEDs during suspend to improve battery life, lower
cpu_alert* temperatures so the phone doesn't get too hot and improve the
backlight brightness values so we have a wider usable range.

Finally, the RGB LED max_brightness is set to 1 as it isn't using a PWM
output.
---
 .../dts/allwinner/sun50i-a64-pinephone-1.1.dts | 10 +++++-----
 .../dts/allwinner/sun50i-a64-pinephone-1.2.dts | 13 ++++++-------
 .../dts/allwinner/sun50i-a64-pinephone.dtsi    | 18 +++++++++++++-----
 3 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dts
index f084c4f21f12..573f1929da4f 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dts
@@ -29,11 +29,11 @@ &backlight {
 	 * value here was chosen as a safe default.
 	 */
 	brightness-levels = <
-		774  793  814  842
-		882  935  1003 1088
-		1192 1316 1462 1633
-		1830 2054 2309 2596
-		2916 3271 3664 4096>;
+		392  413  436  468
+		512  571  647  742
+		857  995  1159 1349
+		1568 1819 2103 2423
+		2779 3176 3614 4096>;
 	num-interpolated-steps = <50>;
 	default-brightness-level = <400>;
 };
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.2.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.2.dts
index bbf64677c22b..6c3922543fec 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.2.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.2.dts
@@ -34,14 +34,13 @@ &backlight {
 	 * chosen as a safe default.
 	 */
 	brightness-levels = <
-		5000 5248 5506 5858 6345
-		6987 7805 8823 10062 11543
-		13287 15317 17654 20319 23336
-		26724 30505 34702 39335 44427
-		50000
-	>;
+		392  413  436  468
+		512  571  647  742
+		857  995  1159 1349
+		1568 1819 2103 2423
+		2779 3176 3614 4096>;
 	num-interpolated-steps = <50>;
-	default-brightness-level = <500>;
+	default-brightness-level = <400>;
 };
 
 &lis3mdl {
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index c55709197804..441358592072 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -80,21 +80,21 @@ blue {
 			function = LED_FUNCTION_INDICATOR;
 			color = <LED_COLOR_ID_BLUE>;
 			gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */
-			retain-state-suspended;
+			max-brightness = <1>;
 		};
 
 		green {
 			function = LED_FUNCTION_INDICATOR;
 			color = <LED_COLOR_ID_GREEN>;
 			gpios = <&pio 3 18 GPIO_ACTIVE_HIGH>; /* PD18 */
-			retain-state-suspended;
+			max-brightness = <1>;
 		};
 
 		red {
 			function = LED_FUNCTION_INDICATOR;
 			color = <LED_COLOR_ID_RED>;
 			gpios = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */
-			retain-state-suspended;
+			max-brightness = <1>;
 		};
 	};
 
@@ -198,6 +198,14 @@ &cpu3 {
 	cpu-supply = <&reg_dcdc2>;
 };
 
+&cpu_alert0 {
+	temperature = <60000>;
+};
+
+&cpu_alert1 {
+	temperature = <80000>;
+};
+
 &csi {
 	pinctrl-0 = <&csi_pins>, <&csi_mclk_pin>;
 	status = "okay";
@@ -671,11 +679,11 @@ &sound {
 	simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>;
 	simple-audio-card,widgets = "Microphone", "Headset Microphone",
 				    "Microphone", "Internal Microphone",
-				    "Headphone", "Headphone Jack",
+				    "Headphone", "Headphone",
 				    "Speaker", "Internal Earpiece",
 				    "Speaker", "Internal Speaker";
 	simple-audio-card,routing =
-			"Headphone Jack", "HP",
+			"Headphone", "HP",
 			"Internal Earpiece", "EARPIECE",
 			"Internal Speaker", "Speaker Amp OUTL",
 			"Internal Speaker", "Speaker Amp OUTR",
-- 
2.30.0

