Hi All,
Sometimes ADC gives below error when it is read using "cat /sys/bus/iio/devices/iio:device0/in_voltage0_raw",
cat: read error: Resource temporarily unavailable
In file " drivers/iio/adc/ti_am335x_adc.c", the below functiion is there,
static int tiadc_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
struct tiadc_device *adc_dev = iio_priv(indio_dev);
int i;
unsigned int fifo1count, read, stepid;
u32 step = UINT_MAX;
bool found = false;
u32 step_en;
unsigned long timeout = jiffies + usecs_to_jiffies
(IDLE_TIMEOUT * adc_dev->channels);
step_en = get_adc_chan_step_mask(adc_dev, chan);
if (!step_en)
{
printk("ADC: step_en = 0\n");
return -EINVAL;
}
am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);
/* Wait for Fifo threshold interrupt */
while (!(tiadc_readl(adc_dev, REG_RAWIRQSTATUS) & IRQENB_FIFO1THRES)) {
if (time_after(jiffies, timeout)) {
am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
printk("ADC: time_after returns true value\n");
return -EAGAIN;
}
}
.........
This function returns EAGAIN, when timeout happens. Timeout happens after 10 micro-seconds. Within this 10 micro-seconds, FIFO is not being updated with data sample.
(IDLE_TIMEOUT * adc_dev->channels) = 5 * 2 = 10 micro-seconds.
In "include/linux/mfd/ti_am335x_tscadc.h"
/*
* ADC runs at 3MHz, and it takes
* 15 cycles to latch one data output.
* Hence the idle time for ADC to
* process one sample data would be
* around 5 micro seconds.
*/
#define IDLE_TIMEOUT 5 /* microsec */
What is the solution for this? Increasing "IDLE_TIMEOUT" may solve this problem? What is the fail-safe value? How to find it?
Regards,
Gangadhar