From 747a078b6546e1bd51aa994a4b4da8d2a7b16882 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Myl=C3=A8ne=20Josserand?=
 <mylene.josserand@free-electrons.com>
Date: Thu, 6 Jul 2017 10:57:55 +0200
Subject: [PATCH 52/82] ARM: dts: sun8i-a83t-tbs-a711: Add powerup/down support
 for the 3G modem
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The modem needs tree gpios to be powered-up:
	- PL10 = reset
	- PL8 = On/Off
	- PL9 = vbat
Because of that, the PL9 corresponds to the regulator's gpio whereas
the PL8 (on/off) will be a power-gpio of the power sequence.

Thanks to that, the modem is powered up:
       # lsusb
	Bus 001 Device 004: ID 19d2:ffeb

Signed-off-by: Ondrej Jirman <megous@megous.com>
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
index b0a94cf13740..f22da26557f2 100644
--- a/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
+++ b/arch/arm/boot/dts/sun8i-a83t-tbs-a711.dts
@@ -142,8 +142,10 @@
 		regulator-name = "vmain";
 		regulator-min-microvolt = <5000000>;
 		regulator-max-microvolt = <5000000>;
-		gpio = <&r_pio 0 9 GPIO_ACTIVE_HIGH>;
+		gpio = <&r_pio 0 9 GPIO_ACTIVE_HIGH>; /* PL9 */
 		enable-active-high;
+		//megi: See modem for comments
+		regulator-always-on;
 		vin-supply = <&reg_vbat>;
 	};
 
@@ -159,6 +161,19 @@
 		clock-names = "ext_clock";
 	};
 
+	modem {
+		compatible = "custom,power-manager";
+		//megi: switching Q5 MOSFET probably leads to brownouts on
+		//VBAT due to larger capacities on VMAIN. Only use PL8 to
+		//enable/disable the modem
+		//power-supply = <&reg_vmain>;
+		enable-gpios = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */
+		reset-gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
+		wakeup-gpios = <&r_pio 0 11 GPIO_ACTIVE_HIGH>; /* PL11 */
+		reset-duration-ms = <5>;
+		char-device-name = "pwr-modem";
+	};
+
 	gps {
 		compatible = "custom,power-manager";
 		power-supply = <&reg_gps>;
-- 
2.20.1

