diff options
Diffstat (limited to 'drivers/iio/pressure')
-rw-r--r-- | drivers/iio/pressure/Kconfig | 10 | ||||
-rw-r--r-- | drivers/iio/pressure/Makefile | 1 | ||||
-rw-r--r-- | drivers/iio/pressure/abp060mg.c | 276 | ||||
-rw-r--r-- | drivers/iio/pressure/mpl3115.c | 26 | ||||
-rw-r--r-- | drivers/iio/pressure/ms5611_core.c | 19 | ||||
-rw-r--r-- | drivers/iio/pressure/st_pressure_core.c | 257 | ||||
-rw-r--r-- | drivers/iio/pressure/zpa2326.c | 4 |
7 files changed, 404 insertions, 189 deletions
diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 15cd416365c1..bd8d96b96771 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -5,6 +5,16 @@ menu "Pressure sensors" +config ABP060MG + tristate "Honeywell ABP pressure sensor driver" + depends on I2C + help + Say yes here to build support for the Honeywell ABP pressure + sensors. + + To compile this driver as a module, choose M here: the module + will be called abp060mg. + config BMP280 tristate "Bosch Sensortec BMP180/BMP280 pressure sensor I2C driver" depends on (I2C || SPI_MASTER) diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index fff77185a5cc..de3dbc81dc5a 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -3,6 +3,7 @@ # # When adding new entries keep the list in alphabetical order +obj-$(CONFIG_ABP060MG) += abp060mg.o obj-$(CONFIG_BMP280) += bmp280.o bmp280-objs := bmp280-core.o bmp280-regmap.o obj-$(CONFIG_BMP280_I2C) += bmp280-i2c.o diff --git a/drivers/iio/pressure/abp060mg.c b/drivers/iio/pressure/abp060mg.c new file mode 100644 index 000000000000..43bdd0b9155f --- /dev/null +++ b/drivers/iio/pressure/abp060mg.c @@ -0,0 +1,276 @@ +/* + * Copyright (C) 2016 - Marcin Malagowski <mrc@bourne.st> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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. + */ +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/err.h> +#include <linux/i2c.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/iio/iio.h> + +#define ABP060MG_ERROR_MASK 0xC000 +#define ABP060MG_RESP_TIME_MS 40 +#define ABP060MG_MIN_COUNTS 1638 /* = 0x0666 (10% of u14) */ +#define ABP060MG_MAX_COUNTS 14745 /* = 0x3999 (90% of u14) */ +#define ABP060MG_NUM_COUNTS (ABP060MG_MAX_COUNTS - ABP060MG_MIN_COUNTS) + +enum abp_variant { + /* gage [kPa] */ + ABP006KG, ABP010KG, ABP016KG, ABP025KG, ABP040KG, ABP060KG, ABP100KG, + ABP160KG, ABP250KG, ABP400KG, ABP600KG, ABP001GG, + /* differential [kPa] */ + ABP006KD, ABP010KD, ABP016KD, ABP025KD, ABP040KD, ABP060KD, ABP100KD, + ABP160KD, ABP250KD, ABP400KD, + /* gage [psi] */ + ABP001PG, ABP005PG, ABP015PG, ABP030PG, ABP060PG, ABP100PG, ABP150PG, + /* differential [psi] */ + ABP001PD, ABP005PD, ABP015PD, ABP030PD, ABP060PD, +}; + +struct abp_config { + int min; + int max; +}; + +static struct abp_config abp_config[] = { + /* mbar & kPa variants */ + [ABP006KG] = { .min = 0, .max = 6000 }, + [ABP010KG] = { .min = 0, .max = 10000 }, + [ABP016KG] = { .min = 0, .max = 16000 }, + [ABP025KG] = { .min = 0, .max = 25000 }, + [ABP040KG] = { .min = 0, .max = 40000 }, + [ABP060KG] = { .min = 0, .max = 60000 }, + [ABP100KG] = { .min = 0, .max = 100000 }, + [ABP160KG] = { .min = 0, .max = 160000 }, + [ABP250KG] = { .min = 0, .max = 250000 }, + [ABP400KG] = { .min = 0, .max = 400000 }, + [ABP600KG] = { .min = 0, .max = 600000 }, + [ABP001GG] = { .min = 0, .max = 1000000 }, + [ABP006KD] = { .min = -6000, .max = 6000 }, + [ABP010KD] = { .min = -10000, .max = 10000 }, + [ABP016KD] = { .min = -16000, .max = 16000 }, + [ABP025KD] = { .min = -25000, .max = 25000 }, + [ABP040KD] = { .min = -40000, .max = 40000 }, + [ABP060KD] = { .min = -60000, .max = 60000 }, + [ABP100KD] = { .min = -100000, .max = 100000 }, + [ABP160KD] = { .min = -160000, .max = 160000 }, + [ABP250KD] = { .min = -250000, .max = 250000 }, + [ABP400KD] = { .min = -400000, .max = 400000 }, + /* psi variants (1 psi ~ 6895 Pa) */ + [ABP001PG] = { .min = 0, .max = 6985 }, + [ABP005PG] = { .min = 0, .max = 34474 }, + [ABP015PG] = { .min = 0, .max = 103421 }, + [ABP030PG] = { .min = 0, .max = 206843 }, + [ABP060PG] = { .min = 0, .max = 413686 }, + [ABP100PG] = { .min = 0, .max = 689476 }, + [ABP150PG] = { .min = 0, .max = 1034214 }, + [ABP001PD] = { .min = -6895, .max = 6895 }, + [ABP005PD] = { .min = -34474, .max = 34474 }, + [ABP015PD] = { .min = -103421, .max = 103421 }, + [ABP030PD] = { .min = -206843, .max = 206843 }, + [ABP060PD] = { .min = -413686, .max = 413686 }, +}; + +struct abp_state { + struct i2c_client *client; + struct mutex lock; + + /* + * bus-dependent MEASURE_REQUEST length. + * If no SMBUS_QUICK support, need to send dummy byte + */ + int mreq_len; + + /* model-dependent values (calculated on probe) */ + int scale; + int offset; +}; + +static const struct iio_chan_spec abp060mg_channels[] = { + { + .type = IIO_PRESSURE, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE), + }, +}; + +static int abp060mg_get_measurement(struct abp_state *state, int *val) +{ + struct i2c_client *client = state->client; + __be16 buf[2]; + u16 pressure; + int ret; + + buf[0] = 0; + ret = i2c_master_send(client, (u8 *)&buf, state->mreq_len); + if (ret < 0) + return ret; + + msleep_interruptible(ABP060MG_RESP_TIME_MS); + + ret = i2c_master_recv(client, (u8 *)&buf, sizeof(buf)); + if (ret < 0) + return ret; + + pressure = be16_to_cpu(buf[0]); + if (pressure & ABP060MG_ERROR_MASK) + return -EIO; + + if (pressure < ABP060MG_MIN_COUNTS || pressure > ABP060MG_MAX_COUNTS) + return -EIO; + + *val = pressure; + + return IIO_VAL_INT; +} + +static int abp060mg_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct abp_state *state = iio_priv(indio_dev); + int ret; + + mutex_lock(&state->lock); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = abp060mg_get_measurement(state, val); + break; + case IIO_CHAN_INFO_OFFSET: + *val = state->offset; + ret = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_SCALE: + *val = state->scale; + *val2 = ABP060MG_NUM_COUNTS * 1000; /* to kPa */ + ret = IIO_VAL_FRACTIONAL; + break; + default: + ret = -EINVAL; + break; + } + + mutex_unlock(&state->lock); + return ret; +} + +static const struct iio_info abp060mg_info = { + .driver_module = THIS_MODULE, + .read_raw = abp060mg_read_raw, +}; + +static void abp060mg_init_device(struct iio_dev *indio_dev, unsigned long id) +{ + struct abp_state *state = iio_priv(indio_dev); + struct abp_config *cfg = &abp_config[id]; + + state->scale = cfg->max - cfg->min; + state->offset = -ABP060MG_MIN_COUNTS; + + if (cfg->min < 0) /* differential */ + state->offset -= ABP060MG_NUM_COUNTS >> 1; +} + +static int abp060mg_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct iio_dev *indio_dev; + struct abp_state *state; + unsigned long cfg_id = id->driver_data; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*state)); + if (!indio_dev) + return -ENOMEM; + + state = iio_priv(indio_dev); + i2c_set_clientdata(client, state); + state->client = client; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK)) + state->mreq_len = 1; + + abp060mg_init_device(indio_dev, cfg_id); + + indio_dev->dev.parent = &client->dev; + indio_dev->name = dev_name(&client->dev); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &abp060mg_info; + + indio_dev->channels = abp060mg_channels; + indio_dev->num_channels = ARRAY_SIZE(abp060mg_channels); + + mutex_init(&state->lock); + + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct i2c_device_id abp060mg_id_table[] = { + /* mbar & kPa variants (abp060m [60 mbar] == abp006k [6 kPa]) */ + /* gage: */ + { "abp060mg", ABP006KG }, { "abp006kg", ABP006KG }, + { "abp100mg", ABP010KG }, { "abp010kg", ABP010KG }, + { "abp160mg", ABP016KG }, { "abp016kg", ABP016KG }, + { "abp250mg", ABP025KG }, { "abp025kg", ABP025KG }, + { "abp400mg", ABP040KG }, { "abp040kg", ABP040KG }, + { "abp600mg", ABP060KG }, { "abp060kg", ABP060KG }, + { "abp001bg", ABP100KG }, { "abp100kg", ABP100KG }, + { "abp1_6bg", ABP160KG }, { "abp160kg", ABP160KG }, + { "abp2_5bg", ABP250KG }, { "abp250kg", ABP250KG }, + { "abp004bg", ABP400KG }, { "abp400kg", ABP400KG }, + { "abp006bg", ABP600KG }, { "abp600kg", ABP600KG }, + { "abp010bg", ABP001GG }, { "abp001gg", ABP001GG }, + /* differential: */ + { "abp060md", ABP006KD }, { "abp006kd", ABP006KD }, + { "abp100md", ABP010KD }, { "abp010kd", ABP010KD }, + { "abp160md", ABP016KD }, { "abp016kd", ABP016KD }, + { "abp250md", ABP025KD }, { "abp025kd", ABP025KD }, + { "abp400md", ABP040KD }, { "abp040kd", ABP040KD }, + { "abp600md", ABP060KD }, { "abp060kd", ABP060KD }, + { "abp001bd", ABP100KD }, { "abp100kd", ABP100KD }, + { "abp1_6bd", ABP160KD }, { "abp160kd", ABP160KD }, + { "abp2_5bd", ABP250KD }, { "abp250kd", ABP250KD }, + { "abp004bd", ABP400KD }, { "abp400kd", ABP400KD }, + /* psi variants */ + /* gage: */ + { "abp001pg", ABP001PG }, + { "abp005pg", ABP005PG }, + { "abp015pg", ABP015PG }, + { "abp030pg", ABP030PG }, + { "abp060pg", ABP060PG }, + { "abp100pg", ABP100PG }, + { "abp150pg", ABP150PG }, + /* differential: */ + { "abp001pd", ABP001PD }, + { "abp005pd", ABP005PD }, + { "abp015pd", ABP015PD }, + { "abp030pd", ABP030PD }, + { "abp060pd", ABP060PD }, + { /* empty */ }, +}; +MODULE_DEVICE_TABLE(i2c, abp060mg_id_table); + +static struct i2c_driver abp060mg_driver = { + .driver = { + .name = "abp060mg", + }, + .probe = abp060mg_probe, + .id_table = abp060mg_id_table, +}; +module_i2c_driver(abp060mg_driver); + +MODULE_AUTHOR("Marcin Malagowski <mrc@bourne.st>"); +MODULE_DESCRIPTION("Honeywell ABP pressure sensor driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index 6392d7b62841..cc3f84139157 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -82,8 +82,9 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: - if (iio_buffer_enabled(indio_dev)) - return -EBUSY; + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; switch (chan->type) { case IIO_PRESSURE: /* in 0.25 pascal / LSB */ @@ -91,32 +92,39 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev, ret = mpl3115_request(data); if (ret < 0) { mutex_unlock(&data->lock); - return ret; + break; } ret = i2c_smbus_read_i2c_block_data(data->client, MPL3115_OUT_PRESS, 3, (u8 *) &tmp); mutex_unlock(&data->lock); if (ret < 0) - return ret; + break; *val = be32_to_cpu(tmp) >> 12; - return IIO_VAL_INT; + ret = IIO_VAL_INT; + break; case IIO_TEMP: /* in 0.0625 celsius / LSB */ mutex_lock(&data->lock); ret = mpl3115_request(data); if (ret < 0) { mutex_unlock(&data->lock); - return ret; + break; } ret = i2c_smbus_read_i2c_block_data(data->client, MPL3115_OUT_TEMP, 2, (u8 *) &tmp); mutex_unlock(&data->lock); if (ret < 0) - return ret; + break; *val = sign_extend32(be32_to_cpu(tmp) >> 20, 11); - return IIO_VAL_INT; + ret = IIO_VAL_INT; + break; default: - return -EINVAL; + ret = -EINVAL; + break; } + + iio_device_release_direct_mode(indio_dev); + return ret; + case IIO_CHAN_INFO_SCALE: switch (chan->type) { case IIO_PRESSURE: diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c index a74ed1f0c880..6bd53e702667 100644 --- a/drivers/iio/pressure/ms5611_core.c +++ b/drivers/iio/pressure/ms5611_core.c @@ -392,17 +392,14 @@ static int ms5611_init(struct iio_dev *indio_dev) /* Enable attached regulator if any. */ st->vdd = devm_regulator_get(indio_dev->dev.parent, "vdd"); - if (!IS_ERR(st->vdd)) { - ret = regulator_enable(st->vdd); - if (ret) { - dev_err(indio_dev->dev.parent, - "failed to enable Vdd supply: %d\n", ret); - return ret; - } - } else { - ret = PTR_ERR(st->vdd); - if (ret != -ENODEV) - return ret; + if (IS_ERR(st->vdd)) + return PTR_ERR(st->vdd); + + ret = regulator_enable(st->vdd); + if (ret) { + dev_err(indio_dev->dev.parent, + "failed to enable Vdd supply: %d\n", ret); + return ret; } ret = ms5611_reset(indio_dev); diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 55df9a75eb3a..e19e0787864c 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -112,115 +112,24 @@ #define ST_PRESS_1_OUT_XL_ADDR 0x28 #define ST_TEMP_1_OUT_L_ADDR 0x2b -/* - * CUSTOM VALUES FOR LPS331AP SENSOR - * See LPS331AP datasheet: - * http://www2.st.com/resource/en/datasheet/lps331ap.pdf - */ -#define ST_PRESS_LPS331AP_WAI_EXP 0xbb -#define ST_PRESS_LPS331AP_ODR_ADDR 0x20 -#define ST_PRESS_LPS331AP_ODR_MASK 0x70 -#define ST_PRESS_LPS331AP_ODR_AVL_1HZ_VAL 0x01 -#define ST_PRESS_LPS331AP_ODR_AVL_7HZ_VAL 0x05 -#define ST_PRESS_LPS331AP_ODR_AVL_13HZ_VAL 0x06 -#define ST_PRESS_LPS331AP_ODR_AVL_25HZ_VAL 0x07 -#define ST_PRESS_LPS331AP_PW_ADDR 0x20 -#define ST_PRESS_LPS331AP_PW_MASK 0x80 -#define ST_PRESS_LPS331AP_FS_ADDR 0x23 -#define ST_PRESS_LPS331AP_FS_MASK 0x30 -#define ST_PRESS_LPS331AP_BDU_ADDR 0x20 -#define ST_PRESS_LPS331AP_BDU_MASK 0x04 -#define ST_PRESS_LPS331AP_DRDY_IRQ_ADDR 0x22 -#define ST_PRESS_LPS331AP_DRDY_IRQ_INT1_MASK 0x04 -#define ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK 0x20 -#define ST_PRESS_LPS331AP_IHL_IRQ_ADDR 0x22 -#define ST_PRESS_LPS331AP_IHL_IRQ_MASK 0x80 -#define ST_PRESS_LPS331AP_OD_IRQ_ADDR 0x22 -#define ST_PRESS_LPS331AP_OD_IRQ_MASK 0x40 -#define ST_PRESS_LPS331AP_MULTIREAD_BIT true - -/* - * CUSTOM VALUES FOR THE OBSOLETE LPS001WP SENSOR - */ - /* LPS001WP pressure resolution */ #define ST_PRESS_LPS001WP_LSB_PER_MBAR 16UL /* LPS001WP temperature resolution */ #define ST_PRESS_LPS001WP_LSB_PER_CELSIUS 64UL - -#define ST_PRESS_LPS001WP_WAI_EXP 0xba -#define ST_PRESS_LPS001WP_ODR_ADDR 0x20 -#define ST_PRESS_LPS001WP_ODR_MASK 0x30 -#define ST_PRESS_LPS001WP_ODR_AVL_1HZ_VAL 0x01 -#define ST_PRESS_LPS001WP_ODR_AVL_7HZ_VAL 0x02 -#define ST_PRESS_LPS001WP_ODR_AVL_13HZ_VAL 0x03 -#define ST_PRESS_LPS001WP_PW_ADDR 0x20 -#define ST_PRESS_LPS001WP_PW_MASK 0x40 +/* LPS001WP pressure gain */ #define ST_PRESS_LPS001WP_FS_AVL_PRESS_GAIN \ (100000000UL / ST_PRESS_LPS001WP_LSB_PER_MBAR) -#define ST_PRESS_LPS001WP_BDU_ADDR 0x20 -#define ST_PRESS_LPS001WP_BDU_MASK 0x04 -#define ST_PRESS_LPS001WP_MULTIREAD_BIT true +/* LPS001WP pressure and temp L addresses */ #define ST_PRESS_LPS001WP_OUT_L_ADDR 0x28 #define ST_TEMP_LPS001WP_OUT_L_ADDR 0x2a -/* - * CUSTOM VALUES FOR LPS25H SENSOR - * See LPS25H datasheet: - * http://www2.st.com/resource/en/datasheet/lps25h.pdf - */ -#define ST_PRESS_LPS25H_WAI_EXP 0xbd -#define ST_PRESS_LPS25H_ODR_ADDR 0x20 -#define ST_PRESS_LPS25H_ODR_MASK 0x70 -#define ST_PRESS_LPS25H_ODR_AVL_1HZ_VAL 0x01 -#define ST_PRESS_LPS25H_ODR_AVL_7HZ_VAL 0x02 -#define ST_PRESS_LPS25H_ODR_AVL_13HZ_VAL 0x03 -#define ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL 0x04 -#define ST_PRESS_LPS25H_PW_ADDR 0x20 -#define ST_PRESS_LPS25H_PW_MASK 0x80 -#define ST_PRESS_LPS25H_BDU_ADDR 0x20 -#define ST_PRESS_LPS25H_BDU_MASK 0x04 -#define ST_PRESS_LPS25H_DRDY_IRQ_ADDR 0x23 -#define ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK 0x01 -#define ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK 0x10 -#define ST_PRESS_LPS25H_IHL_IRQ_ADDR 0x22 -#define ST_PRESS_LPS25H_IHL_IRQ_MASK 0x80 -#define ST_PRESS_LPS25H_OD_IRQ_ADDR 0x22 -#define ST_PRESS_LPS25H_OD_IRQ_MASK 0x40 -#define ST_PRESS_LPS25H_MULTIREAD_BIT true +/* LPS25H pressure and temp L addresses */ #define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28 #define ST_TEMP_LPS25H_OUT_L_ADDR 0x2b -/* - * CUSTOM VALUES FOR LPS22HB SENSOR - * See LPS22HB datasheet: - * http://www2.st.com/resource/en/datasheet/lps22hb.pdf - */ - /* LPS22HB temperature sensitivity */ #define ST_PRESS_LPS22HB_LSB_PER_CELSIUS 100UL -#define ST_PRESS_LPS22HB_WAI_EXP 0xb1 -#define ST_PRESS_LPS22HB_ODR_ADDR 0x10 -#define ST_PRESS_LPS22HB_ODR_MASK 0x70 -#define ST_PRESS_LPS22HB_ODR_AVL_1HZ_VAL 0x01 -#define ST_PRESS_LPS22HB_ODR_AVL_10HZ_VAL 0x02 -#define ST_PRESS_LPS22HB_ODR_AVL_25HZ_VAL 0x03 -#define ST_PRESS_LPS22HB_ODR_AVL_50HZ_VAL 0x04 -#define ST_PRESS_LPS22HB_ODR_AVL_75HZ_VAL 0x05 -#define ST_PRESS_LPS22HB_PW_ADDR 0x10 -#define ST_PRESS_LPS22HB_PW_MASK 0x70 -#define ST_PRESS_LPS22HB_BDU_ADDR 0x10 -#define ST_PRESS_LPS22HB_BDU_MASK 0x02 -#define ST_PRESS_LPS22HB_DRDY_IRQ_ADDR 0x12 -#define ST_PRESS_LPS22HB_DRDY_IRQ_INT1_MASK 0x04 -#define ST_PRESS_LPS22HB_DRDY_IRQ_INT2_MASK 0x08 -#define ST_PRESS_LPS22HB_IHL_IRQ_ADDR 0x12 -#define ST_PRESS_LPS22HB_IHL_IRQ_MASK 0x80 -#define ST_PRESS_LPS22HB_OD_IRQ_ADDR 0x12 -#define ST_PRESS_LPS22HB_OD_IRQ_MASK 0x40 -#define ST_PRESS_LPS22HB_MULTIREAD_BIT true - static const struct iio_chan_spec st_press_1_channels[] = { { .type = IIO_PRESSURE, @@ -321,7 +230,12 @@ static const struct iio_chan_spec st_press_lps22hb_channels[] = { static const struct st_sensor_settings st_press_sensors_settings[] = { { - .wai = ST_PRESS_LPS331AP_WAI_EXP, + /* + * CUSTOM VALUES FOR LPS331AP SENSOR + * See LPS331AP datasheet: + * http://www2.st.com/resource/en/datasheet/lps331ap.pdf + */ + .wai = 0xbb, .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LPS331AP_PRESS_DEV_NAME, @@ -329,24 +243,24 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { .ch = (struct iio_chan_spec *)st_press_1_channels, .num_ch = ARRAY_SIZE(st_press_1_channels), .odr = { - .addr = ST_PRESS_LPS331AP_ODR_ADDR, - .mask = ST_PRESS_LPS331AP_ODR_MASK, + .addr = 0x20, + .mask = 0x70, .odr_avl = { - { 1, ST_PRESS_LPS331AP_ODR_AVL_1HZ_VAL, }, - { 7, ST_PRESS_LPS331AP_ODR_AVL_7HZ_VAL, }, - { 13, ST_PRESS_LPS331AP_ODR_AVL_13HZ_VAL, }, - { 25, ST_PRESS_LPS331AP_ODR_AVL_25HZ_VAL, }, + { .hz = 1, .value = 0x01 }, + { .hz = 7, .value = 0x05 }, + { .hz = 13, .value = 0x06 }, + { .hz = 25, .value = 0x07 }, }, }, .pw = { - .addr = ST_PRESS_LPS331AP_PW_ADDR, - .mask = ST_PRESS_LPS331AP_PW_MASK, + .addr = 0x20, + .mask = 0x80, .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE, .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, }, .fs = { - .addr = ST_PRESS_LPS331AP_FS_ADDR, - .mask = ST_PRESS_LPS331AP_FS_MASK, + .addr = 0x23, + .mask = 0x30, .fs_avl = { /* * Pressure and temperature sensitivity values @@ -360,24 +274,27 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { }, }, .bdu = { - .addr = ST_PRESS_LPS331AP_BDU_ADDR, - .mask = ST_PRESS_LPS331AP_BDU_MASK, + .addr = 0x20, + .mask = 0x04, }, .drdy_irq = { - .addr = ST_PRESS_LPS331AP_DRDY_IRQ_ADDR, - .mask_int1 = ST_PRESS_LPS331AP_DRDY_IRQ_INT1_MASK, - .mask_int2 = ST_PRESS_LPS331AP_DRDY_IRQ_INT2_MASK, - .addr_ihl = ST_PRESS_LPS331AP_IHL_IRQ_ADDR, - .mask_ihl = ST_PRESS_LPS331AP_IHL_IRQ_MASK, - .addr_od = ST_PRESS_LPS331AP_OD_IRQ_ADDR, - .mask_od = ST_PRESS_LPS331AP_OD_IRQ_MASK, + .addr = 0x22, + .mask_int1 = 0x04, + .mask_int2 = 0x20, + .addr_ihl = 0x22, + .mask_ihl = 0x80, + .addr_od = 0x22, + .mask_od = 0x40, .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, }, - .multi_read_bit = ST_PRESS_LPS331AP_MULTIREAD_BIT, + .multi_read_bit = true, .bootime = 2, }, { - .wai = ST_PRESS_LPS001WP_WAI_EXP, + /* + * CUSTOM VALUES FOR LPS001WP SENSOR + */ + .wai = 0xba, .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LPS001WP_PRESS_DEV_NAME, @@ -385,17 +302,17 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { .ch = (struct iio_chan_spec *)st_press_lps001wp_channels, .num_ch = ARRAY_SIZE(st_press_lps001wp_channels), .odr = { - .addr = ST_PRESS_LPS001WP_ODR_ADDR, - .mask = ST_PRESS_LPS001WP_ODR_MASK, + .addr = 0x20, + .mask = 0x30, .odr_avl = { - { 1, ST_PRESS_LPS001WP_ODR_AVL_1HZ_VAL, }, - { 7, ST_PRESS_LPS001WP_ODR_AVL_7HZ_VAL, }, - { 13, ST_PRESS_LPS001WP_ODR_AVL_13HZ_VAL, }, + { .hz = 1, .value = 0x01 }, + { .hz = 7, .value = 0x02 }, + { .hz = 13, .value = 0x03 }, }, }, .pw = { - .addr = ST_PRESS_LPS001WP_PW_ADDR, - .mask = ST_PRESS_LPS001WP_PW_MASK, + .addr = 0x20, + .mask = 0x40, .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE, .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, }, @@ -413,17 +330,22 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { }, }, .bdu = { - .addr = ST_PRESS_LPS001WP_BDU_ADDR, - .mask = ST_PRESS_LPS001WP_BDU_MASK, + .addr = 0x20, + .mask = 0x04, }, .drdy_irq = { .addr = 0, }, - .multi_read_bit = ST_PRESS_LPS001WP_MULTIREAD_BIT, + .multi_read_bit = true, .bootime = 2, }, { - .wai = ST_PRESS_LPS25H_WAI_EXP, + /* + * CUSTOM VALUES FOR LPS25H SENSOR + * See LPS25H datasheet: + * http://www2.st.com/resource/en/datasheet/lps25h.pdf + */ + .wai = 0xbd, .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LPS25H_PRESS_DEV_NAME, @@ -431,18 +353,18 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { .ch = (struct iio_chan_spec *)st_press_1_channels, .num_ch = ARRAY_SIZE(st_press_1_channels), .odr = { - .addr = ST_PRESS_LPS25H_ODR_ADDR, - .mask = ST_PRESS_LPS25H_ODR_MASK, + .addr = 0x20, + .mask = 0x70, .odr_avl = { - { 1, ST_PRESS_LPS25H_ODR_AVL_1HZ_VAL, }, - { 7, ST_PRESS_LPS25H_ODR_AVL_7HZ_VAL, }, - { 13, ST_PRESS_LPS25H_ODR_AVL_13HZ_VAL, }, - { 25, ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL, }, + { .hz = 1, .value = 0x01 }, + { .hz = 7, .value = 0x02 }, + { .hz = 13, .value = 0x03 }, + { .hz = 25, .value = 0x04 }, }, }, .pw = { - .addr = ST_PRESS_LPS25H_PW_ADDR, - .mask = ST_PRESS_LPS25H_PW_MASK, + .addr = 0x20, + .mask = 0x80, .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE, .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, }, @@ -460,24 +382,29 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { }, }, .bdu = { - .addr = ST_PRESS_LPS25H_BDU_ADDR, - .mask = ST_PRESS_LPS25H_BDU_MASK, + .addr = 0x20, + .mask = 0x04, }, .drdy_irq = { - .addr = ST_PRESS_LPS25H_DRDY_IRQ_ADDR, - .mask_int1 = ST_PRESS_LPS25H_DRDY_IRQ_INT1_MASK, - .mask_int2 = ST_PRESS_LPS25H_DRDY_IRQ_INT2_MASK, - .addr_ihl = ST_PRESS_LPS25H_IHL_IRQ_ADDR, - .mask_ihl = ST_PRESS_LPS25H_IHL_IRQ_MASK, - .addr_od = ST_PRESS_LPS25H_OD_IRQ_ADDR, - .mask_od = ST_PRESS_LPS25H_OD_IRQ_MASK, + .addr = 0x23, + .mask_int1 = 0x01, + .mask_int2 = 0x10, + .addr_ihl = 0x22, + .mask_ihl = 0x80, + .addr_od = 0x22, + .mask_od = 0x40, .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, }, - .multi_read_bit = ST_PRESS_LPS25H_MULTIREAD_BIT, + .multi_read_bit = true, .bootime = 2, }, { - .wai = ST_PRESS_LPS22HB_WAI_EXP, + /* + * CUSTOM VALUES FOR LPS22HB SENSOR + * See LPS22HB datasheet: + * http://www2.st.com/resource/en/datasheet/lps22hb.pdf + */ + .wai = 0xb1, .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LPS22HB_PRESS_DEV_NAME, @@ -485,19 +412,19 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { .ch = (struct iio_chan_spec *)st_press_lps22hb_channels, .num_ch = ARRAY_SIZE(st_press_lps22hb_channels), .odr = { - .addr = ST_PRESS_LPS22HB_ODR_ADDR, - .mask = ST_PRESS_LPS22HB_ODR_MASK, + .addr = 0x10, + .mask = 0x70, .odr_avl = { - { 1, ST_PRESS_LPS22HB_ODR_AVL_1HZ_VAL, }, - { 10, ST_PRESS_LPS22HB_ODR_AVL_10HZ_VAL, }, - { 25, ST_PRESS_LPS22HB_ODR_AVL_25HZ_VAL, }, - { 50, ST_PRESS_LPS22HB_ODR_AVL_50HZ_VAL, }, - { 75, ST_PRESS_LPS22HB_ODR_AVL_75HZ_VAL, }, + { .hz = 1, .value = 0x01 }, + { .hz = 10, .value = 0x02 }, + { .hz = 25, .value = 0x03 }, + { .hz = 50, .value = 0x04 }, + { .hz = 75, .value = 0x05 }, }, }, .pw = { - .addr = ST_PRESS_LPS22HB_PW_ADDR, - .mask = ST_PRESS_LPS22HB_PW_MASK, + .addr = 0x10, + .mask = 0x70, .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, }, .fs = { @@ -514,20 +441,20 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { }, }, .bdu = { - .addr = ST_PRESS_LPS22HB_BDU_ADDR, - .mask = ST_PRESS_LPS22HB_BDU_MASK, + .addr = 0x10, + .mask = 0x02, }, .drdy_irq = { - .addr = ST_PRESS_LPS22HB_DRDY_IRQ_ADDR, - .mask_int1 = ST_PRESS_LPS22HB_DRDY_IRQ_INT1_MASK, - .mask_int2 = ST_PRESS_LPS22HB_DRDY_IRQ_INT2_MASK, - .addr_ihl = ST_PRESS_LPS22HB_IHL_IRQ_ADDR, - .mask_ihl = ST_PRESS_LPS22HB_IHL_IRQ_MASK, - .addr_od = ST_PRESS_LPS22HB_OD_IRQ_ADDR, - .mask_od = ST_PRESS_LPS22HB_OD_IRQ_MASK, + .addr = 0x12, + .mask_int1 = 0x04, + .mask_int2 = 0x08, + .addr_ihl = 0x12, + .mask_ihl = 0x80, + .addr_od = 0x12, + .mask_od = 0x40, .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, }, - .multi_read_bit = ST_PRESS_LPS22HB_MULTIREAD_BIT, + .multi_read_bit = true, }, }; diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c index 19d2eb46fda6..c720c3ac0b9b 100644 --- a/drivers/iio/pressure/zpa2326.c +++ b/drivers/iio/pressure/zpa2326.c @@ -147,12 +147,8 @@ struct zpa2326_private { #define zpa2326_warn(_idev, _format, _arg...) \ dev_warn(_idev->dev.parent, _format, ##_arg) -#ifdef DEBUG #define zpa2326_dbg(_idev, _format, _arg...) \ dev_dbg(_idev->dev.parent, _format, ##_arg) -#else -#define zpa2326_dbg(_idev, _format, _arg...) -#endif bool zpa2326_isreg_writeable(struct device *dev, unsigned int reg) { |