Skip to content

Commit a6515b2

Browse files
commodorodrigo455
authored andcommitted
iio: amplifiers: ad8366: add support for HMC271
The part is obsolete. Won't be upstreamed. But we still maintain it in the ADI tree. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
1 parent 8149e1f commit a6515b2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/iio/amplifiers/ad8366.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
77
* ADL5240 Digitally controlled variable gain amplifier (VGA)
88
* HMC792A 0.25 dB LSB GaAs MMIC 6-Bit Digital Attenuator
9+
* HMC271 1 dB LSB GaAs MMIC 5-BIT Control Digital Attenuator
910
* HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator
1011
*
1112
* Copyright 2012-2019 Analog Devices Inc.
@@ -30,6 +31,7 @@ enum ad8366_type {
3031
ID_ADA4961,
3132
ID_ADL5240,
3233
ID_HMC792,
34+
ID_HMC271,
3335
ID_HMC1119,
3436
};
3537

@@ -70,6 +72,10 @@ static const struct ad8366_info ad8366_infos[] = {
7072
.gain_min = -15750,
7173
.gain_max = 0,
7274
},
75+
[ID_HMC271] = {
76+
.gain_min = -31000,
77+
.gain_max = 0,
78+
},
7379
[ID_HMC1119] = {
7480
.gain_min = -31750,
7581
.gain_max = 0,
@@ -96,6 +102,9 @@ static int ad8366_write(struct iio_dev *indio_dev,
96102
case ID_ADL5240:
97103
st->data[0] = (ch_a & 0x3F);
98104
break;
105+
case ID_HMC271:
106+
st->data[0] = bitrev8(ch_a & 0x1F) >> 3;
107+
break;
99108
case ID_HMC792:
100109
case ID_HMC1119:
101110
st->data[0] = ch_a;
@@ -136,6 +145,8 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
136145
break;
137146
case ID_HMC792:
138147
gain = -1 * code * 500;
148+
case ID_HMC271:
149+
gain = -31000 + code * 1000;
139150
break;
140151
case ID_HMC1119:
141152
gain = -1 * code * 250;
@@ -188,6 +199,8 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
188199
break;
189200
case ID_HMC792:
190201
code = (abs(gain) / 500) & 0x3F;
202+
case ID_HMC271:
203+
code = ((gain - 1000) / 1000) & 0x1F;
191204
break;
192205
case ID_HMC1119:
193206
code = (abs(gain) / 250) & 0x7F;
@@ -275,6 +288,7 @@ static int ad8366_probe(struct spi_device *spi)
275288
case ID_ADA4961:
276289
case ID_ADL5240:
277290
case ID_HMC792:
291+
case ID_HMC271:
278292
case ID_HMC1119:
279293
st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH);
280294
if (IS_ERR(st->reset_gpio)) {
@@ -329,6 +343,7 @@ static const struct spi_device_id ad8366_id[] = {
329343
{"ada4961", ID_ADA4961},
330344
{"adl5240", ID_ADL5240},
331345
{"hmc792a", ID_HMC792},
346+
{"hmc271", ID_HMC271},
332347
{"hmc1119", ID_HMC1119},
333348
{ }
334349
};

0 commit comments

Comments
 (0)