Commit c01ef023 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge branch 'togreg' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

parents b600c5b5 cf82cb81
...@@ -3,6 +3,16 @@ ...@@ -3,6 +3,16 @@
# #
menu "Analog to digital converters" menu "Analog to digital converters"
config AD7266
tristate "Analog Devices AD7265/AD7266 ADC driver"
depends on SPI_MASTER
select IIO_BUFFER
select IIO_TRIGGER
select IIO_TRIGGERED_BUFFER
help
Say yes here to build support for Analog Devices AD7265 and AD7266
ADCs.
config AT91_ADC config AT91_ADC
tristate "Atmel AT91 ADC" tristate "Atmel AT91 ADC"
depends on ARCH_AT91 depends on ARCH_AT91
......
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
# Makefile for IIO ADC drivers # Makefile for IIO ADC drivers
# #
obj-$(CONFIG_AD7266) += ad7266.o
obj-$(CONFIG_AT91_ADC) += at91_adc.o obj-$(CONFIG_AT91_ADC) += at91_adc.o
This diff is collapsed.
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
menu "Digital to analog converters" menu "Digital to analog converters"
config AD5064 config AD5064
tristate "Analog Devices AD5064/64-1/65/44/45/24/25, AD5628/48/66/68 DAC driver" tristate "Analog Devices AD5064 and similar multi-channel DAC driver"
depends on SPI depends on (SPI_MASTER || I2C)
help help
Say yes here to build support for Analog Devices AD5024, AD5025, AD5044, Say yes here to build support for Analog Devices AD5024, AD5025, AD5044,
AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5648, AD5666, AD5668 Digital AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R, AD5648, AD5666, AD5668,
to Analog Converter. AD5669R Digital to Analog Converter.
To compile this driver as a module, choose M here: the To compile this driver as a module, choose M here: the
module will be called ad5064. module will be called ad5064.
......
/* /*
* AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5648, * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R,
* AD5666, AD5668 Digital to analog converters driver * AD5648, AD5666, AD5668, AD5669R Digital to analog converters driver
* *
* Copyright 2011 Analog Devices Inc. * Copyright 2011 Analog Devices Inc.
* *
...@@ -12,9 +12,11 @@ ...@@ -12,9 +12,11 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/i2c.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <asm/unaligned.h>
#include <linux/iio/iio.h> #include <linux/iio/iio.h>
#include <linux/iio/sysfs.h> #include <linux/iio/sysfs.h>
...@@ -62,9 +64,14 @@ struct ad5064_chip_info { ...@@ -62,9 +64,14 @@ struct ad5064_chip_info {
unsigned int num_channels; unsigned int num_channels;
}; };
struct ad5064_state;
typedef int (*ad5064_write_func)(struct ad5064_state *st, unsigned int cmd,
unsigned int addr, unsigned int val);
/** /**
* struct ad5064_state - driver instance specific data * struct ad5064_state - driver instance specific data
* @spi: spi_device * @dev: the device for this driver instance
* @chip_info: chip model specific constants, available modes etc * @chip_info: chip model specific constants, available modes etc
* @vref_reg: vref supply regulators * @vref_reg: vref supply regulators
* @pwr_down: whether channel is powered down * @pwr_down: whether channel is powered down
...@@ -72,11 +79,12 @@ struct ad5064_chip_info { ...@@ -72,11 +79,12 @@ struct ad5064_chip_info {
* @dac_cache: current DAC raw value (chip does not support readback) * @dac_cache: current DAC raw value (chip does not support readback)
* @use_internal_vref: set to true if the internal reference voltage should be * @use_internal_vref: set to true if the internal reference voltage should be
* used. * used.
* @data: spi transfer buffers * @write: register write callback
* @data: i2c/spi transfer buffers
*/ */
struct ad5064_state { struct ad5064_state {
struct spi_device *spi; struct device *dev;
const struct ad5064_chip_info *chip_info; const struct ad5064_chip_info *chip_info;
struct regulator_bulk_data vref_reg[AD5064_MAX_VREFS]; struct regulator_bulk_data vref_reg[AD5064_MAX_VREFS];
bool pwr_down[AD5064_MAX_DAC_CHANNELS]; bool pwr_down[AD5064_MAX_DAC_CHANNELS];
...@@ -84,11 +92,16 @@ struct ad5064_state { ...@@ -84,11 +92,16 @@ struct ad5064_state {
unsigned int dac_cache[AD5064_MAX_DAC_CHANNELS]; unsigned int dac_cache[AD5064_MAX_DAC_CHANNELS];
bool use_internal_vref; bool use_internal_vref;
ad5064_write_func write;
/* /*
* DMA (thus cache coherency maintenance) requires the * DMA (thus cache coherency maintenance) requires the
* transfer buffers to live in their own cache lines. * transfer buffers to live in their own cache lines.
*/ */
__be32 data ____cacheline_aligned; union {
u8 i2c[3];
__be32 spi;
} data ____cacheline_aligned;
}; };
enum ad5064_type { enum ad5064_type {
...@@ -109,14 +122,31 @@ enum ad5064_type { ...@@ -109,14 +122,31 @@ enum ad5064_type {
ID_AD5668_2, ID_AD5668_2,
}; };
static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
unsigned int addr, unsigned int val)
{
struct i2c_client *i2c = to_i2c_client(st->dev);
st->data.i2c[0] = (cmd << 4) | addr;
put_unaligned_be16(val, &st->data.i2c[1]);
return i2c_master_send(i2c, st->data.i2c, 3);
}
static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd, static int ad5064_spi_write(struct ad5064_state *st, unsigned int cmd,
unsigned int addr, unsigned int val)
{
struct spi_device *spi = to_spi_device(st->dev);
st->data.spi = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val);
return spi_write(spi, &st->data.spi, sizeof(st->data.spi));
}
static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
unsigned int addr, unsigned int val, unsigned int shift) unsigned int addr, unsigned int val, unsigned int shift)
{ {
val <<= shift; val <<= shift;
st->data = cpu_to_be32(AD5064_CMD(cmd) | AD5064_ADDR(addr) | val); return st->write(st, cmd, addr, val);
return spi_write(st->spi, &st->data, sizeof(st->data));
} }
static int ad5064_sync_powerdown_mode(struct ad5064_state *st, static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
...@@ -130,7 +160,7 @@ static int ad5064_sync_powerdown_mode(struct ad5064_state *st, ...@@ -130,7 +160,7 @@ static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
if (st->pwr_down[channel]) if (st->pwr_down[channel])
val |= st->pwr_down_mode[channel] << 8; val |= st->pwr_down_mode[channel] << 8;
ret = ad5064_spi_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0); ret = ad5064_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0);
return ret; return ret;
} }
...@@ -251,7 +281,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev, ...@@ -251,7 +281,7 @@ static int ad5064_write_raw(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
mutex_lock(&indio_dev->mlock); mutex_lock(&indio_dev->mlock);
ret = ad5064_spi_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N, ret = ad5064_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N,
chan->address, val, chan->scan_type.shift); chan->address, val, chan->scan_type.shift);
if (ret == 0) if (ret == 0)
st->dac_cache[chan->channel] = val; st->dac_cache[chan->channel] = val;
...@@ -413,9 +443,9 @@ static const char * const ad5064_vref_name(struct ad5064_state *st, ...@@ -413,9 +443,9 @@ static const char * const ad5064_vref_name(struct ad5064_state *st,
return st->chip_info->shared_vref ? "vref" : ad5064_vref_names[vref]; return st->chip_info->shared_vref ? "vref" : ad5064_vref_names[vref];
} }
static int __devinit ad5064_probe(struct spi_device *spi) static int __devinit ad5064_probe(struct device *dev, enum ad5064_type type,
const char *name, ad5064_write_func write)
{ {
enum ad5064_type type = spi_get_device_id(spi)->driver_data;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
struct ad5064_state *st; struct ad5064_state *st;
unsigned int i; unsigned int i;
...@@ -426,24 +456,25 @@ static int __devinit ad5064_probe(struct spi_device *spi) ...@@ -426,24 +456,25 @@ static int __devinit ad5064_probe(struct spi_device *spi)
return -ENOMEM; return -ENOMEM;
st = iio_priv(indio_dev); st = iio_priv(indio_dev);
spi_set_drvdata(spi, indio_dev); dev_set_drvdata(dev, indio_dev);
st->chip_info = &ad5064_chip_info_tbl[type]; st->chip_info = &ad5064_chip_info_tbl[type];
st->spi = spi; st->dev = dev;
st->write = write;
for (i = 0; i < ad5064_num_vref(st); ++i) for (i = 0; i < ad5064_num_vref(st); ++i)
st->vref_reg[i].supply = ad5064_vref_name(st, i); st->vref_reg[i].supply = ad5064_vref_name(st, i);
ret = regulator_bulk_get(&st->spi->dev, ad5064_num_vref(st), ret = regulator_bulk_get(dev, ad5064_num_vref(st),
st->vref_reg); st->vref_reg);
if (ret) { if (ret) {
if (!st->chip_info->internal_vref) if (!st->chip_info->internal_vref)
goto error_free; goto error_free;
st->use_internal_vref = true; st->use_internal_vref = true;
ret = ad5064_spi_write(st, AD5064_CMD_CONFIG, 0, ret = ad5064_write(st, AD5064_CMD_CONFIG, 0,
AD5064_CONFIG_INT_VREF_ENABLE, 0); AD5064_CONFIG_INT_VREF_ENABLE, 0);
if (ret) { if (ret) {
dev_err(&spi->dev, "Failed to enable internal vref: %d\n", dev_err(dev, "Failed to enable internal vref: %d\n",
ret); ret);
goto error_free; goto error_free;
} }
...@@ -458,8 +489,8 @@ static int __devinit ad5064_probe(struct spi_device *spi) ...@@ -458,8 +489,8 @@ static int __devinit ad5064_probe(struct spi_device *spi)
st->dac_cache[i] = 0x8000; st->dac_cache[i] = 0x8000;
} }
indio_dev->dev.parent = &spi->dev; indio_dev->dev.parent = dev;
indio_dev->name = spi_get_device_id(spi)->name; indio_dev->name = name;
indio_dev->info = &ad5064_info; indio_dev->info = &ad5064_info;
indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = st->chip_info->channels; indio_dev->channels = st->chip_info->channels;
...@@ -483,10 +514,9 @@ static int __devinit ad5064_probe(struct spi_device *spi) ...@@ -483,10 +514,9 @@ static int __devinit ad5064_probe(struct spi_device *spi)
return ret; return ret;
} }
static int __devexit ad5064_remove(struct device *dev)
static int __devexit ad5064_remove(struct spi_device *spi)
{ {
struct iio_dev *indio_dev = spi_get_drvdata(spi); struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct ad5064_state *st = iio_priv(indio_dev); struct ad5064_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev); iio_device_unregister(indio_dev);
...@@ -501,7 +531,22 @@ static int __devexit ad5064_remove(struct spi_device *spi) ...@@ -501,7 +531,22 @@ static int __devexit ad5064_remove(struct spi_device *spi)
return 0; return 0;
} }
static const struct spi_device_id ad5064_id[] = { #if IS_ENABLED(CONFIG_SPI_MASTER)
static int __devinit ad5064_spi_probe(struct spi_device *spi)
{
const struct spi_device_id *id = spi_get_device_id(spi);
return ad5064_probe(&spi->dev, id->driver_data, id->name,
ad5064_spi_write);
}
static int __devexit ad5064_spi_remove(struct spi_device *spi)
{
return ad5064_remove(&spi->dev);
}
static const struct spi_device_id ad5064_spi_ids[] = {
{"ad5024", ID_AD5024}, {"ad5024", ID_AD5024},
{"ad5025", ID_AD5025}, {"ad5025", ID_AD5025},
{"ad5044", ID_AD5044}, {"ad5044", ID_AD5044},
...@@ -520,19 +565,112 @@ static const struct spi_device_id ad5064_id[] = { ...@@ -520,19 +565,112 @@ static const struct spi_device_id ad5064_id[] = {
{"ad5668-3", ID_AD5668_2}, /* similar enough to ad5668-2 */ {"ad5668-3", ID_AD5668_2}, /* similar enough to ad5668-2 */
{} {}
}; };
MODULE_DEVICE_TABLE(spi, ad5064_id); MODULE_DEVICE_TABLE(spi, ad5064_spi_ids);
static struct spi_driver ad5064_driver = { static struct spi_driver ad5064_spi_driver = {
.driver = { .driver = {
.name = "ad5064", .name = "ad5064",
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = ad5064_probe, .probe = ad5064_spi_probe,
.remove = __devexit_p(ad5064_remove), .remove = __devexit_p(ad5064_spi_remove),
.id_table = ad5064_id, .id_table = ad5064_spi_ids,
}; };
module_spi_driver(ad5064_driver);
static int __init ad5064_spi_register_driver(void)
{
return spi_register_driver(&ad5064_spi_driver);
}
static void __exit ad5064_spi_unregister_driver(void)
{
spi_unregister_driver(&ad5064_spi_driver);
}
#else
static inline int ad5064_spi_register_driver(void) { return 0; }
static inline void ad5064_spi_unregister_driver(void) { }
#endif
#if IS_ENABLED(CONFIG_I2C)
static int __devinit ad5064_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
return ad5064_probe(&i2c->dev, id->driver_data, id->name,
ad5064_i2c_write);
}
static int __devexit ad5064_i2c_remove(struct i2c_client *i2c)
{
return ad5064_remove(&i2c->dev);
}
static const struct i2c_device_id ad5064_i2c_ids[] = {
{"ad5629-1", ID_AD5628_1},
{"ad5629-2", ID_AD5628_2},
{"ad5629-3", ID_AD5628_2}, /* similar enough to ad5629-2 */
{"ad5669-1", ID_AD5668_1},
{"ad5669-2", ID_AD5668_2},
{"ad5669-3", ID_AD5668_2}, /* similar enough to ad5669-2 */
{}
};
MODULE_DEVICE_TABLE(i2c, ad5064_i2c_ids);
static struct i2c_driver ad5064_i2c_driver = {
.driver = {
.name = "ad5064",
.owner = THIS_MODULE,
},
.probe = ad5064_i2c_probe,
.remove = __devexit_p(ad5064_i2c_remove),
.id_table = ad5064_i2c_ids,
};
static int __init ad5064_i2c_register_driver(void)
{
return i2c_add_driver(&ad5064_i2c_driver);
}
static void __exit ad5064_i2c_unregister_driver(void)
{
i2c_del_driver(&ad5064_i2c_driver);
}
#else
static inline int ad5064_i2c_register_driver(void) { return 0; }
static inline void ad5064_i2c_unregister_driver(void) { }
#endif
static int __init ad5064_init(void)
{
int ret;
ret = ad5064_spi_register_driver();
if (ret)
return ret;
ret = ad5064_i2c_register_driver();
if (ret) {
ad5064_spi_unregister_driver();
return ret;
}
return 0;
}
module_init(ad5064_init);
static void __exit ad5064_exit(void)
{
ad5064_i2c_unregister_driver();
ad5064_spi_unregister_driver();
}
module_exit(ad5064_exit);
MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
MODULE_DESCRIPTION("Analog Devices AD5024/25/44/45/64/64-1/65, AD5628/48/66/68 DAC"); MODULE_DESCRIPTION("Analog Devices AD5024 and similar multi-channel DACs");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -70,6 +70,8 @@ static const char * const iio_modifier_names[] = { ...@@ -70,6 +70,8 @@ static const char * const iio_modifier_names[] = {
[IIO_MOD_X] = "x", [IIO_MOD_X] = "x",
[IIO_MOD_Y] = "y", [IIO_MOD_Y] = "y",
[IIO_MOD_Z] = "z", [IIO_MOD_Z] = "z",
[IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
[IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
[IIO_MOD_LIGHT_BOTH] = "both", [IIO_MOD_LIGHT_BOTH] = "both",
[IIO_MOD_LIGHT_IR] = "ir", [IIO_MOD_LIGHT_IR] = "ir",
}; };
......
...@@ -92,8 +92,7 @@ int iio_map_array_unregister(struct iio_dev *indio_dev, ...@@ -92,8 +92,7 @@ int iio_map_array_unregister(struct iio_dev *indio_dev,
EXPORT_SYMBOL_GPL(iio_map_array_unregister); EXPORT_SYMBOL_GPL(iio_map_array_unregister);
static const struct iio_chan_spec static const struct iio_chan_spec
*iio_chan_spec_from_name(const struct iio_dev *indio_dev, *iio_chan_spec_from_name(const struct iio_dev *indio_dev, const char *name)
const char *name)
{ {
int i; int i;
const struct iio_chan_spec *chan = NULL; const struct iio_chan_spec *chan = NULL;
...@@ -108,8 +107,7 @@ static const struct iio_chan_spec ...@@ -108,8 +107,7 @@ static const struct iio_chan_spec
} }
struct iio_channel *iio_st_channel_get(const char *name, struct iio_channel *iio_channel_get(const char *name, const char *channel_name)
const char *channel_name)
{ {
struct iio_map_internal *c_i = NULL, *c = NULL; struct iio_map_internal *c_i = NULL, *c = NULL;
struct iio_channel *channel; struct iio_channel *channel;
...@@ -145,16 +143,16 @@ struct iio_channel *iio_st_channel_get(const char *name, ...@@ -145,16 +143,16 @@ struct iio_channel *iio_st_channel_get(const char *name,
return channel; return channel;
} }
EXPORT_SYMBOL_GPL(iio_st_channel_get); EXPORT_SYMBOL_GPL(iio_channel_get);
void iio_st_channel_release(struct iio_channel *channel) void iio_channel_release(struct iio_channel *channel)
{ {
iio_device_put(channel->indio_dev); iio_device_put(channel->indio_dev);
kfree(channel); kfree(channel);
} }
EXPORT_SYMBOL_GPL(iio_st_channel_release); EXPORT_SYMBOL_GPL(iio_channel_release);
struct iio_channel *iio_st_channel_get_all(const char *name) struct iio_channel *iio_channel_get_all(const char *name)
{ {
struct iio_channel *chans; struct iio_channel *chans;
struct iio_map_internal *c = NULL; struct iio_map_internal *c = NULL;
...@@ -217,9 +215,9 @@ struct iio_channel *iio_st_channel_get_all(const char *name) ...@@ -217,9 +215,9 @@ struct iio_channel *iio_st_channel_get_all(const char *name)
return ERR_PTR(ret); return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(iio_st_channel_get_all); EXPORT_SYMBOL_GPL(iio_channel_get_all);
void iio_st_channel_release_all(struct iio_channel *channels) void iio_channel_release_all(struct iio_channel *channels)
{ {
struct iio_channel *chan = &channels[0]; struct iio_channel *chan = &channels[0];
...@@ -229,9 +227,9 @@ void iio_st_channel_release_all(struct iio_channel *channels) ...@@ -229,9 +227,9 @@ void iio_st_channel_release_all(struct iio_channel *channels)
} }
kfree(channels); kfree(channels);
} }
EXPORT_SYMBOL_GPL(iio_st_channel_release_all); EXPORT_SYMBOL_GPL(iio_channel_release_all);
int iio_st_read_channel_raw(struct iio_channel *chan, int *val) int iio_read_channel_raw(struct iio_channel *chan, int *val)
{ {
int val2, ret; int val2, ret;
...@@ -248,9 +246,9 @@ int iio_st_read_channel_raw(struct iio_channel *chan, int *val) ...@@ -248,9 +246,9 @@ int iio_st_read_channel_raw(struct iio_channel *chan, int *val)
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(iio_st_read_channel_raw); EXPORT_SYMBOL_GPL(iio_read_channel_raw);
int iio_st_read_channel_scale(struct iio_channel *chan, int *val, int *val2) int iio_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
{ {
int ret; int ret;
...@@ -269,10 +267,9 @@ int iio_st_read_channel_scale(struct iio_channel *chan, int *val, int *val2) ...@@ -269,10 +267,9 @@ int iio_st_read_channel_scale(struct iio_channel *chan, int *val, int *val2)
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(iio_st_read_channel_scale); EXPORT_SYMBOL_GPL(iio_read_channel_scale);
int iio_st_get_channel_type(struct iio_channel *chan, int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
enum iio_chan_type *type)
{ {
int ret = 0; int ret = 0;
/* Need to verify underlying driver has not gone away */ /* Need to verify underlying driver has not gone away */
...@@ -289,4 +286,4 @@ int iio_st_get_channel_type(struct iio_channel *chan, ...@@ -289,4 +286,4 @@ int iio_st_get_channel_type(struct iio_channel *chan,
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(iio_st_get_channel_type); EXPORT_SYMBOL_GPL(iio_get_channel_type);
...@@ -159,21 +159,6 @@ static int adis16201_reset(struct iio_dev *indio_dev) ...@@ -159,21 +159,6 @@ static int adis16201_reset(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16201_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
int ret;
bool res;
if (len < 1)
return -EINVAL;
ret = strtobool(buf, &res);
if (ret || !res)
return ret;
return adis16201_reset(dev_to_iio_dev(dev));
}
int adis16201_set_irq(struct iio_dev *indio_dev, bool enable) int adis16201_set_irq(struct iio_dev *indio_dev, bool enable)
{ {
int ret = 0; int ret = 0;
...@@ -507,19 +492,7 @@ static struct iio_chan_spec adis16201_channels[] = { ...@@ -507,19 +492,7 @@ static struct iio_chan_spec adis16201_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(7) IIO_CHAN_SOFT_TIMESTAMP(7)
}; };
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16201_write_reset, 0);
static struct attribute *adis16201_attributes[] = {
&iio_dev_attr_reset.dev_attr.attr,
NULL
};
static const struct attribute_group adis16201_attribute_group = {
.attrs = adis16201_attributes,
};
static const struct iio_info adis16201_info = { static const struct iio_info adis16201_info = {
.attrs = &adis16201_attribute_group,
.read_raw = &adis16201_read_raw, .read_raw = &adis16201_read_raw,
.write_raw = &adis16201_write_raw, .write_raw = &adis16201_write_raw,
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
......
...@@ -178,22 +178,6 @@ static int adis16203_reset(struct iio_dev *indio_dev) ...@@ -178,22 +178,6 @@ static int adis16203_reset(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16203_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
if (len < 1)
return -EINVAL;
switch (buf[0]) {
case '1':
case 'y':
case 'Y':
return adis16203_reset(indio_dev);
}
return -EINVAL;
}
int adis16203_set_irq(struct iio_dev *indio_dev, bool enable) int adis16203_set_irq(struct iio_dev *indio_dev, bool enable)
{ {
int ret = 0; int ret = 0;
...@@ -444,19 +428,7 @@ static struct iio_chan_spec adis16203_channels[] = { ...@@ -444,19 +428,7 @@ static struct iio_chan_spec adis16203_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(5), IIO_CHAN_SOFT_TIMESTAMP(5),
}; };
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16203_write_reset, 0);
static struct attribute *adis16203_attributes[] = {
&iio_dev_attr_reset.dev_attr.attr,
NULL
};
static const struct attribute_group adis16203_attribute_group = {
.attrs = adis16203_attributes,
};
static const struct iio_info adis16203_info = { static const struct iio_info adis16203_info = {
.attrs = &adis16203_attribute_group,
.read_raw = &adis16203_read_raw, .read_raw = &adis16203_read_raw,
.write_raw = &adis16203_write_raw, .write_raw = &adis16203_write_raw,
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
......
...@@ -169,32 +169,6 @@ static int adis16204_check_status(struct iio_dev *indio_dev) ...@@ -169,32 +169,6 @@ static int adis16204_check_status(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16204_read_14bit_signed(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
s16 val = 0;
ssize_t ret;
mutex_lock(&indio_dev->mlock);
ret = adis16204_spi_read_reg_16(indio_dev,
this_attr->address, (u16 *)&val);
if (!ret) {
if (val & ADIS16204_ERROR_ACTIVE)
adis16204_check_status(indio_dev);
val = ((s16)(val << 2) >> 2);
ret = sprintf(buf, "%d\n", val);
}
mutex_unlock(&indio_dev->mlock);
return ret;
}
static int adis16204_reset(struct iio_dev *indio_dev) static int adis16204_reset(struct iio_dev *indio_dev)
{ {
int ret; int ret;
...@@ -207,23 +181,6 @@ static int adis16204_reset(struct iio_dev *indio_dev) ...@@ -207,23 +181,6 @@ static int adis16204_reset(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16204_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
if (len < 1)
return -EINVAL;
switch (buf[0]) {
case '1':
case 'y':
case 'Y':
return adis16204_reset(indio_dev);
}
return -EINVAL;
}
int adis16204_set_irq(struct iio_dev *indio_dev, bool enable) int adis16204_set_irq(struct iio_dev *indio_dev, bool enable)
{ {
int ret = 0; int ret = 0;
...@@ -299,18 +256,6 @@ static int adis16204_initial_setup(struct iio_dev *indio_dev) ...@@ -299,18 +256,6 @@ static int adis16204_initial_setup(struct iio_dev *indio_dev)
} }
/* Unique to this driver currently */ /* Unique to this driver currently */
#define IIO_DEV_ATTR_ACCEL_XY(_show, _addr) \
IIO_DEVICE_ATTR(in_accel_xy, S_IRUGO, _show, NULL, _addr)
#define IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr) \
IIO_DEVICE_ATTR(in_accel_xypeak, S_IRUGO, _show, NULL, _addr)
static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed,
ADIS16204_XY_RSS_OUT);
static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed,
ADIS16204_XY_PEAK_OUT);
static IIO_CONST_ATTR(in_accel_xy_scale, "0.017125");
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16204_write_reset, 0);
enum adis16204_channel { enum adis16204_channel {
in_supply, in_supply,
...@@ -318,9 +263,10 @@ enum adis16204_channel { ...@@ -318,9 +263,10 @@ enum adis16204_channel {
temp, temp,
accel_x, accel_x,
accel_y, accel_y,
accel_xy,
}; };
static u8 adis16204_addresses[5][3] = { static u8 adis16204_addresses[6][3] = {
[in_supply] = { ADIS16204_SUPPLY_OUT }, [in_supply] = { ADIS16204_SUPPLY_OUT },
[in_aux] = { ADIS16204_AUX_ADC }, [in_aux] = { ADIS16204_AUX_ADC },
[temp] = { ADIS16204_TEMP_OUT }, [temp] = { ADIS16204_TEMP_OUT },
...@@ -328,6 +274,8 @@ static u8 adis16204_addresses[5][3] = { ...@@ -328,6 +274,8 @@ static u8 adis16204_addresses[5][3] = {
ADIS16204_X_PEAK_OUT }, ADIS16204_X_PEAK_OUT },
[accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL, [accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL,
ADIS16204_Y_PEAK_OUT }, ADIS16204_Y_PEAK_OUT },
[accel_xy] = { ADIS16204_XY_RSS_OUT, 0,
ADIS16204_XY_PEAK_OUT },
}; };
static int adis16204_read_raw(struct iio_dev *indio_dev, static int adis16204_read_raw(struct iio_dev *indio_dev,
...@@ -381,10 +329,16 @@ static int adis16204_read_raw(struct iio_dev *indio_dev, ...@@ -381,10 +329,16 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case IIO_ACCEL: case IIO_ACCEL:
*val = 0; *val = 0;
if (chan->channel2 == IIO_MOD_X) switch (chan->channel2) {
case IIO_MOD_X:
case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
*val2 = 17125; *val2 = 17125;
else break;
case IIO_MOD_Y:
case IIO_MOD_Z:
*val2 = 8407; *val2 = 8407;
break;
}
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
default: default:
return -EINVAL; return -EINVAL;
...@@ -517,22 +471,23 @@ static struct iio_chan_spec adis16204_channels[] = { ...@@ -517,22 +471,23 @@ static struct iio_chan_spec adis16204_channels[] = {
}, },
}, },
IIO_CHAN_SOFT_TIMESTAMP(5), IIO_CHAN_SOFT_TIMESTAMP(5),
}; {
.type = IIO_ACCEL,
static struct attribute *adis16204_attributes[] = { .modified = 1,
&iio_dev_attr_reset.dev_attr.attr, .channel2 = IIO_MOD_ROOT_SUM_SQUARED_X_Y,
&iio_dev_attr_in_accel_xy.dev_attr.attr, .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
&iio_dev_attr_in_accel_xypeak.dev_attr.attr, IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
&iio_const_attr_in_accel_xy_scale.dev_attr.attr, IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
NULL .address = accel_xy,
}; .scan_type = {
.sign = 'u',
static const struct attribute_group adis16204_attribute_group = { .realbits = 14,
.attrs = adis16204_attributes, .storagebits = 16,
},
}
}; };
static const struct iio_info adis16204_info = { static const struct iio_info adis16204_info = {
.attrs = &adis16204_attribute_group,
.read_raw = &adis16204_read_raw, .read_raw = &adis16204_read_raw,
.write_raw = &adis16204_write_raw, .write_raw = &adis16204_write_raw,
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
...@@ -569,7 +524,7 @@ static int __devinit adis16204_probe(struct spi_device *spi) ...@@ -569,7 +524,7 @@ static int __devinit adis16204_probe(struct spi_device *spi)
ret = iio_buffer_register(indio_dev, ret = iio_buffer_register(indio_dev,
adis16204_channels, adis16204_channels,
ARRAY_SIZE(adis16204_channels)); 6);
if (ret) { if (ret) {
printk(KERN_ERR "failed to initialize the ring\n"); printk(KERN_ERR "failed to initialize the ring\n");
goto error_unreg_ring_funcs; goto error_unreg_ring_funcs;
......
...@@ -153,23 +153,6 @@ static int adis16209_reset(struct iio_dev *indio_dev) ...@@ -153,23 +153,6 @@ static int adis16209_reset(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16209_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
if (len < 1)
return -EINVAL;
switch (buf[0]) {
case '1':
case 'y':
case 'Y':
return adis16209_reset(indio_dev);
}
return -EINVAL;
}
int adis16209_set_irq(struct iio_dev *indio_dev, bool enable) int adis16209_set_irq(struct iio_dev *indio_dev, bool enable)
{ {
int ret = 0; int ret = 0;
...@@ -519,19 +502,7 @@ static struct iio_chan_spec adis16209_channels[] = { ...@@ -519,19 +502,7 @@ static struct iio_chan_spec adis16209_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(8) IIO_CHAN_SOFT_TIMESTAMP(8)
}; };
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0);
static struct attribute *adis16209_attributes[] = {
&iio_dev_attr_reset.dev_attr.attr,
NULL
};
static const struct attribute_group adis16209_attribute_group = {
.attrs = adis16209_attributes,
};
static const struct iio_info adis16209_info = { static const struct iio_info adis16209_info = {
.attrs = &adis16209_attribute_group,
.read_raw = &adis16209_read_raw, .read_raw = &adis16209_read_raw,
.write_raw = &adis16209_write_raw, .write_raw = &adis16209_write_raw,
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
......
...@@ -204,26 +204,6 @@ static int adis16220_reset(struct iio_dev *indio_dev) ...@@ -204,26 +204,6 @@ static int adis16220_reset(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16220_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
bool val;
int ret;
ret = strtobool(buf, &val);
if (ret)
return ret;
if (!val)
return -EINVAL;
ret = adis16220_reset(indio_dev);
if (ret)
return ret;
return len;
}
static ssize_t adis16220_write_capture(struct device *dev, static ssize_t adis16220_write_capture(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t len) const char *buf, size_t len)
...@@ -454,9 +434,6 @@ static struct bin_attribute adc2_bin = { ...@@ -454,9 +434,6 @@ static struct bin_attribute adc2_bin = {
.size = ADIS16220_CAPTURE_SIZE, .size = ADIS16220_CAPTURE_SIZE,
}; };
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL,
adis16220_write_reset, 0);
#define IIO_DEV_ATTR_CAPTURE(_store) \ #define IIO_DEV_ATTR_CAPTURE(_store) \
IIO_DEVICE_ATTR(capture, S_IWUSR, NULL, _store, 0) IIO_DEVICE_ATTR(capture, S_IWUSR, NULL, _store, 0)
...@@ -611,7 +588,6 @@ static const struct iio_chan_spec adis16220_channels[] = { ...@@ -611,7 +588,6 @@ static const struct iio_chan_spec adis16220_channels[] = {
}; };
static struct attribute *adis16220_attributes[] = { static struct attribute *adis16220_attributes[] = {
&iio_dev_attr_reset.dev_attr.attr,
&iio_dev_attr_capture.dev_attr.attr, &iio_dev_attr_capture.dev_attr.attr,
&iio_dev_attr_capture_count.dev_attr.attr, &iio_dev_attr_capture_count.dev_attr.attr,
NULL NULL
......
...@@ -199,23 +199,6 @@ static int adis16240_reset(struct iio_dev *indio_dev) ...@@ -199,23 +199,6 @@ static int adis16240_reset(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16240_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
if (len < 1)
return -EINVAL;
switch (buf[0]) {
case '1':
case 'y':
case 'Y':
return adis16240_reset(indio_dev);
}
return -EINVAL;
}
int adis16240_set_irq(struct iio_dev *indio_dev, bool enable) int adis16240_set_irq(struct iio_dev *indio_dev, bool enable)
{ {
int ret = 0; int ret = 0;
...@@ -329,8 +312,6 @@ static IIO_DEVICE_ATTR(in_accel_xyz_squared_peak_raw, S_IRUGO, ...@@ -329,8 +312,6 @@ static IIO_DEVICE_ATTR(in_accel_xyz_squared_peak_raw, S_IRUGO,
adis16240_read_12bit_signed, NULL, adis16240_read_12bit_signed, NULL,
ADIS16240_XYZPEAK_OUT); ADIS16240_XYZPEAK_OUT);
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16240_write_reset, 0);
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096"); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096");
enum adis16240_chan { enum adis16240_chan {
...@@ -559,7 +540,6 @@ static struct iio_chan_spec adis16240_channels[] = { ...@@ -559,7 +540,6 @@ static struct iio_chan_spec adis16240_channels[] = {
static struct attribute *adis16240_attributes[] = { static struct attribute *adis16240_attributes[] = {
&iio_dev_attr_in_accel_xyz_squared_peak_raw.dev_attr.attr, &iio_dev_attr_in_accel_xyz_squared_peak_raw.dev_attr.attr,
&iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
NULL NULL
}; };
......
...@@ -233,22 +233,6 @@ static int adis16260_reset(struct iio_dev *indio_dev) ...@@ -233,22 +233,6 @@ static int adis16260_reset(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16260_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
if (len < 1)
return -EINVAL;
switch (buf[0]) {
case '1':
case 'y':
case 'Y':
return adis16260_reset(indio_dev);
}
return -EINVAL;
}
int adis16260_set_irq(struct iio_dev *indio_dev, bool enable) int adis16260_set_irq(struct iio_dev *indio_dev, bool enable)
{ {
int ret; int ret;
...@@ -375,8 +359,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ...@@ -375,8 +359,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
adis16260_read_frequency, adis16260_read_frequency,
adis16260_write_frequency); adis16260_write_frequency);
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16260_write_reset, 0);
static IIO_DEVICE_ATTR(sampling_frequency_available, static IIO_DEVICE_ATTR(sampling_frequency_available,
S_IRUGO, adis16260_read_frequency_available, NULL, 0); S_IRUGO, adis16260_read_frequency_available, NULL, 0);
...@@ -604,7 +586,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, ...@@ -604,7 +586,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
static struct attribute *adis16260_attributes[] = { static struct attribute *adis16260_attributes[] = {
&iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_dev_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
NULL NULL
}; };
......
...@@ -51,12 +51,12 @@ static ssize_t iio_hwmon_read_val(struct device *dev, ...@@ -51,12 +51,12 @@ static ssize_t iio_hwmon_read_val(struct device *dev,
* No locking between this pair, so theoretically possible * No locking between this pair, so theoretically possible
* the scale has changed. * the scale has changed.
*/ */
ret = iio_st_read_channel_raw(&state->channels[sattr->index], ret = iio_read_channel_raw(&state->channels[sattr->index],
&val); &val);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = iio_st_read_channel_scale(&state->channels[sattr->index], ret = iio_read_channel_scale(&state->channels[sattr->index],
&scaleint, &scalepart); &scaleint, &scalepart);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -106,7 +106,7 @@ static int __devinit iio_hwmon_probe(struct platform_device *pdev) ...@@ -106,7 +106,7 @@ static int __devinit iio_hwmon_probe(struct platform_device *pdev)
goto error_ret; goto error_ret;
} }
st->channels = iio_st_channel_get_all(dev_name(&pdev->dev)); st->channels = iio_channel_get_all(dev_name(&pdev->dev));
if (IS_ERR(st->channels)) { if (IS_ERR(st->channels)) {
ret = PTR_ERR(st->channels); ret = PTR_ERR(st->channels);
goto error_free_state; goto error_free_state;
...@@ -130,7 +130,7 @@ static int __devinit iio_hwmon_probe(struct platform_device *pdev) ...@@ -130,7 +130,7 @@ static int __devinit iio_hwmon_probe(struct platform_device *pdev)
} }
sysfs_attr_init(&a->dev_attr.attr); sysfs_attr_init(&a->dev_attr.attr);
ret = iio_st_get_channel_type(&st->channels[i], &type); ret = iio_get_channel_type(&st->channels[i], &type);
if (ret < 0) { if (ret < 0) {
kfree(a); kfree(a);
goto error_free_attrs; goto error_free_attrs;
...@@ -186,7 +186,7 @@ static int __devinit iio_hwmon_probe(struct platform_device *pdev) ...@@ -186,7 +186,7 @@ static int __devinit iio_hwmon_probe(struct platform_device *pdev)
iio_hwmon_free_attrs(st); iio_hwmon_free_attrs(st);
kfree(st->attrs); kfree(st->attrs);
error_release_channels: error_release_channels:
iio_st_channel_release_all(st->channels); iio_channel_release_all(st->channels);
error_free_state: error_free_state:
kfree(st); kfree(st);
error_ret: error_ret:
...@@ -201,7 +201,7 @@ static int __devexit iio_hwmon_remove(struct platform_device *pdev) ...@@ -201,7 +201,7 @@ static int __devexit iio_hwmon_remove(struct platform_device *pdev)
sysfs_remove_group(&pdev->dev.kobj, &st->attr_group); sysfs_remove_group(&pdev->dev.kobj, &st->attr_group);
iio_hwmon_free_attrs(st); iio_hwmon_free_attrs(st);
kfree(st->attrs); kfree(st->attrs);
iio_st_channel_release_all(st->channels); iio_channel_release_all(st->channels);
return 0; return 0;
} }
......
...@@ -268,25 +268,6 @@ static int adis16400_reset(struct iio_dev *indio_dev) ...@@ -268,25 +268,6 @@ static int adis16400_reset(struct iio_dev *indio_dev)
return ret; return ret;
} }
static ssize_t adis16400_write_reset(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
bool val;
int ret;
ret = strtobool(buf, &val);
if (ret < 0)
return ret;
if (val) {
ret = adis16400_reset(dev_to_iio_dev(dev));
if (ret < 0)
return ret;
}
return len;
}
int adis16400_set_irq(struct iio_dev *indio_dev, bool enable) int adis16400_set_irq(struct iio_dev *indio_dev, bool enable)
{ {
int ret; int ret;
...@@ -454,8 +435,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ...@@ -454,8 +435,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
adis16400_read_frequency, adis16400_read_frequency,
adis16400_write_frequency); adis16400_write_frequency);
static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16400_write_reset, 0);
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638"); static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
enum adis16400_chan { enum adis16400_chan {
...@@ -1066,7 +1045,6 @@ static const struct iio_chan_spec adis16334_channels[] = { ...@@ -1066,7 +1045,6 @@ static const struct iio_chan_spec adis16334_channels[] = {
static struct attribute *adis16400_attributes[] = { static struct attribute *adis16400_attributes[] = {
&iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr,
&iio_const_attr_sampling_frequency_available.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr,
&iio_dev_attr_reset.dev_attr.attr,
NULL NULL
}; };
......
...@@ -33,17 +33,17 @@ struct iio_channel { ...@@ -33,17 +33,17 @@ struct iio_channel {
* side. This typically describes the channels use within * side. This typically describes the channels use within
* the consumer. E.g. 'battery_voltage' * the consumer. E.g. 'battery_voltage'
*/ */
struct iio_channel *iio_st_channel_get(const char *name, struct iio_channel *iio_channel_get(const char *name,
const char *consumer_channel); const char *consumer_channel);
/** /**
* iio_st_channel_release() - release channels obtained via iio_st_channel_get * iio_channel_release() - release channels obtained via iio_channel_get
* @chan: The channel to be released. * @chan: The channel to be released.
*/ */
void iio_st_channel_release(struct iio_channel *chan); void iio_channel_release(struct iio_channel *chan);
/** /**
* iio_st_channel_get_all() - get all channels associated with a client * iio_channel_get_all() - get all channels associated with a client
* @name: name of consumer device. * @name: name of consumer device.
* *
* Returns an array of iio_channel structures terminated with one with * Returns an array of iio_channel structures terminated with one with
...@@ -51,37 +51,37 @@ void iio_st_channel_release(struct iio_channel *chan); ...@@ -51,37 +51,37 @@ void iio_st_channel_release(struct iio_channel *chan);
* This function is used by fairly generic consumers to get all the * This function is used by fairly generic consumers to get all the
* channels registered as having this consumer. * channels registered as having this consumer.
*/ */
struct iio_channel *iio_st_channel_get_all(const char *name); struct iio_channel *iio_channel_get_all(const char *name);
/** /**
* iio_st_channel_release_all() - reverse iio_st_get_all * iio_channel_release_all() - reverse iio_channel_get_all
* @chan: Array of channels to be released. * @chan: Array of channels to be released.
*/ */
void iio_st_channel_release_all(struct iio_channel *chan); void iio_channel_release_all(struct iio_channel *chan);
/** /**
* iio_st_read_channel_raw() - read from a given channel * iio_read_channel_raw() - read from a given channel
* @channel: The channel being queried. * @channel: The channel being queried.
* @val: Value read back. * @val: Value read back.
* *
* Note raw reads from iio channels are in adc counts and hence * Note raw reads from iio channels are in adc counts and hence
* scale will need to be applied if standard units required. * scale will need to be applied if standard units required.
*/ */
int iio_st_read_channel_raw(struct iio_channel *chan, int iio_read_channel_raw(struct iio_channel *chan,
int *val); int *val);
/** /**
* iio_st_get_channel_type() - get the type of a channel * iio_get_channel_type() - get the type of a channel
* @channel: The channel being queried. * @channel: The channel being queried.
* @type: The type of the channel. * @type: The type of the channel.
* *
* returns the enum iio_chan_type of the channel * returns the enum iio_chan_type of the channel
*/ */
int iio_st_get_channel_type(struct iio_channel *channel, int iio_get_channel_type(struct iio_channel *channel,
enum iio_chan_type *type); enum iio_chan_type *type);
/** /**
* iio_st_read_channel_scale() - read the scale value for a channel * iio_read_channel_scale() - read the scale value for a channel
* @channel: The channel being queried. * @channel: The channel being queried.
* @val: First part of value read back. * @val: First part of value read back.
* @val2: Second part of value read back. * @val2: Second part of value read back.
...@@ -90,7 +90,7 @@ int iio_st_get_channel_type(struct iio_channel *channel, ...@@ -90,7 +90,7 @@ int iio_st_get_channel_type(struct iio_channel *channel,
* as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val * as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val
* + val2/1e6 * + val2/1e6
*/ */
int iio_st_read_channel_scale(struct iio_channel *chan, int *val, int iio_read_channel_scale(struct iio_channel *chan, int *val,
int *val2); int *val2);
#endif #endif
...@@ -44,6 +44,8 @@ enum iio_modifier { ...@@ -44,6 +44,8 @@ enum iio_modifier {
IIO_MOD_X_OR_Y_OR_Z, IIO_MOD_X_OR_Y_OR_Z,
IIO_MOD_LIGHT_BOTH, IIO_MOD_LIGHT_BOTH,
IIO_MOD_LIGHT_IR, IIO_MOD_LIGHT_IR,
IIO_MOD_ROOT_SUM_SQUARED_X_Y,
IIO_MOD_SUM_SQUARED_X_Y_Z,
}; };
#define IIO_VAL_INT 1 #define IIO_VAL_INT 1
......
/*
* AD7266/65 SPI ADC driver
*
* Copyright 2012 Analog Devices Inc.
*
* Licensed under the GPL-2.
*/
#ifndef __IIO_ADC_AD7266_H__
#define __IIO_ADC_AD7266_H__
/**
* enum ad7266_range - AD7266 reference voltage range
* @AD7266_RANGE_VREF: Device is configured for input range 0V - VREF
* (RANGE pin set to low)
* @AD7266_RANGE_2VREF: Device is configured for input range 0V - 2VREF
* (RANGE pin set to high)
*/
enum ad7266_range {
AD7266_RANGE_VREF,
AD7266_RANGE_2VREF,
};
/**
* enum ad7266_mode - AD7266 sample mode
* @AD7266_MODE_DIFF: Device is configured for full differential mode
* (SGL/DIFF pin set to low, AD0 pin set to low)
* @AD7266_MODE_PSEUDO_DIFF: Device is configured for pseudo differential mode
* (SGL/DIFF pin set to low, AD0 pin set to high)
* @AD7266_MODE_SINGLE_ENDED: Device is configured for single-ended mode
* (SGL/DIFF pin set to high)
*/
enum ad7266_mode {
AD7266_MODE_DIFF,
AD7266_MODE_PSEUDO_DIFF,
AD7266_MODE_SINGLE_ENDED,
};
/**
* struct ad7266_platform_data - Platform data for the AD7266 driver
* @range: Reference voltage range the device is configured for
* @mode: Sample mode the device is configured for
* @fixed_addr: Whether the address pins are hard-wired
* @addr_gpios: GPIOs used for controlling the address pins, only used if
* fixed_addr is set to false.
*/
struct ad7266_platform_data {
enum ad7266_range range;
enum ad7266_mode mode;
bool fixed_addr;
unsigned int addr_gpios[3];
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment