Index: linux-2.6.35/drivers/misc/mpu3050/Makefile =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.35/drivers/misc/mpu3050/Makefile 2010-12-24 11:05:24.000000000 +0800 @@ -0,0 +1,112 @@ + +# Kernel makefile for motions sensors +# +# + +# MPU +obj-$(CONFIG_SENSORS_MPU3050) += mpu3050.o +mpu3050-objs += mpuirq.o \ + mpu-sysfs.o \ + mpu-dev.o \ + mpu-i2c.o \ + mlsl-kernel.o \ + $(MLLITE_DIR)mldl_cfg.o + +# +# Accel options +# +ifdef CONFIG_SENSORS_ADXL346 +mpu3050-objs += $(MLLITE_DIR)accel/adxl346.o +endif + +ifdef CONFIG_SENSORS_BMA023 +mpu3050-objs += $(MLLITE_DIR)accel/bma023.o +endif + +ifdef CONFIG_SENSORS_BMA150 +mpu3050-objs += $(MLLITE_DIR)accel/bma150.o +endif + +ifdef CONFIG_SENSORS_BMA222 +mpu3050-objs += $(MLLITE_DIR)accel/bma222.o +endif + +ifdef CONFIG_SENSORS_KXSD9 +mpu3050-objs += $(MLLITE_DIR)accel/kxsd9.o +endif + +ifdef CONFIG_SENSORS_KXTF9 +mpu3050-objs += $(MLLITE_DIR)accel/kxtf9.o +endif + +ifdef CONFIG_SENSORS_LIS331DLH +mpu3050-objs += $(MLLITE_DIR)accel/lis331.o +endif + +ifdef CONFIG_SENSORS_LSM303DLHA +mpu3050-objs += $(MLLITE_DIR)accel/lsm303a.o +endif + +ifdef CONFIG_SENSORS_MMA8450 +mpu3050-objs += $(MLLITE_DIR)accel/mma8450.o +endif + +ifdef CONFIG_SENSORS_MMA8451 +mpu3050-objs += $(MLLITE_DIR)accel/mma8451.o +endif + +# +# Compass options +# +ifdef CONFIG_SENSORS_AK8975 +mpu3050-objs += $(MLLITE_DIR)compass/ak8975.o +endif + +ifdef CONFIG_SENSORS_AMI304 +mpu3050-objs += $(MLLITE_DIR)compass/ami304.o +endif + +ifdef CONFIG_SENSORS_HMC5883 +mpu3050-objs += $(MLLITE_DIR)compass/hmc5883.o +endif + +ifdef CONFIG_SENSORS_LSM303DLHM +mpu3050-objs += $(MLLITE_DIR)compass/lsm303m.o +endif + +ifdef CONFIG_SENSORS_MMC314X +mpu3050-objs += $(MLLITE_DIR)compass/mmc314x.o +endif + +ifdef CONFIG_SENSORS_YAS529 +mpu3050-objs += $(MLLITE_DIR)compass/yas529-kernel.o +endif + +ifdef CONFIG_SENSORS_HSCDTD002B +mpu3050-objs += $(MLLITE_DIR)compass/hscdtd002b.o +endif + +EXTRA_CFLAGS += -I$(M)/$(MLLITE_DIR) \ + -I$(M)/../../include \ + -Idrivers/misc/mpu3050 \ + -Iinclude/linux + +ifdef CONFIG_SENSORS_MPU_DEBUG +EXTRA_CFLAGS += -DDEBUG +endif + +obj-$(CONFIG_SENSORS_MPU6000)= mpu6000.o +mpu6000-objs += mpuirq.o \ + mpu-dev.o \ + mpu-i2c.o \ + mlsl-kernel.o \ + $(MLLITE_DIR)mldl_cfg.o \ + $(MLLITE_DIR)accel/mantis.o + +ifdef CONFIG_SENSORS_AK8975 +mpu6000-objs += $(MLLITE_DIR)compass/ak8975.o +endif + +ifdef CONFIG_SENSORS_MPU6000 +EXTRA_CFLAGS += -DM_HW +endif Index: linux-2.6.35/drivers/misc/Makefile =================================================================== --- linux-2.6.35.orig/drivers/misc/Makefile 2010-12-24 10:19:07.000000000 +0800 +++ linux-2.6.35/drivers/misc/Makefile 2010-12-24 10:19:21.000000000 +0800 @@ -46,3 +46,7 @@ obj-y += ti-st/ obj-$(CONFIG_CMT) += cmt/ + +obj-y += mpu3050/ + + Index: linux-2.6.35/drivers/misc/Kconfig =================================================================== --- linux-2.6.35.orig/drivers/misc/Kconfig 2010-12-24 10:19:07.000000000 +0800 +++ linux-2.6.35/drivers/misc/Kconfig 2010-12-24 10:19:21.000000000 +0800 @@ -459,5 +459,6 @@ source "drivers/misc/cb710/Kconfig" source "drivers/misc/iwmc3200top/Kconfig" source "drivers/misc/ti-st/Kconfig" +source "drivers/misc/mpu3050/Kconfig" endif # MISC_DEVICES Index: linux-2.6.35/drivers/misc/mpu3050/Kconfig =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.35/drivers/misc/mpu3050/Kconfig 2010-12-24 10:19:08.000000000 +0800 @@ -0,0 +1,175 @@ + +menu "Motion Sensors Support" + +choice + tristate "Motion Processing Unit" + depends on I2C + default SENSORS_MPU3050 + +config MPU_NONE + bool "None" + help + This disables support for motion processing using the MPU family of + motion processing units. + +config SENSORS_MPU3050 + tristate "MPU3050" + depends on I2C + 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 SENSORS_MPU6000 + tristate "MPU6000" + depends on I2C + help + If you say yes here you get support for the MPU6000 Gyroscope driver + This driver can also be built as a module. If so, the module + will be called mpu6000. + +endchoice + +choice + prompt "Accelerometer Type" + depends on SENSORS_MPU3050 + default SENSORS_BMA023 + +config SENSORS_ACCELEROMETER_NONE + bool "NONE" + depends on SENSORS_MPU3050 || SENSORS_MPU6000 + help + This disables accelerometer support for the MPU3050 + +config SENSORS_ADXL346 + bool "ADI adxl346" + depends on SENSORS_MPU3050 + help + This enables support for the ADI adxl346 accelerometer + +config SENSORS_BMA023 + bool "Bosch BMA023" + depends on SENSORS_MPU3050 + help + This enables support for the Bosch BMA023 accelerometer + +config SENSORS_BMA150 + bool "Bosch BMA150" + depends on SENSORS_MPU3050 + help + This enables support for the Bosch BMA150 accelerometer + +config SENSORS_BMA222 + bool "Bosch BMA222" + depends on SENSORS_MPU3050 + help + This enables support for the Bosch BMA222 accelerometer + +config SENSORS_KXSD9 + bool "Kionix KXSD9" + depends on SENSORS_MPU3050 + help + This enables support for the Kionix KXSD9 accelerometer + +config SENSORS_KXTF9 + bool "Kionix KXTF9" + depends on SENSORS_MPU3050 + help + This enables support for the Kionix KXFT9 accelerometer + +config SENSORS_LIS331DLH + bool "ST lis331dlh" + depends on SENSORS_MPU3050 + help + This enables support for the ST lis331dlh accelerometer + +config SENSORS_LSM303DLHA + bool "ST lsm303dlh" + depends on SENSORS_MPU3050 + help + This enables support for the ST lsm303dlh accelerometer + +config SENSORS_MMA8450 + bool "Freescale mma8450" + depends on SENSORS_MPU3050 + help + This enables support for the Freescale mma8450 accelerometer + +config SENSORS_MMA8451 + bool "Freescale mma8451" + depends on SENSORS_MPU3050 + help + This enables support for the Freescale mma8451 accelerometer + +endchoice + +choice + prompt "Compass Type" + depends on SENSORS_MPU6000 || SENSORS_MPU3050 + default SENSORS_COMPASS_NONE + +config SENSORS_COMPASS_NONE + bool "NONE" + depends on SENSORS_MPU6000 || SENSORS_MPU3050 + help + This disables compass support for the MPU6000 + +config SENSORS_AK8975 + bool "AKM ak8975" + depends on SENSORS_MPU6000 || SENSORS_MPU3050 + help + This enables support for the AKM ak8975 compass + +config SENSORS_MMC314X + bool "MEMSIC mmc314x" + depends on SENSORS_MPU3050 + help + This enables support for the MEMSIC mmc314x compass + +config SENSORS_AMI304 + bool "Aichi Steel ami304" + depends on SENSORS_MPU3050 + help + This enables support for the Aichi Steel ami304 compass + +config SENSORS_HMC5883 + bool "Honeywell hmc5883" + depends on SENSORS_MPU3050 + help + This enables support for the Honeywell hmc5883 compass + +config SENSORS_LSM303DLHM + bool "ST lsm303dlh" + depends on SENSORS_MPU3050 + help + This enables support for the ST lsm303dlh compass + +config SENSORS_MMC314X + bool "MEMSIC mmc314xMS" + depends on SENSORS_MPU3050 + help + This enables support for the MEMSIC mmc314xMS compass + +config SENSORS_YAS529 + bool "Yamaha yas529" + depends on SENSORS_MPU3050 + help + This enables support for the Yamaha yas529 compass + +config SENSORS_HSCDTD002B + bool "Alps hscdtd002b" + depends on SENSORS_MPU3050 + help + This enables support for the Alps hscdtd002b compass + +endchoice + +config SENSORS_MPU_DEBUG + bool "MPU debug" + depends on SENSORS_MPU3050 || SENSORS_MPU6000 + help + If you say yes here you get extra debug messages from the MPU3050 + and other slave sensors. + +endmenu + Index: linux-2.6.35/drivers/misc/mpu3050/README =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.35/drivers/misc/mpu3050/README 2010-12-24 10:19:08.000000000 +0800 @@ -0,0 +1,192 @@ +Kernel driver mpu +===================== + +Supported chips: + * InvenSense IMU3050 + Prefix: 'mpu3050' + Datasheet: + PS-MPU-3000A-00.2.4b.pdf + + * InvenSense IMU6000 + Prefix: 'mpu6000' + Datasheet: + MPU-6000A-00 v1.0.pdf + +Author: InvenSense <http://invensense.com> + +Description +----------- +The mpu is a motion processor unit that controls the mpu3050 gyroscope, a slave +accelerometer and compass, or the mpu6000 and slave compass. This document +describes how to install the driver into a Linux kernel and a small note about +how to set up the file permissions in an android file system. + +Sysfs entries +------------- +/dev/mpu +/dev/mpuirq + +General Remarks MPU3050 +----------------------- +* Valid addresses for the MPU3050 is 0x68. +* Accelerometer must be on the secondary I2C bus for MPU3050 and the + magnetometer must be on the primary bus. + +General Remarks MPU6000 +----------------------- +* Valid addresses for the MPU6000 is 0x68. +* Magnetometer must be on the secondary I2C bus for the MPU6000. +* Accelerometer slave address must be set to 0x68 +* Gyro and Accel orientation matrices should be the same + +Programming the chip using /dev/mpu +---------------------------------- +Programming of MPU3050 or MPU6000 is done by first opening the /dev/mpu file and +then performing a series of IOCTLS on the handle returned. The IOCTL codes can +be found in mpu.h. Typically this is done by the mllite library in user +space. + +Adding to a Kernel +================== + +The mpu driver is designed to be inserted in the drivers/misc part of the +kernel. Extracting the tarball from the root kernel dir will place the +contents of the tarball here: + + <kernel root dir>/drivers/misc/mpu3050 + <kernel root dir>/include/linux/mpu.h + <kernel root dir>/include/linux/mpu3050.h + <kernel root dir>/include/linux/mpu6000.h + +After this is done the drivers/misc/Kconfig must be edited to add the line: + + source "drivers/misc/mpu3050/Kconfig" + +Similarly drivers/misc/Makefile must be edited to add the line: + + obj-y += mpu3050/ + +Configuration can then be done as normal. + +Board and Platform Data +----------------------- + +In order for the driver to work, board and platform data specific to the device +needs to be added to the board file. A mpu3050_platform_data structure must +be created and populated and set in the i2c_board_info_structure. For details of +each structure member see mpu.h. All values below are simply an example and +should be modified for your platform. + +#include <linux/mpu.h> + +#if defined(CONFIG_SENSORS_MPU3050) || defined(CONFIG_SENSORS_MPU3050_MODULE) + +#define SENSOR_MPU_NAME "mpu3050" + +static struct mpu3050_platform_data mpu_data = { + .int_config = 0x10, + .orientation = { -1, 0, 0, + 0, 1, 0, + 0, 0, -1 }, + /* accel */ + .accel = { +#ifdef CONFIG_SENSORS_MPU3050_MODULE + .get_slave_descr = NULL, +#else + .get_slave_descr = get_accel_slave_descr, +#endif + .adapt_num = 2, + .bus = EXT_SLAVE_BUS_SECONDARY, + .address = 0x0F, + .orientation = { -1, 0, 0, + 0, 1, 0, + 0, 0, -1 }, + }, + /* compass */ + .compass = { +#ifdef CONFIG_SENSORS_MPU3050_MODULE + .get_slave_descr = NULL, +#else + .get_slave_descr = get_compass_slave_descr, +#endif + .adapt_num = 2, + .bus = EXT_SLAVE_BUS_PRIMARY, + .address = 0x0E, + .orientation = { 1, 0, 0, + 0, 1, 0, + 0, 0, 1 }, + }, +}; +#endif + +#if defined(CONFIG_SENSORS_MPU6000) || defined(CONFIG_SENSORS_MPU6000_MODULE) + +#define SENSOR_MPU_NAME "mpu6000" + +static struct mpu3050_platform_data mpu_data = { + .int_config = 0x10, + .orientation = { -1, 0, 0, + 0, 1, 0, + 0, 0, -1 }, + /* accel */ + .accel = { +#ifdef CONFIG_SENSORS_MPU6000_MODULE + .get_slave_descr = NULL, +#else + .get_slave_descr = get_accel_slave_descr, +#endif + .adapt_num = 2, + .bus = EXT_SLAVE_BUS_PRIMARY, + .address = 0x68, + .orientation = { -1, 0, 0, + 0, 1, 0, + 0, 0, -1 }, + }, + /* compass */ + .compass = { +#ifdef CONFIG_SENSORS_MPU6000_MODULE + .get_slave_descr = NULL, +#else + .get_slave_descr = get_compass_slave_descr, +#endif + .adapt_num = 2, + .bus = EXT_SLAVE_BUS_SECONDARY, + .address = 0x0E, + .orientation = { 1, 0, 0, + 0, 1, 0, + 0, 0, 1 }, + }, +}; +#endif + +static struct i2c_board_info __initdata beagle_i2c_2_boardinfo[] = { + { + I2C_BOARD_INFO(SENSOR_MPU_NAME, 0x68), + .irq = (IH_GPIO_BASE + MPU_GPIO_IRQ), + .platform_data = &mpu_data, + }, +}; + +Typically the IRQ is a GPIO input pin and needs to be configured properly. If +in the above example GPIO 168 corresponds to IRQ 299, the following should be +done as well: + +#define MPU_GPIO_IRQ 168 + + gpio_request(MPU_GPIO_IRQ,"MPUIRQ"); + gpio_direction_input(MPU_GPIO_IRQ) + + +Android File Permissions +======================== + +To set up the file permissions on an android system, the /dev/mpu and +/dev/mpuirq files needs to be added to the system/core/init/devices.c file +inside the perms_ structure. + +static struct perms_ devperms[] = { + { "/dev/mpu" ,0640, AID_SYSTEM, AID_SYSTEM, 1 }, +}; + +Sufficient file permissions need to be give to read and write it by the system. +
_______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
