1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c), Vaisala Oyj
4  */
5 
6 #ifndef REBOOT_MODE_REBOOT_MODE_H__
7 #define REBOOT_MODE_REBOOT_MODE_H__
8 
9 #include <asm/types.h>
10 #include <dm/device.h>
11 
12 struct reboot_mode_mode {
13 	const char *mode_name;
14 	u32 mode_id;
15 };
16 
17 struct reboot_mode_uclass_platdata {
18 	struct reboot_mode_mode *modes;
19 	u8 count;
20 	const char *env_variable;
21 };
22 
23 struct reboot_mode_ops {
24 	/**
25 	 * get() - get the current reboot mode value
26 	 *
27 	 * Returns the current value from the reboot mode backing store.
28 	 *
29 	 * @dev:	Device to read from
30 	 * @rebootmode:	Address to save the current reboot mode value
31 	 */
32 	int (*get)(struct udevice *dev, u32 *rebootmode);
33 
34 	/**
35 	 * set() - set a reboot mode value
36 	 *
37 	 * Sets the value in the reboot mode backing store.
38 	 *
39 	 * @dev:	Device to read from
40 	 * @rebootmode:	New reboot mode value to store
41 	 */
42 	int (*set)(struct udevice *dev, u32 rebootmode);
43 };
44 
45 /* Access the operations for a reboot mode device */
46 #define reboot_mode_get_ops(dev) ((struct reboot_mode_ops *)(dev)->driver->ops)
47 
48 /**
49  * dm_reboot_mode_update() - Update the reboot mode env variable.
50  *
51  * @dev:	Device to read from
52  * Return: 0 if OK, -ve on error
53  */
54 int dm_reboot_mode_update(struct udevice *dev);
55 
56 #endif /* REBOOT_MODE_REBOOT_MODE_H__ */
57