Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Google, Inc |
| 3 | * Written by Simon Glass <sjg@chromium.org> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #ifndef __LED_H |
| 9 | #define __LED_H |
| 10 | |
| 11 | /** |
Simon Glass | 56e1987 | 2017-04-10 11:34:53 -0600 | [diff] [blame] | 12 | * struct led_uc_plat - Platform data the uclass stores about each device |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 13 | * |
| 14 | * @label: LED label |
| 15 | */ |
Simon Glass | 56e1987 | 2017-04-10 11:34:53 -0600 | [diff] [blame] | 16 | struct led_uc_plat { |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 17 | const char *label; |
| 18 | }; |
| 19 | |
Simon Glass | ddae9fc | 2017-04-10 11:34:54 -0600 | [diff] [blame^] | 20 | enum led_state_t { |
| 21 | LEDST_OFF = 0, |
| 22 | LEDST_ON = 1, |
| 23 | |
| 24 | LEDST_COUNT, |
| 25 | }; |
| 26 | |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 27 | struct led_ops { |
| 28 | /** |
Simon Glass | ddae9fc | 2017-04-10 11:34:54 -0600 | [diff] [blame^] | 29 | * set_state() - set the state of an LED |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 30 | * |
| 31 | * @dev: LED device to change |
Simon Glass | ddae9fc | 2017-04-10 11:34:54 -0600 | [diff] [blame^] | 32 | * @state: LED state to set |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 33 | * @return 0 if OK, -ve on error |
| 34 | */ |
Simon Glass | ddae9fc | 2017-04-10 11:34:54 -0600 | [diff] [blame^] | 35 | int (*set_state)(struct udevice *dev, enum led_state_t state); |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | #define led_get_ops(dev) ((struct led_ops *)(dev)->driver->ops) |
| 39 | |
| 40 | /** |
| 41 | * led_get_by_label() - Find an LED device by label |
| 42 | * |
| 43 | * @label: LED label to look up |
| 44 | * @devp: Returns the associated device, if found |
Simon Glass | fb8a5ff | 2015-07-06 12:54:33 -0600 | [diff] [blame] | 45 | * @return 0 if found, -ENODEV if not found, other -ve on error |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 46 | */ |
| 47 | int led_get_by_label(const char *label, struct udevice **devp); |
| 48 | |
| 49 | /** |
Simon Glass | ddae9fc | 2017-04-10 11:34:54 -0600 | [diff] [blame^] | 50 | * led_set_state() - set the state of an LED |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 51 | * |
| 52 | * @dev: LED device to change |
Simon Glass | ddae9fc | 2017-04-10 11:34:54 -0600 | [diff] [blame^] | 53 | * @state: LED state to set |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 54 | * @return 0 if OK, -ve on error |
| 55 | */ |
Simon Glass | ddae9fc | 2017-04-10 11:34:54 -0600 | [diff] [blame^] | 56 | int led_set_state(struct udevice *dev, enum led_state_t state); |
Simon Glass | 5917112 | 2015-06-23 15:38:45 -0600 | [diff] [blame] | 57 | |
| 58 | #endif |