1
2
3
4
5
6
7
8
9
10
11
12#ifndef __LINUX_FLASH_LEDS_H_INCLUDED
13#define __LINUX_FLASH_LEDS_H_INCLUDED
14
15#include <linux/leds.h>
16
17struct device_node;
18struct led_classdev_flash;
19
20
21
22
23
24#define LED_FAULT_OVER_VOLTAGE (1 << 0)
25#define LED_FAULT_TIMEOUT (1 << 1)
26#define LED_FAULT_OVER_TEMPERATURE (1 << 2)
27#define LED_FAULT_SHORT_CIRCUIT (1 << 3)
28#define LED_FAULT_OVER_CURRENT (1 << 4)
29#define LED_FAULT_INDICATOR (1 << 5)
30#define LED_FAULT_UNDER_VOLTAGE (1 << 6)
31#define LED_FAULT_INPUT_VOLTAGE (1 << 7)
32#define LED_FAULT_LED_OVER_TEMPERATURE (1 << 8)
33#define LED_NUM_FLASH_FAULTS 9
34
35#define LED_FLASH_SYSFS_GROUPS_SIZE 5
36
37struct led_flash_ops {
38
39 int (*flash_brightness_set)(struct led_classdev_flash *fled_cdev,
40 u32 brightness);
41
42 int (*flash_brightness_get)(struct led_classdev_flash *fled_cdev,
43 u32 *brightness);
44
45 int (*strobe_set)(struct led_classdev_flash *fled_cdev, bool state);
46
47 int (*strobe_get)(struct led_classdev_flash *fled_cdev, bool *state);
48
49 int (*timeout_set)(struct led_classdev_flash *fled_cdev, u32 timeout);
50
51 int (*fault_get)(struct led_classdev_flash *fled_cdev, u32 *fault);
52};
53
54
55
56
57
58struct led_flash_setting {
59
60 u32 min;
61
62 u32 max;
63
64 u32 step;
65
66 u32 val;
67};
68
69struct led_classdev_flash {
70
71 struct led_classdev led_cdev;
72
73
74 const struct led_flash_ops *ops;
75
76
77 struct led_flash_setting brightness;
78
79
80 struct led_flash_setting timeout;
81
82
83 const struct attribute_group *sysfs_groups[LED_FLASH_SYSFS_GROUPS_SIZE];
84};
85
86static inline struct led_classdev_flash *lcdev_to_flcdev(
87 struct led_classdev *lcdev)
88{
89 return container_of(lcdev, struct led_classdev_flash, led_cdev);
90}
91
92
93
94
95
96
97
98
99
100extern int led_classdev_flash_register(struct device *parent,
101 struct led_classdev_flash *fled_cdev);
102
103
104
105
106
107
108
109
110extern void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev);
111
112
113
114
115
116
117
118
119
120
121static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev,
122 bool state)
123{
124 if (!fled_cdev)
125 return -EINVAL;
126 return fled_cdev->ops->strobe_set(fled_cdev, state);
127}
128
129
130
131
132
133
134
135
136
137
138static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev,
139 bool *state)
140{
141 if (!fled_cdev)
142 return -EINVAL;
143 if (fled_cdev->ops->strobe_get)
144 return fled_cdev->ops->strobe_get(fled_cdev, state);
145
146 return -EINVAL;
147}
148
149
150
151
152
153
154
155
156
157
158extern int led_set_flash_brightness(struct led_classdev_flash *fled_cdev,
159 u32 brightness);
160
161
162
163
164
165
166
167
168
169
170extern int led_update_flash_brightness(struct led_classdev_flash *fled_cdev);
171
172
173
174
175
176
177
178
179
180
181extern int led_set_flash_timeout(struct led_classdev_flash *fled_cdev,
182 u32 timeout);
183
184
185
186
187
188
189
190
191
192
193extern int led_get_flash_fault(struct led_classdev_flash *fled_cdev,
194 u32 *fault);
195
196#endif
197