From 66616b654c38ff3cb0b34b6b676fa13425c40d4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Mon, 14 Dec 2020 07:42:08 +0100
Subject: power: supply: axp20x-usb-power: Change Vbus hold voltage to 4.5V

This fixes USB-PD charger resets.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 drivers/power/supply/axp20x_usb_power.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c
index 9722912268fe..b555ba9bf6ad 100644
--- a/drivers/power/supply/axp20x_usb_power.c
+++ b/drivers/power/supply/axp20x_usb_power.c
@@ -1011,6 +1011,18 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
 			return ret;
 	}
 
+	/*TODO: Re-work this into a supply property with OF based default value */
+	if (of_machine_is_compatible("pine64,pinephone-1.2") > 0 ||
+		of_machine_is_compatible("pine64,pinephone-1.1") > 0 ||
+		of_machine_is_compatible("pine64,pinephone-1.0") > 0) {
+
+		dev_info(&pdev->dev, "Increasing Vbus hold voltage to 4.5V\n");
+
+		ret = regmap_update_bits(axp20x->regmap, 0x30, 0x7 << 3, 0x5 << 3);
+		if (ret)
+			return ret;
+	}
+
 	psy_cfg.of_node = pdev->dev.of_node;
 	psy_cfg.drv_data = power;
 
-- 
2.35.3

