-
Notifications
You must be signed in to change notification settings - Fork 916
Add Support for LTC3208 #3022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Support for LTC3208 #3022
Conversation
47e5181 to
d2fada2
Compare
edelweiseescala
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, just sharing what I've learned so far
d2fada2 to
57ca070
Compare
|
Changelog V2:
|
57ca070 to
999b8f4
Compare
999b8f4 to
20cc126
Compare
|
Changelog V3:
|
| if (ret) { | ||
| dev_err(&client->dev, "Error Writing brightness to register %u\n", reg); | ||
| return ret; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I would just return regmap()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exposed to user space by brightness set and is not used in the probe function, if so should I still remove this dev_err?
20cc126 to
e3af1f6
Compare
|
Changelog V4:
leds-ltc3208.c
|
5d8624c to
6e8165c
Compare
|
Changelog V4.1:
|
machschmitt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jcroleda,
Some additional comments. Take these with a grain of salt (specially the one about led_trigger) as I'm not experienced with the LEDs subsystem.
Besides those, I suggest to drop the "LTC3208:" part of the
"dt-bindings: leds: LTC3208: Document LTC3208 Multidisplay LED Driver"
commit title. LTC3208 has not been added to the kernel yet.
| ret = ltc3208_update_options(data, en_rgbs, dis_camhl, | ||
| dropdis_rgb_aux4, cpo_mode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the LED subsystem. Though, I wonder if we can have the ENRGBS pin functionality better supported as a led_trigger. Main idea is, we add/register a struct led_trigger, setting its name, activate/deactivate callbacks, and any other required fields. With the proper configuration, we should be able to get /sys/class/leds/<led>/shot provided to user space (see Documentation/ABI/testing/sysfs-class-led-trigger-oneshot and Documentation/ABI/testing/sysfs-class-led). There could be one trigger for RGB toggle and one for SUB toggle. The trigger activate/deactive handlers would write the proper REGG bit G1, then pulse the connected GPIO (see the comment about the dt property).
Not sure how much of the above actually makes sense so you might look for somebody more experienced with the LED subsystem if things don't fit well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, if this gets too complicated or time consuming, it might be reasonable to assume ENRGBS is always high and not mess around with that on the initial support for LTC3208.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having seperate oneshot triggers for each channel might introduce specific conflicts on the use of the pin (ex. Sub trigger -> RGB trigger before oneshot period is over, will override the Sub trigger as it will switch control of ENRGBS).
However, we could add a general GPIO pin support to provide sysfs access of the pin, and possibly support the same for the CAMHL pin as it serves a similar toggle function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that can be avoided by locking a mutex on LTC3208 driver, no? Lock a mutex at the beginning of SUB trigger handler (before writing the ENRGBS config), unlock the mutex at the end of the handler. Same logic (and lock) for the RGB trigger handler.
Add Documentation for LTC3208 Multidisplay LED Driver. Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
Kernel driver implementation for LTC3208 Multidisplay LED Driver Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
Add entry to Kconfig for LTC3208 driver Signed-off-by: Jan Carlo Roleda <jancarlo.roleda@analog.com>
6e8165c to
0a738c7
Compare
|
Changelog V5:
|
machschmitt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jcroleda,
Third round of review.
| const: 0 | ||
|
|
||
| enrgbs-gpios: | ||
| $ref: /schemas/types.yaml#/definitions/phandle-array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually not needed to reference the phandle-array type. I'd just drop that.
Also, add maxItems: 1
| the SUB channel (if adi,cfg-enrgbs-pin is set). | ||
|
|
||
| camhl-gpios: | ||
| $ref: /schemas/types.yaml#/definitions/phandle-array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| ret = gpiod_get_value(data->enrgbs_gpio); | ||
| return sysfs_emit(buf, "%d\n", ret); | ||
| } | ||
| static DEVICE_ATTR_RW(enrgbs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this can be better supported as some sort of triggerable led. Note this is adding a new interface between the kernel and user space and, if accepted, will very likely need to be documented (e.g. Documentation/ABI/testing/sysfs-class-led-driver-lm3533).
| ret = gpiod_get_value(data->camhl_gpio); | ||
| return sysfs_emit(buf, "%d\n", ret); | ||
| } | ||
| static DEVICE_ATTR_RW(camhl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for this one
| enum ltc3208_aux_channel aux_3, enum ltc3208_aux_channel aux_4) | ||
| { | ||
| struct regmap *map = dev->map; | ||
| u8 val = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to initialize val to zero if it is going to be assigned right below
| struct ltc3208_dev *data; | ||
| struct regmap *map; | ||
| struct ltc3208_led *leds; | ||
| enum ltc3208_aux_channel aux_channels[LTC3208_NUM_AUX_LEDS]; | ||
| enum ltc3208_cpo_mode cpo_mode; | ||
| int ret, i; | ||
| u32 val; | ||
| bool en_rgbs, dis_camhl, dropdis_rgb_aux4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the local variable heres follow reverse xmas tree ordering?
| if (!device_property_read_u32(&client->dev, | ||
| "adi,force-cpo-level", &val)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Description
PR Type
PR Checklist