Go to the documentation of this file.
31 #include <linux/i2c.h>
33 #include <linux/videodev2.h>
37 #define ADP1653_NAME "adp1653"
38 #define ADP1653_I2C_ADDR (0x60 >> 1)
41 #define ADP1653_REG_OUT_SEL 0x00
42 #define ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN 0x01
43 #define ADP1653_REG_OUT_SEL_HPLED_TORCH_MAX 0x0b
44 #define ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN 0x0c
45 #define ADP1653_REG_OUT_SEL_HPLED_FLASH_MAX 0x1f
46 #define ADP1653_REG_OUT_SEL_HPLED_SHIFT 3
47 #define ADP1653_REG_OUT_SEL_ILED_MAX 0x07
48 #define ADP1653_REG_OUT_SEL_ILED_SHIFT 0
50 #define ADP1653_REG_CONFIG 0x01
51 #define ADP1653_REG_CONFIG_TMR_CFG (1 << 4)
52 #define ADP1653_REG_CONFIG_TMR_SET_MAX 0x0f
53 #define ADP1653_REG_CONFIG_TMR_SET_SHIFT 0
55 #define ADP1653_REG_SW_STROBE 0x02
56 #define ADP1653_REG_SW_STROBE_SW_STROBE (1 << 0)
58 #define ADP1653_REG_FAULT 0x03
59 #define ADP1653_REG_FAULT_FLT_SCP (1 << 3)
60 #define ADP1653_REG_FAULT_FLT_OT (1 << 2)
61 #define ADP1653_REG_FAULT_FLT_TMR (1 << 1)
62 #define ADP1653_REG_FAULT_FLT_OV (1 << 0)
64 #define ADP1653_INDICATOR_INTENSITY_MIN 0
65 #define ADP1653_INDICATOR_INTENSITY_STEP 2500
66 #define ADP1653_INDICATOR_INTENSITY_MAX \
67 (ADP1653_REG_OUT_SEL_ILED_MAX * ADP1653_INDICATOR_INTENSITY_STEP)
68 #define ADP1653_INDICATOR_INTENSITY_uA_TO_REG(a) \
69 ((a) / ADP1653_INDICATOR_INTENSITY_STEP)
70 #define ADP1653_INDICATOR_INTENSITY_REG_TO_uA(a) \
71 ((a) * ADP1653_INDICATOR_INTENSITY_STEP)
73 #define ADP1653_FLASH_INTENSITY_BASE 35
74 #define ADP1653_FLASH_INTENSITY_STEP 15
75 #define ADP1653_FLASH_INTENSITY_MIN \
76 (ADP1653_FLASH_INTENSITY_BASE \
77 + ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN * ADP1653_FLASH_INTENSITY_STEP)
78 #define ADP1653_FLASH_INTENSITY_MAX \
79 (ADP1653_FLASH_INTENSITY_MIN + \
80 (ADP1653_REG_OUT_SEL_HPLED_FLASH_MAX - \
81 ADP1653_REG_OUT_SEL_HPLED_FLASH_MIN + 1) * \
82 ADP1653_FLASH_INTENSITY_STEP)
84 #define ADP1653_FLASH_INTENSITY_mA_TO_REG(a) \
85 ((a) < ADP1653_FLASH_INTENSITY_BASE ? 0 : \
86 (((a) - ADP1653_FLASH_INTENSITY_BASE) / ADP1653_FLASH_INTENSITY_STEP))
87 #define ADP1653_FLASH_INTENSITY_REG_TO_mA(a) \
88 ((a) * ADP1653_FLASH_INTENSITY_STEP + ADP1653_FLASH_INTENSITY_BASE)
90 #define ADP1653_TORCH_INTENSITY_MIN \
91 (ADP1653_FLASH_INTENSITY_BASE \
92 + ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN * ADP1653_FLASH_INTENSITY_STEP)
93 #define ADP1653_TORCH_INTENSITY_MAX \
94 (ADP1653_TORCH_INTENSITY_MIN + \
95 (ADP1653_REG_OUT_SEL_HPLED_TORCH_MAX - \
96 ADP1653_REG_OUT_SEL_HPLED_TORCH_MIN + 1) * \
97 ADP1653_FLASH_INTENSITY_STEP)
108 #define to_adp1653_flash(sd) container_of(sd, struct adp1653_flash, subdev)