diff mbox series

FSL P5020/Cyrus+ Board: Poweroff and Restart Support

Message ID fb1762ec-5c08-a92d-0b2a-5e2b48380b29@xenosoft.de (mailing list archive)
State Not Applicable
Headers show
Series FSL P5020/Cyrus+ Board: Poweroff and Restart Support | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch powerpc/merge (a87b93bdf800a4d7a42d95683624a4516e516b4f)
snowpatch_ozlabs/build-ppc64le success Build succeeded
snowpatch_ozlabs/build-ppc64be success Build succeeded
snowpatch_ozlabs/build-ppc64e success Build succeeded
snowpatch_ozlabs/build-pmac32 success Build succeeded
snowpatch_ozlabs/checkpatch warning total: 3 errors, 1 warnings, 0 checks, 64 lines checked
snowpatch_ozlabs/needsstable success Patch has no Fixes tags

Commit Message

Christian Zigotzky March 21, 2020, 12:50 p.m. UTC
Hello,

We would like to add poweroff and restart support for the Cyrus+ board 
[1] [2] to the mainline vanilla kernel.
There is a patch for adding poweroff and restart support. (attached)
It works but I am not sure if it is good enough for the mainline vanilla 
kernel.
Please post some suggestions and comments about this patch.

Thanks,
Christian


[1] http://wiki.amiga.org/index.php?title=X5000
[2] https://www.amigaos.net/hardware/133/amigaone-x5000
diff mbox series

Patch

diff -rupN a/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts b/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts
--- a/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts	2020-02-10 01:08:48.000000000 +0100
+++ b/arch/powerpc/boot/dts/fsl/cyrus_p5020.dts	2020-02-10 08:49:47.953680947 +0100
@@ -146,6 +146,25 @@ 
 				  0 0x00010000>;
 		};
 	};
+
+	gpio-poweroff {
+		compatible = "gpio-poweroff";
+		gpios = <&gpio0 3 1>;
+	};
+
+	gpio-restart {
+		compatible = "gpio-restart";
+		gpios = <&gpio0 2 1>;
+	};
+
+	leds {
+		compatible = "gpio-leds";
+		hdd {
+			label = "Disk activity";
+			gpios = <&gpio0 5 0>;
+			linux,default-trigger = "disk-activity";
+		};
+	};
 };
 
 /include/ "p5020si-post.dtsi"
diff -rupN a/arch/powerpc/platforms/85xx/corenet_generic.c b/arch/powerpc/platforms/85xx/corenet_generic.c
--- a/arch/powerpc/platforms/85xx/corenet_generic.c	2020-02-10 01:08:48.000000000 +0100
+++ b/arch/powerpc/platforms/85xx/corenet_generic.c	2020-02-10 08:49:47.953680947 +0100
@@ -46,6 +46,16 @@  void __init corenet_gen_pic_init(void)
 	mpic_init(mpic);
 }
 
+/* If someone has registered a poweroff callback, invoke it */
+static void __noreturn corenet_generic_halt(void)
+{
+	if (pm_power_off)
+	pm_power_off();
+
+	/* Should not return */
+	for(;;);
+}
+
 /*
  * Setup the architecture
  */
@@ -99,6 +109,15 @@  static const struct of_device_id of_devi
 	{
 		.name		= "handles",
 	},
+	{
+		.name		= "gpio-poweroff",
+	},
+	{
+		.name		= "gpio-restart",
+	},
+	{
+		.name		= "leds",
+	},
 	{}
 };
 
@@ -149,6 +168,8 @@  static int __init corenet_generic_probe(
 	extern struct smp_ops_t smp_85xx_ops;
 #endif
 
+	ppc_md.halt = corenet_generic_halt;
+
 	if (of_device_compatible_match(of_root, boards))
 		return 1;