Skip to contentSkip to conversation

LED interface for PowerNV platform

PATCH Superseded Vasant Hegde 3 participants 7 messages Mar 8, 2015 – Mar 20, 2015

Subsystems (2)

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

cover LED interface for PowerNV platform

The following series implements LED driver for PowerNV platform.

PowerNV platform has below type of indicators:
- System attention indicator (Check log indicator)
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/led' node in device tree to enabled LED driver. And we use OPAL API's to get/set LEDs.

patch 1/2: PowerNV architecture specific code. This adds necessary
OPAL APIs.
patch 2/2 is actual LED driver implemenation for PowerNV platform.

TODO:
- Add support for System Attention Indicator
---
Anshuman Khandual (2):
powerpc/powernv: Add OPAL interfaces for accessing and modifying system LED states leds/powernv: Add driver for PowerNV platform

 arch/powerpc/include/asm/opal.h                |   19 +
 arch/powerpc/platforms/powernv/opal-wrappers.S |    2 
 arch/powerpc/platforms/powernv/opal.c          |   12 
 drivers/leds/Kconfig                           |    9 
 drivers/leds/Makefile                          |    1 
 drivers/leds/leds-powernv.c                    |  599 ++++++++++++++++++++++++
 6 files changed, 635 insertions(+), 7 deletions(-)
 create mode 100644 drivers/leds/leds-powernv.c

--
Vasant
Signature

#1 lore raw

PATCH 1/2 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.h                |   19 +++++++++++++------
 arch/powerpc/platforms/powernv/opal-wrappers.S |    2 ++
 2 files changed, 15 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/opal.h +13 -6
index 9ee0a30..462ee59 100644
@@ -169,6 +169,8 @@ struct opal_sg_list {
 #define OPAL_IPMI_SEND				107
 #define OPAL_IPMI_RECV				108
 #define OPAL_I2C_REQUEST			109
+#define OPAL_LEDS_GET_INDICATOR			114
+#define OPAL_LEDS_SET_INDICATOR			115
 
 /* Device tree flags */
 
@@ -380,14 +382,14 @@ enum OpalPciMaskAction {
 };
 
 enum OpalSlotLedType {
-	OPAL_SLOT_LED_ID_TYPE = 0,
-	OPAL_SLOT_LED_FAULT_TYPE = 1
+	OPAL_SLOT_LED_TYPE_ID = 0,	/* IDENTIFY LED */
+	OPAL_SLOT_LED_TYPE_FAULT = 1,	/* FAULT LED */
+	OPAL_SLOT_LED_TYPE_MAX = 2
 };
 
-enum OpalLedAction {
-	OPAL_TURN_OFF_LED = 0,
-	OPAL_TURN_ON_LED = 1,
-	OPAL_QUERY_LED_STATE_AFTER_BUSY = 2
+enum OpalSlotLedState {
+	OPAL_SLOT_LED_STATE_OFF = 0,	/* LED is OFF */
+	OPAL_SLOT_LED_STATE_ON = 1	/* LED is ON */
 };
 
 enum OpalEpowStatus {
@@ -931,6 +933,11 @@ int64_t opal_ipmi_recv(uint64_t interface, struct opal_ipmi_msg *msg,
 		uint64_t *msg_len);
 int64_t opal_i2c_request(uint64_t async_token, uint32_t bus_id,
 			 struct opal_i2c_request *oreq);
+int64_t opal_leds_get_ind(char *loc_code, u64 *led_mask,
+			  u64 *led_value, u64 *max_led_type);
+int64_t opal_leds_set_ind(uint64_t token, char *loc_code, const u64 led_mask,
+			  const u64 led_value, u64 *max_led_type);
+
 
 /* Internal functions */
 extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
arch/powerpc/platforms/powernv/opal-wrappers.S +2 -0
index 0509bca..86f2acf 100644
@@ -292,3 +292,5 @@ OPAL_CALL(opal_tpo_read,			OPAL_READ_TPO);
 OPAL_CALL(opal_ipmi_send,			OPAL_IPMI_SEND);
 OPAL_CALL(opal_ipmi_recv,			OPAL_IPMI_RECV);
 OPAL_CALL(opal_i2c_request,			OPAL_I2C_REQUEST);
+OPAL_CALL(opal_leds_get_ind,			OPAL_LEDS_GET_INDICATOR);
+OPAL_CALL(opal_leds_set_ind,			OPAL_LEDS_SET_INDICATOR);
Acked-by Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] 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 5 lines

(1) OPAL_LEDS_GET_INDICATOR opal_leds_get_ind
(2) OPAL_LEDS_SET_INDICATOR opal_leds_set_ind

I also just merged the skiboot side of these calls.

(well, it boots, interacts with firmware. I didn't go and look at the LEDs themselves).

#3 lore raw

Re: [PATCH 1/2] powerpc/powernv: Add OPAL interfaces for accessing and modifying system LED states

In reply to Vasant Hegde
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 7 lines

(1) OPAL_LEDS_GET_INDICATOR opal_leds_get_ind
(2) OPAL_LEDS_SET_INDICATOR opal_leds_set_ind

---
 arch/powerpc/include/asm/opal.h                |   19 +++++++++++++------

We've split opal.h in next.

Can you please rebase on top of it:

https://git.kernel.org/cgit/linux/kernel/git/mpe/linux.git/log/?h=next

cheers

#4 lore raw

Re: [PATCH 1/2] powerpc/powernv: Add OPAL interfaces for accessing and modifying system LED states

Quoted 17 lines · Michael Ellerman
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 7 lines

(1) OPAL_LEDS_GET_INDICATOR opal_leds_get_ind
(2) OPAL_LEDS_SET_INDICATOR opal_leds_set_ind

---
 arch/powerpc/include/asm/opal.h                |   19 +++++++++++++------
Quoted 5 lines

We've split opal.h in next.

Can you please rebase on top of it:

https://git.kernel.org/cgit/linux/kernel/git/mpe/linux.git/log/?h=next

Sure.. will rebase and send v2 soon.

-Vasant

#5 lore raw

PATCH 2/2 leds/powernv: Add driver for PowerNV platform

In reply to Vasant Hegde

From: Anshuman Khandual <[email protected]>

This patch implements LED driver for PowerNV platform using the existing generic LED class framework. It registers 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.

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.

As per the LED class framework, the 'brightness_set' function should not sleep. Hence these functions have been implemented through global work queue tasks which might sleep on OPAL async call completion.

All the system LEDs can be found in the same regular path /sys/class/leds/. There are two different kind of LEDs present for the same location code, one being the identify indicator and other one being the fault indicator. We don't use LED colors. Hence our LEDs have names in this format.

<location_code>:<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 for any turned off LED.

---
 arch/powerpc/platforms/powernv/opal.c |   12 +
 drivers/leds/Kconfig                  |    9 
 drivers/leds/Makefile                 |    1 
 drivers/leds/leds-powernv.c           |  599 +++++++++++++++++++++++++++++++++
 4 files changed, 620 insertions(+), 1 deletion(-)
 create mode 100644 drivers/leds/leds-powernv.c
arch/powerpc/platforms/powernv/opal.c +11 -1
index 18fd4e7..a2cad1d 100644
@@ -743,7 +743,7 @@ static void __init opal_irq_init(struct device_node *dn)
 
 static int __init opal_init(void)
 {
-	struct device_node *np, *consoles;
+	struct device_node *np, *consoles, *led;
 	int rc;
 
 	opal_node = of_find_node_by_path("/ibm,opal");
@@ -769,6 +769,13 @@ static int __init opal_init(void)
 	/* Create i2c platform devices */
 	opal_i2c_create_devs();
 
+	/* Create led platform devices */
+	led = of_find_node_by_path("/ibm,opal/led");
+	if (led) {
+		of_platform_device_create(led, "opal_led", NULL);
+		of_node_put(led);
+	}
+
 	/* Find all OPAL interrupts and request them */
 	opal_irq_init(opal_node);
 
@@ -900,3 +907,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);
drivers/leds/Kconfig +9 -0
index 25b320d..a93223c 100644
@@ -508,6 +508,15 @@ 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
+	help
+	  This option enables support for the system LEDs present on
+	  PowerNV platforms. Say 'y' to enable this support in kernel.
+	  Say 'm' enable this support as module.
+
 config LEDS_SYSCON
 	bool "LED support for LEDs on system controllers"
 	depends on LEDS_CLASS=y
drivers/leds/Makefile +1 -0
index cbba921..604ffc9 100644
@@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM)		+= leds-blinkm.o
 obj-$(CONFIG_LEDS_SYSCON)		+= leds-syscon.o
 obj-$(CONFIG_LEDS_VERSATILE)		+= leds-versatile.o
 obj-$(CONFIG_LEDS_MENF21BMC)		+= leds-menf21bmc.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 +599 -0

599 lines not on this page · raw message

Acked-by Tested-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] leds/powernv: Add driver for PowerNV platform

Quoted 21 lines · Vasant Hegde

From: Anshuman Khandual <[email protected]>

This patch implements LED driver for PowerNV platform using the existing generic LED class framework. It registers 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.

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.

As per the LED class framework, the 'brightness_set' function should not sleep. Hence these functions have been implemented through global work queue tasks which might sleep on OPAL async call completion.

All the system LEDs can be found in the same regular path /sys/class/leds/. There are two different kind of LEDs present for the same location code, one being the identify indicator and other one being the fault indicator. We don't use LED colors. Hence our LEDs have names in this format.

Quoted 8 lines

<location_code>:<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 for any turned off LED.

(well, it boots, interacts with firmware. I didn't go and look at the LEDs themselves).