summaryrefslogtreecommitdiff
path: root/drivers/iio/accel/kxcjk-1013.c
AgeCommit message (Collapse)AuthorFilesLines
2015-04-07Merge 4.0-rc7 into staging-nextGreg Kroah-Hartman1-1/+1
We want those fixes (iio primarily) into the -next branch to help with merge and testing issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-03-07iio: fix drivers that check buffer->scan_maskOctavian Purdila1-1/+1
If the in-kernel push interface is used we may have a different masks on the device buffer and the kernel buffer and in this case the device should generate data for the reunion of the buffers, which is available at indio_dev->active_scan_mask. Compiled tested only except for bmc150-accel which was tested at runtime with the hardware. Signed-off-by: Octavian Purdila <octavian.purdila@intel.com> Cc: <stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-02-22iio: improve usage of gpiod APIUwe Kleine-König1-5/+1
Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions) which appeared in v3.17-rc1, the gpiod_get* functions take an additional parameter that allows to specify direction and initial value for outputs. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-21Merge tag 'iio-for-3.20a_take2' of ↵Greg Kroah-Hartman1-13/+39
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-testing Jonathan writes: First round of IIO new drivers, cleanups and functionality for the 3.20 cycle take 2 Updated pull request with Daniel's fix on top for the power management Kconfig changes that had snuck in since last update of the IIO tree worked it's way through from mainline. Original pull message New device support * jsa1212 proxmity / ambient light sensor * SM08500 supported added to the kxcjk-1013 accelerometer driver * KMX61 Accelerometer/Magnetometer. This took a somewhat rocky path being first merged, then reverted for a rewrite after a discussion of how to support additional functionality and finally being merged prior to some last reviews coming in, with resultant follow up patches. * Freescale mma9551l driver (minor follow up warning supression patch). * Semtech SX9500 proximity device driver. * ak8975 gains support for ak09911 and ak09912 and drop the standalone driver for the ak09911. New functionality * Dummy driver gains some virtual registers making it more flexible. * IIO_ACTIVITY channel types, with modifiers running, walking etc. This is to support on chip motion clasifiers. As such it is in the form of a confidence percentage. The only devices so far only do binary decisions but this gives us room when other devices give more nuanced clasification. * IIO_EV_DIR_NONE type for events where there is no obvious direction. First case is step detection. * IIO_STEPS channel type for pedometers. * ENABLE mask element used to control turning on counting types such as the pedometer that need a 'start point'. * INSTANCE event type to support things that happen once. * info element for height calibration (used in various motion estimation algorithms). Note heigh tof use * dummy driver demonstration of the use of all the new bits above. * event monitor support for the new events. * inv_mpu6050 gains an i2c mux to allow bypassing the device to access additional devices connected on the other side of it. Note that in Windows these are handled by firmware on the device and not exposed directly. * inv_mpu6050 gains ACPI enumeration. * inkern interface gains iio_write_channel_raw to allow in kernel users of DAC functionality via a simple wrapper. * Document input current readings in the ABI docs. * Add an error message when we get an out of range error in device tree processing for the in kernel interfaces. Basically a device tree debugging aid. * Add a sanity check that a scan index for a channel is unique during registration. There to help catch bugs as this should never happen in a bug free driver. Cleanups and fixlets A rework of buffer registration from Lars - a precursor to some other upcoming new stuff (a few patches from others rolled in here as well). * Ensure all drivers register the same channels for the device and buffer. * Move buffer registration into the core rather than using the old two step approach. Now we have simple ways of using a unified set channels for both without requiring channels be exposed by both interface, this removes a fair bit of boilerplate. * Stop sca3000 and ad5933 (both in staging) enabling buffer channels by default. It has long be convention in IIO to startup with no channels enabled and leave it up to userspace to say what goes in the buffer. Getting rid of these allows us to drop export of iio_scan_mask_set. * Drop get_bytes_per_datum from iio_buffer_access_funcs as not been used for a while. * Allocate standard buffer attributes in the core rather than in every driver with a buffer. * Make the length attribute read only when a driver is not able to set the length. * Drop the get_length callback for buffers as it is already available in struct iio_buffer. * Drop an unused arguement form iio_kfifo_allocate and add devm allocator for it. * some kconfig entries gain anotation with the resulting module name. * Fix a resulting compile issue in dummy driver due to a stub taking wrong parameters as a result of the above rework. * Fix an off by 2 error in copying the core assigned buffer attributes. Other cleanups, * Trivial space before comma fixups. * ak8975 fixlets - none critical. Rework to allow more device support. * Drop unnecessary sizeof(u8) calls. * bmp280 - refactor the compensation code to reduce copy operations and code length. A second patch futher optimized this and performed some other minor cleanups. * kxcjk-1013 - various power control cleanups to avoid unnecessary enable / disable of device. Make sure it is only controlled at all if CONFIG_PM is enabled. Also som cleanups of error paths. * Small cleanups in adf4530 driver - pointless message and unnecessary braces. * Clarifiy the proximity ABI docs to make it clear it should get bigger as we move futher away. * Drop a misleading comment form industrialio-core.c * Trivial white space cleanups. * sca3000 looses an unused debug function. * Fix char unsigned ordering in ad8366 * Increase the sleep time in ad9523 to make it predictable (value didn't really matter so make it more than 20 msecs) * mxs-lradc touchscreen property cleanups in device tree are fixed to ensure the meet all the 'interesting' documentation. * A couple of cleanups for the staging ad5933 driver to avoid unnecessary conversion to a processed temperature vlaue in kernel and remove platform data form the state structure as not needed after probe. * Fix a wrong scale factor in the docs. Misc * Add IIO include files to the maintainers entry.
2015-01-01iio: accel: kxcjk-1013: Add a blank line after declarationsRoberta Dobrescu1-0/+1
This patch fixes the following checkpatch.pl warning: WARNING: Missing a blank line after declarations Signed-off-by: Roberta Dobrescu <roberta.dobrescu@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12iio: accel: kxcjk-1013: power off device if probe failsIrina Tirdea1-6/+12
When the device is initialized in probe, it is also powered on. If there is an error after the initialization, the device will remain powered on. Power off the device in case probe fails after device initialization. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Suggested-by: Daniel Baluta <daniel.baluta@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12iio: accel: kxcjk-1013: error handling when set mode failsIrina Tirdea1-1/+12
If there is an error in set mode at runtime resume, reset the state of the runtime usage count. If there is an error in set mode at runtime suspend, make sure the framework retries to suspend the device. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12iio: accel: kxcjk-1013: only set power state if CONFIG_PM is definedIrina Tirdea1-0/+2
When CONFIG_PM is not defined and the driver tries to power off the device, kxcjk1013_set_power_state will call pm_runtime_put_autosuspend, which is not implemented (wil return -ENOSYS). Only call pm_runtime calls to change power state when CONFIG_PM is defined. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-12iio: accel: kxcjk-1013: always power on device in resumeIrina Tirdea1-4/+1
When the system resumes, it will first call system resume and then runtime suspend (if CONFIG_RUNTIME_PM is enabled). There is no need to conditionally power on the device in system resume, so always power it on and leave runtime suspend to power it off if needed. Suggested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-12-08Merge branch 'pm-runtime'Rafael J. Wysocki1-2/+2
* pm-runtime: (25 commits) i2c-omap / PM: Drop CONFIG_PM_RUNTIME from i2c-omap.c dmaengine / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM drivers: sh / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM e1000e / igb / PM: Eliminate CONFIG_PM_RUNTIME MMC / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM MFD / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM misc / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM media / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM input / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM iio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM hsi / OMAP / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM i2c-hid / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM drm / exynos / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM gpio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM hwrandom / exynos / PM: Use CONFIG_PM in #ifdef block / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM USB / PM: Drop CONFIG_PM_RUNTIME from the USB core PM: Merge the SET*_RUNTIME_PM_OPS() macros PM / Kconfig: Do not select PM directly from Kconfig files PCI / PM: Drop CONFIG_PM_RUNTIME from the PCI core ...
2014-12-04iio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PMRafael J. Wysocki1-2/+2
After commit b2b49ccbdd54 (PM: Kconfig: Set PM_RUNTIME if PM_SLEEP is selected) PM_RUNTIME is always set if PM is set, so #ifdef blocks depending on CONFIG_PM_RUNTIME may now be changed to depend on CONFIG_PM. Replace CONFIG_PM_RUNTIME with CONFIG_PM everywhere under drivers/iio/. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
2014-11-15iio: accel: kxcjk-1013: Fix kxcjk10013_set_rangeDaniel Baluta1-0/+2
Currently, we get the new GSEL bits by OR-ing the old values with the new ones. This only works first time when the old values are 0. Startup: * GSEL0 = 0, GSEL1 = 0 Set range to 4G: (GSEL0 = 1, GSEL1 = 0) * GSEL0 = 0 | 1 = 1 * GSEL1 = 0 | 0 = 0 * correct Change range to 2G: (GSEL0 = 0, GSEL1 = 0) * GSEL0 = 1 | 0 = 1 * GSEL1 = 0 | 0 = 0 * wrong, GSEL0 should be 0 This has the nice effect that we can use the full scale range, exported in in_accel_scale_available. Fixes: a735e3d7f03 (iio: accel: kxcjk-1013: Set adjustable range) Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-11-08iio:kxcjk-1013: Add support for SMO8500 deviceBastien Nocera1-2/+11
The Onda v975w tablet contains an accelerometer that's advertised over ACPI as SMO8500. This device is however a KXCJ9 accelerometer as can be seen in the Windows driver's INF file, and from the etching on the chipset ("KXCJ9 41566 0414"). This patch also removes the attempt to get the IRQ for the "data ready" signal, as it does not seem to be supported by this device on this platform. Signed-off-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-11-05io: accel: kxcjk-1013: Fix iio_event_spec directionDaniel Baluta1-1/+1
Because IIO_EV_DIR_* are not bitmasks but enums, IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING is not equal with IIO_EV_DIR_EITHER. This could lead to potential misformatted sysfs attributes like: * in_accel_x_thresh_(null)_en * in_accel_x_thresh_(null)_period * in_accel_x_thresh_(null)_value or even memory corruption. Fixes: b4b491c083 (iio: accel: kxcjk-1013: Support threshold) Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-09-14iio: accel: kxcjk-1013: Fix defined but unused warningDaniel Baluta1-0/+2
Noticed when compiling with CONFIG_PM_RUNTIME not set: kxcjk-1013.c: warning: ‘kxcjk1013_get_startup_times’ defined but not used [-Wunused-function] Introduced by commit 124e1b1d (iio: accel: kxcjk-1013: support runtime pm). Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-09-14iio: accel: kxcjk-1013: add support for kxtj2-1009Daniel Baluta1-21/+90
This patch adds support for KXTJ2-1009 3-axis acceleromenter sensor. KXTJ2-1009 uses the same register definitions as KXCJK-1013. The specification for KXTJ2-1009 can be downloaded from: http://www.kionix.com/sites/default/files/KXTJ2-1009%20Specifications%20Rev%204.pdf Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-31iio: accel: kxcjk-1013: add support for kxcj9-1008Daniel Baluta1-0/+2
This patch adds support for KXCJ9-1008 3-axis acceleromenter sensor. KXCJ9-1008 uses the same register definitions as KXCJK-1013. The specification for KXCJ9-1008 can be downloaded from: http://www.kionix.com/sites/default/files/KXCJ9-1008%20Specifications%20Rev%205.pdf Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-27iio: accel: kxcjk-1013: Support thresholdsSrinivas Pandruvada1-50/+447
This chip has a motion detect capability. Using IIO events to specify thresholds and pushing events. In addition a new trigger of type any-motion is added, which pushes data to buffer only when there is any movement. Change list: Comments addressed for Re: [PATCH 5/6] iio: accel: kxcjk-1013: Support thresholds Date: 07/20/2014 - Both motion detect and data ready can be enabled together - Sending RISING/FALLING events based on int status - Separate interrupt configuration for data ready and motion detect Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-26io: accel: kxcjk1013: Remove redundant assignmentDaniel Baluta1-3/+0
data->range is already set by kxcjk1013_set_range. Signed-off-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-07iio: accel: kxcjk-1013: Set adjustable rangeSrinivas Pandruvada1-5/+95
This chip can support 3 different ranges. Allowing range specification. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-08-07iio: accel: kxcjk-1013: support runtime pmSrinivas Pandruvada1-50/+156
In an effort to improve raw read performance and at the same time enter low power state at every possible chance. For raw reads, it will keep the system powered on for a default or user specified time, via autosuspend_delay attribute of device power. This will help read multiple samples without power on/off sequence. For triggers it will keep the system on till, requested to be turned off by trigger state by utilizing run time PM usage counters. When runtime pm is not enabled, then it keeps the chip in operation mode always. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-20iio:kxcjk-1013: Fix endianness in scan_typePeter Meerwald1-1/+1
driver uses i2c_smbus_read_word_data() to the data in the trigger handler and hence already does endianness conversion; the I2C chip has data in little endian, but the value is provides in CPU endianness Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-20iio: accel: kxcjk-1013: Increment ref counter for indio_dev->trigSrinivas Pandruvada1-0/+1
Assigning indio_dev->trig is not a good idea, as this can result in wrong reference count for trigger device. If assigned, it is better to increment reference counter by calling iio_trigger_get. Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-20iio: accel: kxcjk-1013: Use try_reenable to ack intrSrinivas Pandruvada1-17/+16
This chip needs explicit interrupt ack, introducing try_reenable callback. Also removed separate function to ack interrupt as this doesn't add any value. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-07-20iio: accel: kxcjk-1013: Fix setting frequencySrinivas Pandruvada1-1/+1
Fix issue with setting of 12.5 and 6.25 HZ. The match of val2 fails. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-06-16iio: accel: kxcjk1013 Fix missing unlock errorsSrinivas Pandruvada1-2/+6
Fix unlock at two places. One when i2c error occurs and other when trigger set state when raw read is in progress. kbuild test robot errors: >> >> drivers/iio/accel/kxcjk-1013.c:531:3-9: preceding lock on line 524 >> >> drivers/iio/accel/kxcjk-1013.c:376:4-10: preceding lock on line 368 Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reported-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-06-14iio: accel: kxcjk1013 3-axis accelerometer driverSrinivas Pandruvada1-0/+760
This patch adds IIO driver for KXCJK 1013 triaxis accelerometer sensor. The specifications for this driver is downloaded from: http://www.kionix.com/sites/default/files/KXCJK-1013%20Specifications%20Rev%202.pdf Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>