[PATCH 2/2] ad7192 driver: fixed unexpected internal clock fallback when no mclk clock is defined.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
--- 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 {




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux