Commit Graph

217 Commits

Author SHA1 Message Date
Gwendal Grignou
21c46e7b13 motion: Remove duplicate shutdown code
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>
2015-10-28 00:23:48 -07:00
Gwendal Grignou
7253e57b3c driver: si114x: Fail init of proximity sensor if light sensor fails.
If init of the light sensor fails (for instance, the chip is not present
on the i2c bus), we need to fail the init of the proximity sensor.
Otherwise, the EC will report an unexistent sensor to the AP.

BRANCH=smaug
BUG=chrome-os-partner:46638
TEST=check the proximity sensor is not reported if sensor is disconnected from the
main board.

Change-Id: Ie6b1d74eaac4d6c38d52641626966b5d3ce63bd3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308560
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-28 00:23:48 -07:00
Gwendal Grignou
8238dfa27d driver: bmi160: Add magic sequence to unlock
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>
2015-10-27 16:29:33 -07:00
Mary Ruthven
cb4a76e802 i2c: get battery information from charge state
ARM systems currently use SBS kernel driver which talks to the battery
through I2C passthu in the EC. Instead when asking for battery
information try getting it from the charge state machine first, and
then try the battery if charge state does not have the information.
This reduces latency by cutting out the battery response time.

BUG=chromium:484841
BRANCH=none
TEST=check that power_supply_info works properly on Jerry

Change-Id: If4da15ccabe412adc31fc94b189089ebb3e9265c
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307905
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-27 11:52:34 -07:00
Alec Berg
7e81bebb48 tcpc: re-initialize tcpc if it reboots while tcpm is running
On TCPC startup, set an alert to notify TCPM that we have been
reset. When TCPM gets this notification, it should re-send
initial TCPC parameters. If we were in a stable contract as
a sink, make sure we don't reset connection. If not, then
reset PD protocol state machine to the default state.

This fixes a bug where if the TCPC reboots while the TCPM is
still running, then the TCPC would not get re-initialized and
therefore no PD communication would not work. This also fixes
it such that if we are in a stable contract as a sink and the
TCPC reboots, then we don't lose power.

BUG=chrome-os-partner:46676
BRANCH=none
TEST=tested on glados. reboot PD MCU with and without a charger
plugged in and verify that PD communication works after the
reboot. verify that with a charger, we don't lose power.
also tested with a hoho plugged in during reboot.

Change-Id: I84fec4577b0daf5891bd8461d3f3d925014a5ecf
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307187
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-22 17:40:31 -07:00
Duncan Laurie
5ef8956169 ps8740: Make revision check a minimum instead of explicit value
With a new PS8740 chip revision 0xb the explicit check for 0xa
is failing.  Change this to allow revisions >= 0xa to pass.

BUG=chrome-os-partner:46728
BRANCH=none
TEST=boot on chell and confirm lack of mux init errors

Change-Id: I0847bb9953920569922183ed4c83da2370ef40e4
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307932
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-21 17:31:24 -07:00
Bolat Dinc
7b9ec09910 driver: Add L3GD20H gyrometer basic driver support
BUG=chrome-os-partner:40465
BRANCH=None
TEST=Added Gyro config to test L3GD20H Gyro sensor in Kunimitsu.
     Able to read the gyro data from "accelinfo" console command.
     Rotated the sensor in X,Y,Z axis, respective axis values change.
     Fits into the existing accel/gyro framework.

Change-Id: I19369560ddad5160c2fc9c7ef9823bd37b5389fa
Signed-off-by: Bolat Dinc <bolat.dinc@intel.com>
Signed-off-by: Divya Jyothi <divya.jyothi@intel.com>
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/264650
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>
2015-10-20 15:02:49 -07:00
Gwendal Grignou
fcfd32f04a motion: fix manage_activity interface
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>
2015-10-16 14:46:20 -07:00
Gwendal Grignou
917effebbf common: motion: Fix forced mode computation
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
BUG=chrome-os-partner:45627
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>
2015-10-15 21:40:37 -07:00
Gwendal Grignou
50b1a9de02 driver: bmm150: Use Bosch recommend repetition
To minimize noise, instead of using recommend preset from the
documentation, use specific repetition value.

BRANCH=smaug
BUG=chrome-os-partner:45436
TEST=Check the noise is somewhat reduced, still not great.

Change-Id: I0ed3409dd907fa1e393d1eb77b6f23ff03763e53
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/305588
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-15 18:08:25 -07:00
Gwendal Grignou
c884412392 motion: fix spelling
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>
2015-10-15 18:08:25 -07:00
Gwendal Grignou
828b55a735 common: Add magnetometer online calibration.
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>
2015-10-13 05:28:54 -07:00
Alec Berg
9669eeede2 charge_state_v2: fix battfake command race condition
This moves battfake console command to the battery driver.
This fixes a race condition with using the 'battfake' command
where charge_state_v2 could return the real battery percentage
even when a faked percentage is specified, if a higher priority
task uses the battery state of charge in between when the
battery is read, and when the fake state of charge overwrites
the battery parameter.

BUG=chrome-os-partner:45878
BRANCH=none
TEST=use tap for battery with a faked state of charge. the tap
for battery queries the battery percentage a lot, so without
this CL, the tap sequence often temporarily jumps to different
percentages and colors. with this CL, the tap sequence works
great.

Change-Id: I3ae0866d1ff7bb8d0c51355cd6b958310766f19e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302711
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-10-06 22:57:08 -07:00
Vijay Hiremath
229094b245 ALS: Disable the ALS task if all the ALS inits fail
BUG=none
TEST=Manually tested on Kunimitsu & Strago.
     Removed the ALS sensor from DUT, using "taskinfo" console command
     observed that the ALS task is not running.
BRANCH=none

Change-Id: I96cb720bd8d70033d433cdc2cd9cea9b56a3b389
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/301753
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>
2015-10-02 12:55:51 -07:00
Vincent Palatin
2aebfda07f ryu: update charging temperature upper limit
Do not charge above 48 C.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=smaug
BUG=chrome-os-partner:45631
TEST=none

Change-Id: I43260ab6079732ab3779d77ed64e3d872c5da4bd
Reviewed-on: https://chromium-review.googlesource.com/302442
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 071b068816722958cebf326857b68b4bb06ecb5b)
Reviewed-on: https://chromium-review.googlesource.com/302475
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2015-10-02 12:55:50 -07:00
Vijay Hiremath
5cbd9fa7bb Driver: ISL9237: Monitor system power consumption
Added code to enable the system power monitoring functionality to get the
details of the system power consumption.
And also added EC console command "psys" to get the system power consumption.

BUG=none
TEST=Manually tested on Kunimitsu.
     Power = Voltage * Current, reading is equal to the power readings
     from the psys command.
BRANCH=none

Change-Id: I62519ac96800363b67cab23cd9eb0dcac229cb47
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/302472
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>
2015-10-02 03:28:30 -07:00
Kyoung Kim
9104bd94bb Kunimitsu: Fix VRMODECTRL for PMIC VCCIO control
Added VRMODECTRL for VCCIO

BUG=none
TEST=Fab3 with new LSW for VCCIO
BRANCH=master

Change-Id: Ibe5350b535037e8101d2a77dca091479480e58e7
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/302686
Commit-Ready: Kyoung Il Kim <kyoung.il.kim@intel.com>
Tested-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-29 13:07:08 -07:00
Gwendal Grignou
18295c9bb2 board: ryu: Match Samus double tap behavior.
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>
2015-09-29 00:09:41 -07:00
Kyoung Kim
e1b26d02d6 Kunimitsu: initialize PMIC for VCCIO decay on assertion of SLP_S0
PMIC configuration for VCCIO decay and mask PowerGood of some rails

BUG=none
TEST=Fab3 with new LSW for VCCIO
check if VCCSTG is off / on as SLP_S0 is off and on.
is pressed.
BRANCH=master

Change-Id: I00a131171354b3579d40309af700794a6b151f9d
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/302148
Commit-Ready: Kyoung Il Kim <kyoung.il.kim@intel.com>
Tested-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-25 13:24:30 -07:00
Vincent Palatin
bd34af5d78 ryu: change charging temperature limits
Do not charge below 5 C or above 50 C.
Still charge at 0.1C between 5 C and 10 C.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=smaug
BUG=chrome-os-partner:45631
TEST=none

Change-Id: I6788088054ef4a5eb176eb2185b5e1c576128e09
Reviewed-on: https://chromium-review.googlesource.com/302232
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-24 19:36:20 -07:00
Gwendal Grignou
324d6b807f driver: bmi160: Reenable FIFO when EC wants it.
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>
2015-09-24 18:06:58 -07:00
Gwendal Grignou
40e20adefb driver: bmi160: Fix for significant motion while in suspend.
- 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>
2015-09-21 01:13:57 -07:00
Gwendal Grignou
241c2cb429 driver: bmi160: Allow double tap to be set by the host.
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
2015-09-21 01:13:56 -07:00
Gwendal Grignou
8839b30b25 common: motion: Fix accelgyro interface
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
2015-09-21 01:13:56 -07:00
Gwendal Grignou
8139114897 driver: bmi160: Add Significant motion support.
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
2015-09-21 01:13:54 -07:00
Gwendal Grignou
56670f5d8d driver: bmm150: fix repetiton registers
Rereading the spec, the repetition registers are massaged by the chip
to produce the repetition value: for XY: 1 + 2 * REPxy, Z axis: 1 + REPz

BRANCH=smaug
BUG=chrome-os-partner:39900
TEST=check the registers matches the spec.

Change-Id: Ic8618d70c18b4f408e3c95acdbe7fcdf6d95e39e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299582
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-20 12:33:23 -07:00
Gwendal Grignou
1ce66908fb driver: si114x: fix typo
If/When si1142/si1143 are used, we would upload 2/3 IR LED data.

BRANCH=smaug
BUG=None
TEST=compile, data still valid for si1141.

Change-Id: I39cd15d3c791ed514e4e122ddab3d3571edc43f9
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298687
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-19 15:18:08 -07:00
Gwendal Grignou
33046e7d51 common: accel: Add error code for irq handler
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
2015-09-19 15:18:08 -07:00
Aseda Aboagye
d341615383 GLaDOS: Add base accel & gyro.
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>
2015-09-19 02:00:54 -07:00
Gwendal Grignou
6b5a49ef15 motion: Add Gesture Interface
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
2015-09-18 20:57:22 -07:00
Gwendal Grignou
5254d5687c driver: bmi160: add code for setting double tap
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>
2015-09-18 19:21:12 -07:00
Aseda Aboagye
4ef6aabe07 common: Move tps65090 PMIC driver to driver/.
The driver directory is the natural place for drivers.

BUG=chromium:472173
BRANCH=None
TEST=make buildall tests

Change-Id: Iba85b643f20eb9607db16c7e6ad9a67443d78a3d
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/300789
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-18 17:55:35 -07:00
Gwendal Grignou
bde89ebc20 common: motion: move gesture actions in motion task.
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>
2015-09-18 17:55:32 -07:00
Gwendal Grignou
3788806149 driver: si114x: Fix compilation when ACCEL_FIFO is disabled
Fix compilation error when we are not using the FIFO

BUG=none
TEST=compile
BRANCH=none

Change-Id: I50e12fe4ebc6a626638d6f9ae555a324f366fef9
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299947
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-09-18 17:55:32 -07:00
Alec Berg
18ff33318f lucid: set bq24773 switching frequency to 600kHz
Set bq24773 charger switching frequency to 600kHz for
efficiency.

BUG=none
BRANCH=none
TEST=removed #ifdef BOARD_LUCID and tested on samus. verified
that the option0 register was set correctly when charger
plugged in:
> i2cxfer r16 0 0xd4 0
0xe04e

Change-Id: I60d563d0040efc7ca7746985156c4e70b423f3a7
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300622
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-17 20:42:47 -07:00
Alec Berg
c8d95f8a6d tcpc: update to tcpci RC3
Update TCPCI to match specification version RC3.

BUG=none
BRANCH=none
TEST=tested on glados and samus by plugging in a zinger with
both polarities and verifying we make a power contract.

Change-Id: I9cd6d8db7b7149995847ec1b071fba1f4d4cd5a3
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299713
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-09-16 14:49:47 -07:00
Vincent Palatin
3154abd5c3 ryu: put additional temperature checks for battery charging
Whatever the battery gas gauge returns, ensure we never charge below 0 C
and above 60 C.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=smaug
BUG=chrome-os-partner:44820
TEST=charge a Smaug DVT, use a cold spray on the battery and see the
charge stop.

Change-Id: I8670fbe1713b35aa079bebc9c5bb70e9f28cf8ac
Reviewed-on: https://chromium-review.googlesource.com/299945
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 1d19259be3b0721667835ce01bfe719fb547785e)
Reviewed-on: https://chromium-review.googlesource.com/299906
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-09-15 19:17:52 -07:00
Aseda Aboagye
16a18a5e0e driver: Refactor Kionix Accelerometer drivers.
This commit adds a new basic driver for the Kionix KX022 Accelerometer.
Currently, the driver is capable of reading the sensor data and
manipulating its ODR, resolution, and range.

This sensor also has integrated support for Directional
Tap/Double-Tap(TM), however that functionality is not yet implemented in
the driver.

Lastly, since this accelerometer is very similar to the previous KXCJ9,
this commit tries to combine the drivers.

Note, the variant of the Kionix accelerometer MUST be specified in the
private data structure.

BUG=chrome-os-partner:43494
BRANCH=None
TEST=Build GLaDOS EC with driver enabled and verify that valid
accelerometer data is read, and that range, resolution, and odr can all
be modified.
TEST=Build samus EC image and verify that the lid still
works. Additionally, verify that I can change the odr, rate, and
resolution.
TEST=make buildall tests

Change-Id: I238ff1dc13f5342a93f8f701a0da85c52f25d214
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/299013
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2015-09-15 11:02:43 -07:00
Rong Chang
2eabf6fe8c oak_pd: tcpm_power_status: Update power status on init
Oak board relies on TCPCI power status. When board init, PD should
update it's VBUS status and TCPM needs to get power status after enable
TCPC power status mask.

BRANCH=none
BUG=chrome-os-partner:44952
TEST=manual
  build and load on oak, disconnect battery.
  power on system with zinger, and check PD state.

Signed-off-by: Rong Chang <rongchang@chromium.org>
Change-Id: Ic0d4b50d38ac39ff31b3a257c4b3b5dde0ebda4b
Reviewed-on: https://chromium-review.googlesource.com/297871
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-14 00:48:39 -07:00
Vijay Hiremath
ea6c69c839 Driver: Add TI TPS650830 PMIC driver header file
Added initial TI TPS650830 PMIC driver header file containing the
macros for registers & register values.

BUG=none
TEST=make buildall -j
BRANCH=none

Change-Id: I936d8263d44e771bc24b3786aedea95feaa2b30c
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/297515
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>
2015-09-11 23:00:13 -07:00
Wonjoon Lee
8acda59faa driver/temp_sensor: Add support thermistor on EC's own ADC
Add support for ADC / thermistor reads on the EC's ADC
This will support now only ncp15wb but we can expand it
at future time.

BUG=chrome-os-partner:44764
TEST=make buildall -j
Manual on celes with subsequent commit. Boot to S0, run "temps".
Verify that temperatures are. See temperature is changing
BRANCH=None

Change-Id: If26d24b803dcff00c4c24e4e1f71d3b0de8e6738
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/296872
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-11 00:45:38 -07:00
Wonjoon Lee
502dc50f04 temp_sensor: Separate ADC interface and thermistor maths
Separate the bd99992gw ADC interface from the NCP15WB thermistor
adc-to-temp maths so that the thermistor can be used with various
other interfaces.

BUG=chrome-os-partner:44764
TEST=make buildall -j
Manual on Glados. Boot to S0, run "temps".
Verify that temperatures start around 28C and begin to increase after
system is powered-on for a long duration.
BRANCH=None

Change-Id: I3e72e9f390feebaac2440dbe722485f8d1cf8c56
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/296871
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-11 00:45:37 -07:00
Duncan Laurie
2a16019d54 opt3001: Change resume hook priority
If the power rail to the ambient light sensor is only enabled
at HOOK_CHIPSET_RESUME (as on glados) then the ALS init should
not attempt to execute until after that happens.

BUG=chrome-os-partner:43493
BRANCH=none
TEST=enable ALS on glados and successfully build and use it

Change-Id: I4e8841bdf6d3970a30f58431aca771c87c7e15ba
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/298157
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-10 15:40:45 -07:00
Vijay Hiremath
dda0704bf9 Driver: ISL9237: Enable trickle charging
Enabled the trickle charging mode by setting the MinSystemVoltage
register[0x3EH] to board specific battery voltage minimum value.
When the battery voltage drops below the battery voltage minimum
value, trickle charging enabled.

BUG=none
TEST=Manually tested on Kunimitsu FAB4 prototype.
     Drained the battery below voltage minimum value. Using the
     i2cxfer command observed Trickle charging mode is active in
     the information register[0x3AH].
BRANCH=none

Change-Id: Id6416f2b0b74fda8cf3eafb95e044586f90b8a8e
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/298143
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-09-10 12:35:39 -07:00
Anton Staaf
7bdb69c464 UART: Remove unused uart.h header includes
Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j

Change-Id: Ife068807f79f6435292643c49afa1a9a30ae7080
Reviewed-on: https://chromium-review.googlesource.com/296733
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-08 10:38:20 -07:00
Gwendal Grignou
84ed699ac9 driver: bmi160: Prevent crash when FIFO is not valid
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>
2015-09-07 15:16:47 -07:00
Ben Lok
a572c882e4 driver/temp_sensor: Add power control API for TMP432
Some boards didn't define the CONFIG_TEMP_SENSOR_POWER_GPIO (such as: Oak),
Due to the hardware design, the power of temp sensor is always on.
But, we can enable/disable the temperature measurement circuitry of tmp432 by
setup the shutdown (SD) bit. Add a new API: tmp432_set_power() to let upper
layer to control the power of tmp432 by SW approach for power saving.

BRANCH=none
BUG=chrome-os-partner:44170
TEST=manual
1. make BOARD=oak -j
2. Turn off the TMP432:
   > tmp432 power off
3. check whether tmp432 is shutdown:
   > tmp432
   ERROR: Temp sensor not powered.
   Not Powered
4. Turn on the TMP432:
   > tmp432 power on
5. check whether tmp432 is running:
   > tmp432
   Local:
     Temp        29C
     Therm Trip  85C
     High Alarm  85C
     Low Alarm    0C
   Remote1:
     Temp        27C
     Therm Trip  85C
     High Alarm  85C
     Low Alarm    0C
   Remote2:
     Temp        27C
     Therm Trip  85C
     High Alarm  85C
     Low Alarm    0C

   STATUS:  10000000
   CONFIG1: 00000000
   CONFIG2: 00111100

Change-Id: Iab95c4c0b0130baf3bce380a8132e08ded8d159e
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/295058
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-09-03 04:24:33 -07:00
Gwendal Grignou
1dfaf92f3a driver: si114x: Convert unit to distance
Instead of returning the amount of light returned,
convert the data into distance (cm). It can be adjust via range.

BRANCH=smaug
BUG=chrome-os-partner:42526
TEST=check the data is usable by HAL.

Change-Id: I97510246ce054af4e61325d7e295ca09cc536457
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/296472
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2015-09-01 01:28:00 -07:00
Gwendal Grignou
4e7e1bb796 motion_sense: Add more complex EC/AP sensor rate support.
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
2015-08-29 01:34:14 -07:00
Gwendal Grignou
398bd9a017 driver: kxcj9: Remove some printf to fit into kunimitsu
Remove some printfs for the new sensor code to compile.

BRANCH=kunimitsu
BUG=None
TEST=compile

Change-Id: Ia7b203a03866fd497cdfaf5fa91f651423279f61
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295856
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-29 00:04:16 -07:00