diff options
Diffstat (limited to 'arch/arm/mach-exynos/midas-leds.c')
-rw-r--r-- | arch/arm/mach-exynos/midas-leds.c | 137 |
1 files changed, 109 insertions, 28 deletions
diff --git a/arch/arm/mach-exynos/midas-leds.c b/arch/arm/mach-exynos/midas-leds.c index 2d6e1e2..88fb113 100644 --- a/arch/arm/mach-exynos/midas-leds.c +++ b/arch/arm/mach-exynos/midas-leds.c @@ -1,43 +1,121 @@ -#include <linux/platform_device.h> -#include <linux/gpio.h> +/* + * + * Copyright (C) 2011 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + #include <linux/i2c.h> -#include <linux/i2c-gpio.h> +#include <linux/slab.h> #include <linux/leds-lp5521.h> - -#include <plat/gpio-cfg.h> -#include <mach/regs-gpio.h> -#include <mach/gpio.h> #include "midas.h" -#ifdef CONFIG_LEDS_LP5521 static struct lp5521_led_config lp5521_led_config[] = { { - .name = "red", - .chan_nr = 0, - .led_current = 50, - .max_current = 130, - }, { - .name = "green", - .chan_nr = 1, - .led_current = 30, - .max_current = 130, - }, { - .name = "blue", - .chan_nr = 2, - .led_current = 30, - .max_current = 130, + .name = "led_r", + .chan_nr = 0, + .led_current = 20, + .max_current = 20, + }, + { + .name = "led_g", + .chan_nr = 1, + .led_current = 20, + .max_current = 20, + }, + { + .name = "led_b", + .chan_nr = 2, + .led_current = 20, + .max_current = 20, }, }; -#define LP5521_CONFIGS (LP5521_PWM_HF | LP5521_PWRSAVE_EN | \ -LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT | \ -LP5521_CLK_INT) + +/* mode 1 (charging) : RGB(255,0,0) always on */ +static u8 mode_charging[] = { 0x40, 0xFF, }; + +/* mode 2 (charging error) : RGB(255,0,0) 500ms off, 500ms on */ +static u8 mode_charging_err[] = { + 0x40, 0x00, 0x60, 0x00, 0x40, 0xFF, + 0x60, 0x00, + }; + +/* mode 3 (missed noti) : RGB(0,0,255) 5000ms off, 500ms on */ +static u8 mode_missed_noti[] = { + 0x40, 0x00, 0x60, 0x00, 0xA4, 0xA1, + 0x40, 0xFF, 0x60, 0x00, + }; + +/* mode 4 (low batt) : RGB(255,0,0) 5000ms off, 500ms on */ +static u8 mode_low_batt[] = { + 0x40, 0x00, 0x60, 0x00, 0xA4, 0xA1, + 0x40, 0xFF, 0x60, 0x00, + }; + +/* mode 5 (full charged) : RGB(0,255,0) always on */ +static u8 mode_full_chg[] = { 0x40, 0xFF, }; + +/* mode 6 (power on) : RGB(0,0,0) -> RGB(0,140,255) + ramp up 672ms, wait 328ms, ramp down 672ms, wait 328ms */ +static u8 mode_poweron_green[] = { + 0x40, 0x00, 0x0A, 0x45, 0x0A, 0x45, + 0x40, 0x8C, 0x55, 0x00, 0x0A, 0xC5, + 0xE0, 0x08, 0x0A, 0xC5, 0x40, 0x00, + 0x55, 0x00, 0xE0, 0x08, + }; + +static u8 mode_poweron_blue[] = { + 0x40, 0x00, 0x05, 0x7E, 0x05, 0x7E, + 0x40, 0xFF, 0x55, 0x00, 0x05, 0xFE, + 0xE1, 0x00, 0x05, 0xFE, 0x40, 0x00, + 0x55, 0x00, 0xE1, 0x00, + }; + +static struct lp5521_led_pattern board_led_patterns[] = { + { + .r = mode_charging, + .size_r = ARRAY_SIZE(mode_charging), + }, + { + .r = mode_charging_err, + .size_r = ARRAY_SIZE(mode_charging_err), + }, + { + .b = mode_missed_noti, + .size_b = ARRAY_SIZE(mode_missed_noti), + }, + { + .r = mode_low_batt, + .size_r = ARRAY_SIZE(mode_low_batt), + }, + { + .g = mode_full_chg, + .size_g = ARRAY_SIZE(mode_full_chg), + }, + { + .g = mode_poweron_green, + .b = mode_poweron_blue, + .size_g = ARRAY_SIZE(mode_poweron_green), + .size_b = ARRAY_SIZE(mode_poweron_blue), + }, +}; + +#define LP5521_CONFIGS (LP5521_PWM_HF | LP5521_PWRSAVE_EN | \ + LP5521_CP_MODE_BYPASS | \ + LP5521_CLOCK_INT) static struct lp5521_platform_data lp5521_pdata = { .led_config = lp5521_led_config, .num_channels = ARRAY_SIZE(lp5521_led_config), .clock_mode = LP5521_CLOCK_INT, .update_config = LP5521_CONFIGS, + .patterns = board_led_patterns, + .num_patterns = ARRAY_SIZE(board_led_patterns), }; + static struct i2c_board_info i2c_devs21_emul[] __initdata = { { I2C_BOARD_INFO("lp5521", 0x32), @@ -47,8 +125,11 @@ static struct i2c_board_info i2c_devs21_emul[] __initdata = { int __init plat_leds_init(void) { - i2c_add_devices(21, i2c_devs21_emul, ARRAY_SIZE(i2c_devs21_emul)); + i2c_add_devices(21, i2c_devs21_emul, + ARRAY_SIZE(i2c_devs21_emul)); return 0; -}; +} + module_init(plat_leds_init); -#endif + + |