Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec3c13e4 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge tag 'iio-for-4.6c' of...

Merge tag 'iio-for-4.6c' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Third set of IIO new device support, features and cleanups for the 4.6 cycle.

Good to see several new contributors in this set - and more generally a
number of new 'faces' over this whole cycle.

Staging movements
* hmc5843
  - out of staging.
* periodic RTC trigger
  - driver dropped.  This is an ancient driver (brings back some memories ;)
  that was always somewhat of a bodge. Originally there was a driver that
  never went into mainline that supported large numbers of periodict timers
  on the PXA270 via this route. Discussions to have a generic periodic
  timer subsystem never went anywhere.  At the time RTC periodic
  interrupts were real - now they are emulated using high resolution
  timers so with the HRT driver this has become pointless.

New device support
* mpu6050 driver
  - Add support for the mpu6500.
* TI tpl0102 potentiometer
  - new driver.
* Vybrid SoC DAC
  - new driver.  The ADC on this SoC has been supported for a while, this
    adds a separate driver for the DAC.

New Features
* hmc5844
  - Attributes to configure the bias current (typically part of a self test)
    This could be done before via a somewhat obscure custom interface.
    This at least makes it easy to tell what is going on.
  - Document all custom attributes.
* mpu6050
  - Add support for calibration offset control and readback.
* ms5611
  - power regulator support.  This is always one that gets added the
    first time someone has a board that needs it.  Here it was needed,
    hence it was added.

Cleanups / minor fixes
* tree wide
  - clean up all the myriad different return values in response to a
    failure of i2c_check_functionality.  After discussions everyone seemed
    happy wiht -EOPNOTSUPP which seems to describe the situation well.
    I encouraged a tree wide cleanup to set a good example in future for
    this.
* core
  - Typos in the iio_event_spec documentation in iio.h
* afe4403
  - select REGMAP_SPI to avoid dependency issues
  - mark suspend/resume as __maybe_unused to avoid warnings
* afe4404
  - mark suspend/resume as __maybe_unused to avoid warnings
* atlas-ph-sensor
  - switch the regmap cache type from linear to rbtree to gain reading of
    registers on initial startup.  It's not immediately obvious, but
    regmap flat is meant for high performances cases so doesn't read these
    registers.
  - use regmap_bulk_read in one case where it was using
    i2c_smbus_read_i2c_block_data directly (unlike everything else that was
    through regmap).
* ina2xx
  - stype cleanups (lots of them!)
* isl29018
  - Get the struct device back from regmap rather than storing another
    copy of it in the private data.  This cleanup makes sense in a number
    of other drivers so patches may well follow.
* mpu6050
  - style cleanups (lots of them!)
  - improved return value handling
  - use usleep_range to avoid the usual issues with very short msleeps.
  - add some missing documentation.
* ms5611
  - use the probed device name for the device rather than the driver name.
  - select IIO_BUFFER to avoid dependency issues
* palmas
  - drop IRQF_EARLY_RESUME as no longer needed after genirq changes.
parents 3e66848a ac65ca68
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
What:           /sys/bus/iio/devices/iio:deviceX/meas_conf
What:           /sys/bus/iio/devices/iio:deviceX/meas_conf_available
KernelVersion:  4.5
Contact:        linux-iio@vger.kernel.org
Description:
                Current configuration and available configurations
		for the bias current.
		normal		- Normal measurement configurations (default)
		positivebias	- Positive bias configuration
		negativebias	- Negative bias configuration
		disabled	- Only available on HMC5983. Disables magnetic
				  sensor and enables temperature sensor.
		Note: The effect of this configuration may vary
		according to the device. For exact documentation
		check the device's datasheet.
+9 −0
Original line number Diff line number Diff line
@@ -5,3 +5,12 @@ Description:
		Specifies the hardware conversion mode used. The three
		available modes are "normal", "high-speed" and "low-power",
		where the last is the default mode.


What:		/sys/bus/iio/devices/iio:deviceX/out_conversion_mode
KernelVersion:	4.6
Contact:	linux-iio@vger.kernel.org
Description:
		Specifies the hardware conversion mode used within DAC.
		The two available modes are "high-power" and "low-power",
		where "low-power" mode is the default mode.
+20 −0
Original line number Diff line number Diff line
Freescale vf610 Digital to Analog Converter bindings

The devicetree bindings are for the new DAC driver written for
vf610 SoCs from Freescale.

Required properties:
- compatible: Should contain "fsl,vf610-dac"
- reg: Offset and length of the register set for the device
- interrupts: Should contain the interrupt for the device
- clocks: The clock is needed by the DAC controller
- clock-names: Must contain "dac" matching entry in the clocks property.

Example:
dac0: dac@400cc000 {
	compatible = "fsl,vf610-dac";
	reg = <0x400cc000 0x1000>;
	interrupts = <55 IRQ_TYPE_LEVEL_HIGH>;
	clock-names = "dac";
	clocks = <&clks VF610_CLK_DAC0>;
};
+72 −83
Original line number Diff line number Diff line
@@ -19,17 +19,18 @@
 *
 * Configurable 7-bit I2C slave address from 0x40 to 0x4F
 */
#include <linux/module.h>
#include <linux/kthread.h>

#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/sysfs.h>
#include <linux/i2c.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/platform_data/ina2xx.h>

#include <linux/util_macros.h>

#include <linux/platform_data/ina2xx.h>

/* INA2XX registers definition */
#define INA2XX_CONFIG                   0x00
#define INA2XX_SHUNT_VOLTAGE            0x01	/* readonly */
@@ -38,7 +39,7 @@
#define INA2XX_CURRENT                  0x04	/* readonly */
#define INA2XX_CALIBRATION              0x05

#define INA226_ALERT_MASK		0x06
#define INA226_ALERT_MASK		GENMASK(2, 1)
#define INA266_CVRF			BIT(3)

#define INA2XX_MAX_REGISTERS            8
@@ -149,7 +150,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev,
	switch (mask) {
	case IIO_CHAN_INFO_RAW:
		ret = regmap_read(chip->regmap, chan->address, &regval);
		if (ret < 0)
		if (ret)
			return ret;

		if (is_signed_reg(chan->address))
@@ -285,8 +286,8 @@ static int ina2xx_write_raw(struct iio_dev *indio_dev,
			    int val, int val2, long mask)
{
	struct ina2xx_chip_info *chip = iio_priv(indio_dev);
	int ret;
	unsigned int config, tmp;
	int ret;

	if (iio_buffer_enabled(indio_dev))
		return -EBUSY;
@@ -294,8 +295,8 @@ static int ina2xx_write_raw(struct iio_dev *indio_dev,
	mutex_lock(&chip->state_lock);

	ret = regmap_read(chip->regmap, INA2XX_CONFIG, &config);
	if (ret < 0)
		goto _err;
	if (ret)
		goto err;

	tmp = config;

@@ -310,19 +311,19 @@ static int ina2xx_write_raw(struct iio_dev *indio_dev,
		else
			ret = ina226_set_int_time_vbus(chip, val2, &tmp);
		break;

	default:
		ret = -EINVAL;
	}

	if (!ret && (tmp != config))
		ret = regmap_write(chip->regmap, INA2XX_CONFIG, tmp);
_err:
err:
	mutex_unlock(&chip->state_lock);

	return ret;
}


static ssize_t ina2xx_allow_async_readout_show(struct device *dev,
					   struct device_attribute *attr,
					   char *buf)
@@ -355,6 +356,7 @@ static int set_shunt_resistor(struct ina2xx_chip_info *chip, unsigned int val)
		return -EINVAL;

	chip->shunt_resistor = val;

	return 0;
}

@@ -438,7 +440,6 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev)
	struct ina2xx_chip_info *chip = iio_priv(indio_dev);
	unsigned short data[8];
	int bit, ret, i = 0;
	unsigned long buffer_us, elapsed_us;
	s64 time_a, time_b;
	unsigned int alert;

@@ -462,8 +463,6 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev)
				return ret;

			alert &= INA266_CVRF;
			trace_printk("Conversion ready: %d\n", !!alert);

		} while (!alert);

	/*
@@ -488,19 +487,14 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev)
	iio_push_to_buffers_with_timestamp(indio_dev,
					   (unsigned int *)data, time_a);

	buffer_us = (unsigned long)(time_b - time_a) / 1000;
	elapsed_us = (unsigned long)(time_a - chip->prev_ns) / 1000;

	trace_printk("uS: elapsed: %lu, buf: %lu\n", elapsed_us, buffer_us);

	chip->prev_ns = time_a;

	return buffer_us;
	return (unsigned long)(time_b - time_a) / 1000;
};

static int ina2xx_capture_thread(void *data)
{
	struct iio_dev *indio_dev = (struct iio_dev *)data;
	struct iio_dev *indio_dev = data;
	struct ina2xx_chip_info *chip = iio_priv(indio_dev);
	unsigned int sampling_us = SAMPLING_PERIOD(chip);
	int buffer_us;
@@ -530,12 +524,13 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev)
	struct ina2xx_chip_info *chip = iio_priv(indio_dev);
	unsigned int sampling_us = SAMPLING_PERIOD(chip);

	trace_printk("Enabling buffer w/ scan_mask %02x, freq = %d, avg =%u\n",
	dev_dbg(&indio_dev->dev, "Enabling buffer w/ scan_mask %02x, freq = %d, avg =%u\n",
		(unsigned int)(*indio_dev->active_scan_mask),
		1000000 / sampling_us, chip->avg);

	trace_printk("Expected work period: %u us\n", sampling_us);
	trace_printk("Async readout mode: %d\n", chip->allow_async_readout);
	dev_dbg(&indio_dev->dev, "Expected work period: %u us\n", sampling_us);
	dev_dbg(&indio_dev->dev, "Async readout mode: %d\n",
		chip->allow_async_readout);

	chip->prev_ns = iio_get_time_ns();

@@ -575,8 +570,7 @@ static int ina2xx_debug_reg(struct iio_dev *indio_dev,
}

/* Possible integration times for vshunt and vbus */
static IIO_CONST_ATTR_INT_TIME_AVAIL \
 ("0.000140 0.000204 0.000332 0.000588 0.001100 0.002116 0.004156 0.008244");
static IIO_CONST_ATTR_INT_TIME_AVAIL("0.000140 0.000204 0.000332 0.000588 0.001100 0.002116 0.004156 0.008244");

static IIO_DEVICE_ATTR(in_allow_async_readout, S_IRUGO | S_IWUSR,
		       ina2xx_allow_async_readout_show,
@@ -598,21 +592,23 @@ static const struct attribute_group ina2xx_attribute_group = {
};

static const struct iio_info ina2xx_info = {
	.debugfs_reg_access = &ina2xx_debug_reg,
	.read_raw = &ina2xx_read_raw,
	.write_raw = &ina2xx_write_raw,
	.attrs = &ina2xx_attribute_group,
	.driver_module = THIS_MODULE,
	.attrs = &ina2xx_attribute_group,
	.read_raw = ina2xx_read_raw,
	.write_raw = ina2xx_write_raw,
	.debugfs_reg_access = ina2xx_debug_reg,
};

/* Initialize the configuration and calibration registers. */
static int ina2xx_init(struct ina2xx_chip_info *chip, unsigned int config)
{
	u16 regval;
	int ret = regmap_write(chip->regmap, INA2XX_CONFIG, config);
	int ret;

	if (ret < 0)
	ret = regmap_write(chip->regmap, INA2XX_CONFIG, config);
	if (ret)
		return ret;

	/*
	 * Set current LSB to 1mA, shunt is in uOhms
	 * (equation 13 in datasheet). We hardcode a Current_LSB
@@ -632,8 +628,8 @@ static int ina2xx_probe(struct i2c_client *client,
	struct ina2xx_chip_info *chip;
	struct iio_dev *indio_dev;
	struct iio_buffer *buffer;
	int ret;
	unsigned int val;
	int ret;

	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
	if (!indio_dev)
@@ -641,8 +637,19 @@ static int ina2xx_probe(struct i2c_client *client,

	chip = iio_priv(indio_dev);

	/* This is only used for device removal purposes. */
	i2c_set_clientdata(client, indio_dev);

	chip->regmap = devm_regmap_init_i2c(client, &ina2xx_regmap_config);
	if (IS_ERR(chip->regmap)) {
		dev_err(&client->dev, "failed to allocate register map\n");
		return PTR_ERR(chip->regmap);
	}

	chip->config = &ina2xx_config[id->driver_data];

	mutex_init(&chip->state_lock);

	if (of_property_read_u32(client->dev.of_node,
				 "shunt-resistor", &val) < 0) {
		struct ina2xx_platform_data *pdata =
@@ -658,25 +665,6 @@ static int ina2xx_probe(struct i2c_client *client,
	if (ret)
		return ret;

	mutex_init(&chip->state_lock);

	/* This is only used for device removal purposes. */
	i2c_set_clientdata(client, indio_dev);

	indio_dev->name = id->name;
	indio_dev->channels = ina2xx_channels;
	indio_dev->num_channels = ARRAY_SIZE(ina2xx_channels);

	indio_dev->dev.parent = &client->dev;
	indio_dev->info = &ina2xx_info;
	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;

	chip->regmap = devm_regmap_init_i2c(client, &ina2xx_regmap_config);
	if (IS_ERR(chip->regmap)) {
		dev_err(&client->dev, "failed to allocate register map\n");
		return PTR_ERR(chip->regmap);
	}

	/* Patch the current config register with default. */
	val = chip->config->config_default;

@@ -687,24 +675,28 @@ static int ina2xx_probe(struct i2c_client *client,
	}

	ret = ina2xx_init(chip, val);
	if (ret < 0) {
		dev_err(&client->dev, "error configuring the device: %d\n",
			ret);
		return -ENODEV;
	if (ret) {
		dev_err(&client->dev, "error configuring the device\n");
		return ret;
	}

	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
	indio_dev->dev.parent = &client->dev;
	indio_dev->channels = ina2xx_channels;
	indio_dev->num_channels = ARRAY_SIZE(ina2xx_channels);
	indio_dev->name = id->name;
	indio_dev->info = &ina2xx_info;
	indio_dev->setup_ops = &ina2xx_setup_ops;

	buffer = devm_iio_kfifo_allocate(&indio_dev->dev);
	if (!buffer)
		return -ENOMEM;

	indio_dev->setup_ops = &ina2xx_setup_ops;

	iio_device_attach_buffer(indio_dev, buffer);

	return iio_device_register(indio_dev);
}


static int ina2xx_remove(struct i2c_client *client)
{
	struct iio_dev *indio_dev = i2c_get_clientdata(client);
@@ -717,7 +709,6 @@ static int ina2xx_remove(struct i2c_client *client)
				  INA2XX_MODE_MASK, 0);
}


static const struct i2c_device_id ina2xx_id[] = {
	{"ina219", ina219},
	{"ina220", ina219},
@@ -726,7 +717,6 @@ static const struct i2c_device_id ina2xx_id[] = {
	{"ina231", ina226},
	{}
};

MODULE_DEVICE_TABLE(i2c, ina2xx_id);

static struct i2c_driver ina2xx_driver = {
@@ -737,7 +727,6 @@ static struct i2c_driver ina2xx_driver = {
	.remove = ina2xx_remove,
	.id_table = ina2xx_id,
};

module_i2c_driver(ina2xx_driver);

MODULE_AUTHOR("Marc Titinger <marc.titinger@baylibre.com>");
+1 −1
Original line number Diff line number Diff line
@@ -339,7 +339,7 @@ static int mcp3422_probe(struct i2c_client *client,
	u8 config;

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
		return -ENODEV;
		return -EOPNOTSUPP;

	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adc));
	if (!indio_dev)
Loading