Skip to contentSkip to conversation

TWL4030: make LEDs selectable for twl4030_led_init()

PATCH New Grazvydas Ignotas 2 participants 3 messages Dec 10, 2009 – Dec 13, 2009 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 TWL4030: make LEDs selectable for twl4030_led_init()

Not all boards have both LEDs hooked, so enabling both on boards with single LED will just waste power. Make it possible to choose LEDs by adding argument to twl4030_led_init().

Using this turn on only LEDB for pandora, leave both LEDs on for all other boards, as it was before this patch.

---
 board/logicpd/zoom1/zoom1.c         |    2 +-
 board/logicpd/zoom2/zoom2.c         |    2 +-
 board/overo/overo.c                 |    2 +-
 board/pandora/pandora.c             |    2 +-
 board/ti/beagle/beagle.c            |    2 +-
 board/timll/devkit8000/devkit8000.c |    2 +-
 drivers/misc/twl4030_led.c          |   18 +++++++-----------
 include/twl4030.h                   |    6 +++++-
 8 files changed, 18 insertions(+), 18 deletions(-)
board/logicpd/zoom1/zoom1.c +1 -1
index f4d3754..da501a7 100644
@@ -62,7 +62,7 @@ int board_init(void)
 int misc_init_r(void)
 {
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 	dieid_num_r();
 
 	/*
board/logicpd/zoom2/zoom2.c +1 -1
index dadbeb6..560470f 100644
@@ -148,7 +148,7 @@ int misc_init_r(void)
 {
 	zoom2_identify();
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 	dieid_num_r();
 
 	/*
board/overo/overo.c +1 -1
index d42dc13..f363281 100644
@@ -67,7 +67,7 @@ int board_init(void)
 int misc_init_r(void)
 {
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 
 #if defined(CONFIG_CMD_NET)
 	setup_net_chip();
board/pandora/pandora.c +1 -1
index 460ed12..e84c946 100644
@@ -66,7 +66,7 @@ int misc_init_r(void)
 	struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
 
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
 
 	/* Configure GPIOs to output */
 	writel(~(GPIO14 | GPIO15 | GPIO16 | GPIO23), &gpio1_base->oe);
board/ti/beagle/beagle.c +1 -1
index 32d501e..3b4c9e7 100644
@@ -107,7 +107,7 @@ int misc_init_r(void)
 	struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE;
 
 	twl4030_power_init();
-	twl4030_led_init();
+	twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 
 	/* Configure GPIOs to output */
 	writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe);
board/timll/devkit8000/devkit8000.c +1 -1
index db7d2e2..95afaaa 100644
@@ -76,7 +76,7 @@ int misc_init_r(void)
 
 	twl4030_power_init();
 #ifdef CONFIG_TWL4030_LED
-	twl4030_led_init();
+	twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
 #endif
 
 #ifdef CONFIG_DRIVER_DM9000
drivers/misc/twl4030_led.c +7 -11
index bfdafef..33cea11 100644
@@ -34,19 +34,15 @@
 
 #include <twl4030.h>
 
-#define LEDAON			(0x1 << 0)
-#define LEDBON			(0x1 << 1)
-#define LEDAPWM			(0x1 << 4)
-#define LEDBPWM			(0x1 << 5)
-
-void twl4030_led_init(void)
+void twl4030_led_init(unsigned char ledon_mask)
 {
-	unsigned char byte;
-
-	/* enable LED */
-	byte = LEDBPWM | LEDAPWM | LEDBON | LEDAON;
+	/* LEDs need to have corresponding PWMs enabled */
+	if (ledon_mask & TWL4030_LED_LEDEN_LEDAON)
+		ledon_mask |= TWL4030_LED_LEDEN_LEDAPWM;
+	if (ledon_mask & TWL4030_LED_LEDEN_LEDBON)
+		ledon_mask |= TWL4030_LED_LEDEN_LEDBPWM;
 
-	twl4030_i2c_write_u8(TWL4030_CHIP_LED, byte,
+	twl4030_i2c_write_u8(TWL4030_CHIP_LED, ledon_mask,
 			     TWL4030_LED_LEDEN);
 
 }
include/twl4030.h +5 -1
index f260ecb..df30d42 100644
@@ -306,6 +306,10 @@
 
 /* LED */
 #define TWL4030_LED_LEDEN				0xEE
+#define TWL4030_LED_LEDEN_LEDAON			(1 << 0)
+#define TWL4030_LED_LEDEN_LEDBON			(1 << 1)
+#define TWL4030_LED_LEDEN_LEDAPWM			(1 << 4)
+#define TWL4030_LED_LEDEN_LEDBPWM			(1 << 5)
 
 /* Keypad */
 #define TWL4030_KEYPAD_KEYP_CTRL_REG			0xD2
@@ -396,6 +400,6 @@ void twl4030_power_mmc_init(void);
 /*
  * LED
  */
-void twl4030_led_init(void);
+void twl4030_led_init(unsigned char ledon_mask);
 
 #endif /* TWL4030_H */
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH v3 1/1 TWL4030: make LEDs selectable for twl4030_led_init()

Quoted 9 lines · Grazvydas Ignotas

Not all boards have both LEDs hooked, so enabling both on boards with single LED will just waste power. Make it possible to choose LEDs by adding argument to twl4030_led_init().

Using this turn on only LEDB for pandora, leave both LEDs on for all other boards, as it was before this patch.

Ack-ed

Thanks,
Tom

Applied
#2 lore raw

PATCH v3 1/1 TWL4030: make LEDs selectable for twl4030_led_init()

In reply to Grazvydas Ignotas
Quoted 9 lines · Grazvydas Ignotas

Not all boards have both LEDs hooked, so enabling both on boards with single LED will just waste power. Make it possible to choose LEDs by adding argument to twl4030_led_init().

Using this turn on only LEDB for pandora, leave both LEDs on for all other boards, as it was before this patch.

Pushed to arm/next
Thanks
Tom