leds-pm8xxx: Pass LED flags from board file
Instead of hard coding the flag into led driver, pass it
from board file.
While at it, re-factor the code to separate led upstream
core data with board specific data.
Signed-off-by: Jay Chokshi <jchokshi@codeaurora.org>
Conflicts:
drivers/mfd/pm8921-core.c
diff --git a/arch/arm/mach-msm/board-msm8960.c b/arch/arm/mach-msm/board-msm8960.c
index 365121c..ae85aff 100644
--- a/arch/arm/mach-msm/board-msm8960.c
+++ b/arch/arm/mach-msm/board-msm8960.c
@@ -3896,40 +3896,41 @@
#define PM8921_LC_LED_MAX_CURRENT 4 /* I = 4mA */
-/**
- * 'flag' stores three values; led id, led mode, and max current of led.
- * The bit packing format is as follow,
- * reserved (1 byte) | max_current (2 bytes) | led_mode (1 nibble) |
- * led_id (1 nibble)
- */
-#define PM8XXX_SET_FLAG(led_id, led_mode, led_max_current) \
- (((led_id << PM8XXX_LED_ID_SHIFT) & PM8XXX_LED_ID_MASK) |\
- ((led_mode << PM8XXX_LED_MODE_SHIFT) & PM8XXX_LED_MODE_MASK) |\
- ((led_max_current << PM8XXX_LED_MAX_CURRENT_SHIFT) & \
- PM8XXX_LED_MAX_CURRENT_MASK))
-
static struct led_info pm8921_led_info[] = {
[0] = {
.name = "led:usb",
.default_trigger = "usb-online",
- .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_0,
- PM8XXX_LED_MODE_MANUAL,
- PM8921_LC_LED_MAX_CURRENT),
},
[1] = {
.name = "led:ac",
.default_trigger = "ac-online",
- .flags = PM8XXX_SET_FLAG(PM8XXX_ID_LED_1,
- PM8XXX_LED_MODE_MANUAL,
- PM8921_LC_LED_MAX_CURRENT),
},
};
-static struct led_platform_data pm8xxx_leds_pdata = {
+static struct led_platform_data pm8921_led_core_pdata = {
.num_leds = ARRAY_SIZE(pm8921_led_info),
.leds = pm8921_led_info,
};
+static struct pm8xxx_led_config pm8921_led_configs[] = {
+ [0] = {
+ .id = PM8XXX_ID_LED_0,
+ .mode = PM8XXX_LED_MODE_MANUAL,
+ .max_current = PM8921_LC_LED_MAX_CURRENT,
+ },
+ [1] = {
+ .id = PM8XXX_ID_LED_1,
+ .mode = PM8XXX_LED_MODE_MANUAL,
+ .max_current = PM8921_LC_LED_MAX_CURRENT,
+ },
+};
+
+static struct pm8xxx_led_platform_data pm8xxx_leds_pdata = {
+ .led_core = &pm8921_led_core_pdata,
+ .configs = pm8921_led_configs,
+ .num_configs = ARRAY_SIZE(pm8921_led_configs),
+};
+
static struct pm8921_platform_data pm8921_platform_data __devinitdata = {
.irq_pdata = &pm8xxx_irq_pdata,
.gpio_pdata = &pm8xxx_gpio_pdata,