Commit Graph

303 Commits

Author SHA1 Message Date
Vincent Palatin
4e39404604 ectool: increase image capture delay to 200ms
the current 50ms delay between the capture and having the image
available was working (to some definition of it) on the current boards,
but we hit issues on the next revision of the board with new sensor
silicon (and somewhat different delay), let's put a larger 200ms delay.
This will be converted to waiting for the proper MKBP event (aka
EC_MKBP_FP_IMAGE_READY) when all the boards using this feature will have
MKBP events support validated.

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

BRANCH=none
BUG=b:71770455
TEST=run 'ectool --name=cros_fp fpcheckpixels' on different boards.

Change-Id: Id1f2402ef85c903744054b00eeab0086221b4d7b
Reviewed-on: https://chromium-review.googlesource.com/888738
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
2018-01-26 16:12:08 -08:00
Nicolas Boichat
e5c6f97d1a charge_state_v2: Basic dual-battery charging algorithm
First version of the algorithm, some TODOs are left in the code
but this, generally, works reasonably well.

When charging, we allocate input current in this general order:
 - Base system (fixed, low, number)
 - Lid system (based on PSYS)
 - Lid battery (estimating how much current the battery actually
   requires)
 - Base battery (similar estimation)
 - Provide everything else to lid

When discharging, we generally:
 - First discharge the base battery
 - Then discharge the lid battery

BRANCH=none
BUG=b:71881017
TEST=Flash lux and wand, EC-EC communication works, adapter power
     is split in a sensible way, and discharging works fine.

Change-Id: I8a4f87963962fc5466b2fedf1347eb4dadd35740
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/659460
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-26 13:25:38 -08:00
Vincent Palatin
b16f759652 ectool: use poll interface
Test polling for MKBP events through the kernel cros_ec/pd/fp/.. driver
node.

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

BRANCH=none
BUG=b:69460856
TEST=run on Eve EVT:
ectool --name=cros_fp fpmode fingerdown && \
ectool --name=cros_fp waitevent 5 10000

Change-Id: Ibdec137a3b646cf017a29afcf24ff5bbfb731198
Reviewed-on: https://chromium-review.googlesource.com/806167
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-23 05:25:08 -08:00
Vincent Palatin
96a7e9fe81 fpsensor: update interface
Update the FP MCU interface to include a few convenient diagnostics
functions for factory testing.

It's mostly backward compatible, but overall this interface never
shipped in anything, so not a big deal regardless.

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

BRANCH=none
BUG=b:71986991
TEST=ectool --name=cros_fp fpinfo && ectool --name=cros_fp fpcheckpixels
CQ-DEPEND=CL:*546799

Change-Id: Ic641f891ace02d79af9339cf6cb59a2960e506a7
Reviewed-on: https://chromium-review.googlesource.com/873924
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-23 05:25:08 -08:00
Daisuke Nojiri
ead2428e91 CBI: Allow get command to reload data from EEPROM
This patch adds CBI_GET_RELOAD flag to EC_CMD_GET_CROS_BOARD_INFO
command. When the flag is set, the command will be forced to read
data from EEPROM even, ignoring the data cached by the previous
read.

This allows ectool to verify a write was successful without reboot.

BUG=b:70294260
BRANCH=none
TEST=ectool cbi set 0 0x1234 && ectool cbi get 0 1

Change-Id: I3e7ced5be56a74c605870a4c0622c0a2f47963bb
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/874155
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-18 20:18:11 -08:00
Daisuke Nojiri
bc4b786156 CBI: Add host command to set board info
This patch adds host command to write board information in EERPOM.

BUG=b:70294260
BRANCH=none
TEST=Run ectool cbi set <type> <value> to write BOARD_VERSION, OEM_ID,
and SKU_ID. Enable WP and verify cbi set command fails.

Change-Id: I39536d146313408ace666f350a107d89b331bf7a
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/865570
2018-01-18 05:09:31 -08:00
Daisuke Nojiri
5232cdd16b CBI: Add host command to get board info
This patch adds host command to get board info from EEPROM.

BUG=b:70294260
BRANCH=none
TEST=Run ectool cbi get <type> to get board version, OEM, SKU

Change-Id: I41a84d3eea6da9d88fa8122db36dcd1df515842d
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/865161
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-18 05:09:31 -08:00
Nicolas Boichat
e71899a573 ectool: battery: Allow negative present current
Battery interface over host command is different, as it allows
negative current values to indicate discharge, let's not fail in
that case.

BRANCH=none
BUG=b:65697620
TEST=ectool battery 1 does not fail when battery is discharging.

Change-Id: I89ca750e24706f55a0589201aeaf9fea50f3132f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/869552
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-17 06:20:38 -08:00
Vincent Palatin
9d38e46641 ectool: add servo v2 spi support
Add a new transport for ectool to send host command V3 over the Servo v2
SPI interface using libftdi.

Build this new communication mechanism only for the 'build' architecture
as it has a dependency on libftdi, the new ectool binary is called
ectool_servo.
Fix the 'build' tools build if they don't have a source file matching
their binary name.

The serial number of the servo board can be passed in the 'name'
parameter, e.g. :
sudo ectool_servo --name=905537-00474 version

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

BRANCH=none
BUG=b:70320279
TEST=with ZerbleBarn connected to a servo V2, run:
sudo ectool_servo version

Change-Id: Ia7067d465a42f76695fed5932f32fac9a6d0988e
Reviewed-on: https://chromium-review.googlesource.com/864164
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-17 06:20:37 -08:00
Nicolas Boichat
4c56c17a1a battery: Add support for reading base battery through host command
This adds support for EC_CMD_BATTERY_GET_STATIC and
EC_CMD_BATTERY_GET_DYNAMIC host commands, that can currently only
fetch the base battery information using index = 1.

In the future, all battery information can be passed to AP using
these host commands (i.e. lid could provide its own battery
information on index = 0).

BRANCH=none
BUG=b:65697620
TEST=ectool battery shows lid battery information (no change)
TEST=ectool battery 1 shows base battery information

Change-Id: Ib819e4917b3acc337348764f6cc2aa7380bed700
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/863863
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-14 18:38:29 -08:00
Hung-Te Lin
b9f78632fa ectool: Correct reporting fan numbers on fanless device.
`get_num_fans` tries to determine if fans are available according to
feature list, retrieved from an ec_command.

The ec_command today returns received output size on success, so to
we should not check the result by "rv == EC_SUCCESS".

Instead, we should check if rv returns a negative number, just like
the cmd_inventory.

BRANCH=none
BUG=b:71690953
TEST=(on fanless Eve) ectool pwmgetnumfans # see Fans=0
     ectool pwmgetfanrpm # see empty output, $?=0

Change-Id: Id748b70cec0afb0715febbda8883cd5ed53f7e3d
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/853755
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-08 22:42:09 -08:00
Gwendal Grignou
c49334f143 ec_commands: Add sync sensor
SYNC motion sensor are use to count event.
It sends an event to the AP each time a GPIO goes low/high, the datum
contains a 16 bit counter.
The location indicates the source of the event, as Android sensor hal
will use this information (via sysfs location attribute) to link the
sensor with other subsystem.

BUG=b:67743747
BRANCH=none
TEST=Unit tests.

Change-Id: Ia808b25730ad4100efa216c6a86b7b090197c5a3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848496
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-08 17:22:48 -08:00
Randall Spangler
7d2ce0c47e ec_commands: Remove zero-size structs
The size of empty structs (and unions) varies between C and C++.  When
including in C++ code our external API in ec_commands.h header with
extern "C".  clang will complain (correctly) for all empty structs:
       error: empty struct has size 0 in C, size 1 in C++
       [-Werror,-Wextern-c-compat]

Remove them from the ec_commands.h header file.

ectool.c has some ugly macros which assume subcommands have both
requests and responses.  Change those macros so they only reference
the non-empty sub-structs.  The macros are still ugly, but generate
identical output, and don't rely upon zero-length structs.

BUG=chromium:792408
BRANCH=none
TEST=manual

	1) Compile the following using 'clang -Wall -Werror':

	   #include <stdint.h>
	   extern "C" {
	   #include "include/ec_commands.h"
	   }
	   int main(void) { return 0; }

	   It compiles without error.

	2) Copy the lb_command_paramcount, ms_command_sizes, and
	   cs_paramcount globals from ectool.c to a dummy .c file and
	   compile with 'gcc -S' to generate assembly.  Do the same
	   after applying this patch.

	   Confirm the arrays have the same contents.

Change-Id: Iad76f10315b97205b42118ce070463071fe97128
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/820649
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-12-13 12:33:37 -08:00
YB.Ha
47a6acca3a motion: Add bh1730 as a motion sensor
- Add ROHM ambient light sensor driver
    - Add als sensor to motion sensors

    BRANCH=glados
    BUG=b:67022366
    TEST=This driver is tested in caroline
    Signed-off-by: yb.ha <ybha@samsung.com>

Change-Id: Ic73c50e17b412975f7850b7348ce310180f7a6eb
Reviewed-on: https://chromium-review.googlesource.com/784659
Commit-Ready: YongBeum Ha <ybha@samsung.com>
Tested-by: YongBeum Ha <ybha@samsung.com>
Reviewed-by: Gwendal Grignou <gwendal@google.com>
2017-12-08 00:37:03 -08:00
Daisuke Nojiri
b26f023631 ectool: Add switch-slot option to reboot_ec command
This patch adds switch-slot option to reboot_ec command. When the
option is specified, it'll make EC switch the active RW slot
before reboot.

BUG=b:69921268
BRANCH=none
TEST=Run ectool reboot_ec cold switch-slot and verify the active
slot is switched.

Change-Id: Iec568be36e6010ed9a51aa768a7f35e4a63f0fc0
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/809944
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-12-06 14:28:58 -08:00
Nicolas Boichat
bce7b5b4b6 ectool: Print temperature unit in ectool temps output
Currently, 'ectool temps all|<n>' just prints "300". This may easily
be mistakenly read as tenth of degree C (30.0 C), as the value
appears to make sense (close to room temperature). However, the value
is actually 300 K (27 C).

CQ-DEPEND=CL:763578
BRANCH=none
BUG=chromium:783845
TEST=ectool temps all shows temperature unit (K)

Change-Id: I70f7f04d061cb1d4f741d59f8b48c7963dd8280f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/763996
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-11 12:13:42 -08:00
Shawn Nematbakhsh
7c2c5a9dc3 pd: Add "freeze" dual-role policy
Add a new DRP policy to "freeze" the power role of each port, never
toggling automatically, though manual role swaps may still occur.

BUG=chromium:769895
BRANCH=servo
TEST=On servo_v4, verify DUT port stays in SRC role and POWER port
stays in SNK role while disconnected.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ibff3cd1ffaf0e884b030c231003763a57acbe02e
Reviewed-on: https://chromium-review.googlesource.com/715276
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-10-19 12:56:42 -07:00
Patrick Georgi
f1e6af516c util/ectool.c: Make sure device_name is NUL terminated
BRANCH=none
BUG=none
TEST=none

Found-by: Coverity Scan #144116
Change-Id: I9ec030c1a3820af7d08c2a83e3c1f4c3ee7a3f0a
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/702302
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Chris Ching <chingcodes@chromium.org>
2017-10-09 03:06:27 -07:00
Jagadish Krishnamoorthy
49958cf5c2 vboot: Modify the parameter offset
For the Host Command vboot hash EC_VBOOT_HASH_GET case,
if the input parameter offset and size is 0 then change
offset to data_offset to obtain the latest hash value.
Else retain the offset to get the hash value at offset.

BUG=b:66957716
BRANCH=NONE
TEST=On Soraka, ectool echash commands
(RO, RW) should result in hash information.

Change-Id: Ife17d35b0dfeecb5ec799c9ed722ae48dbec5b5b
Signed-off-by: Jagadish Krishnamoorthy <jagadish.krishnamoorthy@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/685738
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2017-09-27 19:03:03 -07:00
Daisuke Nojiri
4dcee1c545 EFS: Add support for early firmware selection
Chromebox ECs performs EFS: verifying firmware before the AP boots.
This patch updates host commands which are required for the EFS.

The change includes:
* Update EC_CMD_FLASH_REGION_INFO to accept EC_FLASH_REGION_UPDATE
* Update EC_CMD_VBOOT_HASH to accept EC_VBOOT_HASH_OFFSET_UPDATE

When EC_FLASHS_REGION_UPDATE is specified, EC_CMD_FLASH_REGION_INFO
returns the slot which currently is not hosting a running RW copy.

When EC_VBOOT_HASH_OFFSET_UPDATE is specified, EC_CMD_VBOOT_HASH
computs the hash of the update slot. This hash covers the entire
region, including the signature at the end.

This patch undefines CONFIG_CMD_USBMUX and CONFIG_CMD_TYPEC
for gru to create space.

BUG=b:65028930
BRANCH=none
CQ-DEPEND=CL:648071
TEST=On Fizz, verify:
1. RW_B is old and updated by soft sync. RW_B is activated and
   executed after reboot. System continues to boot to OS.
2. RW_A is old and updated by soft sync. RW_A is activated and
   executed after reboot. System continues to boot to OS.

Change-Id: I9ece907b764d07ce94054ba27996e048c665a80a
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/648448
2017-09-12 01:11:59 -07:00
Wei-Ning Huang
25d281a42b ectool: do not try other communication methods for none cros_ec devices
There are none cros_ec devices running EC codebase connected to
chromebook, which can be accessed by ectool with
`cros_ec --name=SOME_DEV ...`.

In the case when SOME_DEV is not found, do not fallback to other
communication methods such as LPC or I2C, since ectool will instead get
the reply of real cros_ec device.

BRANCH=none
BUG=b:64468324
TEST=on poppy, `ectool --name=cros_tp version` should show:
     `Unable to establish host communication
      Couldn't find EC`

Change-Id: I2ac232122e0f928703f7607da365d5c1dc6f7194
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/604977
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-08 10:09:18 -07:00
Caveh Jalali
10dab9c7dd ectool: add PD_CHIP_ON support.
this adds CLI support for the new PD_CHIP_ON subcommand of
ec_pd_control_cmd.

TEST=rebuilt ectool to see if "ectool pdcontrol on" does something useful.
	copied new build to electro:

	ec> i2cxfer rlen 0 0x50 1 0x10
	Unknown error
	Usage: i2cxfer r/r16/rlen/w/w16 port addr offset [value | len]
	ec>

	ap$ /tmp/ectool pdcontrol on 0

	ec> i2cxfer rlen 0 0x50 1 0x10
	Data: aa2934ad000000000000010000050500
	ec>

	so, "pdcontrol on" had the desired effect of bringing the chip
	out of sleep mode.

BRANCH=none
BUG=b:35586895

Change-Id: I5275254fe797dda921a352b72f1683e1967efe58
Signed-off-by: Caveh Jalali <caveh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/599361
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-03 19:23:13 -07:00
Shawn Nematbakhsh
2f09d4adea power: Allow host to request higher-power wakeable S3
Allow host to request a higher-power S3 variant, "wakeable S3", in which
more wakeup sources will be enabled by the EC. The actual implementation
and list of wake sources is left up to the chipset power driver and/or
board code.

BUG=b:63037490
BRANCH=gru
TEST=With subsequent commit, compile on scarlet w/ power sequencing
version = 2.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I469f0cd969052f173cb176196bb6d05f6f76fdb5
Reviewed-on: https://chromium-review.googlesource.com/572210
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Philip Chen <philipchen@chromium.org>
2017-07-28 15:04:24 -07:00
Aseda Aboagye
993a0991d6 driver: tcpm: ps8xxx: Add support for PS8805.
This commit adds support for the PS8805, another Parade Tech TCPC with
integrated superspeed muxes.  This also creates a generic Parade Tech
TCPC driver which supports the PS8xxx series.

The current supported TCPCs are:
  - PS8751
  - PS8805

BUG=b:63508740
BRANCH=None
TEST=`make -j buildall`

Change-Id: I78383af414996e0e8d6220985d286f95267136f8
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/564799
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-07-11 13:13:03 -07:00
Furquan Shaikh
5ed0e0f76f button: Implement emulated debug mode using buttons for detachables
BUG=b:36394093
BRANCH=None
TEST=make -j buildall. Verified following actions:
Vup+Vdn (10 seconds) --> Vdn --> Vup : Warm reset AP
Vup+Vdn (10 seconds) --> Vdn -> Power: Exit debug state

Vup+Vdn (10 seconds) --> Vup --> Vdn : Restart chrome
Vup+Vdn (10 seconds) --> Vup --> Power : Exit debug state

Vup+Vdn (10 seconds) --> Vup --> Vup --> Vdn : No action defined
Vup+Vdn (10 seconds) --> Vup --> Vup --> Power: Exit debug state

Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Vdn : Kernel panic
Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Power: Exit debug state

Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Vup: Exit debug state
Vup+Vdn (10 seconds) --> Vdn --> Vdn : Exit debug state

Change-Id: Ic49cc7463f6d8a00f3b4586754feeb3a7d23c371
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/520564
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-15 01:48:26 -07:00
Wei-Ning Huang
e237092ee9 ectool: fix command tpframeget return value
ec_command returns the length of response if there is no error. Fix the
return value so tpframeget sub command returns 0 on success.

BRANCH=none
BUG=b:62077098
TEST=`make BOARD=rose -j`

Change-Id: I87288a3efcca75dacebae784e731e314e97017ad
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/527766
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2017-06-09 09:16:27 -07:00
Wei-Ning Huang
5b1d2b878d rose: add touchpad related host commands
Add touchpad related host commands:
1) EC_CMD_TP_SELF_TEST: run open short test.
2) EC_CMD_TP_FRAME_INFO: get number of frame and frame size.
3) EC_CMD_TP_FRAME_SNAPSHOT: make a snapshot of the frame.
4) EC_CMD_TP_FRAME_GET: get frame data.

BRANCH=none
BUG=b:62077098
TEST=`make BOARD=rose -j`
     `ectool --name=cros_tp tpselftest` and
     `ectool --name=cros_tp tpframeget` works

Change-Id: I43db82278e556b1e6f6301fe88233fe7c4a18a14
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/515282
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2017-06-07 05:22:56 -07:00
Vincent Palatin
563456c658 eve_fp: add more fingerprint host commands
Move the existing fingerprint host command in the driver and
add more of them to prepare the new fingerprint architecture.
The commands are mostly stubbed for now.

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

CQ-DEPEND=*364728
BRANCH=none
BUG=b:35648259
TEST=make BOARD=eve_fp (with and without a private repository)
do a fingerprint image capture with 'fptest'.

Change-Id: Ie17a5fde2d6470c6272e8059bddc845cea07aff2
Reviewed-on: https://chromium-review.googlesource.com/491071
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-05-23 05:57:13 -07:00
Nick Vaccaro
9a0d0aa70d common: sensors: add extra sensor attributes
Adds min_frequency and max_frequency to struct motion_sensor_t.

New attributes min_frequency and max_frequency are now returned in
ectool's MOTIONSENSE_CMD_INFO response.

Incremented ectool's MOTIONSENSE_CMD_INFO version to version 3.

Add constants for MIN_FREQUENCY and MAX_FREQUENCY to each sensor's
header file.

BRANCH=none
BUG=chromium:615059
TEST=build/boot and verify MOTIONSENSE_CMD_INFO response on kevin,
make buildall -j passes.

Change-Id: I66db9715c122ef6bb4665ad5d086a9ecc9c7c93a
Signed-off-by: Nick Vaccaro <nvaccaro@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/482703
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-05-18 21:05:23 -07:00
Wei-Ning Huang
fc562bbf9b rwsig: expose a new feature bit when RWSIG task is enabled
Expose EC_FEATURE_RWSIG if RWSIG task is enabled. This allows flashrom
to run EC_CMD_RWSIG_ACTION and abort RWSIG jump, then perform regular
firmware update flow.

BRANCH=none
BUG=b:37584134
TEST=on eve, `ectool --name=cros_tp inventory` should show 'RWSIG task'.

Change-Id: Iea14f4f01fab201767dccd07d711ae9e1b638f6a
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/497788
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-05-11 05:31:53 -07:00
Wei-Ning Huang
a5a3fa2d13 rwsig: add host command for controlling rwsig task
Add new host command EC_CMD_RWSIG_ACTION for controlling rwsig task.
This allow us to make firmware stay at RO without toggling reset pin.
flashrom can use this host command and removed the need to use any
out-of-band pin to toggle the reset pin (and make RWSIG stay in RO).

BRANCH=none
BUG=b:37584134
TEST=on eve, `ectool --name=cros_tp rwsigaction abort` should prevent EC
     from jumpping to RW after RWSIG check.

Change-Id: Ia435e4e3ea8ed612a1250d3bf755ca50e5db9d37
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/497787
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-05-06 19:52:29 -07:00
Furquan Shaikh
2bb9aec01a common/led_common: Add API for controlling LED state
1. Provide led_control API that can be used by different drivers to
control the state of LED (0=off, 1=on, 2=reset)
2. Add a new LED ID for recovery HW_REINIT indication.

BUG=b:37682514
BRANCH=None
TEST=make -j buildall

Change-Id: I27334bde2b879046746456a610208f3fc2dd68b4
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/487840
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-05-02 17:45:16 -07:00
Wei-Ning Huang
a12bf17be9 common: add feature bit for touchpad support
Add a new 'feature' bit to allow the host to auto-detect a TP MCU.

Signed-off-by: Wei-Ning Huang <wnhuang@google.com>

BRANCH=none
BUG=b:37584134
TEST=on eve with TP connected, look at the feature bit.

Change-Id: I81b30b96b31fc8dcb6769dd146fb33cdd487fddf
Reviewed-on: https://chromium-review.googlesource.com/485422
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-04-27 06:38:15 -07:00
Wei-Ning Huang
4bc509b060 rwsig: add host command for getting rwsig status
Add a new host command EC_CMD_RWSIG_CHECK_STATUS for getting rwsig
status and rw firmware hash.  This command is used to check the RW
signature of newly updated RW image.

A new subcommand is also added to ectool.

BRANCH=none
BUG=b:37584134
TEST=on rose board `ectool rwsigstatus` works

Change-Id: I33d8709f5248d3a4b8bedb36ded84a93dc8c971f
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/485079
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-04-27 06:38:14 -07:00
Vincent Palatin
253366b3af ectool: fix fan commands for older EC
When invoking ectool fan commands on older ECs not supporting
EC_CMD_GET_FEATURES, the tool is choking on the lack of the command at
the beginning of get_num_fans() and not going further.
The regression was introduced by
https://chromium-review.googlesource.com/c/359069/, let's go back to the old
behavior for machines without feature bits and skip the
EC_FEATURE_PWM_FAN check.

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

BRANCH=none
BUG=b:35575890
TEST=on Buddy, run 'ectool pwmgetnumfans' and 'ectool pwmgetfanrpm all'
and get results.

Change-Id: Ie9255d4afc9fa95a55807c310e9593a28c2aadc1
Reviewed-on: https://chromium-review.googlesource.com/456598
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-03-18 14:24:51 -07:00
Vincent Palatin
e86a0dad24 ectool: support FP MCU device node number
Some people love to address the EC device nodes by number with ectool,
add the special offset for the FP MCU (e.g. '--dev=8').
Addressing it by name already works (e.g. '--name=cros_fp').

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

BRANCH=none
BUG=b:35648259
TEST=on Eve, execute 'ectool --dev=8 version'
and see a similar result to 'ectool --name=cros_fp version'
e.g. "RO version:    eve_fp_v1.1.6177-945b19f+ [...]"

Change-Id: Ic08e3b7a3ae31b7e1b73bccc8375badf3284b49c
Reviewed-on: https://chromium-review.googlesource.com/453179
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2017-03-16 00:11:42 -07:00
Duncan Laurie
35387474a1 led: Add options for left and right led
Add LED types for left and right so they can be addressed
properly with ectool.

BUG=b:36150361
BRANCH=none
TEST=manual testing of 'ectool led <left|right> <color>' behavior

Change-Id: Iea25cc69db2d35416e787dcb5a324d2e2cf5d3a6
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/453126
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2017-03-13 19:58:51 -07:00
Daisuke Nojiri
ad089de4b0 pdcontrol: Suspend port individually
pdcontrol suspend command will be used to prevent tcpm from putting
the chip into sleep while firmware update is taking place. Currently
the command suspends or resumes port 0. This patch makes the command
apply to ports individually.

pd enable console command now takes a port number:
pd <port> enable/disable.

This patch also replaces CONFIG_USB_PD_COMM_ENABLED with _DISABLED.
When it's defined, PD communication is disabled at startup.

Plankton undefines CONFIG_USB_PD_COMM_ENABLED enable, intending to
disable PD communication at startup. Therefore, this patch defines
CONFIG_USB_PD_COMM_DISABLED in its board.h.

BUG=b:35586859
BRANCH=none
TEST=From AP console:
localhost # /tmp/ectool pdcontrol suspend 1
[600.188013 TCPC p1 suspended!]
> pd 1 state
Port C1 CC1, Dis - Role: SNK-UFP State: SUSPENDED, Flags: 0x0020
localhost # /tmp/ectool pdcontrol resume 1
[678.516613 TCPC p1 resumed!]
> pd 1 state
Port C1 CC1, Ena - Role: SNK-UFP State: DRP_AUTO_TOGGLE, Flags: 0x0020
From ec console:
> pd 1 disable
Port C1 disable
> pd 1 state
Port C1 CC1, Dis - Role: SNK-UFP State: DRP_AUTO_TOGGLE, Flags: 0x0020
> pd 1 enable
Port C1 enabled
> pd 1 state
Port C1 CC1, Ena - Role: SNK-UFP State: DRP_AUTO_TOGGLE, Flags: 0x0020

Change-Id: Ia0cc4904ac52adc4b89de20918968c8df78b9c80
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/447968
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-03-07 14:15:56 -08:00
Nicolas Boichat
2dcfd2446c flash: Add ROLLBACK flash region, that can be protected separately
ROLLBACK region will be used to store rollback information, and
can be protected independently of RW (it can only be protected when
RO is protected, though).

This is only supported on stm32f0 currently.

BRANCH=none
BUG=chrome-os-partner:61671
TEST=on hammer (stm32f072)
     flashinfo => RO+RW not protected
     flashwp true; reboot => only RO protected
     flashwp all; reboot => RO+RW+RB protected
     flashwp noall; reboot => only RO protected
     flashwp rw; reboot => only RO+RW protected
     flashwp rb; reboot => RO+RW+RB protected
     flashwp norb; reboot => RO+RW protected
     flashwp all; reboot => RO+RW+RB protected
     flashwp norw; reboot => RO+RB protected
TEST=on reef, rb/norb commands not available

Change-Id: I45ffc66d91cf3699ecff025e5114c59a73dc8274
Reviewed-on: https://chromium-review.googlesource.com/430519
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-25 08:36:41 -08:00
Nicolas Boichat
83cf8d0a7a flash: Add EC_FLASH_PROTECT_RW_[AT_BOOT|NOW] flags
The idea of this flag is to be able to protect/unprotect only the
RW portion of the flash. In the (usual) case where ALL=RO+RW, with
no other region, this makes no difference compared to the existing
EC_FLASH_PROTECT_ALL_* flag, and this flag may not be supported.

This is necessary for futher work, where a ROLLBACK region is added,
so that RW/ROLLBACK can be protected/unprotected individually.

Only support for stm32f0 is added, as this is the target for hammer.

BRANCH=none
BUG=chrome-os-partner:61671
TEST=build and flash hammer (stm32f072)
     flashinfo => RO+RW not protected
     flashwp true; reboot => only RO protected
     flashwp all; reboot => RO+RW protected
     flashwp noall; reboot => only RO protected
     flashwp rw/norw not available
TEST=enable CONFIG_FLASH_PROTECT_RW
     build and flash hammer (stm32f072)
     flashinfo => RO+RW not protected
     flashwp true; reboot => only RO protected
     flashwp all; reboot => RO+RW protected
     flashwp noall; reboot => only RO protected
     flashwp rw; reboot => RO+RW protected
     flashwp norw; reboot => only RO protected
TEST=build and flash reef (npcx)
     flashinfo => RO+RW not protected
     flashwp true => RO protected
     flashwp all; flashinfo => all_now displayed
     reboot => RO protected
     flashwp rw/norw not available

Change-Id: Ica6f499cf2e8a9345b08ef52c915655a983ffe3c
Reviewed-on: https://chromium-review.googlesource.com/442265
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-02-23 19:06:16 -08:00
Gwendal Grignou
484ef12119 motion: Add opt3001 as a motion sensor
Use the motion sensor to manage ALS as well.
The current interface (via memmap) is preserved, but
we can also access the sensor via cros ec sensor stack and
send the ALS information to ARC++.

BUG=chrome-os-partner:59423
BRANCH=reef
CQ-DEPEND=CL:424217
TEST=Check the sensor is working via ACPI sensor and
cros ec sensor. Check ARC++ sees the sensors.

Change-Id: Iaf608370454ad582691b72b471ea87b511863a78
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/424323
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-02-16 18:03:59 -08:00
Daisuke Nojiri
4d6eb1bc01 pdchipinfo: Add option to force renewal
This change adds an option to pdchipinfo command to force ec to get
the version from the chip instead of the cache (if it's available).

This option will be used after firmware update, which makes the cache
value stale.

BUG=chrome-os-partner:62383
BRANCH=none
TEST=Run ectool as follows:
localhost ~ # /tmp/ectool pdchipinfo 0 on
vendor_id: 0xaaaa
product_id: 0x3429
device_id: 0xad
fw_version: 0x15
localhost ~ # /tmp/ectool pdchipinfo 1 on
EC result 2 (ERROR)

Change-Id: Icefe96d7fc1208b991a4caa13aaf4f04052edba7
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/441271
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-14 17:28:16 -08:00
Daisuke Nojiri
c9ea4bddbc pdchipinfo: Increase compatibility of fw_version
The firmware version formats may vary chip to chip. fw_version field is
changed to a union of a 8 byte string and an 64-bit integer.

BUG=chrome-os-partner:62383
BRANCH=none
TEST=ectool pdchipinfo 0/1 on Electro

Change-Id: Id51e66c44338a09ed897ee61f54cd6a394400e63
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/441270
2017-02-14 17:28:15 -08:00
Daisuke Nojiri
4ff544a573 Add host command to get PD chip information
This patch adds a host command to get PD chip info.

For PS8751, tcpci_get_chip_info will fail if the chip is in
low power mode. It can be woken up by reading a random register
first then wait for 10ms.

This code doesn't have the wake-up read to avoid 10ms delay.
Instead, we call this function immediately after the chip is
initialized because it'll gurantee the chip is awake.

Once it's called, the chip info will be stored in cache, which
can be accessed by tcpc_get_chip_info without worrying about
chip states.

localhost ~ # ectool pdchipinfo 0
vendor_id: 0xaaaa
product_id: 0x3429
device_id: 0xad
fw_version: 0x15

localhost ~ # ectool pdchipinfo 1
vendor_id: 0x1da0
product_id: 0x8751
device_id: 0x1
fw_version: 0x37

BUG=chrome-os-partner:62383
BRANCH=none
TEST=ectool pdchipinfo 0/1. make buildall

Change-Id: I3f1667d00ce1826936d90882ada1df6ed6b0ea37
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/433166
2017-02-09 22:50:50 -08:00
Aseda Aboagye
b3a9e1b64c motion_sense: Add "spoof" mode
This commit adds a "spoof" mode feature to the motionsense stack.  It
allows the user to arbitrarily set the outputs of the sensor in order to
"spoof" the readings of the sensor.  This can be useful in emulating
tablet mode or device rotations.  A command is available from the EC
console named `accelspoof` and there is a corresponding motionsense
command in ectool called `spoof`.

The usage is as follows:

- EC console
 > accelspoof [id] [on/off] [X Y Z]

- ectool
 # ectool motionsense spoof -- [id] [0/1] [X Y Z]

If on or off(or 0/1) is not specified, the current spoof mode status of
the sensor is returned.  If on is specified, but no components are
provided, the sensor will lock the current values and provide those as
the spoofed values.  If the components are provided, those will be used
as the spoofed values.

BUG=chromium:675263
BRANCH=cyan,glados,gru,oak
TEST=Flash a DUT with accels.  From AP console, run `ectool motionsense
lid_angle` in a loop, use 'accelspoof' EC console command to set spoofed
values.  Verify that the angle is fixed regardless of the actual angle
of the DUT.
TEST=Flash a DUT with accels.  From AP console, use `ectool motionsense
spoof` to spoof values and verify that `ectool motionsense` reflects the
spoofed values.  Test with both provided component values and no
component values.

Change-Id: Ie30688d22f38054e7243b1af493a3092b2cdfb72
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/421280
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-01-07 13:29:52 -08:00
Shawn Nematbakhsh
c6c5a44674 util/ectool: Fix llvm compiler errors
BUG=chromium:668259
BRANCH=None
TEST=Manual on samus (w/ gcc-built ectool).
Verify 'ectool pause_in_s5 [on|off]' followed by 'ectool pause_in_s5'
reflects the new updated state.
Verify 'ectool --name=cros_pd flashpd 0 1 ec.RW.bin' succeeds to flash
valid zinger RW image.
Also verify `emerge-nyan_big ec-utils` succeeds w/ new llvm toolchain.

Change-Id: Ibe83ee0fc0b2e6f535ed822603f438ed62350d29
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/419797
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-12-16 23:47:03 -08:00
Manoj Gupta
2228b76f74 Fix EC build for latest llvm
llvm bug: https://llvm.org/bugs/show_bug.cgi?id=31050 is now fixed
So remove unnecessary pointer casts.

BRANCH=none
BUG=chromium:665240
TEST=Builds now

Change-Id: I5695a9605b5ab47d11f7e9ecacc52f2ba53385e7
Reviewed-on: https://chromium-review.googlesource.com/412880
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
2016-11-20 00:24:27 -08:00
Manoj Gupta
b2bc234197 Fix EC build for latest llvm
BRANCH=none

util/ectool.c:1158 merror: taking address of packed member 'size' of class
or structure 'ec_params_usb_pd_fw_update' may result in an unaligned
pointer value [-Werror,-Waddress-of-packed-member]

For this case, the pointer is always aligned but clang complains.
Workaround using double pointer casts to char and uint.

       uint32_t *data = &(p->size) + 1;

BUG=chromium:665240
TEST=Builds now

Change-Id: Ibccf0f6e409b9724fc9e5acf28dde570e9d341e3
Reviewed-on: https://chromium-review.googlesource.com/411384
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
2016-11-16 07:10:41 -08:00
Gwendal Grignou
16ab1b69c6 util: ectool: Add names for new sensors.
Match ec_commands.h, adding new type and sensors.

BUG=none
BRANCH=reef
TEST=Check on Reef that barometer sensor info is displayed properly.

Change-Id: I257f5161e5f57be562a2b3a29442b49f47f3fc89
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/394749
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-10-08 18:34:43 -07:00
Gwendal Grignou
e40fb3ef58 util: Fix fifo_info when lost vectors are present
Due to an error in ms_command_sizes, fifo_info command
would fail when lost vectors are present:
packet too long (16 bytes, expected 10)
Reorder ms_command_sizes commands properly.
Get the number of sensors present before printing the number of lost
vectors per sensor.

BUG=none
BRANCH=none
TEST=On cave (with broken MKBP support), check fifo_info
is returning the lost vectors count.

Change-Id: Ic745eb762563705372d8a670ce34eab15e188bf9
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/391887
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-10-05 04:03:19 -07:00