xref: /openbmc/linux/include/media/i2c/lm3560.h (revision 4419617e)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * include/media/i2c/lm3560.h
4  *
5  * Copyright (C) 2013 Texas Instruments
6  *
7  * Contact: Daniel Jeong <gshark.jeong@gmail.com>
8  *			Ldd-Mlp <ldd-mlp@list.ti.com>
9  */
10 
11 #ifndef __LM3560_H__
12 #define __LM3560_H__
13 
14 #include <media/v4l2-subdev.h>
15 
16 #define LM3559_NAME	"lm3559"
17 #define LM3560_NAME	"lm3560"
18 #define LM3560_I2C_ADDR	(0x53)
19 
20 /*  FLASH Brightness
21  *	min 62500uA, step 62500uA, max 1000000uA
22  */
23 #define LM3560_FLASH_BRT_MIN 62500
24 #define LM3560_FLASH_BRT_STEP 62500
25 #define LM3560_FLASH_BRT_MAX 1000000
26 #define LM3560_FLASH_BRT_uA_TO_REG(a)	\
27 	((a) < LM3560_FLASH_BRT_MIN ? 0 :	\
28 	 (((a) - LM3560_FLASH_BRT_MIN) / LM3560_FLASH_BRT_STEP))
29 #define LM3560_FLASH_BRT_REG_TO_uA(a)		\
30 	((a) * LM3560_FLASH_BRT_STEP + LM3560_FLASH_BRT_MIN)
31 
32 /*  FLASH TIMEOUT DURATION
33  *	min 32ms, step 32ms, max 1024ms
34  */
35 #define LM3560_FLASH_TOUT_MIN 32
36 #define LM3560_FLASH_TOUT_STEP 32
37 #define LM3560_FLASH_TOUT_MAX 1024
38 #define LM3560_FLASH_TOUT_ms_TO_REG(a)	\
39 	((a) < LM3560_FLASH_TOUT_MIN ? 0 :	\
40 	 (((a) - LM3560_FLASH_TOUT_MIN) / LM3560_FLASH_TOUT_STEP))
41 #define LM3560_FLASH_TOUT_REG_TO_ms(a)		\
42 	((a) * LM3560_FLASH_TOUT_STEP + LM3560_FLASH_TOUT_MIN)
43 
44 /*  TORCH BRT
45  *	min 31250uA, step 31250uA, max 250000uA
46  */
47 #define LM3560_TORCH_BRT_MIN 31250
48 #define LM3560_TORCH_BRT_STEP 31250
49 #define LM3560_TORCH_BRT_MAX 250000
50 #define LM3560_TORCH_BRT_uA_TO_REG(a)	\
51 	((a) < LM3560_TORCH_BRT_MIN ? 0 :	\
52 	 (((a) - LM3560_TORCH_BRT_MIN) / LM3560_TORCH_BRT_STEP))
53 #define LM3560_TORCH_BRT_REG_TO_uA(a)		\
54 	((a) * LM3560_TORCH_BRT_STEP + LM3560_TORCH_BRT_MIN)
55 
56 enum lm3560_led_id {
57 	LM3560_LED0 = 0,
58 	LM3560_LED1,
59 	LM3560_LED_MAX
60 };
61 
62 enum lm3560_peak_current {
63 	LM3560_PEAK_1600mA = 0x00,
64 	LM3560_PEAK_2300mA = 0x20,
65 	LM3560_PEAK_3000mA = 0x40,
66 	LM3560_PEAK_3600mA = 0x60
67 };
68 
69 /* struct lm3560_platform_data
70  *
71  * @peak :  peak current
72  * @max_flash_timeout: flash timeout
73  * @max_flash_brt: flash mode led brightness
74  * @max_torch_brt: torch mode led brightness
75  */
76 struct lm3560_platform_data {
77 	enum lm3560_peak_current peak;
78 
79 	u32 max_flash_timeout;
80 	u32 max_flash_brt[LM3560_LED_MAX];
81 	u32 max_torch_brt[LM3560_LED_MAX];
82 };
83 
84 #endif /* __LM3560_H__ */
85