mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-28 00:19:36 +00:00

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>
28 lines
665 B
C
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_ */
|