linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu
@ 2014-02-05 10:34 Manuel Stahl
  2014-02-05 10:34 ` [PATCH 2/3] iio: imu: inv_mpu6050: Fix typo and formatting Manuel Stahl
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Manuel Stahl @ 2014-02-05 10:34 UTC (permalink / raw)
  To: jic23; +Cc: Ge Gao, Manuel Stahl, linux-iio

Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
---
 drivers/iio/imu/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/Kconfig b/drivers/iio/imu/Kconfig
index 663e88a..2b0e451 100644
--- a/drivers/iio/imu/Kconfig
+++ b/drivers/iio/imu/Kconfig
@@ -25,6 +25,8 @@ config ADIS16480
 	  Say yes here to build support for Analog Devices ADIS16375, ADIS16480,
 	  ADIS16485, ADIS16488 inertial sensors.
 
+source "drivers/iio/imu/inv_mpu6050/Kconfig"
+
 endmenu
 
 config IIO_ADIS_LIB
@@ -38,5 +40,3 @@ config IIO_ADIS_LIB_BUFFER
 	help
 	  A set of buffer helper functions for the Analog Devices ADIS* device
 	  family.
-
-source "drivers/iio/imu/inv_mpu6050/Kconfig"
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/3] iio: imu: inv_mpu6050: Fix typo and formatting
  2014-02-05 10:34 [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu Manuel Stahl
@ 2014-02-05 10:34 ` Manuel Stahl
  2014-02-08 12:29   ` Jonathan Cameron
  2014-02-05 10:34 ` [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150 Manuel Stahl
  2014-02-08 12:28 ` [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu Jonathan Cameron
  2 siblings, 1 reply; 14+ messages in thread
From: Manuel Stahl @ 2014-02-05 10:34 UTC (permalink / raw)
  To: jic23; +Cc: Ge Gao, Manuel Stahl, linux-iio

Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c |  2 +-
 drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  | 38 +++++++++++++++---------------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index df7f1e1..fda1ee2 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -117,7 +117,7 @@ int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask)
 		return result;
 
 	if (en) {
-		/* Wait for output stablize */
+		/* Wait for output stabilize */
 		msleep(INV_MPU6050_TEMP_UP_TIME);
 		if (INV_MPU6050_BIT_PWR_GYRO_STBY == mask) {
 			/* switch internal clock to PLL */
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index f383955..0ab382b 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -126,35 +126,35 @@ struct inv_mpu6050_state {
 #define INV_MPU6050_REG_SAMPLE_RATE_DIV     0x19
 #define INV_MPU6050_REG_CONFIG              0x1A
 #define INV_MPU6050_REG_GYRO_CONFIG         0x1B
-#define INV_MPU6050_REG_ACCEL_CONFIG	    0x1C
+#define INV_MPU6050_REG_ACCEL_CONFIG        0x1C
 
 #define INV_MPU6050_REG_FIFO_EN             0x23
-#define INV_MPU6050_BIT_ACCEL_OUT                   0x08
-#define INV_MPU6050_BITS_GYRO_OUT                   0x70
+#define INV_MPU6050_BIT_ACCEL_OUT           0x08
+#define INV_MPU6050_BITS_GYRO_OUT           0x70
 
 #define INV_MPU6050_REG_INT_ENABLE          0x38
-#define INV_MPU6050_BIT_DATA_RDY_EN                 0x01
-#define INV_MPU6050_BIT_DMP_INT_EN                  0x02
+#define INV_MPU6050_BIT_DATA_RDY_EN         0x01
+#define INV_MPU6050_BIT_DMP_INT_EN          0x02
 
 #define INV_MPU6050_REG_RAW_ACCEL           0x3B
 #define INV_MPU6050_REG_TEMPERATURE         0x41
 #define INV_MPU6050_REG_RAW_GYRO            0x43
 
 #define INV_MPU6050_REG_USER_CTRL           0x6A
-#define INV_MPU6050_BIT_FIFO_RST                    0x04
-#define INV_MPU6050_BIT_DMP_RST                     0x08
-#define INV_MPU6050_BIT_I2C_MST_EN                  0x20
-#define INV_MPU6050_BIT_FIFO_EN                     0x40
-#define INV_MPU6050_BIT_DMP_EN                      0x80
+#define INV_MPU6050_BIT_FIFO_RST            0x04
+#define INV_MPU6050_BIT_DMP_RST             0x08
+#define INV_MPU6050_BIT_I2C_MST_EN          0x20
+#define INV_MPU6050_BIT_FIFO_EN             0x40
+#define INV_MPU6050_BIT_DMP_EN              0x80
 
 #define INV_MPU6050_REG_PWR_MGMT_1          0x6B
-#define INV_MPU6050_BIT_H_RESET                     0x80
-#define INV_MPU6050_BIT_SLEEP                       0x40
-#define INV_MPU6050_BIT_CLK_MASK                    0x7
+#define INV_MPU6050_BIT_H_RESET             0x80
+#define INV_MPU6050_BIT_SLEEP               0x40
+#define INV_MPU6050_BIT_CLK_MASK            0x7
 
 #define INV_MPU6050_REG_PWR_MGMT_2          0x6C
-#define INV_MPU6050_BIT_PWR_ACCL_STBY               0x38
-#define INV_MPU6050_BIT_PWR_GYRO_STBY               0x07
+#define INV_MPU6050_BIT_PWR_ACCL_STBY       0x38
+#define INV_MPU6050_BIT_PWR_GYRO_STBY       0x07
 
 #define INV_MPU6050_REG_FIFO_COUNT_H        0x72
 #define INV_MPU6050_REG_FIFO_R_W            0x74
@@ -180,10 +180,10 @@ struct inv_mpu6050_state {
 
 /* init parameters */
 #define INV_MPU6050_INIT_FIFO_RATE           50
-#define INV_MPU6050_TIME_STAMP_TOR                        5
-#define INV_MPU6050_MAX_FIFO_RATE                         1000
-#define INV_MPU6050_MIN_FIFO_RATE                         4
-#define INV_MPU6050_ONE_K_HZ                              1000
+#define INV_MPU6050_TIME_STAMP_TOR           5
+#define INV_MPU6050_MAX_FIFO_RATE            1000
+#define INV_MPU6050_MIN_FIFO_RATE            4
+#define INV_MPU6050_ONE_K_HZ                 1000
 
 /* scan element definition */
 enum inv_mpu6050_scan {
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-05 10:34 [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu Manuel Stahl
  2014-02-05 10:34 ` [PATCH 2/3] iio: imu: inv_mpu6050: Fix typo and formatting Manuel Stahl
@ 2014-02-05 10:34 ` Manuel Stahl
  2014-02-08 12:31   ` Jonathan Cameron
  2014-02-08 12:28 ` [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu Jonathan Cameron
  2 siblings, 1 reply; 14+ messages in thread
From: Manuel Stahl @ 2014-02-05 10:34 UTC (permalink / raw)
  To: jic23; +Cc: Ge Gao, Manuel Stahl, linux-iio

The magnetometer included in the mpu9150 will be exported to the
I2C bus at address 0x0C and can be accessed by the IIO driver
ak8975.

Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
---
 drivers/iio/imu/inv_mpu6050/Kconfig        |  6 ++++--
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 21 ++++++++++++++++++++-
 drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  4 ++++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig b/drivers/iio/imu/inv_mpu6050/Kconfig
index 361b232..9843f9e 100644
--- a/drivers/iio/imu/inv_mpu6050/Kconfig
+++ b/drivers/iio/imu/inv_mpu6050/Kconfig
@@ -3,12 +3,14 @@
 #
 
 config INV_MPU6050_IIO
-	tristate "Invensense MPU6050 devices"
+	tristate "Invensense MPU6050 and MPU9150 devices"
 	depends on I2C && SYSFS
 	select IIO_BUFFER
 	select IIO_TRIGGERED_BUFFER
 	help
-	  This driver supports the Invensense MPU6050 devices.
+	  This driver supports the Invensense MPU6050 and MPU9150 devices.
 	  It is a gyroscope/accelerometer combo device.
+	  The MPU9150 has an additional magnetometer, but this is currently
+	  only exported as a separate device on I2C address 0x0C.
 	  This driver can be built as a module. The module will be called
 	  inv-mpu6050.
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index fda1ee2..a121b5c 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -71,6 +71,12 @@ static const struct inv_mpu6050_hw hw_info[INV_NUM_PARTS] = {
 		.reg = &reg_set_6050,
 		.config = &chip_config_6050,
 	},
+	{
+		.num_reg = 118,
+		.name = "MPU9150",
+		.reg = &reg_set_6050,
+		.config = &chip_config_6050,
+	},
 };
 
 int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, u8 d)
@@ -616,7 +622,12 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
 {
 	int result;
 
-	st->chip_type = INV_MPU6050;
+	st->chip_type = (unsigned)id->driver_data;
+	if (st->chip_type >= INV_NUM_PARTS) {
+		dev_err(&st->client->dev,
+			"Invalid chip type: %s.\n", id->name);
+		return -ENODEV;
+	}
 	st->hw  = &hw_info[st->chip_type];
 	st->reg = hw_info[st->chip_type].reg;
 
@@ -646,6 +657,11 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
 	if (result)
 		return result;
 
+	/* set to bypass mode */
+	result = inv_mpu6050_write_reg(st, INV_MPU6050_REG_INT_PIN_CFG,
+			INV_MPU6050_BIT_BYPASS_EN);
+	if (result)
+		return result;
 	return 0;
 }
 
@@ -719,6 +735,8 @@ static int inv_mpu_probe(struct i2c_client *client,
 		goto out_remove_trigger;
 	}
 
+	dev_info(&st->client->dev, "IMU %s found\n", id->name);
+
 	return 0;
 
 out_remove_trigger:
@@ -765,6 +783,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume);
  */
 static const struct i2c_device_id inv_mpu_id[] = {
 	{"mpu6050", INV_MPU6050},
+	{"mpu9150", INV_MPU9150},
 	{}
 };
 
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index 0ab382b..d91b1e4 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map {
 /*device enum */
 enum inv_devices {
 	INV_MPU6050,
+	INV_MPU9150,
 	INV_NUM_PARTS
 };
 
@@ -132,6 +133,9 @@ struct inv_mpu6050_state {
 #define INV_MPU6050_BIT_ACCEL_OUT           0x08
 #define INV_MPU6050_BITS_GYRO_OUT           0x70
 
+#define INV_MPU6050_REG_INT_PIN_CFG         0x37
+#define INV_MPU6050_BIT_BYPASS_EN           0x02
+
 #define INV_MPU6050_REG_INT_ENABLE          0x38
 #define INV_MPU6050_BIT_DATA_RDY_EN         0x01
 #define INV_MPU6050_BIT_DMP_INT_EN          0x02
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu
  2014-02-05 10:34 [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu Manuel Stahl
  2014-02-05 10:34 ` [PATCH 2/3] iio: imu: inv_mpu6050: Fix typo and formatting Manuel Stahl
  2014-02-05 10:34 ` [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150 Manuel Stahl
@ 2014-02-08 12:28 ` Jonathan Cameron
  2 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2014-02-08 12:28 UTC (permalink / raw)
  To: Manuel Stahl, jic23; +Cc: Ge Gao, linux-iio

On 05/02/14 10:34, Manuel Stahl wrote:
> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
Applied to the togreg branch of iio.igt

Thanks,
> ---
>   drivers/iio/imu/Kconfig | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/imu/Kconfig b/drivers/iio/imu/Kconfig
> index 663e88a..2b0e451 100644
> --- a/drivers/iio/imu/Kconfig
> +++ b/drivers/iio/imu/Kconfig
> @@ -25,6 +25,8 @@ config ADIS16480
>   	  Say yes here to build support for Analog Devices ADIS16375, ADIS16480,
>   	  ADIS16485, ADIS16488 inertial sensors.
>
> +source "drivers/iio/imu/inv_mpu6050/Kconfig"
> +
>   endmenu
>
>   config IIO_ADIS_LIB
> @@ -38,5 +40,3 @@ config IIO_ADIS_LIB_BUFFER
>   	help
>   	  A set of buffer helper functions for the Analog Devices ADIS* device
>   	  family.
> -
> -source "drivers/iio/imu/inv_mpu6050/Kconfig"
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/3] iio: imu: inv_mpu6050: Fix typo and formatting
  2014-02-05 10:34 ` [PATCH 2/3] iio: imu: inv_mpu6050: Fix typo and formatting Manuel Stahl
@ 2014-02-08 12:29   ` Jonathan Cameron
  0 siblings, 0 replies; 14+ messages in thread
From: Jonathan Cameron @ 2014-02-08 12:29 UTC (permalink / raw)
  To: Manuel Stahl; +Cc: Ge Gao, linux-iio

On 05/02/14 10:34, Manuel Stahl wrote:
> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
Applied to the togreg branch of iio.git

Thanks,
> ---
>   drivers/iio/imu/inv_mpu6050/inv_mpu_core.c |  2 +-
>   drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  | 38 +++++++++++++++---------------
>   2 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index df7f1e1..fda1ee2 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -117,7 +117,7 @@ int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask)
>   		return result;
>
>   	if (en) {
> -		/* Wait for output stablize */
> +		/* Wait for output stabilize */
>   		msleep(INV_MPU6050_TEMP_UP_TIME);
>   		if (INV_MPU6050_BIT_PWR_GYRO_STBY == mask) {
>   			/* switch internal clock to PLL */
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index f383955..0ab382b 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -126,35 +126,35 @@ struct inv_mpu6050_state {
>   #define INV_MPU6050_REG_SAMPLE_RATE_DIV     0x19
>   #define INV_MPU6050_REG_CONFIG              0x1A
>   #define INV_MPU6050_REG_GYRO_CONFIG         0x1B
> -#define INV_MPU6050_REG_ACCEL_CONFIG	    0x1C
> +#define INV_MPU6050_REG_ACCEL_CONFIG        0x1C
>
>   #define INV_MPU6050_REG_FIFO_EN             0x23
> -#define INV_MPU6050_BIT_ACCEL_OUT                   0x08
> -#define INV_MPU6050_BITS_GYRO_OUT                   0x70
> +#define INV_MPU6050_BIT_ACCEL_OUT           0x08
> +#define INV_MPU6050_BITS_GYRO_OUT           0x70
>
>   #define INV_MPU6050_REG_INT_ENABLE          0x38
> -#define INV_MPU6050_BIT_DATA_RDY_EN                 0x01
> -#define INV_MPU6050_BIT_DMP_INT_EN                  0x02
> +#define INV_MPU6050_BIT_DATA_RDY_EN         0x01
> +#define INV_MPU6050_BIT_DMP_INT_EN          0x02
>
>   #define INV_MPU6050_REG_RAW_ACCEL           0x3B
>   #define INV_MPU6050_REG_TEMPERATURE         0x41
>   #define INV_MPU6050_REG_RAW_GYRO            0x43
>
>   #define INV_MPU6050_REG_USER_CTRL           0x6A
> -#define INV_MPU6050_BIT_FIFO_RST                    0x04
> -#define INV_MPU6050_BIT_DMP_RST                     0x08
> -#define INV_MPU6050_BIT_I2C_MST_EN                  0x20
> -#define INV_MPU6050_BIT_FIFO_EN                     0x40
> -#define INV_MPU6050_BIT_DMP_EN                      0x80
> +#define INV_MPU6050_BIT_FIFO_RST            0x04
> +#define INV_MPU6050_BIT_DMP_RST             0x08
> +#define INV_MPU6050_BIT_I2C_MST_EN          0x20
> +#define INV_MPU6050_BIT_FIFO_EN             0x40
> +#define INV_MPU6050_BIT_DMP_EN              0x80
>
>   #define INV_MPU6050_REG_PWR_MGMT_1          0x6B
> -#define INV_MPU6050_BIT_H_RESET                     0x80
> -#define INV_MPU6050_BIT_SLEEP                       0x40
> -#define INV_MPU6050_BIT_CLK_MASK                    0x7
> +#define INV_MPU6050_BIT_H_RESET             0x80
> +#define INV_MPU6050_BIT_SLEEP               0x40
> +#define INV_MPU6050_BIT_CLK_MASK            0x7
>
>   #define INV_MPU6050_REG_PWR_MGMT_2          0x6C
> -#define INV_MPU6050_BIT_PWR_ACCL_STBY               0x38
> -#define INV_MPU6050_BIT_PWR_GYRO_STBY               0x07
> +#define INV_MPU6050_BIT_PWR_ACCL_STBY       0x38
> +#define INV_MPU6050_BIT_PWR_GYRO_STBY       0x07
>
>   #define INV_MPU6050_REG_FIFO_COUNT_H        0x72
>   #define INV_MPU6050_REG_FIFO_R_W            0x74
> @@ -180,10 +180,10 @@ struct inv_mpu6050_state {
>
>   /* init parameters */
>   #define INV_MPU6050_INIT_FIFO_RATE           50
> -#define INV_MPU6050_TIME_STAMP_TOR                        5
> -#define INV_MPU6050_MAX_FIFO_RATE                         1000
> -#define INV_MPU6050_MIN_FIFO_RATE                         4
> -#define INV_MPU6050_ONE_K_HZ                              1000
> +#define INV_MPU6050_TIME_STAMP_TOR           5
> +#define INV_MPU6050_MAX_FIFO_RATE            1000
> +#define INV_MPU6050_MIN_FIFO_RATE            4
> +#define INV_MPU6050_ONE_K_HZ                 1000
>
>   /* scan element definition */
>   enum inv_mpu6050_scan {
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-05 10:34 ` [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150 Manuel Stahl
@ 2014-02-08 12:31   ` Jonathan Cameron
  2014-02-10 18:20     ` Ge Gao
  0 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2014-02-08 12:31 UTC (permalink / raw)
  To: Manuel Stahl, jic23; +Cc: Ge Gao, linux-iio

On 05/02/14 10:34, Manuel Stahl wrote:
> The magnetometer included in the mpu9150 will be exported to the
> I2C bus at address 0x0C and can be accessed by the IIO driver
> ak8975.
>
> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
This looks straight forward to me, but I'll let it sit for a few
days to give Ge an oportunity to comment.

Jonathan

> ---
>   drivers/iio/imu/inv_mpu6050/Kconfig        |  6 ++++--
>   drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 21 ++++++++++++++++++++-
>   drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  4 ++++
>   3 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig b/drivers/iio/imu/inv_mpu6050/Kconfig
> index 361b232..9843f9e 100644
> --- a/drivers/iio/imu/inv_mpu6050/Kconfig
> +++ b/drivers/iio/imu/inv_mpu6050/Kconfig
> @@ -3,12 +3,14 @@
>   #
>
>   config INV_MPU6050_IIO
> -	tristate "Invensense MPU6050 devices"
> +	tristate "Invensense MPU6050 and MPU9150 devices"
>   	depends on I2C && SYSFS
>   	select IIO_BUFFER
>   	select IIO_TRIGGERED_BUFFER
>   	help
> -	  This driver supports the Invensense MPU6050 devices.
> +	  This driver supports the Invensense MPU6050 and MPU9150 devices.
>   	  It is a gyroscope/accelerometer combo device.
> +	  The MPU9150 has an additional magnetometer, but this is currently
> +	  only exported as a separate device on I2C address 0x0C.
>   	  This driver can be built as a module. The module will be called
>   	  inv-mpu6050.
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index fda1ee2..a121b5c 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -71,6 +71,12 @@ static const struct inv_mpu6050_hw hw_info[INV_NUM_PARTS] = {
>   		.reg = &reg_set_6050,
>   		.config = &chip_config_6050,
>   	},
> +	{
> +		.num_reg = 118,
> +		.name = "MPU9150",
> +		.reg = &reg_set_6050,
> +		.config = &chip_config_6050,
> +	},
>   };
>
>   int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, u8 d)
> @@ -616,7 +622,12 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
>   {
>   	int result;
>
> -	st->chip_type = INV_MPU6050;
> +	st->chip_type = (unsigned)id->driver_data;
> +	if (st->chip_type >= INV_NUM_PARTS) {
> +		dev_err(&st->client->dev,
> +			"Invalid chip type: %s.\n", id->name);
> +		return -ENODEV;
> +	}
>   	st->hw  = &hw_info[st->chip_type];
>   	st->reg = hw_info[st->chip_type].reg;
>
> @@ -646,6 +657,11 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
>   	if (result)
>   		return result;
>
> +	/* set to bypass mode */
> +	result = inv_mpu6050_write_reg(st, INV_MPU6050_REG_INT_PIN_CFG,
> +			INV_MPU6050_BIT_BYPASS_EN);
> +	if (result)
> +		return result;
>   	return 0;
>   }
>
> @@ -719,6 +735,8 @@ static int inv_mpu_probe(struct i2c_client *client,
>   		goto out_remove_trigger;
>   	}
>
> +	dev_info(&st->client->dev, "IMU %s found\n", id->name);
> +
>   	return 0;
>
>   out_remove_trigger:
> @@ -765,6 +783,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume);
>    */
>   static const struct i2c_device_id inv_mpu_id[] = {
>   	{"mpu6050", INV_MPU6050},
> +	{"mpu9150", INV_MPU9150},
>   	{}
>   };
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index 0ab382b..d91b1e4 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map {
>   /*device enum */
>   enum inv_devices {
>   	INV_MPU6050,
> +	INV_MPU9150,
>   	INV_NUM_PARTS
>   };
>
> @@ -132,6 +133,9 @@ struct inv_mpu6050_state {
>   #define INV_MPU6050_BIT_ACCEL_OUT           0x08
>   #define INV_MPU6050_BITS_GYRO_OUT           0x70
>
> +#define INV_MPU6050_REG_INT_PIN_CFG         0x37
> +#define INV_MPU6050_BIT_BYPASS_EN           0x02
> +
>   #define INV_MPU6050_REG_INT_ENABLE          0x38
>   #define INV_MPU6050_BIT_DATA_RDY_EN         0x01
>   #define INV_MPU6050_BIT_DMP_INT_EN          0x02
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-08 12:31   ` Jonathan Cameron
@ 2014-02-10 18:20     ` Ge Gao
  2014-02-10 18:39       ` Manuel Stahl
  0 siblings, 1 reply; 14+ messages in thread
From: Ge Gao @ 2014-02-10 18:20 UTC (permalink / raw)
  To: Jonathan Cameron, Manuel Stahl, jic23@cam.ac.uk; +Cc: linux-iio@vger.kernel.org

This is looks fine to me. It is used for primary bus for compass. However, the actual use for MPU9150 is through a secondary bus interface for MPU9150. This interface send a fixed preprogrammed command to AK8975 compass to make it work. The compass result can be read through registers located in MPU9150. 

Thanks.

Best Regards,

Ge GAO


-----Original Message-----
From: Jonathan Cameron [mailto:jic23@kernel.org] 
Sent: Saturday, February 08, 2014 4:32 AM
To: Manuel Stahl; jic23@cam.ac.uk
Cc: Ge Gao; linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150

On 05/02/14 10:34, Manuel Stahl wrote:
> The magnetometer included in the mpu9150 will be exported to the I2C 
> bus at address 0x0C and can be accessed by the IIO driver ak8975.
>
> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
This looks straight forward to me, but I'll let it sit for a few days to give Ge an oportunity to comment.

Jonathan

> ---
>   drivers/iio/imu/inv_mpu6050/Kconfig        |  6 ++++--
>   drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 21 ++++++++++++++++++++-
>   drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  4 ++++
>   3 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig 
> b/drivers/iio/imu/inv_mpu6050/Kconfig
> index 361b232..9843f9e 100644
> --- a/drivers/iio/imu/inv_mpu6050/Kconfig
> +++ b/drivers/iio/imu/inv_mpu6050/Kconfig
> @@ -3,12 +3,14 @@
>   #
>
>   config INV_MPU6050_IIO
> -	tristate "Invensense MPU6050 devices"
> +	tristate "Invensense MPU6050 and MPU9150 devices"
>   	depends on I2C && SYSFS
>   	select IIO_BUFFER
>   	select IIO_TRIGGERED_BUFFER
>   	help
> -	  This driver supports the Invensense MPU6050 devices.
> +	  This driver supports the Invensense MPU6050 and MPU9150 devices.
>   	  It is a gyroscope/accelerometer combo device.
> +	  The MPU9150 has an additional magnetometer, but this is currently
> +	  only exported as a separate device on I2C address 0x0C.
>   	  This driver can be built as a module. The module will be called
>   	  inv-mpu6050.
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c 
> b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index fda1ee2..a121b5c 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -71,6 +71,12 @@ static const struct inv_mpu6050_hw hw_info[INV_NUM_PARTS] = {
>   		.reg = &reg_set_6050,
>   		.config = &chip_config_6050,
>   	},
> +	{
> +		.num_reg = 118,
> +		.name = "MPU9150",
> +		.reg = &reg_set_6050,
> +		.config = &chip_config_6050,
> +	},
>   };
>
>   int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, u8 
> d) @@ -616,7 +622,12 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
>   {
>   	int result;
>
> -	st->chip_type = INV_MPU6050;
> +	st->chip_type = (unsigned)id->driver_data;
> +	if (st->chip_type >= INV_NUM_PARTS) {
> +		dev_err(&st->client->dev,
> +			"Invalid chip type: %s.\n", id->name);
> +		return -ENODEV;
> +	}
>   	st->hw  = &hw_info[st->chip_type];
>   	st->reg = hw_info[st->chip_type].reg;
>
> @@ -646,6 +657,11 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
>   	if (result)
>   		return result;
>
> +	/* set to bypass mode */
> +	result = inv_mpu6050_write_reg(st, INV_MPU6050_REG_INT_PIN_CFG,
> +			INV_MPU6050_BIT_BYPASS_EN);
> +	if (result)
> +		return result;
>   	return 0;
>   }
>
> @@ -719,6 +735,8 @@ static int inv_mpu_probe(struct i2c_client *client,
>   		goto out_remove_trigger;
>   	}
>
> +	dev_info(&st->client->dev, "IMU %s found\n", id->name);
> +
>   	return 0;
>
>   out_remove_trigger:
> @@ -765,6 +783,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume);
>    */
>   static const struct i2c_device_id inv_mpu_id[] = {
>   	{"mpu6050", INV_MPU6050},
> +	{"mpu9150", INV_MPU9150},
>   	{}
>   };
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h 
> b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index 0ab382b..d91b1e4 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map {
>   /*device enum */
>   enum inv_devices {
>   	INV_MPU6050,
> +	INV_MPU9150,
>   	INV_NUM_PARTS
>   };
>
> @@ -132,6 +133,9 @@ struct inv_mpu6050_state {
>   #define INV_MPU6050_BIT_ACCEL_OUT           0x08
>   #define INV_MPU6050_BITS_GYRO_OUT           0x70
>
> +#define INV_MPU6050_REG_INT_PIN_CFG         0x37
> +#define INV_MPU6050_BIT_BYPASS_EN           0x02
> +
>   #define INV_MPU6050_REG_INT_ENABLE          0x38
>   #define INV_MPU6050_BIT_DATA_RDY_EN         0x01
>   #define INV_MPU6050_BIT_DMP_INT_EN          0x02
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-10 18:20     ` Ge Gao
@ 2014-02-10 18:39       ` Manuel Stahl
  2014-02-11 19:12         ` Ge Gao
  0 siblings, 1 reply; 14+ messages in thread
From: Manuel Stahl @ 2014-02-10 18:39 UTC (permalink / raw)
  To: Ge Gao; +Cc: Jonathan Cameron, linux-iio@vger.kernel.org

Hi Ge,

thanks for your approval. You're right, that the compass should be accessed internally. Actually I had some problems with the bypass mode (I can not disable it, but might be a problem of the PCB), so I started with the minimal approach.

Best regards,
Manuel Stahl

Am Montag, 10. Februar 2014, 19:20:59 schrieb Ge Gao:
> This is looks fine to me. It is used for primary bus for compass. However, the actual use for MPU9150 is through a secondary bus interface for MPU9150. This interface send a fixed preprogrammed command to AK8975 compass to make it work. The compass result can be read through registers located in MPU9150. 
> 
> Thanks.
> 
> Best Regards,
> 
> Ge GAO
> 
> 
> -----Original Message-----
> From: Jonathan Cameron [mailto:jic23@kernel.org] 
> Sent: Saturday, February 08, 2014 4:32 AM
> To: Manuel Stahl; jic23@cam.ac.uk
> Cc: Ge Gao; linux-iio@vger.kernel.org
> Subject: Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
> 
> On 05/02/14 10:34, Manuel Stahl wrote:
> > The magnetometer included in the mpu9150 will be exported to the I2C 
> > bus at address 0x0C and can be accessed by the IIO driver ak8975.
> >
> > Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
> This looks straight forward to me, but I'll let it sit for a few days to give Ge an oportunity to comment.
> 
> Jonathan
> 
> > ---
> >   drivers/iio/imu/inv_mpu6050/Kconfig        |  6 ++++--
> >   drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 21 ++++++++++++++++++++-
> >   drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  4 ++++
> >   3 files changed, 28 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig 
> > b/drivers/iio/imu/inv_mpu6050/Kconfig
> > index 361b232..9843f9e 100644
> > --- a/drivers/iio/imu/inv_mpu6050/Kconfig
> > +++ b/drivers/iio/imu/inv_mpu6050/Kconfig
> > @@ -3,12 +3,14 @@
> >   #
> >
> >   config INV_MPU6050_IIO
> > -	tristate "Invensense MPU6050 devices"
> > +	tristate "Invensense MPU6050 and MPU9150 devices"
> >   	depends on I2C && SYSFS
> >   	select IIO_BUFFER
> >   	select IIO_TRIGGERED_BUFFER
> >   	help
> > -	  This driver supports the Invensense MPU6050 devices.
> > +	  This driver supports the Invensense MPU6050 and MPU9150 devices.
> >   	  It is a gyroscope/accelerometer combo device.
> > +	  The MPU9150 has an additional magnetometer, but this is currently
> > +	  only exported as a separate device on I2C address 0x0C.
> >   	  This driver can be built as a module. The module will be called
> >   	  inv-mpu6050.
> > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c 
> > b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> > index fda1ee2..a121b5c 100644
> > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> > @@ -71,6 +71,12 @@ static const struct inv_mpu6050_hw hw_info[INV_NUM_PARTS] = {
> >   		.reg = &reg_set_6050,
> >   		.config = &chip_config_6050,
> >   	},
> > +	{
> > +		.num_reg = 118,
> > +		.name = "MPU9150",
> > +		.reg = &reg_set_6050,
> > +		.config = &chip_config_6050,
> > +	},
> >   };
> >
> >   int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, u8 
> > d) @@ -616,7 +622,12 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
> >   {
> >   	int result;
> >
> > -	st->chip_type = INV_MPU6050;
> > +	st->chip_type = (unsigned)id->driver_data;
> > +	if (st->chip_type >= INV_NUM_PARTS) {
> > +		dev_err(&st->client->dev,
> > +			"Invalid chip type: %s.\n", id->name);
> > +		return -ENODEV;
> > +	}
> >   	st->hw  = &hw_info[st->chip_type];
> >   	st->reg = hw_info[st->chip_type].reg;
> >
> > @@ -646,6 +657,11 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
> >   	if (result)
> >   		return result;
> >
> > +	/* set to bypass mode */
> > +	result = inv_mpu6050_write_reg(st, INV_MPU6050_REG_INT_PIN_CFG,
> > +			INV_MPU6050_BIT_BYPASS_EN);
> > +	if (result)
> > +		return result;
> >   	return 0;
> >   }
> >
> > @@ -719,6 +735,8 @@ static int inv_mpu_probe(struct i2c_client *client,
> >   		goto out_remove_trigger;
> >   	}
> >
> > +	dev_info(&st->client->dev, "IMU %s found\n", id->name);
> > +
> >   	return 0;
> >
> >   out_remove_trigger:
> > @@ -765,6 +783,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume);
> >    */
> >   static const struct i2c_device_id inv_mpu_id[] = {
> >   	{"mpu6050", INV_MPU6050},
> > +	{"mpu9150", INV_MPU9150},
> >   	{}
> >   };
> >
> > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h 
> > b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> > index 0ab382b..d91b1e4 100644
> > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> > @@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map {
> >   /*device enum */
> >   enum inv_devices {
> >   	INV_MPU6050,
> > +	INV_MPU9150,
> >   	INV_NUM_PARTS
> >   };
> >
> > @@ -132,6 +133,9 @@ struct inv_mpu6050_state {
> >   #define INV_MPU6050_BIT_ACCEL_OUT           0x08
> >   #define INV_MPU6050_BITS_GYRO_OUT           0x70
> >
> > +#define INV_MPU6050_REG_INT_PIN_CFG         0x37
> > +#define INV_MPU6050_BIT_BYPASS_EN           0x02
> > +
> >   #define INV_MPU6050_REG_INT_ENABLE          0x38
> >   #define INV_MPU6050_BIT_DATA_RDY_EN         0x01
> >   #define INV_MPU6050_BIT_DMP_INT_EN          0x02
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-10 18:39       ` Manuel Stahl
@ 2014-02-11 19:12         ` Ge Gao
  2014-02-15 12:28           ` Jonathan Cameron
  0 siblings, 1 reply; 14+ messages in thread
From: Ge Gao @ 2014-02-11 19:12 UTC (permalink / raw)
  To: Manuel Stahl; +Cc: Jonathan Cameron, linux-iio@vger.kernel.org

One of the concern of this primary bus usage is that if the MPU9150 is in sleep mode, the bypass mode won't work. The standalone primary bus driver won't be able to access the AKM8975 compass. There is some dependency between the two and the standalone AK8975 driver won't be standalone.
For the bypass mode problem you mentioned, it might be VDDIO? It will depend on your PCB routings.

Thanks.

Ge


-----Original Message-----
From: Manuel Stahl [mailto:manuel.stahl@iis.fraunhofer.de] 
Sent: Monday, February 10, 2014 10:40 AM
To: Ge Gao
Cc: Jonathan Cameron; linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150

Hi Ge,

thanks for your approval. You're right, that the compass should be accessed internally. Actually I had some problems with the bypass mode (I can not disable it, but might be a problem of the PCB), so I started with the minimal approach.

Best regards,
Manuel Stahl

Am Montag, 10. Februar 2014, 19:20:59 schrieb Ge Gao:
> This is looks fine to me. It is used for primary bus for compass. However, the actual use for MPU9150 is through a secondary bus interface for MPU9150. This interface send a fixed preprogrammed command to AK8975 compass to make it work. The compass result can be read through registers located in MPU9150. 
> 
> Thanks.
> 
> Best Regards,
> 
> Ge GAO
> 
> 
> -----Original Message-----
> From: Jonathan Cameron [mailto:jic23@kernel.org]
> Sent: Saturday, February 08, 2014 4:32 AM
> To: Manuel Stahl; jic23@cam.ac.uk
> Cc: Ge Gao; linux-iio@vger.kernel.org
> Subject: Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for 
> mpu9150
> 
> On 05/02/14 10:34, Manuel Stahl wrote:
> > The magnetometer included in the mpu9150 will be exported to the I2C 
> > bus at address 0x0C and can be accessed by the IIO driver ak8975.
> >
> > Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
> This looks straight forward to me, but I'll let it sit for a few days to give Ge an oportunity to comment.
> 
> Jonathan
> 
> > ---
> >   drivers/iio/imu/inv_mpu6050/Kconfig        |  6 ++++--
> >   drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 21 ++++++++++++++++++++-
> >   drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  4 ++++
> >   3 files changed, 28 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig
> > b/drivers/iio/imu/inv_mpu6050/Kconfig
> > index 361b232..9843f9e 100644
> > --- a/drivers/iio/imu/inv_mpu6050/Kconfig
> > +++ b/drivers/iio/imu/inv_mpu6050/Kconfig
> > @@ -3,12 +3,14 @@
> >   #
> >
> >   config INV_MPU6050_IIO
> > -	tristate "Invensense MPU6050 devices"
> > +	tristate "Invensense MPU6050 and MPU9150 devices"
> >   	depends on I2C && SYSFS
> >   	select IIO_BUFFER
> >   	select IIO_TRIGGERED_BUFFER
> >   	help
> > -	  This driver supports the Invensense MPU6050 devices.
> > +	  This driver supports the Invensense MPU6050 and MPU9150 devices.
> >   	  It is a gyroscope/accelerometer combo device.
> > +	  The MPU9150 has an additional magnetometer, but this is currently
> > +	  only exported as a separate device on I2C address 0x0C.
> >   	  This driver can be built as a module. The module will be called
> >   	  inv-mpu6050.
> > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> > b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> > index fda1ee2..a121b5c 100644
> > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> > @@ -71,6 +71,12 @@ static const struct inv_mpu6050_hw hw_info[INV_NUM_PARTS] = {
> >   		.reg = &reg_set_6050,
> >   		.config = &chip_config_6050,
> >   	},
> > +	{
> > +		.num_reg = 118,
> > +		.name = "MPU9150",
> > +		.reg = &reg_set_6050,
> > +		.config = &chip_config_6050,
> > +	},
> >   };
> >
> >   int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg, 
> > u8
> > d) @@ -616,7 +622,12 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
> >   {
> >   	int result;
> >
> > -	st->chip_type = INV_MPU6050;
> > +	st->chip_type = (unsigned)id->driver_data;
> > +	if (st->chip_type >= INV_NUM_PARTS) {
> > +		dev_err(&st->client->dev,
> > +			"Invalid chip type: %s.\n", id->name);
> > +		return -ENODEV;
> > +	}
> >   	st->hw  = &hw_info[st->chip_type];
> >   	st->reg = hw_info[st->chip_type].reg;
> >
> > @@ -646,6 +657,11 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
> >   	if (result)
> >   		return result;
> >
> > +	/* set to bypass mode */
> > +	result = inv_mpu6050_write_reg(st, INV_MPU6050_REG_INT_PIN_CFG,
> > +			INV_MPU6050_BIT_BYPASS_EN);
> > +	if (result)
> > +		return result;
> >   	return 0;
> >   }
> >
> > @@ -719,6 +735,8 @@ static int inv_mpu_probe(struct i2c_client *client,
> >   		goto out_remove_trigger;
> >   	}
> >
> > +	dev_info(&st->client->dev, "IMU %s found\n", id->name);
> > +
> >   	return 0;
> >
> >   out_remove_trigger:
> > @@ -765,6 +783,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume);
> >    */
> >   static const struct i2c_device_id inv_mpu_id[] = {
> >   	{"mpu6050", INV_MPU6050},
> > +	{"mpu9150", INV_MPU9150},
> >   	{}
> >   };
> >
> > diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> > b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> > index 0ab382b..d91b1e4 100644
> > --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> > +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> > @@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map {
> >   /*device enum */
> >   enum inv_devices {
> >   	INV_MPU6050,
> > +	INV_MPU9150,
> >   	INV_NUM_PARTS
> >   };
> >
> > @@ -132,6 +133,9 @@ struct inv_mpu6050_state {
> >   #define INV_MPU6050_BIT_ACCEL_OUT           0x08
> >   #define INV_MPU6050_BITS_GYRO_OUT           0x70
> >
> > +#define INV_MPU6050_REG_INT_PIN_CFG         0x37
> > +#define INV_MPU6050_BIT_BYPASS_EN           0x02
> > +
> >   #define INV_MPU6050_REG_INT_ENABLE          0x38
> >   #define INV_MPU6050_BIT_DATA_RDY_EN         0x01
> >   #define INV_MPU6050_BIT_DMP_INT_EN          0x02
> >
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" 
> in the body of a message to majordomo@vger.kernel.org More majordomo 
> info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-11 19:12         ` Ge Gao
@ 2014-02-15 12:28           ` Jonathan Cameron
  2014-02-15 13:39             ` Wolfram Sang
  0 siblings, 1 reply; 14+ messages in thread
From: Jonathan Cameron @ 2014-02-15 12:28 UTC (permalink / raw)
  To: Ge Gao, Manuel Stahl; +Cc: linux-iio@vger.kernel.org, Wolfram Sang

On 11/02/14 19:12, Ge Gao wrote:
> One of the concern of this primary bus usage is that if the MPU9150
> is in sleep mode, the bypass mode won't work. The standalone primary
> bus driver won't be able to access the AKM8975 compass. There is some
> dependency between the two and the standalone AK8975 driver won't be
> standalone. For the bypass mode problem you mentioned, it might be
> VDDIO? It will depend on your PCB routings.
>
Perhaps this bus interaction needs to be apparent in the driver.  It's
a little hideous, but how about a i2 bus multiplexer with only one output?

That might allow such dependencies to be represented.

Wolfram, what do you think?

In short we have a device that sits on an i2c bus and supports its own
i2c bus (mainly so that the internal processor can use data from devices
on that bus) including support for passing the bus straight through.
The issues is the dependencies when the intermediate device is sleeping
for example.

> Thanks.
>
> Ge
>
>
> -----Original Message-----
> From: Manuel Stahl [mailto:manuel.stahl@iis.fraunhofer.de]
> Sent: Monday, February 10, 2014 10:40 AM
> To: Ge Gao
> Cc: Jonathan Cameron; linux-iio@vger.kernel.org
> Subject: Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
>
> Hi Ge,
>
> thanks for your approval. You're right, that the compass should be accessed internally. Actually I had some problems with the bypass mode (I can not disable it, but might be a problem of the PCB), so I started with the minimal approach.
>
> Best regards,
> Manuel Stahl
>
> Am Montag, 10. Februar 2014, 19:20:59 schrieb Ge Gao:
>> This is looks fine to me. It is used for primary bus for compass. However, the actual use for MPU9150 is through a secondary bus interface for MPU9150. This interface send a fixed preprogrammed command to AK8975 compass to make it work. The compass result can be read through registers located in MPU9150.
>>
>> Thanks.
>>
>> Best Regards,
>>
>> Ge GAO
>>
>>
>> -----Original Message-----
>> From: Jonathan Cameron [mailto:jic23@kernel.org]
>> Sent: Saturday, February 08, 2014 4:32 AM
>> To: Manuel Stahl; jic23@cam.ac.uk
>> Cc: Ge Gao; linux-iio@vger.kernel.org
>> Subject: Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for
>> mpu9150
>>
>> On 05/02/14 10:34, Manuel Stahl wrote:
>>> The magnetometer included in the mpu9150 will be exported to the I2C
>>> bus at address 0x0C and can be accessed by the IIO driver ak8975.
>>>
>>> Signed-off-by: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>
>> This looks straight forward to me, but I'll let it sit for a few days to give Ge an oportunity to comment.
>>
>> Jonathan
>>
>>> ---
>>>    drivers/iio/imu/inv_mpu6050/Kconfig        |  6 ++++--
>>>    drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 21 ++++++++++++++++++++-
>>>    drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  4 ++++
>>>    3 files changed, 28 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig
>>> b/drivers/iio/imu/inv_mpu6050/Kconfig
>>> index 361b232..9843f9e 100644
>>> --- a/drivers/iio/imu/inv_mpu6050/Kconfig
>>> +++ b/drivers/iio/imu/inv_mpu6050/Kconfig
>>> @@ -3,12 +3,14 @@
>>>    #
>>>
>>>    config INV_MPU6050_IIO
>>> -	tristate "Invensense MPU6050 devices"
>>> +	tristate "Invensense MPU6050 and MPU9150 devices"
>>>    	depends on I2C && SYSFS
>>>    	select IIO_BUFFER
>>>    	select IIO_TRIGGERED_BUFFER
>>>    	help
>>> -	  This driver supports the Invensense MPU6050 devices.
>>> +	  This driver supports the Invensense MPU6050 and MPU9150 devices.
>>>    	  It is a gyroscope/accelerometer combo device.
>>> +	  The MPU9150 has an additional magnetometer, but this is currently
>>> +	  only exported as a separate device on I2C address 0x0C.
>>>    	  This driver can be built as a module. The module will be called
>>>    	  inv-mpu6050.
>>> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
>>> b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
>>> index fda1ee2..a121b5c 100644
>>> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
>>> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
>>> @@ -71,6 +71,12 @@ static const struct inv_mpu6050_hw hw_info[INV_NUM_PARTS] = {
>>>    		.reg = &reg_set_6050,
>>>    		.config = &chip_config_6050,
>>>    	},
>>> +	{
>>> +		.num_reg = 118,
>>> +		.name = "MPU9150",
>>> +		.reg = &reg_set_6050,
>>> +		.config = &chip_config_6050,
>>> +	},
>>>    };
>>>
>>>    int inv_mpu6050_write_reg(struct inv_mpu6050_state *st, int reg,
>>> u8
>>> d) @@ -616,7 +622,12 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
>>>    {
>>>    	int result;
>>>
>>> -	st->chip_type = INV_MPU6050;
>>> +	st->chip_type = (unsigned)id->driver_data;
>>> +	if (st->chip_type >= INV_NUM_PARTS) {
>>> +		dev_err(&st->client->dev,
>>> +			"Invalid chip type: %s.\n", id->name);
>>> +		return -ENODEV;
>>> +	}
>>>    	st->hw  = &hw_info[st->chip_type];
>>>    	st->reg = hw_info[st->chip_type].reg;
>>>
>>> @@ -646,6 +657,11 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st,
>>>    	if (result)
>>>    		return result;
>>>
>>> +	/* set to bypass mode */
>>> +	result = inv_mpu6050_write_reg(st, INV_MPU6050_REG_INT_PIN_CFG,
>>> +			INV_MPU6050_BIT_BYPASS_EN);
>>> +	if (result)
>>> +		return result;
>>>    	return 0;
>>>    }
>>>
>>> @@ -719,6 +735,8 @@ static int inv_mpu_probe(struct i2c_client *client,
>>>    		goto out_remove_trigger;
>>>    	}
>>>
>>> +	dev_info(&st->client->dev, "IMU %s found\n", id->name);
>>> +
>>>    	return 0;
>>>
>>>    out_remove_trigger:
>>> @@ -765,6 +783,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume);
>>>     */
>>>    static const struct i2c_device_id inv_mpu_id[] = {
>>>    	{"mpu6050", INV_MPU6050},
>>> +	{"mpu9150", INV_MPU9150},
>>>    	{}
>>>    };
>>>
>>> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
>>> b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
>>> index 0ab382b..d91b1e4 100644
>>> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
>>> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
>>> @@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map {
>>>    /*device enum */
>>>    enum inv_devices {
>>>    	INV_MPU6050,
>>> +	INV_MPU9150,
>>>    	INV_NUM_PARTS
>>>    };
>>>
>>> @@ -132,6 +133,9 @@ struct inv_mpu6050_state {
>>>    #define INV_MPU6050_BIT_ACCEL_OUT           0x08
>>>    #define INV_MPU6050_BITS_GYRO_OUT           0x70
>>>
>>> +#define INV_MPU6050_REG_INT_PIN_CFG         0x37
>>> +#define INV_MPU6050_BIT_BYPASS_EN           0x02
>>> +
>>>    #define INV_MPU6050_REG_INT_ENABLE          0x38
>>>    #define INV_MPU6050_BIT_DATA_RDY_EN         0x01
>>>    #define INV_MPU6050_BIT_DMP_INT_EN          0x02
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio"
>> in the body of a message to majordomo@vger.kernel.org More majordomo
>> info at  http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-15 12:28           ` Jonathan Cameron
@ 2014-02-15 13:39             ` Wolfram Sang
  2014-02-18  8:34               ` Jonathan Cameron
  0 siblings, 1 reply; 14+ messages in thread
From: Wolfram Sang @ 2014-02-15 13:39 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Ge Gao, Manuel Stahl, linux-iio@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]


> Wolfram, what do you think?
> 
> In short we have a device that sits on an i2c bus and supports its own
> i2c bus (mainly so that the internal processor can use data from devices
> on that bus) including support for passing the bus straight through.
> The issues is the dependencies when the intermediate device is sleeping
> for example.

Just judging from the paragraph above and not digging into the topic
deeper, I think the idea of an 1-1 multiplexer is suitable. Would the
pass-throu device then be a MFD? Are the alternative ideas?


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-15 13:39             ` Wolfram Sang
@ 2014-02-18  8:34               ` Jonathan Cameron
  2014-02-24 16:23                 ` Lee Jones
  2014-02-24 17:04                 ` Wolfram Sang
  0 siblings, 2 replies; 14+ messages in thread
From: Jonathan Cameron @ 2014-02-18  8:34 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Ge Gao, Manuel Stahl, linux-iio@vger.kernel.org, lee.jones

On 15/02/14 13:39, Wolfram Sang wrote:
>
>> Wolfram, what do you think?
>>
>> In short we have a device that sits on an i2c bus and supports its own
>> i2c bus (mainly so that the internal processor can use data from devices
>> on that bus) including support for passing the bus straight through.
>> The issues is the dependencies when the intermediate device is sleeping
>> for example.
>
> Just judging from the paragraph above and not digging into the topic
> deeper, I think the idea of an 1-1 multiplexer is suitable. Would the
> pass-throu device then be a MFD? Are the alternative ideas?
>
Seems like overkill to introduce an MFD for this little addition to a fairly
large (and likely to grow driver).  Its a little ugly, but would you mind
if the multiplexer is just handled directly within the  main driver?
(perhaps via a config option).  It would be 'odd' to say the least if
someone really wanted the pass through and not the complex inertial chip
it is part of.

Might just be simpler to do a very trivial mfd with the two parts hanging of it.
The complexity is that the inertial sensor will often take over the device
hanging off it completely so we will need to have it cleanly blocked as busy.

Lee, what do you think?

Jonathan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-18  8:34               ` Jonathan Cameron
@ 2014-02-24 16:23                 ` Lee Jones
  2014-02-24 17:04                 ` Wolfram Sang
  1 sibling, 0 replies; 14+ messages in thread
From: Lee Jones @ 2014-02-24 16:23 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Wolfram Sang, Ge Gao, Manuel Stahl, linux-iio@vger.kernel.org

> >>Wolfram, what do you think?
> >>
> >>In short we have a device that sits on an i2c bus and supports its own
> >>i2c bus (mainly so that the internal processor can use data from devices
> >>on that bus) including support for passing the bus straight through.
> >>The issues is the dependencies when the intermediate device is sleeping
> >>for example.
> >
> >Just judging from the paragraph above and not digging into the topic
> >deeper, I think the idea of an 1-1 multiplexer is suitable. Would the
> >pass-throu device then be a MFD? Are the alternative ideas?
> >
> Seems like overkill to introduce an MFD for this little addition to a fairly
> large (and likely to grow driver).  Its a little ugly, but would you mind
> if the multiplexer is just handled directly within the  main driver?
> (perhaps via a config option).  It would be 'odd' to say the least if
> someone really wanted the pass through and not the complex inertial chip
> it is part of.
> 
> Might just be simpler to do a very trivial mfd with the two parts hanging of it.
> The complexity is that the inertial sensor will often take over the device
> hanging off it completely so we will need to have it cleanly blocked as busy.
> 
> Lee, what do you think?

Sorry for the delay, I was off last week.

Doesn't look like an MFD to me:

Features:

    Digital-output 9-axis MotionFusion data in rotation matrix,
    quaternion, Euler Angle, or raw data format

    Tri-Axis angular rate sensor (gyro) with a sensitivity up to 131
    LSBs/dps and a full-scale range of ±250, ±500, ±1000, and ±2000dps

    Tri-Axis accelerometer with a programmable full scale range of ±2g,
    ±4g, ±8g and ±16g

    Tri-axis compass with a full scale range of ±1200µT
    Reduced settling effects and sensor drift by elimination of
    board-level cross-axis alignment errors between accelerometer,
    gyroscope, and compass

    Digital Motion Processing™ (DMP™) engine offloads complex
    MotionFusion, sensor timing synchronization and gesture detection

    MotionApps™ Platform support for Android, Linux, and Windows
    Embedded algorithms for run-time bias and compass calibration. No user
    intervention required

    Digital-output temperature sensor
    Digital input on FSYNC pin to support video Electronic Image
    Stabilization and GPS

    Programmable interrupt supports gesture recognition, panning, zooming,
    scrolling, tap detection, and shake detection

    VDD Supply voltage range of 2.4V–3.46V; VLOGIC of 1.8V±5% or VDD
    Gyro operating current: 3.6mA (full power, gyro at all rates)
    Gyro + Accel operating current: 3.8mA (full power, gyro at all rates,
    accel at 1kHz sample rate)

    Gyro + Accel + Compass + DMP operating current: 4.25mA (full power,
    gyro at all rates, accel at 1kHz sample rate, compass at 8Hz rate)

    Accel low power mode operating current: 10µA at 1Hz, 20µA at 5Hz, 70µA
    at 20Hz, 140µA at 40Hz

    Full Chip Idle Mode Supply Current: 8µA
    400kHz Fast Mode I²C serial host interface
    On-chip timing generator with ±1% frequency variation over full
    temperature range

    User self test
    10,000g shock tolerant
    Smallest and thinnest package for portable devices (4x4x1mm)
    RoHS and Green compliant

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150
  2014-02-18  8:34               ` Jonathan Cameron
  2014-02-24 16:23                 ` Lee Jones
@ 2014-02-24 17:04                 ` Wolfram Sang
  1 sibling, 0 replies; 14+ messages in thread
From: Wolfram Sang @ 2014-02-24 17:04 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Ge Gao, Manuel Stahl, linux-iio@vger.kernel.org, lee.jones

[-- Attachment #1: Type: text/plain, Size: 277 bytes --]


> Seems like overkill to introduce an MFD for this little addition to a fairly
> large (and likely to grow driver).  Its a little ugly, but would you mind
> if the multiplexer is just handled directly within the  main driver?

I guess this is the pragmatic solution for now.


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-02-24 17:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 10:34 [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu Manuel Stahl
2014-02-05 10:34 ` [PATCH 2/3] iio: imu: inv_mpu6050: Fix typo and formatting Manuel Stahl
2014-02-08 12:29   ` Jonathan Cameron
2014-02-05 10:34 ` [PATCH 3/3] iio: imu: inv_mpu6050: Add basic support for mpu9150 Manuel Stahl
2014-02-08 12:31   ` Jonathan Cameron
2014-02-10 18:20     ` Ge Gao
2014-02-10 18:39       ` Manuel Stahl
2014-02-11 19:12         ` Ge Gao
2014-02-15 12:28           ` Jonathan Cameron
2014-02-15 13:39             ` Wolfram Sang
2014-02-18  8:34               ` Jonathan Cameron
2014-02-24 16:23                 ` Lee Jones
2014-02-24 17:04                 ` Wolfram Sang
2014-02-08 12:28 ` [PATCH 1/3] iio: imu: mpu6050: Move config entry into IMU menu Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).