Skip to content

drivers: led: lp596x controller#105246

Open
mrrosen-cpi wants to merge 2 commits intozephyrproject-rtos:mainfrom
mrrosen-cpi:mrrosen/lp586x
Open

drivers: led: lp596x controller#105246
mrrosen-cpi wants to merge 2 commits intozephyrproject-rtos:mainfrom
mrrosen-cpi:mrrosen/lp586x

Conversation

@mrrosen-cpi
Copy link
Copy Markdown

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

@github-actions
Copy link
Copy Markdown

Hello @mrrosen-cpi, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@zephyrbot zephyrbot added platform: TI SimpleLink Texas Instruments SimpleLink MCU area: LED Label to identify LED subsystem area: Devicetree Binding PR modifies or adds a Device Tree binding labels Mar 11, 2026
LOG_ERR("read dev_config3 failed");
return ret;
}
val = (val & 0xF1) | current_val;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subjective readability nit, feel free to disregard or implement differently

Suggested change
val = (val & 0xF1) | current_val;
val = (val & 0xF1) | current_val;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is this mask maybe worth moving to a named define?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaned up; and did make the mask a macro

return ret;
}

uint8_t current_val = (config->max_current & 0x7) << 1;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

@pdgendt pdgendt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +216 to +228
#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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the name id does not appear to be used? You could opt to make a single lp586x compatible.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@zephyrbot zephyrbot added the area: Tests Issues related to a particular existing or missing test label Mar 12, 2026
@zephyrbot zephyrbot requested a review from nashif March 12, 2026 16:13
pdgendt
pdgendt previously approved these changes Mar 12, 2026
@mrrosen-cpi
Copy link
Copy Markdown
Author

I am a bit confused about the compliance check failing since it seems to point to a file this PR doesn't touch?

@pdgendt
Copy link
Copy Markdown
Contributor

pdgendt commented Mar 13, 2026

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.

- 10
- 11
description: |
Number of lines connected to the device.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, forgot to do that. All of them now should be addressed

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mrrosen-cpi mrrosen-cpi force-pushed the mrrosen/lp586x branch 2 times, most recently from e5bd52e to 13e1fc4 Compare March 28, 2026 02:05
@mrrosen-cpi
Copy link
Copy Markdown
Author

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>
@sonarqubecloud
Copy link
Copy Markdown

@pdgendt
Copy link
Copy Markdown
Contributor

pdgendt commented Mar 30, 2026

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.

clang-format isn't enforced in CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Devicetree Binding PR modifies or adds a Device Tree binding area: LED Label to identify LED subsystem area: Tests Issues related to a particular existing or missing test platform: TI SimpleLink Texas Instruments SimpleLink MCU

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants