GNU Linux-libre 4.14.266-gnu1
[releases.git] / drivers / staging / media / atomisp / i2c / ov5693 / ad5823.h
1 /*
2  * Support for AD5823 VCM.
3  *
4  * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License version
8  * 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA.
19  *
20  */
21
22 #ifndef __AD5823_H__
23 #define __AD5823_H__
24
25 #include <linux/types.h>
26
27
28 #define AD5823_VCM_ADDR 0x0c
29
30 #define AD5823_REG_RESET                0x01
31 #define AD5823_REG_MODE                 0x02
32 #define AD5823_REG_VCM_MOVE_TIME        0x03
33 #define AD5823_REG_VCM_CODE_MSB         0x04
34 #define AD5823_REG_VCM_CODE_LSB         0x05
35 #define AD5823_REG_VCM_THRESHOLD_MSB    0x06
36 #define AD5823_REG_VCM_THRESHOLD_LSB    0x07
37
38 #define AD5823_REG_LENGTH               0x1
39
40 #define AD5823_RING_CTRL_ENABLE         0x04
41 #define AD5823_RING_CTRL_DISABLE        0x00
42
43 #define AD5823_RESONANCE_PERIOD         100000
44 #define AD5823_RESONANCE_COEF           512
45 #define AD5823_HIGH_FREQ_RANGE          0x80
46
47 #define VCM_CODE_MSB_MASK               0xfc
48 #define AD5823_INIT_FOCUS_POS           350
49
50 enum ad5823_tok_type {
51         AD5823_8BIT  = 0x1,
52         AD5823_16BIT = 0x2,
53 };
54
55 enum ad5823_vcm_mode {
56         AD5823_ARC_RES0 = 0x0,  /* Actuator response control RES1 */
57         AD5823_ARC_RES1 = 0x1,  /* Actuator response control RES0.5 */
58         AD5823_ARC_RES2 = 0x2,  /* Actuator response control RES2 */
59         AD5823_ESRC = 0x3,      /* Enhanced slew rate control */
60         AD5823_DIRECT = 0x4,    /* Direct control */
61 };
62
63 #define AD5823_INVALID_CONFIG   0xffffffff
64 #define AD5823_MAX_FOCUS_POS    1023
65 #define DELAY_PER_STEP_NS       1000000
66 #define DELAY_MAX_PER_STEP_NS   (1000000 * 1023)
67 #endif