Commit Graph

2620 Commits

Author SHA1 Message Date
Dominic Chen
bc50751dbe flash: add config option to exclude building console commands by default
some commands, e.g. flashwrite, are never used on the final product and also increase
the size of the flash image.

BRANCH=none
BUG=none
TEST=make buildall

Change-Id: I2a2a0a749b8eee16db5bae6a1dc92c430570e928
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202993
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-12 01:44:31 +00:00
Vic Yang
dbb55cb1f4 Keyborg: implement system reboot
In case the slave got into a bad state, we may need a way to reboot the
slave from the master. The protocol must not involve SPI communication;
otherwise this will fail if the slave SPI module is in a bad state.

This CL implements this using SPI_NSS. In normal SPI communication, the
master pulls SPI_NSS low and immediately sync with the slave. To reboot
the slave, the master pulls SPI_NSS low without the following sync.

BUG=None
TEST=Reboots the slave from the master.
BRANCH=None

Change-Id: I947523e1d86fb2332b87fbfa3dab73cba958fb72
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203485
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-12 01:37:57 +00:00
Vic Yang
b78f9594ae Keyborg: add debug info on sync failure
It's often hard to find out which sync call failed when one happens.
Let's add debug info.

BUG=None
TEST=Add a sync call on master side only, and see the file name and line
number.
BRANCH=None

Change-Id: I68d0fa12d5d84293870e845fbb5f83aa3a8125fa
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203339
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-12 01:37:53 +00:00
Vic Yang
4670e53716 Keyborg: improve error recovery
Previously an error in master-slave communication often leaves the chips
in bad states and thus prevents further operation. Improve this by:
  - Making master_slave_sync() state-less.
  - Restoring SPI_NSS and disabling DMA on error.

BUG=None
TEST=Inject errors on master side and slave side. Check the subsequent
operations succeed.
BRANCH=None

Change-Id: Ief8b5b0df3d4be6319957bb1f9daf93e0e9b5d92
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203337
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-12 01:37:49 +00:00
Vincent Palatin
b170291c36 zinger: do not cut output on up voltage transitions
Update according to the current PD standard, a monotonic transition
seems mandatory in all cases, so keep the voltage output enabled
when increasing the output voltage.

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

BRANCH=none
BUG=chrome-os-partner:28331
TEST=connect Zinger to Fruitpie and probe the VBUS voltage during a
transition.

Change-Id: I3c728cc0049ca41536efd4f075139626b7d371da
Reviewed-on: https://chromium-review.googlesource.com/202657
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-11 22:10:55 +00:00
Vic Yang
40ca542a0d Keyborg: fix incorrect column driving in fast scanning
In the fast scan code, the master chip is driving the right side of the
panel at incorrect time. Let's fix this.

BUG=None
TEST=Manual
BRANCH=None

Change-Id: I9500f8ec4947c46762505ff20d0e5c4169bf5a67
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203370
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-11 22:09:28 +00:00
Vic Yang
2478058b7a Emit error when board.h or config_chip.h is included before config.h
If board.h or config_chip.h is included before config.h, CONFIG_* flags
may be incorrect. For example, if config.h says:

    ...
  #define CONFIG_DEFINED_FLAG
    ...
  #include "board.h"
    ...

And board.h says:

  #ifndef __BOARD_H
  #define __BOARD_H
    ...
  #undef CONFIG_DEFINED_FLAG
    ...
  #endif

Then this code:

  #include "board.h"
  #include "config.h"

would results in CONFIG_DEFINED_FLAG being defined, instead of undefined
as stated in board.h.

Avoid this by emitting error when board.h or config_chip.h is included
before config.h.

BUG=None
TEST=make buildall
BRANCH=None

Change-Id: Ic4a8b68e8ab1ef2a4cf9e926ab9008d2b106b943
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203265
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-11 03:34:17 +00:00
Alec Berg
7fb019e43c samus: decrease stack size for smaller tasks
Created a new smaller task size, 384, for tasks that don't need much
stack space including PDCMD and ALS tasks.

BUG=none
BRANCH=none
TEST=loaded on samus, ran taskinfo, made sure we were comfortbaly
under the smaller task size for those tasks that changed.

Change-Id: Icfa26eeaeed26171ec8b2d888e1190be32f688d1
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202719
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-11 03:34:01 +00:00
Dominic Chen
d414c89a61 util: move console command argument parsing to util.c
move parse_offset_size() from flash.c to util.c for SPI flash driver usage

BRANCH=none
BUG=none
TEST=make buildall

Change-Id: Ib4824d2a7e2f5b8c3e4b918d6507c072ded8837d
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202530
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-11 00:17:06 +00:00
Vic Yang
f317b4de30 Keyborg: fix a bug in fast scan mode
The fast scan buffer is of type 32-bit integer, so the byte size is 4
times of its size.

BUG=None
TEST=Check buffer is fully cleared after each frame
BRANCH=None

Change-Id: I0980e418a4b323195fec56f4970aca3918a6ee11
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203205
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-11 00:13:59 +00:00
Alec Berg
93bbf29aad pd: increase delay after receiving good CRC to avoid starting new packet
Increase the delay after receiving a good CRC in send_validate_message()
to avoid catching the last edge as the start of a new packet.

BUG=none
BRANCH=none
TEST=Tested with zinger and samus using the python script to flash
zinger RW, and simply negotiating power and receiving pings.

Change-Id: Iffdd73e02e5d292396d46a611d728f66402f2da4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203206
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-11 00:13:54 +00:00
Alec Berg
c388281b06 zinger: fix check for is in RO
Fix check for whether or not we are running in RO. The previous
code read the contents of the RW reset vector, but RW code
may be corrupted causing us to think we are in RW when we are not.

BUG=none
BRANCH=none
TEST=mostly just code inspection. verified this code running
in RW correctly identifies we are in RW.

Change-Id: I2c27af45a59b29f55fd24295f91d5c5f0e491dd4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203192
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-11 00:13:51 +00:00
Vic Yang
8c201b1e6c Keep IRQ_HANDLER macro when building without common runtime
Without common runtime, we need to use IRQ_HANDLER to define IRQ
handlers. Previously IRQ_HANDLER is only implemented in irq_handler.h
which is not included by task.h when building without common runtime.
This causes problem when we want to use code that includes task.h and
uses IRQ. By adding IRQ_HANDLER to task.h, we don't need to include
irq_handler.h in any case, and thus avoid that problem.

BUG=None
TEST=make buildall
TEST=include task.h instead of irq_handler.h. Check Keyborg still
builds.
BRANCH=None

Change-Id: I1213506132025fc656630565f58686b9e7de940c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203084
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-10 00:16:50 +00:00
Alec Berg
72357cd1ed samus: Allow samus to charge w/o battery or with dead battery
Use a EC to PD host command to notify the PD MCU when a battery
is present and charged enough that it is ok to negotiate for a
higher power. The PD MCU will not negotiate until the host command
is received, which allows the system to be powered without a
battery or with a dead battery with 5V.

BUG=chrome-os-partner:28611
BRANCH=none
TEST=Tested on a samus:

1) Tested the normal case of battery charged and plugged in. When
charger is plugged in, the device immediately starts negotiating
for 20V and starts charging.
2) Tested with no battery. Plug in a charger, samus boots and stays
alive. VBUS measured at 5V. When a battery is plugged in, device
negotiates for 20V and starts charging.
3) Tested dead battery by taking a battery with no charge, and
plugging in zinger. Everything boots, but PD does not negotiate
for power. Then when battery reaches 1%, PD negotiates and zinger
switches to 20V without causing a reboot.

Change-Id: Iaa451403674e86cddbd3fe80e9503584910be576
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201958
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-09 22:20:48 +00:00
Bill Richardson
f7ae0fb81b Add display-battery-level function to lightbar
This adds a new lightbar sequence (TAP), which temporarily displays the
battery level. It pulses if the system is charging.

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

From the EC console, run

  lightbar seq tap

The lightbar should change temporarily.

Then run

  lightbar demo on

and press the Up, Down, Left, and Right keys to fake the battery charge
level (up & down) and the AC present state (left & right). Run the

  lightbar seq tap

command periodically to watch it change.

Change-Id: I84ff928d93060f7ef7d46d608732d37cf5185aff
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202964
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-07 06:01:00 +00:00
Alec Berg
bcb9428312 samus: enable PP3300_ACCEL_EN by default
Keep accelerometer power enabled all the time. It consumes
very little power, we will need it to be on all the time for
tap for battery, and when it is off, it can cause problems
because the PP3300_EC rail leaks through the i2c pull-ups into
the accelerometer.

With this change, we should never see the bug in which i2c
bus 1 is getting a lot of errors on boot.

BUG=chrome-os-partner:29003
BRANCH=none
TEST=tested on multiple samus units. can talk to accel using
i2cxfer console command, and never saw any bus problems.

Change-Id: I2034e217fbb1157cc0f9b867ef50e7932d75c761
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202988
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-07 06:00:32 +00:00
Alec Berg
6da31fd404 samus_pd: fix pd tx should output low when not transmitting
fixed pd tx so that it really outputs low when not transmitting.

BUG=none
BRANCH=none
TEST=tested on samus by making sure we can still talk PD
to charger and charge.

Change-Id: If04eb3d0e6620985906c49df0429a92832cffd8d
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202668
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-07 01:33:24 +00:00
Alec Berg
49cc3902b0 samus: allow charging of dead battery requesting nil
On samus battery, when the battery is dead it reports 0 for desired
voltage, current, and state of charge. In this case we should allow
charging.

Added a CONFIG option for this that should be removed as soon as
the battery side is fixed.

With this CL, when a dead samus battery is used and a charger is
connected, we attempt to charge it.

BUG=chrome-os-partner:29465
BRANCH=none
TEST=test on a samus with a dead battery. w/o this CL, the battery
never charges because the charging not allowed flag is set. With this
CL, the battery charges.

Change-Id: Ic61f27a27237166d33cb9ea5f024d3ef6360ce82
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202603
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-06-07 01:29:53 +00:00
Alec Berg
57856ba2b3 samus: remove config to use custom battery present signal
The custom battery present signal which relies upon a battery
temp ADC is not working on many of the samus batteries. For
now, we'll use the default battery present status signal which
depends on successful i2c communication.

BUG=none
BRANCH=none
TEST=Test on samus with battery with broken temp sensor. Run
chgstate and make sure is_present = yes and battery does charge.

Change-Id: Idc28a922359106f3b2880236e6df64a4a2ede8e6
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202777
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-06-07 01:29:49 +00:00
Vincent Palatin
1ba242d995 fruitpie: provide VBUS in host mode
When we are a USB host (and a power source), provide 5V VBUS on the
type-C receptacle.

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

BRANCH=none
BUG=none
TEST=with 2 Fruitpies, put one in source mode ("pd charger" command) and
plug a type-C cable between them.

Change-Id: Ifbdbf9db659b2fd03d11197faf2c7e14cb971e75
Reviewed-on: https://chromium-review.googlesource.com/202446
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-06-07 01:28:30 +00:00
Vincent Palatin
5725f4f0ef samus_pd: provide VBUS in host mode
When we are a USB host (and a power source), provide 5V VBUS on the
type-C receptacle.

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

BRANCH=none
BUG=chrome-os-partner:28782
TEST=on Samus, put port0 in host mode (by doing "pd charger" on the PD
MCU command line), then insert a type-C to type-A cable and observe we
have VBUS on the other side.

Change-Id: I5c6cd78b54dc1c651420eaaf122b8545b9f0b0de
Reviewed-on: https://chromium-review.googlesource.com/201066
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-06-07 01:25:28 +00:00
Vincent Palatin
3d9544ae42 fruitpie: new PD TX driving for reworked board
For boards reworked with FETs on the TX path, TX_DATA (PB14) needs to be
driven low when we are not transmitting.
Set MISO as GPIO low by default and set the alternate SPI function in
the TX enable code.

This should be backward compatible with non-reworked Fruitpies.

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

BRANCH=none
BUG=none
TEST=plug 2 fruitpies with a type-C cable and do a PD power
negotiation.

Change-Id: I9ef9c84147e9468667eed9c96647c6a9a7f79fdd
Reviewed-on: https://chromium-review.googlesource.com/202512
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Daming Chen <ddchen@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-06-07 01:25:24 +00:00
Vincent Palatin
3d51ec8823 samus_pd: force USB2.0 + DisplayPort on Port1
Until we have the full dual port support, hardcoded the 2nd type-C
receptacle (port C1) as a power provider with USB2.0 and DisplayPort
source.
Should be reverted to default as a power sink for the dead battery case
when the dual port logic is in place.

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

BRANCH=none
BUG=chrome-os-partner:28341
TEST=Plug a USB key on port 1 through a type-C to type-A cable.

Change-Id: I85d0c48412087d6afcdeb214a485a2bab9d8bcd4
Reviewed-on: https://chromium-review.googlesource.com/201064
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-06-05 23:15:22 +00:00
Bill Richardson
f4b12223e2 Tweaks to lightbar simulation
Improve the get_time() function, add support for GNU readline if desired.

BUG=none
BRANCH=ToT
TEST=manual

cd extra
make
./lightbar

Change-Id: Iedf84253b0e616a6a1b502415a487a2e6248cb2e
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202698
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-05 23:14:34 +00:00
Alec Berg
31369a69db samus: Add EC <-> PD i2c interface using host commands
Initial support for EC to PD communication using host
command interface over i2c.

BUG=chrome-os-partner:28351, chrome-os-partner:28352
BRANCH=none
TEST=on EC console send hello host command:
> pdcmd 0x01 0 0xa0 0xb0 0xc0 0xd0
Host command 0x01, returned 4
a4
b3
c2
d1

Change-Id: I0969808f455574ee456d6db8a60ce9b1204a0739
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200786
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-05 04:22:56 +00:00
Bill Richardson
565f1cb5ae Add CONFIG_BRINGUP option to help debug signals for bringup
When this option is configured, two changes take place.

First, the AP doesn't power on by default when the EC reboots. To boot it,
you can run the "powerbtn" command, or poke the power button manually, or
any of the normal things.

Second, we watch for power-related signal changes (anything that's connected
to the power_signal_interrupt() function) and keep track of them as they
happen. After a second with no further changes, we print the time and value
of each change. For example:

  [19.939212 Port 80: 0x29]
  [19.967971 HC 0x23]
  [19.976236 Port 80: 0x3a]
  [19.995700 HC 0x87]
  [20.567884 Port 80: 0x73]
  11 signal changes:
    19.638241  +0.000000  PCH_SLP_SUS_L => 1
    19.654378  +0.016137  PCH_SLP_S5_L => 1
    19.654457  +0.000079  PCH_SLP_A_L => 1
    19.654535  +0.000078  PCH_SLP_S3_L => 1
    19.654587  +0.000052  PCH_SLP_S4_L => 1
    19.659630  +0.005043  PGOOD_1_5V_DDR => 1
    19.663199  +0.003569  PGOOD_1_5V_PCH => 1
    19.664751  +0.001552  PGOOD_1_8VS => 1
    19.668735  +0.003984  PGOOD_VCCP => 1
    19.671883  +0.003148  PGOOD_VCCSA => 1
    19.868406  +0.196523  PGOOD_CPU_CORE => 1
  [21.908551 Port 80: 0xf0]
  [21.908855 HC 0x48]

BUG=none
BRANCH=ToT
TEST=manual

Build with CONFIG_BRINGUP, notice those two changes.

Change-Id: I55fd2021a0eae7dbfd1aaf5d93971f65bf2367b9
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202574
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2014-06-05 01:36:44 +00:00
Bill Richardson
1732ba691e Make Ctrl-S and Ctrl-Q match the rest of the world
Traditionally, Ctrl-S means XOFF and Ctrl-Q means XON
(http://en.wikipedia.org/wiki/Software_flow_control)

We've had it reversed on the EC console, and it's kind of annoying.

BUG=none
BRANCH=ToT
TEST=make buildall

Boot, watch the EC console. Hit Ctrl-S to stop the output, Ctrl-Q to
continue.

Change-Id: Ib2b9ba9a2688229d5d44f3b3f845208499ef09ff
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202532
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-04 21:01:43 +00:00
Anton Staaf
2a7ea56782 build: Move libs after source or object files
When not using gold as the linker the ordering of libraries
with respect to objects and source files is important.
Previously the build placed -l libraries before source and
objects on the gcc command line.  This doesn't work with
the default ld linker because since none of the symbols in
the libraries are yet required they are thrown out before
their uses are found in the objects and source.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Ic9f83ba6138d6592d3b6e28de6fb0688e664f480
Reviewed-on: https://chromium-review.googlesource.com/202469
Tested-by: Anton Staaf <robotboy@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-04 21:01:16 +00:00
Alec Berg
8b5277defe samus: move als sampling from hooks to its own task
Moved sampling of ALS to its own task. The problem is that it
spin waits on the i2c bus mutex, and it's a bad idea to spin wait
for very long in the hooks task because the hooks task tickles
the watchdog.

BUG=chrome-os-partner:29003
BRANCH=none
TEST=tested on samus: make sure ALS task is running and no
watchdog timeouts when the i2c bus is wedged indefinitely.

Change-Id: Ifcebabdfc151ea85cecdfe7a8ed489e8a82ee5ba
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202545
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-04 21:00:32 +00:00
Alec Berg
eac695e983 lm4: decrease i2c timeout
The i2c timeout on lm4 is currently 1 second, which is very long.
This changes it to 100ms. Note, the biggest transfer we might
every do is probably ~256 bytes to do a flash program using a host
command over i2c. And the slowest bus speed is ~100kHz. So, worst
case, the transaction shouldn't be more than about 25ms.

Decreasing the timeout is useful when peripherals are not plugged
in. For example, the ALS is sampled in the hooks task every second.
We don't want the ALS sampling to be delayed for a second because
it will throw off all of our other hooks.

BUG=chrome-os-partner:29003
BRANCH=none
TEST=ran on a samus and tested i2c commands to various peripherals

Change-Id: I5e1b6d0f8b100cbcb6cd9209c6198e31d99bb085
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202515
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-04 20:59:15 +00:00
Alec Berg
46e9d7b468 samus_pd: pd tx should output low when not transmitting
Change pd spi tx pin to output low when not transmitting.

BUG=none
BRANCH=none
TEST=tested on samus by making sure we can still talk PD
to charger and charge.

Change-Id: I33665d01860c765cc0ff2e7813b04cac0ab9c8fe
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202511
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-04 20:59:11 +00:00
Vincent Palatin
976260dc69 add INA231 driver
Add a driver for INA231 Power/Current monitoring I2C chip.

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

BRANCH=none
BUG=chrome-os-partner:28337
TEST=make BOARD=twinkie
and run "ina" command on Twinkie.

Change-Id: Id322aca74cbb6bbf866aed22e7815c0e01951414
Reviewed-on: https://chromium-review.googlesource.com/202205
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-03 23:23:50 +00:00
Vincent Palatin
bc3a927a03 pd: detect sink disconnection
For non-PD aware sink, ensure that we detect their disconnection when
the CC goes back above Vnc.

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

BRANCH=none
BUG=chrome-os-partner:28782
TEST=on Samus, put the port in source mode (using the "pd charger"
console command), then plug and unplug the type-C to type-A cable and see the
PD state going from Disconnected to Discovery and the other way round
(using "pd state" console command).

Change-Id: Ic9e19fee78f0c5e1fc742e2443eaf4b804ee5ee9
Reviewed-on: https://chromium-review.googlesource.com/202445
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-03 23:23:31 +00:00
Vincent Palatin
455950b6da pd: handle Soft Reset
When receiving a Soft Reset request, handle it as expected:
reset our ID counter, send back an Accept message.

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

BRANCH=none
BUG=none
TEST=make buildall

Change-Id: I85d64d0349092b3a773ab6134fec0a1dcac6e284
Reviewed-on: https://chromium-review.googlesource.com/202456
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-03 23:23:26 +00:00
Alec Berg
2ae05ecbf3 pd: support bist carrier mode 2
Support bist carrier mode 2 - continuously transmit alternating
1's and 0's, and check for bit errors on receive side. note
that once the test is started the only way to stop is to hard
reboot the devices involved.

BUG=none
BRANCH=none
TEST=connect two fruitpies together. set one to be source:
> pd charger
and then start the bist
> pd bist
start receiving data:
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa - incorrect bits: 0 / 0

55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55
55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 - incorrect bits: 0 / 0

Change-Id: Id920f6b7177a418a80e1ce325042243cd633cec6
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202187
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-03 04:26:53 +00:00
Vincent Palatin
bbee5e137e pd: set BMC bit
In the current version of USB-PD standard, the packet header should have bit 15
set to 1 to tell the other side that we are supporting Biphase Mark Coding
(aka BMC).

For now, just set it, do not check it as most of our devices are setting it
yet.

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

BRANCH=none
BUG=none
TEST=make buildall

Change-Id: Ia6f89f592632520b46478a7d7975e9e8d3a28b59
Reviewed-on: https://chromium-review.googlesource.com/202391
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-03 02:25:54 +00:00
Dominic Chen
e6755ca4ac stm32: add SPI register definitions and refactor
refactor existing code in usb_pd_phy.c to use new register definitions

BRANCH=none
BUG=none
TEST=manually verify macro substitutions produce same value

Change-Id: Ia0cd815164b0262640425abd6da973c170163f2f
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202392
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-03 02:25:34 +00:00
Vincent Palatin
a6bf597bbc Add basic support for Twinkie dongle
Just the board configuration to test the PCB

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

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

Change-Id: I3468a651c97aba48a7d3c07ff6a34a676988e426
Reviewed-on: https://chromium-review.googlesource.com/196692
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-06-02 22:21:22 +00:00
Vic Yang
4b396a05c4 Keyborg: options to turn on/off fast scan mode
For experiments, we sometimes need to turn off fast scan mode. Let's add
an option so that this can be easily done.

BUG=None
TEST=Manual test with fast scan mode on/off.
BRANCH=None

Change-Id: Icd9a4a4b18699f34f424e84167748fcfe30588e3
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202141
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-31 03:57:33 +00:00
Vic Yang
200246949a Keyborg: provide options on data encoding/printing style
For easier developement/experiment, this adds two options:
  - CONFIG_ENCODE_SEGMENT/CONFIG_ENCODE_RAW
      SEGMENT style encoding uses less RAM, so it can store the entire
      frame. However, it sometimes losses data. RAW style encoding is
      always lossless, but it can only save a bit more than a half
      frame.
  - CONFIG_ENCODE_DUMP_PYTHON
      If this flag is defined, the output style is a 2-D Python list.
      This is used so that the data can be easily fed into another
      script.

BUG=None
TEST=Tries all four combinations.
BRANCH=None

Change-Id: Ic6a916f1cae20edccee5d05783ef98a1c48dff2e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202140
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-31 03:57:28 +00:00
Vic Yang
fe4f1275b2 Keyborg: improve panel discharge
This fix includes:
  - A faster discharge procedure
  - Added discharge steps between scanning two columns. This is to
    prevent the shadow "wraps around" to the beginning of the next
    column, which is much harder to filter out.

BUG=None
TEST=Press hard on the end of one column. Check the shadow doesn't wrap
around to the next column.
BRANCH=None

Change-Id: Ie1342f7778d0fe18a0ec2086af79d5e459f1cd7d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202073
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-30 01:26:15 +00:00
Vic Yang
cbb5aafc0e Keyborg: show version on boot
Makes it more convenient to tell which version we are running.

BUG=None
TEST=Boot and see version string
BRANCH=None

Change-Id: Icf5497904bad1a8b3ea9dd81fbbe1b416c77127d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201668
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-28 21:19:57 +00:00
Vic Yang
04c18e1e82 Keyborg: handle ADC overflow
Previously we assumed the ADC reading wouldn't overflow, which is
apparently wrong. This CL handles the overflow case.

BUG=None
TEST=Touch the keyboard. Still see sane heat map.
BRANCH=None

Change-Id: Iab5372915319d6a0ef76799f9b5fe821af5a9ca5
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201804
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-28 21:19:35 +00:00
Vincent Palatin
56e0e67abe move stringify macro to common include
We need to stringify macros arguments in various places in the code,
avoid duplicating this definition.

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

BRANCH=none
BUG=none
TEST=make buildall

Change-Id: I03530c06139fad4c60711d041239b396d9ed321e
Reviewed-on: https://chromium-review.googlesource.com/201576
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-27 23:21:26 +00:00
Vincent Palatin
8c89bcff4d zinger: activate the watchdog.
Ensure we are never stuck somewhere without doing the safety checks by
enabling the watchdog and reloading it in the safaty checks function.

I have kept the default timing constants, so on STM32F0xx the watchdog
period should be between 1.2s (LSI at 30kHz) and 2.0s (LSI at 50kHz).

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

BRANCH=none
BUG=none
TEST=add a 2s loop in the serial port interrupt handler and see the
power supply rebooting.

Change-Id: I000f2a36a31e1166adf63a36c2b7f52999adc928
Reviewed-on: https://chromium-review.googlesource.com/201575
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-27 23:21:21 +00:00
Dominic Chen
f4de7fb005 flash_ec: enclose variable $IMG in quotes to handle whitespace in filename
BRANCH=none
BUG=chromium:346807
TEST=flash firmware image with whitespace in filename

Change-Id: I8aa2ea9439a8f861e617256a63803c278708596e
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200995
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 05:02:06 +00:00
Vic Yang
ef2fe47070 Keyborg: implement fast scan mode
With fast scan mode, the scan rate can usually go up to 90-100 Hz. In
worst case, the rate still maintains at around 50 Hz.

BUG=None
TEST=Manual test. Check heat map.
BRANCH=None

Change-Id: I2dc25028ffa5b3175b856d3437004c21b84e7df7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200829
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:59:02 +00:00
Alec Berg
d3d2c077f0 pd: when PD sink request is rejected go back to discovery state
When sink receives a power request rejected packet, go back to discovery
state in order to retry transmitting request.

BUG=none
BRANCH=none
TEST=tested with zinger. when zinger has an over current fault, it
rejects requests for power. made sure that when device gets rejected
it goes back to discovery state.

Change-Id: Id532b69f52bd533e5d7ac1171d8833bc993a0e9f
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201157
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:53:29 +00:00
Alec Berg
b19bd8f438 pd: detect source disconnection
For non-PD aware source, ensure that we detect their disconnection when
the CC goes back below Vnc.

BUG=none
BRANCH=none
TEST=when zinger gets into state where it is not talking PD, remove
charger and make sure we transition to disconnected state.

Change-Id: I675ff6d3300eda680acdd7814f0163f222eeb516
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201156
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:53:24 +00:00
Alec Berg
3dff34e653 samus_pd: add interrupt to detect VBUS transitions quickly
Add interrupt to VBUS signal to detect VBUS transitions
quickly to make sure we transition out of SNK_READY when VBUS
goes away.

BUG=chrome-os-partner:28611
BRANCH=none
TEST=Test on samus 1.9 board. Ran for hours with charger plugged
in, made sure when charger cuts out after missing ping responses,
that it successfully goes to disconnected state and renogiates
power.

Change-Id: I93b2e49891e6a38c98095b7311a9435606cc61ab
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201155
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-05-23 04:50:22 +00:00