From c2d4340aa561998b4afc87cd935c22f2c1b113f4 Mon Sep 17 00:00:00 2001 From: Wen Yi Date: Fri, 28 Jan 2011 14:38:45 -0800 Subject: Port Invensense MPU3050 drivers into tegra-2.6.36 Original-Change-Id: Iceb3ef8b11d4ce18fd3cb0947268744775b81758 Reviewed-on: http://git-master/r/17525 Reviewed-by: Daniel Willemsen Reviewed-by: Varun Colbert Tested-by: Varun Colbert Rebase-Id: R5aa1acdb6de5265529a9695f6cc996d4cf0dbfec --- include/linux/mpu3050.h | 408 ++++-------------------------------------------- 1 file changed, 27 insertions(+), 381 deletions(-) mode change 100755 => 100644 include/linux/mpu3050.h (limited to 'include/linux/mpu3050.h') diff --git a/include/linux/mpu3050.h b/include/linux/mpu3050.h old mode 100755 new mode 100644 index 9c8ddc2ad0af..a8dcd5a9473f --- a/include/linux/mpu3050.h +++ b/include/linux/mpu3050.h @@ -1,35 +1,21 @@ /* - $License: - Copyright (C) 2010 InvenSense Corporation, All Rights Reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - $ + $License: + Copyright (C) 2010 InvenSense Corporation, All Rights Reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + $ */ -/****************************************************************************** - * - * $Id: mpu3050.h 3868 2010-10-09 01:22:37Z dsrivastava $ - * - ******************************************************************************/ - -/** - * @defgroup - * @brief - * - * @{ - * @file mpu3050.h - * @brief -**/ #ifndef __MPU3050_H_ #define __MPU3050_H_ @@ -38,8 +24,11 @@ #include #endif -typedef void *mlsl_handle_t; +#ifdef M_HW +#error MPU6000 build including MPU3050 header +#endif +#define MPU_NAME "mpu3050" #define DEFAULT_MPU_SLAVEADDR 0x68 /*==== MPU REGISTER SET ====*/ @@ -68,7 +57,7 @@ enum mpu_register { MPUREG_SMPLRT_DIV, /* 21 0x15 */ MPUREG_DLPF_FS_SYNC, /* 22 0x16 */ MPUREG_INT_CFG, /* 23 0x17 */ - MPUREG_ACCEL_BURST_ADDR, /* 24 0x18 */ + MPUREG_ACCEL_BURST_ADDR,/* 24 0x18 */ MPUREG_19_RSVD, /* 25 0x19 */ MPUREG_INT_STATUS, /* 26 0x1a */ MPUREG_TEMP_OUT_H, /* 27 0x1b */ @@ -165,7 +154,7 @@ enum mpu_register { #define BIT_DMP_INT_EN 0x02 #define BIT_RAW_RDY_EN 0x01 /*---- MPU 'INT_STATUS' register (1A) ----*/ -#define BIT_INT_STATUS_FIFO_OVERLOW (0x80) +#define BIT_INT_STATUS_FIFO_OVERLOW 0x80 #define BIT_MPU_RDY 0x04 #define BIT_DMP_INT 0x02 #define BIT_RAW_RDY 0x01 @@ -197,10 +186,10 @@ enum mpu_register { #define MPU_SILICON_REV_B6 4 /* MPU B6 Device */ /*---- MPU Memory ----*/ -#define MPU_MEM_BANK_SIZE 256 -#define FIFO_HW_SIZE (512) /* FIFO hw is 512 bytes */ +#define MPU_MEM_BANK_SIZE (256) +#define FIFO_HW_SIZE (512) -typedef enum { +enum MPU_MEMORY_BANKS { MPU_MEM_RAM_BANK_0 = 0, MPU_MEM_RAM_BANK_1, MPU_MEM_RAM_BANK_2, @@ -209,7 +198,7 @@ typedef enum { MPU_MEM_OTP_BANK_0 = MPU_MEM_NUM_RAM_BANKS, /* This one is always last */ MPU_MEM_NUM_BANKS -} tMPUMemoryBanks, MPU_MEMORY_BANKS; +}; #define MPU_NUM_AXES (3) @@ -261,349 +250,6 @@ enum mpu_ext_sync { }; #define DLPF_FS_SYNC_VALUE(ext_sync, full_scale, lpf) \ - ((ext_sync << 5) | (full_scale << 3) | lpf) - -/* IOCTL commands for /dev/mpu */ -#define MPU_SET_MPU_CONFIG (0x00) -#define MPU_SET_INT_CONFIG (0x01) -#define MPU_SET_EXT_SYNC (0x02) -#define MPU_SET_FULL_SCALE (0x03) -#define MPU_SET_LPF (0x04) -#define MPU_SET_CLK_SRC (0x05) -#define MPU_SET_DIVIDER (0x06) -#define MPU_SET_LEVEL_SHIFTER (0x07) -#define MPU_SET_DMP_ENABLE (0x08) -#define MPU_SET_FIFO_ENABLE (0x09) -#define MPU_SET_DMP_CFG1 (0x0a) -#define MPU_SET_DMP_CFG2 (0x0b) -#define MPU_SET_OFFSET_TC (0x0c) -#define MPU_SET_RAM (0x0d) - -#define MPU_SET_PLATFORM_DATA (0x0e) - -#define MPU_GET_MPU_CONFIG (0x80) -#define MPU_GET_INT_CONFIG (0x81) -#define MPU_GET_EXT_SYNC (0x82) -#define MPU_GET_FULL_SCALE (0x83) -#define MPU_GET_LPF (0x84) -#define MPU_GET_CLK_SRC (0x85) -#define MPU_GET_DIVIDER (0x86) -#define MPU_GET_LEVEL_SHIFTER (0x87) -#define MPU_GET_DMP_ENABLE (0x88) -#define MPU_GET_FIFO_ENABLE (0x89) -#define MPU_GET_DMP_CFG1 (0x8a) -#define MPU_GET_DMP_CFG2 (0x8b) -#define MPU_GET_OFFSET_TC (0x8c) -#define MPU_GET_RAM (0x8d) - -#define MPU_READ_REGISTER (0x40) -#define MPU_WRITE_REGISTER (0x41) -#define MPU_READ_MEMORY (0x42) -#define MPU_WRITE_MEMORY (0x43) - -#define MPU_SUSPEND (0x44) -#define MPU_RESUME (0x45) -#define MPU_READ_COMPASS (0x46) -#define MPU_READ_ACCEL (0x47) - -/* Structure for the following IOCTL's: - MPU_SET_RAM - MPU_GET_RAM - MPU_READ_REGISTER - MPU_WRITE_REGISTER - MPU_READ_MEMORY - MPU_WRITE_MEMORY -*/ -struct mpu_read_write { - unsigned short address; - unsigned short length; - unsigned char *data; -}; - -/* Structure for the following IOCTL's - MPU_SUSPEND - MPU_RESUME -*/ -struct mpu_suspend_resume { - int gyro; - int accel; - int compass; -}; - -enum ext_slave_type { - EXT_SLAVE_TYPE_GYROSCOPE, - EXT_SLAVE_TYPE_ACCELEROMETER, - EXT_SLAVE_TYPE_COMPASS, - /* EXT_SLAVE_TYPE_PRESSURE, */ - /* EXT_SLAVE_TYPE_TEMPERATURE */ -}; - -enum ext_slave_id { - ID_INVALID = 0, - - ACCEL_ID_LIS331, - ACCEL_ID_LSM303, - ACCEL_ID_KXSD9, - ACCEL_ID_KXTF9, - ACCEL_ID_BMA150, - ACCEL_ID_BMA222, - ACCEL_ID_ADI346, - ACCEL_ID_MMA8450, - ACCEL_ID_MMA8451, - - COMPASS_ID_AKM, - COMPASS_ID_AICHI, - COMPASS_ID_YAS529, - COMPASS_ID_HMC5883, - COMPASS_ID_LSM303, - COMPASS_ID_MMC314X, -}; - -enum ext_slave_endian { - EXT_SLAVE_BIG_ENDIAN, - EXT_SLAVE_LITTLE_ENDIAN, - EXT_SLAVE_FS8_BIG_ENDIAN, - EXT_SLAVE_FS16_BIG_ENDIAN, -}; - -enum ext_slave_bus { - EXT_SLAVE_BUS_PRIMARY, - EXT_SLAVE_BUS_SECONDARY, -}; - -/** - * struct ext_slave_platform_data - Platform data for mpu3050 slave devices - * - * @get_slave_descr: Function pointer to retrieve the struct ext_slave_descr - * for this slave - * @adapt_num: the I2C adapter number. - * @bus: the bus the slave is attached to: enum ext_slave_bus - * @address: the I2C slave address of the slave device. - * @orientation: the mounting matrix of the device relative to MPU. - * @private_data: additional data, user customizable. Not touched by the MPU - * driver. - * - * The orientation matricies are 3x3 rotation matricies - * that are applied to the data to rotate from the mounting orientation to the - * platform orientation. The values must be one of 0, 1, or -1 and each row and - * column should have exactly 1 non-zero value. - * - * @code - * struct ext_slave_platform_data { - * struct ext_slave_descr* (*get_slave_descr) (void); - * int adapt_num; - * int bus; - * unsigned char address; - * signed char orientation[9]; - * void *private_data; - * }; - * @endcode - */ -struct ext_slave_platform_data { - struct ext_slave_descr *(*get_slave_descr) (void); - int adapt_num; - int bus; - unsigned char address; - signed char orientation[9]; - void *private_data; -}; - -struct tFixPntRange { - long mantissa; - long fraction; -}; - -/** - * struct ext_slave_descr - Description of the slave device for programming - * - * @suspend: function pointer to put the device in suspended state - * @resume: function pointer to put the device in running state - * @read: function that reads the device data - * - * @name: text name of the device - * @type: device type. enum ext_slave_type - * @id: enum ext_slave_id - * @reg: starting register address to retrieve data. - * @len: length in bytes of the sensor data. Should be 6. - * @endian: byte order of the data. enum ext_slave_endian - * @range: full scale range of the slave ouput: struct tFixPntRange - * - * Defines the functions and information about the slave the mpu3050 needs to - * use the slave device. - * - * @code - * struct ext_slave_descr { - * int (*suspend) (mlsl_handle_t mlsl_handle, - * struct ext_slave_descr *slave, - * struct ext_slave_platform_data *pdata); - * int (*resume) (mlsl_handle_t mlsl_handle, - * struct ext_slave_descr *slave, - * struct ext_slave_platform_data *pdata); - * int (*read) (mlsl_handle_t mlsl_handle, - * struct ext_slave_descr *slave, - * struct ext_slave_platform_data *pdata, - * unsigned char * data); - * - * unsigned char type; - * unsigned char id; - * unsigned char reg; - * unsigned int len; - * unsigned char endian; - * struct tFixPntRange range; - * }; - * @endcode - */ -struct ext_slave_descr { - int (*suspend) (mlsl_handle_t mlsl_handle, - struct ext_slave_descr *slave, - struct ext_slave_platform_data *pdata); - int (*resume) (mlsl_handle_t mlsl_handle, - struct ext_slave_descr *slave, - struct ext_slave_platform_data *pdata); - int (*read) (mlsl_handle_t mlsl_handle, - struct ext_slave_descr *slave, - struct ext_slave_platform_data *pdata, - unsigned char *data); - - char *name; - unsigned char type; - unsigned char id; - unsigned char reg; - unsigned int len; - unsigned char endian; - struct tFixPntRange range; -}; - -/** - * struct mpu3050_platform_data - Platform data for the mpu3050 driver - * @int_config: Bits [7:3] of the int config register. - * @orientation: Orientation matrix of the gyroscope - * @level_shifter: 0: VLogic 1: VDD - * @accel: Accel platform data - * @compass: Compass platform data - * - * Contains platform specific information on how to configure the MPU3050 to - * work on this platform. The orientation matricies are 3x3 rotation matricies - * that are applied to the data to rotate from the mounting orientation to the - * platform orientation. The values must be one of 0, 1, or -1 and each row and - * column should have exactly 1 non-zero value. - * - * @code - * struct mpu3050_platform_data { - * unsigned char int_config; - * signed char orientation[MPU_NUM_AXES*MPU_NUM_AXES]; - * unsigned char level_shifter; - * struct ext_slave_platform_data accel; - * struct ext_slave_platform_data compass; - * }; - * @endcode - */ -struct mpu3050_platform_data { - unsigned char int_config; - signed char orientation[MPU_NUM_AXES * MPU_NUM_AXES]; - unsigned char level_shifter; - struct ext_slave_platform_data accel; - struct ext_slave_platform_data compass; -}; - -/* - Accelerometer -*/ -#define get_accel_slave_descr NULL - -#ifdef CONFIG_SENSORS_ADXL346 /* ADI accelerometer */ -struct ext_slave_descr *adxl346_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr adxl346_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_BMA150 /* Bosch accelerometer */ -struct ext_slave_descr *bma150_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr bma150_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_BMA222 /* Bosch 222 accelerometer */ -struct ext_slave_descr *bma222_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr bma222_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_KXSD9 /* Kionix accelerometer */ -struct ext_slave_descr *kxsd9_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr kxsd9_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_KXTF9_MPU /* Kionix accelerometer */ -struct ext_slave_descr *kxtf9_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr kxtf9_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_LIS331DLH /* ST accelerometer */ -struct ext_slave_descr *lis331dlh_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr lis331dlh_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_LSM303DLHA /* ST accelerometer */ -struct ext_slave_descr *lsm303dlha_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr lsm303dlha_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_MMA8450 /* Freescale accelerometer */ -struct ext_slave_descr *mma8450_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr mma8450_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_MMA8451 /* Freescale accelerometer */ -struct ext_slave_descr *mma8451_get_slave_descr(void); -#undef get_accel_slave_descr -#define get_accel_slave_descr mma8451_get_slave_descr -#endif - -/* - Compass -*/ -#define get_compass_slave_descr NULL - -#ifdef CONFIG_SENSORS_AK8975_MPU /* AKM compass */ -struct ext_slave_descr *ak8975_get_slave_descr(void); -#undef get_compass_slave_descr -#define get_compass_slave_descr ak8975_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_AMI304 /* AICHI Steel compass */ -struct ext_slave_descr *ami304_get_slave_descr(void); -#undef get_compass_slave_descr -#define get_compass_slave_descr ami304_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_HMC5883 /* Honeywell compass */ -struct ext_slave_descr *hmc5883_get_slave_descr(void); -#undef get_compass_slave_descr -#define get_compass_slave_descr hmc5883_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_MMC314X /* MEMSIC compass */ -struct ext_slave_descr *mmc314x_get_slave_descr(void); -#undef get_compass_slave_descr -#define get_compass_slave_descr mmc314x_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_LSM303DLHM /* ST compass */ -struct ext_slave_descr *lsm303dlhm_get_slave_descr(void); -#undef get_compass_slave_descr -#define get_compass_slave_descr lsm303dlhm_get_slave_descr -#endif - -#ifdef CONFIG_SENSORS_YAS529 /* Yamaha compass */ -struct ext_slave_descr *yas529_get_slave_descr(void); -#undef get_compass_slave_descr -#define get_compass_slave_descr yas529_get_slave_descr -#endif + ((ext_sync << 5) | (full_scale << 3) | lpf) #endif /* __MPU3050_H_ */ -- cgit v1.2.3