]>
Commit | Line | Data |
---|---|---|
30d66db7 PR |
1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
2 | /* | |
3 | * Copyright (C) 2020 Philippe Reynes <[email protected]> | |
4 | */ | |
5 | ||
6 | #ifndef __BUTTON_H | |
7 | #define __BUTTON_H | |
8 | ||
9 | /** | |
10 | * struct button_uc_plat - Platform data the uclass stores about each device | |
11 | * | |
12 | * @label: Button label | |
13 | */ | |
14 | struct button_uc_plat { | |
15 | const char *label; | |
16 | }; | |
17 | ||
18 | /** | |
19 | * enum button_state_t - State used for button | |
20 | * - BUTTON_OFF - Button is not pressed | |
21 | * - BUTTON_ON - Button is pressed | |
22 | * - BUTTON_COUNT - Number of button state | |
23 | */ | |
24 | enum button_state_t { | |
25 | BUTTON_OFF = 0, | |
26 | BUTTON_ON = 1, | |
27 | BUTTON_COUNT, | |
28 | }; | |
29 | ||
30 | struct button_ops { | |
31 | /** | |
32 | * get_state() - get the state of a button | |
33 | * | |
34 | * @dev: button device to change | |
35 | * @return button state button_state_t, or -ve on error | |
36 | */ | |
37 | enum button_state_t (*get_state)(struct udevice *dev); | |
38 | }; | |
39 | ||
40 | #define button_get_ops(dev) ((struct button_ops *)(dev)->driver->ops) | |
41 | ||
42 | /** | |
43 | * button_get_by_label() - Find a button device by label | |
44 | * | |
45 | * @label: button label to look up | |
46 | * @devp: Returns the associated device, if found | |
47 | * @return 0 if found, -ENODEV if not found, other -ve on error | |
48 | */ | |
49 | int button_get_by_label(const char *label, struct udevice **devp); | |
50 | ||
51 | /** | |
52 | * button_get_state() - get the state of a button | |
53 | * | |
54 | * @dev: button device to change | |
55 | * @return button state button_state_t, or -ve on error | |
56 | */ | |
57 | enum button_state_t button_get_state(struct udevice *dev); | |
58 | ||
59 | #endif |