* [PATCH 0/5] mpu6050: code clean and calibration support
@ 2016-02-22 21:39 Matt Ranostay
2016-02-22 21:39 ` [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code Matt Ranostay
` (5 more replies)
0 siblings, 6 replies; 16+ messages in thread
From: Matt Ranostay @ 2016-02-22 21:39 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, daniel.baluta, adriana.reus, Matt Ranostay
The patchset series cleans up several documentation, return
code issues, incorrect timing delays, and adds accl/gyro offset
support.
Matt Ranostay (5):
iio: imu: mpu6050: use inv_mpu6050_sensor_show return code
iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay
iio: imu: mpu6050: add missing docstring for int_pin_cfg
iio: imu: mpu6050: add calibration offset support
iio: imu: mpu6050: add mpu6500 register settings
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 88 +++++++++++++++++++++++++++---
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 +-
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 20 ++++++-
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 +-
4 files changed, 105 insertions(+), 12 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code
2016-02-22 21:39 [PATCH 0/5] mpu6050: code clean and calibration support Matt Ranostay
@ 2016-02-22 21:39 ` Matt Ranostay
2016-02-22 21:49 ` Daniel Baluta
2016-02-25 19:50 ` Jonathan Cameron
2016-02-22 21:39 ` [PATCH 2/5] iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay Matt Ranostay
` (4 subsequent siblings)
5 siblings, 2 replies; 16+ messages in thread
From: Matt Ranostay @ 2016-02-22 21:39 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, daniel.baluta, adriana.reus, Matt Ranostay
Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 225860016fed..4324328fd304 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -275,7 +275,7 @@ static int inv_mpu6050_read_raw(struct iio_dev *indio_dev,
case IIO_TEMP:
/* wait for stablization */
msleep(INV_MPU6050_SENSOR_UP_TIME);
- inv_mpu6050_sensor_show(st, st->reg->temperature,
+ ret = inv_mpu6050_sensor_show(st, st->reg->temperature,
IIO_MOD_X, val);
break;
default:
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 2/5] iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay
2016-02-22 21:39 [PATCH 0/5] mpu6050: code clean and calibration support Matt Ranostay
2016-02-22 21:39 ` [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code Matt Ranostay
@ 2016-02-22 21:39 ` Matt Ranostay
2016-02-25 19:54 ` Jonathan Cameron
2016-02-22 21:39 ` [PATCH 3/5] iio: imu: mpu6050: add missing docstring for int_pin_cfg Matt Ranostay
` (3 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Matt Ranostay @ 2016-02-22 21:39 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, daniel.baluta, adriana.reus, Matt Ranostay
replace msleep(INV_MPU6050_REG_UP_TIME) with usleep_range calls
due to fact the wait time is under 20 milliseconds.
Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 3 ++-
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 3 ++-
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 7 ++++++-
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 4324328fd304..6d4b19dd16f8 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -148,7 +148,8 @@ int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on)
return result;
if (power_on)
- msleep(INV_MPU6050_REG_UP_TIME);
+ usleep_range(INV_MPU6050_REG_UP_TIME_MIN,
+ INV_MPU6050_REG_UP_TIME_MAX);
return 0;
}
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index af400dd892a9..37cc16d3fca3 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -68,7 +68,8 @@ static int inv_mpu6050_select_bypass(struct i2c_adapter *adap, void *mux_priv,
if (ret)
goto write_error;
- msleep(INV_MPU6050_REG_UP_TIME);
+ usleep_range(INV_MPU6050_REG_UP_TIME_MIN,
+ INV_MPU6050_REG_UP_TIME_MAX);
}
if (!ret) {
st->powerup_count++;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index fcc2f3dfdfa8..243324dd78de 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -172,10 +172,15 @@ struct inv_mpu6050_state {
#define INV_MPU6050_BYTES_PER_3AXIS_SENSOR 6
#define INV_MPU6050_FIFO_COUNT_BYTE 2
#define INV_MPU6050_FIFO_THRESHOLD 500
+
+/* delay time in milliseconds */
#define INV_MPU6050_POWER_UP_TIME 100
#define INV_MPU6050_TEMP_UP_TIME 100
#define INV_MPU6050_SENSOR_UP_TIME 30
-#define INV_MPU6050_REG_UP_TIME 5
+
+/* delay time in microseconds */
+#define INV_MPU6050_REG_UP_TIME_MIN 5000
+#define INV_MPU6050_REG_UP_TIME_MAX 10000
#define INV_MPU6050_TEMP_OFFSET 12421
#define INV_MPU6050_TEMP_SCALE 2941
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 3/5] iio: imu: mpu6050: add missing docstring for int_pin_cfg
2016-02-22 21:39 [PATCH 0/5] mpu6050: code clean and calibration support Matt Ranostay
2016-02-22 21:39 ` [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code Matt Ranostay
2016-02-22 21:39 ` [PATCH 2/5] iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay Matt Ranostay
@ 2016-02-22 21:39 ` Matt Ranostay
2016-02-25 19:55 ` Jonathan Cameron
2016-02-22 21:39 ` [PATCH 4/5] iio: imu: mpu6050: add calibration offset support Matt Ranostay
` (2 subsequent siblings)
5 siblings, 1 reply; 16+ messages in thread
From: Matt Ranostay @ 2016-02-22 21:39 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, daniel.baluta, adriana.reus, Matt Ranostay
Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index 243324dd78de..a6c45ce459ee 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -39,6 +39,7 @@
* @int_enable: Interrupt enable register.
* @pwr_mgmt_1: Controls chip's power state and clock source.
* @pwr_mgmt_2: Controls power state of individual sensors.
+ * @int_pin_cfg; Controls interrupt pin configuration.
*/
struct inv_mpu6050_reg_map {
u8 sample_rate_div;
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 4/5] iio: imu: mpu6050: add calibration offset support
2016-02-22 21:39 [PATCH 0/5] mpu6050: code clean and calibration support Matt Ranostay
` (2 preceding siblings ...)
2016-02-22 21:39 ` [PATCH 3/5] iio: imu: mpu6050: add missing docstring for int_pin_cfg Matt Ranostay
@ 2016-02-22 21:39 ` Matt Ranostay
2016-02-25 19:55 ` Jonathan Cameron
2016-02-22 21:39 ` [PATCH 5/5] iio: imu: mpu6050: add mpu6500 register settings Matt Ranostay
2016-02-24 21:08 ` [PATCH 0/5] mpu6050: code clean and calibration support Jonathan Cameron
5 siblings, 1 reply; 16+ messages in thread
From: Matt Ranostay @ 2016-02-22 21:39 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, daniel.baluta, adriana.reus, Matt Ranostay
Allow setting of the x/y/z axes calibration offsets for the gyroscope
and accelerometer.
Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 51 ++++++++++++++++++++++++++++--
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 10 ++++++
2 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 6d4b19dd16f8..3acf0863e558 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -55,6 +55,8 @@ static const struct inv_mpu6050_reg_map reg_set_6050 = {
.pwr_mgmt_1 = INV_MPU6050_REG_PWR_MGMT_1,
.pwr_mgmt_2 = INV_MPU6050_REG_PWR_MGMT_2,
.int_pin_cfg = INV_MPU6050_REG_INT_PIN_CFG,
+ .accl_offset = INV_MPU6050_REG_ACCEL_OFFSET,
+ .gyro_offset = INV_MPU6050_REG_GYRO_OFFSET,
};
static const struct inv_mpu6050_chip_config chip_config_6050 = {
@@ -200,6 +202,20 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev)
return result;
}
+static int inv_mpu6050_sensor_set(struct inv_mpu6050_state *st, int reg,
+ int axis, int val)
+{
+ int ind, result;
+ __be16 d = cpu_to_be16(val);
+
+ ind = (axis - IIO_MOD_X) * 2;
+ result = regmap_bulk_write(st->map, reg + ind, (u8 *)&d, 2);
+ if (result)
+ return -EINVAL;
+
+ return 0;
+}
+
static int inv_mpu6050_sensor_show(struct inv_mpu6050_state *st, int reg,
int axis, int *val)
{
@@ -221,11 +237,12 @@ static int inv_mpu6050_read_raw(struct iio_dev *indio_dev,
int *val2,
long mask) {
struct inv_mpu6050_state *st = iio_priv(indio_dev);
+ int ret = 0;
switch (mask) {
case IIO_CHAN_INFO_RAW:
{
- int ret, result;
+ int result;
ret = IIO_VAL_INT;
result = 0;
@@ -321,6 +338,20 @@ error_read_raw:
default:
return -EINVAL;
}
+ case IIO_CHAN_INFO_CALIBBIAS:
+ switch (chan->type) {
+ case IIO_ANGL_VEL:
+ ret = inv_mpu6050_sensor_show(st, st->reg->gyro_offset,
+ chan->channel2, val);
+ return IIO_VAL_INT;
+ case IIO_ACCEL:
+ ret = inv_mpu6050_sensor_show(st, st->reg->accl_offset,
+ chan->channel2, val);
+ return IIO_VAL_INT;
+
+ default:
+ return -EINVAL;
+ }
default:
return -EINVAL;
}
@@ -416,6 +447,21 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
break;
}
break;
+ case IIO_CHAN_INFO_CALIBBIAS:
+ switch (chan->type) {
+ case IIO_ANGL_VEL:
+ result = inv_mpu6050_sensor_set(st,
+ st->reg->gyro_offset,
+ chan->channel2, val);
+ break;
+ case IIO_ACCEL:
+ result = inv_mpu6050_sensor_set(st,
+ st->reg->accl_offset,
+ chan->channel2, val);
+ break;
+ default:
+ result = -EINVAL;
+ }
default:
result = -EINVAL;
break;
@@ -569,7 +615,8 @@ static int inv_mpu6050_validate_trigger(struct iio_dev *indio_dev,
.modified = 1, \
.channel2 = _channel2, \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
+ BIT(IIO_CHAN_INFO_CALIBBIAS), \
.scan_index = _index, \
.scan_type = { \
.sign = 's', \
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index a6c45ce459ee..c4e24148c733 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -40,6 +40,8 @@
* @pwr_mgmt_1: Controls chip's power state and clock source.
* @pwr_mgmt_2: Controls power state of individual sensors.
* @int_pin_cfg; Controls interrupt pin configuration.
+ * @accl_offset: Controls the accelerometer calibration offset.
+ * @gyro_offset: Controls the gyroscope calibration offset.
*/
struct inv_mpu6050_reg_map {
u8 sample_rate_div;
@@ -57,6 +59,8 @@ struct inv_mpu6050_reg_map {
u8 pwr_mgmt_1;
u8 pwr_mgmt_2;
u8 int_pin_cfg;
+ u8 accl_offset;
+ u8 gyro_offset;
};
/*device enum */
@@ -133,6 +137,9 @@ struct inv_mpu6050_state {
};
/*register and associated bit definition*/
+#define INV_MPU6050_REG_ACCEL_OFFSET 0x06
+#define INV_MPU6050_REG_GYRO_OFFSET 0x13
+
#define INV_MPU6050_REG_SAMPLE_RATE_DIV 0x19
#define INV_MPU6050_REG_CONFIG 0x1A
#define INV_MPU6050_REG_GYRO_CONFIG 0x1B
@@ -174,6 +181,9 @@ struct inv_mpu6050_state {
#define INV_MPU6050_FIFO_COUNT_BYTE 2
#define INV_MPU6050_FIFO_THRESHOLD 500
+/* mpu6500 registers */
+#define INV_MPU6500_REG_ACCEL_OFFSET 0x77
+
/* delay time in milliseconds */
#define INV_MPU6050_POWER_UP_TIME 100
#define INV_MPU6050_TEMP_UP_TIME 100
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH 5/5] iio: imu: mpu6050: add mpu6500 register settings
2016-02-22 21:39 [PATCH 0/5] mpu6050: code clean and calibration support Matt Ranostay
` (3 preceding siblings ...)
2016-02-22 21:39 ` [PATCH 4/5] iio: imu: mpu6050: add calibration offset support Matt Ranostay
@ 2016-02-22 21:39 ` Matt Ranostay
2016-02-25 19:56 ` Jonathan Cameron
2016-02-24 21:08 ` [PATCH 0/5] mpu6050: code clean and calibration support Jonathan Cameron
5 siblings, 1 reply; 16+ messages in thread
From: Matt Ranostay @ 2016-02-22 21:39 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, daniel.baluta, adriana.reus, Matt Ranostay
Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 32 +++++++++++++++++++++++++++---
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 3 ++-
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 +-
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 ++-
4 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 3acf0863e558..75d93181a16d 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -39,6 +39,26 @@ static const int gyro_scale_6050[] = {133090, 266181, 532362, 1064724};
*/
static const int accel_scale[] = {598, 1196, 2392, 4785};
+static const struct inv_mpu6050_reg_map reg_set_6500 = {
+ .sample_rate_div = INV_MPU6050_REG_SAMPLE_RATE_DIV,
+ .lpf = INV_MPU6050_REG_CONFIG,
+ .user_ctrl = INV_MPU6050_REG_USER_CTRL,
+ .fifo_en = INV_MPU6050_REG_FIFO_EN,
+ .gyro_config = INV_MPU6050_REG_GYRO_CONFIG,
+ .accl_config = INV_MPU6050_REG_ACCEL_CONFIG,
+ .fifo_count_h = INV_MPU6050_REG_FIFO_COUNT_H,
+ .fifo_r_w = INV_MPU6050_REG_FIFO_R_W,
+ .raw_gyro = INV_MPU6050_REG_RAW_GYRO,
+ .raw_accl = INV_MPU6050_REG_RAW_ACCEL,
+ .temperature = INV_MPU6050_REG_TEMPERATURE,
+ .int_enable = INV_MPU6050_REG_INT_ENABLE,
+ .pwr_mgmt_1 = INV_MPU6050_REG_PWR_MGMT_1,
+ .pwr_mgmt_2 = INV_MPU6050_REG_PWR_MGMT_2,
+ .int_pin_cfg = INV_MPU6050_REG_INT_PIN_CFG,
+ .accl_offset = INV_MPU6500_REG_ACCEL_OFFSET,
+ .gyro_offset = INV_MPU6050_REG_GYRO_OFFSET,
+};
+
static const struct inv_mpu6050_reg_map reg_set_6050 = {
.sample_rate_div = INV_MPU6050_REG_SAMPLE_RATE_DIV,
.lpf = INV_MPU6050_REG_CONFIG,
@@ -68,7 +88,13 @@ static const struct inv_mpu6050_chip_config chip_config_6050 = {
.accl_fs = INV_MPU6050_FS_02G,
};
-static const struct inv_mpu6050_hw hw_info[INV_NUM_PARTS] = {
+static const struct inv_mpu6050_hw hw_info[] = {
+ {
+ .num_reg = 117,
+ .name = "MPU6500",
+ .reg = ®_set_6500,
+ .config = &chip_config_6050,
+ },
{
.num_reg = 117,
.name = "MPU6050",
@@ -692,7 +718,6 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
{
int result;
- st->chip_type = INV_MPU6050;
st->hw = &hw_info[st->chip_type];
st->reg = hw_info[st->chip_type].reg;
@@ -726,7 +751,7 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
}
int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
- int (*inv_mpu_bus_setup)(struct iio_dev *))
+ int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type)
{
struct inv_mpu6050_state *st;
struct iio_dev *indio_dev;
@@ -739,6 +764,7 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
return -ENOMEM;
st = iio_priv(indio_dev);
+ st->chip_type = chip_type;
st->powerup_count = 0;
st->irq = irq;
st->map = regmap;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index 37cc16d3fca3..37aec63113ed 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -130,7 +130,8 @@ static int inv_mpu_probe(struct i2c_client *client,
return PTR_ERR(regmap);
}
- result = inv_mpu_core_probe(regmap, client->irq, name, NULL);
+ result = inv_mpu_core_probe(regmap, client->irq, name,
+ NULL, id->driver_data);
if (result < 0)
return result;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index c4e24148c733..e302a49703bf 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -277,7 +277,7 @@ int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on);
int inv_mpu_acpi_create_mux_client(struct i2c_client *client);
void inv_mpu_acpi_delete_mux_client(struct i2c_client *client);
int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
- int (*inv_mpu_bus_setup)(struct iio_dev *));
+ int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type);
int inv_mpu_core_remove(struct device *dev);
int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on);
extern const struct dev_pm_ops inv_mpu_pmops;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index 5b552a677340..dea6c4361de0 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -54,7 +54,8 @@ static int inv_mpu_probe(struct spi_device *spi)
return PTR_ERR(regmap);
}
- return inv_mpu_core_probe(regmap, spi->irq, name, inv_mpu_i2c_disable);
+ return inv_mpu_core_probe(regmap, spi->irq, name,
+ inv_mpu_i2c_disable, id->driver_data);
}
static int inv_mpu_remove(struct spi_device *spi)
--
1.9.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code
2016-02-22 21:39 ` [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code Matt Ranostay
@ 2016-02-22 21:49 ` Daniel Baluta
2016-02-22 21:50 ` Daniel Baluta
2016-02-25 19:50 ` Jonathan Cameron
1 sibling, 1 reply; 16+ messages in thread
From: Daniel Baluta @ 2016-02-22 21:49 UTC (permalink / raw)
To: Matt Ranostay; +Cc: Jonathan Cameron, linux-iio, Daniel Baluta, Adriana Reus
On Mon, Feb 22, 2016 at 11:39 PM, Matt Ranostay <matt.ranostay@intel.com> wrote:
> Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 225860016fed..4324328fd304 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -275,7 +275,7 @@ static int inv_mpu6050_read_raw(struct iio_dev *indio_dev,
> case IIO_TEMP:
> /* wait for stablization */
While at it please also fix this type :D.
> msleep(INV_MPU6050_SENSOR_UP_TIME);
> - inv_mpu6050_sensor_show(st, st->reg->temperature,
> + ret = inv_mpu6050_sensor_show(st, st->reg->temperature,
> IIO_MOD_X, val);
> break;
> default:
> --
> 1.9.1
>
> --
> 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] 16+ messages in thread
* Re: [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code
2016-02-22 21:49 ` Daniel Baluta
@ 2016-02-22 21:50 ` Daniel Baluta
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Baluta @ 2016-02-22 21:50 UTC (permalink / raw)
To: Daniel Baluta; +Cc: Matt Ranostay, Jonathan Cameron, linux-iio, Adriana Reus
On Mon, Feb 22, 2016 at 11:49 PM, Daniel Baluta <daniel.baluta@intel.com> wrote:
> On Mon, Feb 22, 2016 at 11:39 PM, Matt Ranostay <matt.ranostay@intel.com> wrote:
>> Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
>> ---
>> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
>> index 225860016fed..4324328fd304 100644
>> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
>> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
>> @@ -275,7 +275,7 @@ static int inv_mpu6050_read_raw(struct iio_dev *indio_dev,
>> case IIO_TEMP:
>> /* wait for stablization */
>
> While at it please also fix this type :D.
s/type/typo :)))
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/5] mpu6050: code clean and calibration support
2016-02-22 21:39 [PATCH 0/5] mpu6050: code clean and calibration support Matt Ranostay
` (4 preceding siblings ...)
2016-02-22 21:39 ` [PATCH 5/5] iio: imu: mpu6050: add mpu6500 register settings Matt Ranostay
@ 2016-02-24 21:08 ` Jonathan Cameron
[not found] ` <DM3PR1201MB1072776083BB71F4F618555CAFA50@DM3PR1201MB1072.namprd12.prod.outlook.com>
5 siblings, 1 reply; 16+ messages in thread
From: Jonathan Cameron @ 2016-02-24 21:08 UTC (permalink / raw)
To: Matt Ranostay; +Cc: linux-iio, daniel.baluta, adriana.reus, Ge Gao
On 22/02/16 21:39, Matt Ranostay wrote:
> The patchset series cleans up several documentation, return
> code issues, incorrect timing delays, and adds accl/gyro offset
> support.
>
> Matt Ranostay (5):
> iio: imu: mpu6050: use inv_mpu6050_sensor_show return code
> iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay
> iio: imu: mpu6050: add missing docstring for int_pin_cfg
> iio: imu: mpu6050: add calibration offset support
> iio: imu: mpu6050: add mpu6500 register settings
>
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 88 +++++++++++++++++++++++++++---
> drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 +-
> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 20 ++++++-
> drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 +-
> 4 files changed, 105 insertions(+), 12 deletions(-)
>
Whole series looks good to me (the typo fix can follow if you like :)
Ideally I'd like Ge to take a look as well (+ anyone else who fancies
doing so!) so will leave it on list for a few days more.
Jonathan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/5] mpu6050: code clean and calibration support
[not found] ` <DM3PR1201MB1072776083BB71F4F618555CAFA50@DM3PR1201MB1072.namprd12.prod.outlook.com>
@ 2016-02-25 8:45 ` Daniel Baluta
2016-02-25 15:36 ` Ge Gao
0 siblings, 1 reply; 16+ messages in thread
From: Daniel Baluta @ 2016-02-25 8:45 UTC (permalink / raw)
To: Ge Gao
Cc: Jonathan Cameron, Matt Ranostay, linux-iio, daniel.baluta, adriana.reus
On Thu, Feb 25, 2016 at 12:04 AM, Ge Gao <GGao@invensense.com> wrote:
> Dear all,
> It looks good to me.
> Thanks.
>
Hi Ge :),
Thanks for having a look at this. For next patches please also add the
kernel formal
Acked-by tag, like this:
Acked-by: Ge Gao <GGao@invensense.com>
so that Jonathan can mark your collaboration into the commit message.
> Best Regards,
>
> Ge Gao
>
>
> -----Original Message-----
> From: Jonathan Cameron [mailto:jic23@kernel.org]
> Sent: Wednesday, February 24, 2016 1:08 PM
> To: Matt Ranostay
> Cc: linux-iio@vger.kernel.org; daniel.baluta@intel.com; adriana.reus@intel.com; Ge Gao
> Subject: Re: [PATCH 0/5] mpu6050: code clean and calibration support
>
> On 22/02/16 21:39, Matt Ranostay wrote:
>> The patchset series cleans up several documentation, return code
>> issues, incorrect timing delays, and adds accl/gyro offset support.
>>
>> Matt Ranostay (5):
>> iio: imu: mpu6050: use inv_mpu6050_sensor_show return code
>> iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay
>> iio: imu: mpu6050: add missing docstring for int_pin_cfg
>> iio: imu: mpu6050: add calibration offset support
>> iio: imu: mpu6050: add mpu6500 register settings
>>
>> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 88
>> +++++++++++++++++++++++++++---
>> drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 +-
>> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 20 ++++++-
>> drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 +-
>> 4 files changed, 105 insertions(+), 12 deletions(-)
>>
> Whole series looks good to me (the typo fix can follow if you like :)
>
> Ideally I'd like Ge to take a look as well (+ anyone else who fancies doing so!) so will leave it on list for a few days more.
>
> Jonathan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 0/5] mpu6050: code clean and calibration support
2016-02-25 8:45 ` Daniel Baluta
@ 2016-02-25 15:36 ` Ge Gao
0 siblings, 0 replies; 16+ messages in thread
From: Ge Gao @ 2016-02-25 15:36 UTC (permalink / raw)
To: Daniel Baluta; +Cc: Jonathan Cameron, Matt Ranostay, linux-iio, adriana.reus
Sure. I will do that.
Thanks.:-)
Ge
________________________________________
From: daniel.baluta@gmail.com <daniel.baluta@gmail.com> on behalf of Daniel Baluta <daniel.baluta@intel.com>
Sent: Thursday, February 25, 2016 12:45 AM
To: Ge Gao
Cc: Jonathan Cameron; Matt Ranostay; linux-iio@vger.kernel.org; daniel.baluta@intel.com; adriana.reus@intel.com
Subject: Re: [PATCH 0/5] mpu6050: code clean and calibration support
On Thu, Feb 25, 2016 at 12:04 AM, Ge Gao <GGao@invensense.com> wrote:
> Dear all,
> It looks good to me.
> Thanks.
>
Hi Ge :),
Thanks for having a look at this. For next patches please also add the
kernel formal
Acked-by tag, like this:
Acked-by: Ge Gao <GGao@invensense.com>
so that Jonathan can mark your collaboration into the commit message.
> Best Regards,
>
> Ge Gao
>
>
> -----Original Message-----
> From: Jonathan Cameron [mailto:jic23@kernel.org]
> Sent: Wednesday, February 24, 2016 1:08 PM
> To: Matt Ranostay
> Cc: linux-iio@vger.kernel.org; daniel.baluta@intel.com; adriana.reus@intel.com; Ge Gao
> Subject: Re: [PATCH 0/5] mpu6050: code clean and calibration support
>
> On 22/02/16 21:39, Matt Ranostay wrote:
>> The patchset series cleans up several documentation, return code
>> issues, incorrect timing delays, and adds accl/gyro offset support.
>>
>> Matt Ranostay (5):
>> iio: imu: mpu6050: use inv_mpu6050_sensor_show return code
>> iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay
>> iio: imu: mpu6050: add missing docstring for int_pin_cfg
>> iio: imu: mpu6050: add calibration offset support
>> iio: imu: mpu6050: add mpu6500 register settings
>>
>> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 88
>> +++++++++++++++++++++++++++---
>> drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 6 +-
>> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 20 ++++++-
>> drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 +-
>> 4 files changed, 105 insertions(+), 12 deletions(-)
>>
> Whole series looks good to me (the typo fix can follow if you like :)
>
> Ideally I'd like Ge to take a look as well (+ anyone else who fancies doing so!) so will leave it on list for a few days more.
>
> Jonathan
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code
2016-02-22 21:39 ` [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code Matt Ranostay
2016-02-22 21:49 ` Daniel Baluta
@ 2016-02-25 19:50 ` Jonathan Cameron
1 sibling, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2016-02-25 19:50 UTC (permalink / raw)
To: Matt Ranostay; +Cc: linux-iio, daniel.baluta, adriana.reus
On 22/02/16 21:39, Matt Ranostay wrote:
> Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Wouldn't apply automatically so I did it manually.
Anyhow, applied to the togreg branch of iio.git - initially pushed out as testing
for the autobuilders to play tennis with it.
J
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 225860016fed..4324328fd304 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -275,7 +275,7 @@ static int inv_mpu6050_read_raw(struct iio_dev *indio_dev,
> case IIO_TEMP:
> /* wait for stablization */
> msleep(INV_MPU6050_SENSOR_UP_TIME);
> - inv_mpu6050_sensor_show(st, st->reg->temperature,
> + ret = inv_mpu6050_sensor_show(st, st->reg->temperature,
> IIO_MOD_X, val);
> break;
> default:
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/5] iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay
2016-02-22 21:39 ` [PATCH 2/5] iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay Matt Ranostay
@ 2016-02-25 19:54 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2016-02-25 19:54 UTC (permalink / raw)
To: Matt Ranostay; +Cc: linux-iio, daniel.baluta, adriana.reus
On 22/02/16 21:39, Matt Ranostay wrote:
> replace msleep(INV_MPU6050_REG_UP_TIME) with usleep_range calls
> due to fact the wait time is under 20 milliseconds.
>
> Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Applied.
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 3 ++-
> drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 3 ++-
> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 7 ++++++-
> 3 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 4324328fd304..6d4b19dd16f8 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -148,7 +148,8 @@ int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on)
> return result;
>
> if (power_on)
> - msleep(INV_MPU6050_REG_UP_TIME);
> + usleep_range(INV_MPU6050_REG_UP_TIME_MIN,
> + INV_MPU6050_REG_UP_TIME_MAX);
>
> return 0;
> }
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> index af400dd892a9..37cc16d3fca3 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> @@ -68,7 +68,8 @@ static int inv_mpu6050_select_bypass(struct i2c_adapter *adap, void *mux_priv,
> if (ret)
> goto write_error;
>
> - msleep(INV_MPU6050_REG_UP_TIME);
> + usleep_range(INV_MPU6050_REG_UP_TIME_MIN,
> + INV_MPU6050_REG_UP_TIME_MAX);
> }
> if (!ret) {
> st->powerup_count++;
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index fcc2f3dfdfa8..243324dd78de 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -172,10 +172,15 @@ struct inv_mpu6050_state {
> #define INV_MPU6050_BYTES_PER_3AXIS_SENSOR 6
> #define INV_MPU6050_FIFO_COUNT_BYTE 2
> #define INV_MPU6050_FIFO_THRESHOLD 500
> +
> +/* delay time in milliseconds */
> #define INV_MPU6050_POWER_UP_TIME 100
> #define INV_MPU6050_TEMP_UP_TIME 100
> #define INV_MPU6050_SENSOR_UP_TIME 30
> -#define INV_MPU6050_REG_UP_TIME 5
> +
> +/* delay time in microseconds */
> +#define INV_MPU6050_REG_UP_TIME_MIN 5000
> +#define INV_MPU6050_REG_UP_TIME_MAX 10000
>
> #define INV_MPU6050_TEMP_OFFSET 12421
> #define INV_MPU6050_TEMP_SCALE 2941
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 3/5] iio: imu: mpu6050: add missing docstring for int_pin_cfg
2016-02-22 21:39 ` [PATCH 3/5] iio: imu: mpu6050: add missing docstring for int_pin_cfg Matt Ranostay
@ 2016-02-25 19:55 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2016-02-25 19:55 UTC (permalink / raw)
To: Matt Ranostay; +Cc: linux-iio, daniel.baluta, adriana.reus
On 22/02/16 21:39, Matt Ranostay wrote:
> Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Applied.
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index 243324dd78de..a6c45ce459ee 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -39,6 +39,7 @@
> * @int_enable: Interrupt enable register.
> * @pwr_mgmt_1: Controls chip's power state and clock source.
> * @pwr_mgmt_2: Controls power state of individual sensors.
> + * @int_pin_cfg; Controls interrupt pin configuration.
> */
> struct inv_mpu6050_reg_map {
> u8 sample_rate_div;
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 4/5] iio: imu: mpu6050: add calibration offset support
2016-02-22 21:39 ` [PATCH 4/5] iio: imu: mpu6050: add calibration offset support Matt Ranostay
@ 2016-02-25 19:55 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2016-02-25 19:55 UTC (permalink / raw)
To: Matt Ranostay; +Cc: linux-iio, daniel.baluta, adriana.reus
On 22/02/16 21:39, Matt Ranostay wrote:
> Allow setting of the x/y/z axes calibration offsets for the gyroscope
> and accelerometer.
>
> Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Applied - again minor fuzz, but I think it went on top fine.
Jonathan
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 51 ++++++++++++++++++++++++++++--
> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 10 ++++++
> 2 files changed, 59 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 6d4b19dd16f8..3acf0863e558 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -55,6 +55,8 @@ static const struct inv_mpu6050_reg_map reg_set_6050 = {
> .pwr_mgmt_1 = INV_MPU6050_REG_PWR_MGMT_1,
> .pwr_mgmt_2 = INV_MPU6050_REG_PWR_MGMT_2,
> .int_pin_cfg = INV_MPU6050_REG_INT_PIN_CFG,
> + .accl_offset = INV_MPU6050_REG_ACCEL_OFFSET,
> + .gyro_offset = INV_MPU6050_REG_GYRO_OFFSET,
> };
>
> static const struct inv_mpu6050_chip_config chip_config_6050 = {
> @@ -200,6 +202,20 @@ static int inv_mpu6050_init_config(struct iio_dev *indio_dev)
> return result;
> }
>
> +static int inv_mpu6050_sensor_set(struct inv_mpu6050_state *st, int reg,
> + int axis, int val)
> +{
> + int ind, result;
> + __be16 d = cpu_to_be16(val);
> +
> + ind = (axis - IIO_MOD_X) * 2;
> + result = regmap_bulk_write(st->map, reg + ind, (u8 *)&d, 2);
> + if (result)
> + return -EINVAL;
> +
> + return 0;
> +}
> +
> static int inv_mpu6050_sensor_show(struct inv_mpu6050_state *st, int reg,
> int axis, int *val)
> {
> @@ -221,11 +237,12 @@ static int inv_mpu6050_read_raw(struct iio_dev *indio_dev,
> int *val2,
> long mask) {
> struct inv_mpu6050_state *st = iio_priv(indio_dev);
> + int ret = 0;
>
> switch (mask) {
> case IIO_CHAN_INFO_RAW:
> {
> - int ret, result;
> + int result;
>
> ret = IIO_VAL_INT;
> result = 0;
> @@ -321,6 +338,20 @@ error_read_raw:
> default:
> return -EINVAL;
> }
> + case IIO_CHAN_INFO_CALIBBIAS:
> + switch (chan->type) {
> + case IIO_ANGL_VEL:
> + ret = inv_mpu6050_sensor_show(st, st->reg->gyro_offset,
> + chan->channel2, val);
> + return IIO_VAL_INT;
> + case IIO_ACCEL:
> + ret = inv_mpu6050_sensor_show(st, st->reg->accl_offset,
> + chan->channel2, val);
> + return IIO_VAL_INT;
> +
> + default:
> + return -EINVAL;
> + }
> default:
> return -EINVAL;
> }
> @@ -416,6 +447,21 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
> break;
> }
> break;
> + case IIO_CHAN_INFO_CALIBBIAS:
> + switch (chan->type) {
> + case IIO_ANGL_VEL:
> + result = inv_mpu6050_sensor_set(st,
> + st->reg->gyro_offset,
> + chan->channel2, val);
> + break;
> + case IIO_ACCEL:
> + result = inv_mpu6050_sensor_set(st,
> + st->reg->accl_offset,
> + chan->channel2, val);
> + break;
> + default:
> + result = -EINVAL;
> + }
> default:
> result = -EINVAL;
> break;
> @@ -569,7 +615,8 @@ static int inv_mpu6050_validate_trigger(struct iio_dev *indio_dev,
> .modified = 1, \
> .channel2 = _channel2, \
> .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
> - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> + BIT(IIO_CHAN_INFO_CALIBBIAS), \
> .scan_index = _index, \
> .scan_type = { \
> .sign = 's', \
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index a6c45ce459ee..c4e24148c733 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -40,6 +40,8 @@
> * @pwr_mgmt_1: Controls chip's power state and clock source.
> * @pwr_mgmt_2: Controls power state of individual sensors.
> * @int_pin_cfg; Controls interrupt pin configuration.
> + * @accl_offset: Controls the accelerometer calibration offset.
> + * @gyro_offset: Controls the gyroscope calibration offset.
> */
> struct inv_mpu6050_reg_map {
> u8 sample_rate_div;
> @@ -57,6 +59,8 @@ struct inv_mpu6050_reg_map {
> u8 pwr_mgmt_1;
> u8 pwr_mgmt_2;
> u8 int_pin_cfg;
> + u8 accl_offset;
> + u8 gyro_offset;
> };
>
> /*device enum */
> @@ -133,6 +137,9 @@ struct inv_mpu6050_state {
> };
>
> /*register and associated bit definition*/
> +#define INV_MPU6050_REG_ACCEL_OFFSET 0x06
> +#define INV_MPU6050_REG_GYRO_OFFSET 0x13
> +
> #define INV_MPU6050_REG_SAMPLE_RATE_DIV 0x19
> #define INV_MPU6050_REG_CONFIG 0x1A
> #define INV_MPU6050_REG_GYRO_CONFIG 0x1B
> @@ -174,6 +181,9 @@ struct inv_mpu6050_state {
> #define INV_MPU6050_FIFO_COUNT_BYTE 2
> #define INV_MPU6050_FIFO_THRESHOLD 500
>
> +/* mpu6500 registers */
> +#define INV_MPU6500_REG_ACCEL_OFFSET 0x77
> +
> /* delay time in milliseconds */
> #define INV_MPU6050_POWER_UP_TIME 100
> #define INV_MPU6050_TEMP_UP_TIME 100
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/5] iio: imu: mpu6050: add mpu6500 register settings
2016-02-22 21:39 ` [PATCH 5/5] iio: imu: mpu6050: add mpu6500 register settings Matt Ranostay
@ 2016-02-25 19:56 ` Jonathan Cameron
0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2016-02-25 19:56 UTC (permalink / raw)
To: Matt Ranostay; +Cc: linux-iio, daniel.baluta, adriana.reus
On 22/02/16 21:39, Matt Ranostay wrote:
> Signed-off-by: Matt Ranostay <matt.ranostay@intel.com>
Applied to the togreg branch of iio.git - initially pushed out as testing for
the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 32 +++++++++++++++++++++++++++---
> drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 3 ++-
> drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 +-
> drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 3 ++-
> 4 files changed, 34 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index 3acf0863e558..75d93181a16d 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -39,6 +39,26 @@ static const int gyro_scale_6050[] = {133090, 266181, 532362, 1064724};
> */
> static const int accel_scale[] = {598, 1196, 2392, 4785};
>
> +static const struct inv_mpu6050_reg_map reg_set_6500 = {
> + .sample_rate_div = INV_MPU6050_REG_SAMPLE_RATE_DIV,
> + .lpf = INV_MPU6050_REG_CONFIG,
> + .user_ctrl = INV_MPU6050_REG_USER_CTRL,
> + .fifo_en = INV_MPU6050_REG_FIFO_EN,
> + .gyro_config = INV_MPU6050_REG_GYRO_CONFIG,
> + .accl_config = INV_MPU6050_REG_ACCEL_CONFIG,
> + .fifo_count_h = INV_MPU6050_REG_FIFO_COUNT_H,
> + .fifo_r_w = INV_MPU6050_REG_FIFO_R_W,
> + .raw_gyro = INV_MPU6050_REG_RAW_GYRO,
> + .raw_accl = INV_MPU6050_REG_RAW_ACCEL,
> + .temperature = INV_MPU6050_REG_TEMPERATURE,
> + .int_enable = INV_MPU6050_REG_INT_ENABLE,
> + .pwr_mgmt_1 = INV_MPU6050_REG_PWR_MGMT_1,
> + .pwr_mgmt_2 = INV_MPU6050_REG_PWR_MGMT_2,
> + .int_pin_cfg = INV_MPU6050_REG_INT_PIN_CFG,
> + .accl_offset = INV_MPU6500_REG_ACCEL_OFFSET,
> + .gyro_offset = INV_MPU6050_REG_GYRO_OFFSET,
> +};
> +
> static const struct inv_mpu6050_reg_map reg_set_6050 = {
> .sample_rate_div = INV_MPU6050_REG_SAMPLE_RATE_DIV,
> .lpf = INV_MPU6050_REG_CONFIG,
> @@ -68,7 +88,13 @@ static const struct inv_mpu6050_chip_config chip_config_6050 = {
> .accl_fs = INV_MPU6050_FS_02G,
> };
>
> -static const struct inv_mpu6050_hw hw_info[INV_NUM_PARTS] = {
> +static const struct inv_mpu6050_hw hw_info[] = {
> + {
> + .num_reg = 117,
> + .name = "MPU6500",
> + .reg = ®_set_6500,
> + .config = &chip_config_6050,
> + },
> {
> .num_reg = 117,
> .name = "MPU6050",
> @@ -692,7 +718,6 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
> {
> int result;
>
> - st->chip_type = INV_MPU6050;
> st->hw = &hw_info[st->chip_type];
> st->reg = hw_info[st->chip_type].reg;
>
> @@ -726,7 +751,7 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)
> }
>
> int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
> - int (*inv_mpu_bus_setup)(struct iio_dev *))
> + int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type)
> {
> struct inv_mpu6050_state *st;
> struct iio_dev *indio_dev;
> @@ -739,6 +764,7 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
> return -ENOMEM;
>
> st = iio_priv(indio_dev);
> + st->chip_type = chip_type;
> st->powerup_count = 0;
> st->irq = irq;
> st->map = regmap;
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> index 37cc16d3fca3..37aec63113ed 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
> @@ -130,7 +130,8 @@ static int inv_mpu_probe(struct i2c_client *client,
> return PTR_ERR(regmap);
> }
>
> - result = inv_mpu_core_probe(regmap, client->irq, name, NULL);
> + result = inv_mpu_core_probe(regmap, client->irq, name,
> + NULL, id->driver_data);
> if (result < 0)
> return result;
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> index c4e24148c733..e302a49703bf 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
> @@ -277,7 +277,7 @@ int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on);
> int inv_mpu_acpi_create_mux_client(struct i2c_client *client);
> void inv_mpu_acpi_delete_mux_client(struct i2c_client *client);
> int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
> - int (*inv_mpu_bus_setup)(struct iio_dev *));
> + int (*inv_mpu_bus_setup)(struct iio_dev *), int chip_type);
> int inv_mpu_core_remove(struct device *dev);
> int inv_mpu6050_set_power_itg(struct inv_mpu6050_state *st, bool power_on);
> extern const struct dev_pm_ops inv_mpu_pmops;
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> index 5b552a677340..dea6c4361de0 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
> @@ -54,7 +54,8 @@ static int inv_mpu_probe(struct spi_device *spi)
> return PTR_ERR(regmap);
> }
>
> - return inv_mpu_core_probe(regmap, spi->irq, name, inv_mpu_i2c_disable);
> + return inv_mpu_core_probe(regmap, spi->irq, name,
> + inv_mpu_i2c_disable, id->driver_data);
> }
>
> static int inv_mpu_remove(struct spi_device *spi)
>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2016-02-25 19:56 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-22 21:39 [PATCH 0/5] mpu6050: code clean and calibration support Matt Ranostay
2016-02-22 21:39 ` [PATCH 1/5] iio: imu: mpu6050: use inv_mpu6050_sensor_show return code Matt Ranostay
2016-02-22 21:49 ` Daniel Baluta
2016-02-22 21:50 ` Daniel Baluta
2016-02-25 19:50 ` Jonathan Cameron
2016-02-22 21:39 ` [PATCH 2/5] iio: imu: mpu6050: fix INV_MPU6050_REG_UP_TIME delay Matt Ranostay
2016-02-25 19:54 ` Jonathan Cameron
2016-02-22 21:39 ` [PATCH 3/5] iio: imu: mpu6050: add missing docstring for int_pin_cfg Matt Ranostay
2016-02-25 19:55 ` Jonathan Cameron
2016-02-22 21:39 ` [PATCH 4/5] iio: imu: mpu6050: add calibration offset support Matt Ranostay
2016-02-25 19:55 ` Jonathan Cameron
2016-02-22 21:39 ` [PATCH 5/5] iio: imu: mpu6050: add mpu6500 register settings Matt Ranostay
2016-02-25 19:56 ` Jonathan Cameron
2016-02-24 21:08 ` [PATCH 0/5] mpu6050: code clean and calibration support Jonathan Cameron
[not found] ` <DM3PR1201MB1072776083BB71F4F618555CAFA50@DM3PR1201MB1072.namprd12.prod.outlook.com>
2016-02-25 8:45 ` Daniel Baluta
2016-02-25 15:36 ` Ge Gao
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.