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

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

Merge tag 'iio-for-3.8f' of...

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

Jonathan writes:
  "6th set of IIO new driver support, clean up and fixes for the 3.8 cycle
   (possibly wait until 3.9 cycle given timing).

   Here we have
   * the cleanup and move out of staging of ad7793.
   * addition support for additional parts to ad7793.
   * a basic new driver for TI ADC081C021/027
   * 4 little fixes for the recent addition of ad16136 and ad16480.

   So some nice work with nothing controversial or anything that
   will effect stuff outside the drivers in question."
parents e143ef8f 583f2deb
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -42,6 +42,18 @@ config AD7791
	  To compile this driver as a module, choose M here: the module will be
	  called ad7791.

config AD7793
	tristate "Analog Devices AD7793 and similar ADCs driver"
	depends on SPI
	select AD_SIGMA_DELTA
	help
	  Say yes here to build support for Analog Devices AD7785, AD7792, AD7793,
	  AD7794 and AD7795 SPI analog to digital converters (ADC).
	  If unsure, say N (but it's safe to say "Y").

	  To compile this driver as a module, choose M here: the
	  module will be called AD7793.

config AD7476
	tristate "Analog Devices AD7476 and similar 1-channel ADCs driver"
	depends on SPI
@@ -103,4 +115,14 @@ config MAX1363
	  max11646, max11647) Provides direct access via sysfs and buffered
	  data via the iio dev interface.

config TI_ADC081C
	tristate "Texas Instruments ADC081C021/027"
	depends on I2C
	help
	  If you say yes here you get support for Texas Instruments ADC081C021
	  and ADC081C027 ADC chips.

	  This driver can also be built as a module. If so, the module will be
	  called ti-adc081c.

endmenu
+3 −0
Original line number Diff line number Diff line
@@ -7,7 +7,10 @@ obj-$(CONFIG_AD7266) += ad7266.o
obj-$(CONFIG_AD7298) += ad7298.o
obj-$(CONFIG_AD7476) += ad7476.o
obj-$(CONFIG_AD7791) += ad7791.o
obj-$(CONFIG_AD7793) += ad7793.o
obj-$(CONFIG_AD7887) += ad7887.o
obj-$(CONFIG_AT91_ADC) += at91_adc.o
obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o
obj-$(CONFIG_MAX1363) += max1363.o
obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o
+347 −37

File changed and moved.

Preview size limit exceeded, changes collapsed.

+161 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 Avionic Design GmbH
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/module.h>

#include <linux/iio/iio.h>
#include <linux/regulator/consumer.h>

struct adc081c {
	struct i2c_client *i2c;
	struct regulator *ref;
};

#define REG_CONV_RES 0x00

static int adc081c_read_raw(struct iio_dev *iio,
			    struct iio_chan_spec const *channel, int *value,
			    int *shift, long mask)
{
	struct adc081c *adc = iio_priv(iio);
	int err;

	switch (mask) {
	case IIO_CHAN_INFO_RAW:
		err = i2c_smbus_read_word_swapped(adc->i2c, REG_CONV_RES);
		if (err < 0)
			return err;

		*value = (err >> 4) & 0xff;
		return IIO_VAL_INT;

	case IIO_CHAN_INFO_SCALE:
		err = regulator_get_voltage(adc->ref);
		if (err < 0)
			return err;

		*value = err / 1000;
		*shift = 8;

		return IIO_VAL_FRACTIONAL_LOG2;

	default:
		break;
	}

	return -EINVAL;
}

static const struct iio_chan_spec adc081c_channel = {
	.type = IIO_VOLTAGE,
	.info_mask = IIO_CHAN_INFO_SCALE_SHARED_BIT |
		     IIO_CHAN_INFO_RAW_SEPARATE_BIT,
};

static const struct iio_info adc081c_info = {
	.read_raw = adc081c_read_raw,
	.driver_module = THIS_MODULE,
};

static int adc081c_probe(struct i2c_client *client,
			 const struct i2c_device_id *id)
{
	struct iio_dev *iio;
	struct adc081c *adc;
	int err;

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

	iio = iio_device_alloc(sizeof(*adc));
	if (!iio)
		return -ENOMEM;

	adc = iio_priv(iio);
	adc->i2c = client;

	adc->ref = regulator_get(&client->dev, "vref");
	if (IS_ERR(adc->ref)) {
		err = PTR_ERR(adc->ref);
		goto iio_free;
	}

	err = regulator_enable(adc->ref);
	if (err < 0)
		goto regulator_put;

	iio->dev.parent = &client->dev;
	iio->name = dev_name(&client->dev);
	iio->modes = INDIO_DIRECT_MODE;
	iio->info = &adc081c_info;

	iio->channels = &adc081c_channel;
	iio->num_channels = 1;

	err = iio_device_register(iio);
	if (err < 0)
		goto regulator_disable;

	i2c_set_clientdata(client, iio);

	return 0;

regulator_disable:
	regulator_disable(adc->ref);
regulator_put:
	regulator_put(adc->ref);
iio_free:
	iio_device_free(iio);

	return err;
}

static int adc081c_remove(struct i2c_client *client)
{
	struct iio_dev *iio = i2c_get_clientdata(client);
	struct adc081c *adc = iio_priv(iio);

	iio_device_unregister(iio);
	regulator_disable(adc->ref);
	regulator_put(adc->ref);
	iio_device_free(iio);

	return 0;
}

static const struct i2c_device_id adc081c_id[] = {
	{ "adc081c", 0 },
	{ }
};
MODULE_DEVICE_TABLE(i2c, adc081c_id);

#ifdef CONFIG_OF
static const struct of_device_id adc081c_of_match[] = {
	{ .compatible = "ti,adc081c" },
	{ }
};
MODULE_DEVICE_TABLE(of, adc081c_of_match);
#endif

static struct i2c_driver adc081c_driver = {
	.driver = {
		.name = "adc081c",
		.owner = THIS_MODULE,
		.of_match_table = of_match_ptr(adc081c_of_match),
	},
	.probe = adc081c_probe,
	.remove = adc081c_remove,
	.id_table = adc081c_id,
};
module_i2c_driver(adc081c_driver);

MODULE_AUTHOR("Thierry Reding <thierry.reding@avionic-design.de>");
MODULE_DESCRIPTION("Texas Instruments ADC081C021/027 driver");
MODULE_LICENSE("GPL v2");
+2 −3
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
#include <linux/iio/buffer.h>
#include <linux/iio/imu/adis.h>

#include <linux/iio/iio.h>
#include <linux/debugfs.h>

#define ADIS16136_REG_FLASH_CNT		0x00
@@ -203,10 +202,10 @@ static ssize_t adis16136_write_frequency(struct device *dev,
{
	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
	struct adis16136 *adis16136 = iio_priv(indio_dev);
	long val;
	unsigned int val;
	int ret;

	ret = kstrtol(buf, 10, &val);
	ret = kstrtouint(buf, 10, &val);
	if (ret)
		return ret;

Loading