summaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/ti_am335x_adc.c
Commit message (Collapse)AuthorAgeFilesLines
* iio: remove .owner field for driver using module_platform_driverSanjeev Sharma2014-08-261-1/+0
| | | | | | | | | This patch removes the .owner field for drivers which use the platform_driver_register api because this is overriden in _platform_driver_register. Signed-off-by: Sanjeev Sharma <Sanjeev_Sharma@mentor.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: ti_am335x_adc: Fix: Use same step id at FIFOs both endsJan Kardell2014-07-081-1/+1
| | | | | | | | | | | | Since AI lines could be selected at will (linux-3.11) the sending and receiving ends of the FIFO does not agree about what step is used for a line. It only works if the last lines are used, like 5,6,7, and fails if ie 2,4,6 is selected in DT. Signed-off-by: Jan Kardell <jan.kardell@telliq.com> Tested-by: Zubair Lutfullah <zubair.lutfullah@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Cc: stable@vger.kernel.org
* Merge tag 'iio-for-3.15a' of ↵Greg Kroah-Hartman2014-02-111-1/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: First set of new drivers and cleanups for IIO in the 3.15 cycle. New drivers: * si7005 relative humidity and temperature sensor * Lite-on ltr501 ambient light and proximity sensor Cleanups * Clean up some dead comments in max1363 * Drop some obsolete variables in adjd_s311 and tcs3472 left over from the introduction of iio_push_to_buffers_with_timestamp. * Drop some unneeded linux/init.h includes * Squish a sparse warning in mpl3115 by correctly specifying a be32 variable. * A number of cleanups and fixes for sca3000 * Drop an unneed checks in mxs-lradc, ad7303 and adis16400. * Drop a platform_set_drvdata in viperboard after the only use of it was removed during a devm conversion. * Add a missing device name for ak8975 to comply with the ABI. * Put mpu6050 into the IMU menu as it slipped out into the main menu. * Fix a typo and some comment formatting in mpu6050. * Document at91 ADC clock properties.
| * iio: delete non-required instances of include <linux/init.h>Paul Gortmaker2014-01-111-1/+0
| | | | | | | | | | | | | | | | | | | | None of these files are actually using any __init type directives and hence don't need to include <linux/init.h>. Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* | Merge tag 'ib-iio-input-3.13-1' into for-mfd-nextLee Jones2014-01-211-19/+49
|\ \ | |/ |/| | | Immutable branch for IIO and Input
| * mfd: input: iio: ti_amm335x: Rework TSC/ADC synchronizationSebastian Andrzej Siewior2014-01-071-18/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ADC driver always programs all possible ADC values and discards them except for the value IIO asked for. On the am335x-evm the driver programs four values and it takes 500us to gather them. Reducing the number of conversations down to the (required) one also reduces the busy loop down to 125us. This leads to another error, namely the FIFOCOUNT register is sometimes (like one out of 10 attempts) not updated in time leading to EBUSY. The next read has the FIFOCOUNT register updated. Checking for the ADCSTAT register for being idle isn't a good choice either. The problem is that if TSC is used at the same time, the HW completes the conversation for ADC *and* before the driver noticed it, the HW begins to perform a TSC conversation and so the driver never seen the HW idle. The next time we would have two values in the FIFO but since the driver reads everything we always see the current one. So instead of polling for the IDLE bit in ADCStatus register, we should check the FIFOCOUNT register. It should be one instead of zero because we request one value. This change in turn leads to another error. Sometimes if TSC & ADC are used together the TSC starts generating interrupts even if nobody actually touched the touchscreen. The interrupts seem valid because TSC's FIFO is filled with values for each channel of the TSC. This condition stops after a few ADC reads but will occur again. Not good. On top of this (even without the changes I just mentioned) there is a ADC & TSC lockup condition which was reported to me by Jeff Lance including the following test case: A busy loop of "cat /sys/bus/iio/devices/iio\:device0/in_voltage4_raw" and a mug on touch screen. With this setup, the hardware will lockup after something between 20 minutes and it could take up to a couple of hours. During that lockup, the ADCSTAT register says 0x30 (or 0x70) which means STEP_ID = IDLE and FSM_BUSY = yes. That means the hardware says that it is idle and busy at the same time which is an invalid condition. For all this reasons I decided to rework this TSC/ADC part and add a handshake / synchronization here: First the ADC signals that it needs the HW and writes a 0 mask into the SE register. The HW (if active) will complete the current conversation and become idle. The TSC driver will gather the values from the FIFO (woken up by an interrupt) and won't "enable" another conversation. Instead it will wake up the ADC driver which is already waiting. The ADC driver will start "its" conversation and once it is done, it will enable the TSC steps so the TSC will work again. After this rework I haven't observed the lockup so far. Plus the busy loop has been reduced from 500us to 125us. The continues-read mode remains unchanged. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
| * mfd: ti_am335x: Drop am335x_tsc_se_update() from resume pathSebastian Andrzej Siewior2014-01-071-0/+2
| | | | | | | | | | | | | | | | | | | | | | The update of the SE register in MFD doesn't look right as it has nothing to do with it. The better place to do it is in TSC driver (which is already doing it) and in the ADC driver which needs this only in the continues mode. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
| * mfd: ti_am335x_tscadc: Don't read back REG_SESebastian Andrzej Siewior2014-01-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The purpose of reg_se_cache has been defeated. It should avoid the read-back of the register to avoid the latency and the fact that the bits are reset to 0 after the individual conversation took place. The reason why this is required like this to work, is that read-back of the register removes the bits of the ADC so they do not start another conversation after the register is re-written from the TSC side for the update. To avoid the not required read-back I introduce a "set once" variant which does not update the cache mask. After the conversation completes, the bit is removed from the SE register anyway and we don't plan a new conversation "any time soon". The current set function is renamed to set_cache to distinguish the two operations. This is a small preparation for a larger sync-rework. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
| * iio: ti_am335x_adc: Adjust the closing bracket in tiadc_read_raw()Sebastian Andrzej Siewior2014-01-071-1/+1
| | | | | | | | | | | | | | | | | | | | It somehow looks like the ending bracket belongs to the if statement but it does belong to the while loop. This patch moves the bracket where it belongs. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Lee Jones <lee.jones@linaro.org>
* | iio: adc: ti_am335x_adc: avoid double free of buffer.Lars-Peter Clausen2013-11-091-2/+5
|/ | | | | | | | | | | The driver is missing the iio_buffer_attach() call. As such it will attempt to free the buffer twice on removal. Introduced in commit 9e69c9 ("iio: Add reference counting for buffers"). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: adc: ti_am335x_adc: Remove redundant of_match_ptrSachin Kamat2013-10-231-1/+1
| | | | | | | | ti_adc_dt_ids is always compiled in. Hence of_match_ptr is not needed. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio:ti_am335x: Remove redundant call to iio_sw_buffer_preenable()Lars-Peter Clausen2013-10-161-1/+1
| | | | | | | | | The equivalent of iio_sw_buffer_preenable() is now done in the IIO buffer core, so there is no need to do this from the driver anymore. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Zubair Lutfullah <zubair.lutfullah@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: ti_am335x_adc: cleanup error caseZubair Lutfullah2013-09-221-10/+0
| | | | | | | Driver is functional without this error case. Cleaned up. Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: ti_am335x_adc: cleanup trigger related codeZubair Lutfullah2013-09-221-4/+0
| | | | | | | | Trigger related headers and variables are not needed as driver is now based on INDIO_BUFFER_HARDWARE mode Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: ti_am335x_adc: fix static in function headerZubair Lutfullah2013-09-221-1/+1
| | | | | | | | Static is missing in function header. Corrected. Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com> Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: ti_am335x_adc: Add continuous sampling supportZubair Lutfullah2013-09-211-5/+208
| | | | | | | | | | | | | | | | | | | | | | | | Previously the driver had only one-shot reading functionality. This patch adds continuous sampling support to the driver. Continuous sampling starts when buffer is enabled. HW IRQ wakes worker thread that pushes samples to userspace. Sampling stops when buffer is disabled by userspace. Patil Rachna (TI) laid the ground work for ADC HW register access. Russ Dill (TI) fixed bugs in the driver relevant to FIFOs and IRQs. I fixed channel scanning so multiple ADC channels can be read simultaneously and pushed to userspace. Restructured the driver to fit IIO ABI. And added INDIO_BUFFER_HARDWARE mode. Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Russ Dill <Russ.Dill@ti.com> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* iio: ti_am335x_adc: optimize memory usageZubair Lutfullah2013-09-211-2/+2
| | | | | | | | 12 bit ADC data is stored in 32 bits of storage. Change from u32 to u16 to reduce wasted memory. Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* Merge 3.11-rc5 into staging-nextGreg Kroah-Hartman2013-08-121-8/+22
|\ | | | | | | | | | | We want the staging fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * iio: ti_am335x_adc: Fix wrong samples received on 1st readPatil, Rachna2013-07-211-8/+22
| | | | | | | | | | | | | | | | | | | | Previously we tried to read data form ADC even before ADC sequencer finished sampling. This led to wrong samples. We now wait on ADC status register idle bit to be set. Signed-off-by: Patil, Rachna <rachna@ti.com> Signed-off-by: Zubair Lutfullah <zubair.lutfullah@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* | iio: adc: ti_am335x_adc: Use devm_iio_device_allocSachin Kamat2013-08-031-9/+4
|/ | | | | | | | Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Rachna Patil <rachna@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* Merge tag 'iio-fixes-for-3.11a' of ↵Greg Kroah-Hartman2013-07-161-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus Jonathan writes: The first round of IIO fixes for the 3.11 cycle. This set is larger than I would like, partly due to my lack of review time in the weeks before the merge window and partly because a couple of large drivers and the subsystem as a whole seem to be getting a lot more exposure and testing recently. 1) A long term bug in trigger handling gave a double free of the device. 2) Wrong return value handling means offsets are ignored in iio_convert_raw_to_processed_unlocked. 3) The iio_channel_has_info utility function was incorrectly updated during the recent info_mask split, this is now fixed. 4) mxs-lradc has a couple of little fixes. 5) A couple of missing .driver_module entries meant that drivers could be removed from underneath their users. 6) Error path fixes for ad7303 and lis3l02dq. 7) The scale value for presure in the lps331ap driver was out by a factor of 100.
| * iio: ti_am335x_adc: add missing .driver_module to struct iio_infoWei Yongjun2013-07-061-0/+1
| | | | | | | | | | | | | | | | Add missing .driver_module of struct iio_info. This prevents the module from being removed from underneath its users. Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
* | iio: ti_am335x_adc: check if we found the valueSebastian Andrzej Siewior2013-06-121-2/+6
| | | | | | | | | | | | | | | | | | Usually we get all the values we wanted but it is possible, that te ADC unit is busy performing the conversation for the HW events. In that case -EBUSY is returned and the user may re-call the function. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* | iio: ti_am335x_adc: Allow to specify input lineSebastian Andrzej Siewior2013-06-121-20/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The TSC part allows to specify the input lines. The IIO part assumes that it usues always the last few, that means if IIO has adc-channels set to 2 it will use channel 6 and 7. However it might make sense to use only 6. This patch changes the device property (which was introduced recently and was never in an official release) in a way that the user can specify which of the AIN lines should be used. In Addition to this, the name is now AINx where x is the channel number i.e. for AIN6 we would have 6. Prior this, it always started counting at 0 which is confusing. In addition to this, it also checks for correct step number during reading and does not rely on proper FIFO depth. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* | input: ti_am335x_adc: use only FIFO0 and clean up a littleSebastian Andrzej Siewior2013-06-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The driver programs a threshold of "coordinate_readouts" say 5. The REG_FIFO0THR registers says it should it be programmed to "threshold minus one". The driver does not expect just 5 coordinates but 5 * 2 + 2. Multiplied by two because 5 for X and 5 for Y and plus 2 because we have two Z. The whole thing kind of works because It reads the 5 coordinates for X and Y from FIFO0 and FIFO1 and the last element in each FIFO is ignored within the loop and read later. Nothing guaranties that FIFO1 is ready by the time it is read. In fact I could see that that FIFO1 reaturns for Y channels 8,9, 10, 12, 6 and for Y channel 7 for Z. The problem is that channel 7 and channel 12 got somehow mixed up. The other Problem is that FIFO1 is also used by the IIO part leading to wrong results if both (tsc & adc) are used. The patch tries to clean up the whole thing a little: - Remove the +1 and -1 in REG_STEPCONFIG, REG_STEPDELAY and its counter part in the for loop. This is just confusing. - Use only FIFO0 in TSC. The fifo has space for 64 entries so should be fine. - Read the whole FIFO in one function and check the channel. - in case we dawdle around, make sure we only read a multiple of our coordinate set. On the second interrupt we will cleanup the remaining enties. Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* | mfd: iio: ti_am335x_adc: rename device from tiadc to TI-am335x-adcSebastian Andrzej Siewior2013-06-121-2/+1
| | | | | | | | | | | | | | | | TI-adc reads a little better compared to tiadc. And if we add am335x to it then we have the same naming scheme as the tsc side. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* | iio: ti_tscadc: provide datasheet_name and scan_typePantelis Antoniou2013-06-121-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | This patch provides the members "datasheet_name" and scan_type. This is the remaining part of the earlier patch where I (bigeasy) removed iio_map because it is now supplied by the device tree. It also static names as suggested by Jonathan. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* | iio: ti_am335x_adc: remove platform_data supportSebastian Andrzej Siewior2013-06-121-14/+7
| | | | | | | | | | | | | | | | This patch removes access to platform data mfd_tscadc_board because the platform is DT only. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* | iio: ti_am335x_adc: Add DT supportPatil, Rachna2013-06-121-5/+24
| | | | | | | | | | | | | | | | | | | | Add DT support for client ADC driver. Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Patil, Rachna <rachna@ti.com> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* | input: ti_am33x_tsc: Step enable bits made configurablePatil, Rachna2013-06-121-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current code has hard coded value written to step enable bits. Now the bits are updated based on how many steps are needed to be configured got from platform data. The user needs to take care not to exceed the count more than 16. While using ADC and TSC one should take care to set this parameter correctly. Sebastian added the common lock and moved the code, that manipulates the steps, from into the mfd module. Signed-off-by: Patil, Rachna <rachna@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* | mfd: input: iio: ti_am335x_adc: use one structure for ti_tscadc_devSebastian Andrzej Siewior2013-06-121-2/+3
|/ | | | | | | | | | | | The mfd driver creates platform data for the child devices and it is the ti_tscadc_dev struct. This struct is copied for the two devices. The copy of the structure makes a common lock in this structure a little less usefull. Therefore the platform data is not a pointer to the structure and the same structure is used. While doing the change I noticed that the suspend/resume code assumes the wrong pointer for ti_tscadc_dev and this has been fixed as well. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
* iio:adc:ti_am335x_adc move to info_mask_(shared_by_type/separate)Jonathan Cameron2013-03-171-1/+1
| | | | | | | The original info_mask is going away in favour of the broken out versions. Signed-off-by: Jonathan Cameron <jic23@kernel.org> cc: Patil, Rachna <rachna@ti.com>
* Drivers: iio: remove __dev* attributes.Greg Kroah-Hartman2013-01-031-3/+3
| | | | | | | | | | | | | | | CONFIG_HOTPLUG is going away as an option. As a result, the __dev* markings need to be removed. This change removes the use of __devinit, __devexit_p, and __devexit from these drivers. Based on patches originally written by Bill Pemberton, but redone by me in order to handle some of the coding style issues better, by hand. Cc: Bill Pemberton <wfp5p@virginia.edu> Cc: Jonathan Cameron <jic23@cam.ac.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* IIO : ADC: tiadc: Add support of TI's ADC driverPatil, Rachna2012-11-051-0/+260
This patch adds support for TI's ADC driver. This is a multifunctional device. Analog input lines are provided on which voltage measurements can be carried out. You can have upto 8 input lines. Signed-off-by: Patil, Rachna <rachna@ti.com> Acked-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
OpenPOWER on IntegriCloud