2 * Support for AD5823 VCM.
4 * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
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.
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.
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
25 #include <linux/types.h>
28 #define AD5823_VCM_ADDR 0x0c
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
38 #define AD5823_REG_LENGTH 0x1
40 #define AD5823_RING_CTRL_ENABLE 0x04
41 #define AD5823_RING_CTRL_DISABLE 0x00
43 #define AD5823_RESONANCE_PERIOD 100000
44 #define AD5823_RESONANCE_COEF 512
45 #define AD5823_HIGH_FREQ_RANGE 0x80
47 #define VCM_CODE_MSB_MASK 0xfc
48 #define AD5823_INIT_FOCUS_POS 350
50 enum ad5823_tok_type {
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 */
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)