summaryrefslogtreecommitdiff
path: root/drivers/input/sensor/mmc328x_msensor/mmc328x.h
blob: f272ea1dff9f824dd8423a9a9d4055a2c79151fb (plain)
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
/*
 * Copyright (C) 2010 MEMSIC, Inc.
 *
 *
 * 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
 *
 */

/*
 * Definitions for mmc328x magnetic sensor chip.
 */
#ifndef __MMC328X_H__
#define __MMC328X_H__

#include <linux/ioctl.h>

#define MMC328X_I2C_NAME		"mmc328x"

/*
 * This address comes must match the part# on your target.
 * Address to the sensor part# support as following list:
 *	MMC3280MS - 0110000b
 *	MMC3281MS - 0110001b
 *	MMC3282MS - 0110010b
 *	MMC3283MS - 0110011b
 *	MMC3284MS - 0110100b
 *	MMC3285MS - 0110101b
 *	MMC3286MS - 0110110b
 *	MMC3287MS - 0110111b
 * Please refer to sensor datasheet for detail.
 */
 struct wmt_msensor_data{
	// for control
	int int_gpio; //0-3
	int op;
	int samp;
	int xyz_axis[3][2]; // (axis,direction)
	struct proc_dir_entry* sensor_proc;
	struct input_dev *input_dev;
	//struct work_struct work;
	struct delayed_work work; // for polling
	struct workqueue_struct *queue;
	int isdbg;
	int sensor_samp; // 
	int sensor_enable;  // 0 --> disable sensor, 1 --> enable sensor
	int test_pass;
	int offset[3];
	struct i2c_client *client;
#ifdef CONFIG_HAS_EARLYSUSPEND
	struct early_suspend earlysuspend;
#endif

};
#define MMC328X_I2C_ADDR		0x30

/* MMC328X register address */
#define MMC328X_REG_CTRL		0x07
#define MMC328X_REG_DATA		0x00
#define MMC328X_REG_DS			0x06

/* MMC328X control bit */
#define MMC328X_CTRL_TM			0x01
#define MMC328X_CTRL_RM  	        0x20
#define MMC328X_CTRL_RRM                0x40
#define MMC328X_CTRL_NOBOOST            0x10

/* Use 'm' as magic number */
#define MMC328X_IOM			'm'

/* IOCTLs for MMC328X device */
#define MMC328X_IOC_TM			_IO (MMC328X_IOM, 0x00)
#define MMC328X_IOC_RM			_IO (MMC328X_IOM, 0x01)
#define MMC328X_IOC_READ		_IOR(MMC328X_IOM, 0x02, int[3])
#define MMC328X_IOC_READXYZ		_IOR(MMC328X_IOM, 0x03, int[3])
#define MMC328X_IOC_RRM                 _IO (MMC328X_IOM, 0x04)
#define MMC328X_IOC_NOBOOST             _IO (MMC328X_IOM, 0x05)

#endif /* __MMC328X_H__ */