* [PATCH 1/2] dt-bindings: iio: adf4377: add adf4378 link @ 2024-07-17 9:30 Antoniu Miclaus 2024-07-17 9:30 ` [PATCH 2/2] iio: frequency: adf4377: add adf4378 support Antoniu Miclaus 2024-07-20 13:32 ` [PATCH 1/2] dt-bindings: iio: adf4377: add adf4378 link Jonathan Cameron 0 siblings, 2 replies; 5+ messages in thread From: Antoniu Miclaus @ 2024-07-17 9:30 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 product link for the adf4378 part. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> --- Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml b/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml index aa6a3193b4e0..902081b83447 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: -- 2.45.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] iio: frequency: adf4377: add adf4378 support 2024-07-17 9:30 [PATCH 1/2] dt-bindings: iio: adf4377: add adf4378 link Antoniu Miclaus @ 2024-07-17 9:30 ` Antoniu Miclaus 2024-07-17 9:38 ` Krzysztof Kozlowski 2024-07-20 13:32 ` [PATCH 1/2] dt-bindings: iio: adf4377: add adf4378 link Jonathan Cameron 1 sibling, 1 reply; 5+ messages in thread From: Antoniu Miclaus @ 2024-07-17 9:30 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> --- drivers/iio/frequency/adf4377.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c index 9284c13f1abb..e02298a8b47f 100644 --- a/drivers/iio/frequency/adf4377.c +++ b/drivers/iio/frequency/adf4377.c @@ -387,6 +387,11 @@ #define ADF4377_FREQ_PFD_250MHZ (250 * HZ_PER_MHZ) #define ADF4377_FREQ_PFD_320MHZ (320 * HZ_PER_MHZ) +enum adf4377_dev_type { + ADF4377, + ADF4378, +}; + enum { ADF4377_FREQ, }; @@ -402,6 +407,7 @@ enum muxout_select_mode { struct adf4377_state { struct spi_device *spi; + enum adf4377_dev_type type; struct regmap *regmap; struct clk *clkin; /* Protect against concurrent accesses to the device and data content */ @@ -687,7 +693,7 @@ static void adf4377_gpio_init(struct adf4377_state *st) if (st->gpio_enclk1) gpiod_set_value(st->gpio_enclk1, 1); - if (st->gpio_enclk2) + if (st->gpio_enclk2 && st->type == ADF4377) gpiod_set_value(st->gpio_enclk2, 1); } @@ -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->type == ADF4377) { + 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, @@ -945,6 +953,7 @@ static int adf4377_probe(struct spi_device *spi) st->regmap = regmap; st->spi = spi; + st->type = spi_get_device_id(spi)->driver_data; mutex_init(&st->lock); ret = adf4377_properties_parse(st); @@ -964,13 +973,15 @@ static int adf4377_probe(struct spi_device *spi) } static const struct spi_device_id adf4377_id[] = { - { "adf4377", 0 }, + { "adf4377", ADF4377 }, + { "adf4378", ADF4378 }, {} }; MODULE_DEVICE_TABLE(spi, adf4377_id); static const struct of_device_id adf4377_of_match[] = { { .compatible = "adi,adf4377" }, + { .compatible = "adi,adf4378" }, {} }; MODULE_DEVICE_TABLE(of, adf4377_of_match); -- 2.45.2 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] iio: frequency: adf4377: add adf4378 support 2024-07-17 9:30 ` [PATCH 2/2] iio: frequency: adf4377: add adf4378 support Antoniu Miclaus @ 2024-07-17 9:38 ` Krzysztof Kozlowski 2024-07-20 13:36 ` Jonathan Cameron 0 siblings, 1 reply; 5+ messages in thread From: Krzysztof Kozlowski @ 2024-07-17 9:38 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 On 17/07/2024 11:30, Antoniu Miclaus 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> > --- > drivers/iio/frequency/adf4377.c | 25 ++++++++++++++++++------- > 1 file changed, 18 insertions(+), 7 deletions(-) > > diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c > index 9284c13f1abb..e02298a8b47f 100644 > --- a/drivers/iio/frequency/adf4377.c > +++ b/drivers/iio/frequency/adf4377.c > @@ -387,6 +387,11 @@ > #define ADF4377_FREQ_PFD_250MHZ (250 * HZ_PER_MHZ) > #define ADF4377_FREQ_PFD_320MHZ (320 * HZ_PER_MHZ) > > +enum adf4377_dev_type { > + ADF4377, > + ADF4378, > +}; > + > enum { > ADF4377_FREQ, > }; > @@ -402,6 +407,7 @@ enum muxout_select_mode { > > struct adf4377_state { > struct spi_device *spi; > + enum adf4377_dev_type type; > struct regmap *regmap; > struct clk *clkin; > /* Protect against concurrent accesses to the device and data content */ > @@ -687,7 +693,7 @@ static void adf4377_gpio_init(struct adf4377_state *st) > if (st->gpio_enclk1) > gpiod_set_value(st->gpio_enclk1, 1); > > - if (st->gpio_enclk2) > + if (st->gpio_enclk2 && st->type == ADF4377) Why? Isn't everything correct for NULL? > gpiod_set_value(st->gpio_enclk2, 1); > } > > @@ -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->type == ADF4377) { So the device does not have this pin? Then you should express it in the bindings. > + 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, > @@ -945,6 +953,7 @@ static int adf4377_probe(struct spi_device *spi) > > st->regmap = regmap; > st->spi = spi; > + st->type = spi_get_device_id(spi)->driver_data; spi_get_device_match_data() > mutex_init(&st->lock); > > ret = adf4377_properties_parse(st); > @@ -964,13 +973,15 @@ static int adf4377_probe(struct spi_device *spi) > } > > static const struct spi_device_id adf4377_id[] = { > - { "adf4377", 0 }, > + { "adf4377", ADF4377 }, > + { "adf4378", ADF4378 }, > {} > }; > MODULE_DEVICE_TABLE(spi, adf4377_id); > > static const struct of_device_id adf4377_of_match[] = { > { .compatible = "adi,adf4377" }, > + { .compatible = "adi,adf4378" }, Your device ID tables have incoherent match data. Considering that one type is 0, this is error-prone and discouraged. Best regards, Krzysztof ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] iio: frequency: adf4377: add adf4378 support 2024-07-17 9:38 ` Krzysztof Kozlowski @ 2024-07-20 13:36 ` Jonathan Cameron 0 siblings, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2024-07-20 13:36 UTC (permalink / raw) To: Krzysztof Kozlowski Cc: Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Dragos Bogdan, linux-iio, devicetree, linux-kernel On Wed, 17 Jul 2024 11:38:30 +0200 Krzysztof Kozlowski <krzk@kernel.org> wrote: > On 17/07/2024 11:30, Antoniu Miclaus 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> Replying on top of Krzysztof's review as he is raising very similar points to those I was going to make. > > --- > > drivers/iio/frequency/adf4377.c | 25 ++++++++++++++++++------- > > 1 file changed, 18 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/iio/frequency/adf4377.c b/drivers/iio/frequency/adf4377.c > > index 9284c13f1abb..e02298a8b47f 100644 > > --- a/drivers/iio/frequency/adf4377.c > > +++ b/drivers/iio/frequency/adf4377.c > > @@ -387,6 +387,11 @@ > > #define ADF4377_FREQ_PFD_250MHZ (250 * HZ_PER_MHZ) > > #define ADF4377_FREQ_PFD_320MHZ (320 * HZ_PER_MHZ) > > > > +enum adf4377_dev_type { > > + ADF4377, > > + ADF4378, > > +}; See below - but using an enum for device type is normally a bad sign. It means you are adding a bunch of code paths that will need continual extension as new chips are added. Much better to add a description of chip features in a const structure. > > + > > enum { > > ADF4377_FREQ, > > }; > > @@ -402,6 +407,7 @@ enum muxout_select_mode { > > > > struct adf4377_state { > > struct spi_device *spi; > > + enum adf4377_dev_type type; > > struct regmap *regmap; > > struct clk *clkin; > > /* Protect against concurrent accesses to the device and data content */ > > @@ -687,7 +693,7 @@ static void adf4377_gpio_init(struct adf4377_state *st) > > if (st->gpio_enclk1) > > gpiod_set_value(st->gpio_enclk1, 1); > > > > - if (st->gpio_enclk2) > > + if (st->gpio_enclk2 && st->type == ADF4377) > > Why? Isn't everything correct for NULL? > > > gpiod_set_value(st->gpio_enclk2, 1); > > } > > > > @@ -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->type == ADF4377) { > > So the device does not have this pin? Then you should express it in the > bindings. Agreed: That binding needs to ensure that there isn't a second pin expressed for a chip where it makes no sense. > > > + 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, > > @@ -945,6 +953,7 @@ static int adf4377_probe(struct spi_device *spi) > > > > st->regmap = regmap; > > st->spi = spi; > > + st->type = spi_get_device_id(spi)->driver_data; > > > spi_get_device_match_data() > > > mutex_init(&st->lock); > > > > ret = adf4377_properties_parse(st); > > @@ -964,13 +973,15 @@ static int adf4377_probe(struct spi_device *spi) > > } > > > > static const struct spi_device_id adf4377_id[] = { > > - { "adf4377", 0 }, > > + { "adf4377", ADF4377 }, > > + { "adf4378", ADF4378 }, > > {} > > }; > > MODULE_DEVICE_TABLE(spi, adf4377_id); > > > > static const struct of_device_id adf4377_of_match[] = { > > { .compatible = "adi,adf4377" }, > > + { .compatible = "adi,adf4378" }, > > Your device ID tables have incoherent match data. Considering that one > type is 0, this is error-prone and discouraged. Agreed. Much better to use a pointer to a chip specific structure for these thus avoiding the accidental NULL value and turning chip differences into data, not code. > > Best regards, > Krzysztof > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] dt-bindings: iio: adf4377: add adf4378 link 2024-07-17 9:30 [PATCH 1/2] dt-bindings: iio: adf4377: add adf4378 link Antoniu Miclaus 2024-07-17 9:30 ` [PATCH 2/2] iio: frequency: adf4377: add adf4378 support Antoniu Miclaus @ 2024-07-20 13:32 ` Jonathan Cameron 1 sibling, 0 replies; 5+ messages in thread From: Jonathan Cameron @ 2024-07-20 13:32 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 Wed, 17 Jul 2024 12:30:31 +0300 Antoniu Miclaus <antoniu.miclaus@analog.com> wrote: > Add product link for the adf4378 part. This should state why it doesn't need a new compatible (I think it does, see next patch review). > > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> > --- > Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml b/Documentation/devicetree/bindings/iio/frequency/adi,adf4377.yaml > index aa6a3193b4e0..902081b83447 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: ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-20 13:36 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-07-17 9:30 [PATCH 1/2] dt-bindings: iio: adf4377: add adf4378 link Antoniu Miclaus 2024-07-17 9:30 ` [PATCH 2/2] iio: frequency: adf4377: add adf4378 support Antoniu Miclaus 2024-07-17 9:38 ` Krzysztof Kozlowski 2024-07-20 13:36 ` Jonathan Cameron 2024-07-20 13:32 ` [PATCH 1/2] dt-bindings: iio: adf4377: add adf4378 link 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).