From e524a3640f8057a4c8526fefde90dd33d1b0fc85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Sun, 23 Feb 2020 01:23:10 +0100
Subject: [PATCH 165/463] ARM: dts: sun5i: Add PocketBook Touch Lux 3
 display/ctp support

Add support for display and touchscreen via out-of-tree drivers.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 .../sun5i-a13-pocketbook-touch-lux-3.dts      | 105 +++++++++++++++++-
 1 file changed, 103 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/allwinner/sun5i-a13-pocketbook-touch-lux-3.dts b/arch/arm/boot/dts/allwinner/sun5i-a13-pocketbook-touch-lux-3.dts
index d60407772e5d3..db28ab6218044 100644
--- a/arch/arm/boot/dts/allwinner/sun5i-a13-pocketbook-touch-lux-3.dts
+++ b/arch/arm/boot/dts/allwinner/sun5i-a13-pocketbook-touch-lux-3.dts
@@ -62,6 +62,11 @@ key-left {
 		};
 	};
 
+	regulator-eink {
+		compatible = "custom,reg-userspace-consumer";
+		controlled-supply = <&tp65185x>;
+	};
+
 	reg_1v8: regulator-1v8 {
 		compatible = "regulator-fixed";
 		regulator-name = "vdd-1v8-nor-ctp";
@@ -79,7 +84,6 @@ reg_1v8_nor: regulator-nor {
 		gpio = <&pio 2 14 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 		vin-supply = <&reg_1v8>;
-		regulator-always-on;
 	};
 
 	reg_1v8_ctp: regulator-ctp {
@@ -112,6 +116,7 @@ &ehci0 {
 
 &i2c0 {
 	status = "okay";
+	//XXX: bsp has pullup on PB0/PB1 pins enabled, but it works without it
 
 	axp209: pmic@34 {
 		reg = <0x34>;
@@ -128,12 +133,42 @@ pcf8563: rtc@51 {
 		compatible = "nxp,pcf8563";
 		reg = <0x51>;
 	};
+
+	// hacky PMIC driver for eInk display
+	tp65185x: regulator@68 {
+		compatible = "tp,tp65185x";
+		reg = <0x68>;
+
+		regulator-min-microvolt = <3120000>;
+		regulator-max-microvolt = <3120000>;
+		regulator-name = "eink-vcom";
+
+		//XXX: we don't use interrupts in the driver right now
+		//interrupt-parent = <&pio>;
+		//interrupts = <1 10 IRQ_TYPE_LEVEL_LOW>; /* PB10 */
+
+		wakeup-gpios = <&pio 3 18 GPIO_ACTIVE_HIGH>; /* PD18 */
+		powerup-gpios = <&pio 4 7 GPIO_ACTIVE_HIGH>; /* PE7 */
+		vcom-gpios = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */
+		//XXX: not a pullup on BSP (might have an external resistor)
+		powergood-gpios = <&pio 4 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; /* PE6 */
+	};
 };
 
 &i2c2 {
 	status = "okay";
 
-	/* Touchpanel is connected here. */
+	touchpanel@24 {
+		compatible = "cypress,cyttsp4_i2c_adapter";
+		reg = <0x24>;
+
+		interrupt-parent = <&pio>;
+		interrupts = <6 11 IRQ_TYPE_EDGE_FALLING>; /* PG11 */
+
+		vdd-supply = <&reg_1v8_ctp>;
+		power-gpios = <&pio 4 5 GPIO_ACTIVE_LOW>; /* PE5 */
+		reset-gpios = <&pio 1 3 GPIO_ACTIVE_LOW>; /* PB3 */
+	};
 };
 
 &lradc {
@@ -179,6 +214,20 @@ &otg_sram {
 	status = "okay";
 };
 
+&pio {
+	eink_pins_active: eink-pins-lcd {
+		pins = "PD3", "PD4", "PD5", "PD6", "PD7", "PD10", "PD11", "PD12",
+			"PD13", "PD15", "PD20", "PD21", "PD22", "PD23", "PD24";
+		function = "lcd0";
+	};
+
+	eink_pins_idle: eink-pins-gpio {
+		pins = "PD3", "PD4", "PD5", "PD6", "PD7", "PD10", "PD11", "PD12",
+			"PD13", "PD15", "PD20", "PD21", "PD22", "PD23", "PD24";
+		function = "gpio_out";
+	};
+};
+
 &pwm {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pwm0_pin>;
@@ -219,6 +268,55 @@ &reg_ldo3 {
 	regulator-ramp-delay = <1600>;
 };
 
+&soc {
+	display-controller@1c0c000 {
+		pinctrl-names = "idle", "active";
+		pinctrl-0 = <&eink_pins_idle>;
+		pinctrl-1 = <&eink_pins_active>;
+
+		all-gpios = <&pio 3 3 GPIO_ACTIVE_HIGH>,
+			<&pio 3 4 GPIO_ACTIVE_HIGH>,
+			<&pio 3 5 GPIO_ACTIVE_HIGH>,
+			<&pio 3 6 GPIO_ACTIVE_HIGH>,
+			<&pio 3 7 GPIO_ACTIVE_HIGH>,
+			<&pio 3 10 GPIO_ACTIVE_HIGH>,
+			<&pio 3 11 GPIO_ACTIVE_HIGH>,
+			<&pio 3 12 GPIO_ACTIVE_HIGH>,
+			<&pio 3 13 GPIO_ACTIVE_HIGH>,
+			<&pio 3 15 GPIO_ACTIVE_HIGH>,
+			<&pio 3 20 GPIO_ACTIVE_HIGH>,
+			<&pio 3 21 GPIO_ACTIVE_HIGH>,
+			<&pio 3 22 GPIO_ACTIVE_HIGH>,
+			<&pio 3 23 GPIO_ACTIVE_HIGH>,
+			<&pio 3 24 GPIO_ACTIVE_HIGH>;
+
+		compatible = "custom,pocketbook-touch-lux-3-tcon0-ed060xd4-display";
+		reg = <0x01c0c000 0x1000>, // TCON0 regs
+			<0x01e60000 0x10000>; // DEBE regs
+
+		interrupts = <44>; // TCON interrupt
+
+		resets = <&ccu RST_LCD>, <&ccu RST_DE_BE>;
+		reset-names = "tcon", "be";
+
+		clocks = <&ccu CLK_AHB_LCD>, <&ccu CLK_TCON_CH0>,
+			 <&ccu CLK_AHB_DE_BE>, <&ccu CLK_DE_BE>,
+			 <&ccu CLK_DRAM_DE_BE>;
+		clock-names = "tcon_bus", "tcon_mod",
+			      "be_bus", "be_mod",
+			      "be_ram";
+
+		assigned-clocks = <&ccu CLK_DE_BE>;
+		assigned-clock-rates = <300000000>;
+
+		interconnects = <&mbus 18>;
+		interconnect-names = "dma-mem";
+
+		panel-supply = <&tp65185x>;
+		control-device-name = "eink-panel";
+	};
+};
+
 &spi2 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&spi2_pe_pins>, <&spi2_cs0_pe_pin>;
@@ -230,6 +328,7 @@ epd_flash: flash@0 {
 		compatible = "macronix,mx25u4033", "jedec,spi-nor";
 		reg = <0>;
 		spi-max-frequency = <4000000>;
+		vdd-supply = <&reg_1v8_nor>;
 	};
 };
 
@@ -253,6 +352,8 @@ &usb_power_supply {
 };
 
 &usbphy {
+	//XXX: might not work, need to test
+	usb0_vbus_det-gpios = <&pio 6 1 GPIO_ACTIVE_HIGH>; /* PG1 */
 	usb1_vbus-supply = <&reg_ldo3>;
 	status = "okay";
 };
-- 
2.46.0

