Commit Graph

264 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
4d382ad640 charge_manager: Support multiple independent charge ceilings
We will soon have a need to independently set a charge ceiling from both
the PD state machine and from incoming host commands. Store these
ceilings separately, and have the minimum take effect.

BUG=chrome-os-partner:43285
TEST=Pass unit tests. Also, host command current limit takes effect with
subsequent commit.
BRANCH=None

Change-Id: I0ecfe888a7df0d5da5a68999c164c7c841da348b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/293818
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-08-19 01:50:21 +00:00
Shawn Nematbakhsh
8ef87c157a glados_pd: Disable test build
The glados_pd test build runs out of RAM, so disable it for now.

BUG=chrome-os-partner:43948
TEST=emerge-glados chromeos-ec
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I519917a36d193931e993cf16487ac33c81ceb163
Reviewed-on: https://chromium-review.googlesource.com/292935
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-12 19:26:18 +00:00
Wenkai Du
5b4fd77df3 kunimitsu_pd: enable kunimitsu PD build
Symbolic link kunimitsu_pd to glados_pd folder. Disable PD test
build until issue is fixed.

BUG=chrome-os-partner:43142
TEST=emerge-kunimitsu chromeos-ec and check EC and PD binaries

Change-Id: Ic0f1d73246333d8ec7752bb4c42b1c0ac220b5c3
Signed-off-by: Wenkai Du <wenkai.du@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/292841
Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-08-12 04:25:20 +00:00
Shawn Nematbakhsh
c41174c5e5 glados: Enable tests build
`tests` build was previously disabled for glados due to errors building
power/skylake.c. Properly undef the chipset config to make `tests` work
for all skylake platforms.

BUG=None
TEST=`make BOARD=glados tests`
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I7a730cdd5e30a932ff0cd1f3beef77873b9e0630
Reviewed-on: https://chromium-review.googlesource.com/292910
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-08-12 04:25:14 +00:00
Shawn Nematbakhsh
2bb093151f driver/temp_sensor: Add support for BD99992GW
Add support for ADC / thermistor reads on the BD99992GW PMIC.

BUG=chrome-os-partner:42156
TEST=Manual on Glados with subsequent commit. 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: Ic15f41046130317a0e0c3bce4a923ba624328c0d
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289935
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-08-03 21:15:56 +00:00
Gwendal Grignou
a3a5c90b54 accel: mechanical changes from i2c_addr to addr
Encode both the I2C address and SPI GPIO CS in addr field.
Mechanical change to rename i2c_addr into addr.

BRANCH=smaug
TEST=compile
BUG=chrome-os-partner:42304

Change-Id: I1c7435398deacb27211445afa27a08716d224c06
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/288513
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: David James <davidjames@chromium.org>
2015-07-30 19:58:01 +00:00
Gwendal Grignou
57ec5805fe ryu: Fix orientation of accel and compass
Add matrices to align sensors vectors with the device reference.
Move rotation in read routines, to allow fifo to contains processed
information.

BRANCH=smaug
TEST=Worsk on smaug
BUG=chrome-os-partner:39900

Change-Id: I009e7f24ef6ee0574ed664aeb5fd649fcd7039fd
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/286659
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-07-22 05:02:53 +00:00
Gwendal Grignou
d1002e798e common: Untie math_util from motion sense.
math library can be set independentely.
It is implied when motion sensor drivers are compiled in.

BRANCH=smaug
TEST=Build strago board specific tests, host test and ran
ryu image.
BUG=chromium:512329

Change-Id: I743ea7b44e4a3783602c11f3928cb3fa4b105ec4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/287371
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-07-22 03:39:52 +00:00
Vincent Palatin
048436c6d3 ryu: remove P4/P5 code leftover
Remove remaining conditional code for ryu_p4p5 board which is gone.

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

BRANCH=smaug
BUG=chrome-os-partner:38333
TEST=make buildall

Change-Id: I1630fab5355d10018dab7f0fed7e35f240422ddd
Reviewed-on: https://chromium-review.googlesource.com/287142
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>
2015-07-21 19:56:24 +00:00
Gwendal Grignou
a82b97962b test: temporary disable motion_lid test.
The test became flaky because of CL:284616.
Disable it while it is being investigated.

BRANCH=smaug
BUG=chrome-os-partner:42855
TEST=Check motion_lid test is not ran anymore.

Change-Id: I2160dcda65e478817791859a19cdb51e88296259
Reviewed-on: https://chromium-review.googlesource.com/286180
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-07-17 00:05:52 +00:00
Anton Staaf
88a1790bb7 Queue: Add ability to modify contiguous units inplace
Previously all access to the queue was done by adding or removing units
with no access to the underlying byte array, or ability to notify the
queue that the byte array had been updated.  This prevented direct DMA
transfers to and from the underlying byte array.

This change adds a new struct, a queue_chunk, that represents a
contiguous region of the queues byte array.  Regions of valid units as
well as free space can be requested.  And there are now update functions
to signal to the queue that new units were added or existing units were
read from these chunks.  A chunk can be queried and used to initialize
a DMA transfer, as interrupts or polling indicates that the DMA is
working the queue indicies can be updated and the policy activated as
needed.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: I7e37d937c56153122f0a3c73ba8064b656106e3a
Reviewed-on: https://chromium-review.googlesource.com/285556
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-07-15 21:57:36 +00:00
Gwendal Grignou
c0f78b4c0a motion: Add sample frequency per sensor
Store at which frequency each sensor should be sampled.
This frequency is different from the sensor frequency:
- sensor frequency: frequency at which the sensor produce information.
- sensor sampling frequency: frequency at the which the EC gater
information.
If 2 sensors must be sampled at very different frequency,
we don't want to oversample the slow one, and filling the
software FIFO unnecessarily.

BRANCH=smaug
TEST=Unit test. Check that frequency is correct when sensor
frequencies change from IIO driver.
BUG=chrome-os-partner:39900

Change-Id: I4272963413f53d4ca004e26639dc7a2affd317eb
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/284616
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-07-15 02:07:01 +00:00
Alec Berg
ac1cba419a cleanup: remove board_discharge_on_ac() unless custom func needed
Remove duplicate board_discharge_on_ac() functions and create
CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM for boards that have a
unique implementation of board_discharge_on_ac().

BUG=chrome-os-partner:42294
BRANCH=none
TEST=make -j buildall.
load on samus and test 'ectool chargecontrol discharge' forces
discharging on AC, and 'ectool chargecontrol normal' resumes normal
charging.

Change-Id: I2b7c04b9278d07748d6d41798ceab1a7e90684e4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/284911
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-07-14 22:39:36 +00:00
Alec Berg
10dc22867f cleanup: remove board function callback on charge override timeout
Remove board function callback on charge override timeout, since
the implementation should be common to all boards: send host event.
This function is called when a power swap fails during an issued
charge override and notifies the host so that it is aware that the
power swap did not succeed.

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

Change-Id: Ia2a078a17aef6b302fd2b9fd21a5a92c628fd7db
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/284923
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-07-13 03:18:38 +00:00
Gwendal Grignou
a7c4132d25 driver: bmi160: Add FIFO and interrupt support
Add FIFO support, where bmi160 hardware FIFO is copied in local fifo.
Add rudimentary support for single/double tap and lift detection.

BUG=chrome-os-partner:39900
BRANCH=smaug
TEST=Check on F411 that FIFO data is retrieved and correct.
Check on Smaug as well, with proper kernel the collect the FIFO:
- check that increasing sampling_frequency we are collecting
the FIFO less often
- check no frames are lost.
- check tap/lift interrupts are working
- if latency is less than 100ms, check we are collecting much faster.

Change-Id: Ic2317c27fad0ef31dacd6e18cd5f71ccd2cec807
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274227
2015-07-10 03:40:19 +00:00
Bill Richardson
104f811e67 cleanup: fix all the header guards
This unifies all the EC header files to use __CROS_EC_FILENAME_H
as the include guard. Well, except for test/ util/ and extra/
which use __TEST_ __UTIL_ and __EXTRA_ prefixes respectively.

BUG=chromium:496895
BRANCH=none
TEST=make buildall -j

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: Iea71b3a08bdec94a11239de810a2b2e152b15029
Reviewed-on: https://chromium-review.googlesource.com/278121
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-18 19:07:00 +00:00
Gwendal Grignou
cca70a517b common: Add i2c 32bit read/write
Add functions and associated test to read/write a 32 bit register

BRANCH=smaug
TEST=Test on smaug with bm160 driver
BUG=chromium:39900

Change-Id: Ieff24b65f1eb8610874fe13c4a8fadf583a218cb
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/277535
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-06-17 13:10:58 +00:00
Shawn Nematbakhsh
35fbc972e9 charge_manager: Don't cutoff charger when no battery is attached
We normally do not charge from non-dedicated chargers. The process of
determining whether a charger is dedicated or not involves PD protocol
communication, so it can take some time to reach a determination. If no
battery is attached, the charger is likely our only source of power, so
don't cut it off.

BUG=chrome-os-partner:41258
TEST=Attach donette to glados system with no battery, verify that glados
boots to EC console and doesn't reset or panic.
BRANCH=None

Change-Id: I7c9cfcbd37b37ef16010cf1f246d8fddba6f6283
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/277074
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-12 18:23:28 +00:00
Shawn Nematbakhsh
e05ed041cf charger: Move USB charger / BC1.2 task to common code
Move the task responsible for detection of USB chargers to common code
to reduce code duplication.

BUG=chrome-os-partner:40920
TEST=Manual on samus_pd. Plug USB charger, verify detection is correct
on both charge ports.
BRANCH=None

Change-Id: I362f8b5b51741509e459c66928131f1f6d2a3b1d
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276210
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-10 19:48:08 +00:00
Randall Spangler
fe9e3bf565 Remove obsolete board-specific code
Now that we've removed boards from ToT, also delete board-specific
code used only by the removed boards.

There are still more things to remove (unused charging chips, LED
drivers, COMx support).  More CLs coming.

BUG=chromium:493866
BRANCH=none
TEST=make buildall -j

Change-Id: Ie6bdeaf96e61cadd77e3f6336c73b9b54ff4eabb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/276524
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-10 18:24:05 +00:00
Gwendal Grignou
46ccd63c1d accel: move X,Y,Z definition
Move definition so that we can use it in accel driver.

BUG=None
TEST=Compile
BRANCH=none

Change-Id: I45d16a91d923cb0538b7fdf4110112566c87b6d0
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/269837
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-06-09 12:10:42 +00:00
Randall Spangler
bdc680d8ed Remove obsolete EC targets
This is needed to allow cleanup and refactoring of the EC codebase in
ToT.  All of these boards use firmware from branches and uploaded to
BCS, so they don't actually care that ToT can't build their firmware.

BUG=chromium:493866
TEST=build on the following using cbuildbot:
    daisy-paladin
    falco-paladin
    link-paladin
    nyan-paladin
    peppy-paladin
    samus-paladin
    squawks-paladin
    daisy_spring-paladin
CQ-DEPEND=CL:274121,CL:274127
BRANCH=none

Change-Id: I19598843755ded7b2385cc712ef463e5de4411b8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/274121
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-06-05 19:35:06 +00:00
Aaron Durbin
460037b6e9 glados: remove tests for glados
Without this change emerge fails. Hit the tests with
a big hammer.

TEST=emerge-glados chromeos-ec
BRANCH=None
BUG=None

Change-Id: Ieb8f380520f078f91d5a676e3e6fcc687d6050a5
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/275007
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-06-03 22:27:45 +00:00
Alec Berg
488f8c9565 oak_pd: add initial support for oak PD
Add initial support for Oak PD MCU on rev1 boards.
This does not include USB PD communication.

BUG=none
BRANCH=none
TEST=build and load on oak and get console. test we
resond to host commands from EC using "pdcmd 0 0" on
EC console.

Change-Id: I92045cf0fd682279ada6c286f5399f0e258a6305
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/271828
2015-05-27 19:40:18 +00:00
Alec Berg
5b5f737d8f pd: move non-phy layer config out of usb_pd_config.h
Move parts of usb_pd_config.h that are not part of the phy layer
out of usb_pd_config.h and into board.h. This cleans up the
division between the TCPC and TCPM as only the TCPC needs to
use usb_pd_config.h.

Also cleans up the use of the CC detection voltage thresholds
by creating standard macros to use based on Rp strength for the
board.

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

Change-Id: I946cceb38bea8233095b8a4b287102bb8a3a296d
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270337
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-05-27 02:39:41 +00:00
Anton Staaf
a0ebf0a008 Queue: Add policies to queues
Policies give a convenient place to hook into the queue operations
and notify something that there is new space free in the queue or
new units added.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: I94b2aa94b8e8d07911191bc19a39fa827623b117
Reviewed-on: https://chromium-review.googlesource.com/271791
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
2015-05-26 19:36:15 +00:00
Alec Berg
6fcd1c0481 pd: add config options for including TCPM and TCPC separately
Add config options for various parts of USB PD stack:

CONFIG_USB_POWER_DELIVERY: The use of this option has changed
slightly. It now represents whether or not to include the USB
PD protocol and policy layers of the software stack.

CONFIG_USB_PD_TCPC: Compile in type-C port controller module
which performs the phy layer of the PD stack.

CONFIG_USB_PD_TCPM_STUB and CONFIG_USB_PD_TCPM_TCPCI: If
CONFIG_USB_POWER_DELIVERY is defined, then one TCPM needs to
be defined to declare which port management module to use
to drive the TCPC.

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

Change-Id: I41aa65a478e36925745cd37a6707f242c0dfbf91
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270171
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-05-22 05:35:06 +00:00
Shawn Nematbakhsh
e3dce49334 cleanup: Use appropriate image geometry CONFIGs
- Use CONFIG_*_MEM when dealing with images in program memory.
- Use CONFIG_*_STORAGE when dealing with images on storage.
- Use CONFIG_WP when dealing with the entire WP RO region.

BUG=chrome-os-partner:39741,chrome-os-partner:23796
TEST=Manual on Cyan with subsequent commit. Verify that FMAP matches
actual layout of image. Verify flashrom succeeds flashing + verifying EC
image using host command interface.
BRANCH=None

Change-Id: Iadc02daa89fe3bf07b083ed0f7be2e60702a1867
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270269
2015-05-15 06:42:30 +00:00
Vincent Palatin
cba37a13d2 Fix type mismatch on extern declarations
Update a few extern declarations to match the original variable type.

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

BRANCH=none
BUG=none
TEST=make buildall
Compile with LTO enabled and no longer see errors for those
declarations.

Change-Id: I5b0f0f7f498ec414a861cb1ce50a486036c853bd
Reviewed-on: https://chromium-review.googlesource.com/271279
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>
2015-05-15 00:53:31 +00:00
Gwendal Grignou
a9a9ae1abc driver: Use common data structure to store default accel values
Move structure used by lms6ds0 to motion_sense.h,
so that bosh driver can use the same mechanism.
Use code to avoid reading chip range when reading data.

BUG=none
BRANCH=none
TEST=Check Bosh driver is working as expected.

Change-Id: Id8b5bb8735e479a122ef32ab9a400fba189d7488
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270453
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-05-12 23:35:51 +00:00
Shawn Nematbakhsh
39bd18b890 cleanup: Rename image geometry CONFIGs
Rename image geometry configs with a uniform naming scheme to make their
purposes more clear.

CONFIG_RO_MEM_OFF (was CONFIG_FW_RO_OFF) - RO image offset in program memory
CONFIG_RO_STORAGE_OFF (was CONFIG_RO_SPI_OFF) - RO image offset on storage
CONFIG_RO_SIZE (was CONFIG_FW_RO_SIZE) - Size of RO image

CONFIG_RW_MEM_OFF (was CONFIG_FW_RW_OFF) - RW image offset in program memory
CONFIG_RW_STORAGE_OFF (was CONFIG_RW_SPI_OFF) - RW image offset on storage
CONFIG_RW_SIZE (was CONFIG_FW_RW_SIZE) - Size of RW image

CONFIG_WP_OFF (was CONFIG_FW_WP_RO_OFF) - Offset of WP region on storage
CONFIG_WP_SIZE (was CONFIG_FW_WP_RO_SIZE) - Size of WP region on storage

BUG=chrome-os-partner:39741,chrome-os-partner:23796
TEST=Set date / version strings to constants then `make buildall -j`.
Verify that each ec.bin image is identical pre- and post-change.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I6ea0a4e456dae71c266fa917a309b9f6fa4b50cd
Reviewed-on: https://chromium-review.googlesource.com/270189
Reviewed-by: Anton Staaf <robotboy@chromium.org>
2015-05-12 20:54:37 +00:00
Vincent Palatin
13b555dc63 ryu: fork P4/P5 support
In preparation for Proto 6 board support which won't be backward
compatible, fork the EC for Proto 4 and Proto 5 for people who need to
support older boards.

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

BRANCH=none
BUG=chrome-os-partner:39202
TEST=make buildall

Change-Id: I520bbf146cc1c1dc04e55283be57807ec19ebaa1
Reviewed-on: https://chromium-review.googlesource.com/266064
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-05-02 16:49:05 +00:00
Alec Berg
7fd9b69239 charge_ramp: fix flaky charge_ramp test
Fix flaky charge_ramp test. The test often delays CHARGE_DETECT_DELAY
after a new charger has been plugged in. But, that is the same delay
the charge_ramp module uses before starting to ramp. This creates a
race condition where sometimes the test resumes before the ramp up
starts and sometimes the test resumes after the ramp up starts. This
change fixes the problem by modifying the test to delay by 100ms
less than the charge_ramp module.

BUG=chromium:483543
BRANCH=none
TEST=run charge_ramp test 10 times w/o this CL and see failure 4
times. run test 20 times with this CL and observe 0 failures.

Change-Id: I5f7a6a05f9293d3dd7db5517a9df7caec95c58ea
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/268798
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-05-02 01:14:13 +00:00
Bill Richardson
99737a2fef cleanup: rename motion sensor CONFIG_ options
This renames some motion sensor options to start with more
consistent prefixes.

For gesture (tap) detection:

  CONFIG_GESTURE_DETECTION:
    CONFIG_SENSOR_BATTERY_TAP   =>    CONFIG_GESTURE_SENSOR_BATTERY_TAP

For detecting lid angle:

  CONFIG_LID_ANGLE:
    CONFIG_SENSOR_BASE          =>    CONFIG_LID_ANGLE_SENSOR_BASE
    CONFIG_SENSOR_LID           =>    CONFIG_LID_ANGLE_SENSOR_LID

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Ib8f645902a5585346e1d8d2cbf73d825c896a521
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/268777
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-05-01 20:46:37 +00:00
Alec Berg
d09405203f samus: ryu: allow charge ramp on CDP and proprietary chargers
Modify charge ramp so that when it ramps it ramps from 500mA and
up to the maximum allowed by that supplier. Also modify Samus and
Ryu to use charge ramping for CDP and proprietary chargers due
to the possibility that they may not be able to supply the amount
that is supposed to be guaranteed by their advertisement.

BUG=chrome-os-partner:37549
BRANCH=samus
TEST=test on a proprietary charger, make sure we can ramp. test
a DCP and make sure we also ramp as before.

Change-Id: I08fd43c8f0b21aa54d114fbe5a1296c9556357e4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/256972
Reviewed-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2015-03-07 03:38:38 +00:00
Vic Yang
accd0da789 Remove ryu_p1 board
P1 boards are not used anymore. We haven't built ryu_p1 EC for a while.
Let's get rid of it.

BRANCH=None
BUG=chrome-os-partner:35138
TEST=make buildall

Change-Id: Ie0c0b91ce0af99a0975050935af920503ca7383a
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/252340
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-02-24 03:07:59 +00:00
Alec Berg
a573a6c0fd charge_ramp: initial commit of charge ramp module
Add new charge_ramp module which works with charge_manager to
slowly increase input current limit in order to find the optimal
charging current. To do this it looks for either VBUS drooping
too low or for the charger to over-current.

BUG=chrome-os-partner:34946
BRANCH=samus
TEST=tested with a variety of BC1.2 chargers, type-C only chargers,
and PD chargers to make sure we always stabilize charging at an
appropriate current limit.

Change-Id: Icc95aa2738ddb221f163f91c14a342a0674f9e0f
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/247304
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-02-18 04:53:22 +00:00
Shawn Nematbakhsh
c1fe8f2173 charge_manager: Store dualrole capability in charge manager
Since charge manager is now informed of all capability changes as they
happen, it makes sense to store the port capability within charge manager,
rather than storing in pd.

BUG=chrome-os-partner:36390
TEST=Manual on Samus. Insert 1A Apple charger, verify correct detection.
Run 'chgoverride -2' to prevent charging, then repeatedly insert +
remove a dual-role charger on the other charge port. Verify that
charging is still prevented. Finally, insert a dedicated charger and
verify that the override is removed. Also, pass unit tests and verify
correct detection in various scenarios with various chargers.
BRANCH=Samus

Change-Id: I3669050b37ddd67f6608bf790a07e74f86b6ac01
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/247724
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-11 04:48:32 +00:00
Ben Lok
a9ae00b101 llama: add llama board support
This is to add llama board support:
  - new files in board/llama folder, including battery.c and led.c
  - new file power/mediatek.c, which is mostly based on power/tegra.c
  - modified flash_ec for llama board
  - disable tests for llama board.

BRANCH=none
BUG=none
TEST=make BOARD=llama

Change-Id: Ie1ae068c1a402f08e1449668b1be8f31105bb804
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/243510
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: lok.ben ben.mtk <ben.lok.mtk@gmail.com>
Commit-Queue: lok.ben ben.mtk <ben.lok.mtk@gmail.com>
2015-02-10 08:46:06 +00:00
Shawn Nematbakhsh
96895743b0 charge_manager: Wait for dualrole determination before charging
If a dual-role charger is plugged, we will not realize it is dual-role
until after we see a type-C charge source. It can cause us to briefly
charge from a dual-role charger, which has bad side effects related to
charge override and the lightbar. Fix this by not charging from a port
until we are fairly certain that it is a dedicated charger (based upon
PD discovery timeout).

BUG=chrome-os-partner:36390
TEST=Manual on Samus. Insert 1A Apple charger, verify correct detection.
Run 'chgoverride -2' to prevent charging, then repeatedly insert +
remove a dual-role charger on the other charge port. Verify that
charging is still prevented. Finally, insert a dedicated charger and
verify that the override is removed. Also, pass unit tests and verify
correct detection in various scenarios with various chargers.
BRANCH=Samus

Change-Id: Ia4154f34dd0a850b6e72bebadbd938f034532f14
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/247130
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-08 03:27:51 +00:00
Randall Spangler
fd6a6900f7 Convert motion sense calculations to fixed point.
Motion sense calculations do not require huge amounts of precision, so
fixed point is plenty accurate.  And fixed point works on Cortex-M0,
which lacks a FPU.

BUG=chrome-os-partner:36126
BRANCH=minnie (samus already works with the FPU, but could grab this if we
       want additional testing)
TEST=manual
    1. Boot system
    2. At EC console: accelinfo on 250
    3. Move lid through several different angles (30 degrees to max open) and
       see that it updates correctly and relatively smoothly.  A few degrees
       of angle jitter is normal.
    4. At several angles, rotate the chromebook around and see that the lid
       angle remains relatively stable.
    5. If the hinge is made normal to the ground (or within 15 degrees of
       vertical), the angle should read 500, since the acceleration vectors
       don't yield good results in that orientation (for either fixed or float
       math).
    And run 'make buildall -j', which tests arc_cos() and lid angle calculations

Change-Id: I70a0d08b8914629a3e21ae5578cbe8e50f29ad68
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/244116
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-02-05 19:41:41 +00:00
Vic Yang
b7f7cdaa72 ryu: improve inductive charging control
When inductive charging just starts, there might be a blip on
CHARGE_DONE signal and it'd cause our charging control logic to shut
down charging. Fix this by waiting for a second before we start
monitoring CHARGE_DONE.

Also, once we see CHARGE_DONE=1 and disable charging, CHARGE_DONE will
go low. Handle this by ignoring all subsequent CHARGE_DONE change until
the next time the lid is opened.

BRANCH=Ryu
BUG=None
TEST=Pass the updated unit test.
TEST=Charge a base on Ryu P3.

Change-Id: I9d911cd689d8e88ebcd66e6eca7c86dd70704880
Signed-off-by: Vic Yang <victoryang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/243365
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2015-01-30 05:11:06 +00:00
Shawn Nematbakhsh
88ccbe9323 charger: Make critical battery shutdown timeout a config option
Certain platforms may wish to have a longer shutdown timeout, so make
the timeout a config option.

BUG=chrome-os-partner:35188
TEST=Manual on Samus with subsequent CL. Set config option to increase
timeout, verify that timeout is extended.
BRANCH=Samus

Change-Id: I69feb0d31fdc53e533671dec1e88ba96cc4553c2
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/240815
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-15 05:13:14 +00:00
Shawn Nematbakhsh
ed4d13fde2 charger v2: Combine prevent_*_discharge functions
prevent_hot_discharge and prevent_deep_discharge are near-identical
copies of one another, and can be combined without the loss of any
useful functionality.

BUG=chrome-os-partner:35188
TEST=Manual on Samus. Charge to 2% and boot system with 5V power supply.
Verify that warnings print to console and AP powers down after 30s. Also
pass unit tests.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I0f1da5248825a3884f7910babc742dfa7eadf5a3
Reviewed-on: https://chromium-review.googlesource.com/240033
2015-01-13 18:48:18 +00:00
Alec Berg
d83bd6b892 pd: implement new type-C connect state machine
Implement the new type-C connect state machine which removes
lock and hold times and adds a debounce time to make sure
CC lines settle before going into the attached state.

This also adds detection of accessories, but doesn't do anything
when an accessory is detected.

BUG=chrome-os-partner:33680
BRANCH=samus
TEST=test samus connected zinger and samus connected to samus. make
sure that the connection is always formed. also tested with a third
party with old state machine implementation and formed a connection
every time.

Change-Id: I91a7a6031bc35082cc19d7697142e4aa92ef46f2
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/238210
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-10 23:43:25 +00:00
Shawn Nematbakhsh
fdb504e24a charge_manager: Prefer current active port in best port selection
If two identical suppliers are capable of supplying equal power, select
the port which is currently active.

BUG=chrome-os-partner:34912
TEST=Manual on Samus. Plug Zinger into right port, verify that it
becomes active. Plug a new Zinger into left port, verify that the right
port stays active.
BRANCH=Samus

Change-Id: Ib1baf4bd3f619169f0e31ec509a2fe7dbd8c897e
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/238766
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-08 05:02:35 +00:00
Shawn Nematbakhsh
73bbc9eda8 charge_manager: Request power swap when switching from dual-role override port
Ports should have source roles by default, and should go back to being
sources once we stop charging from them.

BUG=chrome-os-partner:31195
TEST=Manual on Samus. Connect Samus to dual-role port. Set override
port, verify that Samus charges. Attach dedicated charger, verify that
the dual-role port becomes a charge source again. Also pass unit tests.
BRANCH=Samus

Change-Id: Icf153117229cbf0f71d4bdeb888f73299acd5eeb
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/237452
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-12-24 21:06:16 +00:00
Shawn Nematbakhsh
86835f7067 charge_manager: Allow board to reject a selected charge port
Modify board_set_active_charge_port to return status indicating whether
the selected charge port was rejected. If rejected, zero out its
available charge and attempt to select a different charge port.

Also, reduce the length of related console prints.

BUG=chrome-os-partner:34677
TEST=Manual on Samus. Plug C-to-Arec into port 1, verify that charge
manager does not select port 1 as active and charging icon is not seen
in OS.
BRANCH=Samus.

Change-Id: I56e3337f90c04b93ef7cc9873af6ee0f4b1ffc7d
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/236361
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-12-17 22:26:56 +00:00
Alec Berg
6c980a4dbf pd: check for collisions before transmitting
Added check for collision just before transmitting on CC line.
To check for collision, RX monitoring is left on all the time
(except when in the act of receiving or transmitting, or in
between receiving and sending a goodCRC), and a
simple check for RX transmission started is used to see if the
CC line is idle or not.

RX monitoring is also changed to only trigger on 3 edges within
20us, as per the PD spec.

When a collision is detected by seeing that CC is not idle, the
transmitting packet is dropped.

BUG=chrome-os-partner:30135
BRANCH=samus
TEST=load onto samus and zinger. make sure we negotiate and make
sure custom VDMs succeed. enabled pings and made sure we stay
alive with pings for a few min.

Also added code to pd_rx_handler to toggle a test point on EVT
board to verify the timing of when we get RX interrupts:

Change-Id: I22d172163319437d3d901e019eda79d4d592f6b8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226118
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-12-17 03:27:17 +00:00
Alec Berg
fca4977983 samus: add high battery temp warning to charge state machine
Add high (and low) battery temperature warning which sends host
event to AP. After 30 seconds of out of range temp readings force
shut off AP and hibernate the EC.

BUG=chrome-os-partner:27641, chrome-os-partner:33111
BRANCH=samus
TEST=make buildall, and write unit tests to test this condition.

Change-Id: I95b7d9d753c17e4b76218a9845aa63dd1b96a500
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/235645
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-12-15 22:44:28 +00:00