Merge tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux
[linux-2.6-block.git] / drivers / staging / media / atomisp / i2c / imx / dw9714.h
1 #ifndef __DW9714_H__
2 #define __DW9714_H__
3
4 #include "../../include/linux/atomisp_platform.h"
5 #include <linux/types.h>
6
7
8 #define DW9714_VCM_ADDR 0x0c
9
10 enum dw9714_tok_type {
11         DW9714_8BIT  = 0x0001,
12         DW9714_16BIT = 0x0002,
13 };
14
15 struct dw9714_vcm_settings {
16         u16 code;       /* bit[9:0]: Data[9:0] */
17         u8 t_src;       /* bit[4:0]: T_SRC[4:0] */
18         u8 step_setting;        /* bit[3:0]: S[3:0]/bit[5:4]: MCLK[1:0] */
19         bool update;
20 };
21
22 enum dw9714_vcm_mode {
23         DW9714_DIRECT = 0x1,    /* direct control */
24         DW9714_LSC = 0x2,       /* linear slope control */
25         DW9714_DLC = 0x3,       /* dual level control */
26 };
27
28 /* dw9714 device structure */
29 struct dw9714_device {
30         struct dw9714_vcm_settings vcm_settings;
31         struct timespec timestamp_t_focus_abs;
32         enum dw9714_vcm_mode vcm_mode;
33         s16 number_of_steps;
34         bool initialized;               /* true if dw9714 is detected */
35         s32 focus;                      /* Current focus value */
36         struct timespec focus_time;     /* Time when focus was last time set */
37         __u8 buffer[4];                 /* Used for i2c transactions */
38         const struct camera_af_platform_data *platform_data;
39 };
40
41 #define DW9714_INVALID_CONFIG   0xffffffff
42 #define DW9714_MAX_FOCUS_POS    1023
43 #define DW9714_DEFAULT_FOCUS_POS        290
44
45
46 /* MCLK[1:0] = 01 T_SRC[4:0] = 00001 S[3:0] = 0111 */
47 #define DELAY_PER_STEP_NS       1000000
48 #define DELAY_MAX_PER_STEP_NS   (1000000 * 1023)
49
50 #define DLC_ENABLE 1
51 #define DLC_DISABLE 0
52 #define VCM_PROTECTION_OFF      0xeca3
53 #define VCM_PROTECTION_ON       0xdc51
54 #define VCM_DEFAULT_S 0x0
55
56 #define vcm_step_s(a) (u8)(a & 0xf)
57 #define vcm_step_mclk(a) (u8)((a >> 4) & 0x3)
58 #define vcm_dlc_mclk(dlc, mclk) (u16)((dlc << 3) | mclk | 0xa104)
59 #define vcm_tsrc(tsrc) (u16)(tsrc << 3 | 0xf200)
60 #define vcm_val(data, s) (u16)(data << 4 | s)
61 #define DIRECT_VCM vcm_dlc_mclk(0, 0)
62
63 #endif