misc: inv_mpu: Remove unused kernel files.
Robert Collins [Wed, 13 Nov 2013 23:10:47 +0000 (15:10 -0800)]
Bug 1406088

Change-Id: Iff64878f908e14c7fd6eee7eafd922e06c7ab7c4
Signed-off-by: Robert Collins <rcollins@nvidia.com>
Reviewed-on: http://git-master/r/330742
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Allen Martin <amartin@nvidia.com>
Reviewed-by: Jon Mayo <jmayo@nvidia.com>

82 files changed:
drivers/misc/inv_mpu/Kconfig [deleted file]
drivers/misc/inv_mpu/Makefile [deleted file]
drivers/misc/inv_mpu/accel/Kconfig [deleted file]
drivers/misc/inv_mpu/accel/Makefile [deleted file]
drivers/misc/inv_mpu/accel/adxl34x.c [deleted file]
drivers/misc/inv_mpu/accel/bma150.c [deleted file]
drivers/misc/inv_mpu/accel/bma222.c [deleted file]
drivers/misc/inv_mpu/accel/bma250.c [deleted file]
drivers/misc/inv_mpu/accel/cma3000.c [deleted file]
drivers/misc/inv_mpu/accel/kxsd9.c [deleted file]
drivers/misc/inv_mpu/accel/kxtf9.c [deleted file]
drivers/misc/inv_mpu/accel/lis331.c [deleted file]
drivers/misc/inv_mpu/accel/lis3dh.c [deleted file]
drivers/misc/inv_mpu/accel/lsm303dlx_a.c [deleted file]
drivers/misc/inv_mpu/accel/mma8450.c [deleted file]
drivers/misc/inv_mpu/accel/mma845x.c [deleted file]
drivers/misc/inv_mpu/accel/mpu6050.c [deleted file]
drivers/misc/inv_mpu/accel/mpu6050.h [deleted file]
drivers/misc/inv_mpu/compass/Kconfig [deleted file]
drivers/misc/inv_mpu/compass/Makefile [deleted file]
drivers/misc/inv_mpu/compass/ak8972.c [deleted file]
drivers/misc/inv_mpu/compass/ak8975.c [deleted file]
drivers/misc/inv_mpu/compass/ak89xx.c [deleted file]
drivers/misc/inv_mpu/compass/ami306.c [deleted file]
drivers/misc/inv_mpu/compass/ami30x.c [deleted file]
drivers/misc/inv_mpu/compass/ami_hw.h [deleted file]
drivers/misc/inv_mpu/compass/ami_sensor_def.h [deleted file]
drivers/misc/inv_mpu/compass/hmc5883.c [deleted file]
drivers/misc/inv_mpu/compass/hscdtd002b.c [deleted file]
drivers/misc/inv_mpu/compass/hscdtd004a.c [deleted file]
drivers/misc/inv_mpu/compass/lsm303dlx_m.c [deleted file]
drivers/misc/inv_mpu/compass/mmc314x.c [deleted file]
drivers/misc/inv_mpu/compass/yas529-kernel.c [deleted file]
drivers/misc/inv_mpu/compass/yas530.c [deleted file]
drivers/misc/inv_mpu/log.h [deleted file]
drivers/misc/inv_mpu/mldl_cfg.h [deleted file]
drivers/misc/inv_mpu/mldl_print_cfg.h [deleted file]
drivers/misc/inv_mpu/mlsl.h [deleted file]
drivers/misc/inv_mpu/mltypes.h [deleted file]
drivers/misc/inv_mpu/mpu-dev.h [deleted file]
drivers/misc/inv_mpu/mpu3050.h [deleted file]
drivers/misc/inv_mpu/mpu3050/Makefile [deleted file]
drivers/misc/inv_mpu/mpu3050/mldl_cfg.c [deleted file]
drivers/misc/inv_mpu/mpu3050/mldl_print_cfg.c [deleted file]
drivers/misc/inv_mpu/mpu3050/mlsl-kernel.c [deleted file]
drivers/misc/inv_mpu/mpu3050/mpu-dev.c [deleted file]
drivers/misc/inv_mpu/mpu6050/Makefile [deleted file]
drivers/misc/inv_mpu/mpu6050/mldl_cfg.c [deleted file]
drivers/misc/inv_mpu/mpu6050/mldl_print_cfg.c [deleted file]
drivers/misc/inv_mpu/mpu6050/mlsl-kernel.c [deleted file]
drivers/misc/inv_mpu/mpu6050/mpu-dev.c [deleted file]
drivers/misc/inv_mpu/mpu6050b1.h [deleted file]
drivers/misc/inv_mpu/mpuirq.c [deleted file]
drivers/misc/inv_mpu/mpuirq.h [deleted file]
drivers/misc/inv_mpu/pressure/Kconfig [deleted file]
drivers/misc/inv_mpu/pressure/Makefile [deleted file]
drivers/misc/inv_mpu/pressure/bma085.c [deleted file]
drivers/misc/inv_mpu/slaveirq.c [deleted file]
drivers/misc/inv_mpu/slaveirq.h [deleted file]
drivers/misc/inv_mpu/timerirq.c [deleted file]
drivers/misc/inv_mpu/timerirq.h [deleted file]
drivers/misc/mpu3050/Kconfig [deleted file]
drivers/misc/mpu3050/Makefile [deleted file]
drivers/misc/mpu3050/accel/kxtf9.c [deleted file]
drivers/misc/mpu3050/compass/ak8975.c [deleted file]
drivers/misc/mpu3050/log.h [deleted file]
drivers/misc/mpu3050/mldl_cfg.c [deleted file]
drivers/misc/mpu3050/mldl_cfg.h [deleted file]
drivers/misc/mpu3050/mlos-kernel.c [deleted file]
drivers/misc/mpu3050/mlos.h [deleted file]
drivers/misc/mpu3050/mlsl-kernel.c [deleted file]
drivers/misc/mpu3050/mlsl.h [deleted file]
drivers/misc/mpu3050/mltypes.h [deleted file]
drivers/misc/mpu3050/mpu-dev.c [deleted file]
drivers/misc/mpu3050/mpu-i2c.c [deleted file]
drivers/misc/mpu3050/mpu-i2c.h [deleted file]
drivers/misc/mpu3050/mpuirq.c [deleted file]
drivers/misc/mpu3050/mpuirq.h [deleted file]
drivers/misc/mpu3050/slaveirq.c [deleted file]
drivers/misc/mpu3050/slaveirq.h [deleted file]
drivers/misc/mpu3050/timerirq.c [deleted file]
drivers/misc/mpu3050/timerirq.h [deleted file]

diff --git a/drivers/misc/inv_mpu/Kconfig b/drivers/misc/inv_mpu/Kconfig
deleted file mode 100644 (file)
index 4c231b5..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-config MPU_SENSORS_TIMERIRQ
-       tristate "MPU Timer IRQ"
-       help
-         If you say yes here you get access to the timerirq device handle which
-         can be used to select on.  This can be used instead of IRQ's, sleeping,
-         or timer threads.  Reading from this device returns the same type of
-         information as reading from the MPU and slave IRQ's.
-
-menuconfig INV_SENSORS
-       tristate "Motion Processing Unit"
-       depends on I2C
-       default y
-
-if INV_SENSORS
-
-choice
-       tristate "MPU Master"
-       depends on I2C && INV_SENSORS
-       default MPU_SENSORS_MPU3050
-
-config MPU_SENSORS_MPU3050
-       tristate "MPU3050"
-       depends on I2C
-       select MPU_SENSORS_MPU3050_GYRO
-       help
-         If you say yes here you get support for the MPU3050 Gyroscope driver
-         This driver can also be built as a module.  If so, the module
-         will be called mpu3050.
-
-config MPU_SENSORS_MPU6050A2
-       tristate "MPU6050A2"
-       depends on I2C
-       select MPU_SENSORS_MPU6050_GYRO
-       help
-         If you say yes here you get support for the MPU6050A2 Gyroscope driver
-         This driver can also be built as a module.  If so, the module
-         will be called mpu6050a2.
-
-config MPU_SENSORS_MPU6050B1
-       tristate "MPU6050B1"
-       depends on I2C
-       select MPU_SENSORS_MPU6050_GYRO
-       help
-         If you say yes here you get support for the MPU6050 Gyroscope driver
-         This driver can also be built as a module.  If so, the module
-         will be called mpu6050b1.
-
-endchoice
-
-config MPU_SENSORS_MPU3050_GYRO
-       bool "MPU3050 built in gyroscope"
-       depends on MPU_SENSORS_MPU3050
-
-config MPU_SENSORS_MPU6050_GYRO
-       bool "MPU6050 built in gyroscope"
-       depends on MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-
-source "drivers/misc/inv_mpu/accel/Kconfig"
-source "drivers/misc/inv_mpu/compass/Kconfig"
-source "drivers/misc/inv_mpu/pressure/Kconfig"
-
-config MPU_USERSPACE_DEBUG
-       bool "MPU Userspace debugging ioctls"
-       help
-         Allows the ioctls MPU_SET_MPU_PLATFORM_DATA and
-         MPU_SET_EXT_SLAVE_PLATFORM_DATA, which allows userspace applications
-         to override the slave address and orientation.  This is dangerous
-         and could cause the devices not to work.
-
-endif #INV_SENSORS
diff --git a/drivers/misc/inv_mpu/Makefile b/drivers/misc/inv_mpu/Makefile
deleted file mode 100644 (file)
index f10c684..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-# Kernel makefile for motions sensors
-#
-#
-
-EXTRA_CFLAGS += -Idrivers/misc/inv_mpu
-EXTRA_CFLAGS += -D__C99_DESIGNATED_INITIALIZER
-EXTRA_CFLAGS += -DINV_CACHE_DMP=1
-
-obj-$(CONFIG_MPU_SENSORS_TIMERIRQ)+= timerirq.o
-obj-$(CONFIG_INV_SENSORS) += mpuirq.o slaveirq.o
-
-obj-$(CONFIG_MPU_SENSORS_MPU3050) += mpu3050/
-obj-$(CONFIG_MPU_SENSORS_MPU6050B1) += mpu6050/
-
-obj-y += accel/
-obj-y += compass/
-obj-y += pressure/
diff --git a/drivers/misc/inv_mpu/accel/Kconfig b/drivers/misc/inv_mpu/accel/Kconfig
deleted file mode 100644 (file)
index 4e280bd..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-menuconfig INV_SENSORS_ACCELEROMETERS
-       bool "Accelerometer Slave Sensors"
-       default y
-       ---help---
-         Say Y here to get to see options for device drivers for various
-         accelerometrs for integration with the MPU3050 or MPU6050 driver.
-         This option alone does not add any kernel code.
-
-         If you say N, all options in this submenu will be skipped and disabled.
-
-if INV_SENSORS_ACCELEROMETERS
-
-config MPU_SENSORS_ADXL34X
-       tristate "ADI adxl34x"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the ADI adxl345 or adxl346 accelerometers.
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_BMA222
-       tristate "Bosch BMA222"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the Bosch BMA222 accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_BMA150
-       tristate "Bosch BMA150"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the Bosch BMA150 accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_BMA250
-       tristate "Bosch BMA250"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the Bosch BMA250 accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_KXSD9
-       tristate "Kionix KXSD9"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the Kionix KXSD9 accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_KXTF9
-       tristate "Kionix KXTF9"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the Kionix KXFT9 accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_LIS331DLH
-       tristate "ST lis331dlh"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the ST lis331dlh accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_LIS3DH
-       tristate "ST lis3dh"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the ST lis3dh accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_LSM303DLX_A
-       tristate "ST lsm303dlx"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the ST lsm303dlh and lsm303dlm accelerometers
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_MMA8450
-       tristate "Freescale mma8450"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the Freescale mma8450 accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_MMA845X
-       tristate "Freescale mma8451/8452/8453"
-       depends on MPU_SENSORS_MPU3050 || MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the Freescale mma8451/8452/8453 accelerometer
-         This support is for integration with the MPU3050 gyroscope device
-         driver.  Only one accelerometer can be registered at a time.
-         Specifying more that one accelerometer in the board file will result
-         in runtime errors.
-
-config MPU_SENSORS_MPU6050_ACCEL
-       tristate "MPU6050 built in accelerometer"
-       depends on MPU_SENSORS_MPU6050B1 || MPU_SENSORS_MPU6050A2
-       help
-         This enables support for the MPU6050 built in accelerometer.
-         This the built in support for integration with the MPU6050 gyroscope
-         device driver.  This is the only accelerometer supported with the
-         MPU6050.  Specifying another accelerometer in the board file will
-         result in runtime errors.
-
-endif
diff --git a/drivers/misc/inv_mpu/accel/Makefile b/drivers/misc/inv_mpu/accel/Makefile
deleted file mode 100644 (file)
index 1f0f5be..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Accel Slaves to MPUxxxx
-#
-obj-$(CONFIG_MPU_SENSORS_ADXL34X) += inv_mpu_adxl34x.o
-inv_mpu_adxl34x-objs += adxl34x.o
-
-obj-$(CONFIG_MPU_SENSORS_BMA150) += inv_mpu_bma150.o
-inv_mpu_bma150-objs += bma150.o
-
-obj-$(CONFIG_MPU_SENSORS_KXTF9) += inv_mpu_kxtf9.o
-inv_mpu_kxtf9-objs += kxtf9.o
-
-obj-$(CONFIG_MPU_SENSORS_BMA222) += inv_mpu_bma222.o
-inv_mpu_bma222-objs += bma222.o
-
-obj-$(CONFIG_MPU_SENSORS_BMA250) += inv_mpu_bma250.o
-inv_mpu_bma250-objs += bma250.o
-
-obj-$(CONFIG_MPU_SENSORS_KXSD9) += inv_mpu_kxsd9.o
-inv_mpu_kxsd9-objs += kxsd9.o
-
-obj-$(CONFIG_MPU_SENSORS_LIS331DLH) += inv_mpu_lis331.o
-inv_mpu_lis331-objs += lis331.o
-
-obj-$(CONFIG_MPU_SENSORS_LIS3DH) += inv_mpu_lis3dh.o
-inv_mpu_lis3dh-objs += lis3dh.o
-
-obj-$(CONFIG_MPU_SENSORS_LSM303DLX_A) += inv_mpu_lsm303dlx_a.o
-inv_mpu_lsm303dlx_a-objs += lsm303dlx_a.o
-
-obj-$(CONFIG_MPU_SENSORS_MMA8450) += inv_mpu_mma8450.o
-inv_mpu_mma8450-objs += mma8450.o
-
-obj-$(CONFIG_MPU_SENSORS_MMA845X) += inv_mpu_mma845x.o
-inv_mpu_mma845x-objs += mma845x.o
-
-EXTRA_CFLAGS += -Idrivers/misc/inv_mpu
-EXTRA_CFLAGS += -D__C99_DESIGNATED_INITIALIZER
diff --git a/drivers/misc/inv_mpu/accel/adxl34x.c b/drivers/misc/inv_mpu/accel/adxl34x.c
deleted file mode 100644 (file)
index f2bff8a..0000000
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   adxl34x.c
- *      @brief  Accelerometer setup and handling methods for AD adxl345 and
- *              adxl346.
- */
-
-/* -------------------------------------------------------------------------- */
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-/* -------------------------------------------------------------------------- */
-
-/* registers */
-#define ADXL34X_ODR_REG                        (0x2C)
-#define ADXL34X_PWR_REG                        (0x2D)
-#define ADXL34X_DATAFORMAT_REG         (0x31)
-
-/* masks */
-#define ADXL34X_ODR_MASK               (0x0F)
-#define ADXL34X_PWR_SLEEP_MASK         (0x04)
-#define ADXL34X_PWR_MEAS_MASK          (0x08)
-#define ADXL34X_DATAFORMAT_JUSTIFY_MASK        (0x04)
-#define ADXL34X_DATAFORMAT_FSR_MASK    (0x03)
-
-/* -------------------------------------------------------------------------- */
-
-struct adxl34x_config {
-       unsigned int odr;               /** < output data rate in mHz */
-       unsigned int fsr;               /** < full scale range mg */
-       unsigned int fsr_reg_mask;      /** < register setting for fsr */
-};
-
-struct adxl34x_private_data {
-       struct adxl34x_config suspend;  /** < suspend configuration */
-       struct adxl34x_config resume;   /** < resume configuration */
-};
-
-/**
- *  @brief Set the output data rate for the particular configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             Config to modify with new ODR.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param odr
- *             Output data rate in units of 1/1000Hz (mHz).
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_set_odr(void *mlsl_handle,
-                          struct ext_slave_platform_data *pdata,
-                          struct adxl34x_config *config,
-                          int apply,
-                          long odr)
-{
-       int result = INV_SUCCESS;
-       unsigned char new_odr_mask;
-
-       /* ADXL346 (Rev. A) pages 13, 24 */
-       if (odr >= 3200000) {
-               new_odr_mask = 0x0F;
-               config->odr = 3200000;
-       } else if (odr >= 1600000) {
-               new_odr_mask = 0x0E;
-               config->odr = 1600000;
-       } else if (odr >= 800000) {
-               new_odr_mask = 0x0D;
-               config->odr = 800000;
-       } else if (odr >= 400000) {
-               new_odr_mask = 0x0C;
-               config->odr = 400000;
-       } else if (odr >= 200000) {
-               new_odr_mask = 0x0B;
-               config->odr = 200000;
-       } else if (odr >= 100000) {
-               new_odr_mask = 0x0A;
-               config->odr = 100000;
-       } else if (odr >= 50000) {
-               new_odr_mask = 0x09;
-               config->odr = 50000;
-       } else if (odr >= 25000) {
-               new_odr_mask = 0x08;
-               config->odr = 25000;
-       } else if (odr >= 12500) {
-               new_odr_mask = 0x07;
-               config->odr = 12500;
-       } else if (odr >= 6250) {
-               new_odr_mask = 0x06;
-               config->odr = 6250;
-       } else if (odr >= 3130) {
-               new_odr_mask = 0x05;
-               config->odr = 3130;
-       } else if (odr >= 1560) {
-               new_odr_mask = 0x04;
-               config->odr = 1560;
-       } else if (odr >= 780) {
-               new_odr_mask = 0x03;
-               config->odr = 780;
-       } else if (odr >= 390) {
-               new_odr_mask = 0x02;
-               config->odr = 390;
-       } else if (odr >= 200) {
-               new_odr_mask = 0x01;
-               config->odr = 200;
-       } else {
-               new_odr_mask = 0x00;
-               config->odr = 100;
-       }
-
-       if (apply) {
-               unsigned char reg_odr;
-               result = inv_serial_read(mlsl_handle, pdata->address,
-                               ADXL34X_ODR_REG, 1, &reg_odr);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               reg_odr &= ~ADXL34X_ODR_MASK;
-               reg_odr |= new_odr_mask;
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               ADXL34X_ODR_REG, reg_odr);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               MPL_LOGV("ODR: %d mHz\n", config->odr);
-       }
-       return result;
-}
-
-/**
- *  @brief Set the full scale range of the accels
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             pointer to configuration.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param fsr
- *             requested full scale range in milli gees (mg).
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_set_fsr(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct adxl34x_config *config,
-                         int apply,
-                         long fsr)
-{
-       int result = INV_SUCCESS;
-
-       if (fsr <= 2000) {
-               config->fsr_reg_mask = 0x00;
-               config->fsr = 2000;
-       } else if (fsr <= 4000) {
-               config->fsr_reg_mask = 0x01;
-               config->fsr = 4000;
-       } else if (fsr <= 8000) {
-               config->fsr_reg_mask = 0x02;
-               config->fsr = 8000;
-       } else { /* 8001 -> oo */
-               config->fsr_reg_mask = 0x03;
-               config->fsr = 16000;
-       }
-
-       if (apply) {
-               unsigned char reg_df;
-               result = inv_serial_read(mlsl_handle, pdata->address,
-                               ADXL34X_DATAFORMAT_REG, 1, &reg_df);
-               reg_df &= ~ADXL34X_DATAFORMAT_FSR_MASK;
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               ADXL34X_DATAFORMAT_REG,
-                               reg_df | config->fsr_reg_mask);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               MPL_LOGV("FSR: %d mg\n", config->fsr);
-       }
-       return result;
-}
-
-/**
- *  @brief facility to retrieve the device configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to store the returned configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_get_config(void *mlsl_handle,
-                   struct ext_slave_descr *slave,
-                               struct ext_slave_platform_data *pdata,
-                               struct ext_slave_config *data)
-{
-       struct adxl34x_private_data *private_data =
-                       (struct adxl34x_private_data *)(pdata->private_data);
-
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief device configuration facility.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to the configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_config(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata,
-                        struct ext_slave_config *data)
-{
-       struct adxl34x_private_data *private_data =
-                       (struct adxl34x_private_data *)(pdata->private_data);
-
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return adxl34x_set_odr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return adxl34x_set_odr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return adxl34x_set_fsr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return adxl34x_set_fsr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief suspends the device to put it in its lowest power mode.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_suspend(void *mlsl_handle,
-                          struct ext_slave_descr *slave,
-                          struct ext_slave_platform_data *pdata)
-{
-       int result;
-
-       /*
-       struct adxl34x_config *suspend_config =
-               &((struct adxl34x_private_data *)pdata->private_data)->suspend;
-
-       result = adxl34x_set_odr(mlsl_handle, pdata, suspend_config,
-                               true, suspend_config->odr);
-       if (result) {
-       LOG_RESULT_LOCATION(result);
-       return result;
-}
-       result = adxl34x_set_fsr(mlsl_handle, pdata, suspend_config,
-                               true, suspend_config->fsr);
-       if (result) {
-       LOG_RESULT_LOCATION(result);
-       return result;
-}
-       */
-
-       /*
-         Page 25
-         When clearing the sleep bit, it is recommended that the part
-         be placed into standby mode and then set back to measurement mode
-         with a subsequent write.
-         This is done to ensure that the device is properly biased if sleep
-         mode is manually disabled; otherwise, the first few samples of data
-         after the sleep bit is cleared may have additional noise,
-         especially if the device was asleep when the bit was cleared. */
-
-       /* go in standy-by mode (suspends measurements) */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       ADXL34X_PWR_REG, ADXL34X_PWR_MEAS_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* and then in sleep */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       ADXL34X_PWR_REG,
-                       ADXL34X_PWR_MEAS_MASK | ADXL34X_PWR_SLEEP_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       return result;
-}
-
-/**
- *  @brief resume the device in the proper power state given the configuration
- *         chosen.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_resume(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       struct adxl34x_config *resume_config =
-               &((struct adxl34x_private_data *)pdata->private_data)->resume;
-       unsigned char reg;
-
-       /*
-         Page 25
-         When clearing the sleep bit, it is recommended that the part
-         be placed into standby mode and then set back to measurement mode
-         with a subsequent write.
-         This is done to ensure that the device is properly biased if sleep
-         mode is manually disabled; otherwise, the first few samples of data
-         after the sleep bit is cleared may have additional noise,
-         especially if the device was asleep when the bit was cleared. */
-
-       /* remove sleep, but leave in stand-by */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       ADXL34X_PWR_REG, ADXL34X_PWR_MEAS_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = adxl34x_set_odr(mlsl_handle, pdata, resume_config,
-                               true, resume_config->odr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       /*
-         -> FSR
-         -> Justiy bit for Big endianess
-         -> resulution to 10 bits
-       */
-       reg = ADXL34X_DATAFORMAT_JUSTIFY_MASK;
-       reg |= resume_config->fsr_reg_mask;
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       ADXL34X_DATAFORMAT_REG, reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       /* go in measurement mode */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       ADXL34X_PWR_REG, 0x00);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       /* DATA_FORMAT: full resolution of +/-2g; data is left justified */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        0x31, reg);
-
-       return result;
-}
-
-/**
- *  @brief one-time device driver initialization function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is loaded in the kernel.
- *         If the driver is built-in in the kernel, this function will be
- *         called at boot time.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_init(void *mlsl_handle,
-                       struct ext_slave_descr *slave,
-                       struct ext_slave_platform_data *pdata)
-{
-       int result;
-       long range;
-
-       struct adxl34x_private_data *private_data;
-       private_data = (struct adxl34x_private_data *)
-           kzalloc(sizeof(struct adxl34x_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       pdata->private_data = private_data;
-
-       result = adxl34x_set_odr(mlsl_handle, pdata, &private_data->suspend,
-                               false, 0);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = adxl34x_set_odr(mlsl_handle, pdata, &private_data->resume,
-                               false, 200000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       range = range_fixedpoint_to_long_mg(slave->range);
-       result = adxl34x_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                               false, range);
-       result = adxl34x_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                               false, range);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = adxl34x_suspend(mlsl_handle, slave, pdata);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief one-time device driver exit function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is removed from the kernel.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_exit(void *mlsl_handle,
-                struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief read the sensor data from the device.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a buffer to store the data read.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int adxl34x_read(void *mlsl_handle,
-                       struct ext_slave_descr *slave,
-                       struct ext_slave_platform_data *pdata,
-                       unsigned char *data)
-{
-       int result;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                slave->read_reg, slave->read_len, data);
-       return result;
-}
-
-static struct ext_slave_descr adxl34x_descr = {
-       .init             = adxl34x_init,
-       .exit             = adxl34x_exit,
-       .suspend          = adxl34x_suspend,
-       .resume           = adxl34x_resume,
-       .read             = adxl34x_read,
-       .config           = adxl34x_config,
-       .get_config       = adxl34x_get_config,
-       .name             = "adxl34x",  /* 5 or 6 */
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_ADXL34X,
-       .read_reg         = 0x32,
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_LITTLE_ENDIAN,
-       .range            = {2, 0},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *adxl34x_get_slave_descr(void)
-{
-       return &adxl34x_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-struct adxl34x_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int adxl34x_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct adxl34x_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       adxl34x_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int adxl34x_mod_remove(struct i2c_client *client)
-{
-       struct adxl34x_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               adxl34x_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id adxl34x_mod_id[] = {
-       { "adxl34x", ACCEL_ID_ADXL34X },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, adxl34x_mod_id);
-
-static struct i2c_driver adxl34x_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = adxl34x_mod_probe,
-       .remove = adxl34x_mod_remove,
-       .id_table = adxl34x_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "adxl34x_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init adxl34x_mod_init(void)
-{
-       int res = i2c_add_driver(&adxl34x_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "adxl34x_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit adxl34x_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&adxl34x_mod_driver);
-}
-
-module_init(adxl34x_mod_init);
-module_exit(adxl34x_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate ADXL34X sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("adxl34x_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/bma150.c b/drivers/misc/inv_mpu/accel/bma150.c
deleted file mode 100644 (file)
index 745d90a..0000000
+++ /dev/null
@@ -1,777 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   bma150.c
- *      @brief  Accelerometer setup and handling methods for Bosch BMA150.
- */
-
-/* -------------------------------------------------------------------------- */
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-
-/* -------------------------------------------------------------------------- */
-/* registers */
-#define BMA150_CTRL_REG                        (0x14)
-#define BMA150_INT_REG                 (0x15)
-#define BMA150_PWR_REG                 (0x0A)
-
-/* masks */
-#define BMA150_CTRL_MASK               (0x18)
-#define BMA150_CTRL_MASK_ODR           (0xF8)
-#define BMA150_CTRL_MASK_FSR           (0xE7)
-#define BMA150_INT_MASK_WUP            (0xF8)
-#define BMA150_INT_MASK_IRQ            (0xDF)
-#define BMA150_PWR_MASK_SLEEP          (0x01)
-#define BMA150_PWR_MASK_SOFT_RESET     (0x02)
-
-/* -------------------------------------------------------------------------- */
-struct bma150_config {
-       unsigned int odr;       /** < output data rate mHz */
-       unsigned int fsr;       /** < full scale range mgees */
-       unsigned int irq_type;  /** < type of IRQ, see bma150_set_irq */
-       unsigned char ctrl_reg; /** < control register value */
-       unsigned char int_reg;  /** < interrupt control register value */
-};
-
-struct bma150_private_data {
-       struct bma150_config suspend;   /** < suspend configuration */
-       struct bma150_config resume;    /** < resume configuration */
-};
-
-/**
- *  @brief Simply disables the IRQ since it is not usable on BMA150 devices.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *              configuration to apply to, suspend or resume
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param irq_type
- *              the type of IRQ.  Valid values are
- *              - MPU_SLAVE_IRQ_TYPE_NONE
- *              - MPU_SLAVE_IRQ_TYPE_MOTION
- *              - MPU_SLAVE_IRQ_TYPE_DATA_READY
- *              The only supported IRQ type is MPU_SLAVE_IRQ_TYPE_NONE which
- *              corresponds to disabling the IRQ completely.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_set_irq(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct bma150_config *config,
-                         int apply,
-                         long irq_type)
-{
-       int result = INV_SUCCESS;
-
-       if (irq_type != MPU_SLAVE_IRQ_TYPE_NONE)
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-
-       config->irq_type = MPU_SLAVE_IRQ_TYPE_NONE;
-       config->int_reg = 0x00;
-
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                        BMA150_CTRL_REG, config->ctrl_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                        BMA150_INT_REG, config->int_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-       return result;
-}
-
-/**
- *  @brief Set the output data rate for the particular configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             Config to modify with new ODR.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param odr
- *             Output data rate in units of 1/1000Hz (mHz).
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_set_odr(void *mlsl_handle,
-                       struct ext_slave_platform_data *pdata,
-                       struct bma150_config *config,
-                       int apply,
-                       long odr)
-{
-       unsigned char odr_bits = 0;
-       unsigned char wup_bits = 0;
-       int result = INV_SUCCESS;
-
-       if (odr > 100000) {
-               config->odr = 190000;
-               odr_bits = 0x03;
-       } else if (odr > 50000) {
-               config->odr = 100000;
-               odr_bits = 0x02;
-       } else if (odr > 25000) {
-               config->odr = 50000;
-               odr_bits = 0x01;
-       } else if (odr > 0) {
-               config->odr = 25000;
-               odr_bits = 0x00;
-       } else {
-               config->odr = 0;
-               wup_bits = 0x00;
-       }
-
-       config->int_reg &= BMA150_INT_MASK_WUP;
-       config->ctrl_reg &= BMA150_CTRL_MASK_ODR;
-       config->ctrl_reg |= odr_bits;
-
-       MPL_LOGV("ODR: %d\n", config->odr);
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       BMA150_CTRL_REG, config->ctrl_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       BMA150_INT_REG, config->int_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-
-       return result;
-}
-
-/**
- *  @brief Set the full scale range of the accels
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             pointer to configuration.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param fsr
- *             requested full scale range.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_set_fsr(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct bma150_config *config,
-                         int apply,
-                         long fsr)
-{
-       unsigned char fsr_bits;
-       int result = INV_SUCCESS;
-
-       if (fsr <= 2048) {
-               fsr_bits = 0x00;
-               config->fsr = 2048;
-       } else if (fsr <= 4096) {
-               fsr_bits = 0x08;
-               config->fsr = 4096;
-       } else {
-               fsr_bits = 0x10;
-               config->fsr = 8192;
-       }
-
-       config->ctrl_reg &= BMA150_CTRL_MASK_FSR;
-       config->ctrl_reg |= fsr_bits;
-
-       MPL_LOGV("FSR: %d\n", config->fsr);
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA150_CTRL_REG, config->ctrl_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA150_CTRL_REG, config->ctrl_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-       return result;
-}
-
-/**
- *  @brief one-time device driver initialization function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is loaded in the kernel.
- *         If the driver is built-in in the kernel, this function will be
- *         called at boot time.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_init(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       int result;
-       unsigned char reg;
-       long range;
-
-       struct bma150_private_data *private_data;
-       private_data = (struct bma150_private_data *)
-           kzalloc(sizeof(struct bma150_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       pdata->private_data = private_data;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       BMA150_PWR_REG, BMA150_PWR_MASK_SOFT_RESET);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(1);
-
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                BMA150_CTRL_REG, 1, &reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       private_data->resume.ctrl_reg = reg;
-       private_data->suspend.ctrl_reg = reg;
-
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                BMA150_INT_REG, 1, &reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       private_data->resume.int_reg = reg;
-       private_data->suspend.int_reg = reg;
-
-       result = bma150_set_odr(mlsl_handle, pdata, &private_data->suspend,
-                               false, 0);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma150_set_odr(mlsl_handle, pdata, &private_data->resume,
-                               false, 200000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       range = range_fixedpoint_to_long_mg(slave->range);
-       result = bma150_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                               false, range);
-       result = bma150_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                               false, range);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = bma150_set_irq(mlsl_handle, pdata, &private_data->suspend,
-                               false, MPU_SLAVE_IRQ_TYPE_NONE);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma150_set_irq(mlsl_handle, pdata, &private_data->resume,
-                               false, MPU_SLAVE_IRQ_TYPE_NONE);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      BMA150_PWR_REG, BMA150_PWR_MASK_SLEEP);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief one-time device driver exit function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is removed from the kernel.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_exit(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief device configuration facility.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to the configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_config(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata,
-                        struct ext_slave_config *data)
-{
-       struct bma150_private_data *private_data =
-                       (struct bma150_private_data *)(pdata->private_data);
-
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return bma150_set_odr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return bma150_set_odr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return bma150_set_fsr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return bma150_set_fsr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               return bma150_set_irq(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               return bma150_set_irq(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief facility to retrieve the device configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to store the returned configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_get_config(void *mlsl_handle,
-                               struct ext_slave_descr *slave,
-                               struct ext_slave_platform_data *pdata,
-                               struct ext_slave_config *data)
-{
-       struct bma150_private_data *private_data =
-                       (struct bma150_private_data *)(pdata->private_data);
-
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.irq_type;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.irq_type;
-               break;
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief suspends the device to put it in its lowest power mode.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_suspend(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata)
-{
-       int result;
-       unsigned char ctrl_reg;
-       unsigned char int_reg;
-
-       struct bma150_private_data *private_data =
-                       (struct bma150_private_data *)(pdata->private_data);
-
-       ctrl_reg = private_data->suspend.ctrl_reg;
-       int_reg = private_data->suspend.int_reg;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       BMA150_PWR_REG, BMA150_PWR_MASK_SOFT_RESET);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(1);
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       BMA150_CTRL_REG, ctrl_reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       BMA150_INT_REG, int_reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-               BMA150_PWR_REG, BMA150_PWR_MASK_SLEEP);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief resume the device in the proper power state given the configuration
- *         chosen.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_resume(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata)
-{
-       int result;
-       unsigned char ctrl_reg;
-       unsigned char int_reg;
-
-       struct bma150_private_data *private_data =
-                       (struct bma150_private_data *)(pdata->private_data);
-
-       ctrl_reg = private_data->resume.ctrl_reg;
-       int_reg = private_data->resume.int_reg;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA150_PWR_REG, BMA150_PWR_MASK_SOFT_RESET);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(1);
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA150_CTRL_REG, ctrl_reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA150_INT_REG, int_reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA150_PWR_REG, 0x00);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief read the sensor data from the device.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a buffer to store the data read.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma150_read(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata,
-                      unsigned char *data)
-{
-       return inv_serial_read(mlsl_handle, pdata->address,
-                              slave->read_reg, slave->read_len, data);
-}
-
-static struct ext_slave_descr bma150_descr = {
-       .init             = bma150_init,
-       .exit             = bma150_exit,
-       .suspend          = bma150_suspend,
-       .resume           = bma150_resume,
-       .read             = bma150_read,
-       .config           = bma150_config,
-       .get_config       = bma150_get_config,
-       .name             = "bma150",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_BMA150,
-       .read_reg         = 0x02,
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_LITTLE_ENDIAN,
-       .range            = {2, 0},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *bma150_get_slave_descr(void)
-{
-       return &bma150_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/* Platform data for the MPU */
-struct bma150_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int bma150_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct bma150_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       bma150_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int bma150_mod_remove(struct i2c_client *client)
-{
-       struct bma150_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               bma150_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id bma150_mod_id[] = {
-       { "bma150", ACCEL_ID_BMA150 },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, bma150_mod_id);
-
-static struct i2c_driver bma150_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = bma150_mod_probe,
-       .remove = bma150_mod_remove,
-       .id_table = bma150_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "bma150_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init bma150_mod_init(void)
-{
-       int res = i2c_add_driver(&bma150_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "bma150_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit bma150_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&bma150_mod_driver);
-}
-
-module_init(bma150_mod_init);
-module_exit(bma150_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate BMA150 sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("bma150_mod");
-
-/**
- *  @}
- */
-
diff --git a/drivers/misc/inv_mpu/accel/bma222.c b/drivers/misc/inv_mpu/accel/bma222.c
deleted file mode 100644 (file)
index e9fc99b..0000000
+++ /dev/null
@@ -1,654 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   bma222.c
- *      @brief  Accelerometer setup and handling methods for Bosch BMA222.
- */
-
-/* ------------------ */
-/* - Include Files. - */
-/* ------------------ */
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-
-/* -------------------------------------------------------------------------- */
-
-#define BMA222_STATUS_REG      (0x0A)
-#define BMA222_FSR_REG         (0x0F)
-#define ADXL34X_ODR_REG                (0x10)
-#define BMA222_PWR_REG         (0x11)
-#define BMA222_SOFTRESET_REG   (0x14)
-
-#define BMA222_STATUS_RDY_MASK (0x80)
-#define BMA222_FSR_MASK                (0x0F)
-#define BMA222_ODR_MASK                (0x1F)
-#define BMA222_PWR_SLEEP_MASK  (0x80)
-#define BMA222_PWR_AWAKE_MASK  (0x00)
-#define BMA222_SOFTRESET_MASK  (0xB6)
-#define BMA222_SOFTRESET_MASK  (0xB6)
-
-/* -------------------------------------------------------------------------- */
-
-struct bma222_config {
-       unsigned int odr;               /** < output data rate in mHz */
-       unsigned int fsr;               /** < full scale range mg */
-};
-
-struct bma222_private_data {
-       struct bma222_config suspend;   /** < suspend configuration */
-       struct bma222_config resume;    /** < resume configuration */
-};
-
-
-/* -------------------------------------------------------------------------- */
-
-/**
- *  @brief Set the output data rate for the particular configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             Config to modify with new ODR.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param odr
- *             Output data rate in units of 1/1000Hz (mHz).
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_set_odr(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct bma222_config *config,
-                         int apply,
-                         long odr)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg_odr;
-
-       if (odr >= 1000000) {
-               reg_odr = 0x0F;
-               config->odr = 1000000;
-       } else if (odr >= 500000) {
-               reg_odr = 0x0E;
-               config->odr = 500000;
-       } else if (odr >= 250000) {
-               reg_odr = 0x0D;
-               config->odr = 250000;
-       } else if (odr >= 125000) {
-               reg_odr = 0x0C;
-               config->odr = 125000;
-       } else if (odr >= 62500) {
-               reg_odr = 0x0B;
-               config->odr = 62500;
-       } else if (odr >= 32000) {
-               reg_odr = 0x0A;
-               config->odr = 32000;
-       } else if (odr >= 16000) {
-               reg_odr = 0x09;
-               config->odr = 16000;
-       } else {
-               reg_odr = 0x08;
-               config->odr = 8000;
-       }
-
-       if (apply) {
-               MPL_LOGV("ODR: %d\n", config->odr);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       ADXL34X_ODR_REG, reg_odr);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-       return result;
-}
-
-/**
- *  @brief Set the full scale range of the accels
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             pointer to configuration.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param fsr
- *             requested full scale range.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_set_fsr(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct bma222_config *config,
-                         int apply,
-                         long fsr)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg_fsr_mask;
-
-       if (fsr <= 2000) {
-               reg_fsr_mask = 0x03;
-               config->fsr = 2000;
-       } else if (fsr <= 4000) {
-               reg_fsr_mask = 0x05;
-               config->fsr = 4000;
-       } else if (fsr <= 8000) {
-               reg_fsr_mask = 0x08;
-               config->fsr = 8000;
-       } else { /* 8001 -> oo */
-               reg_fsr_mask = 0x0C;
-               config->fsr = 16000;
-       }
-
-       if (apply) {
-               MPL_LOGV("FSR: %d\n", config->fsr);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA222_FSR_REG, reg_fsr_mask);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-       return result;
-}
-
-/**
- *  @brief one-time device driver initialization function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is loaded in the kernel.
- *         If the driver is built-in in the kernel, this function will be
- *         called at boot time.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_init(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata)
-{
-       int result;
-
-       struct bma222_private_data *private_data;
-       private_data = (struct bma222_private_data *)
-           kzalloc(sizeof(struct bma222_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       pdata->private_data = private_data;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       BMA222_SOFTRESET_REG, BMA222_SOFTRESET_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(1);
-
-       result = bma222_set_odr(mlsl_handle, pdata, &private_data->suspend,
-                               false, 0);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma222_set_odr(mlsl_handle, pdata, &private_data->resume,
-                               false, 200000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = bma222_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                               false, 2000);
-       result = bma222_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                               false, 2000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA222_PWR_REG, BMA222_PWR_SLEEP_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief one-time device driver exit function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is removed from the kernel.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_exit(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-
-/**
- *  @brief facility to retrieve the device configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to store the returned configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_get_config(void *mlsl_handle,
-                               struct ext_slave_descr *slave,
-                               struct ext_slave_platform_data *pdata,
-                               struct ext_slave_config *data)
-{
-       struct bma222_private_data *private_data =
-                       (struct bma222_private_data *)(pdata->private_data);
-
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief device configuration facility.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to the configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_config(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata,
-                        struct ext_slave_config *data)
-{
-       struct bma222_private_data *private_data =
-                       (struct bma222_private_data *)(pdata->private_data);
-
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return bma222_set_odr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return bma222_set_odr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return bma222_set_fsr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return bma222_set_fsr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief suspends the device to put it in its lowest power mode.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_suspend(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       int result;
-       struct bma222_config *suspend_config =
-               &((struct bma222_private_data *)pdata->private_data)->suspend;
-
-       result = bma222_set_odr(mlsl_handle, pdata, suspend_config,
-                               true, suspend_config->odr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma222_set_fsr(mlsl_handle, pdata, suspend_config,
-                               true, suspend_config->fsr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA222_PWR_REG, BMA222_PWR_SLEEP_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       msleep(3); /* 3 ms powerup time maximum */
-       return result;
-}
-
-/**
- *  @brief resume the device in the proper power state given the configuration
- *         chosen.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_resume(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata)
-{
-       int result;
-       struct bma222_config *resume_config =
-               &((struct bma222_private_data *)pdata->private_data)->resume;
-
-       /* Soft reset */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       BMA222_SOFTRESET_REG, BMA222_SOFTRESET_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(10);
-
-       result = bma222_set_odr(mlsl_handle, pdata, resume_config,
-                               true, resume_config->odr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma222_set_fsr(mlsl_handle, pdata, resume_config,
-                               true, resume_config->fsr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief read the sensor data from the device.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a buffer to store the data read.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma222_read(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata,
-                      unsigned char *data)
-{
-       int result = INV_SUCCESS;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                               BMA222_STATUS_REG, 1, data);
-       if (data[0] & BMA222_STATUS_RDY_MASK) {
-               result = inv_serial_read(mlsl_handle, pdata->address,
-                                slave->read_reg, slave->read_len, data);
-       return result;
-       } else
-               return INV_ERROR_ACCEL_DATA_NOT_READY;
-}
-
-static struct ext_slave_descr bma222_descr = {
-       .init             = bma222_init,
-       .exit             = bma222_exit,
-       .suspend          = bma222_suspend,
-       .resume           = bma222_resume,
-       .read             = bma222_read,
-       .config           = bma222_config,
-       .get_config       = bma222_get_config,
-       .name             = "bma222",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_BMA222,
-       .read_reg         = 0x02,
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_LITTLE_ENDIAN,
-       .range            = {2, 0},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *bma222_get_slave_descr(void)
-{
-       return &bma222_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-
-struct bma222_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int bma222_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct bma222_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       bma222_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int bma222_mod_remove(struct i2c_client *client)
-{
-       struct bma222_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               bma222_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id bma222_mod_id[] = {
-       { "bma222", ACCEL_ID_BMA222 },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, bma222_mod_id);
-
-static struct i2c_driver bma222_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = bma222_mod_probe,
-       .remove = bma222_mod_remove,
-       .id_table = bma222_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "bma222_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init bma222_mod_init(void)
-{
-       int res = i2c_add_driver(&bma222_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "bma222_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit bma222_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&bma222_mod_driver);
-}
-
-module_init(bma222_mod_init);
-module_exit(bma222_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate BMA222 sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("bma222_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/bma250.c b/drivers/misc/inv_mpu/accel/bma250.c
deleted file mode 100644 (file)
index 6a245f4..0000000
+++ /dev/null
@@ -1,787 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   bma250.c
- *      @brief  Accelerometer setup and handling methods for Bosch BMA250.
- */
-
-/* -------------------------------------------------------------------------- */
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-
-/* -------------------------------------------------------------------------- */
-
-/* registers */
-#define BMA250_STATUS_REG      (0x0A)
-#define BMA250_FSR_REG         (0x0F)
-#define BMA250_ODR_REG         (0x10)
-#define BMA250_PWR_REG         (0x11)
-#define BMA250_SOFTRESET_REG   (0x14)
-#define BMA250_INT_TYPE_REG    (0x17)
-#define BMA250_INT_DST_REG     (0x1A)
-#define BMA250_INT_SRC_REG     (0x1E)
-
-/* masks */
-#define BMA250_STATUS_RDY_MASK (0x80)
-#define BMA250_FSR_MASK                (0x0F)
-#define BMA250_ODR_MASK                (0x1F)
-#define BMA250_PWR_SLEEP_MASK  (0x80)
-#define BMA250_PWR_AWAKE_MASK  (0x00)
-#define BMA250_SOFTRESET_MASK   (0xB6)
-#define BMA250_INT_TYPE_MASK   (0x10)
-#define BMA250_INT_DST_1_MASK  (0x01)
-#define BMA250_INT_DST_2_MASK  (0x80)
-#define BMA250_INT_SRC_MASK    (0x00)
-
-/* -------------------------------------------------------------------------- */
-
-struct bma250_config {
-       unsigned int odr;               /** < output data rate in mHz */
-       unsigned int fsr;               /** < full scale range mg */
-       unsigned char irq_type;
-};
-
-struct bma250_private_data {
-       struct bma250_config suspend;   /** < suspend configuration */
-       struct bma250_config resume;    /** < resume configuration */
-};
-
-/* -------------------------------------------------------------------------- */
-/**
- *  @brief Sets the IRQ to fire when one of the IRQ events occur.
- *         Threshold and duration will not be used unless the type is MOT or
- *         NMOT.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *              configuration to apply to, suspend or resume
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param irq_type
- *              the type of IRQ.  Valid values are
- * - MPU_SLAVE_IRQ_TYPE_NONE
- * - MPU_SLAVE_IRQ_TYPE_MOTION
- * - MPU_SLAVE_IRQ_TYPE_DATA_READY
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_set_irq(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct bma250_config *config,
-                         int apply, long irq_type)
-{
-       int result = INV_SUCCESS;
-       unsigned char irqtype_reg;
-       unsigned char irqdst_reg;
-       unsigned char irqsrc_reg;
-
-       switch (irq_type) {
-       case MPU_SLAVE_IRQ_TYPE_DATA_READY:
-               /* data ready int. */
-               irqtype_reg = BMA250_INT_TYPE_MASK;
-               /* routed to interrupt pin 1 */
-               irqdst_reg = BMA250_INT_DST_1_MASK;
-               /* from filtered data */
-               irqsrc_reg = BMA250_INT_SRC_MASK;
-               break;
-       /* unfinished
-       case MPU_SLAVE_IRQ_TYPE_MOTION:
-               reg1 = 0x00;
-               reg2 = config->mot_int1_cfg;
-               reg3 = ;
-               break;
-       */
-       case MPU_SLAVE_IRQ_TYPE_NONE:
-               irqtype_reg = 0x00;
-               irqdst_reg = 0x00;
-               irqsrc_reg = 0x00;
-               break;
-       default:
-               return INV_ERROR_INVALID_PARAMETER;
-               break;
-       }
-
-       config->irq_type = (unsigned char)irq_type;
-
-       if (apply) {
-               /* select the type of interrupt to use */
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA250_INT_TYPE_REG, irqtype_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               /* select to which interrupt pin to route it to */
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA250_INT_DST_REG, irqdst_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               /* select whether the interrupt works off filtered or
-                  unfiltered data */
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA250_INT_SRC_REG, irqsrc_reg);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-       return result;
-}
-
-/**
- *  @brief Set the output data rate for the particular configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             Config to modify with new ODR.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param odr
- *             Output data rate in units of 1/1000Hz (mHz).
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_set_odr(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct bma250_config *config,
-                         int apply,
-                         long odr)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg_odr;
-
-       /* Table uses bandwidth which is half the sample rate */
-       odr = odr >> 1;
-       if (odr >= 1000000) {
-               reg_odr = 0x0F;
-               config->odr = 2000000;
-       } else if (odr >= 500000) {
-               reg_odr = 0x0E;
-               config->odr = 1000000;
-       } else if (odr >= 250000) {
-               reg_odr = 0x0D;
-               config->odr = 500000;
-       } else if (odr >= 125000) {
-               reg_odr = 0x0C;
-               config->odr = 250000;
-       } else if (odr >= 62500) {
-               reg_odr = 0x0B;
-               config->odr = 125000;
-       } else if (odr >= 31250) {
-               reg_odr = 0x0A;
-               config->odr = 62500;
-       } else if (odr >= 15630) {
-               reg_odr = 0x09;
-               config->odr = 31250;
-       } else {
-               reg_odr = 0x08;
-               config->odr = 15630;
-       }
-
-       if (apply) {
-               MPL_LOGV("ODR: %d\n", config->odr);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA250_ODR_REG, reg_odr);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-
-       return result;
-}
-
-/**
- *  @brief Set the full scale range of the accels
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             pointer to configuration.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param fsr
- *             requested full scale range.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_set_fsr(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct bma250_config *config,
-                         int apply,
-                         long fsr)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg_fsr_mask;
-
-       if (fsr <= 2000) {
-               reg_fsr_mask = 0x03;
-               config->fsr = 2000;
-       } else if (fsr <= 4000) {
-               reg_fsr_mask = 0x05;
-               config->fsr = 4000;
-       } else if (fsr <= 8000) {
-               reg_fsr_mask = 0x08;
-               config->fsr = 8000;
-       } else { /* 8001 -> oo */
-               reg_fsr_mask = 0x0C;
-               config->fsr = 16000;
-       }
-
-       if (apply) {
-               MPL_LOGV("FSR: %d\n", config->fsr);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA250_FSR_REG, reg_fsr_mask);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-       return result;
-}
-
-/**
- *  @brief one-time device driver initialization function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is loaded in the kernel.
- *         If the driver is built-in in the kernel, this function will be
- *         called at boot time.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_init(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata)
-{
-       int result;
-       long range;
-
-       struct bma250_private_data *private_data;
-       private_data = kzalloc(sizeof(struct bma250_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       pdata->private_data = private_data;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       BMA250_SOFTRESET_REG, BMA250_SOFTRESET_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(1);
-
-       result = bma250_set_odr(mlsl_handle, pdata, &private_data->suspend,
-                               false, 0);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma250_set_odr(mlsl_handle, pdata, &private_data->resume,
-                               false, 200000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       range = range_fixedpoint_to_long_mg(slave->range);
-       result = bma250_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                               false, range);
-       result = bma250_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                               false, range);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = bma250_set_irq(mlsl_handle, pdata, &private_data->suspend,
-                               false, MPU_SLAVE_IRQ_TYPE_NONE);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma250_set_irq(mlsl_handle, pdata, &private_data->resume,
-                               false, MPU_SLAVE_IRQ_TYPE_NONE);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA250_PWR_REG, BMA250_PWR_SLEEP_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief one-time device driver exit function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is removed from the kernel.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_exit(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief device configuration facility.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to the configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_config(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata,
-                        struct ext_slave_config *data)
-{
-       struct bma250_private_data *private_data =
-                       (struct bma250_private_data *)(pdata->private_data);
-
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return bma250_set_odr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return bma250_set_odr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return bma250_set_fsr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return bma250_set_fsr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               return bma250_set_irq(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply,
-                                     *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               return bma250_set_irq(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply,
-                                     *((long *)data->data));
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief facility to retrieve the device configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to store the returned configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_get_config(void *mlsl_handle,
-                            struct ext_slave_descr *slave,
-                            struct ext_slave_platform_data *pdata,
-                            struct ext_slave_config *data)
-{
-       struct bma250_private_data *private_data =
-                       (struct bma250_private_data *)(pdata->private_data);
-
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.irq_type;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.irq_type;
-               break;
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief suspends the device to put it in its lowest power mode.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_suspend(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       int result;
-       struct bma250_config *suspend_config =
-               &((struct bma250_private_data *)pdata->private_data)->suspend;
-
-       result = bma250_set_odr(mlsl_handle, pdata, suspend_config,
-                               true, suspend_config->odr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma250_set_fsr(mlsl_handle, pdata, suspend_config,
-                               true, suspend_config->fsr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma250_set_irq(mlsl_handle, pdata, suspend_config,
-                               true, suspend_config->irq_type);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               BMA250_PWR_REG, BMA250_PWR_SLEEP_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       msleep(3); /* 3 ms powerup time maximum */
-       return result;
-}
-
-/**
- *  @brief resume the device in the proper power state given the configuration
- *         chosen.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_resume(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata)
-{
-       int result;
-       struct bma250_config *resume_config =
-               &((struct bma250_private_data *)pdata->private_data)->resume;
-
-       result = bma250_set_odr(mlsl_handle, pdata, resume_config,
-                               true, resume_config->odr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma250_set_fsr(mlsl_handle, pdata, resume_config,
-                               true, resume_config->fsr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = bma250_set_irq(mlsl_handle, pdata, resume_config,
-                               true, resume_config->irq_type);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       BMA250_PWR_REG, BMA250_PWR_AWAKE_MASK);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief read the sensor data from the device.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a buffer to store the data read.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int bma250_read(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata,
-                      unsigned char *data)
-{
-       int result = INV_SUCCESS;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                               BMA250_STATUS_REG, 1, data);
-       if (1) { /* KLP - workaroud for small data ready window */
-               result = inv_serial_read(mlsl_handle, pdata->address,
-                               slave->read_reg, slave->read_len, data);
-               return result;
-       } else
-               return INV_ERROR_ACCEL_DATA_NOT_READY;
-}
-
-static struct ext_slave_descr bma250_descr = {
-       .init             = bma250_init,
-       .exit             = bma250_exit,
-       .suspend          = bma250_suspend,
-       .resume           = bma250_resume,
-       .read             = bma250_read,
-       .config           = bma250_config,
-       .get_config       = bma250_get_config,
-       .name             = "bma250",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_BMA250,
-       .read_reg         = 0x02,
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_LITTLE_ENDIAN,
-       .range            = {2, 0},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *bma250_get_slave_descr(void)
-{
-       return &bma250_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-
-/* Platform data for the MPU */
-struct bma250_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int bma250_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct bma250_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       bma250_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int bma250_mod_remove(struct i2c_client *client)
-{
-       struct bma250_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               bma250_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id bma250_mod_id[] = {
-       { "bma250", ACCEL_ID_BMA250 },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, bma250_mod_id);
-
-static struct i2c_driver bma250_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = bma250_mod_probe,
-       .remove = bma250_mod_remove,
-       .id_table = bma250_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "bma250_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init bma250_mod_init(void)
-{
-       int res = i2c_add_driver(&bma250_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "bma250_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit bma250_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&bma250_mod_driver);
-}
-
-module_init(bma250_mod_init);
-module_exit(bma250_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate BMA250 sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("bma250_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/cma3000.c b/drivers/misc/inv_mpu/accel/cma3000.c
deleted file mode 100644 (file)
index 496d1f2..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Accelerometer setup and handling methods for VTI CMA3000.
- *
- *  @{
- *      @file   cma3000.c
- *      @brief  Accelerometer setup and handling methods for VTI CMA3000
- */
-
-/* -------------------------------------------------------------------------- */
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-/* -------------------------------------------------------------------------- */
-
-static int cma3000_suspend(void *mlsl_handle,
-                          struct ext_slave_descr *slave,
-                          struct ext_slave_platform_data *pdata)
-{
-       int result;
-       /* RAM reset */
-       result =
-           inv_serial_single_write(mlsl_handle, pdata->address, 0x1d, 0xcd);
-       return result;
-}
-
-static int cma3000_resume(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-
-       return INV_SUCCESS;
-}
-
-static int cma3000_read(void *mlsl_handle,
-                       struct ext_slave_descr *slave,
-                       struct ext_slave_platform_data *pdata,
-                       unsigned char *data)
-{
-       int result;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                slave->reg, slave->len, data);
-       return result;
-}
-
-static struct ext_slave_descr cma3000_descr = {
-       .init             = NULL,
-       .exit             = NULL,
-       .suspend          = cma3000_suspend,
-       .resume           = cma3000_resume,
-       .read             = cma3000_read,
-       .config           = NULL,
-       .get_config       = NULL,
-       .name             = "cma3000",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ID_INVALID,
-       .read_reg         = 0x06,
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_LITTLE_ENDIAN,
-       .range            = {2, 0},
-       .trigger          = NULL,
-
-};
-
-static
-struct ext_slave_descr *cma3000_get_slave_descr(void)
-{
-       return &cma3000_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-
-struct cma3000_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int cma3000_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct cma3000_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       cma3000_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int cma3000_mod_remove(struct i2c_client *client)
-{
-       struct cma3000_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               cma3000_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id cma3000_mod_id[] = {
-       { "cma3000", ACCEL_ID_CMA3000 },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, cma3000_mod_id);
-
-static struct i2c_driver cma3000_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = cma3000_mod_probe,
-       .remove = cma3000_mod_remove,
-       .id_table = cma3000_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "cma3000_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init cma3000_mod_init(void)
-{
-       int res = i2c_add_driver(&cma3000_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "cma3000_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit cma3000_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&cma3000_mod_driver);
-}
-
-module_init(cma3000_mod_init);
-module_exit(cma3000_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate CMA3000 sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("cma3000_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/kxsd9.c b/drivers/misc/inv_mpu/accel/kxsd9.c
deleted file mode 100644 (file)
index 5cb4eaf..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Accelerometer setup and handling methods for Kionix KXSD9.
- *
- *  @{
- *      @file   kxsd9.c
- *      @brief  Accelerometer setup and handling methods for Kionix KXSD9.
- */
-
-/* -------------------------------------------------------------------------- */
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-/* -------------------------------------------------------------------------- */
-
-static int kxsd9_suspend(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata)
-{
-       int result;
-       /* CTRL_REGB: low-power standby mode */
-       result =
-           inv_serial_single_write(mlsl_handle, pdata->address, 0x0d, 0x0);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       return result;
-}
-
-/* full scale setting - register and mask */
-#define ACCEL_KIONIX_CTRL_REG      (0x0C)
-#define ACCEL_KIONIX_CTRL_MASK     (0x3)
-
-static int kxsd9_resume(void *mlsl_handle,
-                       struct ext_slave_descr *slave,
-                       struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg;
-
-       /* Full Scale */
-       reg = 0x0;
-       reg &= ~ACCEL_KIONIX_CTRL_MASK;
-       reg |= 0x00;
-       if (slave->range.mantissa == 4) {               /* 4g scale = 4.9951 */
-               reg |= 0x2;
-               slave->range.fraction = 9951;
-       } else if (slave->range.mantissa == 7) {        /* 6g scale = 7.5018 */
-               reg |= 0x1;
-               slave->range.fraction = 5018;
-       } else if (slave->range.mantissa == 9) {        /* 8g scale = 9.9902 */
-               reg |= 0x0;
-               slave->range.fraction = 9902;
-       } else {
-               slave->range.mantissa = 2;              /* 2g scale = 2.5006 */
-               slave->range.fraction = 5006;
-               reg |= 0x3;
-       }
-       reg |= 0xC0;            /* 100Hz LPF */
-       result =
-           inv_serial_single_write(mlsl_handle, pdata->address,
-                                   ACCEL_KIONIX_CTRL_REG, reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* normal operation */
-       result =
-           inv_serial_single_write(mlsl_handle, pdata->address, 0x0d, 0x40);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return INV_SUCCESS;
-}
-
-static int kxsd9_read(void *mlsl_handle,
-                     struct ext_slave_descr *slave,
-                     struct ext_slave_platform_data *pdata,
-                     unsigned char *data)
-{
-       int result;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                slave->read_reg, slave->read_len, data);
-       return result;
-}
-
-static struct ext_slave_descr kxsd9_descr = {
-       .init             = NULL,
-       .exit             = NULL,
-       .suspend          = kxsd9_suspend,
-       .resume           = kxsd9_resume,
-       .read             = kxsd9_read,
-       .config           = NULL,
-       .get_config       = NULL,
-       .name             = "kxsd9",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_KXSD9,
-       .read_reg         = 0x00,
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_BIG_ENDIAN,
-       .range            = {2, 5006},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *kxsd9_get_slave_descr(void)
-{
-       return &kxsd9_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-struct kxsd9_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int kxsd9_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct kxsd9_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       kxsd9_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int kxsd9_mod_remove(struct i2c_client *client)
-{
-       struct kxsd9_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               kxsd9_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id kxsd9_mod_id[] = {
-       { "kxsd9", ACCEL_ID_KXSD9 },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, kxsd9_mod_id);
-
-static struct i2c_driver kxsd9_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = kxsd9_mod_probe,
-       .remove = kxsd9_mod_remove,
-       .id_table = kxsd9_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "kxsd9_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init kxsd9_mod_init(void)
-{
-       int res = i2c_add_driver(&kxsd9_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "kxsd9_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit kxsd9_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&kxsd9_mod_driver);
-}
-
-module_init(kxsd9_mod_init);
-module_exit(kxsd9_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate KXSD9 sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("kxsd9_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/kxtf9.c b/drivers/misc/inv_mpu/accel/kxtf9.c
deleted file mode 100644 (file)
index 80776f2..0000000
+++ /dev/null
@@ -1,841 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Accelerometer setup and handling methods for Kionix KXTF9.
- *
- *  @{
- *      @file   kxtf9.c
- *      @brief  Accelerometer setup and handling methods for Kionix KXTF9.
-*/
-
-/* -------------------------------------------------------------------------- */
-
-#undef MPL_LOG_NDEBUG
-#define MPL_LOG_NDEBUG 1
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-#define KXTF9_XOUT_HPF_L                (0x00) /* 0000 0000 */
-#define KXTF9_XOUT_HPF_H                (0x01) /* 0000 0001 */
-#define KXTF9_YOUT_HPF_L                (0x02) /* 0000 0010 */
-#define KXTF9_YOUT_HPF_H                (0x03) /* 0000 0011 */
-#define KXTF9_ZOUT_HPF_L                (0x04) /* 0001 0100 */
-#define KXTF9_ZOUT_HPF_H                (0x05) /* 0001 0101 */
-#define KXTF9_XOUT_L                    (0x06) /* 0000 0110 */
-#define KXTF9_XOUT_H                    (0x07) /* 0000 0111 */
-#define KXTF9_YOUT_L                    (0x08) /* 0000 1000 */
-#define KXTF9_YOUT_H                    (0x09) /* 0000 1001 */
-#define KXTF9_ZOUT_L                    (0x0A) /* 0001 1010 */
-#define KXTF9_ZOUT_H                    (0x0B) /* 0001 1011 */
-#define KXTF9_ST_RESP                   (0x0C) /* 0000 1100 */
-#define KXTF9_WHO_AM_I                  (0x0F) /* 0000 1111 */
-#define KXTF9_TILT_POS_CUR              (0x10) /* 0001 0000 */
-#define KXTF9_TILT_POS_PRE              (0x11) /* 0001 0001 */
-#define KXTF9_INT_SRC_REG1              (0x15) /* 0001 0101 */
-#define KXTF9_INT_SRC_REG2              (0x16) /* 0001 0110 */
-#define KXTF9_STATUS_REG                (0x18) /* 0001 1000 */
-#define KXTF9_INT_REL                   (0x1A) /* 0001 1010 */
-#define KXTF9_CTRL_REG1                 (0x1B) /* 0001 1011 */
-#define KXTF9_CTRL_REG2                 (0x1C) /* 0001 1100 */
-#define KXTF9_CTRL_REG3                 (0x1D) /* 0001 1101 */
-#define KXTF9_INT_CTRL_REG1             (0x1E) /* 0001 1110 */
-#define KXTF9_INT_CTRL_REG2             (0x1F) /* 0001 1111 */
-#define KXTF9_INT_CTRL_REG3             (0x20) /* 0010 0000 */
-#define KXTF9_DATA_CTRL_REG             (0x21) /* 0010 0001 */
-#define KXTF9_TILT_TIMER                (0x28) /* 0010 1000 */
-#define KXTF9_WUF_TIMER                 (0x29) /* 0010 1001 */
-#define KXTF9_TDT_TIMER                 (0x2B) /* 0010 1011 */
-#define KXTF9_TDT_H_THRESH              (0x2C) /* 0010 1100 */
-#define KXTF9_TDT_L_THRESH              (0x2D) /* 0010 1101 */
-#define KXTF9_TDT_TAP_TIMER             (0x2E) /* 0010 1110 */
-#define KXTF9_TDT_TOTAL_TIMER           (0x2F) /* 0010 1111 */
-#define KXTF9_TDT_LATENCY_TIMER         (0x30) /* 0011 0000 */
-#define KXTF9_TDT_WINDOW_TIMER          (0x31) /* 0011 0001 */
-#define KXTF9_WUF_THRESH                (0x5A) /* 0101 1010 */
-#define KXTF9_TILT_ANGLE                (0x5C) /* 0101 1100 */
-#define KXTF9_HYST_SET                  (0x5F) /* 0101 1111 */
-
-#define KXTF9_MAX_DUR (0xFF)
-#define KXTF9_MAX_THS (0xFF)
-#define KXTF9_THS_COUNTS_P_G (32)
-
-/* -------------------------------------------------------------------------- */
-
-struct kxtf9_config {
-       unsigned long odr;      /* Output data rate mHz */
-       unsigned int fsr;       /* full scale range mg */
-       unsigned int ths;       /* Motion no-motion thseshold mg */
-       unsigned int dur;       /* Motion no-motion duration ms */
-       unsigned int irq_type;
-       unsigned char reg_ths;
-       unsigned char reg_dur;
-       unsigned char reg_odr;
-       unsigned char reg_int_cfg1;
-       unsigned char reg_int_cfg2;
-       unsigned char ctrl_reg1;
-};
-
-struct kxtf9_private_data {
-       struct kxtf9_config suspend;
-       struct kxtf9_config resume;
-};
-
-static int kxtf9_set_ths(void *mlsl_handle,
-                        struct ext_slave_platform_data *pdata,
-                        struct kxtf9_config *config, int apply, long ths)
-{
-       int result = INV_SUCCESS;
-       if ((ths * KXTF9_THS_COUNTS_P_G / 1000) > KXTF9_MAX_THS)
-               ths = (long)(KXTF9_MAX_THS * 1000) / KXTF9_THS_COUNTS_P_G;
-
-       if (ths < 0)
-               ths = 0;
-
-       config->ths = ths;
-       config->reg_ths = (unsigned char)
-           ((long)(ths * KXTF9_THS_COUNTS_P_G) / 1000);
-       MPL_LOGV("THS: %d, 0x%02x\n", config->ths, (int)config->reg_ths);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_WUF_THRESH,
-                                                config->reg_ths);
-       return result;
-}
-
-static int kxtf9_set_dur(void *mlsl_handle,
-                        struct ext_slave_platform_data *pdata,
-                        struct kxtf9_config *config, int apply, long dur)
-{
-       int result = INV_SUCCESS;
-       long reg_dur = (dur * config->odr) / 1000000L;
-       config->dur = dur;
-
-       if (reg_dur > KXTF9_MAX_DUR)
-               reg_dur = KXTF9_MAX_DUR;
-
-       config->reg_dur = (unsigned char)reg_dur;
-       MPL_LOGV("DUR: %d, 0x%02x\n", config->dur, (int)config->reg_dur);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_WUF_TIMER,
-                                                (unsigned char)reg_dur);
-       return result;
-}
-
-/**
- * Sets the IRQ to fire when one of the IRQ events occur.  Threshold and
- * duration will not be used uless the type is MOT or NMOT.
- *
- * @param config configuration to apply to, suspend or resume
- * @param irq_type The type of IRQ.  Valid values are
- * - MPU_SLAVE_IRQ_TYPE_NONE
- * - MPU_SLAVE_IRQ_TYPE_MOTION
- * - MPU_SLAVE_IRQ_TYPE_DATA_READY
- */
-static int kxtf9_set_irq(void *mlsl_handle,
-                        struct ext_slave_platform_data *pdata,
-                        struct kxtf9_config *config, int apply, long irq_type)
-{
-       int result = INV_SUCCESS;
-       struct kxtf9_private_data *private_data = pdata->private_data;
-
-       config->irq_type = (unsigned char)irq_type;
-       config->ctrl_reg1 &= ~0x22;
-       if (irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               config->ctrl_reg1 |= 0x20;
-               config->reg_int_cfg1 = 0x38;
-               config->reg_int_cfg2 = 0x00;
-       } else if (irq_type == MPU_SLAVE_IRQ_TYPE_MOTION) {
-               config->ctrl_reg1 |= 0x02;
-               if ((unsigned long)config ==
-                   (unsigned long)&private_data->suspend)
-                       config->reg_int_cfg1 = 0x34;
-               else
-                       config->reg_int_cfg1 = 0x24;
-               config->reg_int_cfg2 = 0xE0;
-       } else {
-               config->reg_int_cfg1 = 0x00;
-               config->reg_int_cfg2 = 0x00;
-       }
-
-       if (apply) {
-               /* Must clear bit 7 before writing new configuration */
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_CTRL_REG1, 0x40);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_INT_CTRL_REG1,
-                                                config->reg_int_cfg1);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_INT_CTRL_REG2,
-                                                config->reg_int_cfg2);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_CTRL_REG1,
-                                                config->ctrl_reg1);
-       }
-       MPL_LOGV("CTRL_REG1: %lx, INT_CFG1: %lx, INT_CFG2: %lx\n",
-                (unsigned long)config->ctrl_reg1,
-                (unsigned long)config->reg_int_cfg1,
-                (unsigned long)config->reg_int_cfg2);
-
-       return result;
-}
-
-/**
- * Set the Output data rate for the particular configuration
- *
- * @param config Config to modify with new ODR
- * @param odr Output data rate in units of 1/1000Hz
- */
-static int kxtf9_set_odr(void *mlsl_handle,
-                        struct ext_slave_platform_data *pdata,
-                        struct kxtf9_config *config, int apply, long odr)
-{
-       unsigned char bits;
-       int result = INV_SUCCESS;
-
-       /* Data sheet says there is 12.5 hz, but that seems to produce a single
-        * correct data value, thus we remove it from the table */
-       if (odr > 400000L) {
-               config->odr = 800000L;
-               bits = 0x06;
-       } else if (odr > 200000L) {
-               config->odr = 400000L;
-               bits = 0x05;
-       } else if (odr > 100000L) {
-               config->odr = 200000L;
-               bits = 0x04;
-       } else if (odr > 50000) {
-               config->odr = 100000L;
-               bits = 0x03;
-       } else if (odr > 25000) {
-               config->odr = 50000;
-               bits = 0x02;
-       } else if (odr != 0) {
-               config->odr = 25000;
-               bits = 0x01;
-       } else {
-               config->odr = 0;
-               bits = 0;
-       }
-
-       if (odr != 0)
-               config->ctrl_reg1 |= 0x80;
-       else
-               config->ctrl_reg1 &= ~0x80;
-
-       config->reg_odr = bits;
-       kxtf9_set_dur(mlsl_handle, pdata, config, apply, config->dur);
-       MPL_LOGV("ODR: %ld, 0x%02x\n", config->odr, (int)config->ctrl_reg1);
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_DATA_CTRL_REG,
-                                                config->reg_odr);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_CTRL_REG1, 0x40);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_CTRL_REG1,
-                                                config->ctrl_reg1);
-       }
-       return result;
-}
-
-/**
- * Set the full scale range of the accels
- *
- * @param config pointer to configuration
- * @param fsr requested full scale range
- */
-static int kxtf9_set_fsr(void *mlsl_handle,
-                        struct ext_slave_platform_data *pdata,
-                        struct kxtf9_config *config, int apply, long fsr)
-{
-       int result = INV_SUCCESS;
-
-       config->ctrl_reg1 = (config->ctrl_reg1 & 0xE7);
-       if (fsr <= 2000) {
-               config->fsr = 2000;
-               config->ctrl_reg1 |= 0x00;
-       } else if (fsr <= 4000) {
-               config->fsr = 4000;
-               config->ctrl_reg1 |= 0x08;
-       } else {
-               config->fsr = 8000;
-               config->ctrl_reg1 |= 0x10;
-       }
-
-       MPL_LOGV("FSR: %d\n", config->fsr);
-       if (apply) {
-               /* Must clear bit 7 before writing new configuration */
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_CTRL_REG1, 0x40);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                KXTF9_CTRL_REG1,
-                                                config->ctrl_reg1);
-       }
-       return result;
-}
-
-static int kxtf9_suspend(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata)
-{
-       int result;
-       unsigned char data;
-       struct kxtf9_private_data *private_data = pdata->private_data;
-
-       /* Wake up */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_CTRL_REG1, 0x40);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* INT_CTRL_REG1: */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_INT_CTRL_REG1,
-                                        private_data->suspend.reg_int_cfg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* WUF_THRESH: */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_WUF_THRESH,
-                                        private_data->suspend.reg_ths);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* DATA_CTRL_REG */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_DATA_CTRL_REG,
-                                        private_data->suspend.reg_odr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* WUF_TIMER */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_WUF_TIMER,
-                                        private_data->suspend.reg_dur);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       /* Normal operation  */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_CTRL_REG1,
-                                        private_data->suspend.ctrl_reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                KXTF9_INT_REL, 1, &data);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/* full scale setting - register and mask */
-#define ACCEL_KIONIX_CTRL_REG      (0x1b)
-#define ACCEL_KIONIX_CTRL_MASK     (0x18)
-
-static int kxtf9_resume(void *mlsl_handle,
-                       struct ext_slave_descr *slave,
-                       struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       unsigned char data;
-       struct kxtf9_private_data *private_data = pdata->private_data;
-
-       /* Wake up */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_CTRL_REG1, 0x40);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* INT_CTRL_REG1: */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_INT_CTRL_REG1,
-                                        private_data->resume.reg_int_cfg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* WUF_THRESH: */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_WUF_THRESH,
-                                        private_data->resume.reg_ths);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* DATA_CTRL_REG */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_DATA_CTRL_REG,
-                                        private_data->resume.reg_odr);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* WUF_TIMER */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_WUF_TIMER,
-                                        private_data->resume.reg_dur);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       /* Normal operation  */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_CTRL_REG1,
-                                        private_data->resume.ctrl_reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                KXTF9_INT_REL, 1, &data);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return INV_SUCCESS;
-}
-
-static int kxtf9_init(void *mlsl_handle,
-                     struct ext_slave_descr *slave,
-                     struct ext_slave_platform_data *pdata)
-{
-
-       struct kxtf9_private_data *private_data;
-       int result = INV_SUCCESS;
-
-       private_data = (struct kxtf9_private_data *)
-           kzalloc(sizeof(struct kxtf9_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       /* RAM reset */
-       /* Fastest Reset */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_CTRL_REG1, 0x40);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* Fastest Reset */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_DATA_CTRL_REG, 0x36);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       /* Reset */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        KXTF9_CTRL_REG3, 0xcd);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(2);
-
-       pdata->private_data = private_data;
-
-       private_data->resume.ctrl_reg1 = 0xC0;
-       private_data->suspend.ctrl_reg1 = 0x40;
-
-       result = kxtf9_set_dur(mlsl_handle, pdata, &private_data->suspend,
-                              false, 1000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = kxtf9_set_dur(mlsl_handle, pdata, &private_data->resume,
-                              false, 2540);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = kxtf9_set_odr(mlsl_handle, pdata, &private_data->suspend,
-                              false, 50000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = kxtf9_set_odr(mlsl_handle, pdata, &private_data->resume,
-                              false, 200000L);
-
-       result = kxtf9_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                              false, 2000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = kxtf9_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                              false, 2000);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = kxtf9_set_ths(mlsl_handle, pdata, &private_data->suspend,
-                              false, 80);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = kxtf9_set_ths(mlsl_handle, pdata, &private_data->resume,
-                              false, 40);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       result = kxtf9_set_irq(mlsl_handle, pdata, &private_data->suspend,
-                              false, MPU_SLAVE_IRQ_TYPE_NONE);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = kxtf9_set_irq(mlsl_handle, pdata, &private_data->resume,
-                              false, MPU_SLAVE_IRQ_TYPE_NONE);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       return result;
-}
-
-static int kxtf9_exit(void *mlsl_handle,
-                     struct ext_slave_descr *slave,
-                     struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-static int kxtf9_config(void *mlsl_handle,
-                       struct ext_slave_descr *slave,
-                       struct ext_slave_platform_data *pdata,
-                       struct ext_slave_config *data)
-{
-       struct kxtf9_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return kxtf9_set_odr(mlsl_handle, pdata,
-                                    &private_data->suspend,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return kxtf9_set_odr(mlsl_handle, pdata,
-                                    &private_data->resume,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return kxtf9_set_fsr(mlsl_handle, pdata,
-                                    &private_data->suspend,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return kxtf9_set_fsr(mlsl_handle, pdata,
-                                    &private_data->resume,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               return kxtf9_set_ths(mlsl_handle, pdata,
-                                    &private_data->suspend,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               return kxtf9_set_ths(mlsl_handle, pdata,
-                                    &private_data->resume,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               return kxtf9_set_dur(mlsl_handle, pdata,
-                                    &private_data->suspend,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               return kxtf9_set_dur(mlsl_handle, pdata,
-                                    &private_data->resume,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               return kxtf9_set_irq(mlsl_handle, pdata,
-                                    &private_data->suspend,
-                                    data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               return kxtf9_set_irq(mlsl_handle, pdata,
-                                    &private_data->resume,
-                                    data->apply, *((long *)data->data));
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-static int kxtf9_get_config(void *mlsl_handle,
-                           struct ext_slave_descr *slave,
-                           struct ext_slave_platform_data *pdata,
-                           struct ext_slave_config *data)
-{
-       struct kxtf9_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.ths;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.ths;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.dur;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.dur;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.irq_type;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.irq_type;
-               break;
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-static int kxtf9_read(void *mlsl_handle,
-                     struct ext_slave_descr *slave,
-                     struct ext_slave_platform_data *pdata,
-                     unsigned char *data)
-{
-       int result;
-       unsigned char reg;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                KXTF9_INT_SRC_REG2, 1, &reg);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       if (!(reg & 0x10))
-               return INV_ERROR_ACCEL_DATA_NOT_READY;
-
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                slave->read_reg, slave->read_len, data);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       return result;
-}
-
-static struct ext_slave_descr kxtf9_descr = {
-       .init             = kxtf9_init,
-       .exit             = kxtf9_exit,
-       .suspend          = kxtf9_suspend,
-       .resume           = kxtf9_resume,
-       .read             = kxtf9_read,
-       .config           = kxtf9_config,
-       .get_config       = kxtf9_get_config,
-       .name             = "kxtf9",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_KXTF9,
-       .read_reg         = 0x06,
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_LITTLE_ENDIAN,
-       .range            = {2, 0},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *kxtf9_get_slave_descr(void)
-{
-       return &kxtf9_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-struct kxtf9_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int kxtf9_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct kxtf9_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       kxtf9_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int kxtf9_mod_remove(struct i2c_client *client)
-{
-       struct kxtf9_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               kxtf9_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id kxtf9_mod_id[] = {
-       { "kxtf9", ACCEL_ID_KXTF9 },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, kxtf9_mod_id);
-
-static struct i2c_driver kxtf9_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = kxtf9_mod_probe,
-       .remove = kxtf9_mod_remove,
-       .id_table = kxtf9_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "kxtf9_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init kxtf9_mod_init(void)
-{
-       int res = i2c_add_driver(&kxtf9_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "kxtf9_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit kxtf9_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&kxtf9_mod_driver);
-}
-
-module_init(kxtf9_mod_init);
-module_exit(kxtf9_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate KXTF9 sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("kxtf9_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/lis331.c b/drivers/misc/inv_mpu/accel/lis331.c
deleted file mode 100644 (file)
index bcbec25..0000000
+++ /dev/null
@@ -1,745 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   lis331.c
- *      @brief  Accelerometer setup and handling methods for ST LIS331DLH.
- */
-
-/* -------------------------------------------------------------------------- */
-
-#undef MPL_LOG_NDEBUG
-#define MPL_LOG_NDEBUG 1
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-/* full scale setting - register & mask */
-#define LIS331DLH_CTRL_REG1         (0x20)
-#define LIS331DLH_CTRL_REG2         (0x21)
-#define LIS331DLH_CTRL_REG3         (0x22)
-#define LIS331DLH_CTRL_REG4         (0x23)
-#define LIS331DLH_CTRL_REG5         (0x24)
-#define LIS331DLH_HP_FILTER_RESET   (0x25)
-#define LIS331DLH_REFERENCE         (0x26)
-#define LIS331DLH_STATUS_REG        (0x27)
-#define LIS331DLH_OUT_X_L           (0x28)
-#define LIS331DLH_OUT_X_H           (0x29)
-#define LIS331DLH_OUT_Y_L           (0x2a)
-#define LIS331DLH_OUT_Y_H           (0x2b)
-#define LIS331DLH_OUT_Z_L           (0x2b)
-#define LIS331DLH_OUT_Z_H           (0x2d)
-
-#define LIS331DLH_INT1_CFG          (0x30)
-#define LIS331DLH_INT1_SRC          (0x31)
-#define LIS331DLH_INT1_THS          (0x32)
-#define LIS331DLH_INT1_DURATION     (0x33)
-
-#define LIS331DLH_INT2_CFG          (0x34)
-#define LIS331DLH_INT2_SRC          (0x35)
-#define LIS331DLH_INT2_THS          (0x36)
-#define LIS331DLH_INT2_DURATION     (0x37)
-
-/* CTRL_REG1 */
-#define LIS331DLH_CTRL_MASK         (0x30)
-#define LIS331DLH_SLEEP_MASK        (0x20)
-#define LIS331DLH_PWR_MODE_NORMAL   (0x20)
-
-#define LIS331DLH_MAX_DUR           (0x7F)
-
-
-/* -------------------------------------------------------------------------- */
-
-struct lis331dlh_config {
-       unsigned int odr;
-       unsigned int fsr;       /* full scale range mg */
-       unsigned int ths;       /* Motion no-motion thseshold mg */
-       unsigned int dur;       /* Motion no-motion duration ms */
-       unsigned char reg_ths;
-       unsigned char reg_dur;
-       unsigned char ctrl_reg1;
-       unsigned char irq_type;
-       unsigned char mot_int1_cfg;
-};
-
-struct lis331dlh_private_data {
-       struct lis331dlh_config suspend;
-       struct lis331dlh_config resume;
-};
-
-/* -------------------------------------------------------------------------- */
-static int lis331dlh_set_ths(void *mlsl_handle,
-                            struct ext_slave_platform_data *pdata,
-                            struct lis331dlh_config *config,
-                            int apply, long ths)
-{
-       int result = INV_SUCCESS;
-       if ((unsigned int)ths >= config->fsr)
-               ths = (long)config->fsr - 1;
-
-       if (ths < 0)
-               ths = 0;
-
-       config->ths = ths;
-       config->reg_ths = (unsigned char)(long)((ths * 128L) / (config->fsr));
-       MPL_LOGV("THS: %d, 0x%02x\n", config->ths, (int)config->reg_ths);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS331DLH_INT1_THS,
-                                                config->reg_ths);
-       return result;
-}
-
-static int lis331dlh_set_dur(void *mlsl_handle,
-                            struct ext_slave_platform_data *pdata,
-                            struct lis331dlh_config *config,
-                            int apply, long dur)
-{
-       int result = INV_SUCCESS;
-       long reg_dur = (dur * config->odr) / 1000000L;
-       config->dur = dur;
-
-       if (reg_dur > LIS331DLH_MAX_DUR)
-               reg_dur = LIS331DLH_MAX_DUR;
-
-       config->reg_dur = (unsigned char)reg_dur;
-       MPL_LOGV("DUR: %d, 0x%02x\n", config->dur, (int)config->reg_dur);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS331DLH_INT1_DURATION,
-                                                (unsigned char)reg_dur);
-       return result;
-}
-
-/**
- * Sets the IRQ to fire when one of the IRQ events occur.  Threshold and
- * duration will not be used uless the type is MOT or NMOT.
- *
- * @param config configuration to apply to, suspend or resume
- * @param irq_type The type of IRQ.  Valid values are
- * - MPU_SLAVE_IRQ_TYPE_NONE
- * - MPU_SLAVE_IRQ_TYPE_MOTION
- * - MPU_SLAVE_IRQ_TYPE_DATA_READY
- */
-static int lis331dlh_set_irq(void *mlsl_handle,
-                            struct ext_slave_platform_data *pdata,
-                            struct lis331dlh_config *config,
-                            int apply, long irq_type)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-
-       config->irq_type = (unsigned char)irq_type;
-       if (irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x02;
-               reg2 = 0x00;
-       } else if (irq_type == MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x00;
-               reg2 = config->mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS331DLH_CTRL_REG3, reg1);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS331DLH_INT1_CFG, reg2);
-       }
-
-       return result;
-}
-
-/**
- * Set the Output data rate for the particular configuration
- *
- * @param config Config to modify with new ODR
- * @param odr Output data rate in units of 1/1000Hz
- */
-static int lis331dlh_set_odr(void *mlsl_handle,
-                            struct ext_slave_platform_data *pdata,
-                            struct lis331dlh_config *config,
-                            int apply, long odr)
-{
-       unsigned char bits;
-       int result = INV_SUCCESS;
-
-       /* normal power modes */
-       if (odr > 400000) {
-               config->odr = 1000000;
-               bits = LIS331DLH_PWR_MODE_NORMAL | 0x18;
-       } else if (odr > 100000) {
-               config->odr = 400000;
-               bits = LIS331DLH_PWR_MODE_NORMAL | 0x10;
-       } else if (odr > 50000) {
-               config->odr = 100000;
-               bits = LIS331DLH_PWR_MODE_NORMAL | 0x08;
-       } else if (odr > 10000) {
-               config->odr = 50000;
-               bits = LIS331DLH_PWR_MODE_NORMAL | 0x00;
-       /* low power modes */
-       } else if (odr > 5000) {
-               config->odr = 10000;
-               bits = 0xC0;
-       } else if (odr > 2000) {
-               config->odr = 5000;
-               bits = 0xA0;
-       } else if (odr > 1000) {
-               config->odr = 2000;
-               bits = 0x80;
-       } else if (odr > 500) {
-               config->odr = 1000;
-               bits = 0x60;
-       } else if (odr > 0) {
-               config->odr = 500;
-               bits = 0x40;
-       } else {
-               config->odr = 0;
-               bits = 0;
-       }
-
-       config->ctrl_reg1 = bits | (config->ctrl_reg1 & 0x7);
-       lis331dlh_set_dur(mlsl_handle, pdata, config, apply, config->dur);
-       MPL_LOGV("ODR: %d, 0x%02x\n", config->odr, (int)config->ctrl_reg1);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS331DLH_CTRL_REG1,
-                                                config->ctrl_reg1);
-       return result;
-}
-
-/**
- * Set the full scale range of the accels
- *
- * @param config pointer to configuration
- * @param fsr requested full scale range
- */
-static int lis331dlh_set_fsr(void *mlsl_handle,
-                            struct ext_slave_platform_data *pdata,
-                            struct lis331dlh_config *config,
-                            int apply, long fsr)
-{
-       unsigned char reg1 = 0x40;
-       int result = INV_SUCCESS;
-
-       if (fsr <= 2048) {
-               config->fsr = 2048;
-       } else if (fsr <= 4096) {
-               reg1 |= 0x30;
-               config->fsr = 4096;
-       } else {
-               reg1 |= 0x10;
-               config->fsr = 8192;
-       }
-
-       lis331dlh_set_ths(mlsl_handle, pdata, config, apply, config->ths);
-       MPL_LOGV("FSR: %d\n", config->fsr);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS331DLH_CTRL_REG4, reg1);
-
-       return result;
-}
-
-static int lis331dlh_suspend(void *mlsl_handle,
-                            struct ext_slave_descr *slave,
-                            struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-       struct lis331dlh_private_data *private_data =
-               (struct lis331dlh_private_data *)(pdata->private_data);
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_CTRL_REG1,
-                                        private_data->suspend.ctrl_reg1);
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_CTRL_REG2, 0x0f);
-       reg1 = 0x40;
-       if (private_data->suspend.fsr == 8192)
-               reg1 |= 0x30;
-       else if (private_data->suspend.fsr == 4096)
-               reg1 |= 0x10;
-       /* else bits [4..5] are already zero */
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_CTRL_REG4, reg1);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_INT1_THS,
-                                        private_data->suspend.reg_ths);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_INT1_DURATION,
-                                        private_data->suspend.reg_dur);
-
-       if (private_data->suspend.irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x02;
-               reg2 = 0x00;
-       } else if (private_data->suspend.irq_type ==
-                  MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x00;
-               reg2 = private_data->suspend.mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_CTRL_REG3, reg1);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_INT1_CFG, reg2);
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                LIS331DLH_HP_FILTER_RESET, 1, &reg1);
-       return result;
-}
-
-static int lis331dlh_resume(void *mlsl_handle,
-                           struct ext_slave_descr *slave,
-                           struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-       struct lis331dlh_private_data *private_data =
-               (struct lis331dlh_private_data *)(pdata->private_data);
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_CTRL_REG1,
-                                        private_data->resume.ctrl_reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(6);
-
-       /* Full Scale */
-       reg1 = 0x40;
-       if (private_data->resume.fsr == 8192)
-               reg1 |= 0x30;
-       else if (private_data->resume.fsr == 4096)
-               reg1 |= 0x10;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_CTRL_REG4, reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       /* Configure high pass filter */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_CTRL_REG2, 0x0F);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       if (private_data->resume.irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x02;
-               reg2 = 0x00;
-       } else if (private_data->resume.irq_type == MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x00;
-               reg2 = private_data->resume.mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_CTRL_REG3, reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_INT1_THS,
-                                        private_data->resume.reg_ths);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_INT1_DURATION,
-                                        private_data->resume.reg_dur);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS331DLH_INT1_CFG, reg2);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                LIS331DLH_HP_FILTER_RESET, 1, &reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       return result;
-}
-
-static int lis331dlh_read(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata,
-                         unsigned char *data)
-{
-       int result = INV_SUCCESS;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                LIS331DLH_STATUS_REG, 1, data);
-       if (data[0] & 0x0F) {
-               result = inv_serial_read(mlsl_handle, pdata->address,
-                                        slave->read_reg, slave->read_len,
-                                        data);
-               return result;
-       } else
-               return INV_ERROR_ACCEL_DATA_NOT_READY;
-}
-
-static int lis331dlh_init(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       struct lis331dlh_private_data *private_data;
-       long range;
-       private_data = (struct lis331dlh_private_data *)
-           kzalloc(sizeof(struct lis331dlh_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       pdata->private_data = private_data;
-
-       private_data->resume.ctrl_reg1 = 0x37;
-       private_data->suspend.ctrl_reg1 = 0x47;
-       private_data->resume.mot_int1_cfg = 0x95;
-       private_data->suspend.mot_int1_cfg = 0x2a;
-
-       lis331dlh_set_odr(mlsl_handle, pdata, &private_data->suspend, false, 0);
-       lis331dlh_set_odr(mlsl_handle, pdata, &private_data->resume,
-                         false, 200000);
-
-       range = range_fixedpoint_to_long_mg(slave->range);
-       lis331dlh_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                       false, range);
-       lis331dlh_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                       false, range);
-
-       lis331dlh_set_ths(mlsl_handle, pdata, &private_data->suspend,
-                         false, 80);
-       lis331dlh_set_ths(mlsl_handle, pdata, &private_data->resume, false, 40);
-
-
-       lis331dlh_set_dur(mlsl_handle, pdata, &private_data->suspend,
-                         false, 1000);
-       lis331dlh_set_dur(mlsl_handle, pdata, &private_data->resume,
-                         false, 2540);
-
-       lis331dlh_set_irq(mlsl_handle, pdata, &private_data->suspend,
-                         false, MPU_SLAVE_IRQ_TYPE_NONE);
-       lis331dlh_set_irq(mlsl_handle, pdata, &private_data->resume,
-                         false, MPU_SLAVE_IRQ_TYPE_NONE);
-       return INV_SUCCESS;
-}
-
-static int lis331dlh_exit(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-static int lis331dlh_config(void *mlsl_handle,
-                           struct ext_slave_descr *slave,
-                           struct ext_slave_platform_data *pdata,
-                           struct ext_slave_config *data)
-{
-       struct lis331dlh_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return lis331dlh_set_odr(mlsl_handle, pdata,
-                                        &private_data->suspend,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return lis331dlh_set_odr(mlsl_handle, pdata,
-                                        &private_data->resume,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return lis331dlh_set_fsr(mlsl_handle, pdata,
-                                        &private_data->suspend,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return lis331dlh_set_fsr(mlsl_handle, pdata,
-                                        &private_data->resume,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               return lis331dlh_set_ths(mlsl_handle, pdata,
-                                        &private_data->suspend,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               return lis331dlh_set_ths(mlsl_handle, pdata,
-                                        &private_data->resume,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               return lis331dlh_set_dur(mlsl_handle, pdata,
-                                        &private_data->suspend,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               return lis331dlh_set_dur(mlsl_handle, pdata,
-                                        &private_data->resume,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               return lis331dlh_set_irq(mlsl_handle, pdata,
-                                        &private_data->suspend,
-                                        data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               return lis331dlh_set_irq(mlsl_handle, pdata,
-                                        &private_data->resume,
-                                        data->apply, *((long *)data->data));
-       default:
-               LOG_RESULT_LOCATION(INV_ERROR_FEATURE_NOT_IMPLEMENTED);
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-static int lis331dlh_get_config(void *mlsl_handle,
-                               struct ext_slave_descr *slave,
-                               struct ext_slave_platform_data *pdata,
-                               struct ext_slave_config *data)
-{
-       struct lis331dlh_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.ths;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.ths;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.dur;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.dur;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.irq_type;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.irq_type;
-               break;
-       default:
-               LOG_RESULT_LOCATION(INV_ERROR_FEATURE_NOT_IMPLEMENTED);
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-static struct ext_slave_descr lis331dlh_descr = {
-       .init             = lis331dlh_init,
-       .exit             = lis331dlh_exit,
-       .suspend          = lis331dlh_suspend,
-       .resume           = lis331dlh_resume,
-       .read             = lis331dlh_read,
-       .config           = lis331dlh_config,
-       .get_config       = lis331dlh_get_config,
-       .name             = "lis331dlh",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_LIS331,
-       .read_reg         = (0x28 | 0x80), /* 0x80 for burst reads */
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_BIG_ENDIAN,
-       .range            = {2, 480},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *lis331_get_slave_descr(void)
-{
-       return &lis331dlh_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-struct lis331_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int lis331_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct lis331_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       lis331_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int lis331_mod_remove(struct i2c_client *client)
-{
-       struct lis331_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               lis331_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id lis331_mod_id[] = {
-       { "lis331", ACCEL_ID_LIS331 },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, lis331_mod_id);
-
-static struct i2c_driver lis331_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = lis331_mod_probe,
-       .remove = lis331_mod_remove,
-       .id_table = lis331_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "lis331_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init lis331_mod_init(void)
-{
-       int res = i2c_add_driver(&lis331_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "lis331_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit lis331_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&lis331_mod_driver);
-}
-
-module_init(lis331_mod_init);
-module_exit(lis331_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate LIS331 sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("lis331_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/lis3dh.c b/drivers/misc/inv_mpu/accel/lis3dh.c
deleted file mode 100644 (file)
index 27206e4..0000000
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   lis3dh.c
- *      @brief  Accelerometer setup and handling methods for ST LIS3DH.
- */
-
-/* -------------------------------------------------------------------------- */
-
-#undef MPL_LOG_NDEBUG
-#define MPL_LOG_NDEBUG 0
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-/* full scale setting - register & mask */
-#define LIS3DH_CTRL_REG1         (0x20)
-#define LIS3DH_CTRL_REG2         (0x21)
-#define LIS3DH_CTRL_REG3         (0x22)
-#define LIS3DH_CTRL_REG4         (0x23)
-#define LIS3DH_CTRL_REG5         (0x24)
-#define LIS3DH_CTRL_REG6         (0x25)
-#define LIS3DH_REFERENCE         (0x26)
-#define LIS3DH_STATUS_REG        (0x27)
-#define LIS3DH_OUT_X_L           (0x28)
-#define LIS3DH_OUT_X_H           (0x29)
-#define LIS3DH_OUT_Y_L           (0x2a)
-#define LIS3DH_OUT_Y_H           (0x2b)
-#define LIS3DH_OUT_Z_L           (0x2c)
-#define LIS3DH_OUT_Z_H           (0x2d)
-
-#define LIS3DH_INT1_CFG          (0x30)
-#define LIS3DH_INT1_SRC          (0x31)
-#define LIS3DH_INT1_THS          (0x32)
-#define LIS3DH_INT1_DURATION     (0x33)
-
-#define LIS3DH_MAX_DUR (0x7F)
-
-/* -------------------------------------------------------------------------- */
-
-struct lis3dh_config {
-       unsigned long odr;
-       unsigned int fsr;       /* full scale range mg */
-       unsigned int ths;       /* Motion no-motion thseshold mg */
-       unsigned int dur;       /* Motion no-motion duration ms */
-       unsigned char reg_ths;
-       unsigned char reg_dur;
-       unsigned char ctrl_reg1;
-       unsigned char irq_type;
-       unsigned char mot_int1_cfg;
-};
-
-struct lis3dh_private_data {
-       struct lis3dh_config suspend;
-       struct lis3dh_config resume;
-};
-
-/* -------------------------------------------------------------------------- */
-
-static int lis3dh_set_ths(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct lis3dh_config *config, int apply, long ths)
-{
-       int result = INV_SUCCESS;
-       if ((unsigned int)ths > 1000 * config->fsr)
-               ths = (long)1000 * config->fsr;
-
-       if (ths < 0)
-               ths = 0;
-
-       config->ths = ths;
-       config->reg_ths = (unsigned char)(long)((ths * 128L) / (config->fsr));
-       MPL_LOGV("THS: %d, 0x%02x\n", config->ths, (int)config->reg_ths);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS3DH_INT1_THS,
-                                                config->reg_ths);
-       return result;
-}
-
-static int lis3dh_set_dur(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct lis3dh_config *config, int apply, long dur)
-{
-       int result = INV_SUCCESS;
-       long reg_dur = (dur * config->odr) / 1000000L;
-       config->dur = dur;
-
-       if (reg_dur > LIS3DH_MAX_DUR)
-               reg_dur = LIS3DH_MAX_DUR;
-
-       config->reg_dur = (unsigned char)reg_dur;
-       MPL_LOGV("DUR: %d, 0x%02x\n", config->dur, (int)config->reg_dur);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS3DH_INT1_DURATION,
-                                                (unsigned char)reg_dur);
-       return result;
-}
-
-/**
- * Sets the IRQ to fire when one of the IRQ events occur.  Threshold and
- * duration will not be used uless the type is MOT or NMOT.
- *
- * @param config configuration to apply to, suspend or resume
- * @param irq_type The type of IRQ.  Valid values are
- * - MPU_SLAVE_IRQ_TYPE_NONE
- * - MPU_SLAVE_IRQ_TYPE_MOTION
- * - MPU_SLAVE_IRQ_TYPE_DATA_READY
- */
-static int lis3dh_set_irq(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct lis3dh_config *config,
-                         int apply, long irq_type)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-
-       config->irq_type = (unsigned char)irq_type;
-       if (irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x10;
-               reg2 = 0x00;
-       } else if (irq_type == MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x40;
-               reg2 = config->mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS3DH_CTRL_REG3, reg1);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS3DH_INT1_CFG, reg2);
-       }
-
-       return result;
-}
-
-/**
- * Set the Output data rate for the particular configuration
- *
- * @param config Config to modify with new ODR
- * @param odr Output data rate in units of 1/1000Hz
- */
-static int lis3dh_set_odr(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct lis3dh_config *config, int apply, long odr)
-{
-       unsigned char bits;
-       int result = INV_SUCCESS;
-
-       if (odr > 400000L) {
-               config->odr = 1250000L;
-               bits = 0x90;
-       } else if (odr > 200000L) {
-               config->odr = 400000L;
-               bits = 0x70;
-       } else if (odr > 100000L) {
-               config->odr = 200000L;
-               bits = 0x60;
-       } else if (odr > 50000) {
-               config->odr = 100000L;
-               bits = 0x50;
-       } else if (odr > 25000) {
-               config->odr = 50000;
-               bits = 0x40;
-       } else if (odr > 10000) {
-               config->odr = 25000;
-               bits = 0x30;
-       } else if (odr > 1000) {
-               config->odr = 10000;
-               bits = 0x20;
-       } else if (odr > 500) {
-               config->odr = 1000;
-               bits = 0x10;
-       } else {
-               config->odr = 0;
-               bits = 0;
-       }
-
-       config->ctrl_reg1 = bits | (config->ctrl_reg1 & 0xf);
-       lis3dh_set_dur(mlsl_handle, pdata, config, apply, config->dur);
-       MPL_LOGV("ODR: %ld, 0x%02x\n", config->odr, (int)config->ctrl_reg1);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS3DH_CTRL_REG1,
-                                                config->ctrl_reg1);
-       return result;
-}
-
-/**
- * Set the full scale range of the accels
- *
- * @param config pointer to configuration
- * @param fsr requested full scale range
- */
-static int lis3dh_set_fsr(void *mlsl_handle,
-                         struct ext_slave_platform_data *pdata,
-                         struct lis3dh_config *config, int apply, long fsr)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1 = 0x48;
-
-       if (fsr <= 2048) {
-               config->fsr = 2048;
-       } else if (fsr <= 4096) {
-               reg1 |= 0x10;
-               config->fsr = 4096;
-       } else if (fsr <= 8192) {
-               reg1 |= 0x20;
-               config->fsr = 8192;
-       } else {
-               reg1 |= 0x30;
-               config->fsr = 16348;
-       }
-
-       lis3dh_set_ths(mlsl_handle, pdata, config, apply, config->ths);
-       MPL_LOGV("FSR: %d\n", config->fsr);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                                LIS3DH_CTRL_REG4, reg1);
-
-       return result;
-}
-
-static int lis3dh_suspend(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-       struct lis3dh_private_data *private_data = pdata->private_data;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_CTRL_REG1,
-                                        private_data->suspend.ctrl_reg1);
-
-       reg1 = 0x48;
-       if (private_data->suspend.fsr == 16384)
-               reg1 |= 0x30;
-       else if (private_data->suspend.fsr == 8192)
-               reg1 |= 0x20;
-       else if (private_data->suspend.fsr == 4096)
-               reg1 |= 0x10;
-       else if (private_data->suspend.fsr == 2048)
-               reg1 |= 0x00;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_CTRL_REG4, reg1);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_INT1_THS,
-                                        private_data->suspend.reg_ths);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_INT1_DURATION,
-                                        private_data->suspend.reg_dur);
-
-       if (private_data->suspend.irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x10;
-               reg2 = 0x00;
-       } else if (private_data->suspend.irq_type ==
-                  MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x40;
-               reg2 = private_data->suspend.mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_CTRL_REG3, reg1);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_INT1_CFG, reg2);
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                LIS3DH_CTRL_REG6, 1, &reg1);
-
-       return result;
-}
-
-static int lis3dh_resume(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata)
-{
-       int result;
-       unsigned char reg1;
-       unsigned char reg2;
-       struct lis3dh_private_data *private_data = pdata->private_data;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_CTRL_REG1,
-                                        private_data->resume.ctrl_reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(6);
-
-       /* Full Scale */
-       reg1 = 0x48;
-       if (private_data->suspend.fsr == 16384)
-               reg1 |= 0x30;
-       else if (private_data->suspend.fsr == 8192)
-               reg1 |= 0x20;
-       else if (private_data->suspend.fsr == 4096)
-               reg1 |= 0x10;
-       else if (private_data->suspend.fsr == 2048)
-               reg1 |= 0x00;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_CTRL_REG4, reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       if (private_data->resume.irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x10;
-               reg2 = 0x00;
-       } else if (private_data->resume.irq_type == MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x40;
-               reg2 = private_data->resume.mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_CTRL_REG3, reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_INT1_THS,
-                                        private_data->resume.reg_ths);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_INT1_DURATION,
-                                        private_data->resume.reg_dur);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_INT1_CFG, reg2);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                LIS3DH_CTRL_REG6, 1, &reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       return result;
-}
-
-static int lis3dh_read(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata,
-                      unsigned char *data)
-{
-       int result = INV_SUCCESS;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                                LIS3DH_STATUS_REG, 1, data);
-       if (data[0] & 0x0F) {
-               result = inv_serial_read(mlsl_handle, pdata->address,
-                                        slave->read_reg, slave->read_len,
-                                        data);
-               return result;
-       } else
-               return INV_ERROR_ACCEL_DATA_NOT_READY;
-}
-
-static int lis3dh_init(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata)
-{
-       int result;
-       long range;
-       struct lis3dh_private_data *private_data;
-       private_data = (struct lis3dh_private_data *)
-           kzalloc(sizeof(struct lis3dh_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       pdata->private_data = private_data;
-
-       private_data->resume.ctrl_reg1 = 0x67;
-       private_data->suspend.ctrl_reg1 = 0x18;
-       private_data->resume.mot_int1_cfg = 0x95;
-       private_data->suspend.mot_int1_cfg = 0x2a;
-
-       lis3dh_set_odr(mlsl_handle, pdata, &private_data->suspend, false, 0);
-       lis3dh_set_odr(mlsl_handle, pdata, &private_data->resume,
-                      false, 200000L);
-
-       range = range_fixedpoint_to_long_mg(slave->range);
-       lis3dh_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                       false, range);
-       lis3dh_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                       false, range);
-
-       lis3dh_set_ths(mlsl_handle, pdata, &private_data->suspend,
-                       false, 80);
-       lis3dh_set_ths(mlsl_handle, pdata, &private_data->resume,
-                       false, 40);
-
-       lis3dh_set_dur(mlsl_handle, pdata, &private_data->suspend,
-                       false, 1000);
-       lis3dh_set_dur(mlsl_handle, pdata, &private_data->resume,
-                       false, 2540);
-
-       lis3dh_set_irq(mlsl_handle, pdata, &private_data->suspend,
-                       false, MPU_SLAVE_IRQ_TYPE_NONE);
-       lis3dh_set_irq(mlsl_handle, pdata, &private_data->resume,
-                       false, MPU_SLAVE_IRQ_TYPE_NONE);
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                        LIS3DH_CTRL_REG1, 0x07);
-       msleep(6);
-
-       return INV_SUCCESS;
-}
-
-static int lis3dh_exit(void *mlsl_handle,
-                      struct ext_slave_descr *slave,
-                      struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-static int lis3dh_config(void *mlsl_handle,
-                        struct ext_slave_descr *slave,
-                        struct ext_slave_platform_data *pdata,
-                        struct ext_slave_config *data)
-{
-       struct lis3dh_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return lis3dh_set_odr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return lis3dh_set_odr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return lis3dh_set_fsr(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return lis3dh_set_fsr(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               return lis3dh_set_ths(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               return lis3dh_set_ths(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               return lis3dh_set_dur(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               return lis3dh_set_dur(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               return lis3dh_set_irq(mlsl_handle, pdata,
-                                     &private_data->suspend,
-                                     data->apply, *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               return lis3dh_set_irq(mlsl_handle, pdata,
-                                     &private_data->resume,
-                                     data->apply, *((long *)data->data));
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-       return INV_SUCCESS;
-}
-
-static int lis3dh_get_config(void *mlsl_handle,
-                            struct ext_slave_descr *slave,
-                            struct ext_slave_platform_data *pdata,
-                            struct ext_slave_config *data)
-{
-       struct lis3dh_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.ths;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.ths;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.dur;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.dur;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->suspend.irq_type;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               (*(unsigned long *)data->data) =
-                   (unsigned long)private_data->resume.irq_type;
-               break;
-       default:
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-static struct ext_slave_descr lis3dh_descr = {
-       .init             = lis3dh_init,
-       .exit             = lis3dh_exit,
-       .suspend          = lis3dh_suspend,
-       .resume           = lis3dh_resume,
-       .read             = lis3dh_read,
-       .config           = lis3dh_config,
-       .get_config       = lis3dh_get_config,
-       .name             = "lis3dh",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_LIS3DH,
-       .read_reg         = 0x28 | 0x80, /* 0x80 for burst reads */
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_BIG_ENDIAN,
-       .range            = {2, 480},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *lis3dh_get_slave_descr(void)
-{
-       return &lis3dh_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-struct lis3dh_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int lis3dh_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct lis3dh_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       lis3dh_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int lis3dh_mod_remove(struct i2c_client *client)
-{
-       struct lis3dh_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               lis3dh_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id lis3dh_mod_id[] = {
-       { "lis3dh", ACCEL_ID_LIS3DH },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, lis3dh_mod_id);
-
-static struct i2c_driver lis3dh_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = lis3dh_mod_probe,
-       .remove = lis3dh_mod_remove,
-       .id_table = lis3dh_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "lis3dh_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init lis3dh_mod_init(void)
-{
-       int res = i2c_add_driver(&lis3dh_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "lis3dh_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit lis3dh_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&lis3dh_mod_driver);
-}
-
-module_init(lis3dh_mod_init);
-module_exit(lis3dh_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate LIS3DH sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("lis3dh_mod");
-
-/*
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/lsm303dlx_a.c b/drivers/misc/inv_mpu/accel/lsm303dlx_a.c
deleted file mode 100644 (file)
index 576282a..0000000
+++ /dev/null
@@ -1,881 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   lsm303dlx_a.c
- *      @brief  Accelerometer setup and handling methods for ST LSM303DLH
- *              or LSM303DLM accel.
- */
-
-/* -------------------------------------------------------------------------- */
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-/* -------------------------------------------------------------------------- */
-
-/* full scale setting - register & mask */
-#define LSM303DLx_CTRL_REG1         (0x20)
-#define LSM303DLx_CTRL_REG2         (0x21)
-#define LSM303DLx_CTRL_REG3         (0x22)
-#define LSM303DLx_CTRL_REG4         (0x23)
-#define LSM303DLx_CTRL_REG5         (0x24)
-#define LSM303DLx_HP_FILTER_RESET   (0x25)
-#define LSM303DLx_REFERENCE         (0x26)
-#define LSM303DLx_STATUS_REG        (0x27)
-#define LSM303DLx_OUT_X_L           (0x28)
-#define LSM303DLx_OUT_X_H           (0x29)
-#define LSM303DLx_OUT_Y_L           (0x2a)
-#define LSM303DLx_OUT_Y_H           (0x2b)
-#define LSM303DLx_OUT_Z_L           (0x2b)
-#define LSM303DLx_OUT_Z_H           (0x2d)
-
-#define LSM303DLx_INT1_CFG          (0x30)
-#define LSM303DLx_INT1_SRC          (0x31)
-#define LSM303DLx_INT1_THS          (0x32)
-#define LSM303DLx_INT1_DURATION     (0x33)
-
-#define LSM303DLx_INT2_CFG          (0x34)
-#define LSM303DLx_INT2_SRC          (0x35)
-#define LSM303DLx_INT2_THS          (0x36)
-#define LSM303DLx_INT2_DURATION     (0x37)
-
-#define LSM303DLx_CTRL_MASK         (0x30)
-#define LSM303DLx_SLEEP_MASK        (0x20)
-#define LSM303DLx_PWR_MODE_NORMAL   (0x20)
-
-#define LSM303DLx_MAX_DUR           (0x7F)
-
-/* -------------------------------------------------------------------------- */
-
-struct lsm303dlx_a_config {
-       unsigned int odr;
-       unsigned int fsr; /** < full scale range mg */
-       unsigned int ths; /** < Motion no-motion thseshold mg */
-       unsigned int dur; /** < Motion no-motion duration ms */
-       unsigned char reg_ths;
-       unsigned char reg_dur;
-       unsigned char ctrl_reg1;
-       unsigned char irq_type;
-       unsigned char mot_int1_cfg;
-};
-
-struct lsm303dlx_a_private_data {
-       struct lsm303dlx_a_config suspend;
-       struct lsm303dlx_a_config resume;
-};
-
-/* -------------------------------------------------------------------------- */
-
-static int lsm303dlx_a_set_ths(void *mlsl_handle,
-                              struct ext_slave_platform_data *pdata,
-                              struct lsm303dlx_a_config *config,
-                              int apply,
-                              long ths)
-{
-       int result = INV_SUCCESS;
-       if ((unsigned int) ths >= config->fsr)
-               ths = (long) config->fsr - 1;
-
-       if (ths < 0)
-               ths = 0;
-
-       config->ths = ths;
-       config->reg_ths = (unsigned char)(long)((ths * 128L) / (config->fsr));
-       MPL_LOGV("THS: %d, 0x%02x\n", config->ths, (int)config->reg_ths);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       LSM303DLx_INT1_THS,
-                                       config->reg_ths);
-       return result;
-}
-
-static int lsm303dlx_a_set_dur(void *mlsl_handle,
-                              struct ext_slave_platform_data *pdata,
-                              struct lsm303dlx_a_config *config,
-                              int apply,
-                              long dur)
-{
-       int result = INV_SUCCESS;
-       long reg_dur = (dur * config->odr) / 1000000L;
-       config->dur = dur;
-
-       if (reg_dur > LSM303DLx_MAX_DUR)
-               reg_dur = LSM303DLx_MAX_DUR;
-
-       config->reg_dur = (unsigned char) reg_dur;
-       MPL_LOGV("DUR: %d, 0x%02x\n", config->dur, (int)config->reg_dur);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       LSM303DLx_INT1_DURATION,
-                                       (unsigned char)reg_dur);
-       return result;
-}
-
-/**
- * Sets the IRQ to fire when one of the IRQ events occur.  Threshold and
- * duration will not be used uless the type is MOT or NMOT.
- *
- * @param config configuration to apply to, suspend or resume
- * @param irq_type The type of IRQ.  Valid values are
- * - MPU_SLAVE_IRQ_TYPE_NONE
- * - MPU_SLAVE_IRQ_TYPE_MOTION
- * - MPU_SLAVE_IRQ_TYPE_DATA_READY
- */
-static int lsm303dlx_a_set_irq(void *mlsl_handle,
-                              struct ext_slave_platform_data *pdata,
-                              struct lsm303dlx_a_config *config,
-                              int apply,
-                              long irq_type)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-
-       config->irq_type = (unsigned char)irq_type;
-       if (irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x02;
-               reg2 = 0x00;
-       } else if (irq_type == MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x00;
-               reg2 = config->mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       LSM303DLx_CTRL_REG3, reg1);
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       LSM303DLx_INT1_CFG, reg2);
-       }
-
-       return result;
-}
-
-/**
- *  @brief Set the output data rate for the particular configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             Config to modify with new ODR.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param odr
- *             Output data rate in units of 1/1000Hz (mHz).
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_set_odr(void *mlsl_handle,
-                              struct ext_slave_platform_data *pdata,
-                              struct lsm303dlx_a_config *config,
-                              int apply,
-                              long odr)
-{
-       unsigned char bits;
-       int result = INV_SUCCESS;
-
-       /* normal power modes */
-       if (odr > 400000) {
-               config->odr = 1000000;
-               bits = LSM303DLx_PWR_MODE_NORMAL | 0x18;
-       } else if (odr > 100000) {
-               config->odr = 400000;
-               bits = LSM303DLx_PWR_MODE_NORMAL | 0x10;
-       } else if (odr > 50000) {
-               config->odr = 100000;
-               bits = LSM303DLx_PWR_MODE_NORMAL | 0x08;
-       } else if (odr > 10000) {
-               config->odr = 50000;
-               bits = LSM303DLx_PWR_MODE_NORMAL | 0x00;
-       /* low power modes */
-       } else if (odr > 5000) {
-               config->odr = 10000;
-               bits = 0xC0;
-       } else if (odr > 2000) {
-               config->odr = 5000;
-               bits = 0xA0;
-       } else if (odr > 1000) {
-               config->odr = 2000;
-               bits = 0x80;
-       } else if (odr > 500) {
-               config->odr = 1000;
-               bits = 0x60;
-       } else if (odr > 0) {
-               config->odr = 500;
-               bits = 0x40;
-       } else {
-               config->odr = 0;
-               bits = 0;
-       }
-
-       config->ctrl_reg1 = bits | (config->ctrl_reg1 & 0x7);
-       lsm303dlx_a_set_dur(mlsl_handle, pdata, config, apply, config->dur);
-       MPL_LOGV("ODR: %d, 0x%02x\n", config->odr, (int)config->ctrl_reg1);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       LSM303DLx_CTRL_REG1,
-                                       config->ctrl_reg1);
-       return result;
-}
-
-/**
- *  @brief Set the full scale range of the accels
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             pointer to configuration.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param fsr
- *             requested full scale range.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_set_fsr(void *mlsl_handle,
-                              struct ext_slave_platform_data *pdata,
-                              struct lsm303dlx_a_config *config,
-                              int apply,
-                              long fsr)
-{
-       unsigned char reg1 = 0x40;
-       int result = INV_SUCCESS;
-
-       if (fsr <= 2048) {
-               config->fsr = 2048;
-       } else if (fsr <= 4096) {
-               reg1 |= 0x30;
-               config->fsr = 4096;
-       } else {
-               reg1 |= 0x10;
-               config->fsr = 8192;
-       }
-
-       lsm303dlx_a_set_ths(mlsl_handle, pdata,
-                       config, apply, config->ths);
-       MPL_LOGV("FSR: %d\n", config->fsr);
-       if (apply)
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       LSM303DLx_CTRL_REG4, reg1);
-
-       return result;
-}
-
-/**
- *  @brief suspends the device to put it in its lowest power mode.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_suspend(void *mlsl_handle,
-                              struct ext_slave_descr *slave,
-                              struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-       struct lsm303dlx_a_private_data *private_data =
-               (struct lsm303dlx_a_private_data *)(pdata->private_data);
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_CTRL_REG1,
-                                      private_data->suspend.ctrl_reg1);
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_CTRL_REG2, 0x0f);
-       reg1 = 0x40;
-       if (private_data->suspend.fsr == 8192)
-               reg1 |= 0x30;
-       else if (private_data->suspend.fsr == 4096)
-               reg1 |= 0x10;
-       /* else bits [4..5] are already zero */
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_CTRL_REG4, reg1);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_INT1_THS,
-                                      private_data->suspend.reg_ths);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_INT1_DURATION,
-                                      private_data->suspend.reg_dur);
-
-       if (private_data->suspend.irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x02;
-               reg2 = 0x00;
-       } else if (private_data->suspend.irq_type ==
-                  MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x00;
-               reg2 = private_data->suspend.mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_CTRL_REG3, reg1);
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_INT1_CFG, reg2);
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                               LSM303DLx_HP_FILTER_RESET, 1, &reg1);
-       return result;
-}
-
-/**
- *  @brief resume the device in the proper power state given the configuration
- *         chosen.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_resume(void *mlsl_handle,
-                             struct ext_slave_descr *slave,
-                             struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-       struct lsm303dlx_a_private_data *private_data =
-               (struct lsm303dlx_a_private_data *)(pdata->private_data);
-
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_CTRL_REG1,
-                                      private_data->resume.ctrl_reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       msleep(6);
-
-       /* Full Scale */
-       reg1 = 0x40;
-       if (private_data->resume.fsr == 8192)
-               reg1 |= 0x30;
-       else if (private_data->resume.fsr == 4096)
-               reg1 |= 0x10;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_CTRL_REG4, reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       /* Configure high pass filter */
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_CTRL_REG2, 0x0F);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       if (private_data->resume.irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x02;
-               reg2 = 0x00;
-       } else if (private_data->resume.irq_type ==
-                  MPU_SLAVE_IRQ_TYPE_MOTION) {
-               reg1 = 0x00;
-               reg2 = private_data->resume.mot_int1_cfg;
-       } else {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_CTRL_REG3, reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_INT1_THS,
-                                      private_data->resume.reg_ths);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_INT1_DURATION,
-                                      private_data->resume.reg_dur);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                      LSM303DLx_INT1_CFG, reg2);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                               LSM303DLx_HP_FILTER_RESET, 1, &reg1);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       return result;
-}
-
-/**
- *  @brief read the sensor data from the device.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a buffer to store the data read.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_read(void *mlsl_handle,
-                           struct ext_slave_descr *slave,
-                           struct ext_slave_platform_data *pdata,
-                           unsigned char *data)
-{
-       int result = INV_SUCCESS;
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                               LSM303DLx_STATUS_REG, 1, data);
-       if (data[0] & 0x0F) {
-               result = inv_serial_read(mlsl_handle, pdata->address,
-                                       slave->read_reg, slave->read_len, data);
-       return result;
-       } else
-               return INV_ERROR_ACCEL_DATA_NOT_READY;
-}
-
-/**
- *  @brief one-time device driver initialization function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is loaded in the kernel.
- *         If the driver is built-in in the kernel, this function will be
- *         called at boot time.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_init(void *mlsl_handle,
-                           struct ext_slave_descr *slave,
-                           struct ext_slave_platform_data *pdata)
-{
-       long range;
-       struct lsm303dlx_a_private_data *private_data;
-       private_data = (struct lsm303dlx_a_private_data *)
-           kzalloc(sizeof(struct lsm303dlx_a_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       pdata->private_data = private_data;
-
-       private_data->resume.ctrl_reg1 = 0x37;
-       private_data->suspend.ctrl_reg1 = 0x47;
-       private_data->resume.mot_int1_cfg = 0x95;
-       private_data->suspend.mot_int1_cfg = 0x2a;
-
-       lsm303dlx_a_set_odr(mlsl_handle, pdata, &private_data->suspend,
-                       false, 0);
-       lsm303dlx_a_set_odr(mlsl_handle, pdata, &private_data->resume,
-                       false, 200000);
-
-       range = range_fixedpoint_to_long_mg(slave->range);
-       lsm303dlx_a_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                       false, range);
-       lsm303dlx_a_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                       false, range);
-
-       lsm303dlx_a_set_ths(mlsl_handle, pdata, &private_data->suspend,
-                       false, 80);
-       lsm303dlx_a_set_ths(mlsl_handle, pdata, &private_data->resume,
-                       false, 40);
-
-       lsm303dlx_a_set_dur(mlsl_handle, pdata, &private_data->suspend,
-                       false, 1000);
-       lsm303dlx_a_set_dur(mlsl_handle, pdata, &private_data->resume,
-                       false, 2540);
-
-       lsm303dlx_a_set_irq(mlsl_handle, pdata, &private_data->suspend,
-                       false, MPU_SLAVE_IRQ_TYPE_NONE);
-       lsm303dlx_a_set_irq(mlsl_handle, pdata, &private_data->resume,
-                       false, MPU_SLAVE_IRQ_TYPE_NONE);
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief one-time device driver exit function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is removed from the kernel.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_exit(void *mlsl_handle,
-                           struct ext_slave_descr *slave,
-                           struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief device configuration facility.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to the configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_config(void *mlsl_handle,
-                             struct ext_slave_descr *slave,
-                             struct ext_slave_platform_data *pdata,
-                             struct ext_slave_config *data)
-{
-       struct lsm303dlx_a_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return lsm303dlx_a_set_odr(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return lsm303dlx_a_set_odr(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return lsm303dlx_a_set_fsr(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return lsm303dlx_a_set_fsr(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               return lsm303dlx_a_set_ths(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               return lsm303dlx_a_set_ths(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               return lsm303dlx_a_set_dur(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               return lsm303dlx_a_set_dur(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               return lsm303dlx_a_set_irq(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               return lsm303dlx_a_set_irq(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       default:
-               LOG_RESULT_LOCATION(INV_ERROR_FEATURE_NOT_IMPLEMENTED);
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief facility to retrieve the device configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to store the returned configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int lsm303dlx_a_get_config(void *mlsl_handle,
-                                 struct ext_slave_descr *slave,
-                                 struct ext_slave_platform_data *pdata,
-                                 struct ext_slave_config *data)
-{
-       struct lsm303dlx_a_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.ths;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.ths;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.dur;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.dur;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.irq_type;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.irq_type;
-               break;
-       default:
-               LOG_RESULT_LOCATION(INV_ERROR_FEATURE_NOT_IMPLEMENTED);
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-static struct ext_slave_descr lsm303dlx_a_descr = {
-       .init             = lsm303dlx_a_init,
-       .exit             = lsm303dlx_a_exit,
-       .suspend          = lsm303dlx_a_suspend,
-       .resume           = lsm303dlx_a_resume,
-       .read             = lsm303dlx_a_read,
-       .config           = lsm303dlx_a_config,
-       .get_config       = lsm303dlx_a_get_config,
-       .name             = "lsm303dlx_a",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_LSM303DLX,
-       .read_reg         = (0x28 | 0x80), /* 0x80 for burst reads */
-       .read_len         = 6,
-       .endian           = EXT_SLAVE_BIG_ENDIAN,
-       .range            = {2, 480},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *lsm303dlx_a_get_slave_descr(void)
-{
-       return &lsm303dlx_a_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-struct lsm303dlx_a_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int lsm303dlx_a_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct lsm303dlx_a_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       lsm303dlx_a_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int lsm303dlx_a_mod_remove(struct i2c_client *client)
-{
-       struct lsm303dlx_a_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               lsm303dlx_a_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id lsm303dlx_a_mod_id[] = {
-       { "lsm303dlx", ACCEL_ID_LSM303DLX },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, lsm303dlx_a_mod_id);
-
-static struct i2c_driver lsm303dlx_a_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = lsm303dlx_a_mod_probe,
-       .remove = lsm303dlx_a_mod_remove,
-       .id_table = lsm303dlx_a_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "lsm303dlx_a_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init lsm303dlx_a_mod_init(void)
-{
-       int res = i2c_add_driver(&lsm303dlx_a_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "lsm303dlx_a_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit lsm303dlx_a_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&lsm303dlx_a_mod_driver);
-}
-
-module_init(lsm303dlx_a_mod_init);
-module_exit(lsm303dlx_a_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate LSM303DLX_A sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("lsm303dlx_a_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/mma8450.c b/drivers/misc/inv_mpu/accel/mma8450.c
deleted file mode 100644 (file)
index f698ee9..0000000
+++ /dev/null
@@ -1,804 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   mma8450.c
- *      @brief  Accelerometer setup and handling methods for Freescale MMA8450.
- */
-
-/* -------------------------------------------------------------------------- */
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-/* full scale setting - register & mask */
-#define ACCEL_MMA8450_XYZ_DATA_CFG     (0x16)
-
-#define ACCEL_MMA8450_CTRL_REG1                (0x38)
-#define ACCEL_MMA8450_CTRL_REG2     (0x39)
-#define ACCEL_MMA8450_CTRL_REG4                (0x3B)
-#define ACCEL_MMA8450_CTRL_REG5                (0x3C)
-
-#define ACCEL_MMA8450_CTRL_REG         (0x38)
-#define ACCEL_MMA8450_CTRL_MASK                (0x03)
-
-#define ACCEL_MMA8450_SLEEP_MASK       (0x03)
-
-/* -------------------------------------------------------------------------- */
-
-struct mma8450_config {
-       unsigned int odr;
-       unsigned int fsr;       /** < full scale range mg */
-       unsigned int ths;       /** < Motion no-motion thseshold mg */
-       unsigned int dur;       /** < Motion no-motion duration ms */
-       unsigned char reg_ths;
-       unsigned char reg_dur;
-       unsigned char ctrl_reg1;
-       unsigned char irq_type;
-       unsigned char mot_int1_cfg;
-};
-
-struct mma8450_private_data {
-       struct mma8450_config suspend;
-       struct mma8450_config resume;
-};
-
-
-/* -------------------------------------------------------------------------- */
-
-static int mma8450_set_ths(void *mlsl_handle,
-                       struct ext_slave_platform_data *pdata,
-                       struct mma8450_config *config,
-                       int apply,
-                       long ths)
-{
-       return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-}
-
-static int mma8450_set_dur(void *mlsl_handle,
-                       struct ext_slave_platform_data *pdata,
-                       struct mma8450_config *config,
-                       int apply,
-                       long dur)
-{
-       return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-}
-
-/**
- *  @brief Sets the IRQ to fire when one of the IRQ events occur.
- *         Threshold and duration will not be used unless the type is MOT or
- *         NMOT.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *              configuration to apply to, suspend or resume
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param irq_type
- *              the type of IRQ.  Valid values are
- *              - MPU_SLAVE_IRQ_TYPE_NONE
- *              - MPU_SLAVE_IRQ_TYPE_MOTION
- *              - MPU_SLAVE_IRQ_TYPE_DATA_READY
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_set_irq(void *mlsl_handle,
-               struct ext_slave_platform_data *pdata,
-               struct mma8450_config *config,
-               int apply,
-               long irq_type)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-       unsigned char reg3;
-
-       config->irq_type = (unsigned char)irq_type;
-       if (irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x01;
-               reg2 = 0x01;
-               reg3 = 0x07;
-       } else if (irq_type == MPU_SLAVE_IRQ_TYPE_NONE) {
-               reg1 = 0x00;
-               reg2 = 0x00;
-               reg3 = 0x00;
-       } else {
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       }
-
-       if (apply) {
-               /* XYZ_DATA_CFG: event flag enabled on Z axis */
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       ACCEL_MMA8450_XYZ_DATA_CFG, reg3);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       ACCEL_MMA8450_CTRL_REG4, reg1);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       ACCEL_MMA8450_CTRL_REG5, reg2);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-
-       return result;
-}
-
-/**
- *  @brief Set the output data rate for the particular configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             Config to modify with new ODR.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param odr
- *             Output data rate in units of 1/1000Hz (mHz).
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_set_odr(void *mlsl_handle,
-               struct ext_slave_platform_data *pdata,
-               struct mma8450_config *config,
-               int apply,
-               long odr)
-{
-       unsigned char bits;
-       int result = INV_SUCCESS;
-
-       if (odr > 200000) {
-               config->odr = 400000;
-               bits = 0x00;
-       } else if (odr > 100000) {
-               config->odr = 200000;
-               bits = 0x04;
-       } else if (odr > 50000) {
-               config->odr = 100000;
-               bits = 0x08;
-       } else if (odr > 25000) {
-               config->odr = 50000;
-               bits = 0x0C;
-       } else if (odr > 12500) {
-               config->odr = 25000;
-               bits = 0x40; /* Sleep -> Auto wake mode */
-       } else if (odr > 1563) {
-               config->odr = 12500;
-               bits = 0x10;
-       } else if (odr > 0) {
-               config->odr = 1563;
-               bits = 0x14;
-       } else {
-               config->ctrl_reg1 = 0; /* Set FS1.FS2 to Standby */
-               config->odr = 0;
-               bits = 0;
-       }
-
-       config->ctrl_reg1 = bits | (config->ctrl_reg1 & 0x3);
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               ACCEL_MMA8450_CTRL_REG1, 0);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               ACCEL_MMA8450_CTRL_REG1, config->ctrl_reg1);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               MPL_LOGV("ODR: %d mHz, 0x%02x\n",
-                       config->odr, (int)config->ctrl_reg1);
-       }
-       return result;
-}
-
-/**
- *  @brief Set the full scale range of the accels
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             pointer to configuration.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param fsr
- *             requested full scale range.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_set_fsr(void *mlsl_handle,
-               struct ext_slave_platform_data *pdata,
-               struct mma8450_config *config,
-               int apply,
-               long fsr)
-{
-       unsigned char bits;
-       int result = INV_SUCCESS;
-
-       if (fsr <= 2000) {
-               bits = 0x01;
-               config->fsr = 2000;
-       } else if (fsr <= 4000) {
-               bits = 0x02;
-               config->fsr = 4000;
-       } else {
-               bits = 0x03;
-               config->fsr = 8000;
-       }
-
-       config->ctrl_reg1 = bits | (config->ctrl_reg1 & 0xFC);
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               ACCEL_MMA8450_CTRL_REG1, config->ctrl_reg1);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               MPL_LOGV("FSR: %d mg\n", config->fsr);
-       }
-       return result;
-}
-
-/**
- *  @brief suspends the device to put it in its lowest power mode.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_suspend(void *mlsl_handle,
-                   struct ext_slave_descr *slave,
-                   struct ext_slave_platform_data *pdata)
-{
-       int result;
-       struct mma8450_private_data *private_data = pdata->private_data;
-
-       if (private_data->suspend.fsr == 4000)
-               slave->range.mantissa = 4;
-       else if (private_data->suspend.fsr == 8000)
-               slave->range.mantissa = 8;
-       else
-               slave->range.mantissa = 2;
-       slave->range.fraction = 0;
-
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       ACCEL_MMA8450_CTRL_REG1, 0);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       if (private_data->suspend.ctrl_reg1) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               ACCEL_MMA8450_CTRL_REG1,
-                               private_data->suspend.ctrl_reg1);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-
-       result = mma8450_set_irq(mlsl_handle, pdata,
-                               &private_data->suspend,
-                               true, private_data->suspend.irq_type);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       return result;
-}
-
-/**
- *  @brief resume the device in the proper power state given the configuration
- *         chosen.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_resume(void *mlsl_handle,
-                  struct ext_slave_descr *slave,
-                  struct ext_slave_platform_data *pdata)
-{
-       int result = INV_SUCCESS;
-       struct mma8450_private_data *private_data = pdata->private_data;
-
-       /* Full Scale */
-       if (private_data->resume.fsr == 4000)
-               slave->range.mantissa = 4;
-       else if (private_data->resume.fsr == 8000)
-               slave->range.mantissa = 8;
-       else
-               slave->range.mantissa = 2;
-       slave->range.fraction = 0;
-
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       result = inv_serial_single_write(mlsl_handle, pdata->address,
-                       ACCEL_MMA8450_CTRL_REG1, 0);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       if (private_data->resume.ctrl_reg1) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               ACCEL_MMA8450_CTRL_REG1,
-                               private_data->resume.ctrl_reg1);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-       result = mma8450_set_irq(mlsl_handle, pdata,
-                       &private_data->resume,
-                       true, private_data->resume.irq_type);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-
-       return result;
-}
-
-/**
- *  @brief read the sensor data from the device.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a buffer to store the data read.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_read(void *mlsl_handle,
-                struct ext_slave_descr *slave,
-                struct ext_slave_platform_data *pdata, unsigned char *data)
-{
-       int result;
-       unsigned char local_data[4];    /* Status register + 3 bytes data */
-       result = inv_serial_read(mlsl_handle, pdata->address,
-                               0x00, sizeof(local_data), local_data);
-       if (result) {
-               LOG_RESULT_LOCATION(result);
-               return result;
-       }
-       memcpy(data, &local_data[1], (slave->read_len) - 1);
-
-       MPL_LOGV("Data Not Ready: %02x %02x %02x %02x\n",
-                local_data[0], local_data[1],
-                local_data[2], local_data[3]);
-
-       return result;
-}
-
-/**
- *  @brief one-time device driver initialization function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is loaded in the kernel.
- *         If the driver is built-in in the kernel, this function will be
- *         called at boot time.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_init(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       struct mma8450_private_data *private_data;
-       private_data = (struct mma8450_private_data *)
-           kzalloc(sizeof(struct mma8450_private_data), GFP_KERNEL);
-
-       if (!private_data)
-               return INV_ERROR_MEMORY_EXAUSTED;
-
-       pdata->private_data = private_data;
-
-       mma8450_set_odr(mlsl_handle, pdata, &private_data->suspend,
-                       false, 0);
-       mma8450_set_odr(mlsl_handle, pdata, &private_data->resume,
-                       false, 200000);
-       mma8450_set_fsr(mlsl_handle, pdata, &private_data->suspend,
-                       false, 2000);
-       mma8450_set_fsr(mlsl_handle, pdata, &private_data->resume,
-                       false, 2000);
-       mma8450_set_irq(mlsl_handle, pdata, &private_data->suspend,
-                       false,
-                       MPU_SLAVE_IRQ_TYPE_NONE);
-       mma8450_set_irq(mlsl_handle, pdata, &private_data->resume,
-                       false,
-                       MPU_SLAVE_IRQ_TYPE_NONE);
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief one-time device driver exit function.
- *         If the driver is built as a kernel module, this function will be
- *         called when the module is removed from the kernel.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_exit(void *mlsl_handle,
-                         struct ext_slave_descr *slave,
-                         struct ext_slave_platform_data *pdata)
-{
-       kfree(pdata->private_data);
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief device configuration facility.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to the configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_config(void *mlsl_handle,
-                       struct ext_slave_descr *slave,
-                       struct ext_slave_platform_data *pdata,
-                       struct ext_slave_config *data)
-{
-       struct mma8450_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               return mma8450_set_odr(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               return mma8450_set_odr(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               return mma8450_set_fsr(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               return mma8450_set_fsr(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               return mma8450_set_ths(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               return mma8450_set_ths(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               return mma8450_set_dur(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               return mma8450_set_dur(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               return mma8450_set_irq(mlsl_handle, pdata,
-                                       &private_data->suspend,
-                                       data->apply,
-                                       *((long *)data->data));
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               return mma8450_set_irq(mlsl_handle, pdata,
-                                       &private_data->resume,
-                                       data->apply,
-                                       *((long *)data->data));
-       default:
-               LOG_RESULT_LOCATION(INV_ERROR_FEATURE_NOT_IMPLEMENTED);
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-/**
- *  @brief facility to retrieve the device configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param slave
- *             a pointer to the slave descriptor data structure.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param data
- *             a pointer to store the returned configuration data structure.
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma8450_get_config(void *mlsl_handle,
-                               struct ext_slave_descr *slave,
-                               struct ext_slave_platform_data *pdata,
-                               struct ext_slave_config *data)
-{
-       struct mma8450_private_data *private_data = pdata->private_data;
-       if (!data->data)
-               return INV_ERROR_INVALID_PARAMETER;
-
-       switch (data->key) {
-       case MPU_SLAVE_CONFIG_ODR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.odr;
-               break;
-       case MPU_SLAVE_CONFIG_ODR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.odr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_FSR_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.fsr;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_THS:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.ths;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_THS:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.ths;
-               break;
-       case MPU_SLAVE_CONFIG_MOT_DUR:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.dur;
-               break;
-       case MPU_SLAVE_CONFIG_NMOT_DUR:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.dur;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_SUSPEND:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->suspend.irq_type;
-               break;
-       case MPU_SLAVE_CONFIG_IRQ_RESUME:
-               (*(unsigned long *)data->data) =
-                       (unsigned long) private_data->resume.irq_type;
-               break;
-       default:
-               LOG_RESULT_LOCATION(INV_ERROR_FEATURE_NOT_IMPLEMENTED);
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       };
-
-       return INV_SUCCESS;
-}
-
-static struct ext_slave_descr mma8450_descr = {
-       .init             = mma8450_init,
-       .exit             = mma8450_exit,
-       .suspend          = mma8450_suspend,
-       .resume           = mma8450_resume,
-       .read             = mma8450_read,
-       .config           = mma8450_config,
-       .get_config       = mma8450_get_config,
-       .name             = "mma8450",
-       .type             = EXT_SLAVE_TYPE_ACCEL,
-       .id               = ACCEL_ID_MMA8450,
-       .read_reg         = 0x00,
-       .read_len         = 4,
-       .endian           = EXT_SLAVE_FS8_BIG_ENDIAN,
-       .range            = {2, 0},
-       .trigger          = NULL,
-};
-
-static
-struct ext_slave_descr *mma8450_get_slave_descr(void)
-{
-       return &mma8450_descr;
-}
-
-/* -------------------------------------------------------------------------- */
-struct mma8450_mod_private_data {
-       struct i2c_client *client;
-       struct ext_slave_platform_data *pdata;
-};
-
-static unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-static int mma8450_mod_probe(struct i2c_client *client,
-                          const struct i2c_device_id *devid)
-{
-       struct ext_slave_platform_data *pdata;
-       struct mma8450_mod_private_data *private_data;
-       int result = 0;
-
-       dev_info(&client->adapter->dev, "%s: %s\n", __func__, devid->name);
-
-       if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               result = -ENODEV;
-               goto out_no_free;
-       }
-
-       pdata = client->dev.platform_data;
-       if (!pdata) {
-               dev_err(&client->adapter->dev,
-                       "Missing platform data for slave %s\n", devid->name);
-               result = -EFAULT;
-               goto out_no_free;
-       }
-
-       private_data = kzalloc(sizeof(*private_data), GFP_KERNEL);
-       if (!private_data) {
-               result = -ENOMEM;
-               goto out_no_free;
-       }
-
-       i2c_set_clientdata(client, private_data);
-       private_data->client = client;
-       private_data->pdata = pdata;
-
-       result = inv_mpu_register_slave(THIS_MODULE, client, pdata,
-                                       mma8450_get_slave_descr);
-       if (result) {
-               dev_err(&client->adapter->dev,
-                       "Slave registration failed: %s, %d\n",
-                       devid->name, result);
-               goto out_free_memory;
-       }
-
-       return result;
-
-out_free_memory:
-       kfree(private_data);
-out_no_free:
-       dev_err(&client->adapter->dev, "%s failed %d\n", __func__, result);
-       return result;
-
-}
-
-static int mma8450_mod_remove(struct i2c_client *client)
-{
-       struct mma8450_mod_private_data *private_data =
-               i2c_get_clientdata(client);
-
-       dev_dbg(&client->adapter->dev, "%s\n", __func__);
-
-       inv_mpu_unregister_slave(client, private_data->pdata,
-                               mma8450_get_slave_descr);
-
-       kfree(private_data);
-       return 0;
-}
-
-static const struct i2c_device_id mma8450_mod_id[] = {
-       { "mma8450", ACCEL_ID_MMA8450 },
-       {}
-};
-
-MODULE_DEVICE_TABLE(i2c, mma8450_mod_id);
-
-static struct i2c_driver mma8450_mod_driver = {
-       .class = I2C_CLASS_HWMON,
-       .probe = mma8450_mod_probe,
-       .remove = mma8450_mod_remove,
-       .id_table = mma8450_mod_id,
-       .driver = {
-                  .owner = THIS_MODULE,
-                  .name = "mma8450_mod",
-                  },
-       .address_list = normal_i2c,
-};
-
-static int __init mma8450_mod_init(void)
-{
-       int res = i2c_add_driver(&mma8450_mod_driver);
-       pr_info("%s: Probe name %s\n", __func__, "mma8450_mod");
-       if (res)
-               pr_err("%s failed\n", __func__);
-       return res;
-}
-
-static void __exit mma8450_mod_exit(void)
-{
-       pr_info("%s\n", __func__);
-       i2c_del_driver(&mma8450_mod_driver);
-}
-
-module_init(mma8450_mod_init);
-module_exit(mma8450_mod_exit);
-
-MODULE_AUTHOR("Invensense Corporation");
-MODULE_DESCRIPTION("Driver to integrate MMA8450 sensor with the MPU");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("mma8450_mod");
-
-/**
- *  @}
- */
diff --git a/drivers/misc/inv_mpu/accel/mma845x.c b/drivers/misc/inv_mpu/accel/mma845x.c
deleted file mode 100644 (file)
index 5f62b22..0000000
+++ /dev/null
@@ -1,713 +0,0 @@
-/*
-       $License:
-       Copyright (C) 2011 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 ACCELDL
- *  @brief      Provides the interface to setup and handle an accelerometer.
- *
- *  @{
- *      @file   mma845x.c
- *      @brief  Accelerometer setup and handling methods for Freescale MMA845X
- */
-
-/* -------------------------------------------------------------------------- */
-
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "mpu-dev.h"
-
-#include <log.h>
-#include <linux/mpu.h>
-#include "mlsl.h"
-#include "mldl_cfg.h"
-#undef MPL_LOG_TAG
-#define MPL_LOG_TAG "MPL-acc"
-
-#define ACCEL_MMA845X_XYZ_DATA_CFG     (0x0E)
-#define ACCEL_MMA845X_CTRL_REG1      (0x2A)
-#define ACCEL_MMA845X_CTRL_REG4                (0x2D)
-#define ACCEL_MMA845X_CTRL_REG5                (0x2E)
-
-#define ACCEL_MMA845X_SLEEP_MASK     (0x01)
-
-/* full scale setting - register & mask */
-#define ACCEL_MMA845X_CFG_REG       (0x0E)
-#define ACCEL_MMA845X_CTRL_MASK     (0x03)
-
-/* -------------------------------------------------------------------------- */
-
-struct mma845x_config {
-       unsigned int odr;
-       unsigned int fsr;               /** < full scale range mg */
-       unsigned int ths;               /** < Motion no-motion thseshold mg */
-       unsigned int dur;               /** < Motion no-motion duration ms */
-       unsigned char reg_ths;
-       unsigned char reg_dur;
-       unsigned char ctrl_reg1;
-       unsigned char irq_type;
-       unsigned char mot_int1_cfg;
-};
-
-struct mma845x_private_data {
-       struct mma845x_config suspend;
-       struct mma845x_config resume;
-};
-
-/* -------------------------------------------------------------------------- */
-
-static int mma845x_set_ths(void *mlsl_handle,
-               struct ext_slave_platform_data *pdata,
-               struct mma845x_config *config,
-               int apply,
-               long ths)
-{
-       return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-}
-
-static int mma845x_set_dur(void *mlsl_handle,
-               struct ext_slave_platform_data *pdata,
-               struct mma845x_config *config,
-               int apply,
-               long dur)
-{
-       return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-}
-
-/**
- *  @brief Sets the IRQ to fire when one of the IRQ events occur.
- *         Threshold and duration will not be used unless the type is MOT or
- *         NMOT.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *              configuration to apply to, suspend or resume
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param irq_type
- *              the type of IRQ.  Valid values are
- *              - MPU_SLAVE_IRQ_TYPE_NONE
- *              - MPU_SLAVE_IRQ_TYPE_MOTION
- *              - MPU_SLAVE_IRQ_TYPE_DATA_READY
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma845x_set_irq(void *mlsl_handle,
-               struct ext_slave_platform_data *pdata,
-               struct mma845x_config *config,
-               int apply,
-               long irq_type)
-{
-       int result = INV_SUCCESS;
-       unsigned char reg1;
-       unsigned char reg2;
-
-       config->irq_type = (unsigned char)irq_type;
-       if (irq_type == MPU_SLAVE_IRQ_TYPE_DATA_READY) {
-               reg1 = 0x01;
-               reg2 = 0x01;
-       } else if (irq_type == MPU_SLAVE_IRQ_TYPE_NONE) {
-               reg1 = 0x00;
-               reg2 = 0x00;
-       } else {
-               return INV_ERROR_FEATURE_NOT_IMPLEMENTED;
-       }
-
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       ACCEL_MMA845X_CTRL_REG4, reg1);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                                       ACCEL_MMA845X_CTRL_REG5, reg2);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-       }
-
-       return result;
-}
-
-/**
- *  @brief Set the output data rate for the particular configuration.
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             Config to modify with new ODR.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *             at the next resume.
- *  @param odr
- *             Output data rate in units of 1/1000Hz (mHz).
- *
- *  @return INV_SUCCESS if successful or a non-zero error code.
- */
-static int mma845x_set_odr(void *mlsl_handle,
-                       struct ext_slave_platform_data *pdata,
-                       struct mma845x_config *config,
-                       int apply,
-                       long odr)
-{
-       unsigned char bits;
-       int result = INV_SUCCESS;
-
-       if (odr > 400000) {
-               config->odr = 800000;
-               bits = 0x01;
-       } else if (odr > 200000) {
-               config->odr = 400000;
-               bits = 0x09;
-       } else if (odr > 100000) {
-               config->odr = 200000;
-               bits = 0x11;
-       } else if (odr > 50000) {
-               config->odr = 100000;
-               bits = 0x19;
-       } else if (odr > 12500) {
-               config->odr = 50000;
-               bits = 0x21;
-       } else if (odr > 6250) {
-               config->odr = 12500;
-               bits = 0x29;
-       } else if (odr > 1560) {
-               config->odr = 6250;
-               bits = 0x31;
-       } else if (odr > 0) {
-               config->odr = 1560;
-               bits = 0x39;
-       } else {
-               config->ctrl_reg1 = 0; /* Set FS1.FS2 to Standby */
-               config->odr = 0;
-               bits = 0;
-       }
-
-       config->ctrl_reg1 = bits;
-       if (apply) {
-               result = inv_serial_single_write(mlsl_handle, pdata->address,
-                               ACCEL_MMA845X_CTRL_REG1,
-                               config->ctrl_reg1);
-               if (result) {
-                       LOG_RESULT_LOCATION(result);
-                       return result;
-               }
-               MPL_LOGV("ODR: %d mHz, 0x%02x\n", config->odr,
-                        (int)config->ctrl_reg1);
-       }
-       return result;
-}
-
-/**
- *  @brief Set the full scale range of the accels
- *
- *  @param mlsl_handle
- *             the handle to the serial channel the device is connected to.
- *  @param pdata
- *             a pointer to the slave platform data.
- *  @param config
- *             pointer to configuration.
- *  @param apply
- *             whether to apply immediately or save the settings to be applied
- *