aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mediatek/magnetometer/st480/st480.h
blob: 6f7c46efb6fd2a1bd67490c1b5a096d700cb3084 (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
121
122
123
124
125
126
127
128
129
130
131
/*
 * Definitions for senodia compass chip.
 */
#ifndef MAGNETIC_H
#define MAGNETIC_H

#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/irq.h>
#include <linux/miscdevice.h>
#include <linux/uaccess.h>
#include <asm/atomic.h>
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/workqueue.h>
#include <linux/kobject.h>
#include <linux/platform_device.h>
#include <linux/earlysuspend.h>
#include <linux/time.h>
#include <linux/hrtimer.h>
#include <linux/ioctl.h>

#include <linux/hwmsensor.h>
#include <linux/hwmsen_dev.h>
#include <linux/sensors_io.h>
#include <cust_mag.h>
#include <linux/hwmsen_helper.h>

/*
 * Self test
 */
#define SENSOR_AUTO_TEST 0

#if SENSOR_AUTO_TEST
#include <linux/kthread.h>
#endif

/*
 * I2C name
 */
#define ST480_I2C_NAME "st480"

/*
 * register shift
 */
#define ST480_REG_DRR_SHIFT 2
#define ST480_DEVICE_ID 0x7c


/*
 * register
 */
#define SINGLE_MEASUREMENT_MODE_CMD 0x3E
#define READ_MEASUREMENT_CMD 0x4E
#define WRITE_REGISTER_CMD 0x60
#define READ_REGISTER_CMD 0x50
#define EXIT_REGISTER_CMD 0x80
#define MEMORY_RECALL_CMD 0xD0
#define MEMORY_STORE_CMD 0xE0
#define RESET_CMD 0xF0

#define CALIBRATION_REG (0x02 << ST480_REG_DRR_SHIFT)
#define CALIBRATION_DATA_LOW 0x1C
#define CALIBRATION_DATA_HIGH 0x00

#define ONE_INIT_DATA_LOW 0x7C
#define ONE_INIT_DATA_HIGH 0x00
#define ONE_INIT_REG (0x00 << ST480_REG_DRR_SHIFT)

#define TWO_INIT_DATA_LOW 0x00
#define TWO_INIT_DATA_HIGH 0x00
#define TWO_INIT_REG (0x02 << ST480_REG_DRR_SHIFT)



/*
 * Miscellaneous set.
 */
#define SENSOR_DATA_SIZE 6
#define MAX_FAILURE_COUNT 3
#define ST480_DEFAULT_DELAY   27

/* 
 * Debug
 */

/*******************************************************************/
#define SENODIAIO                   0xA1

/* IOCTLs for st480d */
#define MSENSOR_IOCTL_SET_CALIDATA     	  	_IOW(MSENSOR, 0x0a, int)
#define MSENSOR_IOCTL_SET_POSTURE        	_IOW(MSENSOR, 0x09, int)



#define IOCTL_SENSOR_GET_DATA_MAG           _IO(SENODIAIO, 0x01)
#define IOCTL_SENSOR_WRITE_DATA_COMPASS     _IO(SENODIAIO, 0x02)
#define IOCTL_SENSOR_GET_COMPASS_FLAG	    _IO(SENODIAIO, 0x03)
#define IOCTL_SENSOR_GET_COMPASS_DELAY 	    _IO(SENODIAIO, 0x04)

#ifdef CONFIG_COMPAT
#define COMPAT_MSENSOR_IOCTL_SET_CALIDATA     	  	_IOW(MSENSOR, 0x0a, compat_int_t)
#define COMPAT_MSENSOR_IOCTL_SET_POSTURE        	_IOW(MSENSOR, 0x09, compat_int_t)
	
	
	
#define COMPAT_IOCTL_SENSOR_GET_DATA_MAG           _IO(SENODIAIO, 0x01)
#define COMPAT_IOCTL_SENSOR_WRITE_DATA_COMPASS     _IO(SENODIAIO, 0x02)
#define COMPAT_IOCTL_SENSOR_GET_COMPASS_FLAG	    _IO(SENODIAIO, 0x03)
#define COMPAT_IOCTL_SENSOR_GET_COMPASS_DELAY 	    _IO(SENODIAIO, 0x04)
#endif




struct SensorData {
    rwlock_t datalock;
    rwlock_t ctrllock;    
    int controldata[10];
    unsigned int debug;
    int yaw;
    int roll;
    int pitch;
    int nmx;
    int nmy;
    int nmz;
    int mag_status;
};
#endif