* [PATCH v2 1/2] dt-bindings: iio: adf4377: add adf4378 support
@ 2024-07-22 13:45 Antoniu Miclaus
2024-07-22 13:45 ` [PATCH v2 2/2] iio: frequency: " Antoniu Miclaus
2024-07-22 16:26 ` [PATCH v2 1/2] dt-bindings: iio: " Conor Dooley
0 siblings, 2 replies; 5+ messages in thread
From: Antoniu Miclaus @ 2024-07-22 13:45 UTC (permalink / raw)
To: Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich,
Jonathan Cameron, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Dragos Bogdan, linux-iio, devicetree, linux-kernel
Add porperty conditions for the adf4378.
Add product link for the adf4378.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
changes in v2:
- use property conditions for clk2 gpio
Note: the compatible is already available from the firs iteration of the driver
where these particularities weren't available for adf4378
.../devicetree/bindings/iio/frequency/adi,adf4377.yaml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml b/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
index aa6a3193b4e0..5f950ee9aec7 100644
--- a/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
+++ b/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
@@ -17,6 +17,7 @@ description: |
applications.
https://www.analog.com/en/products/adf4377.html
+ https://www.analog.com/en/products/adf4378.html
properties:
compatible:
@@ -73,6 +74,15 @@ required:
allOf:
- $ref: /schemas/spi/spi-peripheral-props.yaml#
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - adi,adf4378
+ then:
+ properties:
+ clk2-enable-gpios: false
unevaluatedProperties: false
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] iio: frequency: adf4377: add adf4378 support
2024-07-22 13:45 [PATCH v2 1/2] dt-bindings: iio: adf4377: add adf4378 support Antoniu Miclaus
@ 2024-07-22 13:45 ` Antoniu Miclaus
2024-07-27 12:33 ` Jonathan Cameron
2024-07-22 16:26 ` [PATCH v2 1/2] dt-bindings: iio: " Conor Dooley
1 sibling, 1 reply; 5+ messages in thread
From: Antoniu Miclaus @ 2024-07-22 13:45 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Antoniu Miclaus,
Jonathan Cameron, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Dragos Bogdan, linux-iio, devicetree, linux-kernel
Add separate handling for adf4378 within the driver.
The main difference between adf4377 and adf4378 is that adf4378 has only
one output which is handled by only one gpio.
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
changes in v2:
- use chip_info structure to handle new added part (adf4378)
- use spi_get_device_match_data
- drop redundant check in if statement.
drivers/iio/frequency/adf4377.c | 36 ++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c
index 9284c13f1abb..82374f5d2695 100644
--- a/drivers/iio/frequency/adf4377.c
+++ b/drivers/iio/frequency/adf4377.c
@@ -400,7 +400,13 @@ enum muxout_select_mode {
ADF4377_MUXOUT_HIGH = 0x8,
};
+struct adf4377_chip_info {
+ const char *name;
+ bool has_gpio_enclk2;
+};
+
struct adf4377_state {
+ const struct adf4377_chip_info *chip_info;
struct spi_device *spi;
struct regmap *regmap;
struct clk *clkin;
@@ -889,11 +895,13 @@ static int adf4377_properties_parse(struct adf4377_state *st)
return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk1),
"failed to get the CE GPIO\n");
- st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable",
- GPIOD_OUT_LOW);
- if (IS_ERR(st->gpio_enclk2))
- return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2),
- "failed to get the CE GPIO\n");
+ if (st->chip_info->has_gpio_enclk2) {
+ st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(st->gpio_enclk2))
+ return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2),
+ "failed to get the CE GPIO\n");
+ }
ret = device_property_match_property_string(&spi->dev, "adi,muxout-select",
adf4377_muxout_modes,
@@ -921,6 +929,17 @@ static int adf4377_freq_change(struct notifier_block *nb, unsigned long action,
return NOTIFY_OK;
}
+static const struct adf4377_chip_info adf4377_chip_info_tbl[] = {
+ {
+ .name = "adf4377",
+ .has_gpio_enclk2 = true,
+ },
+ {
+ .name = "adf4378",
+ .has_gpio_enclk2 = false,
+ },
+};
+
static int adf4377_probe(struct spi_device *spi)
{
struct iio_dev *indio_dev;
@@ -945,6 +964,7 @@ static int adf4377_probe(struct spi_device *spi)
st->regmap = regmap;
st->spi = spi;
+ st->chip_info = spi_get_device_match_data(spi);
mutex_init(&st->lock);
ret = adf4377_properties_parse(st);
@@ -964,13 +984,15 @@ static int adf4377_probe(struct spi_device *spi)
}
static const struct spi_device_id adf4377_id[] = {
- { "adf4377", 0 },
+ { "adf4377", (kernel_ulong_t)&adf4377_chip_info_tbl[0] },
+ { "adf4378", (kernel_ulong_t)&adf4377_chip_info_tbl[1] },
{}
};
MODULE_DEVICE_TABLE(spi, adf4377_id);
static const struct of_device_id adf4377_of_match[] = {
- { .compatible = "adi,adf4377" },
+ { .compatible = "adi,adf4377", .data = &adf4377_chip_info_tbl[0] },
+ { .compatible = "adi,adf4378", .data = &adf4377_chip_info_tbl[1]},
{}
};
MODULE_DEVICE_TABLE(of, adf4377_of_match);
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: iio: adf4377: add adf4378 support
2024-07-22 13:45 [PATCH v2 1/2] dt-bindings: iio: adf4377: add adf4378 support Antoniu Miclaus
2024-07-22 13:45 ` [PATCH v2 2/2] iio: frequency: " Antoniu Miclaus
@ 2024-07-22 16:26 ` Conor Dooley
2024-07-27 12:30 ` Jonathan Cameron
1 sibling, 1 reply; 5+ messages in thread
From: Conor Dooley @ 2024-07-22 16:26 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Dragos Bogdan,
linux-iio, devicetree, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1577 bytes --]
On Mon, Jul 22, 2024 at 04:45:05PM +0300, Antoniu Miclaus wrote:
> Add porperty conditions for the adf4378.
> Add product link for the adf4378.
I can see this from the diff. You need to explain /why/ this gpio is not
valid for use on this device.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
> changes in v2:
> - use property conditions for clk2 gpio
> Note: the compatible is already available from the firs iteration of the driver
> where these particularities weren't available for adf4378
> .../devicetree/bindings/iio/frequency/adi,adf4377.yaml | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml b/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
> index aa6a3193b4e0..5f950ee9aec7 100644
> --- a/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
> +++ b/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
> @@ -17,6 +17,7 @@ description: |
> applications.
>
> https://www.analog.com/en/products/adf4377.html
> + https://www.analog.com/en/products/adf4378.html
>
> properties:
> compatible:
> @@ -73,6 +74,15 @@ required:
>
> allOf:
> - $ref: /schemas/spi/spi-peripheral-props.yaml#
> + - if:
> + properties:
> + compatible:
> + contains:
> + enum:
> + - adi,adf4378
> + then:
> + properties:
> + clk2-enable-gpios: false
>
> unevaluatedProperties: false
>
> --
> 2.45.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] dt-bindings: iio: adf4377: add adf4378 support
2024-07-22 16:26 ` [PATCH v2 1/2] dt-bindings: iio: " Conor Dooley
@ 2024-07-27 12:30 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2024-07-27 12:30 UTC (permalink / raw)
To: Conor Dooley
Cc: Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Dragos Bogdan,
linux-iio, devicetree, linux-kernel
On Mon, 22 Jul 2024 17:26:37 +0100
Conor Dooley <conor@kernel.org> wrote:
> On Mon, Jul 22, 2024 at 04:45:05PM +0300, Antoniu Miclaus wrote:
> > Add porperty conditions for the adf4378.
property
> > Add product link for the adf4378.
>
> I can see this from the diff. You need to explain /why/ this gpio is not
> valid for use on this device.
>
> >
> > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> > ---
> > changes in v2:
> > - use property conditions for clk2 gpio
> > Note: the compatible is already available from the firs iteration of the driver
> > where these particularities weren't available for adf4378
> > .../devicetree/bindings/iio/frequency/adi,adf4377.yaml | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml b/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
> > index aa6a3193b4e0..5f950ee9aec7 100644
> > --- a/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
> > +++ b/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml
> > @@ -17,6 +17,7 @@ description: |
> > applications.
> >
> > https://www.analog.com/en/products/adf4377.html
> > + https://www.analog.com/en/products/adf4378.html
> >
> > properties:
> > compatible:
> > @@ -73,6 +74,15 @@ required:
> >
> > allOf:
> > - $ref: /schemas/spi/spi-peripheral-props.yaml#
> > + - if:
> > + properties:
> > + compatible:
> > + contains:
> > + enum:
> > + - adi,adf4378
> > + then:
> > + properties:
> > + clk2-enable-gpios: false
> >
> > unevaluatedProperties: false
> >
> > --
> > 2.45.2
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] iio: frequency: adf4377: add adf4378 support
2024-07-22 13:45 ` [PATCH v2 2/2] iio: frequency: " Antoniu Miclaus
@ 2024-07-27 12:33 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2024-07-27 12:33 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Dragos Bogdan, linux-iio,
devicetree, linux-kernel
On Mon, 22 Jul 2024 16:45:06 +0300
Antoniu Miclaus <antoniu.miclaus@analog.com> wrote:
> Add separate handling for adf4378 within the driver.
>
> The main difference between adf4377 and adf4378 is that adf4378 has only
> one output which is handled by only one gpio.
>
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Follow up comments on the v2 changes inline.
For future series, please always use a cover letter
--cover-letter in git format-patch as it provides somewhere for general
comments and gives the series a nice name etc in patchwork.
Jonathan
> ---
> changes in v2:
> - use chip_info structure to handle new added part (adf4378)
> - use spi_get_device_match_data
> - drop redundant check in if statement.
> drivers/iio/frequency/adf4377.c | 36 ++++++++++++++++++++++++++-------
> 1 file changed, 29 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c
> index 9284c13f1abb..82374f5d2695 100644
> --- a/drivers/iio/frequency/adf4377.c
> +++ b/drivers/iio/frequency/adf4377.c
> @@ -400,7 +400,13 @@ enum muxout_select_mode {
> ADF4377_MUXOUT_HIGH = 0x8,
> };
>
> +struct adf4377_chip_info {
> + const char *name;
> + bool has_gpio_enclk2;
> +};
> +
> struct adf4377_state {
> + const struct adf4377_chip_info *chip_info;
> struct spi_device *spi;
> struct regmap *regmap;
> struct clk *clkin;
> @@ -889,11 +895,13 @@ static int adf4377_properties_parse(struct adf4377_state *st)
> return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk1),
> "failed to get the CE GPIO\n");
>
> - st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable",
> - GPIOD_OUT_LOW);
> - if (IS_ERR(st->gpio_enclk2))
> - return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2),
> - "failed to get the CE GPIO\n");
> + if (st->chip_info->has_gpio_enclk2) {
> + st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "clk2-enable",
> + GPIOD_OUT_LOW);
> + if (IS_ERR(st->gpio_enclk2))
> + return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2),
> + "failed to get the CE GPIO\n");
> + }
>
> ret = device_property_match_property_string(&spi->dev, "adi,muxout-select",
> adf4377_muxout_modes,
> @@ -921,6 +929,17 @@ static int adf4377_freq_change(struct notifier_block *nb, unsigned long action,
> return NOTIFY_OK;
> }
>
> +static const struct adf4377_chip_info adf4377_chip_info_tbl[] = {
See below on why an array is not useful here.
> + {
> + .name = "adf4377",
> + .has_gpio_enclk2 = true,
> + },
> + {
> + .name = "adf4378",
> + .has_gpio_enclk2 = false,
> + },
> +};
> +
> static int adf4377_probe(struct spi_device *spi)
> {
> struct iio_dev *indio_dev;
> @@ -945,6 +964,7 @@ static int adf4377_probe(struct spi_device *spi)
>
> st->regmap = regmap;
> st->spi = spi;
> + st->chip_info = spi_get_device_match_data(spi);
> mutex_init(&st->lock);
>
> ret = adf4377_properties_parse(st);
> @@ -964,13 +984,15 @@ static int adf4377_probe(struct spi_device *spi)
> }
>
> static const struct spi_device_id adf4377_id[] = {
> - { "adf4377", 0 },
> + { "adf4377", (kernel_ulong_t)&adf4377_chip_info_tbl[0] },
> + { "adf4378", (kernel_ulong_t)&adf4377_chip_info_tbl[1] },
> {}
> };
> MODULE_DEVICE_TABLE(spi, adf4377_id);
>
> static const struct of_device_id adf4377_of_match[] = {
> - { .compatible = "adi,adf4377" },
> + { .compatible = "adi,adf4377", .data = &adf4377_chip_info_tbl[0] },
> + { .compatible = "adi,adf4378", .data = &adf4377_chip_info_tbl[1]},
We've been moving away from this use of an array because it means you then need
an enum to say which is which. Better to just have two named structures
as then it's obvious which one is which.
adf4377_chip_info and adf4378_chip_info
> {}
> };
> MODULE_DEVICE_TABLE(of, adf4377_of_match);
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-27 12:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-22 13:45 [PATCH v2 1/2] dt-bindings: iio: adf4377: add adf4378 support Antoniu Miclaus
2024-07-22 13:45 ` [PATCH v2 2/2] iio: frequency: " Antoniu Miclaus
2024-07-27 12:33 ` Jonathan Cameron
2024-07-22 16:26 ` [PATCH v2 1/2] dt-bindings: iio: " Conor Dooley
2024-07-27 12:30 ` 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).