[U-Boot] [PATCH 3/3] net2big_v2: initialize LEDs at startup

Simon Guinot simon.guinot at sequanux.org
Mon Jun 17 22:58:04 CEST 2013


This patch allows to configure the net2big_v2 LEDs at startup (through
the GPIO extension bus). The front blue LED is enabled and the SATA rear
LEDs are configured to blink in relation with the SATA activity.

Signed-off-by: Simon Guinot <simon.guinot at sequanux.org>
---
 board/LaCie/net2big_v2/Makefile     |    3 ++
 board/LaCie/net2big_v2/net2big_v2.c |   86 +++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+)

diff --git a/board/LaCie/net2big_v2/Makefile b/board/LaCie/net2big_v2/Makefile
index fbae48e..eca25e7 100644
--- a/board/LaCie/net2big_v2/Makefile
+++ b/board/LaCie/net2big_v2/Makefile
@@ -28,6 +28,9 @@ endif
 LIB	= $(obj)lib$(BOARD).o
 
 COBJS	:= $(BOARD).o ../common/common.o
+ifneq ($(and $(CONFIG_KIRKWOOD_GPIO),$(CONFIG_NET2BIG_V2)),)
+COBJS	+= ../common/gpio-ext.o
+endif
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
diff --git a/board/LaCie/net2big_v2/net2big_v2.c b/board/LaCie/net2big_v2/net2big_v2.c
index 6cca4fb..caa9f64 100644
--- a/board/LaCie/net2big_v2/net2big_v2.c
+++ b/board/LaCie/net2big_v2/net2big_v2.c
@@ -30,6 +30,7 @@
 
 #include "net2big_v2.h"
 #include "../common/common.h"
+#include "../common/gpio-ext.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -143,6 +144,89 @@ err:
 static void init_fan(void) {}
 #endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_G762_ADDR */
 
+#if defined(CONFIG_NET2BIG_V2) && defined(CONFIG_KIRKWOOD_GPIO)
+/*
+ * GPIO extension bus:
+ *
+ * - address register : bit [0-2] -> GPIO [47-49]
+ * - data register    : bit [0-2] -> GPIO [44-46]
+ * - enable register  : GPIO 29
+ */
+static unsigned gpio_ext_addr[] = { 47, 48, 49 };
+static unsigned gpio_ext_data[] = { 44, 45, 46 };
+
+static struct gpio_ext gpio_ext = {
+	.addr		= gpio_ext_addr,
+	.num_addr	= ARRAY_SIZE(gpio_ext_addr),
+	.data		= gpio_ext_data,
+	.num_data	= ARRAY_SIZE(gpio_ext_data),
+	.enable		= 29,
+};
+
+/*
+ * LEDs configuration:
+ *
+ * The LEDs are controlled by a CPLD and can be configured through
+ * the GPIO extension bus.
+ *
+ * Address register selection:
+ *
+ * addr | register
+ * ----------------------------
+ *   0  | front LED
+ *   1  | front LED brightness
+ *   2  | SATA LED brightness
+ *   3  | SATA0 LED
+ *   4  | SATA1 LED
+ *   5  | SATA2 LED
+ *   6  | SATA3 LED
+ *   7  | SATA4 LED
+ *
+ * Data register configuration:
+ *
+ * data | LED brightness
+ * -------------------------------------------------
+ *   0  | min (off)
+ *   -  | -
+ *   7  | max
+ *
+ * data | front LED mode
+ * -------------------------------------------------
+ *   0  | fix off
+ *   1  | fix blue on
+ *   2  | fix red on
+ *   3  | blink blue on=1 sec and blue off=1 sec
+ *   4  | blink red on=1 sec and red off=1 sec
+ *   5  | blink blue on=2.5 sec and red on=0.5 sec
+ *   6  | blink blue on=1 sec and red on=1 sec
+ *   7  | blink blue on=0.5 sec and blue off=2.5 sec
+ *
+ * data | SATA LED mode
+ * -------------------------------------------------
+ *   0  | fix off
+ *   1  | SATA activity blink
+ *   2  | fix red on
+ *   3  | blink blue on=1 sec and blue off=1 sec
+ *   4  | blink red on=1 sec and red off=1 sec
+ *   5  | blink blue on=2.5 sec and red on=0.5 sec
+ *   6  | blink blue on=1 sec and red on=1 sec
+ *   7  | fix blue on
+ */
+static void init_leds(void)
+{
+	/* Enable the front blue LED */
+	gpio_ext_set_value(&gpio_ext, 0, 1);
+	gpio_ext_set_value(&gpio_ext, 1, 3);
+
+	/* Configure SATA LEDs to blink in relation with the SATA activity */
+	gpio_ext_set_value(&gpio_ext, 3, 1);
+	gpio_ext_set_value(&gpio_ext, 4, 1);
+	gpio_ext_set_value(&gpio_ext, 2, 3);
+}
+#else
+static void init_leds(void) {}
+#endif /* CONFIG_NET2BIG_V2 && CONFIG_KIRKWOOD_GPIO */
+
 int misc_init_r(void)
 {
 	init_fan();
@@ -153,6 +237,8 @@ int misc_init_r(void)
 			eth_setenv_enetaddr("ethaddr", mac);
 	}
 #endif
+	init_leds();
+
 	return 0;
 }
 #endif /* CONFIG_MISC_INIT_R */
-- 
1.7.10.4



More information about the U-Boot mailing list