import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / magnetometer / lsm303c-new / lsm303c.h
1 /* linux/drivers/hwmon/LSM303C.c
2 *
3 * (C) Copyright 2008
4 * MediaTek <www.mediatek.com>
5 *
6 * LSM303C driver for MT6516
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23
24 #ifndef LSM303C
25 #define LSM303C
26 #include <linux/ioctl.h>
27
28 /* Magnetometer Sensor Full Scale */
29 // conversion of magnetic data to uT units
30 #define CONVERT_M (1.0f/10.0f)
31 #define CONVERT_M_X (CONVERT_M)
32 #define CONVERT_M_Y (CONVERT_M)
33 #define CONVERT_M_Z (CONVERT_M)
34
35 #define I2C_AUTO_INCREMENT (0x80)
36
37
38 #define LSM303C_REG_CTL0 0x1F
39 #define LSM303C_REG_DEVID 0x0F
40 #define LSM303C_REG_BW_RATE 0x20
41 #define LSM303C_REG_DATA_FORMAT 0x21
42 #define LSM303C_REG_POWER_CTL 0x22
43 #define LSM303C_REG_DATAX0 0x28
44
45 #define LSM303C_REG_OFSX 0XFF
46
47
48
49
50 #define LSM303C_FIXED_DEVID 0x3d
51
52
53 #define LSM303C_MAG_FS_MASK (0x60)
54 #define LSM303C_MAG_FS_16G (0x60) /* Full scale 16 gauss */
55
56
57 #define SENSITIVITY_MAG_16G 480 /** ugauss/LSB */
58
59 #define LSM303C_MAG_POWER_ON (0x00) /* POWER ON */
60 #define LSM303C_MAG_POWER_OFF (0x02) /* POWER ON */
61
62
63 #define ODR_MAG_MASK (0X1C) /* Mask for odr change on mag */
64 //#define LSM303C_MAG_ODR3_125 (0x00) /* 3.25Hz output data rate */
65 #define LSM303C_MAG_ODR_625 (0x00) /* 0.625Hz output data rate */
66 #define LSM303C_MAG_ODR1_25 (0x04) /* 1.25Hz output data rate */
67 #define LSM303C_MAG_ODR2_5 (0x08) /* 2.5Hz output data rate */
68 #define LSM303C_MAG_ODR5 (0x0c) /* 5Hz output data rate */
69 #define LSM303C_MAG_ODR10 (0x10) /* 10Hz output data rate */
70 #define LSM303C_MAG_ODR20 (0x14) /* 20Hz output data rate */
71 #define LSM303C_MAG_ODR40 (0x18) /* 20Hz output data rate */
72 #define LSM303C_MAG_ODR80 (0x1c) /* 20Hz output data rate */
73
74
75 #define LSM303C_SUCCESS 0
76 #define LSM303C_ERR_I2C -1
77 #define LSM303C_ERR_STATUS -3
78 #define LSM303C_ERR_SETUP_FAILURE -4
79 #define LSM303C_ERR_GETGSENSORDATA -5
80 #define LSM303C_ERR_IDENTIFICATION -6
81
82
83
84 #define LSM303C_BUFSIZE 256
85
86
87 #endif