1 /*
2  * Copyright (c) 2020 Intel Corporation
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/sys/printk.h>
8 #include <zephyr/types.h>
9 #include <zephyr/pm/device.h>
10 #include <zephyr/pm/device_runtime.h>
11 #include "dummy_driver.h"
12 
dummy_open(const struct device * dev)13 static int dummy_open(const struct device *dev)
14 {
15 	return pm_device_runtime_get(dev);
16 }
17 
dummy_close(const struct device * dev)18 static int dummy_close(const struct device *dev)
19 {
20 	return pm_device_runtime_put(dev);
21 }
22 
dummy_device_pm_action(const struct device * dev,enum pm_device_action action)23 static int dummy_device_pm_action(const struct device *dev,
24 				  enum pm_device_action action)
25 {
26 	return 0;
27 }
28 
29 static const struct dummy_driver_api funcs = {
30 	.open = dummy_open,
31 	.close = dummy_close,
32 };
33 
dummy_init(const struct device * dev)34 int dummy_init(const struct device *dev)
35 {
36 	return pm_device_runtime_enable(dev);
37 }
38 
39 PM_DEVICE_DEFINE(dummy_driver, dummy_device_pm_action);
40 
41 DEVICE_DEFINE(dummy_driver, DUMMY_DRIVER_NAME, &dummy_init,
42 	      PM_DEVICE_GET(dummy_driver), NULL, NULL, POST_KERNEL,
43 	      CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &funcs);
44