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.
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
diff --git a/drivers/misc/twl4030_led.c b/drivers/misc/twl4030_led.c
index bfdafef..33cea11 100644
--- a/drivers/misc/twl4030_led.c
+++ b/drivers/misc/twl4030_led.c
@@ -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;
+ /* 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;
- /* enable LED */
- byte = LEDBPWM | LEDAPWM | LEDBON | LEDAON;
-
- twl4030_i2c_write_u8(TWL4030_CHIP_LED, byte,
+ twl4030_i2c_write_u8(TWL4030_CHIP_LED, ledon_mask,
TWL4030_LED_LEDEN);
}