LED driver for PowerNV platform
Subsystems (3)
v10 cover LED driver for PowerNV platform
The following series implements LED driver for PowerNV platform.
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.
On PowerNV (Non Virtualized) platform OPAL firmware provides LED information to host via device tree (location code and LED type). During init we check for 'ibm,opal/leds' node in device tree to enable LED driver. And we use OPAL API's to get/set LEDs.
Note that on PowerNV platform firmware can activate fault LED, if it can isolate the problem. Also one can modify the LEDs using service processor interface. None of these involes kernel. Hence we retain LED state in unload path.
Sample LED device tree output:
------------------------------
leds {
compatible = "ibm,opal-v3-led";
led-mode = "lightpath";
U78C9.001.RST0027-P1-C1 {
led-types = "identify", "fault";
};
...
...
}Sample sysfs output:
--------------------
.
├── U78CB.001.WZS008R-A1:fault │ ├── brightness │ ├── device -> ../../../opal_leds │ ├── max_brightness │ ├── power │ │ ├── async │ │ ├── autosuspend_delay_ms │ │ ├── control │ │ ├── runtime_active_kids │ │ ├── runtime_active_time │ │ ├── runtime_enabled │ │ ├── runtime_status │ │ ├── runtime_suspended_time │ │ └── runtime_usage │ ├── subsystem -> ../../../../../class/leds │ ├── trigger │ └── uevent ├── U78CB.001.WZS008R-A1:identify │ ├── brightness │ ├── device -> ../../../opal_leds │ ├── max_brightness │ ├── power │ │ ├── async │ │ ├── autosuspend_delay_ms │ │ ├── control │ │ ├── runtime_active_kids │ │ ├── runtime_active_time │ │ ├── runtime_enabled │ │ ├── runtime_status │ │ ├── runtime_suspended_time │ │ └── runtime_usage │ ├── subsystem -> ../../../../../class/leds │ ├── trigger │ └── uevent
....
....
....
patch 1/2: PowerNV architecture specific code. This adds necessary
OPAL APIs.
patch 2/2: Create LED platform device and export OPAL symbols patch 3/3: Actual LED driver implemenation for PowerNV platform.
Note:
- This version of patchset is based on top of v4.2-rc7.
@Ben/Michael,
This patchset is Acked by LED subsystem maintainer (Jacek) [1] and he suggested merge it via powerpc tree [1]. Can you please review/take this patchset?
[1] https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-July/131695.html
Previous patchset:
v9: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-August/132964.html
v8: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-July/131652.html
v7: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-July/131533.html
v6: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-July/131328.html
v5: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-July/130602.html
v4: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-April/128028.html
v3: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-April/127702.html
v2: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-March/126301.html
v1: https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-March/125705.html
Changes in v10:
- Removed "led_disabled" variable initialization
- Removed ".owner = THIS_MODULE"
Changes in v9:
- Addressed minor comments from Jacek.
- Added Ack-by: Jacek
Changes in v8:
- Added powernv_led_common structure for common variables
- Removed unused variable 'value'
- Fixed locking issue
Changes in v7:
- Club powernv_led_data & powernv_leds_priv into single structure
- Removed num_leds & powernv_leds_count()
- Replaced per LED mutex with global mutex
- Removed driver specific workqueue. Instead this version uses new global workqueue.
Changes in v6:
- Added loc_code and type to powernv_led_data structure instead of parsing them from led classdev name.
- Fixed documentation issues.
- Fixed mutex_destry issue
- Replaced led_classdev_register with devm_led_classdev_register
Changes in v5:
- Rebased on top of Linus tree
- Renamed led as leds and updated documentation
- As Ben and Arnd suggested, removed phandle from documenation
- As Ben suggested removed led-loc device tree property
- As Jacek suggested, added back compatible property to documentation
Changes in v4:
- Updated macros to reflect platform.
- s/u64/__be64/g for big endian data we get from firmware
- Addressed review comments from Jacek. Major once are:
Removed list in powernv_led_data structure s/kzalloc/devm_kzalloc/
Removed compatible property from documentation
Anshuman Khandual (1):
powerpc/powernv: Add OPAL interfaces for accessing and modifying
system LED states
Vasant Hegde (2):
powerpc/powernv: Create LED platform device
leds/powernv: Add driver for PowerNV platform
.../devicetree/bindings/leds/leds-powernv.txt | 26 ++ arch/powerpc/include/asm/opal-api.h | 25 +- arch/powerpc/include/asm/opal.h | 4 + arch/powerpc/platforms/powernv/opal-wrappers.S | 2 + arch/powerpc/platforms/powernv/opal.c | 12 +- drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-powernv.c | 345 +++++++++++++++++++++ 8 files changed, 424 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/leds/leds-powernv.txt create mode 100644 drivers/leds/leds-powernv.c
Signature · 2 lines
Vasant 2.1.0
PATCH v10 1/3 powerpc/powernv: Add OPAL interfaces for accessing and modifying system LED states
From: Anshuman Khandual <[email protected]>
This patch registers the following two new OPAL interfaces calls for the platform LED subsystem. With the help of these new OPAL calls, the kernel will be able to get or set the state of various individual LEDs on the system at any given location code which is passed through the LED specific device tree nodes.
(1) OPAL_LEDS_GET_INDICATOR opal_leds_get_ind
(2) OPAL_LEDS_SET_INDICATOR opal_leds_set_ind
--- arch/powerpc/include/asm/opal-api.h | 25 ++++++++++++++++++++++++- arch/powerpc/include/asm/opal.h | 4 ++++ arch/powerpc/platforms/powernv/opal-wrappers.S | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/opal-api.h +24 -1
@@ -154,7 +154,9 @@#define OPAL_FLASH_WRITE 111#define OPAL_FLASH_ERASE 112#define OPAL_PRD_MSG 113 -#define OPAL_LAST 113 +#define OPAL_LEDS_GET_INDICATOR 114 +#define OPAL_LEDS_SET_INDICATOR 115 +#define OPAL_LAST 115/* Device tree flags */
@@ -756,6 +758,27 @@ struct opal_i2c_request {__be64 buffer_ra;/* Buffer real address */ }; +/* LED Mode */ +#define POWERNV_LED_MODE_LIGHT_PATH "lightpath" +#define POWERNV_LED_MODE_GUIDING_LIGHT "guidinglight" + +/* LED type */ +#define POWERNV_LED_TYPE_IDENTIFY "identify" +#define POWERNV_LED_TYPE_FAULT "fault" +#define POWERNV_LED_TYPE_ATTENTION "attention" + +enum OpalSlotLedType { +OPAL_SLOT_LED_TYPE_ID =0 ,/* IDENTIFY LED */ +OPAL_SLOT_LED_TYPE_FAULT =1 ,/* FAULT LED */ +OPAL_SLOT_LED_TYPE_ATTN =2 ,/* System Attention LED */ +OPAL_SLOT_LED_TYPE_MAX =3 +}; + +enum OpalSlotLedState { +OPAL_SLOT_LED_STATE_OFF =0 ,/* LED is OFF */ +OPAL_SLOT_LED_STATE_ON =1 /* LED is ON */ +}; +#endif /* __ASSEMBLY__ */ #endif /* __OPAL_API_H */
arch/powerpc/include/asm/opal.h +4 -0
@@ -195,6 +195,10 @@ int64_t opal_ipmi_recv(uint64_t interface, struct opal_ipmi_msg *msg,int64_t opal_i2c_request (uint64_t async_token,uint32_t bus_id,struct opal_i2c_request *oreq);int64_t opal_prd_msg (struct opal_prd_msg *msg); +int64_t opal_leds_get_ind (char *loc_code,__be64 *led_mask, +__be64 *led_value,__be64 *max_led_type); +int64_t opal_leds_set_ind (uint64_t token,char *loc_code,const u64 led_mask, +const u64 led_value,__be64 *max_led_type);int64_t opal_flash_read (uint64_t id,uint64_t offset,uint64_t buf,uint64_t size,uint64_t token);
arch/powerpc/platforms/powernv/opal-wrappers.S +2 -0
@@ -297,3 +297,5 @@ OPAL_CALL(opal_flash_read, OPAL_FLASH_READ); OPAL_CALL(opal_flash_write, OPAL_FLASH_WRITE); OPAL_CALL(opal_flash_erase, OPAL_FLASH_ERASE); OPAL_CALL(opal_prd_msg, OPAL_PRD_MSG); +OPAL_CALL(opal_leds_get_ind, OPAL_LEDS_GET_INDICATOR); +OPAL_CALL(opal_leds_set_ind, OPAL_LEDS_SET_INDICATOR);
Signature · 1 line
2.1.0
Re: [v10, 1/3] powerpc/powernv: Add OPAL interfaces for accessing and modifying system LED states
Quoted 8 lines · Vasant Hegde
From: Anshuman Khandual <[email protected]>
This patch registers the following two new OPAL interfaces calls for the platform LED subsystem. With the help of these new OPAL calls, the kernel will be able to get or set the state of various individual LEDs on the system at any given location code which is passed through the LED specific device tree nodes.
Quoted 8 lines
(1)
OPAL_LEDS_GET_INDICATORopal_leds_get_ind
(2)OPAL_LEDS_SET_INDICATORopal_leds_set_indSigned-off-by Anshuman Khandual <[email protected]>Signed-off-by Vasant Hegde <[email protected]>Acked-by Stewart Smith <[email protected]>Tested-by Stewart Smith <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/8a8d91817aec6b9ca7a2
cheers
PATCH v10 2/3 powerpc/powernv: Create LED platform device
In reply to Vasant HegdeThis patch adds platform devices for leds. Also export LED related OPAL API's so that led driver can use these APIs.
--- arch/powerpc/platforms/powernv/opal.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/opal.c +11 -1
@@ -648,7 +648,7 @@ static void opal_init_heartbeat(void)static int __init opal_init (void ) { -struct device_node *np, *consoles; +struct device_node *np, *consoles, *leds;int rc; opal_node =of_find_node_by_path ("/ibm,opal" );
@@ -689,6 +689,13 @@ static int __init opal_init(void)/* Setup a heatbeat thread if requested by OPAL */ opal_init_heartbeat (); +/* Create leds platform devices */ + leds =of_find_node_by_path ("/ibm,opal/leds" ); +if (leds) { +of_platform_device_create (leds,"opal_leds" ,NULL ); +of_node_put (leds); + } +/* Create "opal" kobject under /sys/firmware */ rc =opal_sysfs_init ();if (rc ==0 ) {
@@ -841,3 +848,6 @@ EXPORT_SYMBOL_GPL(opal_rtc_write);EXPORT_SYMBOL_GPL (opal_tpo_read);EXPORT_SYMBOL_GPL (opal_tpo_write);EXPORT_SYMBOL_GPL (opal_i2c_request); +/* Export these symbols for PowerNV LED class driver */ +EXPORT_SYMBOL_GPL (opal_leds_get_ind); +EXPORT_SYMBOL_GPL (opal_leds_set_ind);
Signature · 1 line
2.1.0
Re: [v10,2/3] powerpc/powernv: Create LED platform device
Quoted 5 lines · Vasant Hegde
This patch adds platform devices for leds. Also export LED related OPAL API's so that led driver can use these APIs.
Signed-off-by Vasant Hegde <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/c159b5968ec9d3cbf168
cheers
PATCH v10 3/3 leds/powernv: Add driver for PowerNV platform
In reply to Vasant HegdeThis 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.
We register classdev structures for all individual LEDs detected on the 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. We use LED node and led-types property to form LED classdev. Our LEDs have names in this format.
<location_code>:<attention|identify|fault>
Any positive brightness value would turn on the LED and a zero value would turn off the LED. The driver will return LED_FULL (255) for any turned on LED and LED_OFF (0) for any turned off LED.
The platform level implementation of LED get and set state has been achieved through OPAL calls. These calls are made available for the driver by exporting from architecture specific codes.
--- .../devicetree/bindings/leds/leds-powernv.txt | 26 ++ drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-powernv.c | 345 +++++++++++++++++++++ 4 files changed, 383 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-powernv.txt create mode 100644 drivers/leds/leds-powernv.c
Documentation/devicetree/bindings/leds/leds-powernv.txt new file +26 -0
@@ -0,0 +1,26 @@ +Device Tree binding for LEDs on IBM Power Systems +------------------------------------------------- + +Required properties: +- compatible : Should be "ibm,opal-v3-led". +- led-mode : Should be "lightpath" or "guidinglight". + +Each location code of FRU/Enclosure must be expressed in the +form of a sub-node. + +Required properties for the sub nodes: +- led-types : Supported LED types (attention/identify/fault) provided + in the form of string array. + +Example: + +leds { + compatible = "ibm,opal-v3-led"; + led-mode = "lightpath"; + + U78C9.001.RST0027-P1-C1 { + led-types = "identify", "fault"; + }; + ... + ... +};
drivers/leds/Kconfig +11 -0
@@ -560,6 +560,17 @@ config LEDS_BLINKM This option enables support for the BlinkM RGB LED connected through I2C. Say Y to enable support for the BlinkM LED. +config LEDS_POWERNV + tristate "LED support for PowerNV Platform" + depends on LEDS_CLASS + depends on PPC_POWERNV + depends on OF + help + This option enables support for the system LEDs present on + PowerNV platforms. Say 'y' to enable this support in kernel. + To compile this driver as a module, choose 'm' here: the module + will be called leds-powernv. + config LEDS_SYSCON bool "LED support for LEDs on system controllers" depends on LEDS_CLASS=y
drivers/leds/Makefile +1 -0
@@ -65,6 +65,7 @@ obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o obj-$(CONFIG_LEDS_PM8941_WLED) += leds-pm8941-wled.o obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o +obj-$(CONFIG_LEDS_POWERNV) += leds-powernv.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
drivers/leds/leds-powernv.c new file +345 -0
345 lines not on this page · raw message
Signature · 1 line
2.1.0
Re: [v10,3/3] leds/powernv: Add driver for PowerNV platform
Quoted 32 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.We register classdev structures for all individual LEDs detected on the 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. We use LED node and led-types property to form LED classdev. Our LEDs have names in this format.<location_code>:<attention|identify|fault>
Any positive brightness value would turn on the LED and a zero value would turn off the LED. The driver will return
LED_FULL(255) for any turned on LED andLED_OFF(0) for any turned off LED.The platform level implementation of LED get and set state has been achieved through OPAL calls. These calls are made available for the driver by exporting from architecture specific codes.
Quoted 5 lines
Signed-off-by Vasant Hegde <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>Acked-by Stewart Smith <[email protected]>Tested-by Stewart Smith <[email protected]>Acked-by Jacek Anaszewski <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/84ad6e5cd3e8b365c893
cheers