4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
6
7
- #define DT_DRV_COMPAT issi_is31fl3194
8
7
9
8
/**
10
9
* @file
21
20
22
21
#include <zephyr/dt-bindings/led/led.h>
23
22
24
- LOG_MODULE_REGISTER (is31fl3194 , CONFIG_LED_LOG_LEVEL );
23
+ LOG_MODULE_REGISTER (is31fl319x , CONFIG_LED_LOG_LEVEL );
25
24
26
25
#define IS31FL3194_PROD_ID_REG 0x00
27
26
#define IS31FL3194_CONF_REG 0x01
@@ -43,14 +42,14 @@ static const uint8_t led_channels[] = {
43
42
IS31FL3194_OUT3_REG
44
43
};
45
44
46
- struct is31fl3194_config {
45
+ struct is31fl319x_config {
47
46
struct i2c_dt_spec bus ;
48
47
uint8_t num_leds ;
49
48
const struct led_info * led_infos ;
50
49
const uint8_t * current_limits ;
51
50
};
52
51
53
- static const struct led_info * is31fl3194_led_to_info (const struct is31fl3194_config * config ,
52
+ static const struct led_info * is31fl319x_led_to_info (const struct is31fl319x_config * config ,
54
53
uint32_t led )
55
54
{
56
55
if (led < config -> num_leds ) {
@@ -60,12 +59,12 @@ static const struct led_info *is31fl3194_led_to_info(const struct is31fl3194_con
60
59
return NULL ;
61
60
}
62
61
63
- static int is31fl3194_get_info (const struct device * dev ,
62
+ static int is31fl319x_get_info (const struct device * dev ,
64
63
uint32_t led ,
65
64
const struct led_info * * info_out )
66
65
{
67
- const struct is31fl3194_config * config = dev -> config ;
68
- const struct led_info * info = is31fl3194_led_to_info (config , led );
66
+ const struct is31fl319x_config * config = dev -> config ;
67
+ const struct led_info * info = is31fl319x_led_to_info (config , led );
69
68
70
69
if (info == NULL ) {
71
70
return - EINVAL ;
@@ -75,11 +74,11 @@ static int is31fl3194_get_info(const struct device *dev,
75
74
return 0 ;
76
75
}
77
76
78
- static int is31fl3194_set_color (const struct device * dev , uint32_t led , uint8_t num_colors ,
77
+ static int is31fl319x_set_color (const struct device * dev , uint32_t led , uint8_t num_colors ,
79
78
const uint8_t * color )
80
79
{
81
- const struct is31fl3194_config * config = dev -> config ;
82
- const struct led_info * info = is31fl3194_led_to_info (config , led );
80
+ const struct is31fl319x_config * config = dev -> config ;
81
+ const struct led_info * info = is31fl319x_led_to_info (config , led );
83
82
int ret ;
84
83
85
84
if (info == NULL ) {
@@ -108,7 +107,7 @@ static int is31fl3194_set_color(const struct device *dev, uint32_t led, uint8_t
108
107
value = color [2 ];
109
108
break ;
110
109
default :
111
- /* unreachable: mapping already tested in is31fl3194_check_config */
110
+ /* unreachable: mapping already tested in is31fl319x_check_config */
112
111
return - EINVAL ;
113
112
}
114
113
@@ -131,10 +130,10 @@ static int is31fl3194_set_color(const struct device *dev, uint32_t led, uint8_t
131
130
return ret ;
132
131
}
133
132
134
- static int is31fl3194_set_brightness (const struct device * dev , uint32_t led , uint8_t value )
133
+ static int is31fl319x_set_brightness (const struct device * dev , uint32_t led , uint8_t value )
135
134
{
136
- const struct is31fl3194_config * config = dev -> config ;
137
- const struct led_info * info = is31fl3194_led_to_info (config , led );
135
+ const struct is31fl319x_config * config = dev -> config ;
136
+ const struct led_info * info = is31fl319x_led_to_info (config , led );
138
137
int ret = 0 ;
139
138
140
139
if (info == NULL ) {
@@ -166,7 +165,7 @@ static int is31fl3194_set_brightness(const struct device *dev, uint32_t led, uin
166
165
* Counts red, green, blue channels; returns true if color_id is valid
167
166
* and no more than one channel maps to the same color
168
167
*/
169
- static bool is31fl3194_count_colors (const struct device * dev ,
168
+ static bool is31fl319x_count_colors (const struct device * dev ,
170
169
uint8_t color_id , uint8_t * rgb_counts )
171
170
{
172
171
bool ret = false;
@@ -191,9 +190,9 @@ static bool is31fl3194_count_colors(const struct device *dev,
191
190
return ret ;
192
191
}
193
192
194
- static int is31fl3194_check_config (const struct device * dev )
193
+ static int is31fl319x_check_config (const struct device * dev )
195
194
{
196
- const struct is31fl3194_config * config = dev -> config ;
195
+ const struct is31fl319x_config * config = dev -> config ;
197
196
const struct led_info * info ;
198
197
uint8_t rgb_counts [3 ] = { 0 };
199
198
uint8_t i ;
@@ -211,7 +210,7 @@ static int is31fl3194_check_config(const struct device *dev)
211
210
}
212
211
213
212
for (i = 0 ; i < 3 ; i ++ ) {
214
- if (!is31fl3194_count_colors (dev , info -> color_mapping [i ], rgb_counts )) {
213
+ if (!is31fl319x_count_colors (dev , info -> color_mapping [i ], rgb_counts )) {
215
214
return - EINVAL ;
216
215
}
217
216
@@ -229,7 +228,7 @@ static int is31fl3194_check_config(const struct device *dev)
229
228
return - EINVAL ;
230
229
}
231
230
232
- if (!is31fl3194_count_colors (dev , info -> color_mapping [0 ], rgb_counts )) {
231
+ if (!is31fl319x_count_colors (dev , info -> color_mapping [0 ], rgb_counts )) {
233
232
return - EINVAL ;
234
233
}
235
234
}
@@ -243,15 +242,15 @@ static int is31fl3194_check_config(const struct device *dev)
243
242
return 0 ;
244
243
}
245
244
246
- static int is31fl3194_init (const struct device * dev )
245
+ static int is31fl319x_init (const struct device * dev )
247
246
{
248
- const struct is31fl3194_config * config = dev -> config ;
247
+ const struct is31fl319x_config * config = dev -> config ;
249
248
const struct led_info * info = NULL ;
250
249
int i , ret ;
251
250
uint8_t prod_id , band ;
252
251
uint8_t current_reg = 0 ;
253
252
254
- ret = is31fl3194_check_config (dev );
253
+ ret = is31fl319x_check_config (dev );
255
254
if (ret != 0 ) {
256
255
return ret ;
257
256
}
@@ -299,10 +298,10 @@ static int is31fl3194_init(const struct device *dev)
299
298
return i2c_reg_write_byte_dt (& config -> bus , IS31FL3194_CONF_REG , IS31FL3194_CONF_ENABLE );
300
299
}
301
300
302
- static DEVICE_API (led , is31fl3194_led_api ) = {
303
- .set_brightness = is31fl3194_set_brightness ,
304
- .get_info = is31fl3194_get_info ,
305
- .set_color = is31fl3194_set_color ,
301
+ static DEVICE_API (led , is31fl319x_led_api ) = {
302
+ .set_brightness = is31fl319x_set_brightness ,
303
+ .get_info = is31fl319x_get_info ,
304
+ .set_color = is31fl319x_set_color ,
306
305
};
307
306
308
307
#define COLOR_MAPPING (led_node_id ) \
@@ -319,25 +318,28 @@ static DEVICE_API(led, is31fl3194_led_api) = {
319
318
#define LED_CURRENT (led_node_id ) \
320
319
DT_PROP(led_node_id, current_limit),
321
320
322
- #define IS31FL3194_DEFINE (id ) \
321
+ #define IS31FL319X_DEVICE (n , id ) \
322
+ \
323
+ DT_INST_FOREACH_CHILD(n, COLOR_MAPPING) \
323
324
\
324
- DT_INST_FOREACH_CHILD(id, COLOR_MAPPING) \
325
+ static const struct led_info is31fl319##id##_leds_##n[] = \
326
+ { DT_INST_FOREACH_CHILD(n, LED_INFO) }; \
325
327
\
326
- static const struct led_info is31fl3194_leds_##id[] = \
327
- { DT_INST_FOREACH_CHILD(id, LED_INFO) }; \
328
- static const uint8_t is31fl3194_currents_##id[] = \
329
- { DT_INST_FOREACH_CHILD(id, LED_CURRENT) }; \
330
- BUILD_ASSERT(ARRAY_SIZE(is31fl3194_leds_##id) > 0, \
331
- "No LEDs defined for " #id); \
328
+ static const uint8_t is31fl319##id##_currents_##n[] = \
329
+ { DT_INST_FOREACH_CHILD(n, LED_CURRENT) }; \
330
+ BUILD_ASSERT(ARRAY_SIZE(is31fl319##id##_leds_##n) > 0, \
331
+ "No LEDs defined for " #n); \
332
332
\
333
- static const struct is31fl3194_config is31fl3194_config_ ##id = { \
334
- .bus = I2C_DT_SPEC_INST_GET(id ), \
335
- .num_leds = ARRAY_SIZE(is31fl3194_leds_ ##id), \
336
- .led_infos = is31fl3194_leds_ ##id, \
337
- .current_limits = is31fl3194_currents_ ##id, \
333
+ static const struct is31fl319x_config is31fl319 ##id##_config_##n = { \
334
+ .bus = I2C_DT_SPEC_INST_GET(n ), \
335
+ .num_leds = ARRAY_SIZE(is31fl319 ##id##_leds_##n), \
336
+ .led_infos = is31fl319 ##id##_leds_##n , \
337
+ .current_limits = is31fl319 ##id##_currents_##n , \
338
338
}; \
339
- DEVICE_DT_INST_DEFINE(id , &is31fl3194_init , NULL, NULL, \
340
- &is31fl3194_config_ ##id, POST_KERNEL, \
341
- CONFIG_LED_INIT_PRIORITY, &is31fl3194_led_api );
339
+ DEVICE_DT_INST_DEFINE(n , &is31fl319x_init , NULL, NULL, \
340
+ &is31fl319 ##id##_config_##n , POST_KERNEL, \
341
+ CONFIG_LED_INIT_PRIORITY, &is31fl319x_led_api );
342
342
343
- DT_INST_FOREACH_STATUS_OKAY (IS31FL3194_DEFINE )
343
+ #undef DT_DRV_COMPAT
344
+ #define DT_DRV_COMPAT issi_is31fl3194
345
+ DT_INST_FOREACH_STATUS_OKAY_VARGS (IS31FL319X_DEVICE , 4 )
0 commit comments