summaryrefslogtreecommitdiff
path: root/driver/accelgyro_bmi160.c
Commit message (Collapse)AuthorAgeFilesLines
...
* sensor: bmi160/bma2x2: Fix the timeout value of compensation.Marco Chen2018-03-261-1/+1
| | | | | | | | | | | | | | | | | | | CL:957872 introduced "get_time().val + 400" as the deadline to perform compensation and the comment in bma2x2.c mentioned the deadline should be 400ms. But the unit of val in timestamp_t is microsecond not milisecond so only 400us is defined not 400ms. BRANCH=none BUG=b:76234078 BUG=b:76202592 TEST=test manually on the dut by performing calibrate. Change-Id: I7a834ef6dcb0772569d2c8d6c507803deb5d2fc1 Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/979512 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* driver: bma2x2: Add perform_calibGwendal Grignou2018-03-161-4/+5
| | | | | | | | | | | | | | | | | | Add fast compensation automatic calibration, like bmi160. Use timestamp_expired for timeout measurement for both perform_calib functions. Remove driver offset field, remove private bma2x2 structure. BUG=b:73205042 BRANCH=master TEST=echo 1 > calibrate perform calibration. Reading in_accel_*_calibbias is within range. Check on Lami for both bma2x2 and bmi160. Change-Id: I3472865287fa4769a05e6f872b92d7c3f933cb4e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/957872 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* driver: sensor: Remove set_resolution when NOOPGwendal Grignou2018-03-151-9/+0
| | | | | | | | | | | | | | set_resolution is only used for few sensors and is not exposed to the AP. Remove definition when sensors have a fixed resolution. BUG=none BRANCH=master TEST=compile, kevin has enough space for perform_calib. Change-Id: I8482387e135356467edaee44da3a0e47cf1db524 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/961222 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* motion: Lower jitter of Sensor->EC timestampAlexandru M Stan2018-03-141-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead getting the time for each sample in the task code, we should be getting it as soon as the sensor reported it added it to its fifo (so sensor just finished integration). Because of that each sensor should provide the time when it provides a sample, ideally from an accurate spot like an interrupt. Deprecate motion_sense_fifo_add_unit (without a timestamp) in favour of motion_sense_fifo_add_data (which adds the timestamps). Update all relevant sensors to use the new api. Note: for now I focused on the BMI160, where I actually made it get the time in the interrupt. The other sensors were made to use the new api, but still don't record the time in the right place (though it's not any worse than before). BUG=b:67743747 TEST=In the kernel, fifo_info->info.timestamp still has sane values. TEST=CTS should still pass BRANCH=master Change-Id: I9829343f8702e00cc19f9c88134fa1f258c9e1e9 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/807331 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* motion: remove load_fifoGwendal Grignou2018-03-091-166/+179
| | | | | | | | | | | | | | | | | | | | | To prevent invalid timestamping, call load_fifo only when we get a FIFO interrupt. In consequence, remove load_fifo entry point and only process fifo inside the IRQ. Add helper function to know when we are in forced mode (the EC needs to periodically read sensor data or interrupt driven). BUG=b:73557414 BRANCH=master TEST=compile Change-Id: I959e476f3f7215be95424c07223f7421e8b13da1 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/938146 Commit-Ready: Alexandru M Stan <amstan@chromium.org> Tested-by: Alexandru M Stan <amstan@chromium.org> Reviewed-by: Alexandru M Stan <amstan@chromium.org>
* sensor: bmi160: Don't batch data on the sensorAlexandru M Stan2018-03-091-3/+2
| | | | | | | | | | | | | | | | | | | Set the sensor side fifo watermark to interrupt the EC as soon as there's any data in there, that way we get more frequent accelerometer interrupts (which is handy when you want to mark down the time of each sample accuratelly). BUG=b:67743747 TEST=Sensor should still be working normally, the ec will probably start recieving sensor interrupts (before this was probably not the case). BRANCH=master Change-Id: I726550e68447a74bbfed88b703d2f68b6967ac93 Signed-off-by: Alexandru M Stan <amstan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/956626 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* motion_sense: Put set_range in common codeGwendal Grignou2017-11-171-3/+1
| | | | | | | | | | | | | | | | At the end of the sensor initialization, all _init sensor routines set the range to the default value from board.c file. Put all the code in a single place, move it from sensor_common.c to motion_sense.c. BUG=none BRANCH=none TEST=compile Change-Id: If89cf27c6438e0f215c193d68a480e027110174c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/767610 Reviewed-by: Shawn N <shawnn@chromium.org>
* sensors: add bmi160 & kionix orientation driverNick Vaccaro2017-08-081-0/+49
| | | | | | | | | | | | | BRANCH=none BUG=chromium:718919 TEST=make buildall -j works, orientation works when enabled on gru and scarlet. Change-Id: I16dcfa5d9dea39c082d98190fa1bb6e496168b17 Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/540124 Tested-by: Nick Vaccaro <nvaccaro@google.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* sensor: bmi160: Fix macro used to set double tap intersticeScott Collyer2017-05-311-1/+1
| | | | | | | | | | | | | | | | | The line to convert the desired double tap window time to its register value was using the incorrect macro. Have corrected this to use the intended one. BUG=b:62202895 BRANCH=none TEST=On Eve verified that double tap events are properly detected. Change-Id: I70d810c93a8e27a3f61f3175e1ea95d0e59554ac Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/518522 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* console: Add non-verbose print config optionShawn Nematbakhsh2017-02-111-2/+2
| | | | | | | | | | | | | | | | | Shorten certain long prints and reduce the precision of timestamp prints when CONFIG_CONSOLE_VERBOSE is undef'd. BUG=chromium:688743 BRANCH=gru TEST=On kevin, cold reset the EC, boot to OS, and verify cros_ec.log contains all data since sysjump and is < 2K bytes (~1500 bytes). Change-Id: Ia9390867788d0ab3087f827b0296107b4e9d4bca Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/438932 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* driver: bmi160: Set odr to 0 at init.Gwendal Grignou2017-01-101-0/+6
| | | | | | | | | | | | | | | | | | | | | | | When we switch to a state where the sensor is not powered, we don't call set_data_rate(0), because we may trigger an i2c/spi access to a sensor already powered off. It has the side effect to leave data->odr to the last set sensor frequency. When we init the BMI160, it starts in suspend mode. We will set it to normal mode only if data->odr is 0. Therefore, we must set odr to 0 in the init routine. BUG=chrome-os-partner:61502 BRANCH=reef,kevin TEST=On reef, without this change. When going to S5 (shutdown -h 0) and power back up, sensor is stuck (on EC, accelread 1 reads old value). With this fix, sensor is active and working. This fix a regression due to CL:411964. Check others driver do not check odr for setting suspend/normal mode. Change-Id: Ibc7519d49e55a0b43b4c12ed545bd75ab0260766 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/426766 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* motion_sense: Add "spoof" modeAseda Aboagye2017-01-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a "spoof" mode feature to the motionsense stack. It allows the user to arbitrarily set the outputs of the sensor in order to "spoof" the readings of the sensor. This can be useful in emulating tablet mode or device rotations. A command is available from the EC console named `accelspoof` and there is a corresponding motionsense command in ectool called `spoof`. The usage is as follows: - EC console > accelspoof [id] [on/off] [X Y Z] - ectool # ectool motionsense spoof -- [id] [0/1] [X Y Z] If on or off(or 0/1) is not specified, the current spoof mode status of the sensor is returned. If on is specified, but no components are provided, the sensor will lock the current values and provide those as the spoofed values. If the components are provided, those will be used as the spoofed values. BUG=chromium:675263 BRANCH=cyan,glados,gru,oak TEST=Flash a DUT with accels. From AP console, run `ectool motionsense lid_angle` in a loop, use 'accelspoof' EC console command to set spoofed values. Verify that the angle is fixed regardless of the actual angle of the DUT. TEST=Flash a DUT with accels. From AP console, use `ectool motionsense spoof` to spoof values and verify that `ectool motionsense` reflects the spoofed values. Test with both provided component values and no component values. Change-Id: Ie30688d22f38054e7243b1af493a3092b2cdfb72 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/421280 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* driver: Move sensor private struture definition to boards.Gwendal Grignou2016-12-281-4/+0
| | | | | | | | | | | | | | | | sensor private structure for bmi160 and bmp280 were defined in the drivers themselves. It worked because there was only one instance of each sensors on a board. However, this is an error it should be in board files, as it was done for other sensors like the kionix. BUG=none TEST=buildall. BRANCH=kevin,reef Change-Id: Ica3aba358d141a7df9a3e97251d4c1e520cbf2c8 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/424218 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* driver: bmi160: Add temperature sensorGwendal Grignou2016-12-121-0/+16
| | | | | | | | | | | | | | | | | | | | Allow BMI160 to report temperature like other device with a temperature sensor. Temparature is returned in K. Although BMI160 resolution is 9bits per degree, we round to the nearest degree. BUG=chrome-os-partner:58894 BRANCH=reef TEST=After enabling sensor on Reef, check we can measure the temperature with EC console commands temp or from user space with 'ectool temps 3' Check 'ectool tempsinfo 3' returns valid data: Sensor name: Gyro Sensor type: 1 Change-Id: Ib48f988e078cdee1dfbc05b23df806bd4eb09931 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/416297 Reviewed-by: Scott Collyer <scollyer@chromium.org>
* driver: bmi160: Remove unnecessary delayGwendal Grignou2016-11-211-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | Rereading the specification, remove delays when not needed: - When we move the sensor out of suspend, we need to wait before using it (BMI160 spec: 2.11.38 Register (0x7E) CMD) When we do a softreset, we need just need to wait 300us for the sensor to go in suspend, we will wait only when we change the rate and enable the sensor. - The timeout at fifo flush is not needed, it was added for debugging. - Remove unnecessary printf when initializing the magnetometer. BUG=chrome-os-partner:59188 BRANCH=glados, reef, strago TEST=On reef, check the EC boot faster: time spend initializing the sensors decreased from 240ms to 133ms Change-Id: Ia80232da42aa705df819a4988da483a344ffcbb4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/411964 Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
* Fix various misspellings in commentsMartin Roth2016-11-151-1/+1
| | | | | | | | | | | | | No functional changes. BUG=none BRANCH=none TEST=make buildall passes Change-Id: Ie852feb8e3951975d99dce5a49c17f5f0e8bc791 Signed-off-by: Martin Roth <martinroth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/403417 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
* driver: sensor: Remove set_interruptGwendal Grignou2016-11-081-8/+0
| | | | | | | | | | | | | | Remove set_interrupt(), was always a noop. Unused, interrupt is done inside the init routine. BUG=none BRANCH=none TEST=buildall Change-Id: I0ff4843212ea8140be41dcd17af130991117e3da Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/407968 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: bmi160: Autocalibrate Accelerometer properly.Gwendal Grignou2016-11-021-1/+6
| | | | | | | | | | | | | | | Take into account the rotation matrix to do calibration. In particular the Z axis: if board is upside down, we need to use MINUS_1G instead of PLUS_1G when setting online calibration. BRANCH=kevin BUG=none TEST=Before, calibration would not work on the Z axis. Change-Id: Ifaec331aac40a4be0e34fcab5dd3752d2d59b91f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/405854 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: bmi160: Fix logic issue when accelerometer is not first sensorGwendal Grignou2016-10-071-4/+2
| | | | | | | | | | | | | | BMI160 driver assumes accel, gyro, compass are next to each other. It was also assuming accel was sensor 0, which is wrong. BUG=none BRANCH=glados TEST=On Cave, check sensors 1 (accel) and 2 (gyro) are working properly. Change-Id: I37402e1d48070caaecbd7e32bbf53754616ee8cb Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/394067 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* driver: bmi160: Add config variable for INT2 settingGwendal Grignou2016-10-071-8/+10
| | | | | | | | | | | | | | BMI INT2 can be input or output. It is not used currently, but configure it properly nevertheless. BUG=none BRANCH=none TEST=On cave, (int2 is output), ensure FIFO headers are free of interrupt information. Change-Id: I9c058689a8676593aad542e33601cc11da105838 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/394066
* i2c: Add i2ctest console commandVijay Hiremath2016-09-231-2/+14
| | | | | | | | | | | | | | | | | | Added i2ctest console command to test the reliability of the I2C. By reading/writing to the known registers this tests provides the number of successful read and writes. BUG=chrome-os-partner:57487 TEST=Enabled the i2ctest config on Reef and tested the i2c read/writes. BRANCH=none Change-Id: I9e27ff96f2b85422933bc590d112a083990e2dfb Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/290427 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
* driver: bmi160: Add support bmi168Wonjoon Lee2016-05-101-1/+1
| | | | | | | | | | | | BMI168 is twins sensor with BMI160. Adding chip ID. BUG=chrome-os-partner:52844 TEST="accelread 0" is working on kevin Change-Id: Iadb5aeb9bc7be7fb2c6bc23e48ea2510b4bf84df Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com> Reviewed-on: https://chromium-review.googlesource.com/341578 Reviewed-by: Shawn N <shawnn@chromium.org>
* driver/accelgyro_bmi160.c: fix the error handle in read()james_chao2016-05-061-1/+1
| | | | | | | | | | | | | | | | | The function raw_read_n() return the status, and then check it it should be saved to the variable ret. BUG=none BRANCH=tot TEST=make buildall -j Signed-off-by: james_chao <james_chao@asus.com> Change-Id: I4d2bd200fc49892ae95c63aaeca3af75f7338bec Reviewed-on: https://chromium-review.googlesource.com/342809 Commit-Ready: BoChao Jhan <james_chao@asus.com> Tested-by: BoChao Jhan <james_chao@asus.com> Reviewed-by: BoChao Jhan <james_chao@asus.com> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
* sensor: update sensor driver to use I2C port from motion_sensor_tKevin K Wong2016-03-311-93/+104
| | | | | | | | | | | | | this allow motion sensor devices to be locate on different I2C port BUG=none BRANCH=none TEST=make buildall Change-Id: Ia7ba2f5729ebb19561768ec87fdb267e79aafb6a Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/334269 Reviewed-by: Shawn N <shawnn@chromium.org>
* common: spi: Add a delay after write commands.Gwendal Grignou2015-11-191-0/+6
| | | | | | | | | | | | | | | Some SPI slave devices need a delay to digest write commands. (BMI160). Add a 1ms delay in the write command. BRANCH=smaug BUG=none TEST=Check on the logic analyzer that there is ~1.5ms delay between back to back spixfer w ... commands. Change-Id: I7cc6ed0da9ae39550e58457b9431eb01b5ab36d8 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/305379 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* motion: Remove duplicate shutdown codeGwendal Grignou2015-10-281-4/+0
| | | | | | | | | | | | | | | | | Call shutdown() entry point at init() and remove duplicate code. shutdown would init the sensor so they would be ready if needed. Set S5 flag to include G3 (hard off) state, not only S5 (soft off). BUG=chrome-os-partner:45722 BRANCH=smaug TEST=When doing a RO->RW transition while AP is in G3, check the sensors are initialized properly. This issue was found while testng the magic sequence code. Change-Id: I647f83580240bf5ba0c340fca3184220abe4c12e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/308561 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* driver: bmi160: Add magic sequence to unlockGwendal Grignou2015-10-271-1/+12
| | | | | | | | | | | | | | | | | | | | | | If init() is interrupted while we are setting the link to the compass, the BMI160 may be in paging mode and will only answer to registers 7Eh and 7Fh. Other registers access will return 00h. To get out of this state, run the sequence to move back from the paging mode in the error handler. If successful, a subsequent call to init() will work. BRANCH=smaug BUG=chrome-os-partner:45722 TEST=use a special firmware that exists in the middle of the compass init sequence. Check that the FIFO and all other registers return 0. Issue 'accelinit 1' (to reset the Gyro): the command succeeds and the accelerometer is operational again (double tap works). Check the sequence can be issued after sysjump to RW/RO. Change-Id: I3455a8cbdcf1c88699ae90f7c09e4438e1268d47 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/308184 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* motion: fix manage_activity interfaceGwendal Grignou2015-10-161-1/+1
| | | | | | | | | | | | | | Declare optional parameters are const structure. These parameters, when used, are just read by the sensor driver. BRANCH=smaug BUG=None TEST=compile Change-Id: I8f2a9291e1908922831fb5e2a524bb6edd0e0f65 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/306696 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* motion: fix spellingGwendal Grignou2015-10-151-4/+4
| | | | | | | | | | | | | | | | | | Fix various spelling errors. Command used: spell include/motion_sense.h | sort | uniq -c | \ grep -v -f ~/tmp/known_words | sort -n > /tmp/checking_spell Appended /tmp/checking_spell to ~/tmp/known_words to avoid C code. BRANCH=smaug TEST=compile BUG=none Change-Id: I39acfeaefef51d142a587940bccb02db86e87068 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/305570 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* common: Add magnetometer online calibration.Gwendal Grignou2015-10-131-0/+23
| | | | | | | | | | | | | | | | Code for hard iron calibration: Every seconds (or faster if enough samples), find a sphere that fit the compass data. Based on Android code. BRANCH=smaug BUG=chrome-os-partner:39900 TEST=Check hard-iron bias is removed. Works better outside. Change-Id: Iab479d5113b6560b4f01b0fd87373d2eecdb9b54 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/299583 Reviewed-by: Anton Staaf <robotboy@chromium.org>
* board: ryu: Match Samus double tap behavior.Gwendal Grignou2015-09-291-0/+2
| | | | | | | | | | | | | | | | | | Increase the change of false positive, but make double feels like Samus: - increase time beetwen tap to 500ms - decrease tap threshold to 100mg (actually 62.5mg) - increase ODR during TAP. BRANCH=smaug BUG=b:24440423 TEST=check Ryu and Samus side by side, their tap behavior is more similar. run cts -c android.hardware.cts.SingleSensorTests Change-Id: I260ad95136cb2be71ef4d71efc4bee0b28afa8e0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/302627 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* driver: bmi160: Reenable FIFO when EC wants it.Gwendal Grignou2015-09-241-2/+5
| | | | | | | | | | | | | | | | Code has been added to not send data to AP ring when the AP does not want data, but we should still enable the BMI160 FIFO if the EC wants the data. BRANCH=smaug BUG=chromium:513458 TEST=Disable sensor at AP (sysfs frequency) enable in EC (accelrate). Check with accelinfo we are collecting sensor info. Change-Id: I962fecad0e8cea899e4d788d25982e8bc7e7fb88 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/301795 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* driver: bmi160: Fix for significant motion while in suspend.Gwendal Grignou2015-09-211-8/+10
| | | | | | | | | | | | | | | | | | | | - Add interrupt latching: notice that interrupt register was cleared before entering the task irq handler. Add a 5ms latching time address the issue. Check it was not a problem for regular operation. - Fix FIFO interrupt setting: interrupt when FIFO was full was missing from one register - Really disable FIFO when AP does not want data from sensors. BRANCH=smaug BUG=b:23570481 TEST=check that significant motion and double tap are reliable in S3. Change-Id: Iec3681da00462b1aa392056eecea4ee6862d42ee Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/298689 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* driver: bmi160: Allow double tap to be set by the host.Gwendal Grignou2015-09-211-6/+28
| | | | | | | | | | | | | | In S0, allow the host to enable/disable double tap. Set S0 accel frequency to 100Hz to track double tap event. BRANCH=smaug BUG=chrome-os-partner:44754 TEST=check CTS results are identical to previous runs. Check we can enable/disable double tap from the host. Change-Id: Ic36bdd77005a1152fd413fb3869c8a77ef680117 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/298685
* common: motion: Fix accelgyro interfaceGwendal Grignou2015-09-211-4/+4
| | | | | | | | | | | | Use const struct motion_sensor when needed. BRANCH=smaug BUG=chrome-os-partner:44754 TEST=compile Change-Id: Ib1e92b91439e6af83aa7b6b49ac9e6271d4ed3d9 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/298684
* driver: bmi160: Add Significant motion support.Gwendal Grignou2015-09-211-0/+94
| | | | | | | | | | | | Add support for significant motion. BRANCH=smaug BUG=b:23570481 TEST=On Ryu, check significant motion (not still) is detected. Change-Id: I5760a1ba3624490a0297de82371b1d15f05df5dc Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/296214
* common: accel: Add error code for irq handlerGwendal Grignou2015-09-191-1/+1
| | | | | | | | | | | | | | | | | | When IRQ handler is not processing any event raised, return NOT_HANDLED. Without this change, any event would set the light sensor process timestamp and, if the light sensor frequency was lower than BM160 fifo interrupt frequency, we would never read from the light sensor. BRANCH=smaug BUG=chrome-os-partner:43800 TEST=Compile. Check that light sensor data get updated. Change-Id: I302f80c5cd9b4f3c926362fdafdc8b5074cabb60 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/298686
* GLaDOS: Add base accel & gyro.Aseda Aboagye2015-09-191-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds the base accelerometer as well as the gyroscope to the list of motion sensors on the board. They are currently wrapped behind an ifdef for HAS_TASK_MOTIONSENSE due to space constraints. BUG=chrome-os-partner:43494 BRANCH=None TEST=Build GLaDOS EC with driver enabled and verify that we can calcuate a valid lid angle. TEST=Verify that signs of accelerometer conform to those shown in the Chrome/Android/HTML5 doc/spec. See description in accelerometer_types.h TEST=Verify that signs of gyroscope conform to those shown in the "Sysfs interface to EC accelerometers" document. TEST=make buildall tests CQ-DEPEND=CL:299504 CQ-DEPEND=CL:300510 Change-Id: I34026813431f0df6211f9c781ab5b8c7b4dd8403 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/299886 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* motion: Add Gesture InterfaceGwendal Grignou2015-09-181-0/+1
| | | | | | | | | | | | | | | Add an interface with the host to set up gesture recognition. Today, only significant motion is supported. Add a virtual sensor for concentrating gesture support from host. BRANCH=smaug BUG=b:23570481 TEST=On ryu, enable significant motion from host. Change-Id: I906fa2d2d7b4ca2771ea2f58b91de8d97bf4e2e3 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/296213
* driver: bmi160: add code for setting double tapGwendal Grignou2015-09-181-16/+18
| | | | | | | | | | | | | | Macro and code to set double tap parameters. Enable double tap in Ryu. BRANCH=smaug TEST=double works: interrupt detected. BUG=b:23570481 Change-Id: I11a84186f6dc49b75d0f09afb4b03dcbeea6066f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295949 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* common: motion: move gesture actions in motion task.Gwendal Grignou2015-09-181-2/+2
| | | | | | | | | | | | | | Change the IRQ interface to allow adding events. Move code to send the lightbar sequence from gesture.c to motion task. TEST=compile, works on Ryu. BRANCH=smaug BUG=chrome-os-partner:44754 Change-Id: I981ea123ebef0e8e3d6aa320eade89f10e83b6fc Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/296822 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* driver: bmi160: Prevent crash when FIFO is not validGwendal Grignou2015-09-071-12/+34
| | | | | | | | | | | | | | | | | | | | | | | | | When all BMI160 sensors are suspended, FIFO is invalid. Put the test to check if all sensors are disable within the processing loop: otherwise, the FIFO can become invalid while we are processing it. Add printf to be sure we are not processing invalid FIFO. Add a macro around ODR to really check the ODR rate, excluding the roundup flag. BRANCH=smaug BUG=chrome-os-partner:44381 TEST=Using a special patch (see 44381#14) add delay to simulate a loaded EC (like at resume). Using a script flip-flop sensors frequency (to simulate suspend/resume). Check that: - we are not crashing anymore (we were before this patch) - the driver is not hitting invalid FIFO content. Change-Id: I7c9e86f5dcfc231ab89472a6ea03af22e2c2ac32 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/297178 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* motion_sense: Add more complex EC/AP sensor rate support.Gwendal Grignou2015-08-291-10/+10
| | | | | | | | | | | | | | | | | | | | | Add config settings for ODR and EC rate per requestor and per power state (1 for the AP, 3 for the EC). This way we can finely set ec rate and ODR depending on usage. On chromeos, AP is not setting frequency, so EC sets for different power state. On some platform, sensors can now be suspended in S3/S5. Allow EC oversampling when AP is only looking for a few samples. It is useful for double tap detection where high accelerator ODR is required. BRANCH=ryu TEST=Tested on Ryu BUG=chromium:513458 Change-Id: Ic3888a749699f07b10c5da3bc07204afd4de70da Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295637
* driver: change get_ interface.Gwendal Grignou2015-08-291-15/+8
| | | | | | | | | | | | | | | Simplify sensor get_data_rate, get_range and get_resolution. Error code was not checked and these functions as currently implemented have no reason to fail. BRANCH=ryu,samus,cyan,strago BUG=chromium:513458 TEST=Check on ryu, compile Change-Id: I40dca41cee29a19f65b2f84d434b4c19eb6cbf3c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/295635 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* driver: bmi160: use rotation matrix to handle offsets.Gwendal Grignou2015-08-241-9/+19
| | | | | | | | | | | | | | | | Store offsets using sensors axis, not the device axis. Therefore apply rot_standard_ref to the offset vector before get and rot_standard_ref^-1 before set. BRANCH=smaug TEST=using mag sensor, check the offset are applied to the right axis and store correctly. BUG=chromium:517675 Change-Id: I95c8ef2a62603890184412674e7bde91ebecd288 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/294596 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* motion_sense: Force flush when sensor disabled.Gwendal Grignou2015-08-241-1/+9
| | | | | | | | | | | | | | | | | | | When sensor is disabled, HAL will not send flush request to EC. However, when sensor is reenabled, only new events are expected. When we have a change in frequency, we have to request the host to query all the current events. Flush the FIFO when events are not needed because all sensors are disabled. BRANCH=smaug TEST=Pass more tests: tests like ..._fastest_batching after _50hz_flush have more change to pass. BUG=chrome-os-partner:39900 Change-Id: I1a8fc3784e3e6be260b23103b28e336e242f14cd Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291991 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* bmm150: add measurement repetitionGwendal Grignou2015-08-241-3/+4
| | | | | | | | | | | | | | | | To reduce noise the magnetometer measures in burst and average the data. Use "regular" presets: max frequency is limited to 100Hz. Using a more precise presets limit frequency to no more than 50Hz. BRANCH=smaug TEST=Check magnetomter still works. BUG=chrome-os-partner:39900 Change-Id: Ida6af86f6c207cc91e11378c129032f6d9e6b9ea Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291990 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* motion_sense: Allow multiple IRQ based sensorsGwendal Grignou2015-08-221-4/+6
| | | | | | | | | | | | | | | Add a mask of custom events reserved for IRQ based sensors. Copy data from raw_xzy to xyz while filling the FIFO when FIFO is enabled. BRANCH=smaug TEST=Test with si1141 driver, check irq works for both driver. BUG=chrome-os-partner:32829 Change-Id: I5e106df0c121e3bf1385f635195717395235ccc3 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291334 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* bmm150: Add support for calibrationGwendal Grignou2015-08-221-0/+5
| | | | | | | | | | | | | Allow sending calibration information to the magnetometer. BRANCH=smaug TEST=Check from user space that calibration is taken into account. BUG=chrome-os-partner:39900 Change-Id: Ic0f595bde1afdc0b6a79e3516a42b55d1f50c17c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291333 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* driver: bmi160: Allow Dynamic selection of SPI or I2C transportGwendal Grignou2015-08-011-76/+64
| | | | | | | | | | | | | | | Using the LSB bit of motion_sensor addr field, we can select at run time if a sensor is using SPI or I2C. When the hardware stabilize, this CL can be removed. BRANCH=smaug TEST=Check that same image works on both i2c and SPI devices. BUG=chrome-os-partner:42304 Change-Id: I9aef9a4dc739366a3d4e2f6fafe063ecfb5199c6 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/289925 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>