All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add ADRF5740 driver
@ 2023-11-13 10:25 Ana-Maria Cusco
  2023-11-13 10:25 ` [PATCH v3 1/2] iio: amplifiers: hmc425a: add support for ADRF5740 Attenuator Ana-Maria Cusco
  2023-11-13 10:25 ` [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry " Ana-Maria Cusco
  0 siblings, 2 replies; 7+ messages in thread
From: Ana-Maria Cusco @ 2023-11-13 10:25 UTC (permalink / raw)
  To: Ana-Maria Cusco
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-iio,
	devicetree, linux-kernel

From: Ana-Maria Cusco <ana-maria.cusco@analog.com>

This patch series adds support for the ADRF5740 Attenuator within the existing 
HMC425A driver.

The ADRF5740 is a silicon, 4-bit digital attenuator with 22 dB
attenuation control range in 2 dB steps.
It offers parallel control mode through four digitally controlled inputs.

V2 -> V3:
* hmc425a.c: edit commit message to clarify the change related to default 
attenuation setting.

V1 -> V2:
* dt-bindings: arrange entry in alphabetical order
* improve title clarity

Ana-Maria Cusco (2):
  iio: amplifiers: hmc425a: add support for ADRF5740 Attenuator
  dt-bindings: iio: hmc425a: add entry for ADRF5740 Attenuator

 .../bindings/iio/amplifiers/adi,hmc425a.yaml  |  4 ++++
 drivers/iio/amplifiers/hmc425a.c              | 23 +++++++++++++++++++
 2 files changed, 27 insertions(+)

-- 
2.34.1


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

* [PATCH v3 1/2] iio: amplifiers: hmc425a: add support for ADRF5740 Attenuator
  2023-11-13 10:25 [PATCH v3 0/2] Add ADRF5740 driver Ana-Maria Cusco
@ 2023-11-13 10:25 ` Ana-Maria Cusco
  2023-11-13 10:25 ` [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry " Ana-Maria Cusco
  1 sibling, 0 replies; 7+ messages in thread
From: Ana-Maria Cusco @ 2023-11-13 10:25 UTC (permalink / raw)
  To: Ana-Maria Cusco
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-iio,
	devicetree, linux-kernel

From: Ana-Maria Cusco <ana-maria.cusco@analog.com>

This adds support for the Analog Devices ADRF5740 2 dB LSB, 4-Bit,
Silicon Digital Attenuator, 10 MHz to 60 GHz.
The default (maximum) gain is also set at probe time, with GPIO lines
driven high to achieve maximum gain, in contrast to other devices
where GPIOs need to be driven low.

Signed-off-by: Ana-Maria Cusco <ana-maria.cusco@analog.com>
---
 drivers/iio/amplifiers/hmc425a.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/iio/amplifiers/hmc425a.c b/drivers/iio/amplifiers/hmc425a.c
index e87d35d50a95..ed4d72922696 100644
--- a/drivers/iio/amplifiers/hmc425a.c
+++ b/drivers/iio/amplifiers/hmc425a.c
@@ -5,6 +5,7 @@
  * Copyright 2020 Analog Devices Inc.
  */
 
+#include <linux/bitops.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/gpio/consumer.h>
@@ -22,6 +23,7 @@
 enum hmc425a_type {
 	ID_HMC425A,
 	ID_HMC540S,
+	ID_ADRF5740
 };
 
 struct hmc425a_chip_info {
@@ -74,6 +76,10 @@ static int hmc425a_read_raw(struct iio_dev *indio_dev,
 		case ID_HMC540S:
 			gain = ~code * -1000;
 			break;
+		case ID_ADRF5740:
+			code = code & BIT(3) ? code & ~BIT(2) : code;
+			gain = code * -2000;
+			break;
 		}
 
 		*val = gain / 1000;
@@ -113,6 +119,10 @@ static int hmc425a_write_raw(struct iio_dev *indio_dev,
 	case ID_HMC540S:
 		code = ~((abs(gain) / 1000) & 0xF);
 		break;
+	case ID_ADRF5740:
+		code = (abs(gain) / 2000) & 0xF;
+		code = code & BIT(3) ? code | BIT(2) : code;
+		break;
 	}
 
 	mutex_lock(&st->lock);
@@ -165,6 +175,7 @@ static const struct iio_chan_spec hmc425a_channels[] = {
 static const struct of_device_id hmc425a_of_match[] = {
 	{ .compatible = "adi,hmc425a", .data = (void *)ID_HMC425A },
 	{ .compatible = "adi,hmc540s", .data = (void *)ID_HMC540S },
+	{ .compatible = "adi,adrf5740", .data = (void *)ID_ADRF5740 },
 	{},
 };
 MODULE_DEVICE_TABLE(of, hmc425a_of_match);
@@ -188,6 +199,15 @@ static struct hmc425a_chip_info hmc425a_chip_info_tbl[] = {
 		.gain_max = 0,
 		.default_gain = -0x10, /* set default gain -15.0db*/
 	},
+	[ID_ADRF5740] = {
+		.name = "adrf5740",
+		.channels = hmc425a_channels,
+		.num_channels = ARRAY_SIZE(hmc425a_channels),
+		.num_gpios = 4,
+		.gain_min = -22000,
+		.gain_max = 0,
+		.default_gain = 0xF, /* set default gain -22.0db*/
+	},
 };
 
 static int hmc425a_probe(struct platform_device *pdev)
@@ -229,6 +249,9 @@ static int hmc425a_probe(struct platform_device *pdev)
 	indio_dev->info = &hmc425a_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
+	/* Set default gain */
+	hmc425a_write(indio_dev, st->gain);
+
 	return devm_iio_device_register(&pdev->dev, indio_dev);
 }
 
-- 
2.34.1


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

* [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry for ADRF5740 Attenuator
  2023-11-13 10:25 [PATCH v3 0/2] Add ADRF5740 driver Ana-Maria Cusco
  2023-11-13 10:25 ` [PATCH v3 1/2] iio: amplifiers: hmc425a: add support for ADRF5740 Attenuator Ana-Maria Cusco
@ 2023-11-13 10:25 ` Ana-Maria Cusco
  2023-11-13 13:40   ` Conor Dooley
  1 sibling, 1 reply; 7+ messages in thread
From: Ana-Maria Cusco @ 2023-11-13 10:25 UTC (permalink / raw)
  To: Ana-Maria Cusco
  Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, linux-iio,
	devicetree, linux-kernel

From: Ana-Maria Cusco <ana-maria.cusco@analog.com>

The ADRF5740 is a silicon, 4-bit digital attenuator with 22 dB
attenuation control range in 2 dB steps.

Signed-off-by: Ana-Maria Cusco <ana-maria.cusco@analog.com>
---
 .../devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml       | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml b/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
index 2ee6080deac7..67de9d4e3a1d 100644
--- a/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
+++ b/Documentation/devicetree/bindings/iio/amplifiers/adi,hmc425a.yaml
@@ -12,6 +12,9 @@ maintainers:
 description: |
   Digital Step Attenuator IIO devices with gpio interface.
   Offer various frequency and attenuation ranges.
+  ADRF5750 2 dB LSB, 4-Bit, Silicon Digital Attenuator, 10 MHz to 60 GHz
+    https://www.analog.com/media/en/technical-documentation/data-sheets/adrf5740.pdf
+
   HMC425A 0.5 dB LSB GaAs MMIC 6-BIT DIGITAL POSITIVE CONTROL ATTENUATOR, 2.2 - 8.0 GHz
     https://www.analog.com/media/en/technical-documentation/data-sheets/hmc425A.pdf
 
@@ -22,6 +25,7 @@ description: |
 properties:
   compatible:
     enum:
+      - adi,adrf5740
       - adi,hmc425a
       - adi,hmc540s
 
-- 
2.34.1


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

* Re: [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry for ADRF5740 Attenuator
  2023-11-13 10:25 ` [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry " Ana-Maria Cusco
@ 2023-11-13 13:40   ` Conor Dooley
  2023-11-13 13:41     ` Conor Dooley
  0 siblings, 1 reply; 7+ messages in thread
From: Conor Dooley @ 2023-11-13 13:40 UTC (permalink / raw)
  To: Ana-Maria Cusco
  Cc: Ana-Maria Cusco, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-iio, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 375 bytes --]

On Mon, Nov 13, 2023 at 12:25:35PM +0200, Ana-Maria Cusco wrote:
> From: Ana-Maria Cusco <ana-maria.cusco@analog.com>
> 
> The ADRF5740 is a silicon, 4-bit digital attenuator with 22 dB
> attenuation control range in 2 dB steps.
> 
> Signed-off-by: Ana-Maria Cusco <ana-maria.cusco@analog.com>

Acked-by: Conor Dooley <conor.dooley@microchip.com>

Thanks,
Conor.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry for ADRF5740 Attenuator
  2023-11-13 13:40   ` Conor Dooley
@ 2023-11-13 13:41     ` Conor Dooley
  2023-11-26 16:39       ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Conor Dooley @ 2023-11-13 13:41 UTC (permalink / raw)
  To: Ana-Maria Cusco
  Cc: Ana-Maria Cusco, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	linux-iio, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 549 bytes --]

On Mon, Nov 13, 2023 at 01:40:40PM +0000, Conor Dooley wrote:
> On Mon, Nov 13, 2023 at 12:25:35PM +0200, Ana-Maria Cusco wrote:
> > From: Ana-Maria Cusco <ana-maria.cusco@analog.com>
> > 
> > The ADRF5740 is a silicon, 4-bit digital attenuator with 22 dB
> > attenuation control range in 2 dB steps.
> > 
> > Signed-off-by: Ana-Maria Cusco <ana-maria.cusco@analog.com>
> 
> Acked-by: Conor Dooley <conor.dooley@microchip.com>

One thing though, the bindings patch should come before the driver patch
in your series.

Thanks,
conor.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

* Re: [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry for ADRF5740 Attenuator
  2023-11-13 13:41     ` Conor Dooley
@ 2023-11-26 16:39       ` Jonathan Cameron
  2023-11-27 17:48         ` Conor Dooley
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2023-11-26 16:39 UTC (permalink / raw)
  To: Conor Dooley
  Cc: Ana-Maria Cusco, Ana-Maria Cusco, Lars-Peter Clausen,
	Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, devicetree, linux-kernel

On Mon, 13 Nov 2023 13:41:27 +0000
Conor Dooley <conor@kernel.org> wrote:

> On Mon, Nov 13, 2023 at 01:40:40PM +0000, Conor Dooley wrote:
> > On Mon, Nov 13, 2023 at 12:25:35PM +0200, Ana-Maria Cusco wrote:  
> > > From: Ana-Maria Cusco <ana-maria.cusco@analog.com>
> > > 
> > > The ADRF5740 is a silicon, 4-bit digital attenuator with 22 dB
> > > attenuation control range in 2 dB steps.
> > > 
> > > Signed-off-by: Ana-Maria Cusco <ana-maria.cusco@analog.com>  
> > 
> > Acked-by: Conor Dooley <conor.dooley@microchip.com>  
> 
> One thing though, the bindings patch should come before the driver patch
> in your series.
Flipped order whilst applying.

Applied to the togreg branch of iio.git an pushed out initially as
testing for 0-day to poke at it and see if it can find anythign we missed.

Trivial thing but Ana-Maria, I'd prefer a cover letter even on a short series
like this. It provides a place for general comments / discussion / tags to be
applied and it gives it a pretty name in patchwork.

Jonathan


> 
> Thanks,
> conor.


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

* Re: [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry for ADRF5740 Attenuator
  2023-11-26 16:39       ` Jonathan Cameron
@ 2023-11-27 17:48         ` Conor Dooley
  0 siblings, 0 replies; 7+ messages in thread
From: Conor Dooley @ 2023-11-27 17:48 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Ana-Maria Cusco, Ana-Maria Cusco, Lars-Peter Clausen,
	Michael Hennerich, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, linux-iio, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

On Sun, Nov 26, 2023 at 04:39:22PM +0000, Jonathan Cameron wrote:

> Trivial thing but Ana-Maria, I'd prefer a cover letter even on a short series
> like this. It provides a place for general comments / discussion / tags to be
> applied and it gives it a pretty name in patchwork.

It also helps patchwork detect when things are a later revision and mark
the old ones as superseded, which is rather nice :)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

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

end of thread, other threads:[~2023-11-27 17:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 10:25 [PATCH v3 0/2] Add ADRF5740 driver Ana-Maria Cusco
2023-11-13 10:25 ` [PATCH v3 1/2] iio: amplifiers: hmc425a: add support for ADRF5740 Attenuator Ana-Maria Cusco
2023-11-13 10:25 ` [PATCH v3 2/2] dt-bindings: iio: hmc425a: add entry " Ana-Maria Cusco
2023-11-13 13:40   ` Conor Dooley
2023-11-13 13:41     ` Conor Dooley
2023-11-26 16:39       ` Jonathan Cameron
2023-11-27 17:48         ` Conor Dooley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.