summaryrefslogtreecommitdiffstats
path: root/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-03-18 11:33:12 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-03-18 11:33:12 +0100
commit281d90e24f1378967531d715decf6b81ecba664e (patch)
tree8da0b30ba74495d31b66db1aa3af6c3d3d57a8c0 /drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
parent09dd629eeabb8af4d261ba9eb4b21d7e440362bc (diff)
parentfe297f8f048a7a0663479dcf6447ec450b53b905 (diff)
Merge tag 'iio-5.7a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes: First set of new IIO device support, fatures and cleanups for the 5.7 cycle Includes changes for the counter subsystem Core Feature * Explicitly handle sysfs values in dB, including correctly handling the needed postfix dB. * Add a TODO to suggest suitable activities for new contributors to IIO now the vast majority of drivers are out of staging (and the remaining ones there are 'hard'). Also update the TODO in staging to remove stale entries. Staging graduations * ad7192 ADC. New device support * ad5770r - New driver for this 6 channel DAC including DT bindings. * ad8366 - Add supprot for the hmc1119 attenuator. * al3010 - New driver supporting this Dyna-image light sensors. - Power management and DT bindings added in additional patches. * atlas-sensor - Add support for atlas DO-SM device. Reads disolved oxygen in a solution. * gpap002x00f - New driver and bindings to support the GP2AP002A00F and GP2AP002S00F light and proximity sensors. There is some limited existing support in input. The intent is to drop this driver once IIO driver is in place. * hmc425a - New driver for this attenuator. * icp10100 - New driver for this presure sensor. * ltc2632 - Add support for the ltc2636 8 channel DAC. Includes bindings and some tidying up of the driver. * inv_mpu6050 - Support IAM20680, ICM20609, ICM20689 and ICM20690. Includes related tidy up and rework of low pass filter bandwidth handling to give suitable values for all chips. Binding conversions to yaml or missing bindings docs. * atlas-sensor, including consolidation of previous 3 separate docs into 1. * ad7923, previously no doc. * max1363, split into max1238 and max1363 to simplify yaml. * stm32-adc Features * (counter) 104-quad-8 - Support a filter clock prescaler. - Support reporting of encoder cable status. * ad7124 - Low pass filter support. - Debugfs interface to access registers directly. * ad8366 - Support control of hardware gain. * inv_mpu6050 - Runtime pm with autosuspend. * npcm adc - Add reset support. This is a breaking change if DT is not in sync, however this device is a BMC so the ecosystem is closed enought that this should not be a problem. * srf04 - Add power management with DT bindings for the GPIO. * stm32-timer-trigger - Power management. * (counter) stm32-timer-cnt - Power management. * vcnl4000 - Enable runtime PM for devices that don't use on demand measurement. Cleanups and minor fixes * core - Avoid double read when using debugfs. Whilst we provide no guarantees on lack of side effects using the debugfs interfaces, this one is generate unexpected results so let us tidy it up. * dac/Kconfig - Alphabetic order. * ad5755 - Grammar and minor other fixes. * ad7124 - Fail probe if get_voltage fails as no meaningful readings can be had without knowing the external reference. - Switch to selection between different channel attributes rather than building the arrays at runtime. - Remove the spi_device_id table as the driver cannot be probled without more information that can be provided without dt. - Update sysfs docs to provide more inormation and bring remaining docs for this part out of staging. * ad9292 - Use new SPI transfer delay structure. * adis library - Add unlocked version of adis_initial_startup and refactor the function. - Add a product ID santiy check. - Add support for different self test registers. - Use new SPI delay structure. - Add new docs and tidy up existing. * adis16136 - Initialize adis_data statically. * adis16400 - Initialize adis_data statically. * adis16460 - Use core __adis_initial_Startup now it supports everything needed. * adis16480 - Initialize adis_data statically. - Use core __adis_initial_startup now it supports everything needed. * al3320a - Add missing DT binding docs. - Tidy up code formatting. - Simplify error paths using devm_add_action_or_reset. - Ensure autoloading works by adding the of_match_table. * atlas-sensor - Drop false requirement for interrupt line, the value can be polled using a sysfs or hrtimer type trigger. * exynos-adc - Silence warning message on deferring probe. * gp2ap002 - Greatly simplify the Lux LUT. - Reorder actions around buffer setup and tear down as part of a sub-system wide standardization of these. * inv_mpu6050 - Various lttle tidyups. - Simpliy I2C aux MUX handling by enabling it only at startup. It never needs to be disabled. - Simplify polling rate when magnetometer enabled by putting only under control of userspace. - Always execute full reset on devices supporting spi. It does no harm when using i2c and makes for simpler code. - Reduce over the top sleep times for vddio regulator power up. - Greatly simplify power and engine management. - Fix some delays in polled reads (only visible due to other changes) - Stop preventing sampling rate changes whilst running as there is no adverse consequence of doing so. - Prevent attempting to read the temperature if neither accel nor gyro is enabled. * lmp9100 - Reorder actions around buffer setup and tear down as part of a sub-system wide standardization of these. * max1118 - Use new SPI transfer delay structure. * mcp320x - Use new SPI transfer delay structure. * si1133 - Read full 24 bit signed integer instead o dropping last 8 bits of value. Not a critical fix as just adds precision. * st_sensors - Use st_sensors_dev_name_probe instead of open coded version in st_accel - Handle potential memory allocation failure. * st_lsm6dsx - Fix some wrong structure element naming in documentation. - Add missing return value check. * stm32_timer_cnt - Drop some unused left over IIO headers from this count subsystem driver. - Ensure the clock is enabled in master mode. Theoretical issue rather than one known to happen in the wild. * tlc4541 - Use new SPI delay structure. * tag 'iio-5.7a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (98 commits) iio: dac: Kconfig: sort symbols alphabetically iio: light: gp2ap020a00f: fix iio_triggered_buffer_{predisable,postenable} positions iio: potentiostat: lmp9100: fix iio_triggered_buffer_{predisable,postenable} positions iio: trigger: stm32-timer: add power management support iio: trigger: stm32-timer: rename enabled flag iio: add a TODO counter: 104-quad-8: Support Differential Encoder Cable Status counter: 104-quad-8: Support Filter Clock Prescaler iio: pressure: icp10100: add driver for InvenSense ICP-101xx iio: industrialio-core: Fix debugfs read iio: imu: adis: add a note better explaining state_lock iio: imu: adis: update 'adis_data' struct doc-string iio: imu: adis: add doc-string for 'adis' struct iio: imu: adis_buffer: Use new structure for SPI transfer delays iio: adc: ti-tlc4541: Use new structure for SPI transfer delays iio: adc: mcp320x: Use new structure for SPI transfer delays iio: adc: max1118: Use new structure for SPI transfer delays iio: adc: ad9292: Use new structure for SPI transfer delays iio: adc: exynos: Silence warning about regulators during deferred probe staging: iio: update TODO ...
Diffstat (limited to 'drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c')
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c111
1 files changed, 47 insertions, 64 deletions
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
index f47a28b4be23..6993d3b87bb0 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
@@ -10,6 +10,7 @@
#include <linux/iio/iio.h>
#include <linux/module.h>
#include <linux/of_device.h>
+#include <linux/property.h>
#include "inv_mpu_iio.h"
static const struct regmap_config inv_mpu_regmap_config = {
@@ -19,62 +20,19 @@ static const struct regmap_config inv_mpu_regmap_config = {
static int inv_mpu6050_select_bypass(struct i2c_mux_core *muxc, u32 chan_id)
{
- struct iio_dev *indio_dev = i2c_mux_priv(muxc);
- struct inv_mpu6050_state *st = iio_priv(indio_dev);
- int ret;
-
- mutex_lock(&st->lock);
-
- ret = inv_mpu6050_set_power_itg(st, true);
- if (ret)
- goto error_unlock;
-
- ret = regmap_write(st->map, st->reg->int_pin_cfg,
- st->irq_mask | INV_MPU6050_BIT_BYPASS_EN);
-
-error_unlock:
- mutex_unlock(&st->lock);
-
- return ret;
-}
-
-static int inv_mpu6050_deselect_bypass(struct i2c_mux_core *muxc, u32 chan_id)
-{
- struct iio_dev *indio_dev = i2c_mux_priv(muxc);
- struct inv_mpu6050_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->lock);
-
- /* It doesn't really matter if any of the calls fail */
- regmap_write(st->map, st->reg->int_pin_cfg, st->irq_mask);
- inv_mpu6050_set_power_itg(st, false);
-
- mutex_unlock(&st->lock);
-
return 0;
}
-static const char *inv_mpu_match_acpi_device(struct device *dev,
- enum inv_devices *chip_id)
-{
- const struct acpi_device_id *id;
-
- id = acpi_match_device(dev->driver->acpi_match_table, dev);
- if (!id)
- return NULL;
-
- *chip_id = (int)id->driver_data;
-
- return dev_name(dev);
-}
-
static bool inv_mpu_i2c_aux_bus(struct device *dev)
{
struct inv_mpu6050_state *st = iio_priv(dev_get_drvdata(dev));
switch (st->chip_type) {
case INV_ICM20608:
+ case INV_ICM20609:
+ case INV_ICM20689:
case INV_ICM20602:
+ case INV_IAM20680:
/* no i2c auxiliary bus on the chip */
return false;
case INV_MPU9150:
@@ -89,19 +47,20 @@ static bool inv_mpu_i2c_aux_bus(struct device *dev)
}
}
-/*
- * MPU9xxx magnetometer support requires to disable i2c auxiliary bus support.
- * To ensure backward compatibility with existing setups, do not disable
- * i2c auxiliary bus if it used.
- * Check for i2c-gate node in devicetree and set magnetometer disabled.
- * Only MPU6500 is supported by ACPI, no need to check.
- */
-static int inv_mpu_magn_disable(struct iio_dev *indio_dev)
+static int inv_mpu_i2c_aux_setup(struct iio_dev *indio_dev)
{
struct inv_mpu6050_state *st = iio_priv(indio_dev);
struct device *dev = indio_dev->dev.parent;
struct device_node *mux_node;
+ int ret;
+ /*
+ * MPU9xxx magnetometer support requires to disable i2c auxiliary bus.
+ * To ensure backward compatibility with existing setups, do not disable
+ * i2c auxiliary bus if it used.
+ * Check for i2c-gate node in devicetree and set magnetometer disabled.
+ * Only MPU6500 is supported by ACPI, no need to check.
+ */
switch (st->chip_type) {
case INV_MPU9150:
case INV_MPU9250:
@@ -117,6 +76,14 @@ static int inv_mpu_magn_disable(struct iio_dev *indio_dev)
break;
}
+ /* enable i2c bypass when using i2c auxiliary bus */
+ if (inv_mpu_i2c_aux_bus(dev)) {
+ ret = regmap_write(st->map, st->reg->int_pin_cfg,
+ st->irq_mask | INV_MPU6050_BIT_BYPASS_EN);
+ if (ret)
+ return ret;
+ }
+
return 0;
}
@@ -130,6 +97,7 @@ static int inv_mpu_magn_disable(struct iio_dev *indio_dev)
static int inv_mpu_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
+ const void *match;
struct inv_mpu6050_state *st;
int result;
enum inv_devices chip_type;
@@ -140,18 +108,14 @@ static int inv_mpu_probe(struct i2c_client *client,
I2C_FUNC_SMBUS_I2C_BLOCK))
return -EOPNOTSUPP;
- if (client->dev.of_node) {
- chip_type = (enum inv_devices)
- of_device_get_match_data(&client->dev);
+ match = device_get_match_data(&client->dev);
+ if (match) {
+ chip_type = (enum inv_devices)match;
name = client->name;
} else if (id) {
chip_type = (enum inv_devices)
id->driver_data;
name = id->name;
- } else if (ACPI_HANDLE(&client->dev)) {
- name = inv_mpu_match_acpi_device(&client->dev, &chip_type);
- if (!name)
- return -ENODEV;
} else {
return -ENOSYS;
}
@@ -164,7 +128,7 @@ static int inv_mpu_probe(struct i2c_client *client,
}
result = inv_mpu_core_probe(regmap, client->irq, name,
- inv_mpu_magn_disable, chip_type);
+ inv_mpu_i2c_aux_setup, chip_type);
if (result < 0)
return result;
@@ -173,8 +137,7 @@ static int inv_mpu_probe(struct i2c_client *client,
/* declare i2c auxiliary bus */
st->muxc = i2c_mux_alloc(client->adapter, &client->dev,
1, 0, I2C_MUX_LOCKED | I2C_MUX_GATE,
- inv_mpu6050_select_bypass,
- inv_mpu6050_deselect_bypass);
+ inv_mpu6050_select_bypass, NULL);
if (!st->muxc)
return -ENOMEM;
st->muxc->priv = dev_get_drvdata(&client->dev);
@@ -218,7 +181,11 @@ static const struct i2c_device_id inv_mpu_id[] = {
{"mpu9250", INV_MPU9250},
{"mpu9255", INV_MPU9255},
{"icm20608", INV_ICM20608},
+ {"icm20609", INV_ICM20609},
+ {"icm20689", INV_ICM20689},
{"icm20602", INV_ICM20602},
+ {"icm20690", INV_ICM20690},
+ {"iam20680", INV_IAM20680},
{}
};
@@ -254,9 +221,25 @@ static const struct of_device_id inv_of_match[] = {
.data = (void *)INV_ICM20608
},
{
+ .compatible = "invensense,icm20609",
+ .data = (void *)INV_ICM20609
+ },
+ {
+ .compatible = "invensense,icm20689",
+ .data = (void *)INV_ICM20689
+ },
+ {
.compatible = "invensense,icm20602",
.data = (void *)INV_ICM20602
},
+ {
+ .compatible = "invensense,icm20690",
+ .data = (void *)INV_ICM20690
+ },
+ {
+ .compatible = "invensense,iam20680",
+ .data = (void *)INV_IAM20680
+ },
{ }
};
MODULE_DEVICE_TABLE(of, inv_of_match);