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 -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;
 

Reply via email to