Skip to content

Conversation

AyushKot96
Copy link
Contributor

@AyushKot96 AyushKot96 commented May 23, 2024

Description

This PR adds a new common driver for controlling LP5521, supported by CX1825 (in-tree hardware) and LP5562

Changes

  • Introduce LP55XX LED Driver to control LP5521 and LP5562.
  • Remove old LP5562 driver files.
  • Add LP5521 support to existing croxel_cx1825.

Testing

Testing has been done using samples/drivers/led_lp5521 application on croxel_cx1825 board.

west build -b croxel_cx1825/nrf52840 samples/drivers/led_lp5521

Due to unavailability of LP5562, its testing is currently pending.

@AyushKot96 AyushKot96 force-pushed the feature-add-lp5521-led-driver branch 9 times, most recently from e41727d to 6901f20 Compare May 24, 2024 07:20
@ubieda ubieda self-requested a review May 24, 2024 11:17
@ubieda ubieda changed the title driver: led: Add driver for LP5521 drivers: led: Introduce LP5521 driver May 24, 2024
Copy link
Member

@ubieda ubieda left a comment

Choose a reason for hiding this comment

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

First pass review

@AyushKot96 AyushKot96 force-pushed the feature-add-lp5521-led-driver branch 4 times, most recently from 7594d5b to 83eaa40 Compare May 27, 2024 13:00
@AyushKot96 AyushKot96 marked this pull request as ready for review May 27, 2024 14:34
@zephyrbot zephyrbot added area: Devicetree Binding PR modifies or adds a Device Tree binding area: LED Label to identify LED subsystem platform: TI SimpleLink Texas Instruments SimpleLink MCU area: Samples Samples labels May 27, 2024
@RickBruyninckx
Copy link
Contributor

@simonguinot while we're at it, can't we just make a lp55xx driver covering all of them? (I will look Monday how much the lp55xx family shares functionality)

Thanks @RickBruyninckx. Let me know !

I glanced at the drivers made for linux and documented at TI and they have a seperate driver for each of the leddrivers but with a "leds-lp55xx-common.h" file for the generic lp55xx stuff and a common devicetree binding:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/leds/leds-lp55xx.yaml

We can do something similar right?

@ubieda
Copy link
Member

ubieda commented Jun 10, 2024

Friendly reminder: Feature Freeze for the next Release is this upcoming friday. Do you believe this PR can be targetted to get in by then, @AyushKot96 @simonguinot?

@ubieda I think it's unlikely. For now my opinion is that some of the lp55xx drivers should be merged. So if I'm correct, the lp5521 driver cannot be merged into its current form. And again I won't rush it.

There's a clear upside in refactoring these drivers into common code, as it makes it easier to maintain and catch bugs. As pointed out by @RickBruyninckx, this has been somewhat done on Linux so it's possible.

However, I disagree with this being a requirement for merging this PR, for the following reasons:

Long-story short: the benefits for getting this feature for 3.7.0 far outweigh the cost of introducing it as a separate driver now and refactoring it later.

@simonguinot @RickBruyninckx please, reconsider your stance on this.

@ubieda
Copy link
Member

ubieda commented Jun 10, 2024

@AyushKot96 please fix CI failures. Rememeber you can run these locally:

twister -p croxel_cx1825/nrf52840 -T samples

@ubieda
Copy link
Member

ubieda commented Jun 10, 2024

Because of this: this refactoring efforts naturally falls into a GH enhancement issue (which we can happily capture before merging this PR).

Issue captured: #74027

@simonguinot
Copy link
Contributor

simonguinot commented Jun 10, 2024

@simonguinot @RickBruyninckx please, reconsider your stance on this.

@ubieda I understand this feature is important for your company.

But here is my problem. I can see a lot of similarities between the lp5521 and lp5562 drivers. And I am opposed to the addition of a new driver duplicating code with an existing one if the latter can be extended. So I am trying to evaluate the cost of a such extension here and I am asking @AyushKot96 about it. I think it is a legitimate request which should have been anticipated considering that the code of the lp5521 driver has been copied from lp5562. Please note that I already raised this point two weeks ago and here is the answer I got:

Both IC's are similar but many register addresses are different. LP5562 driver wont work with LP5521.

About the registers addresses it is not accurate. I can see that most of them are identical. And I already know that the lp5562 driver won't work with the LP5521 controller in its current state. But that didn't answer my question...

@AyushKot96 is that possible to add support for the LP5521 controller to the lp5562 driver ? have you considered this option ? And why did choose to write a separate driver ?

@AyushKot96
Copy link
Contributor Author

@simonguinot @RickBruyninckx please, reconsider your stance on this.

@ubieda I understand this feature is important for your company.

But here is my problem. I can see a lot of similarities between the lp5521 and lp5562 drivers. And I am opposed to the addition of a new driver duplicating code with an existing one if the latter can be extended. So I am trying to evaluate the cost of a such extension here and I am asking @AyushKot96 about it. I think it is a legitimate request which should have been anticipated considering that the code of the lp5521 driver has been copied from lp5562. Please note that I already raised this point two weeks ago and here is the answer I got:

Both IC's are similar but many register addresses are different. LP5562 driver wont work with LP5521.

About the registers addresses it is not accurate. I can see that most of them are identical. And I already know that the lp5562 driver won't work with the LP5521 controller in its current state. But that didn't answer my question...

@AyushKot96 is that possible to add support for the LP5521 controller to the lp5562 driver ? have you considered this option ? And why did choose to write a separate driver ?

@simonguinot Upon revisiting the drivers, I came to know that I could have refactor them and make a common driver. I am prepared to address this in a separate pull request.

@bbilas
Copy link
Contributor

bbilas commented Jun 11, 2024

Hi @AyushKot96,

Thanks for contributing this driver !

I started my review but the more code I read, the more I find it very similar to the lp5562 driver. So I stop here and I reiterate my initial question: what would prevent to have a common driver for the lp5521 and lp5562 chips ? I understand that there are slight differences with some registers but they can be abstracted. Please comment.

I agree with Simon. Please create a generic lp55xx driver that will support both variants. The current solution is unacceptable to me as there is no need to have another driver which was mostly copied from the other one.

@kartben
Copy link
Contributor

kartben commented Jun 11, 2024

@simonguinot Upon revisiting the drivers, I came to know that I could have refactor them and make a common driver. I am prepared to address this in a separate pull request.

Hi @AyushKot96 - I think it's fair that the maintainer of a particular area would not want to accept new code that's duplicated if it's clear that there is a better path. That's how technical debt can quickly add up in an open source project as the promised follow-up PR may or may not ever show up (and I am by no means implying that you, in particular, won't follow up, but you get the idea).

@ubieda

However, I disagree with this being a requirement for merging this PR, for the following reasons:

First and foremost: This feature is important for us (Croxel) as it provides upstream support for a feature on our board (docs.zephyrproject.org/latest/boards/croxel/croxel_cx1825/doc/index.html) and we would highly benefit from it making it to the release.

Of course! On the other hand it's also worth pointing out it's a not unsignificant amount of code that was submitted 3-ish weeks ahead of feature freeze :) And the feedback re: trying to identify common code was mentioned very early in the review process.

The review process of a PR introducting a new driver and the refactoring of existing functional drivers into common code are very different from each other.
This suggested refactoring is not implemented for the existing LP55XX instances (main/drivers/led/lp5562.c and main/drivers/led/lp5569.c) so this PR is not breaking a pattern, nor ignoring an already filed issue. Because of this: this refactoring efforts naturally falls into a GH enhancement issue (which we can happily capture before merging this PR).

It seems to me as the lp5569 driver is vastly different from the existing LP5562, where the LP5512 one is effectively copy-pasting a lot of existing code?

@AyushKot96 AyushKot96 force-pushed the feature-add-lp5521-led-driver branch from 3e34e30 to 01f3be2 Compare June 11, 2024 10:07
@ubieda
Copy link
Member

ubieda commented Jun 11, 2024

@simonguinot @kartben Understood. We'll refactor the driver. Thanks!
CC: @AyushKot96

@AyushKot96 AyushKot96 force-pushed the feature-add-lp5521-led-driver branch from 01f3be2 to 281a4b7 Compare June 13, 2024 14:48
@AyushKot96
Copy link
Contributor Author

@simonguinot @ubieda Hey guys, I have pushed a new common driver for LP5521 and LP5562.
Please let me know your thoughts and feel free to suggest any changes you might have. Also, I have only tested this with the LP5521, as I do not have an LP5562 available at the moment.

@AyushKot96 AyushKot96 requested review from simonguinot and ubieda June 13, 2024 14:58
@AyushKot96 AyushKot96 force-pushed the feature-add-lp5521-led-driver branch 3 times, most recently from ad819fe to 6917f69 Compare June 14, 2024 06:25
- Add common driver for LP5521 and
  LP5562
- Remove LP5562 driver source and
  KConfig files
- Add sample application for LP5521

Signed-off-by: Ayush Kothari <ayush@croxel.com>
-Add LP5521 node in croxel_cx1825 board dts file
-Remove arduino_i2c and arduino_gpio from dts file
 to prevent shield sample build test

Signed-off-by: Ayush Kothari <ayush@croxel.com>
@AyushKot96 AyushKot96 force-pushed the feature-add-lp5521-led-driver branch from 6917f69 to 954a45f Compare June 15, 2024 13:01
};

arduino_i2c: &i2c0 {
&i2c0 {
Copy link
Member

Choose a reason for hiding this comment

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

Needs rebasing. This has been updated already: #74893

@ubieda
Copy link
Member

ubieda commented Aug 8, 2024

@simonguinot Seems like the refactoring has been done. Would you mind taking another look at this? Thanks

@simonguinot
Copy link
Contributor

@simonguinot Seems like the refactoring has been done. Would you mind taking another look at this? Thanks

Hello @ubieda,

I'll look at it next week.

Note that I already reviewed #72713 from @AyushKot96 last month but I didn't get any answer since... That's why I was hesitant to start the review for this PR.

@ubieda
Copy link
Member

ubieda commented Aug 8, 2024

@simonguinot Seems like the refactoring has been done. Would you mind taking another look at this? Thanks

Hello @ubieda,

I'll look at it next week.

Note that I already reviewed #72713 from @AyushKot96 last month but I didn't get any answer since... That's why I was hesitant to start the review for this PR.

Thanks! We'll come back to that one soon (it's in our backlog). CC: @cx-anuj-pathak

Copy link
Contributor

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

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

Hi @AyushKot96,

You need to help me a little here. I can't review a such big commit with everything in it, including renamed files. You need to structure the pull request with several commits. For example:

  • rename the lp5562 driver and sample into lp55xx. So I'll be able to use git to visualize the changes coming in the next commits.
  • make the driver and sample generic to prepare for adding support of the LP5521 controller. Don't be afraid to split this step into several commits as well.
  • add support for the LP5521 controller to the driver.
  • add support for the LP5521 controller to the sample.

Thanks in advance !

@cx-anuj-pathak
Copy link
Contributor

cx-anuj-pathak commented Aug 22, 2024

@simonguinot we have rearranged commits. but it went upto 14 commits, and in the process we have identified few other things too and a bug in lp5562 driver. So we have decided internally to break it down in 3-4 PR's.

Let me know if you have any suggestions?
We'll close this PR

@ubieda ubieda closed this Sep 4, 2024
@simonguinot
Copy link
Contributor

Hi @cx-anuj-pathak. Yes it seems fine to use several PRs !

@biii-anuj-pathak
Copy link

FIled a new PR #78968

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: Samples Samples area: Shields Shields (add-on boards) platform: TI SimpleLink Texas Instruments SimpleLink MCU
Projects
None yet
Development

Successfully merging this pull request may close these issues.