Skip to content

Commit

Permalink
Merge tag 'staging-5.5-rc2' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/gregkh/staging

Pull staging/IIO fixes from Greg KH:
 "Here are a number of small staging and IIO driver fixes for reported
  issues for 5.5-rc2

  Nothing major, a bunch of tiny IIO driver issues resolved, and some
  staging driver fixes for things that people ran into with 5.5-rc1.
  Full details are in the shortlog.

  All of these have been in linux-next with no reported issues"

* tag 'staging-5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (28 commits)
  fbtft: Fix the initialization from property algorithm
  staging: rtl8712: fix interface sanity check
  staging: rtl8188eu: fix interface sanity check
  staging: gigaset: add endpoint-type sanity check
  staging: gigaset: fix illegal free on probe errors
  staging: gigaset: fix general protection fault on probe
  staging: vchiq: call unregister_chrdev_region() when driver registration fails
  staging: exfat: fix multiple definition error of `rename_file'
  staging/wlan-ng: add CRC32 dependency in Kconfig
  staging: hp100: Fix build error without ETHERNET
  staging: fbtft: Do not hardcode SPI CS polarity inversion
  staging: exfat: properly support discard in clr_alloc_bitmap()
  staging/octeon: Mark Ethernet driver as BROKEN
  iio: adc: max9611: Fix too short conversion time delay
  iio: ad7949: fix channels mixups
  iio: imu: st_lsm6dsx: do not power-off accel if events are enabled
  iio: imu: st_lsm6dsx: track hw FIFO buffering with fifo_mask
  iio: imu: st_lsm6dsx: fix decimation factor estimation
  iio: imu: inv_mpu6050: fix temperature reporting using bad unit
  iio: humidity: hdc100x: fix IIO_HUMIDITYRELATIVE channel reporting
  ...
  • Loading branch information
Linus Torvalds committed Dec 14, 2019
2 parents a1b85b3 + 4bcd9ea commit aff2a52
Show file tree
Hide file tree
Showing 28 changed files with 198 additions and 90 deletions.
5 changes: 3 additions & 2 deletions Documentation/devicetree/bindings/iio/adc/adi,ad7292.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/adc/adi,ad7292.yaml#
Expand Down Expand Up @@ -53,7 +53,8 @@ patternProperties:
description: |
The channel number. It can have up to 8 channels numbered from 0 to 7.
items:
maximum: 7
- minimum: 0
maximum: 7

diff-channels:
description: see Documentation/devicetree/bindings/iio/adc/adc.txt
Expand Down
8 changes: 6 additions & 2 deletions drivers/iio/accel/st_accel_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ static const struct iio_trigger_ops st_accel_trigger_ops = {
#define ST_ACCEL_TRIGGER_OPS NULL
#endif

#ifdef CONFIG_ACPI
static const struct iio_mount_matrix *
get_mount_matrix(const struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
Expand All @@ -1012,7 +1013,6 @@ static const struct iio_chan_spec_ext_info mount_matrix_ext_info[] = {
static int apply_acpi_orientation(struct iio_dev *indio_dev,
struct iio_chan_spec *channels)
{
#ifdef CONFIG_ACPI
struct st_sensor_data *adata = iio_priv(indio_dev);
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
struct acpi_device *adev;
Expand Down Expand Up @@ -1140,10 +1140,14 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev,
out:
kfree(buffer.pointer);
return ret;
}
#else /* !CONFIG_ACPI */
static int apply_acpi_orientation(struct iio_dev *indio_dev,
struct iio_chan_spec *channels)
{
return 0;
#endif
}
#endif

/*
* st_accel_get_settings() - get sensor settings from device name
Expand Down
7 changes: 6 additions & 1 deletion drivers/iio/adc/ad7124.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#define AD7124_STATUS_POR_FLAG_MSK BIT(4)

/* AD7124_ADC_CONTROL */
#define AD7124_ADC_CTRL_REF_EN_MSK BIT(8)
#define AD7124_ADC_CTRL_REF_EN(x) FIELD_PREP(AD7124_ADC_CTRL_REF_EN_MSK, x)
#define AD7124_ADC_CTRL_PWR_MSK GENMASK(7, 6)
#define AD7124_ADC_CTRL_PWR(x) FIELD_PREP(AD7124_ADC_CTRL_PWR_MSK, x)
#define AD7124_ADC_CTRL_MODE_MSK GENMASK(5, 2)
Expand Down Expand Up @@ -424,7 +426,10 @@ static int ad7124_init_channel_vref(struct ad7124_state *st,
break;
case AD7124_INT_REF:
st->channel_config[channel_number].vref_mv = 2500;
break;
st->adc_control &= ~AD7124_ADC_CTRL_REF_EN_MSK;
st->adc_control |= AD7124_ADC_CTRL_REF_EN(1);
return ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL,
2, st->adc_control);
default:
dev_err(&st->sd.spi->dev, "Invalid reference %d\n", refsel);
return -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/iio/adc/ad7606.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int ad7606_reg_access(struct iio_dev *indio_dev,

static int ad7606_read_samples(struct ad7606_state *st)
{
unsigned int num = st->chip_info->num_channels;
unsigned int num = st->chip_info->num_channels - 1;
u16 *data = st->data;
int ret;

Expand Down
22 changes: 17 additions & 5 deletions drivers/iio/adc/ad7949.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
unsigned int channel)
{
int ret;
int i;
int bits_per_word = ad7949_adc->resolution;
int mask = GENMASK(ad7949_adc->resolution, 0);
struct spi_message msg;
Expand All @@ -100,12 +101,23 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val,
},
};

ret = ad7949_spi_write_cfg(ad7949_adc,
channel << AD7949_OFFSET_CHANNEL_SEL,
AD7949_MASK_CHANNEL_SEL);
if (ret)
return ret;
/*
* 1: write CFG for sample N and read old data (sample N-2)
* 2: if CFG was not changed since sample N-1 then we'll get good data
* at the next xfer, so we bail out now, otherwise we write something
* and we read garbage (sample N-1 configuration).
*/
for (i = 0; i < 2; i++) {
ret = ad7949_spi_write_cfg(ad7949_adc,
channel << AD7949_OFFSET_CHANNEL_SEL,
AD7949_MASK_CHANNEL_SEL);
if (ret)
return ret;
if (channel == ad7949_adc->current_channel)
break;
}

/* 3: write something and read actual data */
ad7949_adc->buffer = 0;
spi_message_init_with_transfers(&msg, tx, 1);
ret = spi_sync(ad7949_adc->spi, &msg);
Expand Down
2 changes: 1 addition & 1 deletion drivers/iio/adc/intel_mrfld_adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static int mrfld_adc_probe(struct platform_device *pdev)
int irq;
int ret;

indio_dev = devm_iio_device_alloc(dev, sizeof(*indio_dev));
indio_dev = devm_iio_device_alloc(dev, sizeof(struct mrfld_adc));
if (!indio_dev)
return -ENOMEM;

Expand Down
8 changes: 7 additions & 1 deletion drivers/iio/adc/max1027.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,13 @@ static int max1027_probe(struct spi_device *spi)
st->trig->ops = &max1027_trigger_ops;
st->trig->dev.parent = &spi->dev;
iio_trigger_set_drvdata(st->trig, indio_dev);
iio_trigger_register(st->trig);
ret = devm_iio_trigger_register(&indio_dev->dev,
st->trig);
if (ret < 0) {
dev_err(&indio_dev->dev,
"Failed to register iio trigger\n");
return ret;
}

ret = devm_request_threaded_irq(&spi->dev, spi->irq,
iio_trigger_generic_data_rdy_poll,
Expand Down
16 changes: 10 additions & 6 deletions drivers/iio/adc/max9611.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
#define MAX9611_TEMP_SCALE_NUM 1000000
#define MAX9611_TEMP_SCALE_DIV 2083

/*
* Conversion time is 2 ms (typically) at Ta=25 degreeC
* No maximum value is known, so play it safe.
*/
#define MAX9611_CONV_TIME_US_RANGE 3000, 3300

struct max9611_dev {
struct device *dev;
struct i2c_client *i2c_client;
Expand Down Expand Up @@ -236,11 +242,9 @@ static int max9611_read_single(struct max9611_dev *max9611,
return ret;
}

/*
* need a delay here to make register configuration
* stabilize. 1 msec at least, from empirical testing.
*/
usleep_range(1000, 2000);
/* need a delay here to make register configuration stabilize. */

usleep_range(MAX9611_CONV_TIME_US_RANGE);

ret = i2c_smbus_read_word_swapped(max9611->i2c_client, reg_addr);
if (ret < 0) {
Expand Down Expand Up @@ -507,7 +511,7 @@ static int max9611_init(struct max9611_dev *max9611)
MAX9611_REG_CTRL2, 0);
return ret;
}
usleep_range(1000, 2000);
usleep_range(MAX9611_CONV_TIME_US_RANGE);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/iio/humidity/hdc100x.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev,
*val2 = 65536;
return IIO_VAL_FRACTIONAL;
} else {
*val = 100;
*val = 100000;
*val2 = 65536;
return IIO_VAL_FRACTIONAL;
}
Expand Down
23 changes: 12 additions & 11 deletions drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,62 +117,71 @@ static const struct inv_mpu6050_hw hw_info[] = {
.reg = &reg_set_6050,
.config = &chip_config_6050,
.fifo_size = 1024,
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
},
{
.whoami = INV_MPU6500_WHOAMI_VALUE,
.name = "MPU6500",
.reg = &reg_set_6500,
.config = &chip_config_6050,
.fifo_size = 512,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
},
{
.whoami = INV_MPU6515_WHOAMI_VALUE,
.name = "MPU6515",
.reg = &reg_set_6500,
.config = &chip_config_6050,
.fifo_size = 512,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
},
{
.whoami = INV_MPU6000_WHOAMI_VALUE,
.name = "MPU6000",
.reg = &reg_set_6050,
.config = &chip_config_6050,
.fifo_size = 1024,
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
},
{
.whoami = INV_MPU9150_WHOAMI_VALUE,
.name = "MPU9150",
.reg = &reg_set_6050,
.config = &chip_config_6050,
.fifo_size = 1024,
.temp = {INV_MPU6050_TEMP_OFFSET, INV_MPU6050_TEMP_SCALE},
},
{
.whoami = INV_MPU9250_WHOAMI_VALUE,
.name = "MPU9250",
.reg = &reg_set_6500,
.config = &chip_config_6050,
.fifo_size = 512,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
},
{
.whoami = INV_MPU9255_WHOAMI_VALUE,
.name = "MPU9255",
.reg = &reg_set_6500,
.config = &chip_config_6050,
.fifo_size = 512,
.temp = {INV_MPU6500_TEMP_OFFSET, INV_MPU6500_TEMP_SCALE},
},
{
.whoami = INV_ICM20608_WHOAMI_VALUE,
.name = "ICM20608",
.reg = &reg_set_6500,
.config = &chip_config_6050,
.fifo_size = 512,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
},
{
.whoami = INV_ICM20602_WHOAMI_VALUE,
.name = "ICM20602",
.reg = &reg_set_icm20602,
.config = &chip_config_6050,
.fifo_size = 1008,
.temp = {INV_ICM20608_TEMP_OFFSET, INV_ICM20608_TEMP_SCALE},
},
};

Expand Down Expand Up @@ -481,12 +490,8 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,

return IIO_VAL_INT_PLUS_MICRO;
case IIO_TEMP:
*val = 0;
if (st->chip_type == INV_ICM20602)
*val2 = INV_ICM20602_TEMP_SCALE;
else
*val2 = INV_MPU6050_TEMP_SCALE;

*val = st->hw->temp.scale / 1000000;
*val2 = st->hw->temp.scale % 1000000;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_MAGN:
return inv_mpu_magn_get_scale(st, chan, val, val2);
Expand All @@ -496,11 +501,7 @@ inv_mpu6050_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_OFFSET:
switch (chan->type) {
case IIO_TEMP:
if (st->chip_type == INV_ICM20602)
*val = INV_ICM20602_TEMP_OFFSET;
else
*val = INV_MPU6050_TEMP_OFFSET;

*val = st->hw->temp.offset;
return IIO_VAL_INT;
default:
return -EINVAL;
Expand Down
16 changes: 12 additions & 4 deletions drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,18 @@ struct inv_mpu6050_chip_config {
* @reg: register map of the chip.
* @config: configuration of the chip.
* @fifo_size: size of the FIFO in bytes.
* @temp: offset and scale to apply to raw temperature.
*/
struct inv_mpu6050_hw {
u8 whoami;
u8 *name;
const struct inv_mpu6050_reg_map *reg;
const struct inv_mpu6050_chip_config *config;
size_t fifo_size;
struct {
int offset;
int scale;
} temp;
};

/*
Expand Down Expand Up @@ -279,16 +284,19 @@ struct inv_mpu6050_state {
#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
#define INV_MPU6050_TEMP_OFFSET 12420
#define INV_MPU6050_TEMP_SCALE 2941176
#define INV_MPU6050_MAX_GYRO_FS_PARAM 3
#define INV_MPU6050_MAX_ACCL_FS_PARAM 3
#define INV_MPU6050_THREE_AXIS 3
#define INV_MPU6050_GYRO_CONFIG_FSR_SHIFT 3
#define INV_MPU6050_ACCL_CONFIG_FSR_SHIFT 3

#define INV_ICM20602_TEMP_OFFSET 8170
#define INV_ICM20602_TEMP_SCALE 3060
#define INV_MPU6500_TEMP_OFFSET 7011
#define INV_MPU6500_TEMP_SCALE 2995178

#define INV_ICM20608_TEMP_OFFSET 8170
#define INV_ICM20608_TEMP_SCALE 3059976

/* 6 + 6 + 7 (for MPU9x50) = 19 round up to 24 and plus 8 */
#define INV_MPU6050_OUTPUT_DATA_SIZE 32
Expand Down
6 changes: 2 additions & 4 deletions drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ enum st_lsm6dsx_fifo_mode {
* @odr: Output data rate of the sensor [Hz].
* @watermark: Sensor watermark level.
* @sip: Number of samples in a given pattern.
* @decimator: FIFO decimation factor.
* @ts_ref: Sensor timestamp reference for hw one.
* @ext_info: Sensor settings if it is connected to i2c controller
*/
Expand All @@ -334,7 +333,6 @@ struct st_lsm6dsx_sensor {

u16 watermark;
u8 sip;
u8 decimator;
s64 ts_ref;

struct {
Expand All @@ -351,9 +349,9 @@ struct st_lsm6dsx_sensor {
* @fifo_lock: Mutex to prevent concurrent access to the hw FIFO.
* @conf_lock: Mutex to prevent concurrent FIFO configuration update.
* @page_lock: Mutex to prevent concurrent memory page configuration.
* @fifo_mode: FIFO operating mode supported by the device.
* @suspend_mask: Suspended sensor bitmask.
* @enable_mask: Enabled sensor bitmask.
* @fifo_mask: Enabled hw FIFO bitmask.
* @ts_gain: Hw timestamp rate after internal calibration.
* @ts_sip: Total number of timestamp samples in a given pattern.
* @sip: Total number of samples (acc/gyro/ts) in a given pattern.
Expand All @@ -373,9 +371,9 @@ struct st_lsm6dsx_hw {
struct mutex conf_lock;
struct mutex page_lock;

enum st_lsm6dsx_fifo_mode fifo_mode;
u8 suspend_mask;
u8 enable_mask;
u8 fifo_mask;
s64 ts_gain;
u8 ts_sip;
u8 sip;
Expand Down
Loading

0 comments on commit aff2a52

Please sign in to comment.