Skip to content

Commit cee211f

Browse files
Paul Cercueiljic23
authored andcommitted
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 <[email protected]> Signed-off-by: Michael Hennerich <[email protected]> Signed-off-by: Alexandru Ardelean <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 11ab555 commit cee211f

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

drivers/iio/amplifiers/Kconfig

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
menu "Amplifiers"
88

99
config AD8366
10-
tristate "Analog Devices AD8366 VGA"
10+
tristate "Analog Devices AD8366 and similar Gain Amplifiers"
1111
depends on SPI
12+
depends on GPIOLIB
1213
select BITREVERSE
1314
help
14-
Say yes here to build support for Analog Devices AD8366
15-
SPI Dual-Digital Variable Gain Amplifier (VGA).
15+
Say yes here to build support for Analog Devices AD8366 and similar
16+
gain amplifiers. This driver supports the following gain amplifiers
17+
from Analog Devices:
18+
AD8366 Dual-Digital Variable Gain Amplifier (VGA)
19+
ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
1620

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

drivers/iio/amplifiers/ad8366.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* AD8366 SPI Dual-Digital Variable Gain Amplifier (VGA)
3+
* AD8366 and similar Gain Amplifiers
4+
* This driver supports the following gain amplifiers:
5+
* AD8366 Dual-Digital Variable Gain Amplifier (VGA)
6+
* ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
47
*
58
* Copyright 2012-2019 Analog Devices Inc.
69
*/
@@ -11,6 +14,7 @@
1114
#include <linux/sysfs.h>
1215
#include <linux/spi/spi.h>
1316
#include <linux/regulator/consumer.h>
17+
#include <linux/gpio/consumer.h>
1418
#include <linux/err.h>
1519
#include <linux/module.h>
1620
#include <linux/bitrev.h>
@@ -20,6 +24,7 @@
2024

2125
enum ad8366_type {
2226
ID_AD8366,
27+
ID_ADA4961,
2328
};
2429

2530
struct ad8366_info {
@@ -31,6 +36,7 @@ struct ad8366_state {
3136
struct spi_device *spi;
3237
struct regulator *reg;
3338
struct mutex lock; /* protect sensor state */
39+
struct gpio_desc *reset_gpio;
3440
unsigned char ch[2];
3541
enum ad8366_type type;
3642
struct ad8366_info *info;
@@ -46,6 +52,10 @@ static struct ad8366_info ad8366_infos[] = {
4652
.gain_min = 4500,
4753
.gain_max = 20500,
4854
},
55+
[ID_ADA4961] = {
56+
.gain_min = -6000,
57+
.gain_max = 15000,
58+
},
4959
};
5060

5161
static int ad8366_write(struct iio_dev *indio_dev,
@@ -62,6 +72,9 @@ static int ad8366_write(struct iio_dev *indio_dev,
6272
st->data[0] = ch_b >> 4;
6373
st->data[1] = (ch_b << 4) | (ch_a >> 2);
6474
break;
75+
case ID_ADA4961:
76+
st->data[0] = ch_a & 0x1F;
77+
break;
6578
}
6679

6780
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,
90103
case ID_AD8366:
91104
gain = code * 253 + 4500;
92105
break;
106+
case ID_ADA4961:
107+
gain = 15000 - code * 1000;
108+
break;
93109
}
94110

95111
/* Values in dB */
@@ -130,6 +146,9 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
130146
case ID_AD8366:
131147
code = (gain - 4500) / 253;
132148
break;
149+
case ID_ADA4961:
150+
code = (15000 - gain) / 1000;
151+
break;
133152
}
134153

135154
mutex_lock(&st->lock);
@@ -164,6 +183,10 @@ static const struct iio_chan_spec ad8366_channels[] = {
164183
AD8366_CHAN(1),
165184
};
166185

186+
static const struct iio_chan_spec ada4961_channels[] = {
187+
AD8366_CHAN(0),
188+
};
189+
167190
static int ad8366_probe(struct spi_device *spi)
168191
{
169192
struct iio_dev *indio_dev;
@@ -193,6 +216,12 @@ static int ad8366_probe(struct spi_device *spi)
193216
indio_dev->channels = ad8366_channels;
194217
indio_dev->num_channels = ARRAY_SIZE(ad8366_channels);
195218
break;
219+
case ID_ADA4961:
220+
st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
221+
GPIOD_OUT_HIGH);
222+
indio_dev->channels = ada4961_channels;
223+
indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
224+
break;
196225
default:
197226
dev_err(&spi->dev, "Invalid device ID\n");
198227
ret = -EINVAL;
@@ -238,6 +267,7 @@ static int ad8366_remove(struct spi_device *spi)
238267

239268
static const struct spi_device_id ad8366_id[] = {
240269
{"ad8366", ID_AD8366},
270+
{"ada4961", ID_ADA4961},
241271
{}
242272
};
243273
MODULE_DEVICE_TABLE(spi, ad8366_id);
@@ -254,5 +284,5 @@ static struct spi_driver ad8366_driver = {
254284
module_spi_driver(ad8366_driver);
255285

256286
MODULE_AUTHOR("Michael Hennerich <[email protected]>");
257-
MODULE_DESCRIPTION("Analog Devices AD8366 VGA");
287+
MODULE_DESCRIPTION("Analog Devices AD8366 and similar Gain Amplifiers");
258288
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)