Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1391342

[PATCH 2/7] iio: inv_mpu6050: Initial regcache support

From Crestez Dan Leonard <leonard.crestez@intel.com>
Newsgroups linux.kernel
Subject [PATCH 2/7] iio: inv_mpu6050: Initial regcache support
Date 2016-04-29 21:10 +0200
Message-ID <rtlXA-2Jp-25@gated-at.bofh.it> (permalink)
References <rtlXz-2Jp-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 47 ++++++++++++++++++++++++++++++
 drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c  |  5 ----
 drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h  |  1 +
 drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c  |  5 ----
 4 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index b269b37..5918c23 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -116,6 +116,53 @@ static const struct inv_mpu6050_hw hw_info[] = {
 	},
 };
 
+static bool inv_mpu6050_volatile_reg(struct device *dev, unsigned int reg)
+{
+	if (reg >= INV_MPU6050_REG_RAW_ACCEL && reg < INV_MPU6050_REG_RAW_ACCEL + 6)
+		return true;
+	if (reg >= INV_MPU6050_REG_RAW_GYRO && reg < INV_MPU6050_REG_RAW_GYRO + 6)
+		return true;
+	switch (reg) {
+	case INV_MPU6050_REG_TEMPERATURE:
+	case INV_MPU6050_REG_TEMPERATURE + 1:
+	case INV_MPU6050_REG_USER_CTRL:
+	case INV_MPU6050_REG_PWR_MGMT_1:
+	case INV_MPU6050_REG_FIFO_COUNT_H:
+	case INV_MPU6050_REG_FIFO_COUNT_H + 1:
+	case INV_MPU6050_REG_FIFO_R_W:
+		return true;
+	default:
+		return false;
+	}
+}
+
+static bool inv_mpu6050_precious_reg(struct device *dev, unsigned int reg)
+{
+	switch (reg) {
+	case INV_MPU6050_REG_FIFO_R_W:
+		return true;
+	default:
+		return false;
+	}
+}
+
+/*
+ * Common regmap config for inv_mpu devices
+ *
+ * The current volatile/precious registers are common among supported devices.
+ * When that changes the volatile/precious callbacks should go through the
+ * inv_mpu6050_reg_map structs.
+ */
+const struct regmap_config inv_mpu_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+
+	.cache_type = REGCACHE_RBTREE,
+	.volatile_reg = inv_mpu6050_volatile_reg,
+	.precious_reg = inv_mpu6050_precious_reg,
+};
+EXPORT_SYMBOL_GPL(inv_mpu_regmap_config);
+
 int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask)
 {
 	unsigned int d, mgmt_1;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index 1a424a6..1a8d1a5 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -20,11 +20,6 @@
 #include <linux/module.h>
 #include "inv_mpu_iio.h"
 
-static const struct regmap_config inv_mpu_regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-};
-
 /*
  * The i2c read/write needs to happen in unlocked mode. As the parent
  * adapter is common. If we use locked versions, it will fail as
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
index 47ca25b..297b0ef 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
@@ -291,3 +291,4 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
 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;
+extern const struct regmap_config inv_mpu_regmap_config;
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
index 190a4a5..b3bd977 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
@@ -17,11 +17,6 @@
 #include <linux/iio/iio.h>
 #include "inv_mpu_iio.h"
 
-static const struct regmap_config inv_mpu_regmap_config = {
-	.reg_bits = 8,
-	.val_bits = 8,
-};
-
 static int inv_mpu_i2c_disable(struct iio_dev *indio_dev)
 {
 	struct inv_mpu6050_state *st = iio_priv(indio_dev);
-- 
2.5.5

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 0/7] iio: inv_mpu6050: Support i2c master and external readings Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-04-29 21:10 +0200
  [RFC 5/7] iio: inv_mpu6050: Add support for auxiliary I2C master Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-04-29 21:10 +0200
    Re: [RFC 5/7] iio: inv_mpu6050: Add support for auxiliary I2C master Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:40 +0200
      Re: [RFC 5/7] iio: inv_mpu6050: Add support for auxiliary I2C master Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-05-05 14:40 +0200
        Re: [RFC 5/7] iio: inv_mpu6050: Add support for auxiliary I2C master Rob Herring <robh+dt@kernel.org> - 2016-05-05 15:20 +0200
    Re: [RFC 5/7] iio: inv_mpu6050: Add support for auxiliary I2C master Peter Rosin <peda@axentia.se> - 2016-05-02 17:40 +0200
  [PATCH 4/7] iio: inv_mpu6050: Cache non-volatile bits of user_ctrl Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-04-29 21:10 +0200
    Re: [PATCH 4/7] iio: inv_mpu6050: Cache non-volatile bits of  user_ctrl Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:40 +0200
  [PATCH 6/7] iio: inv_mpu6050: Check channel configuration on preenable Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-04-29 21:10 +0200
    Re: [PATCH 6/7] iio: inv_mpu6050: Check channel configuration on  preenable Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:30 +0200
      Re: [PATCH 6/7] iio: inv_mpu6050: Check channel configuration on  preenable Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-05-03 15:10 +0200
        Re: [PATCH 6/7] iio: inv_mpu6050: Check channel configuration on  preenable Jonathan Cameron <jic23@kernel.org> - 2016-05-04 16:40 +0200
          Re: [PATCH 6/7] iio: inv_mpu6050: Check channel configuration on  preenable Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-05-04 17:40 +0200
            Re: [PATCH 6/7] iio: inv_mpu6050: Check channel configuration on preenable Jonathan Cameron <jic23@jic23.retrosnub.co.uk> - 2016-05-04 20:30 +0200
  [PATCH 1/7] iio: inv_mpu6050: Do burst reads using spi/i2c directly Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-04-29 21:10 +0200
    Re: [PATCH 1/7] iio: inv_mpu6050: Do burst reads using spi/i2c  directly Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:30 +0200
      Re: [PATCH 1/7] iio: inv_mpu6050: Do burst reads using spi/i2c  directly Mark Brown <broonie@kernel.org> - 2016-05-02 17:30 +0200
  [RFC 7/7] iio: inv_mpu6050: Add support for external sensors Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-04-29 21:10 +0200
    Re: [RFC 7/7] iio: inv_mpu6050: Add support for external sensors Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:40 +0200
  [PATCH 3/7] iio: inv_mpu6050: Only toggle DATA_RDY_EN in inv_reset_fifo Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-04-29 21:10 +0200
    Re: [PATCH 3/7] iio: inv_mpu6050: Only toggle DATA_RDY_EN in  inv_reset_fifo Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:30 +0200
  [PATCH 2/7] iio: inv_mpu6050: Initial regcache support Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-04-29 21:10 +0200
    Re: [PATCH 2/7] iio: inv_mpu6050: Initial regcache support Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:40 +0200
  Re: [RFC 0/7] iio: inv_mpu6050: Support i2c master and external  readings Jonathan Cameron <jic23@kernel.org> - 2016-05-01 23:40 +0200
    Re: [RFC 0/7] iio: inv_mpu6050: Support i2c master and external  readings Mark Brown <broonie@kernel.org> - 2016-05-02 17:30 +0200
      Re: [RFC 0/7] iio: inv_mpu6050: Support i2c master and external  readings Crestez Dan Leonard <leonard.crestez@intel.com> - 2016-05-03 13:30 +0200
        Re: [RFC 0/7] iio: inv_mpu6050: Support i2c master and external  readings Mark Brown <broonie@kernel.org> - 2016-05-03 13:40 +0200

csiph-web