aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-exynos/midas-leds.c
blob: 88fb1130498a844128bead73673a5cc5f2fd8e52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 *
 * 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/slab.h>
#include <linux/leds-lp5521.h>
#include "midas.h"

static struct lp5521_led_config lp5521_led_config[] = {
	{
		.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,
	},
};

/* 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),
		.platform_data = &lp5521_pdata,
	},
};

int __init plat_leds_init(void)
{
	i2c_add_devices(21, i2c_devs21_emul,
				ARRAY_SIZE(i2c_devs21_emul));
	return 0;
}

module_init(plat_leds_init);