aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mediatek/accelerometer/bma250e/bma250.h
blob: 9527355e59afba3193a3a3b54b4afdb9e4603e4d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* linux/drivers/hwmon/adxl345.c
 *
 * (C) Copyright 2008 
 * MediaTek <www.mediatek.com>
 *
 * BMA150 driver for MT6516
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  BMA150
 */
#ifndef BMA250_H
#define BMA250_H
	 
#include <linux/ioctl.h>
	 
	#define BMA250_I2C_SLAVE_WRITE_ADDR		0x30
	 
	 /* BMA222 Register Map  (Please refer to BMA150 Specifications) */
	#define BMA250_REG_DEVID				0x00
	#define BMA250_FIXED_DEVID			0x03
	#define BMA250E_FIXED_DEVID			0xF9
	#define BMA250_REG_OFSX				0x16
	#define BMA250_REG_OFSX_HIGH			0x1A
	#define BMA250_REG_BW_RATE			0x10
	#define BMA250_BW_MASK				0x1f
	#define BMA250_BW_200HZ				0x0d
	#define BMA250_BW_100HZ				0x0c
	#define BMA250_BW_50HZ				0x0b
	#define BMA250_BW_25HZ				0x0a
	#define BMA250_REG_POWER_CTL		0x11		
	#define BMA250_REG_DATA_FORMAT		0x0f
	#define BMA250_RANGE_MASK			0x0f
	#define BMA250_RANGE_2G				0x03
	#define BMA250_RANGE_4G				0x05
	#define BMA250_RANGE_8G				0x08
	#define BMA250_REG_DATAXLOW			0x02
	#define BMA250_REG_DATA_RESOLUTION	0x14
	#define BMA250_MEASURE_MODE			0x80	
	#define BMA250_SELF_TEST           			0x32
	#define BMA250_SELF_TEST_AXIS_X		0x01
	#define BMA250_SELF_TEST_AXIS_Y		0x02
	#define BMA250_SELF_TEST_AXIS_Z		0x03
	#define BMA250_SELF_TEST_POSITIVE	0x00
	#define BMA250_SELF_TEST_NEGATIVE	0x04
	#define BMA250_INT_REG_1           			0x16
	#define BMA250_INT_REG_2          		 	0x17
	#define BMA250_EEPROM_CTL_REG       0x33
	#define BMA250_RESERVED_REG_1       0x3E
	#define BMA250E_RESERVED_REG_1      0x3B
	
#define BMA250_SUCCESS						0
#define BMA250_ERR_I2C						-1
#define BMA250_ERR_STATUS					-3
#define BMA250_ERR_SETUP_FAILURE			-4
#define BMA250_ERR_GETGSENSORDATA			-5
#define BMA250_ERR_IDENTIFICATION			-6
	 
	 
	 
#define BMA250_BUFSIZE				256

/*----------------------------------------------------------------------------*/
#define BMA250_AXIS_X          0
#define BMA250_AXIS_Y          1
#define BMA250_AXIS_Z          2
#define BMA250_AXES_NUM        3
#define BMA250_DATA_LEN        6
#define BMA250_DEV_NAME        "BMA250"

/*----------------------------------------------------------------------------*/
typedef enum{
    BMA250_CUST_ACTION_SET_CUST = 1,
    BMA250_CUST_ACTION_SET_CALI,
    BMA250_CUST_ACTION_RESET_CALI
}CUST_ACTION;
/*----------------------------------------------------------------------------*/
typedef struct
{
    uint16_t    action;
}BMA250_CUST;
/*----------------------------------------------------------------------------*/
typedef struct
{
    uint16_t    action;
    uint16_t    part;
    int32_t     data[0];
}BMA250_SET_CUST;
/*----------------------------------------------------------------------------*/
typedef struct
{
    uint16_t    action;
    int32_t     data[BMA250_AXES_NUM];
}BMA250_SET_CALI;
/*----------------------------------------------------------------------------*/
typedef BMA250_CUST BMA250_RESET_CALI;
/*----------------------------------------------------------------------------*/
typedef union
{
    uint32_t                data[10];
    BMA250_CUST         cust;
    BMA250_SET_CUST     setCust;
    BMA250_SET_CALI     setCali;
    BMA250_RESET_CALI   resetCali;
}BMA250_CUST_DATA;
/*----------------------------------------------------------------------------*/

	 
#endif