1 // Copyright 2017 The Fuchsia Authors
2 //
3 // Use of this source code is governed by a MIT-style
4 // license that can be found in the LICENSE file or at
5 // https://opensource.org/licenses/MIT
6 
7 #include <pdev/power.h>
8 
9 #include <arch/arch_ops.h>
10 #include <dev/power.h>
11 #include <dev/psci.h>
12 
default_reboot(enum reboot_flags flags)13 static void default_reboot(enum reboot_flags flags) {
14     psci_system_reset(flags);
15 }
16 
default_shutdown()17 static void default_shutdown() {
18     psci_system_off();
19 }
20 
21 static const struct pdev_power_ops default_ops = {
22     .reboot = default_reboot,
23     .shutdown = default_shutdown,
24 };
25 
26 static const struct pdev_power_ops* power_ops = &default_ops;
27 
power_reboot(enum reboot_flags flags)28 void power_reboot(enum reboot_flags flags) {
29     power_ops->reboot(flags);
30 }
31 
power_shutdown()32 void power_shutdown() {
33     power_ops->shutdown();
34 }
35 
pdev_register_power(const struct pdev_power_ops * ops)36 void pdev_register_power(const struct pdev_power_ops* ops) {
37     power_ops = ops;
38     smp_mb();
39 }
40