1 From 68aaa2f653c83f8fda6032153566b4f895dff524 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Sat, 12 May 2018 21:35:43 +0100
4 Subject: [PATCH 131/806] firmware/raspberrypi: Notify firmware of a reboot
6 Register for reboot notifications, sending RPI_FIRMWARE_NOTIFY_REBOOT
7 over the mailbox interface on reception.
9 Signed-off-by: Phil Elwell <phil@raspberrypi.org>
11 drivers/firmware/raspberrypi.c | 40 +++++++++++++++++++++++++++++++++-
12 1 file changed, 39 insertions(+), 1 deletion(-)
14 --- a/drivers/firmware/raspberrypi.c
15 +++ b/drivers/firmware/raspberrypi.c
17 #include <linux/module.h>
18 #include <linux/of_platform.h>
19 #include <linux/platform_device.h>
20 +#include <linux/reboot.h>
21 #include <soc/bcm2835/raspberrypi-firmware.h>
23 #define MBOX_MSG(chan, data28) (((data28) & ~0xf) | ((chan) & 0xf))
24 @@ -174,6 +175,26 @@ int rpi_firmware_property(struct rpi_fir
26 EXPORT_SYMBOL_GPL(rpi_firmware_property);
28 +static int rpi_firmware_notify_reboot(struct notifier_block *nb,
29 + unsigned long action,
32 + struct rpi_firmware *fw;
33 + struct platform_device *pdev = g_pdev;
38 + fw = platform_get_drvdata(pdev);
42 + (void)rpi_firmware_property(fw, RPI_FIRMWARE_NOTIFY_REBOOT,
49 rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
51 @@ -284,15 +305,32 @@ static struct platform_driver rpi_firmwa
52 .remove = rpi_firmware_remove,
55 +static struct notifier_block rpi_firmware_reboot_notifier = {
56 + .notifier_call = rpi_firmware_notify_reboot,
59 static int __init rpi_firmware_init(void)
61 - return platform_driver_register(&rpi_firmware_driver);
62 + int ret = register_reboot_notifier(&rpi_firmware_reboot_notifier);
65 + ret = platform_driver_register(&rpi_firmware_driver);
72 + unregister_reboot_notifier(&rpi_firmware_reboot_notifier);
76 subsys_initcall(rpi_firmware_init);
78 static void __init rpi_firmware_exit(void)
80 platform_driver_unregister(&rpi_firmware_driver);
81 + unregister_reboot_notifier(&rpi_firmware_reboot_notifier);
83 module_exit(rpi_firmware_exit);