linux-loongson/include/linux/iio/adc-helpers.h
Matti Vaittinen f3a8f870fa iio: adc: add helpers for parsing ADC nodes
There are ADC ICs which may have some of the AIN pins usable for other
functions. These ICs may have some of the AIN pins wired so that they
should not be used for ADC.

A common way of marking pins that can be used as ADC inputs is to add
corresponding channel@N nodes in the device tree as described in the ADC
	      binding yaml.

Add couple of helper functions which can be used to retrieve the channel
information from the device node.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://patch.msgid.link/f1d8b3e15237947738912c0d297b3e1e21d8b03e.1742560649.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-04-22 19:09:52 +01:00

28 lines
665 B
C

/* SPDX-License-Identifier: GPL-2.0-only */
/*
* The industrial I/O ADC firmware property parsing helpers
*
* Copyright (c) 2025 Matti Vaittinen <mazziesaccount@gmail.com>
*/
#ifndef _INDUSTRIAL_IO_ADC_HELPERS_H_
#define _INDUSTRIAL_IO_ADC_HELPERS_H_
#include <linux/property.h>
struct device;
struct iio_chan_spec;
static inline int iio_adc_device_num_channels(struct device *dev)
{
return device_get_named_child_node_count(dev, "channel");
}
int devm_iio_adc_device_alloc_chaninfo_se(struct device *dev,
const struct iio_chan_spec *template,
int max_chan_id,
struct iio_chan_spec **cs);
#endif /* _INDUSTRIAL_IO_ADC_HELPERS_H_ */