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