Commit Graph

288 Commits

Author SHA1 Message Date
Vadim Bendebury
afaaba44f1 cr50: Extended command test utility
The utility builds on the extended command protocol recently
introduced in the EC and allows to test implementation of various
cryptographic primitives available on CR50.

This patch brings in the ftdi_spi_tpm.c and mpsse.c from the AOSP
trunksd package. mpsse.c has been modified to limit its feature set
(no i2c or bigbang support, only SPI0 mode), and ftdit_spi_tpm.c has
been modified to properly present binary strings to the Python swig
wrapper.

The crypro_test.xml file includes descriptions of the tests to perform
on the target. Most of its contents other than the first crypto_test
element are borrowed from NIST AES test vectors set. See file header
for description of the contents format.

The actual test command is the tpmtest.py. When started it establishes
connection with the device, and then reads test vectors from
crypto_test.xml and executes them one at a time.

Starting the test program with the -d command line argument enables
debug output sent to the console.

There are some other programs in ./extras which use the mpsse.c from
AOSP, they will have to be modified to use the local copy.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=ran the following in the directory:
   $ make  # output suppressed
   $ ./tpmtest.py
   Starting MPSSE at 800 kHz
   Connected to device vid:did:rid of 1ae0:0028:00
   \New max timeout: 1 s
   SUCCESS: AES:ECB common
   SUCCESS: AES:ECB128 1
   SUCCESS: AES:ECB192 1
   SUCCESS: AES:ECB256 1
   SUCCESS: AES:ECB256 2
   SUCCESS: AES:CTR128I 1
   SUCCESS: AES:CTR256I 1

  - temporarily corrupted the contents of the clear_text element of 'AES:ECB common':
  $ ./tpmtest.py
  Starting MPSSE at 800 kHz
  Connected to device vid:did:rid of 1ae0:0028:00
  |
  Out text mismatch in node AES:ECB common, operation 1:
  In text:
  74 68 69 73 20 20 69 73 20 74 68 65 20 74 65 78
  74 20 77 68 69 63 68 20 77 69 6c 6c 20 62 65 20
  65 6e 63 72 79 70 74 65 64 20 69 66 20 65 76 65
  72 79 74 68 69 6e 67 20 69 73 20 67 6f 69 6e 67
  20 66 69 6e 65 2e 20
  Expected out text:
  3d e2 0f f9 ee d9 62 ce f0 8a 17 57 c6 04 86 d0
  3d ec 44 72 d8 79 18 87 3f 31 81 6d 66 4c bb 10
  da 8d e0 9f 63 67 b3 cc 64 b4 e8 bd 12 b0 a9 c9
  09 6d f0 9f a4 e2 ae fb 0d fe 1c 90 6c e2 fe f0
  68 8f b5 34 07 76 e2 a9 72 8e dd 7b 8b 52 2b 8b
  Real out text:
  f9 50 fe 93 c9 3f cb e5 9e e0 a4 7e 51 1a bb a0
  36 2f d1 d6 5f a8 1d 22 5a 1a bb f7 e6 65 89 55
  ad e8 f5 8f 1a 20 ff a5 c4 de 76 3e b8 ef cc 8d
  9d 94 b8 89 22 1c c9 2a 43 58 c3 8c 75 9f 9f 56
  ab 2f 89 1a f6 a0 36 8b 95 23 91 d6 23 47 77 36

Change-Id: I2687ac03236b528e71b92df7cb35606e473ab2c5
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313443
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-11-21 13:12:18 -08:00
Gwendal Grignou
420099f749 motion: Change units of ec_rate from us to ms.
To ease finer calculation of ec rate change units from
ms to us.

BRANCH=smaug
BUG=b:24367625
TEST=compile

Change-Id: I52057c8ca1b1180a64b58d1ba0af9ec53f40b026
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312984
2015-11-18 13:33:27 -08:00
Gwendal Grignou
0922cc81ce motion: cleanup include file
Use test_export_static for static variable/function that needs to by
used by tests/motion_lid.c

BRANCH=smaug
BUG=none
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>
2015-11-12 23:12:33 -08:00
Shawn Nematbakhsh
2431602575 cleanup: Standardize use of CONFIG_I2C and add MASTER/SLAVE CONFIGs
Some chips previously defined CONFIG_I2C and others didn't. Standardize
the usage by removing CONFIG_I2C from all config_chip files and force it
to be defined at the board level. Also, make boards define
CONFIG_I2C_MASTER and/or CONFIG_I2C_SLAVE based on the I2C interfaces
they will use - this will assist with some later cleanup.

BUG=chromium:550206
TEST=`make buildall -j`
BRANCH=None

Change-Id: I2f0970e494ea49611abc315587c7c9aa0bc2d14a
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/310070
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-11-03 09:08:21 -08:00
Alec Berg
a023d6b0c1 glados: oak: chell: enable USB PD logging
Enable USB PD logging.

BUG=chrome-os-partner:45933
BRANCH=none
TEST=make -j buildall
make -j BOARD=glados tests
Load on glados and test that PDLOG events show up in dmesg

Change-Id: I61dbc5019ea3228542c2c244228bbb483cf51ead
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309881
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-10-30 17:51:20 -07:00
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
Shawn Nematbakhsh
2bd7dce32e charger: Add LIMIT_POWER charger param for low bat + weak charger
Add support for two new configs to specify critical energy battery
percentage and critical external charger power. When we are under both
thresholds, set the LIMIT_POWER charger parameter to inform the AP that it
should conserve power to avoid brownout, and consider jumping to EC RW
to negotiate PD.

In addition, modify the existing CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
to allow power-up regardless of power level if a 15W+ charger is
attached, since there is a reasonable chance it may speak PD and provide
sufficient power to boot the AP.

BUG=chromium:537269
TEST=Manual on Glados. Set CHG_MW thresh to 20000, BAT_PCT to 50. Verify
that LIMIT_POWER charger param is set until Zinger negotiates to 20V. Also
veify that system can boot with Donette.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic963c82fea4ad10e8a5d7e476c5ce3e5ae525dad
Reviewed-on: https://chromium-review.googlesource.com/306774
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-27 13:19:51 -07:00
Gwendal Grignou
81d269dc00 common: lightbar: Add histeresis to prevent flickering
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
BUG=chrome-os-partner:44400
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
2015-10-23 18:03:12 -07:00
Ryan Zhang
061abcea96 Lars: Init board
Preparing for new board, Lars
Copy kunimitsu setting to init board.

BUG=none
BRANCH=lars
TEST=Run "make -j BOARD=lars", "make -j BOARD=lars_pd" and
 "make buildall -j" to build code and ec.bin can be generated.

Change-Id: Ic0ab3e57679fc7ea98a7b73527ce2276e706db1d
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/305128
Commit-Ready: 志偉 黃 <David.Huang@quantatw.com>
Tested-by: 志偉 黃 <David.Huang@quantatw.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-22 19:16:16 -07:00
Alec Berg
8acea1ec39 glados_pd: oak_pd: add and enable option for i2c slave only
Add CONFIG_I2C_SLAVE_ONLY for boards that only operate as a slave
on i2c.

BUG=chrome-os-partner:41959
BRANCH=none
TEST=make BOARD=glados_pd and see 2kB flash savings

Change-Id: I30831ce48b391d985c25e266229d5c6f2312042b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/306783
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-10-19 15:15:36 -07:00
Duncan Laurie
84e27570e9 chell: Add EC/PD configuration for chell board
Add new EC board for chell proto:
- no motion sensors or tablet mode
- no independent volume buttons
- no ALS
- 2x PS8740 USB MUX
- apply PMIC_LDO_EN behavior by default
- leave SLP_S0 workaround in place until HW is updated
- misc GPIO changes
- update battery info with basic 3S config from blaze
- remove custom battery charger profile

The PD board is a symlink to glados as it appears to be the same.

BUG=chrome-os-partner:46289
BRANCH=none
TEST=make -j BOARD=chell ; make -j BOARD=chell_pd

Change-Id: I1084d663b06eeb55f035b10eb776a2e30e0f7074
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/304398
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2015-10-12 13:15:48 -07:00
Gwendal Grignou
ac234f05e0 test: motion_lid: reenable
After fixes CL:300630, motion_lid test is fixed:
motion_sense task was exiting during the tests.

BRANCH=smaug
BUG=chrome-os-partner:42855
TEST=motion_lid test now pass.

Change-Id: I7bc464fb2766684093de9b3e479fb5ac3718df04
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302861
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-29 19:38:21 -07:00
Gwendal Grignou
d0e1c2394c common: motion: Separate motion task interval from AP configuration
Some sensors are in forced mode, motion sense must be scheduled at
their ODR. However the host may not want the data right away,
so motion task may not wake up the host that often.

Add a new variable motion_int_interval that defines the maximum interval
between FIFO host event.

BRANCH=smaug
BUG=chrome-os-partner:43800
TEST=Check that light sensor is polled at ODR frequency.
Check that when AP does not want any event, no FIFO host event are
requested.
Check CTS tests work as before.
Reenable motion_lid unit test.

Change-Id: Ie25e6cbe28fed899073856057855ffa03c0cd9fd
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301134
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-09-29 19:38:21 -07:00
Alec Berg
5717b3150c motion: add config option to use the old accelerometer ref frame
Add config option to use the old accelerometer reference frame,
which is used on samus and products using 3.14 or earlier kernel.

This fixes samus so that the lid angle calculation is correct
again.

This also moves the accel_orientation structure out of the board
directory and into common code, since it purely is a function of
the reference frame being used.

BUG=chrome-os-partner:43494
BRANCH=none
TEST=test on samus, verify lid angle calculation is correct once
again. also, enable the motion_lid test and verify that it passes.

Change-Id: I948a74a71964b54c68be66e828a030ddd0418947
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/300510
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2015-09-17 19:00:53 -07:00
Gwendal Grignou
c2c02249a0 host: mock i2c_xfer
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
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>
2015-09-16 14:49:46 -07:00
Shawn Nematbakhsh
1167cad6a8 cleanup: Change meaning of storage offset CONFIGs
In order to support architectures with non-contiguous writable and
protected regions, change storage offsets to be relative to writable and
protected regions, rather than relative to "the start of the region of
storage belonging to the EC".

Spec doc available at https://goo.gl/fnzTvr.

BRANCH=None
BUG=chrome-os-partner:23796
TEST=With entire patch series, on both Samus and Glados:
- Verify 'version' EC console command is correct
- Verify 'flashrom -p ec -r read.bin' reads back EC image
- Verify software sync correctly flashes both EC and PD RW images

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I796f8e7305a6336495bd256a78774595cb16a2e4
Reviewed-on: https://chromium-review.googlesource.com/297823
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:32 -07:00
Shawn Nematbakhsh
d58e54730c cleanup: Rename geometry constants
Rename and add geometry constants to match spec doc -
https://goo.gl/fnzTvr.

CONFIG_FLASH_BASE becomes CONFIG_PROGRAM_MEMORY_BASE
CONFIG_FLASH_MAPPED becomes CONFIG_MAPPED_STORAGE

Add CONFIG_INTERNAL_STORAGE, CONFIG_EXTERNAL_STORAGE and
CONFIG_MAPPED_STORAGE_BASE where appropriate.

This CL leaves chip/npcx in a broken state -- it's fixed in a follow-up
CL.

BRANCH=None
BUG=chrome-os-partner:23796
TEST=With entire patch series, on both Samus and Glados:
- Verify 'version' EC console command is correct
- Verify 'flashrom -p ec -r read.bin' reads back EC image
- Verify software sync correctly flashes both EC and PD RW images

Change-Id: Idb3c4ed9f7f6edd0a6d49ad11753eba713e67a80
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297484
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:31 -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
Alec Berg
3963d3b77d charge_manager: ensure we source power when not charging
Move asking for a power swap to become a source to happen
anytime we stop charging from a dual-role port. We used to
ask for a power swap when a dual-role override port was
cancelled, but with CONFIG_CHARGE_MANAGER_DRP_CHARGING we
can be charging from a dual-role port without having chosen
it as the override port, so this guarantees that we always
ask to become the source when we stop charging from a port.

BUG=chrome-os-partner:44958
BRANCH=smaug
TEST=build and run unit tests

Change-Id: I009178b479a4626888d11a9993c8738d928fbaf9
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297880
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-08 21:58:21 -07:00
Alec Berg
ebfdb59702 charge_manager: add option to charge from dual-role devices
Add option to charge automatically from dual-role devices. This
also changes the charge override behavior such that any new
device attached will clear the override because any new source
is a potential device we might charge from.

BUG=chrome-os-partner:44958
BRANCH=smaug
TEST=tested charge_manager unittests with
CONFIG_CHARGE_MANAGER_DRP_CHARGING both defined and undefined

Change-Id: Iac77ff0c501826d5fb5a9d50f88399ebc3955b87
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297789
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-08 21:58:21 -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
Ben Lok
c2cf0fb198 oak: enable MBKP events for PD events
(refer to CL:273620) enable the MKBP event feature to send host event
and wire up the PD specific events.
But, CONFIG_MKBP_EVENT conflicts with CONFIG_KEYBOARD_PROTOCOL_MKBP,
due to the GPIO name of EC interrupt pin. Align the GPIO naming of EC
interrupt pin to EC_INT_L.

BRANCH=none
BUG=chrome-os-partner:44643
TEST=On Oak rev3, plug/unplug USB devices and add kernel trace to see
the PD events happening.

Change-Id: I10de9c6611583bb6165bdc1848e542d4b8bba954
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/296012
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-08-31 22:59:52 -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
0e01759ced math: Add inverse matrix calculation
Add a slow inverse matrix calculation function.
It is needed to apply factory offset properly.

Also consider the NULL matrix the identity matrix.

BRANCH=smaug,cyan
TEST=Unit test
BUG=chromium:517675

Change-Id: Ifa11954992e6f2fab02b4e92684e7b01bbaafe94
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/294594
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2015-08-24 19:08:20 +00:00
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