Commit Graph

367 Commits

Author SHA1 Message Date
Vic Yang
140aa36904 pd: Show literal PD state name for 'ectool usbpd'
Currently, 'ectool usbpd' shows PD task state in numerical format. Every
time we add/remove a state, the number changes, and this makes the
command difficult to use. Modify the command to print the name of the PD
task state.

BRANCH=Samus,Ryu
BUG=chrome-os-partner:34296
TEST=Run 'ectool usbpd 0' with different combination of new/old PD
firmware and new/old ectool.

Change-Id: Ic0daa03e9f7565c1322166713c2cce3b7cb93a30
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/237623
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
2015-01-07 17:48:15 +00:00
Shawn Nematbakhsh
35ea0a968c charge_manager: Bug fixes for power_info host commands
- Correctly identify certain source ports (ex. c-plug to empty a-receptacle)
- Correct ectool power unit print (mV * mA != mW).

BUG=chrome-os-partner:33248
TEST=Manual on Samus. Connect c-plug to empty a-receptacle, run
"ectool --name usbpdpower", verify that port power role is identified
as source. Also, verify that 5000 mV @ 500mA port correctly prints
2500mW total power.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Icf0850afc570a1056578df9f1a647079a00229b3
Reviewed-on: https://chromium-review.googlesource.com/238235
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2015-01-07 17:48:09 +00:00
Vic Yang
c3adc315b3 Support command versioning of new host command range
We've extended host command range from 8-bit to 16-bit. Extend
EC_CMD_GET_CMD_VERSIONS so that the host may query supported command
versions of the new host commands.

BRANCH=All
BUG=chrome-os-partner:26577
TEST=Extend 'usbpd' to version 1. Test that we can check its version.
TEST=Run 'ectool gpioget' with new ectool and old EC.
TEST=Run 'ectool gpioget' with old ectool and new EC.

Change-Id: I1651aaf21ac2604aea101244b5e53713ead8c1af
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/237622
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-01-06 02:33:04 +00:00
Vincent Palatin
9ce66a98b2 zinger: enable RO partition write-protection
Check the flash protection at startup, if the RDP is still at level 0
(no read protection) or if the RO partition is not write protected :
- set the write protection on the first 16KB of flash (4 LSB of WRP0)
- push the RDP to level 1, so SWD/serial monitor needs to fully erase
  the part before re-writing the code or the write-protection.

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

BRANCH=samus
BUG=chrome-os-partner:34935
TEST=dump the content of the option bytes.

Change-Id: I11af64365a6fbc34327b2e463eb8e2d369ffacd2
Reviewed-on: https://chromium-review.googlesource.com/238262
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-05 19:10:27 +00:00
Shawn Nematbakhsh
c69e9ceb31 pd: Modify EC_CMD_USB_PD_RW_HASH_ENTRY to return PD device image type
This addition allows the AP to query whether the PD device is currently
running from RO or RW FW.

BUG=chrome-os-partner:34599
TEST=Manual on Samus. Run 'ectool --name cros_pd infopddev 0' and verify
that correct RO/RW status of Zinger is printed. Verify that the output
matches the index printed by "pd 1 hash" on samus_pd console.
BRANCH=Samus

Change-Id: I4266cae931f5c7855ca0531717c4a18b138b2d62
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/236771
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-12-20 08:54:18 +00:00
Yen Lin
5898366382 stm32mon: fix unable to flash to nyan board problem
When comparing chip name of "STM32L15", use strncmp to compare the
first 8 characters.

BUG=chrome-os-partner:34558
BRANCH=none
TEST=flash_ec --board nyan

Change-Id: I3318385cee1d4e4c4d9688591f7a7bfd46c54dee
Signed-off-by: Yen Lin <yelin@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/235511
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2014-12-16 01:28:55 +00:00
Gwendal Grignou
0777ebaef6 Makefile: remove burn_my_ec
burn_my_ec is an utility that flash an image embedded in its code.
We can not compile it as part of ec-[dev]utils, because we have
devices that firmware should be build as part of chrome-ec package.
Remove burn_my_ec, barely used.

Split the makefile to build just the host utility when requested.

BRANCH=ToT
BUG=chrome-os-partner:32025,chromium:408713
TEST=Check that files are stil built when needed and
not when utils-host is invoked.

Change-Id: I3fabe16067d57c74ae36b05138f4c6fd2483c7c4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/233347
2014-12-15 03:51:17 +00:00
ZhengShunQian
3c780a915c Speedy: add initial speedy support
Copy from Jerry for now.

BUG=chrome-os-partner:33269
TEST=emerge-veyron_speedy chromeos-ec
BRANCH=None

Change-Id: I8375e1e23de5dbae0d1c579770d88e81223debce
Signed-off-by: ZhengShunQian <zhengsq@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/233795
Reviewed-by: Katie Roberts-Hoffman <katierh@chromium.org>
2014-12-08 09:51:14 +00:00
Todd Broch
540584eb6d pd: ectool: Increase sleep after PD reboot for flashing.
Longer sleep is needed to provide enough time for USB-PD devices to:
  1. boot RO & validate RW
  2. Initialize PD
  3. Enter Alternate mode (GFU)

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:31192,chrome-os-partner:31193
TEST=manual,
Flashing RW on dingdong via,
  ectool --name cros_pd flashpd 3 1 dingdong.ec.RW.bin
works

Change-Id: Id9c6f3907022f62bf887dfefc23b51d070b331b8
Reviewed-on: https://chromium-review.googlesource.com/233023
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2014-12-05 01:09:44 +00:00
Todd Broch
01047f6524 pd: ectool: Expose device id major & minor.
Also unifies other console output of same field.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:32650
TEST=manual

  # connect zinger to port 1 on samus
  ectool --name cros_pd infopddev 1

Before:
  Port:1 Device:1025 Hash:  0x3f34bc13  0xf8d15d12  0xf81f03cf  0xba3a3db6  0x0152a520
  Port:1 ptype:5 vid:0x18d1 pid:0x5012

After:
  Port:1 DevId:1.1 Hash: 0x3f34bc13 0xf8d15d12 0xf81f03cf 0xba3a3db6 0x0152a520
  Port:1 ptype:5 vid:0x18d1 pid:0x5012

Change-Id: I4e7ac56354e92ea3bc54a2c6ab5746399abdefe5
Reviewed-on: https://chromium-review.googlesource.com/231832
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2014-12-02 01:57:18 +00:00
Todd Broch
63277d145b pd: ectool: Allow different payload sizes for flashpd.
Dingdong & Hoho have different sized internal flash so the RW payload
can't be fixed.  CL removes check as operators should know be capable
of picking correct payload.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:31192,chrome-os-partner:31193
TEST=manual,

  <copy build/zinger/ec.RW.bin to samus>

  # reserved dev_id w/ zinger RW payload.
  ectool --name cros_pd flashpd 0 1 /tmp/ec.RW.bin
  Reading 65536 bytes from /tmp/ec.RW.bin...
  payload size 65536 but expected 0

  # hoho dev_id w/ zinger RW payload.
  ectool --name cros_pd flashpd 4 1 /tmp/ec.RW.bin
  Reading 16384 bytes from /tmp/ec.RW.bin...
  payload size 16384 but expected 65536

  # bogus dev_id
  ectool --name cros_pd flashpd 99 1 /tmp/ec.RW.bin
  Unknown device ID 99

  # zinger dev_id w/ zinger RW payload
  ectool --name cros_pd flashpd 1 1 /tmp/ec.RW.bin
  Reading 16384 bytes from /tmp/ec.RW.bin...
  Erasing expected RW hash
  Rebooting
  Erasing RW flash
  Writing RW flash

Change-Id: I49ad81edb04f359154fbff6710484c0d095069f7
Reviewed-on: https://chromium-review.googlesource.com/231831
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2014-12-01 20:31:00 +00:00
Todd Broch
b41a0632db WORKAROUND: ectool: Throttle flashpd so it does not watchdog EC.
CL adds sleep to USB-PD flashing loop in ectool.  Real problem is
likely busy waiting within the host command master in the EC which
causes it to starve other lower priority tasks there.

Additionally,
1. Sleep 100ms after reboot to attempt to avoid colliding with other
   USB-PD traffic communication that happens when accessories boot.

2. Sleep 100ms after last flash write prior to reboot as there's some
   race between finalizing flash write.

Workaround should be removed once we've identified root cause.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=samus
BUG=chrome-os-partner:33905
TEST=manual,

1. attach zinger to port 1 of samus
2. create ec.RW.bin for zinger and copy to samus
3. update RW fw on zinger via:
  ectool --name cros_pd flash_pd 1 1 ec.RW.bin

Result:
- No longer see watchdog fire on samus EC
- See successful update of RW fw on zinger.  Takes ~15secs.

Change-Id: If617cbf1c25ee92de94bdb312ec822af2a688640
Reviewed-on: https://chromium-review.googlesource.com/230845
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2014-12-01 20:30:40 +00:00
Katie Roberts-Hoffman
c420bf1922 Add initial mighty support
Essentially a copy of jerry for now.

BUG=chrome-os-partner:33269
TEST=make BOARD=jerry

Change-Id: I696919455f4752ebe43b616bdace6ac0820f8fe5
Reviewed-on: https://chromium-review.googlesource.com/230917
Reviewed-by: Alexandru Stan <amstan@chromium.org>
Commit-Queue: Katie Roberts-Hoffman <katierh@chromium.org>
Tested-by: Katie Roberts-Hoffman <katierh@chromium.org>
2014-11-20 05:09:09 +00:00
Shawn Nematbakhsh
b3bf2a61a3 charge_manager: Add PD_CHARGE_PORT_OVERRIDE host command
Add host command to set charge port override.

BUG=chrome-os-partner:32003
BRANCH=Samus
TEST=Manual on Samus. Insert PD charger in port1 and BC1.2 charger in
port0.
./ectool --name=cros_pd chargeoverride 0 --> Charges from port 0
./ectool --name=cros_pd chargeoverride off --> Charges from port 1
./ectool --name=cros_pd chargeoverride dontcharge --> No charge port
./ectool --name=cros_pd chargeoverride 1 --> Charges from port 1
./ectool --name=cros_pd chargeoverride 2 --> Correctly returns error

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ib35f797a4a24e96fd2e3c008ace3fd6291b89d25
Reviewed-on: https://chromium-review.googlesource.com/230910
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-11-20 02:55:41 +00:00
Gwendal Grignou
4b154c6f95 motion: Add decoding for MOTION_CMD_DUMP v1 command
MOTIONSENSE_CMD_DUMP is deprecated, replaced with MOTIONSENSE_CMD_GET_DATA
Also use vector_3_t instead of x,y,z

ectool motionsense commands only work with newer firmware, to
handle a dynamic number of sensors.
- The host sends the number of sensor it has allocated space for.
- If 0, the EC just sends the number of sensors available
- Otherwise returns sensor information up to the limit imposed by the host.

Remove MOTIONSENSE_GET_STATUS: not needed. It is only useful for LPC,
to guarantee atomicity of the data.
Remove MOTIONSENSE_GET_DATA: not needed since we increase the version
number of MOTIONSENSE command.

BUG=chrome-os-partner:31071,chromium:430792
BRANCH=ToT
TEST=Compile. On a firmware that support the new command:
/usr/sbin/ectool --name=cros_sh motionsense
Motion sensing active
Sensor 0: 92    15      1030
Sensor 1: -94   -63     718
/usr/sbin/ectool --name=cros_sh motionsense active
0
On a machine with older firmware (samus), check these
functions are not working anymore.

Change-Id: I64b62afff96670fb93457760d43d4e64e26e029f
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226880
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-11-18 05:19:08 +00:00
Henry Hsu
89442037be lid_switch: Support forced lid open
Factory test process need lid switch no function or keep lid opened

BUG=chrome-os-partner:33304
BRANCH=paine,yuna
TEST=Run command "ectool forcelidopen 1" and "reboot". Then lid close
quickly, the system boot as lid opened.
Deault value  or run command "ectool forcelidopen 0" make the device normal.

Change-Id: I94527b7ef7f9efe779c6b86f3eab651f99af6000
Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/230180
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-by: Bowgo Tsai <bowgotsai@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
2014-11-18 01:05:49 +00:00
Todd Broch
e96afe490f pd: fix alignment issue for print rwhashtable.
struct ec_params_usb_pd_rw_hash_entry is packed so addressing rw_hash
array caused alignment faults.

CL removes union in favor of just shipping bytes across
the host command.

BRANCH=samus
BUG=none
TEST=manual

from DUT
  ectool --name cros_pd infopddev 0
  Port:0 Device:1025 Hash:  0xa90a5d48 0xcc2af4ea 0xc7796d08 0x4a8f9e8e 0x0ba7578b

  ectool --name cros_pd rwhashpd 1025 0xa90a5d48 0xcc2af4ea 0xc7796d08 0x4a8f9e8e 0x0ba7578b

from PD MCU console,
  pd rwhashtable # no exception due to memory read alignment and ...

  Device:0x0401 Hash: 0xa90a5d48 0xcc2af4ea 0xc7796d08 0x4a8f9e8e 0x0ba7578b
  Device:0x0000 Hash: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
  Device:0x0000 Hash: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
  Device:0x0000 Hash: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000

Change-Id: I134a5402eac3e5159441ce6c483633ca0d575a03
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226890
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-11-17 22:12:48 +00:00
Gwendal Grignou
5fad6d4b8c util: Fix return value of ec_command
When ec_command fails because of transport issue,
it should returns an error between -1 and -EECRESULT.
If the command fails because of the EC, the error should be less
than -EECRESULT.
Unify all transports to return the error in the same manner.

BRANCH=ToT
BUG=None
TEST=Samus: Check that unsupported command fails with the correct error
number over dev transport.
Qwarks: Check the same command with a 3.10 kernel (no dev transport,
just LPC) fails with the same error code.

Change-Id: I2e43d0cb003d75318b0edd3745e534c700d7d7d8
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/228295
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-11-17 16:34:16 +00:00
Vincent Palatin
b63b0d70f5 rsa: add support for 4096 and 8192 bit keys
Allow to use larger RSA keys by setting CONFIG_RSA_KEY_SIZE to 4096 or
8192 rather than using the default 2048-bit size.

It's mainly for benchmarking purpose right now as we don't have the RAM
to store the 3x key size buffer and the flash space for the public key
structure.

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

BRANCH=samus
BUG=none
TEST=build Zinger with CONFIG_RSA_KEY_SIZE equals to 4096 and run it.

Change-Id: I9839121bf158d0a30dde1e48d875f345191bfec2
Reviewed-on: https://chromium-review.googlesource.com/228925
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-11-15 06:00:02 +00:00
Vic Yang
3bcc5673c9 ryu: switch default firmware to use STM32F373
This simply renames ryu to ryu_p1, and ryu_p2 to ryu. 'ryu_p1' will be
kept for a while and will be decommisioned when most developers make
switch to the new boards.

BRANCH=None
BUG=chrome-os-partner:33583
TEST=Build ryu and boot on P2 board.

Change-Id: Ief61c64c6aefdaeae76ac7b86e0ea28131810aa1
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/229291
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-11-12 23:08:12 +00:00
Todd Broch
73e182a443 pd: Add SVDM discovery info into host command.
During the discovery identity phase of type-C devices that support it
there is some info that could be useful to kernel & userland for
policy decisions.  CL starts by passing up the vid, pid & product type
(ptype) of the discover identity VDO.

BRANCH=samus
BUG=chrome-os-partner:32650
TEST=manual,

From host, w/ hoho in port 1

ectool --name=cros_pd infopddev 1
Port:1 Device:4 Hash:  0x57b1e4e0 0x7204075f 0x65c0fa72 0xdcca15ed 0xf3231237
Port:1 ptype:6 vid:0x18d1 pid:0x5010

Change-Id: Ie05d191149ada0ec860b713d780b0345eab3a647
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226899
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-11-11 05:41:01 +00:00
Gwendal Grignou
4792db413f ectool: compile LPC and i2C support by default.
Currently, LPC or I2C are compiled based on the board.h.
This is not really necessary, code can handle both at the same time.
Note that LPC and I2C access mode are backup modes, the main mode is
dev (accessing ECs through /dev/cros_XX).

BRANCH=None
BUG=chromium:408713
TEST=Compile, tested on Ryu and Samus.

Change-Id: I8b4730f0f5708c543dc034165e9b53de0e543860
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/227432
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-11-05 19:48:26 +00:00
Anton Staaf
8513e23df1 USB: Remove special case for iVersion string descriptor
Previously the version string was special cased in the USB stack
because the build system prevented the inclusion of ec_version.h in
any file other than common/version.c.  This lead to common/version.c
being the only place that the USB version string could be computed
and thus the special case of filling in the version string descriptor
at run time.  This made the USB stack more complex, and lead to the
common/version.c file including usb.h, which is actually STM32
specific.

Now, the portion of ec_version.h that is deterministic is only
updated when something in the tree actually changes (by way of a
conditional in the makefile), and ec_version.h no longer has to
depend on all object files (other than the special version.o).
This allows anyone to include ec_version.h as needed.  In particular,
each board that wants to define a USB version string can directly
include ec_version.h and do so.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     touch files and verify rebuilds happen correctly

Change-Id: Ic84d0b9da90f82ebb4630fb550ec841071e25a49
Reviewed-on: https://chromium-review.googlesource.com/227211
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-11-04 21:34:39 +00:00
Alec Berg
3a4f718f22 samus_pd: add dual-role port flag to power info host command
Add flag for whether or not device plugged into a given port is a
dual-role PD device. For now, the dual-role flag is always 0, but
need to add the flag to the host command now for compatibility
in the future.

BUG=chrome-os-partner:32650
BRANCH=samus
TEST=load onto samus, run ectool --name=cros_pd usbpdpower and
verify that for anything plugged in it says "dedicated charger"

Change-Id: I2d3c8c149802492f27a87a47aaa68fbf505ee7a9
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226820
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2014-10-31 22:32:54 +00:00
Alec Berg
498abf833c samus_pd: add host command to get type-c port power info
Get type-c port power info including power role, charger type,
and charging info. Also added host command to get number of type-c
ports.

Also adds new charging suppliers for pericom identified chargers
including DCP, CDP, SDP, proprietary, and other chargers. Priority
of these for charging is set in samus board file.

BUG=chrome-os-partner:32650
BRANCH=samus
TEST=run 'ectool --name=cros_pd usbpdpower' and verify correct
status with minimuffin, zinger, and type-C to type-A adapter.

Change-Id: I1dabbe7de4185a23df5684a5ea9a2d944f1f6ff5
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223523
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-30 04:31:34 +00:00
Gwendal Grignou
d5b32aa6e1 core: Add subcommands to MOTION_SENSE_CMD
These subcommands allow accessing sensor (accel+gyro)
over i2c.

BRANCH=ToT
BUG=chrome-os-partner:31071
TEST=Compile.

Change-Id: Ic6c3e9bf9c23f369de9f540c50daab7f2e4582ee
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225653
2014-10-29 22:23:49 +00:00
Katie Roberts-Hoffman
908b3f559b Add initial support for jerry
BUG=chrome-os-partner:33269
TEST=make BOARD=jerry; ./util/flash_ec BOARD=jerry
(on a pinky rev2 as a sanity)

Change-Id: I2c54e4044a65a0014adb32dd46f74bf5ed11b02d
Signed-off-by: Katie Roberts-Hoffman <katierh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225300
Reviewed-by: Alexandru Stan <amstan@chromium.org>
2014-10-25 08:14:16 +00:00
Vic Yang
d1ed75815e MKBP event signalling implementation
This implements a new API for EC modules to define MKBP event sources
and send MKBP event to the AP. Also, a new host command
EC_CMD_GET_NEXT_EVENT is added for the AP to query the pending MKBP
events. Each event type may have custom event data sent along with the
event.

BRANCH=None
BUG=chrome-os-partner:33194
TEST=Enable MKBP event on Ryu. Set a host event from EC console, run
'ectool nextevent', and see MKBP event 0x01 (HOST_EVENT) and the set
host event.

Signed-off-by: Vic Yang <victoryang@chromium.org>
Change-Id: I28a1b7e826bcc102bbe39016c9bb3e37d125664c
Reviewed-on: https://chromium-review.googlesource.com/224905
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-24 01:37:58 +00:00
Ken Chang
89a28fd464 flash_ec: Add support for kitty
Make board kitty to use flash_stm32.

BUG=chrome-os-partner:33035
BRANCH=None
TEST=Run util/flash_ec on kitty, verify flashing
complete successfully.

Change-Id: I302cfc85bfe5fa36fdf1a61d59b4dc21b36cc06a
Signed-off-by: Ken Chang <kenc@nvidia.com>
Reviewed-on: https://chromium-review.googlesource.com/224231
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-23 09:06:12 +00:00
Vic Yang
00551f7331 Add new build target ryu_p2 for Ryu P2 boards
The new build target ryu_p2 is mostly based on ryu. On ryu_p2, we have a
new EC chip with bigger flash, so make the corresponding changes:
  - Pinout changes
  - HW Timer: TIM5
  - USB PD Tx Timer: TIM3_CH4
  - USB PD Rx Timer: TIM2_CH4
  - Use UART2 for EC console
  - Disable UART Tx DMA as it conflicts with USB PD Tx DMA
  - Use 24MHz HSE x2 = 48MHz for SYSCLK

BRANCH=None
BUG=chrome-os-partner:32660
TEST=Sanity check on a new board:
       - i2cscan
       - PD negotiation
       - UART console
       - gettime

Change-Id: I4ef6b53a928a2777721e3874032aeb0e6b2b4c92
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221404
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-22 00:30:42 +00:00
Bill Richardson
f36a859e06 samus: new algorithm for tmp006 object temperature
The original algorithm is given in the TMP006 User's Guide
(SBOU107.pdf). The algorithm we previously implemented is that,
plus some additional and completely undocumented massaging of the
Tdie and Vobj registers. The original meaning of that hack is now
lost in the mists of time, thanks to our email retention policy.

This CL introduces a new algorithm variant, but at least this
time the details are in the bug report. It's essentially the same
as the User's Guide algorithm, except that we apply one-stage FIR
filters to the Tdie input and the Tobj output.

There are five new parameters: d0, d1, ds, e0, e1. Refer to
tmp006_read_object_temp_k() in ec/driver/temp_sensor/tmp006.c to
see how these new parameters are applied.

CAUTION: The tmp006 sensor algorithm is mostly math and magic
numbers. The spreadsheet attached to the bug report has six
sheets with wildly varying values for those parameters. Since the
correct parameter values haven't yet been determined for Samus,
all I can be sure of with this CL is that it seems to work and
isn't any worse than the old one.

Oh, and note that the EC's 't6cal' console command has been
disabled until/unless we add support for floating point IO. Use
ectool from the host to get and set the params instead.

BUG=chrome-os-partner:32260
BRANCH=ToT,Samus
TEST=manual

After booting, look at the sensor values using ectool:

  localhost ~ # ectool temps all
  0: 312
  1: 314
  2: 313
  Sensor 3 not calibrated
  4: 311
  Sensor 5 not calibrated
  6: 305
  Sensor 7 not calibrated
  8: 306
  Sensor 9 not calibrated
  10: 307
  Sensor 11 not calibrated
  12: 312
  Sensor 13 not calibrated
  localhost ~ #
  localhost ~ # ectool tempsinfo all
  0: 0 PECI
  1: 1 ECInternal
  2: 1 I2C-Charger-Die
  3: 2 I2C-Charger-Object
  4: 1 I2C-CPU-Die
  5: 2 I2C-CPU-Object
  6: 1 I2C-Left C-Die
  7: 2 I2C-Left C-Object
  8: 1 I2C-Right C-Die
  9: 2 I2C-Right C-Object
  10: 1 I2C-Right D-Die
  11: 2 I2C-Right D-Object
  12: 1 I2C-Left D-Die
  13: 2 I2C-Left D-Object
  EC result 2 (ERROR)
  ...
  localhost ~ #

There are six tmp006 object temps that need calibrating. The
index used for the calibration is for the tmp006 objects, not the
3,5,7,.. numbers reported for all temp sensors. See the current
values with tmp006cal:

  localhost ~ # /tmp/ectool tmp006cal 5
  algorithm:  1
  params:
    s0  0.000000e+00
    a1  1.750000e-03
    a2  -1.678000e-05
    b0  -2.940000e-05
    b1  -5.700000e-07
    b2  4.630000e-09
    c2  1.340000e+01
    d0  2.000000e-01
    d1  8.000000e-01
    ds  1.480000e-04
    e0  1.000000e-01
    e1  9.000000e-01
  localhost ~ #

If the s0 param is zero, this sensor is uncalibrated. The params
are entered in the order in which they're displayed You can
change any or all of the parameters. Skip the ones you don't want
to update by specifying '-' for its position. (Note: throw in an
extra '--' first so that ectool doesn't think that negative
numbers are command options).

For example, to change s0 and b0:

  localhost ~ # ectool -- tmp006cal 5 1.0 - - -3.0
  localhost ~ #
  localhost ~ # ectool tmp006cal 5
  algorithm:  1
  params:
    s0  1.000000e+00
    a1  1.750000e-03
    a2  -1.678000e-05
    b0  -3.000000e+00
    b1  -5.700000e-07
    b2  4.630000e-09
    c2  1.340000e+01
    d0  2.000000e-01
    d1  8.000000e-01
    ds  1.480000e-04
    e0  1.000000e-01
    e1  9.000000e-01
  localhost ~ #

Now sensor 13 (tmp006 object index 5) is calibrated:

  localhost ~ # ectool temps all
  0: 310
  1: 315
  2: 313
  Sensor 3 not calibrated
  4: 310
  Sensor 5 not calibrated
  6: 305
  Sensor 7 not calibrated
  8: 307
  Sensor 9 not calibrated
  10: 307
  Sensor 11 not calibrated
  12: 312
  13: 313

Change-Id: I61b5da486f5e053a028c533ca9e00b9a82a91615
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/224409
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-22 00:30:31 +00:00
Vic Yang
d0d6befc3f Add stm32mon support for STM32F37xx
This is needed for the new Ryu boards.

BRANCH=none
BUG=chrome-os-partner:32660
TEST=Program STM32F373 chip.

Change-Id: Ib7a58826945090300b7e086e888c43c46fb499ab
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223893
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-21 00:44:29 +00:00
Eric Caruso
bcc5057ad3 lightbar: interpreter additions to encode other patterns
Makes a significant encoding change to existing opcodes and
adds several opcodes to allow for encoding the more complicated
patterns that we have on the lightbar (S0, etc.) as well as
condense the ones we technically could encode but couldn't
fit in the 192-byte footprint allotted to us (KONAMI).

We need this to remove sequences from the EC code.

BUG=chrome-os-partner:32203
BRANCH=ToT
TEST=run test programs on hardware and lightbar simulator

Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Change-Id: I12fe908d3a43a924aa39f24ad66adbe53f7f38e1
Reviewed-on: https://chromium-review.googlesource.com/222949
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-15 18:22:37 +00:00
Bill Richardson
8fc80e86e4 lightbar: bring the TAP sequence in gradually
With only four LED segments, it's confusing to indicate a power
percentage by dimming the top segment unless you can see the
indicator smoothly ramping up from all-off. This does that.
Kind of pretty, if I say so myself.

BUG=chrome-os-partner:29041
BRANCH=ToT, Samus
TEST=make buildall

Run "ectool lightbar demo on", then press the T key to invoke the
pattern and the arrow keys to fake the charge state.

Change-Id: Ib6a56aea56078b8c1fc9edddda469d7f41735ff7
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223300
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-15 18:22:33 +00:00
Shawn Nematbakhsh
e63ab6da20 ectool: flashpd: Reboot PD after successful RW flash
Reboot the PD device after a successful flash so that it will boot into
the new RW. This syncs the ectool PD update to the implementation in
flash_pd.py.

BUG=chrome-os-partner:31361
TEST="./ectool --name=cros_pd flashpd 0 1 ec.RW.bin", verify flashing
succeeds and PD is rebooted after flash.
BRANCH=samus

Change-Id: I14e7dffe59fcc7ca678c76890dbc825df5b19862
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223062
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-14 23:59:16 +00:00
Sameer Nanda
63c41f2392 temp_metrics: add "--" when invoking ectool tmp006cal
ectool has switched over to using getopt for command line options parsing.
This breaks temp_metrics' invocation of "ectool tmp006cal" command since
some of the coefficients are negative and therefore start with "-".
getopt treats that as another command line option causing ectool to
barf.

BUG=chromium:422160
TEST=On a Pixel issue "sudo start temp_metrics" and check
/var/log/messages to ensure that no new messages such as "init:
temp_metrics main process ended, respawning" show up.
BRANCH=none

Change-Id: I42232b3027ec6339814d226f1d8ab493e3420eea
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222845
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-11 02:22:53 +00:00
Eric Caruso
6713fa2d38 lightbar: Rename structs and macros for kernel cros_ec_commands
This prepends EC_ a macro exposed in ec_commands.h, moves a
macro into lbcc that is not used elsewhere, and changes lb_program
structs to lightbar_program.

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

Change-Id: I481562da72d91f846c64cf9af40338027641462c
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222406
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-09 23:29:42 +00:00
Shawn Nematbakhsh
0938563284 zinger: Remove references to SHA1 hash
The PD protocol no longer uses a SHA1 RW hash. Instead, it uses the
first 20 bytes of the SHA-256 hash. Update constants and comments
accordingly.

BUG=chrome-os-partner:31361
TEST='make buildall -j'
BRANCH=samus

Change-Id: Ice74b841dbd1d81205c1ef0079a5e18fca2153b6
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222446
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-09 20:44:39 +00:00
Mohammed Habibulla
0fd73ae937 ectool: replace thermal_threshold_version with ec_cmd_version_supported
BUG=none
TEST='ectool thermalget' works as expected
BRANCH=none

Change-Id: Ie225ef0aaeae913162e8cd6c56193dedd9f56f2f
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221745
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-08 05:07:33 +00:00
Todd Broch
c1714dac12 dingdong: Initial board and USB PD support.
Allows dingdong to receive initial USB PD communication (source
capabilities payload) and with some manual manipulation (see 'TEST=')
drive DPout.

CL is based heavily off hoho dongle where all files were copied from
   board/hoho:
     7b1e58c ectool: Add host command support to set fan RPM for each
             fan separately

   Files gpio.inc, board.h & board.c were modified but others should
   be identical.

BRANCH=none
BUG=chrome-os-partner:31193
TEST=manual,

When attaching dingdong to samus_pd and configured via
  'pd dualrole source'

I see following on samus_pd console:
    C1 st9
    Switch to 5000 V 900 mA (for 900/900 mA)
    C1 st10
    C1 st11
    C1 st12

showing power constract and transition to SRC_RDY:
    > pd 1 state
    Port C1, Enabled - Role: SRC Polarity: CC1 State: SRC_READY

    > typec 1 dp

Also if I connect in CC1 configuration and get access to dingdong
console I can
   > gpioset PD_SBU_ENABLE 1

And see dingdong drive external monitor

Change-Id: I30ef6f8503a3fb015cfb8806bc36fb98f5150e40
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221913
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-08 05:07:29 +00:00
Alexandru M Stan
c5b30aa9f2 Renaming board veyron -> pinky
Seems that all previous boards used the subvariant specific name, and had an
alias from emerge-variant_subvariant to the ec subvariant folder.

BUG=chrome-os-partner:32331
BRANCH=None
TEST=cd board/pinky; make clean && make -j && ../../util/flash_ec --board=pinky

Change-Id: Ie6e0c977b6659687357a1b5aa2915cf0e40a5da7
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-10-08 02:51:13 +00:00
Mohammed Habibulla
72aee5c113 ectool: Fix help string for pwmsetfanrpm
BUG=none
TEST='ectool pwmsetfanrpm' prints correct help command
BRANCH=none

Change-Id: I6b1ecc7a581bb916563177f878f6361841e3ed90
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221957
2014-10-08 02:51:10 +00:00
Mohammed Habibulla
5c8da35f87 ectool: hostcmd support to set fans auto control individually
ectool autofanctrl 1 - set auto fan control for fan 1

BUG=chrome-os-partner:23803
TEST=Tested the above EC command on Auron
BRANCH=none

Change-Id: Idcd3690ad98d7965420f26f7cc445207fe73704d
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221816
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-07 20:58:33 +00:00
Vincent Palatin
c817472c07 Update Zinger flashing process
Convert the Zinger flash update commands to the new RSA signature
mechanism.

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

BRANCH=samus
BUG=chrome-os-partner:28336
TEST=from the workstation:
./util/flash_pd.py -m 1 build/zinger/ec.RW.bin
from Samus command-line :
ectool --name=cros_pd flashpd 0 1 ec.RW.bin

Change-Id: Ie8cd7f644ec94e461c5775a4dbbcd408782c72e1
Reviewed-on: https://chromium-review.googlesource.com/221560
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 03:37:48 +00:00
Mohammed Habibulla
876b0f0bdc ectool: Add hostcmd support to set fan duty cycle for each fan separately
ectool fanduty <percent>	- set all fans to <percent> duty cycle
ectool fanduty <fan> <percent>	- set <fan> to <percent> duty cycle

BUG=chrome-os-partner:23803
TEST=Tested the above EC commands on Auron
BRANCH=none

Change-Id: I06ca1552bd8f3412f6e90245da302c9f86ab6103
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221505
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-07 01:29:36 +00:00
Mohammed Habibulla
7b1e58cc43 ectool: Add host command support to set fan RPM for each fan separately
First case is for legacy support
ectool pwmsetfanrpm <targetrpm>		- set all fans to <targetrpm>
ectool pwmsetfanrpm <fan> <targetrpm>	- set <fan> to <targetrpm>

BUG=chrome-os-partner:23803
TEST=Tested the above EC commands on Auron
BRANCH=none
CQ-DEPEND=CL:220960

Change-Id: I8f447f53289abaa9c5cc1285f9f0921328fbf32c
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221291
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 22:27:03 +00:00
Mohammed Habibulla
75d7e31b9c ectool: add new host command to get number of fans
BUG=chrome-os-partner:23803
TEST="ectool pwmgetnumfans" returns correct number of fans on Auron
BRANCH=none

Change-Id: I2a1930a8f0965b08558bfb3c6424c571a6149bbb
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220960
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 22:26:52 +00:00
Mohammed Habibulla
938ba82bd7 ectool: Fix fanduty help
BUG=none
BRANCH=none
TEST=none

Change-Id: Iff09a24064d4245d2660dd307084cd701d03676b
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221202
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 04:30:01 +00:00
Vincent Palatin
beaddbf1a3 zinger: check RW firmware signature
The Zinger RW is now signed with 2048-bit RSA key (using SHA-256 as
digest).
This CL implements the verification mechanism.

note: the RSA key used for signing must be provided as a .pem file.
The path to .pem file must be provided in the PEM environment variable.
By default, it's using the dev key stored in zinger_dev_key.pem.

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

BRANCH=samus
BUG=chrome-os-partner:28336
TEST=on Zinger, run with properly signed RW firmware and corrupted
firmware and check the serial traces.

Change-Id: Ia58482458904a3ed72d6b0e95996cae86a0ead83
Reviewed-on: https://chromium-review.googlesource.com/220178
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-02 23:18:25 +00:00
Alec Berg
0330d9adf2 zinger: minimuffin: add board support for minimuffin
Minimuffin is identical to zinger, same MCU, same gpio, same
circuitry aroundt the MCU with two differences:
- Rated current is 2.25A instead of 3A
- USB PD hardware device ID needs to be different so that host
can differentiate between the two.

Due to the similarity between the two, minimuffin is defined
as a symlink to the zinger board.

BUG=none
BRANCH=samus
TEST=make BOARD=minimuffin
load onto a zinger and verify that samus reads device ID correctly
and limits input current limit to 2.25mA.

Change-Id: Ie39ec43262c7d14663eb68abff073bfeec451a24
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220689
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-02 20:51:10 +00:00