summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Clear OWNERS for factory/firmware branchfirmware-cyan-7287.57.BBrian Norris2021-09-102-10/+1
| | | | | | | | | | | | BUG=none TEST=none Change-Id: I0f03f432ada1064ffba9595be78ca7ab4d25ecd1 Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3155154 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Owners-Override: Jora Jacobi <jora@google.com> Tested-by: Jack Rosenthal <jrosenth@chromium.org>
* cyan: lower the maximum allowed ODR to 100HzGwendal Grignou2019-08-131-0/+3
| | | | | | | | | | | | | | | | | | | | Some tests are failing on Cyan at the highest ODR. This is likely due to Cyan not having a dedicated GPIO path for MKBP events, instead relying on the ACPI path which is known to have lower latency guarantees than we expect. Lowering the ODR allows the tests to pass more reliably. BUG=b:129992692 BRANCH=cyan TEST=Compile, loaded on Cyan, pass on R78: CTS_P.9.0_r8.x86.CtsSensorTestCases and CTS_P.9.0_r8.arm.CtsSensorTestCases Change-Id: I3200fac14776ce08a9c45f1a9c68a1523acd0d9c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1747287 Reviewed-by: Alexandru M Stan <amstan@chromium.org>
* poppy: Lower sensor max ODRGwendal Grignou2019-08-131-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | EC seems to miss sample while providing sensor data at 200Hz. Limit sensors ODR to 100Hz. BUG=b:67112751, b:129992692 BRANCH=none TEST=compile, tbd Reviewed-on: https://chromium-review.googlesource.com/753434 Commit-Ready: Li1 Feng <li1.feng@intel.com> Tested-by: Li1 Feng <li1.feng@intel.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit c5c061f9b5707205bb32abdac15dc14a9af14800) Conflicts: board/poppy/board.h: board not present in cyan branch. include/config.h: Only apply sensor related changes. Change-Id: Ic324c3d989854ae8b7f6b27bf6338266ce01ceda Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1747286 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* use _DEFAULT_SOURCE for newer glibcMike Frysinger2019-08-132-2/+4
| | | | | | | | | | | | | | | | | | | Newer versions of glibc have moved to _DEFAULT_SOURCE and away from _BSD_SOURCE. Trying to use the BSD define by itself leads to warnings which causes build failures. BRANCH=none BUG=None TEST=precq still works Reviewed-on: https://chromium-review.googlesource.com/316730 Reviewed-by: Bill Richardson <wfrichar@chromium.org> (cherry picked from commit 85cac7ec14fd2d29a64047297db79b36571731c8) Change-Id: Ice24b84dc6a540695fc7b76e8f22a4c85c301976 Signed-off-by: Mike Frysinger <vapier@chromium.org> Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1747065
* cyan: sensors: add extra sensor attributesEnrico Granata2019-03-298-5/+91
| | | | | | | | | | | | | This is a direct port of CL:482703 to the cyan firmware branch. BRANCH=cyan BUG=b:129101597 TEST=build Signed-off-by: Enrico Granata <egranata@chromium.org> Change-Id: I51cb7e5ea57e2b79f6d92671286dd44ad0d3760b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1537827 Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* config_option_check.py: Add owner to TODO.Aseda Aboagye2018-10-161-1/+1
| | | | | | | | | | | | | BUG=None BRANCH=firmware-strago-7287.B, firmware-cyan-7287.B TEST=None Change-Id: Id00b23942f3239833e6ee2e7478beb0dfe5e053f Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/1277608 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* Cyan: Add new battery configurationDannyChou2018-06-181-2/+24
| | | | | | | | | | | | | | | Add Cyan new battery : AC15A8J BUG=b:69997769 BRANCH=cyan TEST=recognize new battery AP15A8J OK. Change-Id: Id90d2fd4a5691f18e728ef44a43c775198e2b040 Signed-off-by: David Huang <David.Huang@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/1051850 Reviewed-by: Vincent Wang <vwang@chromium.org> Reviewed-by: Jerry Parson <jwp@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* Cyan: Change charge voltage for batterydavid.huang2018-02-101-1/+4
| | | | | | | | | | | | | | | | | | | Change battery charge voltage based on Cycle Count or State of Health for different battery. BRANCH=cyan BUG=b:68012423, b:37484779, chromium:774428 TEST=Use console command "charger" to check charge voltage with different battery. Signed-off-by: David Huang <David.Huang@quantatw.com> Change-Id: Ib8ee577bd795b784b8c69ab1d48b3eef4ef95fd9 Reviewed-on: https://chromium-review.googlesource.com/859136 Commit-Queue: David Huang <David.Huang@quantatw.com> Tested-by: David Huang <David.Huang@quantatw.com> Reviewed-by: Vincent Wang <vwang@chromium.org> Reviewed-by: YH Lin <yueherngl@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
* strago: fix builder errorsYH Lin2017-04-2211-0/+1396
| | | | | | | | | | | | | | | | | The builders for firmware-cyan-7287.57.B branch (pre-flight and strago) have failed due to the removal of board/strago directory (CL:359322). Therefore restoring this directory and adding gyro_l3gd20h files from firmware-strago-7287.B:5399a6245d2dc21c2234f0d908032ab7fa6ac6e7 to get the builders working again. BRANCH=firmware-cyan-7287.57.B BUG=None TEST=./cbuildbot --local strago-pre-flight-branch TEST=./cbuildbot --local strago-firmware Change-Id: I495a10e4150775fbb2942a73a1eabb19d47ae968 Signed-off-by: YH Lin <yueherngl@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/484744
* Cyan: Change charge voltage for batteryDavid.Huang2017-04-194-2/+430
| | | | | | | | | | | | | | | Change battery charge voltage based on Cycle Count or State of Health for different battery. BRANCH=cyan BUG=b:37484779 TEST=Use console command "charger" to check charge voltage with different battery. Change-Id: I21d3c09148c251baaa5455862fcdc179a7fbf264 Signed-off-by: David Huang <David.Huang@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/479177 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
* motion_sense: Add "spoof" modeAseda Aboagye2017-01-216-17/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/426373 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
* cyan: Enable lid angle calculation in S3.Gwendal Grignou2016-12-161-6/+6
| | | | | | | | | | | | | | In S3, lid angle was not calculated, so keyboard and touchpad can wake up the system, even in tent/tablet mode. BUG=chrome-os-partner:620633 BRANCH=cyan TEST=With this fix, check the keyboard is not waking up Cyan. Change-Id: Ief7cbb68552d50b1ad169e53d8df74041fb12498 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/420874 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* kionix: Add reading whoami to be sure device has booted.Gwendal Grignou2016-11-172-1/+28
| | | | | | | | | | | | | | | | | | From the specs, "KX022-1020 Specifications Rev4.0", the power up time can be as long as 10ms. Add a loop to be sure the device is responsive before initalizing it. BRANCH=reef,glados,oak,veyron,cyan BUG=chrome-os-partner:620633 TEST=After putting a KX022 accel as first in the list, it would not initialize properly. After adding the loop, it initializes properly. Reviewed-on: https://chromium-review.googlesource.com/394750 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 09f90a3b8f0f48d11b3653ad2af1d61c29691a48) Change-Id: I3194a5d1deb0c2eb2a04a459aab3b4269e479af3 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/412361
* power_button_x86: avoid chipset force shutdown from off stateKevin K Wong2016-11-031-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to avoid system from shutting down asynchronously if the power button is pressed and held for more than 4 seconds since x86 chipset will force itself to shutdown based on its own hardware timer on 4 seconds timeout. The current code has already accounted for the case when Refresh + Power Button is pressed and held to not shutdown by not continue to pass through the power button signal after the 200ms pulse is sent. This change is follownig the same behavior. The lid open execution path from off state is also similar. BUG=chrome-os-partner:58513 BRANCH=firmware-terra-7287.154.B TEST=System does not shut itself off if the power button is pressed and held from S5. The power button is behaving as expected in S0 or S3. Change-Id: I52536749ad6f4d1a3fcf6ba4c5b3bb6f953da6a5 Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/404711 Reviewed-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: BoChao Jhan <james_chao@asus.com> Commit-Queue: BoChao Jhan <james_chao@asus.com> Tested-by: BoChao Jhan <james_chao@asus.com> (cherry picked from commit bce3965c51a928bc5264c341618285be649a7ddf) Reviewed-on: https://chromium-review.googlesource.com/406148 Commit-Queue: 志偉 黃 <David.Huang@quantatw.com> Tested-by: 志偉 黃 <David.Huang@quantatw.com>
* driver: kionix: Add set_valueGwendal Grignou2016-09-011-74/+45
| | | | | | | | | | | | | | Put the common code for set_[data_rate|range|resolution] in the same function BUG=b:27849483 TEST=tested on Cyan, save 128 bytes on minnie. BRANCH=veyron,cyan Change-Id: Ie66f64a478ad73c2a46129a664f2a6c60c5157bc Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/379099 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: kionix: No need to set static field to NULLGwendal Grignou2016-09-011-1/+0
| | | | | | | | | | | | | Redundant, already set by the compiler. BRANCH=none BUG=none TEST=compile. Change-Id: I4d1c7263034c0cef1a6484a516edb3893c11945f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/379098 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* motion: Remove redundant set_range.Gwendal Grignou2016-09-011-6/+0
| | | | | | | | | | | | | | No need to do set_range in motion_sense_shutdown(), already done at init. Besides, this is an error if the sensor is not powered in S5. BUG=b:27849483 BRANCH=cyan, minnie, samus TEST=Check sensor range is set correctly. Change-Id: Id0b9c2e4988ffc8b55b21258f60b1efa26156dbb Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/379097 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: kionix: Remove variant field.Gwendal Grignou2016-08-313-45/+39
| | | | | | | | | | | | | Field is not required: sensor->chip already has that information. BRANCH=veyron BUG=none TEST=compile Change-Id: I6c0bc2e71d7c848968caa78c749dd3fb916f6263 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/379096 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* cyan: Enable Force mode for accelerometerGwendal Grignou2016-08-182-9/+25
| | | | | | | | | | | | | | | | Given we do not enble FIFO on these, we must ask the EC to collect samples as soon as they are available. Reduce sampling rate when measuring lid angle, EC will collect when needed. BRANCH=cyan BUG=b:27849483 TEST=Pass CTS, check lid angle with ectool motionsense lid_angle Change-Id: Icb703f8e5a63c27b704d907804838edd287e0226 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/372404 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* system: Add hibernate board-level callbackShawn Nematbakhsh2016-08-129-0/+35
| | | | | | | | | | | | | | | | | | | | | Allow boards to take action (such as entering a custom low-power hibernate-like state) before putting the chip into hibernate state. BUG=chrome-os-partner:56070 BRANCH=firmware-strago-7287.B TEST=Manual with subsequent commit on chell. Verify board-level hibernate callback is called when "hibernate" is run on EC console. Ported from the master branch to strago branch. Change-Id: Ie1da044037a74ff8bce5c822f28ce837c62ceec0 Reviewed-on: https://chromium-review.googlesource.com/324086 Change-Id: I1665e56bf471f04180467513f5a7bdc4976bcc55 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/367884 Reviewed-by: Shawn N <shawnn@chromium.org> (cherry picked from commit 7d5f758795ba0b9178335c2f08f4b2e51e1bf880) Reviewed-on: https://chromium-review.googlesource.com/368342
* cyan: Add support for new motion sensor stackGwendal Grignou2016-08-012-9/+63
| | | | | | | | | BRANCH=cyan BUG=b:27849483 Change-Id: I43e2e6c1dc7d0b15a6f69095328d090d354e9132 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359413
* UPSTREAM: motion: Fix comparison between signed and unsigned integerKoro Chen2016-08-011-0/+3
| | | | | | | | | | | | | | | | | | | | If wait_us < 0, comparison against motion_min_interval actually fails, and this negative wait_us causes task_wait_event() never returns if we are not using any motion task event except the timer. The motion task will then stop running and sensor data stay unchanged. BRANCH=none BUG=chrome-os-partner:54092 TEST=hardcode wait_us to a negative value before motion_min_interval check, and see motion task is still running by EC console cmd timerinfo Change-Id: Ic1e7ffeeb9d2ec1f5c5beb4387294014298123af Signed-off-by: Koro Chen <koro.chen@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/358332 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/364930 Tested-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
* UPSTREAM: Add CONFIG_HOSTCMD_DEBUG_MODE to set default hcdebug modeNicolas Boichat2016-08-012-1/+4
| | | | | | | | | | | | | | | | | | elm EC console output is very spammy, as EC_CMD_MOTION_SENSE_CMD is called every 100ms, so we want to set "hcdebug" to "off" as the default (which still includes errors, but no "normal" commands). BRANCH=cyan BUG=chrome-os-partner:55001 TEST=make buildall -j TEST=Flash cyan EC, see that output is fairly quiet. Change-Id: I70d91c291d934b4f032e5c57f3c333e2c10b93bc Reviewed-on: https://chromium-review.googlesource.com/359412 Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
* BACKPORT: host: mock i2c_xferGwendal Grignou2016-08-018-225/+77
| | | | | | | | | | | | | | | | | | Instead of mocking i2c_read8/16/32, mock i2c_xfer. We can now test code that call i2c_xfer directly and test common/i2c.c BRANCH=samus, ryu, cyan BUG=chrome-os-partner:45223 TEST=Unit tests pass. Change-Id: Iaa772515c40cf55d2050d0019e2062d63278adc0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/299768 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit c2c02249a01ec56857a51e1645060325f7558b59) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359411
* UPSTREAM: motion: Add ability to stop ring interrupts.Gwendal Grignou2016-08-013-17/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, it is assumed the host will sooner or later retrieve the events from the sensor ring: It is only used by Android and the sensor HAL is enabling the ring buffer at boot. But if nobody processes the ring, and the ring is almost full, the EC will generate interrupt for every new events. This can happen with ARC, where events generated for ChromeOS will be in the ring but nobody will process them until Android is started. Add a command to allow sending ring MKBP events. It will be used when the IIO ring buffer is enabled / disabled. It also can be used for preventing raising interrupt when the device is about to go to sleep. BRANCH=ryu, cyan BUG=b:25425420,b:2784948, b:27849483 TEST=Check with fiforead that no events are queued when IIO ring buffer is disabled. Check with ectool and androsensor that interrupt generation stops. Change-Id: Ibc85eed2e0eae3a9ec07d191e692118bc2fd0dab Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/356689 (cherry picked from commit f6b26dee24f4a4006e1a5509031972f8c0b5e9fc) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359410
* UPSTREAM: ectool: provide lid angle infoKevin K Wong2016-08-014-4/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added new host command to support returning lid angle. New output from ectool: System with lid angle support: ------------------------------------------ localhost ~ # ectool motionsense lid_angle Lid angle: 72 System without lid angle support: ------------------------------------------ localhost ~ # ectool motionsense lid_angle EC result 3 (INVALID_PARAM) BUG=b:27849483 BRANCH=cyan TEST=run "ectool motionsense lid_angle" verify the value matches the physical lid angle position Change-Id: I4179172c778f643640561e819216f7adfee679d2 Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/313345 Reviewed-by: Shawn N <shawnn@chromium.org> (cherry picked from commit e24ac972e21d60a65d15e957605e8b78bd25e039) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359409
* BACKPORT: mkpb: Add MKBP support over ACPIGwendal Grignou2016-08-014-5/+20
| | | | | | | | | | | | | | | | | | | | | | | Add a host event to support MKPB: When sent, the ACPI code will send a notification to the kernel cros-ec-lpcs driver that will issue EC_CMD_GET_NEXT_EVENT. We can allow code (sensor stack for instance) that uses MKBP to work on ACPI based architecture. Obviously, host event over MKPB is not supported. BRANCH=cyan BUG=b:27849483 TEST=Check we get sensor events on Cyan through the sensor ring. (cyan branch) Change-Id: Iadc9c852b410cf69ef15bcbbb1b086c36687c687 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/353634 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 00aef53a7b4c1a302b8f1448f2c634712c7b77eb) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359408
* UPSTREAM: kionix: Initialize rv in all casesStefan Reinauer2016-08-011-3/+3
| | | | | | | | | | | | | | | | Signed-off-by: Stefan Reinauer <reinauer@chromium.org> BRANCH=cyan BUG=b:27849483 TEST=compile tested for Samus Change-Id: Ib7a0a75a2d63cf8f55d0b59f4a3225da2cb4e70b Reviewed-on: https://chromium-review.googlesource.com/343282 Commit-Ready: Stefan Reinauer <reinauer@chromium.org> Tested-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-by: Patrick Georgi <pgeorgi@chromium.org> (cherry picked from commit 65bca9b9fdd797c1a659718f08b4eaa3d7de41ce) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359407
* BACKPORT: elm: kionix: allow dynamic selection of SPI or I2C transportKoro Chen2016-08-012-6/+66
| | | | | | | | | | | | | | | | | This CL ports c9832e04f1528 to Kionix accel driver. And also enables SPI access of Elm's base kx022. BUG=b:27849483 BRANCH=cyan TEST=manual Change-Id: I0c1de028c82fc62a124bb5b930a3882c4b368d71 Signed-off-by: Koro Chen <koro.chen@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/331851 Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org> (cherry picked from commit f00d4621a480f12293214f14716ac33a90281ce7) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359406
* BACKPORT: sensor: update sensor driver to use I2C port from motion_sensor_tKevin K Wong2016-08-014-36/+45
| | | | | | | | | | | | | | | | this allow motion sensor devices to be locate on different I2C port BUG=b:27849483 BRANCH=cyan 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> (cherry picked from commit 6711629163f23a98099d8c6d37f6cdb1ef56ca52) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359405
* UPSTREAM: motion: Set interrupt interval properly for sensor in force modeGwendal Grignou2016-08-011-6/+22
| | | | | | | | | | | | | | | | | | | | | | | | | cl/301134 has a bug. If the AP wants a forced sensor (i.e. light) at 100Hz but a sampling frequency at 1s, we would still wake it up every .1s instead of 1s. Take in account force mode only when calculating the sampling frequency not the interrupt interval. BRANCH=smau, cyan BUG=b:2542542, b:27849483 TEST=Check the device goes to suspend even with 40Hz light sampling rate: echo 0 > /sys/bus/iio/devices/iio:device0/frequency echo 40000 > /sys/bus/iio/devices/iio:device3/frequency echo mem >/sys/power/state Before it would resume just after suspend/while suspending. Change-Id: Ie4fe36268cb1b04bc8f01ec885af84fad9e8b282 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/314315 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 70915b501249017e4e962316bf178fd00d09e696) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359404
* UPSTREAM: motion: At shutdown, access sensors only if initialized.Gwendal Grignou2016-08-011-2/+9
| | | | | | | | | | | | | | | | | | | When sensor_shutdown() is called, the sensors may already been powered off, or will be soon. In that case, do not attempts to access them. Check their state before setting range or disabling activities. BRANCH=smau, cyan BUG=chromium:55796, b:27849483 TEST=compile Change-Id: I60640b120a23f9aab393a93c4c67ef17222ced4e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/314382 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit cef0fdb90e17fae3fd9f035bb6ada17e2833369e) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359403
* UPSTREAM: motion: fix ec_rate to be more accurateGwendal Grignou2016-08-011-3/+3
| | | | | | | | | | | | | | | | | | In case the actual ODR rate is way higher that the AP asked for, we don't have to settle to a slower EC rate if EC rate == AP requested ODR rate. BRANCH=smau, cyan BUG=b:27849483 TEST=Run android.hardware.cts.SingleSensorTests Change-Id: I437f47bd942a16694c7efcdbc00201352f0480a6 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/313641 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 68502864c7db47b0dae250600dec5531c5f35619) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359402
* UPSTREAM: motion: Fix the number of sample to collect in motion taskGwendal Grignou2016-08-011-1/+10
| | | | | | | | | | | | | | | | | | | | AP could collect samples while motion task was still adding timestamp. A data stream not ending with a timestamp can lead to timestamp error in the kernel. This is espcially true if the motion task interrupt the AP back to back, when sensor ODR changes for instance. BRANCH=smau, cyan BUG=b:2436762, b:27849483 TEST=Run android.hardware.cts.SingleSensorTests Change-Id: I5820216a2cfc0a869db7dc5ef75d4be126a53b4f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/313640 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 708f81e3d1d222270c697b5643760b1ca361b9f9) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359401
* UPSTREAM: motion: improve readability by adding units to variable names.Gwendal Grignou2016-08-012-22/+23
| | | | | | | | | | | | | | | | | | Throughout the code, there are comparison between frequency (in mHz) and period (in us). To improve readability, append units (_mhz, _us) after variable names. BRANCH=smau, cyan BUG=b:27849483 TEST=compile. Change-Id: Icc9c66d9f06c526fc3b74fd85ca9759b702ee416 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/313221 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 87a60df71f24aca95a485662e30a94076c75b0e0) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359400
* UPSTREAM: motion: wake up main task for all changes in EC parameter.Gwendal Grignou2016-08-012-11/+16
| | | | | | | | | | | | | | | | | | | | We need to wake up the main task, even if we disable a sensor. It will force sending the sensors samples in the FIFO and put a timestamp behind them. Also, reduce the interrupt period by 10us to be sure we fire interrupt to the AP even if there are some variation in the timing calculation. BUG=b:2436762, b:27849483 BRANCH=smau, cyan TEST=Run ts.SingleSensorTests overnight. Change-Id: I6d966d52b5cbb72ba5eb936bc2fad6c06c7d8605 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/312986 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 9d7f1674460ce8e1a9c2fab79909cfd3bc856807) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359399
* UPSTREAM: motion: Alter ec_rate to prevent samples without dataGwendal Grignou2016-08-011-11/+40
| | | | | | | | | | | | | | | | | | | If EC sampling rate is close to sensor rate, decrease sampling frequency by 5% to prevent samples by the EC without data. It can happen when the clocks are slightly different and get unsynchronized. BRANCH=smau, cyan BUG=b:2436762, b:27849483 TEST=Ran cts.SingleSensorTests overnight without error. Change-Id: Iab5e578763171411eb474e1e717167c8e1ef7ecf Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/312985 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit d98999f3685ddbd27af86e1d96f2af030af9beab) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359398
* BACKPORT: motion: Change units of ec_rate from us to ms.Gwendal Grignou2016-08-013-19/+19
| | | | | | | | | | | | | | | | To ease finer calculation of ec rate change units from ms to us. BRANCH=smaug, cyan BUG=b:24367625, b:27849483 TEST=compile Change-Id: I52057c8ca1b1180a64b58d1ba0af9ec53f40b026 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/312984 (cherry picked from commit 420099f74976b3af1f4b24dc24b9fec461b1037b) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359397
* UPSTREAM: motion: fix oversampling formulaGwendal Grignou2016-08-012-42/+33
| | | | | | | | | | | | | | | | | | | | Overly complex previous formula could lead the EC to throw all samples between 2 timestamps and put 2 event within one timestamp. That would confuse the kernel. If the motion sense task is delayed while this happen, the delta between the 2 samples could be so long that CTS test cts.SingleSensorTests would fail. BRANCH=smau, cyan BUG=b:2436762, b:27849483 TEST=Loops of cts.SingleSensorTests pass. Change-Id: I29e6bf354ccb7ecf741a91116854d6abe07558dc Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/312364 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 96b65354878587df434becfbc5d707a687c85fa4) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359396
* BACKPORT: motion: minium interval between motion task now a variableGwendal Grignou2016-08-013-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Ryu EVT2, where sensors share a 100kb i2c bus with other device, when the sensors set to their maximal frequency and sampling interval set to 5ms, the power management task would wait forever for the i2c lock. Increase the minimal amount of time the task can wait from 3ms to 8ms in that case. This is not an issue for Ryu PVT where the sensors are on a separate SPI bus. However, on EVT, when setting the accelerometer/gyro over 125Hz, EC won't be able to deliver the data in non-batched mode. BRANCH=smaug, cyan BUG=b:25510300, b:27849483 TEST=Without this change, an evt2 board would crash when plugging/unplugging the charger while the sensors are set with: echo 200000 > iio:device0/frequency # Accel echo 5 > iio:device0/sampling_frequency echo 200000 > iio:device1/frequency # Gyro echo 25000 > iio:device2/frequency # Mag Change-Id: Idb30da9ab8da61284388db73365c37be3a250dec Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/311755 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 66a72f0b6e379edc3a2a52fa2e9b0f66c557a447) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359395
* UPSTREAM: motion: cleanup include fileGwendal Grignou2016-08-013-8/+5
| | | | | | | | | | | | | | | | | Use test_export_static for static variable/function that needs to by used by tests/motion_lid.c BRANCH=smau, cyan BUG=b:27849483 TEST=Compile, make buildall -j Change-Id: I2f3eb72ce319622842885be9125b91e58f47133a Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/311754 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 0922cc81ce22204264a2b96cec4bf2195939e516) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359394
* BACKPORT: motion: Remove duplicate shutdown codeGwendal Grignou2016-08-013-12/+8
| | | | | | | | | | | | | | | | | | | | 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, b:27849483 BRANCH=smaug, cyan 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> (cherry picked from commit 21c46e7b1300022fcee1e5997b3e9293c47c27ea) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359393
* BACKPORT: common: lightbar: Add histeresis to prevent flickeringGwendal Grignou2016-08-015-20/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | When ALS is enabled, if light is around one threshold (say 40 lux), the lightbar will flicker between readings. Add a histeresis to prevent the flickering. The current setting is: setting ^ (dim) 2 | ------+---->---+ 1 | +----<---+--->---+ (bright) 0 | +---<---+--------- +-------+--------+-------+--------> lux 20 40 60 BRANCH=smaug, cyan BUG=chrome-os-partner:44400, b:27849483 TEST=check in a dark room (30~40 lux) there is no flickering. Add unit test. Change-Id: I4018e2c2ed764abf9c9ed28e2d50a3e94a7d5f75 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/308205 (cherry picked from commit 81d269dc004b6c7334e4e8eafbb2872e5b6fdcf1) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359392
* BACKPORT: common: Add lightbar dimming based on outside light.Gwendal Grignou2016-08-014-0/+60
| | | | | | | | | | | | | | | | | | | Unless the lid is closed, the ALS is used for lightbar dimming. Change the google colors depending on the light sensor result. BUG=chrome-os-partner:44400, b:27849483 BRANCH=smaug, cyan TEST=Check all 3 levels of brightness of the lightbar. Check value using "adb shell ectool lightbar" Check double tap color are not affected and is using full brightness. Change-Id: I7b5e2890c3557f1dd3ae719f5f82ffb5fe7b24fb Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/301216 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 7340e804a1e3ffba2f1ffb9bf826a33b8b5fb19c) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359391
* UPSTREAM: motion: reenable double tap in S5.Gwendal Grignou2016-08-011-0/+3
| | | | | | | | | | | | | | | | | | Double TAP must be enabled in S5, even if it has been disabled by the AP, otherwise we would not be able to check the battery level if the AP did not shutdown properly or does not reenable double tap on shutdown. BRANCH=cyan BUG=chrome-os-partner:4657, b:27849483 TEST=Check double tap is working after unit has been powered down. Change-Id: Ic798399a3e4ae4d87c6e80eab4cf1fd680f99585 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/306697 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 0686445847dac456e867f96968b2ee29d7cce74a) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359390
* BACKPORT: motion: fix manage_activity interfaceGwendal Grignou2016-08-012-2/+2
| | | | | | | | | | | | | | | | | Declare optional parameters are const structure. These parameters, when used, are just read by the sensor driver. BRANCH=smaug, cyan BUG=b:27849483 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> (cherry picked from commit fcfd32f04a58e1baf54b39d97c7b37eabb0770db) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359389
* BACKPORT: common: motion: Fix forced mode computationGwendal Grignou2016-08-011-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When the sensor is defined to be used in forced mode, ec rate was not calculated properly: if the AP rate was rounded up, ec_rate requested by the AP would always be 0. If the EC rate is 0, the sensor may potientally never be queried. Also, when the sensor was disable for a long time, the last timestamp of collection may appear to be in the future, so collection was not initiated. (long time more than 35 minutes, less than 71 minutes). We still see instance where the sensor seems locked up. accelinit would not help because the state machine was not reseted, fix that. BRANCH=smaug, cyan BUG=chrome-os-partner:45627, b:27849483 TEST=With accelerate 3/4, check the value is now correct. Check proximity sensor is not stuck 45 minutes after last collection. Change-Id: Ia6805b75f67b048cb0b42c0f91a73dfaf94a254f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/305823 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 917effebbf4f64607a94b10490c143817bf10801) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359388
* UPSTREAM: motion: Add timestamp in ODRGwendal Grignou2016-08-011-9/+17
| | | | | | | | | | | | | | | | | | Before setting a new frequency, put a timestamp in the FIFO. In case there was a long silence, the sample timestamp will be anchored on that timestamp instead of the last timestamp the AP collected. BRANCH=smau, cyan BUG=chrome-os-partner:4381, b:27849483 TEST=Check SingleSensorTests pass. Change-Id: Ie40ebd9d856abdeeeccf4b636351560bb8a6305c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/305571 Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit 0174b9a21d0764bf32243cf23a3f138bf44e5938) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359387
* BACKPORT: motion: fix spellingGwendal Grignou2016-08-012-16/+16
| | | | | | | | | | | | | | | | | | | | | 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, cyan TEST=compile BUG=b:27849483 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> (cherry picked from commit c8844123923f8b65f38a7d16aaac3e9ce774ce2c) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359386
* UPSTREAM: motion: fix sensor interrupt interval computationVincent Palatin2016-08-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | When a sensor has a null rate, do not reset the interrupt interval as we need the minimum for all used sensors. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smau, cyan BUG=b:2467859, b:27849483 TEST=Rotate a Ryu at the Home Screen and see a proper auto-rotation. Change-Id: Ia4cbb1e8bc425c076af245f45a72b1beb356f686 Reviewed-on: https://chromium-review.googlesource.com/304132 Trybot-Ready: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 1c73c7958e5db4024e05d5e691918238107654d3) Reviewed-on: https://chromium-review.googlesource.com/304196 Commit-Ready: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> (cherry picked from commit f7022544bffac0964300405eb878b114d14128ae) Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/359385