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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
/*
* TI LMU (Lighting Management Unit) Backlight Device Data
*
* Copyright 2016 Texas Instruments
*
* Author: Milo Kim <milo.kim@ti.com>
*
* 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/kernel.h>
#include <linux/mfd/ti-lmu.h>
#include <linux/mfd/ti-lmu-backlight.h>
#include <linux/mfd/ti-lmu-register.h>
#include <linux/module.h>
/* LM3532 */
static u32 lm3532_init_regs[] = {
LM3532_INIT_ZONE_0,
LM3532_INIT_ZONE_1,
LM3532_INIT_ZONE_2,
};
static u32 lm3532_channel_regs[] = {
LM3532_CHANNEL_1,
LM3532_CHANNEL_2,
LM3532_CHANNEL_3,
};
static u32 lm3532_mode_regs[] = {
LM3532_MODE_PWM_A,
LM3532_MODE_PWM_B,
LM3532_MODE_PWM_C,
};
static u32 lm3532_ramp_regs[] = {
LM3532_RAMPUP,
LM3532_RAMPDN,
};
static u8 lm3532_enable_reg = LM3532_REG_ENABLE;
static u8 lm3532_brightness_regs[] = {
LM3532_REG_BRT_A,
LM3532_REG_BRT_B,
LM3532_REG_BRT_C,
};
static const struct ti_lmu_bl_reg lm3532_reg_info = {
.init = lm3532_init_regs,
.num_init = ARRAY_SIZE(lm3532_init_regs),
.channel = lm3532_channel_regs,
.mode = lm3532_mode_regs,
.ramp = lm3532_ramp_regs,
.enable = &lm3532_enable_reg,
.brightness_msb = lm3532_brightness_regs,
};
/* LM36272 and LM36274 */
static u32 lm3627x_init_regs[] = {
LM3627X_INIT_OVP_25V,
LM3627X_INIT_SWFREQ_1MHZ,
};
static u32 lm36272_channel_regs[] = {
LM36272_SINGLE_CHANNEL,
LM36272_DUAL_CHANNEL,
};
static u32 lm36274_channel_regs[] = {
LM36274_CHANNEL_1,
LM36274_CHANNEL_2,
LM36274_CHANNEL_3,
LM36274_CHANNEL_4,
};
static u32 lm3627x_mode_reg = LM3627X_MODE_PWM;
static u8 lm3627x_enable_reg = LM3627X_REG_ENABLE;
static u8 lm3627x_brightness_msb_reg = LM3627X_REG_BRT_MSB;
static u8 lm3627x_brightness_lsb_reg = LM3627X_REG_BRT_LSB;
static const struct ti_lmu_bl_reg lm36272_reg_info = {
.init = lm3627x_init_regs,
.num_init = ARRAY_SIZE(lm3627x_init_regs),
.channel = lm36272_channel_regs,
.mode = &lm3627x_mode_reg,
.enable = &lm3627x_enable_reg,
.enable_offset = LM3627X_BL_ENABLE_OFFSET,
.brightness_msb = &lm3627x_brightness_msb_reg,
.brightness_lsb = &lm3627x_brightness_lsb_reg,
};
static const struct ti_lmu_bl_reg lm36274_reg_info = {
.init = lm3627x_init_regs,
.num_init = ARRAY_SIZE(lm3627x_init_regs),
.channel = lm36274_channel_regs,
.mode = &lm3627x_mode_reg,
.enable = &lm3627x_enable_reg,
.enable_offset = LM3627X_BL_ENABLE_OFFSET,
.brightness_msb = &lm3627x_brightness_msb_reg,
.brightness_lsb = &lm3627x_brightness_lsb_reg,
};
/* LM3631 */
static u32 lm3631_init_regs[] = {
LM3631_INIT_BRT_MODE,
LM3631_INIT_DIMMING_MODE,
};
static u32 lm3631_channel_regs[] = {
LM3631_SINGLE_CHANNEL,
LM3631_DUAL_CHANNEL,
};
static u32 lm3631_ramp_reg = LM3631_RAMP;
static u8 lm3631_enable_reg = LM3631_REG_DEVCTRL;
static u8 lm3631_brightness_msb_reg = LM3631_REG_BRT_MSB;
static u8 lm3631_brightness_lsb_reg = LM3631_REG_BRT_LSB;
static const struct ti_lmu_bl_reg lm3631_reg_info = {
.init = lm3631_init_regs,
.num_init = ARRAY_SIZE(lm3631_init_regs),
.channel = lm3631_channel_regs,
.ramp = &lm3631_ramp_reg,
.enable = &lm3631_enable_reg,
.brightness_msb = &lm3631_brightness_msb_reg,
.brightness_lsb = &lm3631_brightness_lsb_reg,
};
/* LM3632 */
static u32 lm3632_init_regs[] = {
LM3632_INIT_OVP_25V,
LM3632_INIT_SWFREQ_1MHZ,
};
static u32 lm3632_channel_regs[] = {
LM3632_SINGLE_CHANNEL,
LM3632_DUAL_CHANNEL,
};
static u32 lm3632_mode_reg = LM3632_MODE_PWM;
static u8 lm3632_enable_reg = LM3632_REG_ENABLE;
static u8 lm3632_brightness_msb_reg = LM3632_REG_BRT_MSB;
static u8 lm3632_brightness_lsb_reg = LM3632_REG_BRT_LSB;
static const struct ti_lmu_bl_reg lm3632_reg_info = {
.init = lm3632_init_regs,
.num_init = ARRAY_SIZE(lm3632_init_regs),
.channel = lm3632_channel_regs,
.mode = &lm3632_mode_reg,
.enable = &lm3632_enable_reg,
.brightness_msb = &lm3632_brightness_msb_reg,
.brightness_lsb = &lm3632_brightness_lsb_reg,
};
/* LM3633 */
static u32 lm3633_init_regs[] = {
LM3633_INIT_OVP_40V,
LM3633_INIT_RAMP_SELECT,
};
static u32 lm3633_channel_regs[] = {
LM3633_CHANNEL_HVLED1,
LM3633_CHANNEL_HVLED2,
LM3633_CHANNEL_HVLED3,
};
static u32 lm3633_mode_regs[] = {
LM3633_MODE_PWM_A,
LM3633_MODE_PWM_B,
};
static u32 lm3633_ramp_regs[] = {
LM3633_RAMPUP,
LM3633_RAMPDN,
};
static u8 lm3633_enable_reg = LM3633_REG_ENABLE;
static u8 lm3633_brightness_msb_regs[] = {
LM3633_REG_BRT_HVLED_A_MSB,
LM3633_REG_BRT_HVLED_B_MSB,
};
static u8 lm3633_brightness_lsb_regs[] = {
LM3633_REG_BRT_HVLED_A_LSB,
LM3633_REG_BRT_HVLED_B_LSB,
};
static const struct ti_lmu_bl_reg lm3633_reg_info = {
.init = lm3633_init_regs,
.num_init = ARRAY_SIZE(lm3633_init_regs),
.channel = lm3633_channel_regs,
.mode = lm3633_mode_regs,
.ramp = lm3633_ramp_regs,
.ramp_reg_offset = 1, /* For LM3633_REG_BL1_RAMPUP/DN */
.enable = &lm3633_enable_reg,
.brightness_msb = lm3633_brightness_msb_regs,
.brightness_lsb = lm3633_brightness_lsb_regs,
};
/* LM3695 */
static u32 lm3695_init_regs[] = {
LM3695_INIT_BRT_MODE,
};
static u32 lm3695_channel_regs[] = {
LM3695_SINGLE_CHANNEL,
LM3695_DUAL_CHANNEL,
};
static u8 lm3695_enable_reg = LM3695_REG_GP;
static u8 lm3695_brightness_msb_reg = LM3695_REG_BRT_MSB;
static u8 lm3695_brightness_lsb_reg = LM3695_REG_BRT_LSB;
static const struct ti_lmu_bl_reg lm3695_reg_info = {
.init = lm3695_init_regs,
.num_init = ARRAY_SIZE(lm3695_init_regs),
.channel = lm3695_channel_regs,
.enable = &lm3695_enable_reg,
.enable_usec = 600,
.brightness_msb = &lm3695_brightness_msb_reg,
.brightness_lsb = &lm3695_brightness_lsb_reg,
};
/* LM3697 */
static u32 lm3697_init_regs[] = {
LM3697_INIT_RAMP_SELECT,
};
static u32 lm3697_channel_regs[] = {
LM3697_CHANNEL_1,
LM3697_CHANNEL_2,
LM3697_CHANNEL_3,
};
static u32 lm3697_mode_regs[] = {
LM3697_MODE_PWM_A,
LM3697_MODE_PWM_B,
};
static u32 lm3697_ramp_regs[] = {
LM3697_RAMPUP,
LM3697_RAMPDN,
};
static u8 lm3697_enable_reg = LM3697_REG_ENABLE;
static u8 lm3697_brightness_msb_regs[] = {
LM3697_REG_BRT_A_MSB,
LM3697_REG_BRT_B_MSB,
};
static u8 lm3697_brightness_lsb_regs[] = {
LM3697_REG_BRT_A_LSB,
LM3697_REG_BRT_B_LSB,
};
static const struct ti_lmu_bl_reg lm3697_reg_info = {
.init = lm3697_init_regs,
.num_init = ARRAY_SIZE(lm3697_init_regs),
.channel = lm3697_channel_regs,
.mode = lm3697_mode_regs,
.ramp = lm3697_ramp_regs,
.ramp_reg_offset = 1, /* For LM3697_REG_BL1_RAMPUP/DN */
.enable = &lm3697_enable_reg,
.brightness_msb = lm3697_brightness_msb_regs,
.brightness_lsb = lm3697_brightness_lsb_regs,
};
static int lm3532_ramp_table[] = { 0, 1, 2, 4, 8, 16, 32, 65 };
static int lm3631_ramp_table[] = {
0, 1, 2, 5, 10, 20, 50, 100,
250, 500, 750, 1000, 1500, 2000, 3000, 4000,
};
static int common_ramp_table[] = {
2, 250, 500, 1000, 2000, 4000, 8000, 16000,
};
struct ti_lmu_bl_cfg lmu_bl_cfg[LMU_MAX_ID] = {
{
.reginfo = &lm3532_reg_info,
.num_channels = LM3532_MAX_CHANNELS,
.max_brightness = MAX_BRIGHTNESS_8BIT,
.pwm_action = UPDATE_PWM_AND_BRT_REGISTER,
.ramp_table = lm3532_ramp_table,
.size_ramp = ARRAY_SIZE(lm3532_ramp_table),
},
{
.reginfo = &lm36272_reg_info,
.num_channels = LM36272_MAX_CHANNELS,
.max_brightness = MAX_BRIGHTNESS_11BIT,
.pwm_action = UPDATE_PWM_ONLY,
},
{
.reginfo = &lm36274_reg_info,
.num_channels = LM36274_MAX_CHANNELS,
.single_bank_used = true,
.max_brightness = MAX_BRIGHTNESS_11BIT,
.pwm_action = UPDATE_PWM_ONLY,
},
{
.reginfo = &lm3631_reg_info,
.num_channels = LM3631_MAX_CHANNELS,
.max_brightness = MAX_BRIGHTNESS_11BIT,
.pwm_action = UPDATE_PWM_ONLY,
.ramp_table = lm3631_ramp_table,
.size_ramp = ARRAY_SIZE(lm3631_ramp_table),
},
{
.reginfo = &lm3632_reg_info,
.num_channels = LM3632_MAX_CHANNELS,
.max_brightness = MAX_BRIGHTNESS_11BIT,
.pwm_action = UPDATE_PWM_ONLY,
},
{
.reginfo = &lm3633_reg_info,
.num_channels = LM3633_MAX_CHANNELS,
.max_brightness = MAX_BRIGHTNESS_11BIT,
.pwm_action = UPDATE_MAX_BRT,
.ramp_table = common_ramp_table,
.size_ramp = ARRAY_SIZE(common_ramp_table),
.fault_monitor_used = true,
},
{
.reginfo = &lm3695_reg_info,
.num_channels = LM3695_MAX_CHANNELS,
.max_brightness = MAX_BRIGHTNESS_11BIT,
.pwm_action = UPDATE_PWM_AND_BRT_REGISTER,
},
{
.reginfo = &lm3697_reg_info,
.num_channels = LM3697_MAX_CHANNELS,
.max_brightness = MAX_BRIGHTNESS_11BIT,
.pwm_action = UPDATE_PWM_AND_BRT_REGISTER,
.ramp_table = common_ramp_table,
.size_ramp = ARRAY_SIZE(common_ramp_table),
.fault_monitor_used = true,
},
};
EXPORT_SYMBOL_GPL(lmu_bl_cfg);
|