diff options
Diffstat (limited to 'drivers/iio/accel')
-rw-r--r-- | drivers/iio/accel/Kconfig | 50 | ||||
-rw-r--r-- | drivers/iio/accel/bma180.c | 18 | ||||
-rw-r--r-- | drivers/iio/accel/bmc150-accel-core.c | 23 | ||||
-rw-r--r-- | drivers/iio/accel/cros_ec_accel_legacy.c | 40 | ||||
-rw-r--r-- | drivers/iio/accel/kxcjk-1013.c | 15 | ||||
-rw-r--r-- | drivers/iio/accel/kxsd9.c | 4 | ||||
-rw-r--r-- | drivers/iio/accel/mma8452.c | 2 | ||||
-rw-r--r-- | drivers/iio/accel/st_accel.h | 2 | ||||
-rw-r--r-- | drivers/iio/accel/st_accel_core.c | 78 | ||||
-rw-r--r-- | drivers/iio/accel/st_accel_i2c.c | 5 |
10 files changed, 178 insertions, 59 deletions
diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 898839ca164a..62a970a20219 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -6,28 +6,28 @@ menu "Accelerometers" config ADIS16201 - tristate "Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer" - depends on SPI - select IIO_ADIS_LIB - select IIO_ADIS_LIB_BUFFER if IIO_BUFFER - help - Say Y here to build support for Analog Devices adis16201 dual-axis - digital inclinometer and accelerometer. + tristate "Analog Devices ADIS16201 Dual-Axis Digital Inclinometer and Accelerometer" + depends on SPI + select IIO_ADIS_LIB + select IIO_ADIS_LIB_BUFFER if IIO_BUFFER + help + Say Y here to build support for Analog Devices adis16201 dual-axis + digital inclinometer and accelerometer. - To compile this driver as a module, say M here: the module will - be called adis16201. + To compile this driver as a module, say M here: the module will + be called adis16201. config ADIS16209 - tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" - depends on SPI - select IIO_ADIS_LIB - select IIO_ADIS_LIB_BUFFER if IIO_BUFFER - help - Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer - and accelerometer. + tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" + depends on SPI + select IIO_ADIS_LIB + select IIO_ADIS_LIB_BUFFER if IIO_BUFFER + help + Say Y here to build support for Analog Devices adis16209 dual-axis digital inclinometer + and accelerometer. - To compile this driver as a module, say M here: the module will be - called adis16209. + To compile this driver as a module, say M here: the module will be + called adis16209. config ADXL345 tristate @@ -100,16 +100,16 @@ config BMA180 module will be called bma180. config BMA220 - tristate "Bosch BMA220 3-Axis Accelerometer Driver" + tristate "Bosch BMA220 3-Axis Accelerometer Driver" depends on SPI select IIO_BUFFER select IIO_TRIGGERED_BUFFER - help - Say yes here to add support for the Bosch BMA220 triaxial - acceleration sensor. + help + Say yes here to add support for the Bosch BMA220 triaxial + acceleration sensor. - To compile this driver as a module, choose M here: the - module will be called bma220_spi. + To compile this driver as a module, choose M here: the + module will be called bma220_spi. config BMC150_ACCEL tristate "Bosch BMC150 Accelerometer Driver" @@ -223,7 +223,7 @@ config IIO_ST_ACCEL_3AXIS Say yes here to build support for STMicroelectronics accelerometers: LSM303DLH, LSM303DLHC, LIS3DH, LSM330D, LSM330DL, LSM330DLC, LIS331DLH, LSM303DL, LSM303DLM, LSM330, LIS2DH12, H3LIS331DL, - LNG2DM, LIS3DE + LNG2DM, LIS3DE, LIS2DE12 This driver can also be built as a module. If so, these modules will be created: diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index cb9765a3de60..f9720a1e8a7c 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -116,6 +116,7 @@ struct bma180_data { struct i2c_client *client; struct iio_trigger *trig; const struct bma180_part_info *part_info; + struct iio_mount_matrix orientation; struct mutex mutex; bool sleep_state; int scale; @@ -561,6 +562,15 @@ static int bma180_set_power_mode(struct iio_dev *indio_dev, return ret; } +static const struct iio_mount_matrix * +bma180_accel_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct bma180_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + static const struct iio_enum bma180_power_mode_enum = { .items = bma180_power_modes, .num_items = ARRAY_SIZE(bma180_power_modes), @@ -571,7 +581,8 @@ static const struct iio_enum bma180_power_mode_enum = { static const struct iio_chan_spec_ext_info bma180_ext_info[] = { IIO_ENUM("power_mode", true, &bma180_power_mode_enum), IIO_ENUM_AVAILABLE("power_mode", &bma180_power_mode_enum), - { }, + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bma180_accel_get_mount_matrix), + { } }; #define BMA180_ACC_CHANNEL(_axis, _bits) { \ @@ -722,6 +733,11 @@ static int bma180_probe(struct i2c_client *client, chip = id->driver_data; data->part_info = &bma180_part_info[chip]; + ret = iio_read_mount_matrix(&client->dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + ret = data->part_info->chip_config(data); if (ret < 0) goto err_chip_disable; diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 383c802eb5b8..44d7c49fe2a1 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -204,6 +204,7 @@ struct bmc150_accel_data { int ev_enable_state; int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */ const struct bmc150_accel_chip_info *chip_info; + struct iio_mount_matrix orientation; }; static const struct { @@ -393,7 +394,7 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on) if (ret < 0) { dev_err(dev, - "Failed: bmc150_accel_set_power_state for %d\n", on); + "Failed: %s for %d\n", __func__, on); if (on) pm_runtime_put_noidle(dev); @@ -796,6 +797,20 @@ static ssize_t bmc150_accel_get_fifo_state(struct device *dev, return sprintf(buf, "%d\n", state); } +static const struct iio_mount_matrix * +bmc150_accel_get_mount_matrix(const struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct bmc150_accel_data *data = iio_priv(indio_dev); + + return &data->orientation; +} + +static const struct iio_chan_spec_ext_info bmc150_accel_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, bmc150_accel_get_mount_matrix), + { } +}; + static IIO_CONST_ATTR(hwfifo_watermark_min, "1"); static IIO_CONST_ATTR(hwfifo_watermark_max, __stringify(BMC150_ACCEL_FIFO_LENGTH)); @@ -978,6 +993,7 @@ static const struct iio_event_spec bmc150_accel_event = { .shift = 16 - (bits), \ .endianness = IIO_LE, \ }, \ + .ext_info = bmc150_accel_ext_info, \ .event_spec = &bmc150_accel_event, \ .num_event_specs = 1 \ } @@ -1555,6 +1571,11 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, data->regmap = regmap; + ret = iio_read_mount_matrix(dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + ret = bmc150_accel_chip_init(data); if (ret < 0) return ret; diff --git a/drivers/iio/accel/cros_ec_accel_legacy.c b/drivers/iio/accel/cros_ec_accel_legacy.c index 063e89eff791..46bb2e421bb9 100644 --- a/drivers/iio/accel/cros_ec_accel_legacy.c +++ b/drivers/iio/accel/cros_ec_accel_legacy.c @@ -1,17 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Driver for older Chrome OS EC accelerometer * * Copyright 2017 Google, Inc * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * * This driver uses the memory mapper cros-ec interface to communicate * with the Chrome OS EC about accelerometer data. * Accelerometer access is presented through iio sysfs. @@ -29,7 +21,6 @@ #include <linux/mfd/cros_ec_commands.h> #include <linux/module.h> #include <linux/slab.h> -#include <linux/sysfs.h> #include <linux/platform_device.h> #define DRV_NAME "cros-ec-accel-legacy" @@ -353,7 +344,7 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev) struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev); struct iio_dev *indio_dev; struct cros_ec_accel_legacy_state *state; - int ret, i; + int ret; if (!ec || !ec->ec_dev) { dev_warn(&pdev->dev, "No EC device found.\n"); @@ -381,20 +372,17 @@ static int cros_ec_accel_legacy_probe(struct platform_device *pdev) * Present the channel using HTML5 standard: * need to invert X and Y and invert some lid axis. */ - for (i = X ; i < MAX_AXIS; i++) { - switch (i) { - case X: - ec_accel_channels[X].scan_index = Y; - case Y: - ec_accel_channels[Y].scan_index = X; - case Z: - ec_accel_channels[Z].scan_index = Z; - } - if (state->sensor_num == MOTIONSENSE_LOC_LID && i != Y) - state->sign[i] = -1; - else - state->sign[i] = 1; - } + ec_accel_channels[X].scan_index = Y; + ec_accel_channels[Y].scan_index = X; + ec_accel_channels[Z].scan_index = Z; + + state->sign[Y] = 1; + + if (state->sensor_num == MOTIONSENSE_LOC_LID) + state->sign[X] = state->sign[Z] = -1; + else + state->sign[X] = state->sign[Z] = 1; + indio_dev->num_channels = ARRAY_SIZE(ec_accel_channels); indio_dev->dev.parent = &pdev->dev; indio_dev->info = &cros_ec_accel_legacy_info; @@ -419,5 +407,5 @@ module_platform_driver(cros_ec_accel_platform_driver); MODULE_DESCRIPTION("ChromeOS EC legacy accelerometer driver"); MODULE_AUTHOR("Gwendal Grignou <gwendal@chromium.org>"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" DRV_NAME); diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 7096e577b23f..2922a2e88a1b 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -451,7 +451,7 @@ static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on) } if (ret < 0) { dev_err(&data->client->dev, - "Failed: kxcjk1013_set_power_state for %d\n", on); + "Failed: %s for %d\n", __func__, on); if (on) pm_runtime_put_noidle(&data->client->dev); return ret; @@ -1437,6 +1437,8 @@ static int kxcjk1013_resume(struct device *dev) mutex_lock(&data->mutex); ret = kxcjk1013_set_mode(data, OPERATION); + if (ret == 0) + ret = kxcjk1013_set_range(data, data->range); mutex_unlock(&data->mutex); return ret; @@ -1489,6 +1491,7 @@ static const struct acpi_device_id kx_acpi_match[] = { {"KXCJ1013", KXCJK1013}, {"KXCJ1008", KXCJ91008}, {"KXCJ9000", KXCJ91008}, + {"KIOX0008", KXCJ91008}, {"KIOX0009", KXTJ21009}, {"KIOX000A", KXCJ91008}, {"KIOX010A", KXCJ91008}, /* KXCJ91008 inside the display of a 2-in-1 */ @@ -1510,10 +1513,20 @@ static const struct i2c_device_id kxcjk1013_id[] = { MODULE_DEVICE_TABLE(i2c, kxcjk1013_id); +static const struct of_device_id kxcjk1013_of_match[] = { + { .compatible = "kionix,kxcjk1013", }, + { .compatible = "kionix,kxcj91008", }, + { .compatible = "kionix,kxtj21009", }, + { .compatible = "kionix,kxtf9", }, + { } +}; +MODULE_DEVICE_TABLE(of, kxcjk1013_of_match); + static struct i2c_driver kxcjk1013_driver = { .driver = { .name = KXCJK1013_DRV_NAME, .acpi_match_table = ACPI_PTR(kx_acpi_match), + .of_match_table = kxcjk1013_of_match, .pm = &kxcjk1013_pm_ops, }, .probe = kxcjk1013_probe, diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index 0c0df4fce420..70c60db62247 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -420,9 +420,7 @@ int kxsd9_common_probe(struct device *dev, indio_dev->available_scan_masks = kxsd9_scan_masks; /* Read the mounting matrix, if present */ - ret = of_iio_read_mount_matrix(dev, - "mount-matrix", - &st->orientation); + ret = iio_read_mount_matrix(dev, "mount-matrix", &st->orientation); if (ret) return ret; diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 302781126bc6..00e100fc845a 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1580,7 +1580,7 @@ static int mma8452_probe(struct i2c_client *client, case FXLS8471_DEVICE_ID: if (ret == data->chip_info->chip_id) break; - /* else: fall through */ + /* fall through */ default: ret = -ENODEV; goto disable_regulators; diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index fd53258656ca..9d25955af58e 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h @@ -34,6 +34,7 @@ enum st_accel_type { LIS3LV02DL, LIS2DW12, LIS3DHH, + LIS2DE12, ST_ACCEL_MAX, }; @@ -57,6 +58,7 @@ enum st_accel_type { #define LIS2DW12_ACCEL_DEV_NAME "lis2dw12" #define LIS3DHH_ACCEL_DEV_NAME "lis3dhh" #define LIS3DE_ACCEL_DEV_NAME "lis3de" +#define LIS2DE12_ACCEL_DEV_NAME "lis2de12" /** * struct st_sensors_platform_data - default accel platform data diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index a3c0916479fa..5ff04d9755d5 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -831,6 +831,82 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { .multi_read_bit = false, .bootime = 2, }, + { + .wai = 0x33, + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, + .sensors_supported = { + [0] = LIS2DE12_ACCEL_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_accel_8bit_channels, + .odr = { + .addr = 0x20, + .mask = 0xf0, + .odr_avl = { + { .hz = 1, .value = 0x01, }, + { .hz = 10, .value = 0x02, }, + { .hz = 25, .value = 0x03, }, + { .hz = 50, .value = 0x04, }, + { .hz = 100, .value = 0x05, }, + { .hz = 200, .value = 0x06, }, + { .hz = 400, .value = 0x07, }, + { .hz = 1620, .value = 0x08, }, + { .hz = 5376, .value = 0x09, }, + }, + }, + .pw = { + .addr = 0x20, + .mask = 0xf0, + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, + }, + .enable_axis = { + .addr = ST_SENSORS_DEFAULT_AXIS_ADDR, + .mask = ST_SENSORS_DEFAULT_AXIS_MASK, + }, + .fs = { + .addr = 0x23, + .mask = 0x30, + .fs_avl = { + [0] = { + .num = ST_ACCEL_FS_AVL_2G, + .value = 0x00, + .gain = IIO_G_TO_M_S_2(15600), + }, + [1] = { + .num = ST_ACCEL_FS_AVL_4G, + .value = 0x01, + .gain = IIO_G_TO_M_S_2(31200), + }, + [2] = { + .num = ST_ACCEL_FS_AVL_8G, + .value = 0x02, + .gain = IIO_G_TO_M_S_2(62500), + }, + [3] = { + .num = ST_ACCEL_FS_AVL_16G, + .value = 0x03, + .gain = IIO_G_TO_M_S_2(187500), + }, + }, + }, + .drdy_irq = { + .int1 = { + .addr = 0x22, + .mask = 0x10, + }, + .addr_ihl = 0x25, + .mask_ihl = 0x02, + .stat_drdy = { + .addr = ST_SENSORS_DEFAULT_STAT_ADDR, + .mask = 0x07, + }, + }, + .sim = { + .addr = 0x23, + .value = BIT(0), + }, + .multi_read_bit = true, + .bootime = 2, + }, }; static int st_accel_read_raw(struct iio_dev *indio_dev, @@ -992,7 +1068,7 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev, goto out; val = elements[i].integer.value; - if (val < 0 || val > 2) + if (val > 2) goto out; /* Avoiding full matrix multiplication, we simply reorder the diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index de8ae4327094..4e54477ccf24 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -102,6 +102,10 @@ static const struct of_device_id st_accel_of_match[] = { .compatible = "st,lis3de", .data = LIS3DE_ACCEL_DEV_NAME, }, + { + .compatible = "st,lis2de12", + .data = LIS2DE12_ACCEL_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_accel_of_match); @@ -140,6 +144,7 @@ static const struct i2c_device_id st_accel_id_table[] = { { LIS3LV02DL_ACCEL_DEV_NAME }, { LIS2DW12_ACCEL_DEV_NAME }, { LIS3DE_ACCEL_DEV_NAME }, + { LIS2DE12_ACCEL_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(i2c, st_accel_id_table); |