Linux IIO development
 help / color / mirror / Atom feed
* [PATCH 2/2] ad7192 driver: fixed unexpected internal clock fallback when no mclk clock is defined.
@ 2023-03-27 20:21 Fabrizio Lamarque
  2023-03-29 15:15 ` Nuno Sá
  0 siblings, 1 reply; 7+ messages in thread
From: Fabrizio Lamarque @ 2023-03-27 20:21 UTC (permalink / raw)
  To: alexandru.tachici; +Cc: linux-iio

Allow the use of external clock when mclk clock is defined.
When defining a mclk clock source in device tree with adi,clock-xtal
property, the external crystal oscillator is not turned on.
Without the change, the driver always uses the internal clock even
when mclk clock is defined.

Current implementation seems to contain a typo, since it expected
st->mclk to be NULL within ad7192_of_clock_select() in order to select
the external clock, but, if null, external clock cannot loaded
correctly (out of bounds due to invalid mclk) in ad7192_probe().

I believe this patch follows the author's intended behavior.
 After applying this patch, the external oscillator is started as expected.

I kindly ask your feedback, I may adjust the patch according to your
suggestions. I could also follow up with another patch on
documentation, containing the following (related) issues:

- adi,int-clock-output-enable is undocumented
- adi,clock-xtal is undocumented
- regulator name avdd and its description is quite misleading, since
this is unrelated to the AVdd pin (#20) of AD7192; it is used instead
as reference voltage (REFIN1 on #15/#16 or REFIN2 on #7/#8). See
int_vref_mv variable within driver implementation.

Signed-off-by: Fabrizio Lamarque <fl.scratchpad@gmail.com>
--- linux/drivers/iio/adc/ad7192.c  2023-03-13 19:32:42.646239506 +0100
+++ linux/drivers/iio/adc/ad7192.c  2023-03-14 10:19:32.361924242 +0100
@@ -367,7 +367,7 @@ static int ad7192_of_clock_select(struct
      clock_sel = AD7192_CLK_INT;

      /* use internal clock */
-     if (st->mclk) {
+     if (!st->mclk) {
            if (of_property_read_bool(np, "adi,int-clock-output-enable"))
                  clock_sel = AD7192_CLK_INT_CO;
      } else {

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

end of thread, other threads:[~2023-04-08 10:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-27 20:21 [PATCH 2/2] ad7192 driver: fixed unexpected internal clock fallback when no mclk clock is defined Fabrizio Lamarque
2023-03-29 15:15 ` Nuno Sá
2023-03-29 21:23   ` Fabrizio Lamarque
2023-03-30  7:53     ` Nuno Sá
2023-04-01 14:37       ` Jonathan Cameron
2023-04-04  7:20         ` Fabrizio Lamarque
2023-04-08 10:37           ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox