Re: [PATCH v3 2/3] iio: adc: ad7625: add driver

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

 



On Mon, 19 Aug 2024 10:11:44 -0400
Trevor Gamblin <tgamblin@xxxxxxxxxxxx> wrote:

> Add a driver for the AD762x and AD796x family of ADCs. These are
> pin-compatible devices using an LVDS interface for data transfer,
> capable of sampling at rates of 6 (AD7625), 10 (AD7626), and 5
> (AD7960/AD7961) MSPS, respectively. They also feature multiple voltage
> reference options based on the configuration of the EN1/EN0 pins, which
> can be set in the devicetree.
> 
> Signed-off-by: Trevor Gamblin <tgamblin@xxxxxxxxxxxx>
Hi Trevor
A few really minor things in here.  Given we are waiting on the 
PWM set anyway, I haven't just tidied them up whilst applying.
> ---
>  MAINTAINERS              |   1 +
>  drivers/iio/adc/Kconfig  |  15 ++
>  drivers/iio/adc/Makefile |   1 +
>  drivers/iio/adc/ad7625.c | 688 +++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 705 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 2361f92751dd..a90972e1c5c5 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -1268,6 +1268,7 @@ S:	Supported
>  W:	https://ez.analog.com/linux-software-drivers
>  W:	http://analogdevicesinc.github.io/hdl/projects/pulsar_lvds/index.html
>  F:	Documentation/devicetree/bindings/iio/adc/adi,ad7625.yaml
> +F:	drivers/iio/adc/ad7625.c
>  
>  ANALOG DEVICES INC AD7768-1 DRIVER
>  M:	Michael Hennerich <Michael.Hennerich@xxxxxxxxxx>
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index f60fe85a30d5..e25fb505f545 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -219,6 +219,21 @@ config AD7606_IFACE_SPI
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called ad7606_spi.
>  
> +config AD7625
> +        tristate "Analog Devices AD7625/AD7626 High Speed ADC driver"
> +        select IIO_BACKEND
> +        help
> +          Say yes here to build support for Analog Devices:
> +	  * AD7625 16-Bit, 6 MSPS PulSAR Analog-to-Digital Converter
Looks like some tabs mixed in with otherwise spaces.
Should be tabs + spaces as per entry above.
> +	  * AD7626 16-Bit, 10 MSPS PulSAR Analog-to-Digital Converter
> +	  * AD7960 18-Bit, 5 MSPS PulSAR Analog-to-Digital Converter
> +	  * AD7961 16-Bit, 5 MSPS PulSAR Analog-to-Digital Converter
> +
> +          The driver requires the assistance of the AXI ADC IP core to operate.
> +
> +          To compile this driver as a module, choose M here: the module will be
> +          called ad7625.
> +
>  config AD7766
>  	tristate "Analog Devices AD7766/AD7767 ADC driver"
>  	depends on SPI_MASTER

> diff --git a/drivers/iio/adc/ad7625.c b/drivers/iio/adc/ad7625.c
> new file mode 100644
> index 000000000000..3ac3c56d43eb
> --- /dev/null
> +++ b/drivers/iio/adc/ad7625.c
> @@ -0,0 +1,688 @@

> +
> +struct ad7625_chip_info {
> +	const char *name;
> +	const unsigned int max_sample_rate_hz;
> +	const struct ad7625_timing_spec *timing_spec;
> +	const struct iio_chan_spec chan_spec;
> +	const bool has_power_down_state;
> +	const bool has_bandwidth_control;
> +	const bool has_internal_vref;
Not sure I'd bother marking these bools const. Unlikely the compiler
can do anything with that info it can't do without it. I guess it does no
real harm thowever.
> +};


> +static int ad7625_probe(struct platform_device *pdev)
> +{

...

> +	/*
> +	 * Set the initial sampling frequency to the maximum, unless the
> +	 * AD796x device is limited to narrow bandwidth by EN2 == 1, in
> +	 * which case the sampling frequency should be limited to 2MSPS
> +	 */
> +	if (!st->info->has_bandwidth_control) {
> +		default_sample_freq = st->info->max_sample_rate_hz;
> +	} else {
> +		default_sample_freq = !st->can_wide_bandwidth ?

Flip the logic.
		default_sample_freq = st->can_wide_bandwidth ?
				      st->info->max_sample_rate_hz :
				      AD7960_MAX_NBW_FREQ;

seems simpler or set a default and override it.
	default_sample_freq = st->info_max_sample_rate_hz;
	if (st->info->has_bandwidth_control &&
	    !st->can_wide_bandwidth)
		default_sampling_freq = AD7960_MAX_NBW_FREQ;
		

> +				      AD7960_MAX_NBW_FREQ :
> +				      st->info->max_sample_rate_hz;
> +	}




[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