Commit graph

20 commits

Author SHA1 Message Date
Irina Tirdea
b1532909de iio: remove unused gpio consumer.h include
GPIO handling code has been removed from the drivers (since
this is now handled by the ACPI core) in commit 0f0796509c ("iio:
remove gpio interrupt probing from drivers that use a single interrupt").

Remove the include for linux/gpio/consumer.h since it is no longer
used.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-03 10:27:47 +01:00
Adriana Reus
7d0ead5c3f iio: Reconcile operation order between iio_register/unregister and pm functions
At probe, runtime pm should be setup before registering the sysfs interface so
that all the power attributes are accurate and functional when registering.
Also, when removing the device we should unregister first to make sure
that the interfaces that may result in wakeups are no longer available.

Fix this behaviour for the following drivers: bmc150, bmg160, kmx61,
kxcj-1013, mma9551, mma9553, rpr0521.

Signed-off-by: Adriana Reus <adriana.reus@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-11-08 15:36:53 +00:00
Octavian Purdila
0f0796509c iio: remove gpio interrupt probing from drivers that use a single interrupt
Commit 845c877009 ("i2c / ACPI: Assign IRQ for devices that have
GpioInt automatically") automatically assigns the first ACPI GPIO
interrupt in client->irq, so we can remove the probing code from
drivers that use only one interrupt.

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-10-03 12:05:51 +01:00
Octavian Purdila
c176becd81 iio: fix drivers that consider 0 as a valid IRQ in client->irq
Since patch "i2c / ACPI: Use 0 to indicate that device does not have
interrupt assigned" [1], 0 is not a valid i2c client irq anymore, so
change all driver's checks accordingly.

The same issue occurs when the device is instantiated via device tree
with no IRQ, or from the i2c sysfs interface, even before the patch
above.

[1] http://lkml.kernel.org/g/<1430908148-201129-3-git-send-email-mika.westerberg@linux.intel.com>

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-23 20:23:11 +01:00
Irina Tirdea
23f93cde93 iio: accel: mma9553: document use of mutex
Fix checkpatch.pl --strict check:
CHECK: struct mutex definition without comment
+     struct mutex mutex;

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-14 16:01:37 +01:00
Irina Tirdea
b37c19903a iio: accel: mma9553: fix alignment issues
Fix code alignment and wrap parameters.
Fix issues reported by checkpatch.pl --strict.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Suggested-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-14 16:00:54 +01:00
Irina Tirdea
c0d901cce7 iio: accel: mma9551_core: use size in words for word buffers
Change the prototype for the mma9551_read/write_*_words functions
to receive the length of the buffer in words (instead of bytes) since
we are using a word buffer. This will prevent users from sending an
odd number of bytes for a word array.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-06-14 15:59:28 +01:00
Greg Kroah-Hartman
936a0cd52a Merge 4.1-rc4 into staging-next
We want the fixes in here for testing and merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-05-18 13:52:44 -07:00
Irina Tirdea
ef8307a21a iio: accel: mma9553: fix gpio bitnum init value
Initial value of gpio bitnum is set to -1, but
the variable is declared as unsigned.

Use a positive invalid value for initial gpio
bitnum.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Suggested-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:52:35 +01:00
Irina Tirdea
334efd076d iio: accel: mma9553: refactor mma9553_read_raw
Refactor code for simplicity and clarity.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Suggested-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:52:31 +01:00
Irina Tirdea
996ba51459 iio: accel: mma9553: prefix naming fixes
Add mma9553_ prefix to all local functions/declarations.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Suggested-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:49:46 +01:00
Irina Tirdea
43c30937c3 iio: accel: mma9553: use GENMASK
Use GENMASK instead of BIT or direct value to
define a mask.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Suggested-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:49:27 +01:00
Irina Tirdea
c105ac6a03 iio: accel: mma9553: comment and error message fixes
Use "GPIO" instead of "gpio" and "ACPI" instead of "acpi".

Includes a couple of small style fixes in comments
(missing full stop, whitespace, paranthesis).

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Suggested-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:48:11 +01:00
Irina Tirdea
04aff96ad4 iio: accel: mma9553: return 0 as indication of success
Use return 0 instead of return ret to mark
clearly the success return path.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Suggested-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:47:41 +01:00
Irina Tirdea
1d052931c6 iio: accel: mma9553: check for error in reading initial activity and stepcnt
When configuring gpio, we need to read initial values for activity and
step count. This function may fail due to i2c read errors.

Check the error code returned by mma9553_read_activity_stepcnt
and return the appropriate error in gpio config function.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Reported-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:46:39 +01:00
Irina Tirdea
1d93353da5 iio: accel: mma9553: check input value for activity period
When setting the activity period, the value introduced by
the user in sysfs is not checked for validity.

Add a boundary check so that only allowed values are
reported as successfully written to device.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Reported-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:43:08 +01:00
Irina Tirdea
ae2ec9597c iio: accel: mma9553: add enable channel for activity
Add an enable channel for activity, so it can also
be polled independently of events or other channels.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Reported-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:41:59 +01:00
Irina Tirdea
cd62322a97 iio: accel: mma9553: fix endianness issue when reading status
Refactor code for simplicity and clarity.

This also fixes an endianness issue with the original code.
When reading multiple registers, the received buffer of
16-bytes words is little endian (status, step count). On
big endian machines, casting them to u32 would result in
reversed order in the buffer (step count, status) leading
to incorrect values for step count and activity.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Reported-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-26 19:39:42 +01:00
Uwe Kleine-König
b457f53a2a iio: improve usage of gpiod API
Since 39b2bbe3d7 (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-02-22 09:49:22 +00:00
Irina Tirdea
40cb761306 iio: add driver for Freescale MMA9553
Add support for Freescale MMA9553L Intelligent Pedometer Platform.

The following functionalities are supported:
 - step counter (counts the number of steps using a HW register)
 - step detector (generates an iio event at every step the user takes)
 - activity recognition (rest, walking, jogging, running)
 - speed
 - calories
 - distance

To get accurate pedometer results, the user's height, weight and gender
need to be configured.

The specifications can be downloaded from:
http://www.freescale.com/files/sensors/doc/ref_manual/MMA955xLSWRM.pdf
http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-30 20:34:59 +00:00