summaryrefslogtreecommitdiff
path: root/drivers/misc/mpu3050/mldl_cfg.h
blob: d714a0ee3ed8481d4ee941c78251bf3c46ae28a8 (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
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
132
133
134
135
136
137
/*
 $License:
    Copyright (C) 2010 InvenSense Corporation, All Rights Reserved.

    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, see <http://www.gnu.org/licenses/>.
  $
 */

/**
 *  @addtogroup MLDL
 *
 *  @{
 *      @file   mldl_cfg.h
 *      @brief  The Motion Library Driver Layer Configuration header file.
 */

#ifndef __MLDL_CFG_H__
#define __MLDL_CFG_H__

/* ------------------ */
/* - Include Files. - */
/* ------------------ */

#include "mlsl.h"
#include "mpu.h"

/* --------------------- */
/* -    Defines.       - */
/* --------------------- */

#define SAMPLING_PERIOD(mldl_cfg) \
	(((((mldl_cfg->lpf) == 0) || ((mldl_cfg->lpf) == 7))		\
		? (8000)						\
		: (1000))						\
		/ (mldl_cfg->divider + 1))

/* --------------------- */
/* -    Variables.     - */
/* --------------------- */

/* Platform data for the MPU */
struct mldl_cfg {
	/* MPU related configuration */
	unsigned char addr;
	unsigned char int_config;
	unsigned char ext_sync;
	unsigned char full_scale;
	unsigned char lpf;
	unsigned char clk_src;
	unsigned char divider;
	unsigned char dmp_enable;
	unsigned char fifo_enable;
	unsigned char dmp_cfg1;
	unsigned char dmp_cfg2;
	unsigned char gyro_power;
	unsigned char offset_tc[MPU_NUM_AXES];
	unsigned short offset[MPU_NUM_AXES];
	unsigned char ram[MPU_MEM_NUM_RAM_BANKS][MPU_MEM_BANK_SIZE];

	/* MPU Related stored status and info */
	unsigned char silicon_revision;
	unsigned char product_id;
	unsigned short trim;

	/* Driver/Kernel related state information */
	int is_suspended;

	/* Slave related information */
	struct ext_slave_descr *accel;
	struct ext_slave_descr *compass;
	struct ext_slave_descr *pressure;

	struct mpu3050_platform_data *pdata;
};


int mpu3050_open(struct mldl_cfg *mldl_cfg,
		 void *mlsl_handle,
		 void *accel_handle,
		 void *compass_handle,
		 void *pressure_handle);
int mpu3050_close(struct mldl_cfg *mldl_cfg,
		  void *mlsl_handle,
		  void *accel_handle,
		  void *compass_handle,
		  void *pressure_handle);
int mpu3050_resume(struct mldl_cfg *mldl_cfg,
		   void *mlsl_handle,
		   void *accel_handle,
		   void *compass_handle,
		   void *pressure_handle,
		   bool resume_accel,
		   bool resume_compass,
		   bool resume_pressure);
int mpu3050_suspend(struct mldl_cfg *mldl_cfg, void *mlsl_handle,
		    void *accel_handle,
		    void *compass_handle,
		    void *pressure_handle,
		    bool resume_accel,
		    bool resume_compass,
		    bool resume_pressure);
int mpu3050_read_accel(struct mldl_cfg *mldl_cfg,
		       void *accel_handle,
		       unsigned char *data);
int mpu3050_read_compass(struct mldl_cfg *mldl_cfg,
			 void *compass_handle,
			 unsigned char *data);
int mpu3050_read_pressure(struct mldl_cfg *mldl_cfg, void *mlsl_handle,
			  unsigned char *data);

int mpu3050_config_accel(struct mldl_cfg *mldl_cfg,
			 void *accel_handle,
			 struct ext_slave_config *data);
int mpu3050_config_compass(struct mldl_cfg *mldl_cfg,
			   void *compass_handle,
			   struct ext_slave_config *data);
int mpu3050_config_pressure(struct mldl_cfg *mldl_cfg,
			    void *pressure_handle,
			    struct ext_slave_config *data);


#endif				/* __MLDL_CFG_H__ */

/**
 *@}
 */