Thanks for the update and the example, but this is from sysfs user space and not for a kernel driver.
I am looking for an example that utilizes the dts file and references to obtaining data within the kernel driver.
For reference, this is what I have tried without success:
In myboard.dts
Using this as a ROOT node?
&adc0 {
#io-channel-cells = <1>;
status = "okay";
adc0_capture {status = "okay";
compatible = "my-adc-driver";
io-channels = <&adc0 3>;
};
Or using the following as a SOC node?
iio_map {
ch0 {
nxp,adc-channel-number = <0x0>;
nxp,adc-consumer-device = "adc-input.1";
nxpi,adc-consumer-channel = "vin1";
};
ch1 {
nxp,adc-channel-number = <0x1>;
nxp,adc-consumer-device = "adc-input.2";
nxp,adc-consumer-channel = "vin2";
};
};
In my_adc_driver.c:
// Get the instance of the channel from iio_map?
iio_channel *adc_vin1= iio_channel_get(&pdev->dev, "ch0");
// Read ADC value
ret = iio_read_channel_raw(adc_vin1, &value);
I'm not sure if I need a ROOT or a SOC node in myboard.dts file, and how to setup either? So, I am looking for an example on either, both for the dts and in the kernel driver file.
Thanks again for any additional assistance.