linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: amplifiers: ad8366: add support for HMC1119 Attenuator
@ 2020-02-20  9:28 Sergiu
  2020-02-21 15:32 ` Jonathan Cameron
  2020-02-21 16:18 ` [PATCH v2] " Alexandru Ardelean
  0 siblings, 2 replies; 4+ messages in thread
From: Sergiu @ 2020-02-20  9:28 UTC (permalink / raw)
  To: linux-iio, linux-kernel; +Cc: jic23, Sergiu

This change adds support for the HMC1119 Silicon Digial Attenuator. The
HMC1119 is a broadband, highly accurate, 7-bit digital attenuator,
operating from 0.1 GHz to 6.0 GHz with 31.5 dB attenuation control range
in 0.25 dB steps.

Link: https://www.analog.com/media/en/technical-documentation/data-sheets/hmc1119.pdf

Signed-off-by: Sergiu <sergiu.cuciurean@analog.com>
---
 drivers/iio/amplifiers/ad8366.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 95972ab60f42..62167b87caea 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -5,6 +5,7 @@
  *   AD8366 Dual-Digital Variable Gain Amplifier (VGA)
  *   ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
  *   ADL5240 Digitally controlled variable gain amplifier (VGA)
+ *   HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator
  *
  * Copyright 2012-2019 Analog Devices Inc.
  */
@@ -27,6 +28,7 @@ enum ad8366_type {
 	ID_AD8366,
 	ID_ADA4961,
 	ID_ADL5240,
+	ID_HMC1119,
 };
 
 struct ad8366_info {
@@ -62,6 +64,10 @@ static struct ad8366_info ad8366_infos[] = {
 		.gain_min = -11500,
 		.gain_max = 20000,
 	},
+	[ID_HMC1119] = {
+		.gain_min = -31750,
+		.gain_max = 0,
+	},
 };
 
 static int ad8366_write(struct iio_dev *indio_dev,
@@ -84,6 +90,9 @@ static int ad8366_write(struct iio_dev *indio_dev,
 	case ID_ADL5240:
 		st->data[0] = (ch_a & 0x3F);
 		break;
+	case ID_HMC1119:
+		st->data[0] = ch_a;
+		break;
 	}
 
 	ret = spi_write(st->spi, st->data, indio_dev->num_channels);
@@ -118,6 +127,9 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
 		case ID_ADL5240:
 			gain = 20000 - 31500 + code * 500;
 			break;
+		case ID_HMC1119:
+			gain = -1 * code * 250;
+			break;
 		}
 
 		/* Values in dB */
@@ -164,6 +176,9 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
 	case ID_ADL5240:
 		code = ((gain - 500 - 20000) / 500) & 0x3F;
 		break;
+	case ID_HMC1119:
+		code = (abs(gain) / 250) & 0x7F;
+		break;
 	}
 
 	mutex_lock(&st->lock);
@@ -246,6 +261,7 @@ static int ad8366_probe(struct spi_device *spi)
 		break;
 	case ID_ADA4961:
 	case ID_ADL5240:
+	case ID_HMC1119:
 		st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
 			GPIOD_OUT_HIGH);
 		indio_dev->channels = ada4961_channels;
@@ -298,6 +314,7 @@ static const struct spi_device_id ad8366_id[] = {
 	{"ad8366",  ID_AD8366},
 	{"ada4961", ID_ADA4961},
 	{"adl5240", ID_ADL5240},
+	{"hmc1119", ID_HMC1119},
 	{}
 };
 MODULE_DEVICE_TABLE(spi, ad8366_id);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: amplifiers: ad8366: add support for HMC1119 Attenuator
  2020-02-20  9:28 [PATCH] iio: amplifiers: ad8366: add support for HMC1119 Attenuator Sergiu
@ 2020-02-21 15:32 ` Jonathan Cameron
  2020-02-21 16:18 ` [PATCH v2] " Alexandru Ardelean
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2020-02-21 15:32 UTC (permalink / raw)
  To: Sergiu; +Cc: linux-iio, linux-kernel

On Thu, 20 Feb 2020 11:28:21 +0200
Sergiu <sergiu.cuciurean@analog.com> wrote:

> This change adds support for the HMC1119 Silicon Digial Attenuator. The
> HMC1119 is a broadband, highly accurate, 7-bit digital attenuator,
> operating from 0.1 GHz to 6.0 GHz with 31.5 dB attenuation control range
> in 0.25 dB steps.
> 
> Link: https://www.analog.com/media/en/technical-documentation/data-sheets/hmc1119.pdf
> 
> Signed-off-by: Sergiu <sergiu.cuciurean@analog.com>

Sign offs need to be full names, and match the from of the email.
See the Developer Certificate of Origin stuff in Documentation/process/submitting patches.

Otherwise the patch looks fine to me.

Thanks,

Jonathan


> ---
>  drivers/iio/amplifiers/ad8366.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index 95972ab60f42..62167b87caea 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -5,6 +5,7 @@
>   *   AD8366 Dual-Digital Variable Gain Amplifier (VGA)
>   *   ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
>   *   ADL5240 Digitally controlled variable gain amplifier (VGA)
> + *   HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator
>   *
>   * Copyright 2012-2019 Analog Devices Inc.
>   */
> @@ -27,6 +28,7 @@ enum ad8366_type {
>  	ID_AD8366,
>  	ID_ADA4961,
>  	ID_ADL5240,
> +	ID_HMC1119,
>  };
>  
>  struct ad8366_info {
> @@ -62,6 +64,10 @@ static struct ad8366_info ad8366_infos[] = {
>  		.gain_min = -11500,
>  		.gain_max = 20000,
>  	},
> +	[ID_HMC1119] = {
> +		.gain_min = -31750,
> +		.gain_max = 0,
> +	},
>  };
>  
>  static int ad8366_write(struct iio_dev *indio_dev,
> @@ -84,6 +90,9 @@ static int ad8366_write(struct iio_dev *indio_dev,
>  	case ID_ADL5240:
>  		st->data[0] = (ch_a & 0x3F);
>  		break;
> +	case ID_HMC1119:
> +		st->data[0] = ch_a;
> +		break;
>  	}
>  
>  	ret = spi_write(st->spi, st->data, indio_dev->num_channels);
> @@ -118,6 +127,9 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
>  		case ID_ADL5240:
>  			gain = 20000 - 31500 + code * 500;
>  			break;
> +		case ID_HMC1119:
> +			gain = -1 * code * 250;
> +			break;
>  		}
>  
>  		/* Values in dB */
> @@ -164,6 +176,9 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
>  	case ID_ADL5240:
>  		code = ((gain - 500 - 20000) / 500) & 0x3F;
>  		break;
> +	case ID_HMC1119:
> +		code = (abs(gain) / 250) & 0x7F;
> +		break;
>  	}
>  
>  	mutex_lock(&st->lock);
> @@ -246,6 +261,7 @@ static int ad8366_probe(struct spi_device *spi)
>  		break;
>  	case ID_ADA4961:
>  	case ID_ADL5240:
> +	case ID_HMC1119:
>  		st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
>  			GPIOD_OUT_HIGH);
>  		indio_dev->channels = ada4961_channels;
> @@ -298,6 +314,7 @@ static const struct spi_device_id ad8366_id[] = {
>  	{"ad8366",  ID_AD8366},
>  	{"ada4961", ID_ADA4961},
>  	{"adl5240", ID_ADL5240},
> +	{"hmc1119", ID_HMC1119},
>  	{}
>  };
>  MODULE_DEVICE_TABLE(spi, ad8366_id);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] iio: amplifiers: ad8366: add support for HMC1119 Attenuator
  2020-02-20  9:28 [PATCH] iio: amplifiers: ad8366: add support for HMC1119 Attenuator Sergiu
  2020-02-21 15:32 ` Jonathan Cameron
@ 2020-02-21 16:18 ` Alexandru Ardelean
  2020-02-21 16:29   ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandru Ardelean @ 2020-02-21 16:18 UTC (permalink / raw)
  To: linux-iio, linux-kernel; +Cc: jic23, Sergiu Cuciurean

From: Sergiu Cuciurean <sergiu.cuciurean@analog.com>

This change adds support for the HMC1119 Silicon Digial Attenuator. The
HMC1119 is a broadband, highly accurate, 7-bit digital attenuator,
operating from 0.1 GHz to 6.0 GHz with 31.5 dB attenuation control range
in 0.25 dB steps.

Link: https://www.analog.com/media/en/technical-documentation/data-sheets/hmc1119.pdf

Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
---
 drivers/iio/amplifiers/ad8366.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index 95972ab60f42..62167b87caea 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -5,6 +5,7 @@
  *   AD8366 Dual-Digital Variable Gain Amplifier (VGA)
  *   ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
  *   ADL5240 Digitally controlled variable gain amplifier (VGA)
+ *   HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator
  *
  * Copyright 2012-2019 Analog Devices Inc.
  */
@@ -27,6 +28,7 @@ enum ad8366_type {
 	ID_AD8366,
 	ID_ADA4961,
 	ID_ADL5240,
+	ID_HMC1119,
 };
 
 struct ad8366_info {
@@ -62,6 +64,10 @@ static struct ad8366_info ad8366_infos[] = {
 		.gain_min = -11500,
 		.gain_max = 20000,
 	},
+	[ID_HMC1119] = {
+		.gain_min = -31750,
+		.gain_max = 0,
+	},
 };
 
 static int ad8366_write(struct iio_dev *indio_dev,
@@ -84,6 +90,9 @@ static int ad8366_write(struct iio_dev *indio_dev,
 	case ID_ADL5240:
 		st->data[0] = (ch_a & 0x3F);
 		break;
+	case ID_HMC1119:
+		st->data[0] = ch_a;
+		break;
 	}
 
 	ret = spi_write(st->spi, st->data, indio_dev->num_channels);
@@ -118,6 +127,9 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
 		case ID_ADL5240:
 			gain = 20000 - 31500 + code * 500;
 			break;
+		case ID_HMC1119:
+			gain = -1 * code * 250;
+			break;
 		}
 
 		/* Values in dB */
@@ -164,6 +176,9 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
 	case ID_ADL5240:
 		code = ((gain - 500 - 20000) / 500) & 0x3F;
 		break;
+	case ID_HMC1119:
+		code = (abs(gain) / 250) & 0x7F;
+		break;
 	}
 
 	mutex_lock(&st->lock);
@@ -246,6 +261,7 @@ static int ad8366_probe(struct spi_device *spi)
 		break;
 	case ID_ADA4961:
 	case ID_ADL5240:
+	case ID_HMC1119:
 		st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
 			GPIOD_OUT_HIGH);
 		indio_dev->channels = ada4961_channels;
@@ -298,6 +314,7 @@ static const struct spi_device_id ad8366_id[] = {
 	{"ad8366",  ID_AD8366},
 	{"ada4961", ID_ADA4961},
 	{"adl5240", ID_ADL5240},
+	{"hmc1119", ID_HMC1119},
 	{}
 };
 MODULE_DEVICE_TABLE(spi, ad8366_id);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] iio: amplifiers: ad8366: add support for HMC1119 Attenuator
  2020-02-21 16:18 ` [PATCH v2] " Alexandru Ardelean
@ 2020-02-21 16:29   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2020-02-21 16:29 UTC (permalink / raw)
  To: Alexandru Ardelean; +Cc: linux-iio, linux-kernel, Sergiu Cuciurean

On Fri, 21 Feb 2020 18:18:26 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> From: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
> 
> This change adds support for the HMC1119 Silicon Digial Attenuator. The
> HMC1119 is a broadband, highly accurate, 7-bit digital attenuator,
> operating from 0.1 GHz to 6.0 GHz with 31.5 dB attenuation control range
> in 0.25 dB steps.
> 
> Link: https://www.analog.com/media/en/technical-documentation/data-sheets/hmc1119.pdf
> 
> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>

Applied, thanks.

Jonathan

> ---
>  drivers/iio/amplifiers/ad8366.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index 95972ab60f42..62167b87caea 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -5,6 +5,7 @@
>   *   AD8366 Dual-Digital Variable Gain Amplifier (VGA)
>   *   ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
>   *   ADL5240 Digitally controlled variable gain amplifier (VGA)
> + *   HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator
>   *
>   * Copyright 2012-2019 Analog Devices Inc.
>   */
> @@ -27,6 +28,7 @@ enum ad8366_type {
>  	ID_AD8366,
>  	ID_ADA4961,
>  	ID_ADL5240,
> +	ID_HMC1119,
>  };
>  
>  struct ad8366_info {
> @@ -62,6 +64,10 @@ static struct ad8366_info ad8366_infos[] = {
>  		.gain_min = -11500,
>  		.gain_max = 20000,
>  	},
> +	[ID_HMC1119] = {
> +		.gain_min = -31750,
> +		.gain_max = 0,
> +	},
>  };
>  
>  static int ad8366_write(struct iio_dev *indio_dev,
> @@ -84,6 +90,9 @@ static int ad8366_write(struct iio_dev *indio_dev,
>  	case ID_ADL5240:
>  		st->data[0] = (ch_a & 0x3F);
>  		break;
> +	case ID_HMC1119:
> +		st->data[0] = ch_a;
> +		break;
>  	}
>  
>  	ret = spi_write(st->spi, st->data, indio_dev->num_channels);
> @@ -118,6 +127,9 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
>  		case ID_ADL5240:
>  			gain = 20000 - 31500 + code * 500;
>  			break;
> +		case ID_HMC1119:
> +			gain = -1 * code * 250;
> +			break;
>  		}
>  
>  		/* Values in dB */
> @@ -164,6 +176,9 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
>  	case ID_ADL5240:
>  		code = ((gain - 500 - 20000) / 500) & 0x3F;
>  		break;
> +	case ID_HMC1119:
> +		code = (abs(gain) / 250) & 0x7F;
> +		break;
>  	}
>  
>  	mutex_lock(&st->lock);
> @@ -246,6 +261,7 @@ static int ad8366_probe(struct spi_device *spi)
>  		break;
>  	case ID_ADA4961:
>  	case ID_ADL5240:
> +	case ID_HMC1119:
>  		st->reset_gpio = devm_gpiod_get(&spi->dev, "reset",
>  			GPIOD_OUT_HIGH);
>  		indio_dev->channels = ada4961_channels;
> @@ -298,6 +314,7 @@ static const struct spi_device_id ad8366_id[] = {
>  	{"ad8366",  ID_AD8366},
>  	{"ada4961", ID_ADA4961},
>  	{"adl5240", ID_ADL5240},
> +	{"hmc1119", ID_HMC1119},
>  	{}
>  };
>  MODULE_DEVICE_TABLE(spi, ad8366_id);


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-21 16:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20  9:28 [PATCH] iio: amplifiers: ad8366: add support for HMC1119 Attenuator Sergiu
2020-02-21 15:32 ` Jonathan Cameron
2020-02-21 16:18 ` [PATCH v2] " Alexandru Ardelean
2020-02-21 16:29   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).