leds/powernv: Add driver for PowerNV platform
Quoted 8 lines · Vasant Hegde
Quoted 2 lines · Jacek Anaszewski
Hi Vasant,
Jacek,
Thanks for the review.
You are welcome.
Quoted 39 lines
Quoted 17 lines
Thanks for the update.
Quoted 14 lines · Vasant Hegde
This patch implements LED driver for PowerNV platform using the existing generic LED class framework.
PowerNV platform has below type of LEDs:
- System attention
Indicates there is a problem with the system that needs
attention.
- Identify
Helps the user locate/identify a particular FRU or resource
in the system.
- Fault
Indicates there is a problem with the FRU or resource at the location with which the indicator is associated.Quoted 4 lines
Quoted 2 lines
We registers classdev structures for all individual LEDs detected on the
s/registers/register
Fixed.
Quoted 9 lines
Quoted 9 lines
system through LED specific device tree nodes. Device tree nodes specify what all kind of LEDs present on the same location code.It registers LED classdev structure for each of them.
All the system LEDs can be found in the same regular path
/sys/class/leds/. We don't use LED colors. Hence our LEDs have names in this format.Quoted 5 lines
Quoted 1 line
<location_code>:<ATTENTION|IDENT|FAULT>
I think that powernv prefix should be also present in the beginning. What would be the format of <
location_code> ? Does it identify a LED uniquely.
Quoted 8 lines
Location code is unique and its guaranteed that we don't clash here. Also this is platform specific LEDs and I don't see any value by prefixing "powernv". Hence I think its fine with current format.
Sample location code : U78C9.001.RST0027-P1-C1
Here "U78C9.001.RST0027" represents the system model
P1 - Planar 1
C1 - Card 1
I consulted ePAPR standard and all the characters used for location code are allowed. Nonetheless AFAIK no existing bindings use uppercase for node name.
We will need DT maintainer's ack here too, so cc DT list. Please CC [email protected] next time, especially for DT documentation patch.
Quoted 13 lines
.../...
Quoted 10 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+led { + compatible = "ibm,opal-v3-led"; + phandle = <0x1000006b>; + linux,phandle = <0x1000006b>; + led-mode = "lightpath"; + + U78C9.001.RST0027-P1-C1 {DT node names should be in lowercase form.
Is U78C9.001.RST0027-P1-C1 a location code?
Quoted 9 lines
Yes ... Node presents the location code.. Platform provides these location code in upper case. Hence our OPAL firmware exposes them in upper case.
Quoted 5 lines
Quoted 5 lines
(quoted diff) +4
-0+ led-types = "identify", "fault"; + led-loc = "descendent"; + phandle = <0x1000006f>; + linux,phandle = <0x1000006f>;
I think that all these properties will not be needed.
Quoted 16 lines
Quoted 9 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+ }; + ... + ... +}; + + +'compatible' property describes LEDs compatibility.compatible doesn't need to be mentioned here.
Removed.
Quoted 4 lines
Quoted 3 lines
+'led-mode' property describes service indicator mode (lightpath/guidinglight).
Quoted 6 lines
Quoted 1 line
You don't parse this in the driver? What is its purpose?
As mentioned in other thread, currently our driver doesn't parse this. (As mode is provided by platform and its static).
Do you want me to elaborate this property here?
I don't think so. At least for now :)
Quoted 17 lines
.../...
Quoted 6 lines
Quoted 6 lines
(quoted diff) +3
-0+ +/* + * By default unload path resets all the LEDs. But on PowerNVplatform
+ * we want to retain LED state across reboot as these are controlled byQuoted 8 lines
Quoted 5 lines
+ * firmware. Also service processor can modify the LEDs independent of
+ * OS. Hence avoid resetting LEDs in unload path.
+ */
+static boolled_disabled;I think that we have to make it configurable from the Device Tree level. There could be a 'retain-state-removed' property introduced.
Quoted 2 lines
Hmmm.. In my case, LED behavior is not going to change. Hence I don't think we need this property.
Can you guarantee that the next version of the platform will have also the same requirements? What if it would be made available to choose that the LEDs are software-only controlled?
If these are unjustified doubts, I'm ok with leaving the static variable.
Quoted 50 lines
Quoted 4 lines
There is also another implication - you define
LED_CORE_SUSPENDRESUMEflag. With current approach it wouldn't turn the led off on suspend. Please either drop the flag or assure correct behaviour on suspend.I will drop this.
Quoted 3 lines
You can also make this configurable like retain-state-suspended property in
Documentation/devicetree/bindings/leds/leds-gpio.txt..../...
Quoted 11 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+ + if (powernv_get_loc_code(led_type, loc_code) != 0) + goto out_loc; + + /* Prepare for the OPAL call */ + max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX); + led_mask = OPAL_SLOT_LED_STATE_ON << led_type; + if (value) + led_value = OPAL_SLOT_LED_STATE_ON << led_type;led_value = led_mask;Fixed.
.../...
Quoted 6 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ +/* Schedule work to update LED state */ +static void powernv_led_set_queue(struct led_classdev *led_cdev, + enum led_brightness value, u64 led_type)It doesn't set any queue. It should be
powernv_brightness_set.Make sense. Fixed.
.../...
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* Create the name for classdev */ + switch (led_type) { + case OPAL_SLOT_LED_TYPE_ATTN: + powernv_led->cdev.name = kasprintf(GFP_KERNEL, + "%s%s", node->name, + POWERNV_LED_ATTN);LED name should be taken from
of_nodename or label property directly. Please refer to the other LED class drivers.
Quoted 7 lines
Hmmm.. Our current FW provides led-types property which tells available type for given location code..
like
led-types = "identify" "fault"..Can I use this ? So the names will be
<location_code>:<identify|fault|attention>
I adressed this in the other message.
Quoted 2 lines
And if this approach fine, I can fix (assuming maintainer agrees :-) ) firmware side to change identify -> ident.
Let's leave it. It seems to be platform specific.
Signature · 2 lines
Best Regards, Jacek Anaszewski
Quoted 5 lines · Jacek Anaszewski
Quoted 5 lines · Vasant Hegde
Quoted 2 lines · Jacek Anaszewski
Hi Vasant,
Jacek,
.../...
Quoted 15 lines
Quoted 15 lines
Quoted 10 lines
Quoted 6 lines
All the system LEDs can be found in the same regular path
/sys/class/leds/. We don't use LED colors. Hence our LEDs have names in this format.<location_code>:<ATTENTION|IDENT|FAULT>
I think that powernv prefix should be also present in the beginning. What would be the format of <
location_code> ? Does it identify a LED uniquely.Location code is unique and its guaranteed that we don't clash here. Also this is platform specific LEDs and I don't see any value by prefixing "powernv". Hence I think its fine with current format.
Quoted 9 lines
Quoted 4 lines
Sample location code : U78C9.001.RST0027-P1-C1
Here "U78C9.001.RST0027" represents the system model
P1 - Planar 1
C1 - Card 1I consulted ePAPR standard and all the characters used for location code are allowed. Nonetheless AFAIK no existing bindings use uppercase for node name.
These are PowerNV platform specific properties..
Quoted 5 lines
We will need DT maintainer's ack here too, so cc DT list. Please CC [email protected] next time, especially for DT documentation patch.
Sure. Next time I will CC DT mailing list.
@Ben,
Any comments?
Quoted 18 lines
Quoted 18 lines
.../...
Quoted 10 lines
Review
Quoted 7 lines
(quoted diff) +7
-0+led { + compatible = "ibm,opal-v3-led"; + phandle = <0x1000006b>; + linux,phandle = <0x1000006b>; + led-mode = "lightpath"; + + U78C9.001.RST0027-P1-C1 {DT node names should be in lowercase form.
Is U78C9.001.RST0027-P1-C1 a location code?Yes ... Node presents the location code.. Platform provides these location code in upper case. Hence our OPAL firmware exposes them in upper case.
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ led-types = "identify", "fault"; + led-loc = "descendent"; + phandle = <0x1000006f>; + linux,phandle = <0x1000006f>;I think that all these properties will not be needed.
These properties are coming from our firmware which is static.
phandle property is default .. which is required to uniquely identify node inside DT.
led-loc property is not used today. If its not going to be used forever then I can request
FW folks to remove it later.
Quoted 17 lines
Quoted 17 lines
Quoted 10 lines
Review
Quoted 8 lines
(quoted diff) +7
-0+ }; + ... + ... +}; + + +'compatible' property describes LEDs compatibility.compatible doesn't need to be mentioned here.
Removed.
Quoted 4 lines
Quoted 3 lines
+'led-mode' property describes service indicator mode (lightpath/guidinglight).
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
You don't parse this in the driver? What is its purpose?
As mentioned in other thread, currently our driver doesn't parse this. (As mode is provided by platform and its static).
Do you want me to elaborate this property here?
I don't think so. At least for now :)
Ok.
Quoted 18 lines
Quoted 18 lines
.../...
Quoted 14 lines
Quoted 11 lines
(quoted diff) +3
-0+ +/* + * By default unload path resets all the LEDs. But on PowerNVplatform
+ * we want to retain LED state across reboot as these are controlled by
+ * firmware. Also service processor can modify the LEDs independent of
+ * OS. Hence avoid resetting LEDs in unload path.
+ */
+static boolled_disabled;I think that we have to make it configurable from the Device Tree level. There could be a 'retain-state-removed' property introduced.
Quoted 6 lines
Quoted 2 lines
Hmmm.. In my case, LED behavior is not going to change. Hence I don't think we need this property.
Can you guarantee that the next version of the platform will have also the same requirements? What if it would be made available to choose that the LEDs are software-only controlled?
This design exists for ages.. IMO if we change this to software control (or dynamic property which can be changed during runtime) then it completely defeats the LED purpose. Hence I don't think it will change anytime.
Quoted 62 lines
If these are unjustified doubts, I'm ok with leaving the static variable.
Quoted 50 lines
Quoted 4 lines
There is also another implication - you define
LED_CORE_SUSPENDRESUMEflag. With current approach it wouldn't turn the led off on suspend. Please either drop the flag or assure correct behaviour on suspend.I will drop this.
Quoted 3 lines
You can also make this configurable like retain-state-suspended property in
Documentation/devicetree/bindings/leds/leds-gpio.txt..../...
Quoted 11 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+ + if (powernv_get_loc_code(led_type, loc_code) != 0) + goto out_loc; + + /* Prepare for the OPAL call */ + max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX); + led_mask = OPAL_SLOT_LED_STATE_ON << led_type; + if (value) + led_value = OPAL_SLOT_LED_STATE_ON << led_type;led_value = led_mask;Fixed.
.../...
Quoted 6 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ +/* Schedule work to update LED state */ +static void powernv_led_set_queue(struct led_classdev *led_cdev, + enum led_brightness value, u64 led_type)It doesn't set any queue. It should be
powernv_brightness_set.Make sense. Fixed.
.../...
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ /* Create the name for classdev */ + switch (led_type) { + case OPAL_SLOT_LED_TYPE_ATTN: + powernv_led->cdev.name = kasprintf(GFP_KERNEL, + "%s%s", node->name, + POWERNV_LED_ATTN);LED name should be taken from
of_nodename or label property directly. Please refer to the other LED class drivers.Quoted 7 lines
Hmmm.. Our current FW provides led-types property which tells available type for given location code..
like
led-types = "identify" "fault"..Can I use this ? So the names will be
<location_code>:<identify|fault|attention>
Quoted 6 lines
I adressed this in the other message.
Quoted 2 lines
And if this approach fine, I can fix (assuming maintainer agrees :-) ) firmware side to change identify -> ident.
Let's leave it. It seems to be platform specific.
Sure.
Thanks!
-Vasant