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

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

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

Jonathan writes:

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

This is a somewhat sneaky late pull request given Linus has announced
a likely 1 week delay.  If it is too late I'll resend after the merge
window.  I merged in the fixes branch as those are primarily around
things queued for the merge window.

Particulary good to see the output of our Himanshu Jha, a GSOC student
who developed the bme680 driver.

New device support:
* bme680 gas sensor (with temperature, humidity and pressure)
  - new driver to support this device
* vcn4000
  - support vcnl4200 (lots of rework to allow this)
  - ids added for VCNL4010 and VCNL4020 sensors

New features:
* ad9523
  - support the various external signal options via gpios.

Cleanups and fixes
* ad_sigma_delta
  - unsigned long for a timeout.
* ad9523
  - fix a wrong return value that was indicating successful write failed
    and might lead to an infinite loop.
* si1133
  - fix an impossible test.
  - fix an uninitialsed variable by reading from the device in all paths.
* xilinx xadc
  - check for return values in clk related functions
  - limit the pcap clock frequency to supported ranges.
  - stash the irq to avoid calling platform_get_irq from the remove path.
  - ensure the irq is actually requested before we enable the hardware to
    output it.
parents 799d8a8e 496fb59e
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,
	unsigned int mode, unsigned int channel)
{
	int ret;
	unsigned long timeout;

	ret = ad_sigma_delta_set_channel(sigma_delta, channel);
	if (ret)
@@ -224,8 +225,8 @@ static int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta,

	sigma_delta->irq_dis = false;
	enable_irq(sigma_delta->spi->irq);
	ret = wait_for_completion_timeout(&sigma_delta->completion, 2*HZ);
	if (ret == 0) {
	timeout = wait_for_completion_timeout(&sigma_delta->completion, 2 * HZ);
	if (timeout == 0) {
		sigma_delta->irq_dis = true;
		disable_irq_nosync(sigma_delta->spi->irq);
		ret = -EIO;
+31 −9
Original line number Diff line number Diff line
@@ -322,6 +322,7 @@ static irqreturn_t xadc_zynq_interrupt_handler(int irq, void *devid)

#define XADC_ZYNQ_TCK_RATE_MAX 50000000
#define XADC_ZYNQ_IGAP_DEFAULT 20
#define XADC_ZYNQ_PCAP_RATE_MAX 200000000

static int xadc_zynq_setup(struct platform_device *pdev,
	struct iio_dev *indio_dev, int irq)
@@ -332,6 +333,7 @@ static int xadc_zynq_setup(struct platform_device *pdev,
	unsigned int div;
	unsigned int igap;
	unsigned int tck_rate;
	int ret;

	/* TODO: Figure out how to make igap and tck_rate configurable */
	igap = XADC_ZYNQ_IGAP_DEFAULT;
@@ -340,6 +342,15 @@ static int xadc_zynq_setup(struct platform_device *pdev,
	xadc->zynq_intmask = ~0;

	pcap_rate = clk_get_rate(xadc->clk);
	if (!pcap_rate)
		return -EINVAL;

	if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX) {
		ret = clk_set_rate(xadc->clk,
				   (unsigned long)XADC_ZYNQ_PCAP_RATE_MAX);
		if (ret)
			return ret;
	}

	if (tck_rate > pcap_rate / 2) {
		div = 2;
@@ -366,6 +377,12 @@ static int xadc_zynq_setup(struct platform_device *pdev,
			XADC_ZYNQ_CFG_REDGE | XADC_ZYNQ_CFG_WEDGE |
			tck_div | XADC_ZYNQ_CFG_IGAP(igap));

	if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX) {
		ret = clk_set_rate(xadc->clk, pcap_rate);
		if (ret)
			return ret;
	}

	return 0;
}

@@ -887,6 +904,9 @@ static int xadc_write_raw(struct iio_dev *indio_dev,
	unsigned long clk_rate = xadc_get_dclk_rate(xadc);
	unsigned int div;

	if (!clk_rate)
		return -EINVAL;

	if (info != IIO_CHAN_INFO_SAMP_FREQ)
		return -EINVAL;

@@ -1155,6 +1175,7 @@ static int xadc_probe(struct platform_device *pdev)

	xadc = iio_priv(indio_dev);
	xadc->ops = id->data;
	xadc->irq = irq;
	init_completion(&xadc->completion);
	mutex_init(&xadc->mutex);
	spin_lock_init(&xadc->lock);
@@ -1205,14 +1226,14 @@ static int xadc_probe(struct platform_device *pdev)
	if (ret)
		goto err_free_samplerate_trigger;

	ret = xadc->ops->setup(pdev, indio_dev, irq);
	ret = request_irq(xadc->irq, xadc->ops->interrupt_handler, 0,
			dev_name(&pdev->dev), indio_dev);
	if (ret)
		goto err_clk_disable_unprepare;

	ret = request_irq(irq, xadc->ops->interrupt_handler, 0,
			dev_name(&pdev->dev), indio_dev);
	ret = xadc->ops->setup(pdev, indio_dev, xadc->irq);
	if (ret)
		goto err_clk_disable_unprepare;
		goto err_free_irq;

	for (i = 0; i < 16; i++)
		xadc_read_adc_reg(xadc, XADC_REG_THRESHOLD(i),
@@ -1237,8 +1258,10 @@ static int xadc_probe(struct platform_device *pdev)
		goto err_free_irq;

	/* Disable all alarms */
	xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK,
	ret = xadc_update_adc_reg(xadc, XADC_REG_CONF1, XADC_CONF1_ALARM_MASK,
				  XADC_CONF1_ALARM_MASK);
	if (ret)
		goto err_free_irq;

	/* Set thresholds to min/max */
	for (i = 0; i < 16; i++) {
@@ -1266,7 +1289,7 @@ static int xadc_probe(struct platform_device *pdev)
	return 0;

err_free_irq:
	free_irq(irq, indio_dev);
	free_irq(xadc->irq, indio_dev);
err_clk_disable_unprepare:
	clk_disable_unprepare(xadc->clk);
err_free_samplerate_trigger:
@@ -1288,7 +1311,6 @@ static int xadc_remove(struct platform_device *pdev)
{
	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
	struct xadc *xadc = iio_priv(indio_dev);
	int irq = platform_get_irq(pdev, 0);

	iio_device_unregister(indio_dev);
	if (xadc->ops->flags & XADC_FLAGS_BUFFERED) {
@@ -1296,7 +1318,7 @@ static int xadc_remove(struct platform_device *pdev)
		iio_trigger_free(xadc->convst_trigger);
		iio_triggered_buffer_cleanup(indio_dev);
	}
	free_irq(irq, indio_dev);
	free_irq(xadc->irq, indio_dev);
	clk_disable_unprepare(xadc->clk);
	cancel_delayed_work(&xadc->zynq_unmask_work);
	kfree(xadc->data);
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ struct xadc {
	spinlock_t lock;

	struct completion completion;
	int irq;
};

struct xadc_ops {
+23 −0
Original line number Diff line number Diff line
@@ -21,6 +21,29 @@ config ATLAS_PH_SENSOR
	 To compile this driver as module, choose M here: the
	 module will be called atlas-ph-sensor.

config BME680
	tristate "Bosch Sensortec BME680 sensor driver"
	depends on (I2C || SPI)
	select REGMAP
	select BME680_I2C if I2C
	select BME680_SPI if SPI
	help
	  Say yes here to build support for Bosch Sensortec BME680 sensor with
	  temperature, pressure, humidity and gas sensing capability.

	  This driver can also be built as a module. If so, the module for I2C
	  would be called bme680_i2c and bme680_spi for SPI support.

config BME680_I2C
	tristate
	depends on I2C && BME680
	select REGMAP_I2C

config BME680_SPI
	tristate
	depends on SPI && BME680
	select REGMAP_SPI

config CCS811
	tristate "AMS CCS811 VOC sensor"
	depends on I2C
+3 −0
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@

# When adding new entries keep the list in alphabetical order
obj-$(CONFIG_ATLAS_PH_SENSOR)	+= atlas-ph-sensor.o
obj-$(CONFIG_BME680) += bme680_core.o
obj-$(CONFIG_BME680_I2C) += bme680_i2c.o
obj-$(CONFIG_BME680_SPI) += bme680_spi.o
obj-$(CONFIG_CCS811)		+= ccs811.o
obj-$(CONFIG_IAQCORE)		+= ams-iaq-core.o
obj-$(CONFIG_VZ89X)		+= vz89x.o
Loading