From 23b18d126723a40f13434206bd9b2c7f84fb9420 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Mon, 15 Feb 2021 17:45:13 +0100
Subject: [PATCH 193/463] arm64: dts: sun50i-a64-pinephone: Add reboot mode
 driver

With the latest p-boot (released 2021-02-15), you can reboot to
a particular boot option or to the menu, to FEL, to eMMC bootloader,
regardless of the user defined p-boot defaults.

Call reboot with cmd of LINUX_REBOOT_CMD_RESTART2 and arg:

- fel          Reboot to FEL
- emmc-egon    Reboot with chainload of bootloader from eMMC
- sd1-8        Reboot to SD bootfs option
- emmc1-8      Reboot to eMMC bootfs option
- menu         Reboot to p-boot menu

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 .../dts/allwinner/sun50i-a64-pinephone.dtsi   | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index 136de65e48b94..f0aab1fd60802 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -423,6 +423,34 @@ sgm3140_flash: led {
 		};
 	};
 
+	/* PinePhone specific reboot modes for p-boot. */
+	reboot-mode {
+		compatible = "nvmem-reboot-mode";
+		nvmem-cells = <&reboot_mode>;
+		nvmem-cell-names = "reboot-mode";
+
+		mode-normal     = <0x0>;
+		mode-fel        = <0xb0010fe1>;
+		mode-emmc-egon  = <0xb001e33c>;
+		mode-sd1        = <0xb0010020>;
+		mode-sd2        = <0xb0010021>;
+		mode-sd3        = <0xb0010022>;
+		mode-sd4        = <0xb0010023>;
+		mode-sd5        = <0xb0010024>;
+		mode-sd6        = <0xb0010025>;
+		mode-sd7        = <0xb0010026>;
+		mode-sd8        = <0xb0010027>;
+		mode-emmc1      = <0xb0010000>;
+		mode-emmc2      = <0xb0010001>;
+		mode-emmc3      = <0xb0010002>;
+		mode-emmc4      = <0xb0010003>;
+		mode-emmc5      = <0xb0010004>;
+		mode-emmc6      = <0xb0010005>;
+		mode-emmc7      = <0xb0010006>;
+		mode-emmc8      = <0xb0010007>;
+		mode-menu       = <0xb00100ff>;
+	};
+
 	speaker_amp: audio-amplifier {
 		compatible = "simple-audio-amplifier";
 		enable-gpios = <&pio 2 7 GPIO_ACTIVE_HIGH>; /* PC7 */
@@ -916,6 +944,15 @@ &reg_rtc_ldo {
 	regulator-name = "vcc-rtc";
 };
 
+&rtc {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	reboot_mode: reboot-mode@4 {
+		reg = <0x4 0x4>;
+	};
+};
+
 &sound {
 	status = "okay";
 	simple-audio-card,name = "PinePhone";
-- 
2.46.0

