From 858041fd8c63a990bc7ab2cd135f1acc49090780 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Sun, 4 Sep 2022 23:13:21 +0200
Subject: [PATCH 367/463] arm64: dts: rk3399-pinephone-pro: Add BSP battery
 driver support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is based on a mix of BSP code and a new charger driver.

Signed-off-by: Martijn Braam <martijn@brixit.nl>
Co-developed-by: Kamil Trzciński <ayufan@ayufan.eu>
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 .../dts/rockchip/rk3399-pinephone-pro.dts     | 71 +++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
index e58cb344e7b63..e5fc049c72933 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3399-pinephone-pro.dts
@@ -51,6 +51,43 @@ button-down {
 		};
 	};
 
+	bat: battery {
+                compatible = "simple-battery";
+                voltage-min-design-microvolt = <3400000>;
+                voltage-max-design-microvolt = <4350000>;
+                energy-full-design-microwatt-hours = <11400000>;
+                charge-full-design-microamp-hours = <3000000>;
+                precharge-current-microamp = <120000>;
+                charge-term-current-microamp = <150000>;
+                constant-charge-current-max-microamp = <1500000>;
+                constant-charge-voltage-max-microvolt = <4350000>;
+                factory-internal-resistance-micro-ohms = <150000>;
+                resistance-temp-table = <20 150>;
+                ocv-capacity-celsius = <20>;
+                ocv-capacity-table-0 =
+			<4308000 100>,
+			<4217000 95>,
+			<4161000 90>,
+			<4110000 85>,
+			<4066000 80>,
+			<4007000 75>,
+			<3974000 70>,
+			<3937000 65>,
+			<3896000 60>,
+			<3853000 55>,
+			<3827000 50>,
+			<3807000 45>,
+			<3793000 40>,
+			<3780000 35>,
+			<3768000 30>,
+			<3756000 25>,
+			<3740000 20>,
+			<3716000 15>,
+			<3689000 10>,
+			<3675000 5>,
+			<3400000 0>;
+        };
+
 	backlight: backlight {
 		compatible = "pwm-backlight";
 		pwms = <&pwm0 0 50000 0>;
@@ -389,6 +426,40 @@ regulator-state-mem {
 				};
 			};
 		};
+
+		/*
+		 * XXX: Backported BSP stuff, drop this. Use standard
+		 * "monitored-battery" property.
+		 */
+		battery {
+			compatible = "rockchip,rk818-battery";
+			ocv_table = <3400 3675 3689 3716 3740 3756 3768 3780
+				3793 3807 3827 3853 3896 3937 3974 4007 4066
+				4110 4161 4217 4308>;
+			design_capacity = <2916>;
+			design_qmax = <2708>;
+			bat_res = <150>;
+			max_input_current = <3000>;
+			max_chrg_current = <2000>;
+			max_chrg_voltage = <4350>;
+			sleep_enter_current = <300>;
+			sleep_exit_current = <300>;
+			power_off_thresd = <3400>;
+			zero_algorithm_vol = <3950>;
+			fb_temperature = <105>;
+			sample_res = <10>;
+			max_soc_offset = <60>;
+			energy_mode = <0>;
+			monitor_sec = <5>;
+			virtual_power = <0>;
+			power_dc2otg = <0>;
+			otg5v_suspend_enable = <1>;
+		};
+
+		charger {
+			compatible = "rockchip,rk818-charger";
+			monitored-battery = <&bat>;
+		};
 	};
 
 	vdd_cpu_b: regulator@40 {
-- 
2.46.0

