summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cercueil <paul.cercueil@analog.com>2019-05-30 16:18:11 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-06-17 21:06:48 +0100
commitcee211f4e5a0f70ee0c202e9a5fc8eac0b9b4945 (patch)
tree971687342cf94162919391c435dcbe3f384b3090
parent11ab555a6d3b0ecbb51076af79e625303bfa61de (diff)
iio: amplifiers: ad8366: Add support for the ADA4961 DGA
This change adds support for the ADA4961 BiCMOS RF Digital Gain Amplifier, (DGA), which is optimized for driving heavy loads out 2.0 GHz and beyond. The device typically achieves -90 dBc IMD3 performance at 500 MHz and -85 dBc at 1.5 GHz. Datasheet link: http://www.analog.com/media/en/technical-documentation/data-sheets/ADA4961.pdf This change re-uses the existing ad8366 driver, as most logic is similar. Also, this chip has a reset pin which is initialized during probe. Signed-off-by: Paul Cercueil <paul.cercueil@analog.com> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/amplifiers/Kconfig10
-rw-r--r--drivers/iio/amplifiers/ad8366.c34
2 files changed, 39 insertions, 5 deletions
diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig
index da5830da9bcf..f39c05677d52 100644
--- a/drivers/iio/amplifiers/Kconfig
+++ b/drivers/iio/amplifiers/Kconfig
@@ -7,12 +7,16 @@
menu "Amplifiers"
config AD8366
- tristate "Analog Devices AD8366 VGA"
+ tristate "Analog Devices AD8366 and similar Gain Amplifiers"
depends on SPI
+ depends on GPIOLIB
select BITREVERSE
help
- Say yes here to build support for Analog Devices AD8366
- SPI Dual-Digital Variable Gain Amplifier (VGA).
+ Say yes here to build support for Analog Devices AD8366 and similar
+ gain amplifiers. This driver supports the following gain amplifiers
+ from Analog Devices:
+ AD8366 Dual-Digital Variable Gain Amplifier (VGA)
+ ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
To compile this driver as a module, choose M here: the
module will be called ad8366.
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 1beda6409301..0a9883e8eb2e 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * AD8366 SPI Dual-Digital Variable Gain Amplifier (VGA)
+ * AD8366 and similar Gain Amplifiers
+ * This driver supports the following gain amplifiers:
+ * AD8366 Dual-Digital Variable Gain Amplifier (VGA)
+ * ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
*
* Copyright 2012-2019 Analog Devices Inc.
*/
@@ -11,6 +14,7 @@
#include <linux/sysfs.h>
#include <linux/spi/spi.h>
#include <linux/regulator/consumer.h>
+#include <linux/gpio/consumer.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/bitrev.h>
@@ -20,6 +24,7 @@
enum ad8366_type {
ID_AD8366,
+ ID_ADA4961,
};
struct ad8366_info {
@@ -31,6 +36,7 @@ struct ad8366_state {
struct spi_device *spi;
struct regulator *reg;
struct mutex lock; /* protect sensor state */
+ struct gpio_desc *reset_gpio;
unsigned char ch[2];
enum ad8366_type type;
struct ad8366_info *info;
@@ -46,6 +52,10 @@ static struct ad8366_info ad8366_infos[] = {
.gain_min = 4500,
.gain_max = 20500,
},
+ [ID_ADA4961] = {
+ .gain_min = -6000,
+ .gain_max = 15000,
+ },
};
static int ad8366_write(struct iio_dev *indio_dev,
@@ -62,6 +72,9 @@ static int ad8366_write(struct iio_dev *indio_dev,
st->data[0] = ch_b >> 4;
st->data[1] = (ch_b << 4) | (ch_a >> 2);
break;
+ case ID_ADA4961:
+ st->data[0] = ch_a & 0x1F;
+ break;
}
ret = spi_write(st->spi, st->data, indio_dev->num_channels);
@@ -90,6 +103,9 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
case ID_AD8366:
gain = code * 253 + 4500;
break;
+ case ID_ADA4961:
+ gain = 15000 - code * 1000;
+ break;
}
/* Values in dB */
@@ -130,6 +146,9 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
case ID_AD8366:
code = (gain - 4500) / 253;
break;
+ case ID_ADA4961:
+ code = (15000 - gain) / 1000;
+ break;
}
mutex_lock(&st->lock);
@@ -164,6 +183,10 @@ static const struct iio_chan_spec ad8366_channels[] = {
AD8366_CHAN(1),
};
+static const struct iio_chan_spec ada4961_channels[] = {
+ AD8366_CHAN(0),
+};
+
static int ad8366_probe(struct spi_device *spi)
{
struct iio_dev *indio_dev;
@@ -193,6 +216,12 @@ static int ad8366_probe(struct spi_device *spi)
indio_dev->channels = ad8366_channels;
indio_dev->num_channels = ARRAY_SIZE(ad8366_channels);
break;
+ case ID_ADA4961:
+ st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
+ GPIOD_OUT_HIGH);
+ indio_dev->channels = ada4961_channels;
+ indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
+ break;
default:
dev_err(&spi->dev, "Invalid device ID\n");
ret = -EINVAL;
@@ -238,6 +267,7 @@ static int ad8366_remove(struct spi_device *spi)
static const struct spi_device_id ad8366_id[] = {
{"ad8366", ID_AD8366},
+ {"ada4961", ID_ADA4961},
{}
};
MODULE_DEVICE_TABLE(spi, ad8366_id);
@@ -254,5 +284,5 @@ static struct spi_driver ad8366_driver = {
module_spi_driver(ad8366_driver);
MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
-MODULE_DESCRIPTION("Analog Devices AD8366 VGA");
+MODULE_DESCRIPTION("Analog Devices AD8366 and similar Gain Amplifiers");
MODULE_LICENSE("GPL v2");