Commit Graph

2998 Commits

Author SHA1 Message Date
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
Alec Berg
01c331fd33 zinger: add config option for hibernate and disable by default
Disable hibernate by default on zinger because some EVT zingers
do not wake up on connect due to hardware problem.

BUG=chrome-os-partner:28335
BRANCH=samus
TEST=load onto zinger, leave disconnected for 60s, make sure it
doesn't go into hibernate

Change-Id: I9f5f9fb1ce349ea862652cd38aa5d1e521234b30
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221478
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 01:29:39 +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
Alec Berg
e541eeb294 cortex-m0: disallow rescheduling if task_start() has not yet run
Do not allow rescheduling tasks if task_start() has not been called.
This fixes a bug in which if console input occurs between uart_init()
and task_start(), the MCU crashes because uart_init() enables uart
interrupts which attempts to wake up the console task when RX data
is received, which then tries to task switch before we initialized
task scheduling.

BUG=chrome-os-partner:32561
BRANCH=samus
TEST=add while(1) loop to adc_init() to simulate stalled ADC
initialization. When stalled, send console character and observe
that without this CL MCU crashes, and with this CL the MCU does
not crash.

Change-Id: I34418e88ebe0063acf1cc55ab5a57b5fddcd9d23
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221599
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 01:29:33 +00:00
Vic Yang
f0dc012cf7 Add back unit test for usb_pd"
This is mostly the same as previous commits, but with increased delay.
Previously, we have short delays (e.g. 3ms) which is too short and may
cause instability.

Now that we have slowed down the time when running unit tests and
increased the delay, this shouldn't cause problems anymore.

BUG=chrome-os-partner:31200
TEST=Repeatedly run multiple unit tests in parallel.
BRANCH=Samus

Change-Id: Ib55e3adc5fd27a8e233996b4799dab3cefd62318
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220734
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-04 21:08:48 +00:00
Eric Caruso
15eced0374 lightbar: refactoring RAMP_ONCE and CYCLE_ONCE
These opcodes basically do the same thing, but with minor
changes. We can factor this out to avoid code duplication.
Saves 90 bytes.

BUG=None
BRANCH=ToT
TEST=Inspected programs that use RAMP_ONCE and CYCLE_ONCE with
  both nonzero and zero ramp delay.

Change-Id: I0105dbd4fc0af86beea993dbef85a0e0f01a0a90
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220604
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-10-04 21:08:45 +00:00
Vic Yang
7bbf6d7bb3 Slow down time when running unit tests
When a timing sensitive test run on a heavily loaded system, sometimes a
task runs for longer than it usually does and causes the test to fail.
All the timing requirements in the unit tests are trying to verify the
various delays in our codebase, and mostly we don't care about the time
taken by active running code (as they are very quick.) To improve the
stability of tests, let's slow down the time. To a test, it's as if the
code runs faster. If a test uses udelay() and exceeds the 10-second time
limit, we can make that single test faster by setting the time scale.

BUG=None
TEST=Repeatedly run 'make runtests'
BRANCH=None

Change-Id: I9bc5c77e0d34d04c8630d495387a751ef29c7bd5
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220717
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-04 21:08:38 +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
Todd Broch
f93c3e83e4 hoho: updates for rev2.0
BRANCH=none
BUG=chrome-os-partner:31192
TEST=manual,

- compiles & installs & runs on hoho rev2.0
- see RFUx -> SBU gpio change
> gpioget PD_SBU_ENABLE
  1  PD_SBU_ENABLE

Change-Id: Ice6963e05463670653470b24d451d41a35e249f3
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220181
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-03 22:26:58 +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
Alec Berg
ba624e7241 zinger: add hibernate if disconnected for 60s
Automatically go into hibernate (standby mode) if not powering
anything for 60 seconds. Will wake up when it is plugged into
something (senses pull-down on CC line).

BUG=chrome-os-partner:28335
BRANCH=samus
TEST=load onto zinger. if disconnected for 60s, see hibernate
print on zinger console. when connected to a device, verified
it boots again.

Change-Id: I2564c6192395bb5e4f6d7586c2725f13a4581049
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220837
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-03 04:29:57 +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
Chris Zhong
4be45e962c stm32: invert keyboard col2 option
Silego variant in pinky rev2 require the signal to be inverted.

BUG=None
TEST=on pinky-rev2: all keys from col2 work correctly
BRANCH=None

Change-Id: I83a029b4e9c6b4770e83f30b170595d45ea40cca
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220314
2014-10-02 20:51:05 +00:00
Chris Zhong
7a8891268d Veyron: power on 5v drv for pinky-rev2
EC need to enable 5v_drv when power on AP, disable it when power off AP.

BUG=None
TEST=USB host works well
BRANCH=None

Change-Id: Ie18679a5a2d3c676daf0af4da599fa010d98161d
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/220162
Reviewed-by: Alexandru Stan <amstan@chromium.org>
Tested-by: Alexandru Stan <amstan@chromium.org>
Commit-Queue: Alexandru Stan <amstan@chromium.org>
2014-10-02 20:51:02 +00:00
Vic Yang
cac05af1aa Remove 'param' option in lightbar console command
We can use ectool to set/get lightbar parameters and don't need a huge
console command option for this. Let's get rid of it to save flash
space.

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

Change-Id: Ifbc122c887a36accaf3f8dce43f091d7d1333550
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220710
2014-10-02 18:24:43 +00:00
Vincent Palatin
1ec56e8546 stm32mon: add option to read firmware image from stdin
Add a command-line option to ask stm32mon to read the EC firmware image
to flash from the standard input when the filename is replaced by a "-".

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

BRANCH=none
BUG=chromium:398165 chromium:396233
TEST=use the following flashing commands:
cat build/fruitpie/ec.bin | ./util/flash_ec --board=fruitpie --image=-
./util/flash_ec --board=fruitpie
./util/flash_ec --board=fruitpie --image=build/fruitpie/ec.RO.flat
and check the content of the flash.

Change-Id: I8039ecb6910f912161a7f59c5f5e2fc80447ce7b
Reviewed-on: https://chromium-review.googlesource.com/220842
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-10-02 07:02:54 +00:00
Eric Caruso
d3ebcb18ca lightbar: hide program command over console
This doesn't make any sense to expose to the console, so we can
save some logic and string literals by only compiling it for the
simulator.

BUG=chrome-os-partner:32203
BRANCH=ToT
TEST=Checked console does not support command. ectool still
  works and the lightbar simulator still has the command.

Change-Id: Ib216c7c11fd3d0d2d444ef7fc0dda4e451103219
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220834
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-01 22:42:30 +00:00
Alexandru M Stan
786a45347d stm32f0: deep sleep in S0
Enabled deep sleeping during S0. This was previously inhibited by
SLEEP_MASK_AP_RUN but the new config option (CONFIG_LOW_POWER_S0) will ignore it.

SPI needed a sleep mask, it essentially gets enabled and disabled whenever the
CS changes. Warning: waking up when the CS falls takes a little time, if the AP
sends fast data before the 48MHz clock is enabled characters will get corrupted;
leave about 30uS time for the clock to start.

CQ-DEPEND=CL:219997
CQ-DEPEND=CL:220243
CQ-DEPEND=CL:220461
BUG=chrome-os-partner:32223
BRANCH=none
TEST=load onto pinky, boot the AP(S0), use idlestats command to verify
that we are going into deep sleep (STOP mode). Verify that everything works
normally during S0(SPI, keyboard, anything that requires the EC to wakeup).

Change-Id: I81c4fa472332f1ad8ad93301089a99dcdb108948
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219555
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-01 22:42:25 +00:00
Vic Yang
813ac32380 pd: Translate host command parameters with lookup tables
We have giant switch-case just for translating USB PD host command
parameters. Let's change this to lookup tables so that it's clearer and
also reduces code size.

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

Change-Id: Ieef0e989bd0faa95e261748a73250c53f0942dad
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220511
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-01 10:19:52 +00:00
Eric Caruso
71df668d46 lightbar: Removing unused space in ramp table
We don't need the upper two bytes of any elements in the ramp table,
since none of them are big enough to flow into them. This saves us
another 60-70 bytes.

BUG=None
BRANCH=ToT
TEST=Manual, visual inspection

Change-Id: Id9d03b8f63e61172c5cc6b36b010582957c7bb22
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220595
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-01 06:53:25 +00:00
Eric Caruso
fcdbcfe5e0 lightbar: simplify JUMP, SET_DELAY_TIME opcode execution
We do some unnecessary work here. All we are trying to do is decode,
and decode already does all the error checking we want. Saves
20 bytes.

BUG=None
BRANCH=ToT
TEST=Run programs with JUMP and SET_DELAY_TIME opcodes in simulator
  and on hardware.

Change-Id: Ia55f9010da50fe748bda565e069359162cc92b4f
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220630
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-01 06:53:22 +00:00
Vic Yang
baf3bac6d8 ryu: Use brief assertion failure message
Currently, when an assertion fails, the error message is like:

  ASSERTION FAILURE '1 + 1 == 3' in command_apreset() at common/chipset.c:24

To save flash space, let's add an option to remove the failed
expression and function name. The error message becomes:

  ASSERTION FAILURE at common/chipset.c:24

BUG=chrome-os-partner:32203
TEST=make buildall
TEST=Add an assertion and triggers it. Check error message.
BRANCH=None

Change-Id: Ie323d5b43cbff2cd8f6cd5bb46c1f34ecd16bd5e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219670
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-01 06:53:14 +00:00
Eric Caruso
28891eaaab lightbar: treat HALT like a normal opcode
This removes the special casing around HALT. It saves us a string
literal and some logic. In total, we gain about 50 bytes and a
little cleanup for this.

BUG=None
BRANCH=ToT
TEST=Tried a program that uses HALT (i.e. red-green-blink) in
  simulator and on hardware.

Change-Id: Iffee1b559983fd1ecd385cc6b8967f72a6b968a0
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220589
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-01 01:47:39 +00:00
Eric Caruso
85d2d1f503 lightbar: remove erroneous multiplications by FP_SCALE
Not sure why these were around. They were making RAMP_ONCE and
CYCLE_ONCE do obviously incorrect things.

BUG=None
BRANCH=ToT
TEST=Manual, visual inspection

Change-Id: I618078e8bef8824f5449d5b5453924beb36d50e1
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220463
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-09-30 23:04:29 +00:00
Eric Caruso
d747c44dda lightbar: shrink size of sine table for ramping
cycle_010 now uses a table one-fourth the size and does a small
bit of linear interpolation in order to save space. This change
saves around 350 bytes.

BUG=None
BRANCH=ToT
TEST=manual; inspection that ramping still looks smooth

Change-Id: Ib5900630ba4a471a6284660377134724070babdc
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220430
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-09-30 20:12:27 +00:00
Alec Berg
3b00f5fed8 samus: add auto unwedge to all i2c busses
Allow automatic wedge detection and unwedge to all i2c busses
on Samus.

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

Change-Id: I4a9f91532c479da527bdf40531732108aa2c2c89
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220467
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Commit-Queue: Duncan Laurie <dlaurie@chromium.org>
2014-09-30 08:32:27 +00:00
Alec Berg
28d4565d8e i2c: allow for mulitple i2c busses to utilize automatic unwedging
Previously we had a restriction that only one i2c bus could use the
automatic wedge detect and unwedge functionality. This removes that
restriction, although it uses a mutex to make sure only one bus is
being unwedged at any given time.

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

Change-Id: I8ff238fb8a9e9d2f5bc57a2b0a05e2b231024772
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220466
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Commit-Queue: Duncan Laurie <dlaurie@chromium.org>
2014-09-30 08:32:23 +00:00
Vincent Palatin
400851595a add RSA signature verification code
2048-bit RSA public key cryptography signature verification code
which uses a pre-processed key for computation.

it is based on the code from vboot :
platform/vboot_reference/firmware/2lib/2rsa.c

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

BRANCH=samus
BUG=chrome-os-partner:28336
TEST=using following CL, on Zinger, verify RW firmware signature.

Change-Id: I681a29144eb805cd5758aa6efe697ce2f656a298
Reviewed-on: https://chromium-review.googlesource.com/220186
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-09-30 05:42:15 +00:00
Duncan Laurie
b67eadf702 samus: Increase ALS task size
Sometimes I2C1 is wedging and this can cause the ALS task to
overflow its stack.

As a temporary measure to stop the random reboots increase the
ALS task size.

BUG=chrome-os-partner:32471
BRANCH=samus
TEST=build and boot on samus with stuck I2C1
taskinfo before (after fresh reboot):
   2   ALS              00000000    0.001012  364/384
taskinfo after (notice it is >384 after some time):
   2   ALS              00000000    0.031586  400/512

Change-Id: I04e9b93d3cc60afd3303eb4610c81952f365b992
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220442
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-30 05:42:10 +00:00
Bill Richardson
87762fa699 Add compiler/decompiler for lightbar bytecode programs.
BUG=none
BRANCH=ToT
TEST=manual

  make BOARD=samus
  for i in extra/lightbar/programs/[g-z]*.bin; do
    ./build/samus/util/lbcc -d $i /tmp/x.lbs
    ./build/samus/util/lbcc /tmp/x.lbs /tmp/x.bin
    cmp $i /tmp/x.bin
  done

Change-Id: I86c014c425e917ecafadd1c6845fcf2e5b4edbb7
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220244
2014-09-30 01:53:53 +00:00
Duncan Laurie
af3d103dbc samus_pd: Add BST_DISABLE GPIO for EVT2 board
This pin is already set to out+low so it should be fine to rename
it on EVT1 boards.

BUG=chrome-os-partner:32031,chrome-os-partner:32359
BRANCH=samus
TEST=make buildall

Change-Id: I0d904b0301b793bbfa1d829b4fce60e0b1154b00
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220259
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-30 01:53:49 +00:00
Duncan Laurie
08e0421359 samus: Add define for EVT2 board
EVT2 will be board id 0b100.

BUG=chrome-os-partner:32359
BRANCH=samus
TEST=make buildall

Change-Id: Id82c319e84fac6db1a5223692e575bfe11790190
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220258
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-30 01:53:45 +00:00
Duncan Laurie
fa4407c11c charge_state_v2: Send host event if charge state changes
If there is any delay between AC status and the battery charge status
it is possible for the power_manager to read the battery state when
the AC status event is sent and still see that the battery is not
yet charging.  This can cause lag in the UI battery icon because the
AP is not notified when the battery charge state changes.

In order for the host to be able to differentiate the dynamic battery
state changing (re-read ACPI _BST by sending Notify 0x80) from the
static battery info (re-read ACPI _BIX/_BIF by sending Notify 0x81)
it needs a separate host event.

BUG=chrome-os-partner:32196
BRANCH=samus
TEST=Test AC instertion and removal while watching state on the host
to ensure that an event is sent to the host which triggers power
manager to re-read the battery status and notice that the charge
state has changed if there is any delay after the AC status event:

watch -n 0.1 "cat /sys/class/power_supply/AC/online;
cat /sys/class/power_supply/BAT0/status;
tail -10 /var/log/power_manager/powerd.LATEST"

Change-Id: I18ce70719dc231c43c474cefad2068f949675a2b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220257
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-30 01:53:41 +00:00
Alec Berg
a451aa850b zinger: add low power stop mode
Add low power mode for zinger. This uses stop mode in task_wait_event(),
the non-runtime equivalent of the idle task.

BUG=chrome-os-partner:28335
BRANCH=samus
TEST=load onto zinger and plug and unplug into samus a bunch of times
to make sure it negotiates to 20V every time. also send custom vdm's
from samus_pd and make sure those always succeed.

Change-Id: I626365e7d22e030792d28dbf7eafaeb8f54f8a74
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219933
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-09-29 23:18:44 +00:00
Vic Yang
41b927442e Fix floating point usage in lightbar module
This patch fixes stary floating point usage in lightbar module. They
should be scaled by FP_SCALE and of type 'int'.

BUG=None
TEST=Compile and make sure the compiler is not using floating point
related instructions.
BRANCH=None

Change-Id: I8d598af1014160b83bc44ef3e88e2cc4bf304e5e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220121
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
2014-09-27 09:27:55 +00:00
Alexandru M Stan
c83db9a119 stm32f0/i2c: Return error if we see a NACK
i2cdetect -q was broken on the AP. The way it works is by sending a 0 length
write request and checking for NACK. The stm32f0 driver had to be fixed to
actually return non-success if there was a NACK. i2cdetect -r worked so far
because it relied on a 1-length read and we indirectly detected NACKs by the
lack of data.

The error catching also had to be moved(in both drivers) before the success
returns, because it is possible to transmit something successfully(buffer got
emptied) without getting an ACK. We want this to be an error.

BUG=None
BRANCH=None
TEST=veyron: i2cdetect -y -r 20 0x09 0x0b should display -- on the 0x0a spot
since there's no device there. i2cdetect -y -{r,q} 20 should display the same
thing.

Change-Id: Id6cadb798e4d972dea089f15742e5b30888a038b
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220185
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-09-27 04:57:49 +00:00
Vincent Palatin
458d39c1a8 twinkie: add USB PD sniffer
Record the edges on the CC lines to sniff the USB PD traffic.

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

BRANCH=none
BUG=chrome-os-partner:28337
TEST=make BOARD=twinkie

Change-Id: I05c3135e47d0dc848875cbc99e4b57aff52ccbf6
Reviewed-on: https://chromium-review.googlesource.com/202206
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-09-27 02:40:27 +00:00
Bill Richardson
b88866828f Add demo_tap() function for lightbar demo mode
BUG=chrome-os-partner:29041
BRANCH=ToT
TEST=manual

From the host run

  ectool lightbar demo on

Then press the 'T' key. The lightbar should change to indicate
the charge state. Fiddle with the arrows to change the pretend
battery level and AC presence.

Change-Id: I398a829e2e5de5e1a186500aa2ed72c61e71deaa
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220024
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-26 09:21:06 +00:00
Eric Caruso
748848e8a2 lightbar: test programs for seq type PROGRAM
These programs test various bytecode interpreter functions.
rainbow-shift, red-green-blink and green-pulse produce visual
effects, whereas the other three programs test error cases.

bad-jump makes sure the interpreter stops if the PC goes
out of bounds. bad-opcode makes sure the interpreter stops if it
does not understand the instructions it is decoding.
infinite-jump makes sure that sticking a tight loop in the EC
(i.e., one not perforated with any DELAYs, RAMP_ONCEs, or CYCLE*s)
does not cause it to hang or crash. bad-decode-8 and -32 test that
malformed instructions are detected while decoding the
instruction's immediate data.

BUG=None
BRANCH=ToT
TEST=In simulator/scp files to device and test

Change-Id: I6c189997a13e7c6196daa28eb74d5506b5288f2b
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219565
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-09-26 01:12:45 +00:00
Alec Berg
23bad6732c zinger: remove reserved 4k for pstate
Remove 4kB reserved flash for pstate since we don't use persistent
state flash on zinger and flash space is limited.

BUG=none
BRANCH=none
TEST=make -j buildall. load and run zinger.

Change-Id: Id0020932ed47873d22e81516abf97b4279a7deae
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219932
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-09-25 22:49:45 +00:00
Alec Berg
e04f4cce11 stm32f0: enable flash prefetch buffer
Enable flash prefetch buffer for stm32f0 chips to make for
faster CPU execution.

BUG=none
BRANCH=none
TEST=load onto samus_pd and zinger. let run for a while.
connect/disconnect AC a few times. boot samus.

Change-Id: I88c0ae67a3205987344552f5b44952f9890c8177
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219921
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alexandru Stan <amstan@chromium.org>
2014-09-25 22:49:41 +00:00
Alexandru Stan
2c00459e19 veyron: enable low power idle
Enable low power idle for veyron (with uart wakeup as well).
Low power idle is only active in S5/S3.

Also sorted options from board.h

BUG=chrome-os-partner:31226
BRANCH=none
TEST=load onto pinky-proto1, use idlestats command to verify that we are going
into deep sleep (STOP mode). Run 30 min. and verify no watchdog reboots or
anything out of ordinary.

Change-Id: Id14b04f33ea46b1e6cca1c8e812b5875e9ee0446
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219044
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-25 20:32:48 +00:00
Vincent Palatin
2edf7ee161 Allow to disable default DMA interrupt handlers
The default DMA interrupt handlers are somewhat slow and not really flexible,
allow to override them in board if needed.

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

BRANCH=none
BUG=none
TEST=none

Change-Id: I909bfab265ccaa4f3b61d0a2a69bf7dfc0414be2
Reviewed-on: https://chromium-review.googlesource.com/215671
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-09-25 20:27:07 +00:00
Alec Berg
69238f9c66 pd: change pd_soft_reset() to use PD task to send command
Fix potential bug in pd_soft_reset() function. That function is
part of a global API and as such can be called by other tasks.
For example, a sysjump which takes place as part of host command
task. So, this function should not directly initiate PD communication
because if it is interrupted by the PD task, then there will
be unpredictable behavior since the send_validate_message() is not
designed to be re-entrant for a given port.

This changes pd_soft_reset() to simply change the PD state to
SOFT_RESET and then wake up the task to actually send the command.

BUG=none
BRANCH=none
TEST=you can test this with a type-C to A receptacle dongle. The
dongle has a pulldown on the CC line, but no device to respond to
PD comms. When you plug in C to A cable, samus should send source
cap repeatedly for 5 seconds. During that time, if you do a sysjump
from RO to RW, it will call pd_soft_reset(), which will send the
soft reset command. But, since there is no device it will timeout
and retry 3 times. During that period, the PD task will wake up
and try to do it's own thing, causing craziness and eventually a
hang and watchdog reset.

With this fix, I can plug in a C to A adapter, and sysjump to RW
cleanly.

Change-Id: Icab936ab8ab930e8e37b5a23825f7f054a50c177
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219893
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-09-25 18:15:47 +00:00
Alec Berg
9c62920f96 stm32f0: fix rare ADC initialization bug
Fix potential bug in ADC initialization. After setting ADEN bit to
enable ADC module, we must wait for ADRDY (ADC ready) bit before
continuing. This bug only affects a few chips, and only some of
the time.

BUG=chrome-os-partner:31978
BRANCH=none
TEST=Used a samus board where the PD MCU fails ADC initialization
quite often. Without this fix, if you reboot the PD MCU, it will
sometimes come up with all ADC's reading 0 and ADEN reading 0.
With this fix, it always boots with the ADC's working

Change-Id: Iba1d0e56006ba1ad6d9f0eee964a70ef2d0f8dcf
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219522
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-09-25 18:15:41 +00:00
Eric Caruso
fb5ff7b1bb lightbar: add seq type PROGRAM for user-programmable sequences
This diff allows the user to send small programs to the EC and
gain control of the lightbar. Right now, this is only exposed
through ectool, and sysfs support will come later.

To send a program to the EC, use
$ ectool lightbar program /path/to/program.bin
and then start running the program with
$ ectool lightbar seq program

BUG=None
BRANCH=ToT
TEST=Using the above steps with hand-assembled programs.
  Checked that infinite bytecode loops do not hang the EC.
  Checked that bad opcodes exit with an error.
  Stress tested pushing programs and changing sequences.

Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Change-Id: I635fb041a5dc5c403f7c26fb9a41b5563be9b6b7
Reviewed-on: https://chromium-review.googlesource.com/219558
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-09-25 07:59:16 +00:00
Bill Richardson
2939b986cf lightbar: show google colors in S0 (red for low battery)
This removes the pulsing blue colors in S0.

BUG=chrome-os-partner:31546
BRANCH=ToT
TEST=manual

Change-Id: Ib756b93bb51cb7b618958e5b1d270ba9cd1eef22
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219417
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-09-25 07:59:11 +00:00
Gwendal Grignou
7be8ff812b [common]: Remove accelerator calibration code.
This code is used to find the orientation of the sensor.
Given sensor are aligned with the edges of the device,
it is not too dificult to find manually.

BRANCH=ToT
BUG=None
TEST=Check ACCEL_CALIBRATE is not used anymore.
Check 'make buildall -j' works.

Change-Id: I81ffcb4f6b01c530ef16baf13113a5942f615092
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219527
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-09-25 04:09:07 +00:00