drivers: led: lp596x controller#105246
drivers: led: lp596x controller#105246mrrosen-cpi wants to merge 2 commits intozephyrproject-rtos:mainfrom
Conversation
|
Hello @mrrosen-cpi, and thank you very much for your first pull request to the Zephyr project! |
drivers/led/lp586x.c
Outdated
| LOG_ERR("read dev_config3 failed"); | ||
| return ret; | ||
| } | ||
| val = (val & 0xF1) | current_val; |
There was a problem hiding this comment.
Subjective readability nit, feel free to disregard or implement differently
| val = (val & 0xF1) | current_val; | |
| val = (val & 0xF1) | current_val; | |
There was a problem hiding this comment.
Also, is this mask maybe worth moving to a named define?
There was a problem hiding this comment.
Cleaned up; and did make the mask a macro
drivers/led/lp586x.c
Outdated
| return ret; | ||
| } | ||
|
|
||
| uint8_t current_val = (config->max_current & 0x7) << 1; |
There was a problem hiding this comment.
Not sure if this definition should be moved to the top (i.e. start of the scope). I cannot remember where to find the rule so please do correct me if I'm wrong
There was a problem hiding this comment.
Ive seen other parts of the Zephyr code define local variables mid-function and I cant find anywhere in the style guide where it asks for them all to be defined at the top of the function either. But, after I did a minor cleanup on this part of the code, I ended up doing that anyway
There was a problem hiding this comment.
This is a common practice followed by the Linux kernel. The Zephyr LED code follow it too. Please, move this variable declaration at the top of the function.
e9e769d to
41c7f79
Compare
pdgendt
left a comment
There was a problem hiding this comment.
Splitting the compatibles as is done now might be a bit overkill, but non-blocking.
Please add nodes to tests/drivers/build_all/led/app.overlay so they are built in CI.
| #define LP586X_DEVICE(n, id) \ | ||
| static const struct lp586x_config lp##id##_config_##n = { \ | ||
| .i2c = I2C_DT_SPEC_INST_GET(n), \ | ||
| .enable = GPIO_DT_SPEC_INST_GET_OR(n, enable_gpios, {0}), \ | ||
| .data_mode = DT_INST_PROP_OR(n, data_mode, 1) - 1, \ | ||
| .num_lines = DT_INST_PROP(n, num_lines), \ | ||
| .num_channels = DT_INST_PROP(n, num_channels), \ | ||
| .channels_per_led = DT_INST_PROP(n, channels_per_led), \ | ||
| .max_current = LP586X_MAX_CURRENT_UA_CONVERT(DT_INST_PROP(n, max_current_ua)), \ | ||
| }; \ | ||
| \ | ||
| DEVICE_DT_INST_DEFINE(n, lp586x_led_init, NULL, NULL, &lp##id##_config_##n, POST_KERNEL, \ | ||
| CONFIG_LED_INIT_PRIORITY, &lp586x_led_api); |
There was a problem hiding this comment.
Other than the name id does not appear to be used? You could opt to make a single lp586x compatible.
There was a problem hiding this comment.
Most other LED drivers follow this pattern from what I saw if there are any differences in the family. In this case, the number of lines is family-dependent (up to 11 or up to 6, others in the family have different limits); so it somewhat depends on whether we want to have the build system enforce checks to make sure developers setup their devicetrees correctly, or just let the binding allow the maximum the family allows and if the devicetree is wrong for the particular part on their board, then it will silently compile and only fail if an application attempts to drive an LED that "doesnt exist." I dont disagree that the differences are very minor (thus the combined driver), and if there is a way to have a "ti,lp586x" compatible that can also enforce the line limits, that would be fine (I dont recall if something like "ti,lp5860", "ti,lp586x" as multiple compatibles would work, its not super pretty either but a common pattern). Just thought this was the cleanest and most consistent but if we dont like this pattern, we could make a single compatible.
41c7f79 to
d958054
Compare
|
I am a bit confused about the compliance check failing since it seems to point to a file this PR doesn't touch? |
I'm assuming this was fixed in #105389, please rebase. |
d958054 to
8925e1a
Compare
dts/bindings/led/ti,lp5860.yaml
Outdated
| - 10 | ||
| - 11 | ||
| description: | | ||
| Number of lines connected to the device. |
There was a problem hiding this comment.
default value needs to be justified
https://docs.zephyrproject.org/latest/build/dts/bindings-upstream.html#rules-for-default-values
comment applies to the whole PR
There was a problem hiding this comment.
Apologies, forgot to do that. All of them now should be addressed
There was a problem hiding this comment.
Pull request overview
Initial addition of a Zephyr LED controller driver and devicetree bindings for the TI LP586x LED matrix family (LP5860/LP5866) over I2C, plus enabling it in build-all LED tests.
Changes:
- Add LP586x driver implementation (
drivers/led/lp586x.c) and hook it into Kconfig/CMake. - Add devicetree bindings for LP586x common + per-part (LP5860/LP5866).
- Extend the LED build-all test overlay with LP5860/LP5866 nodes.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/drivers/build_all/led/app.overlay | Adds LP5860/LP5866 test nodes on the build-all I2C bus. |
| dts/bindings/led/ti,lp586x.yaml | Common LP586x binding properties (I2C + LED controller). |
| dts/bindings/led/ti,lp5866.yaml | LP5866-compatible binding including LP586x common properties. |
| dts/bindings/led/ti,lp5860.yaml | LP5860-compatible binding including LP586x common properties. |
| drivers/led/lp586x.c | New LP586x LED driver (init + brightness/color setting). |
| drivers/led/Kconfig.lp586x | New Kconfig option to enable LP586x driver. |
| drivers/led/Kconfig | Sources the new LP586x Kconfig fragment. |
| drivers/led/CMakeLists.txt | Builds lp586x.c when CONFIG_LP586X is enabled. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e5bd52e to
13e1fc4
Compare
|
There seems to be a conflict between clang-format and the compliance check for line 232. I tried to fix it in the cleanest way possible but unsure if its alright from style perspective. |
Initial implementation of TI LP586x family of LED Matrix drivers. Include devices LP5860 and LP6866 over I2C. Signed-off-by: Michael Rosen <michael.rosen@chargepoint.com>
Add LP586x family devices (LP5860 and LP866) to build_all led test. Signed-off-by: Michael Rosen <michael.rosen@chargepoint.com>
13e1fc4 to
7d41f90
Compare
|
|



Initial implementation of TI LP586x family of LED Matrix drivers. Include devices LP5860 and LP6866 over I2C.