aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dynamic_debug.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 21:57:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 21:57:59 -0400
commitc48c43e422c1404fd72c57d1d21a6f6d01e18900 (patch)
tree48e5d3828b4f5479361986535f71a1ae44e4f3c1 /include/linux/dynamic_debug.h
parent520045db940a381d2bee1c1b2179f7921b40fb10 (diff)
parent135cba0dc399fdd47bd3ae305c1db75fcd77243f (diff)
Merge branch 'drm-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6
* 'drm-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/airlied/drm-2.6: (476 commits) vmwgfx: Implement a proper GMR eviction mechanism drm/radeon/kms: fix r6xx/7xx 1D tiling CS checker v2 drm/radeon/kms: properly compute group_size on 6xx/7xx drm/radeon/kms: fix 2D tile height alignment in the r600 CS checker drm/radeon/kms/evergreen: set the clear state to the blit state drm/radeon/kms: don't poll dac load detect. gpu: Add Intel GMA500(Poulsbo) Stub Driver drm/radeon/kms: MC vram map needs to be >= pci aperture size drm/radeon/kms: implement display watermark support for evergreen drm/radeon/kms/evergreen: add some additional safe regs v2 drm/radeon/r600: fix tiling issues in CS checker. drm/i915: Move gpu_write_list to per-ring drm/i915: Invalidate the to-ring, flush the old-ring when updating domains drm/i915/ringbuffer: Write the value passed in to the tail register agp/intel: Restore valid PTE bit for Sandybridge after bdd3072 drm/i915: Fix flushing regression from 9af90d19f drm/i915/sdvo: Remove unused encoding member i915: enable AVI infoframe for intel_hdmi.c [v4] drm/i915: Fix current fb blocking for page flip drm/i915: IS_IRONLAKE is synonymous with gen == 5 ... Fix up conflicts in - drivers/gpu/drm/i915/{i915_gem.c, i915/intel_overlay.c}: due to the new simplified stack-based kmap_atomic() interface - drivers/gpu/drm/vmwgfx/vmwgfx_drv.c: added .llseek entry due to BKL removal cleanups.
Diffstat (limited to 'include/linux/dynamic_debug.h')
0 files changed, 0 insertions, 0 deletions
Remove work queue' href='/cgit/cgit.cgi/litmus-rt-ext-res.git/commit/drivers/leds/leds-lm355x.c?id=df8ff5d2e0f733aa6e866a6ba11a4c3376bb47f7'>df8ff5d2e0f7
b98d13c72592
df8ff5d2e0f7
b98d13c72592

df8ff5d2e0f7


b98d13c72592



df8ff5d2e0f7
b98d13c72592
df8ff5d2e0f7



b98d13c72592



0c0d9067ac6f
b98d13c72592


























14ce82e53645
b98d13c72592

5bbf150cca19
b98d13c72592
0d25376c3262





b98d13c72592






98ea1ea20cb7
b98d13c72592

87aae1ea82f9
b98d13c72592
















































b98d13c72592

df8ff5d2e0f7
313bf0b1a0ea
b98d13c72592




b98d13c72592

df8ff5d2e0f7
313bf0b1a0ea
b98d13c72592




b98d13c72592




df8ff5d2e0f7

0d25376c3262


b98d13c72592



b98d13c72592




b98d13c72592







678e8a6be911
b98d13c72592




b98d13c72592
b98d13c72592
b98d13c72592
b98d13c72592















b98d13c72592


df07cf812681
b98d13c72592








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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537

















                                                                      









































                                            




































































































                                                                           
                                                          


































                                                                             
                                                        































































































                                                                                
                               






                                                                      
                   

                                                                         
                   


           
 
                                                                 



                                                                       
                

                                
                                                           
                                  
                   

 


                                                                  



                                                                        
                

                                
                                                           
                                  
                   

 


                                                                     



                                                                           
                
 



                                                           



                                                                 
                                                                            


























                                                                            
                   

 
                                                                           
 





                                                     






                                                   
                                                  

                                                                 
                                                                            
















































                                                                         

                                             
                                                                                
                                                   




                                                                     

                                            
                                                                               
                                                   




                                                                     




                                                        

                                                                        


                                                                      



                                                                         




                                                     







                                                   
                                                   




                                                                   
                                                       
                                                   
                                                   















                                                                           


                              
                                








                                                                         
/*
* Simple driver for Texas Instruments LM355x LED Flash driver chip
* Copyright (C) 2012 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/module.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/leds.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/fs.h>
#include <linux/regmap.h>
#include <linux/platform_data/leds-lm355x.h>

enum lm355x_type {
	CHIP_LM3554 = 0,
	CHIP_LM3556,
};

enum lm355x_regs {
	REG_FLAG = 0,
	REG_TORCH_CFG,
	REG_TORCH_CTRL,
	REG_STROBE_CFG,
	REG_FLASH_CTRL,
	REG_INDI_CFG,
	REG_INDI_CTRL,
	REG_OPMODE,
	REG_MAX,
};

/* operation mode */
enum lm355x_mode {
	MODE_SHDN = 0,
	MODE_INDIC,
	MODE_TORCH,
	MODE_FLASH
};

/* register map info. */
struct lm355x_reg_data {
	u8 regno;
	u8 mask;
	u8 shift;
};

struct lm355x_chip_data {
	struct device *dev;
	enum lm355x_type type;

	struct led_classdev cdev_flash;
	struct led_classdev cdev_torch;
	struct led_classdev cdev_indicator;

	struct lm355x_platform_data *pdata;
	struct regmap *regmap;
	struct mutex lock;

	unsigned int last_flag;
	struct lm355x_reg_data *regs;
};

/* specific indicator function for lm3556 */
enum lm3556_indic_pulse_time {
	PULSE_TIME_0_MS = 0,
	PULSE_TIME_32_MS,
	PULSE_TIME_64_MS,
	PULSE_TIME_92_MS,
	PULSE_TIME_128_MS,
	PULSE_TIME_160_MS,
	PULSE_TIME_196_MS,
	PULSE_TIME_224_MS,
	PULSE_TIME_256_MS,
	PULSE_TIME_288_MS,
	PULSE_TIME_320_MS,
	PULSE_TIME_352_MS,
	PULSE_TIME_384_MS,
	PULSE_TIME_416_MS,
	PULSE_TIME_448_MS,
	PULSE_TIME_480_MS,
};

enum lm3556_indic_n_blank {
	INDIC_N_BLANK_0 = 0,
	INDIC_N_BLANK_1,
	INDIC_N_BLANK_2,
	INDIC_N_BLANK_3,
	INDIC_N_BLANK_4,
	INDIC_N_BLANK_5,
	INDIC_N_BLANK_6,
	INDIC_N_BLANK_7,
	INDIC_N_BLANK_8,
	INDIC_N_BLANK_9,
	INDIC_N_BLANK_10,
	INDIC_N_BLANK_11,
	INDIC_N_BLANK_12,
	INDIC_N_BLANK_13,
	INDIC_N_BLANK_14,
	INDIC_N_BLANK_15,
};

enum lm3556_indic_period {
	INDIC_PERIOD_0 = 0,
	INDIC_PERIOD_1,
	INDIC_PERIOD_2,
	INDIC_PERIOD_3,
	INDIC_PERIOD_4,
	INDIC_PERIOD_5,
	INDIC_PERIOD_6,
	INDIC_PERIOD_7,
};

#define INDIC_PATTERN_SIZE 4

struct indicator {
	u8 blinking;
	u8 period_cnt;
};

/* indicator pattern data only for lm3556 */
static struct indicator indicator_pattern[INDIC_PATTERN_SIZE] = {
	[0] = {(INDIC_N_BLANK_1 << 4) | PULSE_TIME_32_MS, INDIC_PERIOD_1},
	[1] = {(INDIC_N_BLANK_15 << 4) | PULSE_TIME_32_MS, INDIC_PERIOD_2},
	[2] = {(INDIC_N_BLANK_10 << 4) | PULSE_TIME_32_MS, INDIC_PERIOD_4},
	[3] = {(INDIC_N_BLANK_5 << 4) | PULSE_TIME_32_MS, INDIC_PERIOD_7},
};

static struct lm355x_reg_data lm3554_regs[REG_MAX] = {
	[REG_FLAG] = {0xD0, 0xBF, 0},
	[REG_TORCH_CFG] = {0xE0, 0x80, 7},
	[REG_TORCH_CTRL] = {0xA0, 0x38, 3},
	[REG_STROBE_CFG] = {0xE0, 0x04, 2},
	[REG_FLASH_CTRL] = {0xB0, 0x78, 3},
	[REG_INDI_CFG] = {0xE0, 0x08, 3},
	[REG_INDI_CTRL] = {0xA0, 0xC0, 6},
	[REG_OPMODE] = {0xA0, 0x03, 0},
};

static struct lm355x_reg_data lm3556_regs[REG_MAX] = {
	[REG_FLAG] = {0x0B, 0xFF, 0},
	[REG_TORCH_CFG] = {0x0A, 0x10, 4},
	[REG_TORCH_CTRL] = {0x09, 0x70, 4},
	[REG_STROBE_CFG] = {0x0A, 0x20, 5},
	[REG_FLASH_CTRL] = {0x09, 0x0F, 0},
	[REG_INDI_CFG] = {0xFF, 0xFF, 0},
	[REG_INDI_CTRL] = {0x09, 0x70, 4},
	[REG_OPMODE] = {0x0A, 0x03, 0},
};

static char lm355x_name[][I2C_NAME_SIZE] = {
	[CHIP_LM3554] = LM3554_NAME,
	[CHIP_LM3556] = LM3556_NAME,
};

/* chip initialize */
static int lm355x_chip_init(struct lm355x_chip_data *chip)
{
	int ret;
	unsigned int reg_val;
	struct lm355x_platform_data *pdata = chip->pdata;

	/* input and output pins configuration */
	switch (chip->type) {
	case CHIP_LM3554:
		reg_val = pdata->pin_tx2 | pdata->ntc_pin;
		ret = regmap_update_bits(chip->regmap, 0xE0, 0x28, reg_val);
		if (ret < 0)
			goto out;
		reg_val = pdata->pass_mode;
		ret = regmap_update_bits(chip->regmap, 0xA0, 0x04, reg_val);
		if (ret < 0)
			goto out;
		break;

	case CHIP_LM3556:
		reg_val = pdata->pin_tx2 | pdata->ntc_pin | pdata->pass_mode;
		ret = regmap_update_bits(chip->regmap, 0x0A, 0xC4, reg_val);
		if (ret < 0)
			goto out;
		break;
	default:
		return -ENODATA;
	}

	return ret;
out:
	dev_err(chip->dev, "%s:i2c access fail to register\n", __func__);
	return ret;
}

/* chip control */
static int lm355x_control(struct lm355x_chip_data *chip,
			   u8 brightness, enum lm355x_mode opmode)
{
	int ret;
	unsigned int reg_val;
	struct lm355x_platform_data *pdata = chip->pdata;
	struct lm355x_reg_data *preg = chip->regs;

	ret = regmap_read(chip->regmap, preg[REG_FLAG].regno, &chip->last_flag);
	if (ret < 0)
		goto out;
	if (chip->last_flag & preg[REG_FLAG].mask)
		dev_info(chip->dev, "%s Last FLAG is 0x%x\n",
			 lm355x_name[chip->type],
			 chip->last_flag & preg[REG_FLAG].mask);
	/* brightness 0 means shutdown */
	if (!brightness)
		opmode = MODE_SHDN;

	switch (opmode) {
	case MODE_TORCH:
		ret =
		    regmap_update_bits(chip->regmap, preg[REG_TORCH_CTRL].regno,
				       preg[REG_TORCH_CTRL].mask,
				       (brightness - 1)
				       << preg[REG_TORCH_CTRL].shift);
		if (ret < 0)
			goto out;

		if (pdata->pin_tx1 != LM355x_PIN_TORCH_DISABLE) {
			ret =
			    regmap_update_bits(chip->regmap,
					       preg[REG_TORCH_CFG].regno,
					       preg[REG_TORCH_CFG].mask,
					       0x01 <<
					       preg[REG_TORCH_CFG].shift);
			if (ret < 0)
				goto out;
			opmode = MODE_SHDN;
			dev_info(chip->dev,
				 "torch brt is set - ext. torch pin mode\n");
		}
		break;

	case MODE_FLASH:

		ret =
		    regmap_update_bits(chip->regmap, preg[REG_FLASH_CTRL].regno,
				       preg[REG_FLASH_CTRL].mask,
				       (brightness - 1)
				       << preg[REG_FLASH_CTRL].shift);
		if (ret < 0)
			goto out;

		if (pdata->pin_strobe != LM355x_PIN_STROBE_DISABLE) {
			if (chip->type == CHIP_LM3554)
				reg_val = 0x00;
			else
				reg_val = 0x01;
			ret =
			    regmap_update_bits(chip->regmap,
					       preg[REG_STROBE_CFG].regno,
					       preg[REG_STROBE_CFG].mask,
					       reg_val <<
					       preg[REG_STROBE_CFG].shift);
			if (ret < 0)
				goto out;
			opmode = MODE_SHDN;
			dev_info(chip->dev,
				 "flash brt is set - ext. strobe pin mode\n");
		}
		break;

	case MODE_INDIC:
		ret =
		    regmap_update_bits(chip->regmap, preg[REG_INDI_CTRL].regno,
				       preg[REG_INDI_CTRL].mask,
				       (brightness - 1)
				       << preg[REG_INDI_CTRL].shift);
		if (ret < 0)
			goto out;

		if (pdata->pin_tx2 != LM355x_PIN_TX_DISABLE) {
			ret =
			    regmap_update_bits(chip->regmap,
					       preg[REG_INDI_CFG].regno,
					       preg[REG_INDI_CFG].mask,
					       0x01 <<
					       preg[REG_INDI_CFG].shift);
			if (ret < 0)
				goto out;
			opmode = MODE_SHDN;
		}
		break;
	case MODE_SHDN:
		break;
	default:
		return -EINVAL;
	}
	/* operation mode control */
	ret = regmap_update_bits(chip->regmap, preg[REG_OPMODE].regno,
				 preg[REG_OPMODE].mask,
				 opmode << preg[REG_OPMODE].shift);
	if (ret < 0)
		goto out;
	return ret;
out:
	dev_err(chip->dev, "%s:i2c access fail to register\n", __func__);
	return ret;
}

/* torch */

static int lm355x_torch_brightness_set(struct led_classdev *cdev,
					enum led_brightness brightness)
{
	struct lm355x_chip_data *chip =
	    container_of(cdev, struct lm355x_chip_data, cdev_torch);
	int ret;

	mutex_lock(&chip->lock);
	ret = lm355x_control(chip, brightness, MODE_TORCH);
	mutex_unlock(&chip->lock);
	return ret;
}

/* flash */

static int lm355x_strobe_brightness_set(struct led_classdev *cdev,
					 enum led_brightness brightness)
{
	struct lm355x_chip_data *chip =
	    container_of(cdev, struct lm355x_chip_data, cdev_flash);
	int ret;

	mutex_lock(&chip->lock);
	ret = lm355x_control(chip, brightness, MODE_FLASH);
	mutex_unlock(&chip->lock);
	return ret;
}

/* indicator */

static int lm355x_indicator_brightness_set(struct led_classdev *cdev,
					    enum led_brightness brightness)
{
	struct lm355x_chip_data *chip =
	    container_of(cdev, struct lm355x_chip_data, cdev_indicator);
	int ret;

	mutex_lock(&chip->lock);
	ret = lm355x_control(chip, brightness, MODE_INDIC);
	mutex_unlock(&chip->lock);
	return ret;
}

/* indicator pattern only for lm3556*/
static ssize_t lm3556_indicator_pattern_store(struct device *dev,
					      struct device_attribute *attr,
					      const char *buf, size_t size)
{
	ssize_t ret;
	struct led_classdev *led_cdev = dev_get_drvdata(dev);
	struct lm355x_chip_data *chip =
	    container_of(led_cdev, struct lm355x_chip_data, cdev_indicator);
	unsigned int state;

	ret = kstrtouint(buf, 10, &state);
	if (ret)
		goto out;
	if (state > INDIC_PATTERN_SIZE - 1)
		state = INDIC_PATTERN_SIZE - 1;

	ret = regmap_write(chip->regmap, 0x04,
			   indicator_pattern[state].blinking);
	if (ret < 0)
		goto out;

	ret = regmap_write(chip->regmap, 0x05,
			   indicator_pattern[state].period_cnt);