3 Copyright (C) 2010 InvenSense Corporation, All Rights Reserved.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 /*******************************************************************************
21 * $Id: kxtf9.c 3867 2010-10-09 01:06:18Z prao $
23 *******************************************************************************/
26 * @defgroup ACCELDL (Motion Library - Accelerometer Driver Layer)
27 * @brief Provides the interface to setup and handle an accelerometers
28 * connected to the secondary I2C interface of the gyroscope.
32 * @brief Accelerometer setup and handling methods.
35 /* ------------------ */
36 /* - Include Files. - */
37 /* ------------------ */
40 #include <linux/module.h>
49 #define MPL_LOG_TAG "MPL-acc"
51 /* --------------------- */
53 /* --------------------- */
55 /*****************************************
56 Accelerometer Initialization Functions
57 *****************************************/
59 static int kxtf9_suspend(mlsl_handle_t mlsl_handle,
60 struct ext_slave_descr *slave,
61 struct ext_slave_platform_data *pdata)
65 result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1d, 0xcd);
69 /* full scale setting - register and mask */
70 #define ACCEL_KIONIX_CTRL_REG (0x1b)
71 #define ACCEL_KIONIX_CTRL_MASK (0x18)
73 static int kxtf9_resume(mlsl_handle_t mlsl_handle,
74 struct ext_slave_descr *slave,
75 struct ext_slave_platform_data *pdata)
77 int result = ML_SUCCESS;
81 result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1d, 0xcd);
84 result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1b, 0x42);
86 result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1e, 0x14);
88 result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x5a, 0x00);
90 result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x21, 0x04);
92 result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x29, 0x02);
96 reg &= ~ACCEL_KIONIX_CTRL_MASK;
97 reg |= 0x00; /* TODO FIXME michelle */
98 if (slave->range.mantissa == 2) {
100 } else if (slave->range.mantissa == 4) {
102 } else if (slave->range.mantissa == 8) {
105 /* Normal operation */
106 result = MLSLSerialWriteSingle(mlsl_handle, pdata->address, 0x1b, reg);
112 static int kxtf9_read(mlsl_handle_t mlsl_handle,
113 struct ext_slave_descr *slave,
114 struct ext_slave_platform_data *pdata,
117 return ML_ERROR_FEATURE_NOT_IMPLEMENTED;
120 static struct ext_slave_descr kxtf9_descr = {
121 /*.suspend = */ kxtf9_suspend,
122 /*.resume = */ kxtf9_resume,
123 /*.read = */ kxtf9_read,
124 /*.name = */ "kxtf9",
125 /*.type = */ EXT_SLAVE_TYPE_ACCELEROMETER,
126 /*.id = */ ACCEL_ID_KXTF9,
129 /*.endian = */ EXT_SLAVE_LITTLE_ENDIAN,
130 /*.range = */ {2, 0},
133 struct ext_slave_descr *kxtf9_get_slave_descr(void)
139 EXPORT_SYMBOL(kxtf9_get_slave_descr);