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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
/*
* leds-S2MPB02.h - Flash-led driver for Samsung S2MPB02
*
* Copyright (C) 2014 Samsung Electronics
*
* 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.
*
* This driver is based on leds-max77804.h
*/
#ifndef __LEDS_S2MPB02_H__
#define __LEDS_S2MPB02_H__
#define S2MPB02_FLASH_TORCH_CURRENT_MAX 0xF
#define S2MPB02_TIMEOUT_MAX 0xF
/* S2MPB02_LV_SEL_VOUT */
#define S2MPB02_LV_SEL_VOUT_MASK 0x07
#define S2MPB02_LV_SEL_VOLT(voltage) \
((voltage) <= 2700 ? 0x00 : \
((voltage) <= 3400 ? ((voltage) - 2900) / 100 : 0x07))
#define S2MPB02_FLASH_MASK 0xF0
#define S2MPB02_TORCH_MASK 0x0F
#define S2MPB02_FLED_ENABLE 1
#define S2MPB02_FLED_DISABLE 0
#define S2MPB02_FLED_ENABLE_SHIFT 7
#define S2MPB02_FLED_FLASH_MODE 0
#define S2MPB02_FLED_TORCH_MODE 1
#define S2MPB02_FLED_MODE_SHIFT 6
#define S2MPB02_FLED_FLASH_TORCH_OFF 0x00
#define S2MPB02_FLED_FLASH_ON 0x80
#define S2MPB02_FLED_TORCH_ON 0xC0
#define S2MPB02_FLED_ENABLE_MODE_MASK 0xC0
#define S2MPB02_FLED_CTRL1_LV_EN_MASK 0x08
#define S2MPB02_FLED_CTRL1_LV_ENABLE 1
#define S2MPB02_FLED_CTRL1_LV_DISABLE 0
#ifdef CONFIG_LEDS_IRIS_IRLED_CERTIFICATE_SUPPORT
#define S2MPB02_FLED_CTRL2_TORCH_ON 0xF0
#define S2MPB02_FLED_CTRL2_FLASH_ON 0x38
#define S2MPB02_FLED_CTRL2_TORCH_MASK 0xFB
#define S2MPB02_FLED_CUR2_TORCH_CUR2_MASK 0x0F
#define S2MPB02_FLED_TIME2_IRMAX_TIMER_DISABLE 0x00
#define S2MPB02_FLED_TIME2_IRMAX_TIMER_EN_MASK 0x01
#endif
#define S2MPB02_FLED2_MAX_TIME_MASK 0x1F
#define S2MPB02_FLED2_MAX_TIME_CLEAR_MASK 0x04
#define S2MPB02_FLED2_MAX_TIME_EN_MASK 0x01
#define S2MPB02_FLED2_IRON2_MASK 0xC0
#define TORCH_STEP 10
enum s2mpb02_led_id {
S2MPB02_FLASH_LED_1,
S2MPB02_TORCH_LED_1,
S2MPB02_LED_MAX,
};
enum s2mpb02_flash_current {
S2MPB02_FLASH_OUT_I_150MA = 1,
S2MPB02_FLASH_OUT_I_250MA,
S2MPB02_FLASH_OUT_I_350MA,
S2MPB02_FLASH_OUT_I_450MA,
S2MPB02_FLASH_OUT_I_550MA,
S2MPB02_FLASH_OUT_I_650MA,
S2MPB02_FLASH_OUT_I_750MA,
S2MPB02_FLASH_OUT_I_850MA,
S2MPB02_FLASH_OUT_I_950MA,
S2MPB02_FLASH_OUT_I_1050MA,
S2MPB02_FLASH_OUT_I_1150MA,
S2MPB02_FLASH_OUT_I_1250MA,
S2MPB02_FLASH_OUT_I_1350MA,
S2MPB02_FLASH_OUT_I_1450MA,
S2MPB02_FLASH_OUT_I_1550MA,
S2MPB02_FLASH_OUT_I_MAX,
};
enum s2mpb02_torch_current {
S2MPB02_TORCH_OUT_I_20MA = 1,
S2MPB02_TORCH_OUT_I_40MA,
S2MPB02_TORCH_OUT_I_60MA,
S2MPB02_TORCH_OUT_I_80MA,
S2MPB02_TORCH_OUT_I_100MA,
S2MPB02_TORCH_OUT_I_120MA,
S2MPB02_TORCH_OUT_I_140MA,
S2MPB02_TORCH_OUT_I_160MA,
S2MPB02_TORCH_OUT_I_180MA,
S2MPB02_TORCH_OUT_I_200MA,
S2MPB02_TORCH_OUT_I_220MA,
S2MPB02_TORCH_OUT_I_240MA,
S2MPB02_TORCH_OUT_I_260MA,
S2MPB02_TORCH_OUT_I_280MA,
S2MPB02_TORCH_OUT_I_300MA,
S2MPB02_TORCH_OUT_I_MAX,
};
enum s2mpb02_flash_timeout {
S2MPB02_FLASH_TIMEOUT_62P5MS,
S2MPB02_FLASH_TIMEOUT_125MS,
S2MPB02_FLASH_TIMEOUT_187P5MS,
S2MPB02_FLASH_TIMEOUT_250MS,
S2MPB02_FLASH_TIMEOUT_312P5MS,
S2MPB02_FLASH_TIMEOUT_375MS,
S2MPB02_FLASH_TIMEOUT_437P5MS,
S2MPB02_FLASH_TIMEOUT_500MS,
S2MPB02_FLASH_TIMEOUT_562P5MS,
S2MPB02_FLASH_TIMEOUT_625MS,
S2MPB02_FLASH_TIMEOUT_687P5MS,
S2MPB02_FLASH_TIMEOUT_750MS,
S2MPB02_FLASH_TIMEOUT_812P5MS,
S2MPB02_FLASH_TIMEOUT_875MS,
S2MPB02_FLASH_TIMEOUT_937P5MS,
S2MPB02_FLASH_TIMEOUT_1000MS,
S2MPB02_FLASH_TIMEOUT_MAX,
};
enum s2mpb02_torch_timeout {
S2MPB02_TORCH_TIMEOUT_1S,
S2MPB02_TORCH_TIMEOUT_2S,
S2MPB02_TORCH_TIMEOUT_3S,
S2MPB02_TORCH_TIMEOUT_4S,
S2MPB02_TORCH_TIMEOUT_5S,
S2MPB02_TORCH_TIMEOUT_6S,
S2MPB02_TORCH_TIMEOUT_7S,
S2MPB02_TORCH_TIMEOUT_8S,
S2MPB02_TORCH_TIMEOUT_9S,
S2MPB02_TORCH_TIMEOUT_10S,
S2MPB02_TORCH_TIMEOUT_11S,
S2MPB02_TORCH_TIMEOUT_12S,
S2MPB02_TORCH_TIMEOUT_13S,
S2MPB02_TORCH_TIMEOUT_14S,
S2MPB02_TORCH_TIMEOUT_15S,
S2MPB02_TORCH_TIMEOUT_16S,
S2MPB02_TORCH_TIMEOUT_MAX,
};
enum s2mpb02_led_turn_way {
S2MPB02_LED_TURN_WAY_I2C,
S2MPB02_LED_TURN_WAY_GPIO,
S2MPB02_LED_TURN_WAY_MAX,
};
struct s2mpb02_led {
const char *name;
int id;
int brightness;
int brightness_cam;
int timeout;
int irda_off;
int torch_table_enable;
int torch_table[TORCH_STEP];
};
struct s2mpb02_led_platform_data {
int num_leds;
struct s2mpb02_led leds[S2MPB02_LED_MAX];
};
#ifdef CONFIG_LEDS_IRIS_IRLED_SUPPORT
extern int s2mpb02_ir_led_current(uint32_t current_value);
extern int s2mpb02_ir_led_pulse_width(uint32_t width);
extern int s2mpb02_ir_led_pulse_delay(uint32_t delay);
extern int s2mpb02_ir_led_max_time(uint32_t max_time);
#endif
#endif
|