Commit Graph

2767 Commits

Author SHA1 Message Date
Vincent Palatin
550669cbfb ryu: remove console help to save flash space
Build the ryu EC without the command line commands help to save flash
space.

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

BRANCH=none
BUG=none
TEST=make buildall
build with and without the change and see we are saving 2.3kB of flash.

Change-Id: I8282c709715a84c8136a951a478f053fa888e86c
Reviewed-on: https://chromium-review.googlesource.com/210055
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-07-31 04:37:54 +00:00
Alec Berg
3c05559334 pd: fix transmit bug, add back in retry mechanism
Fix bug in pd transmission. The retry mechanism was not working right
and was causing us to not do any retries.

BUG=none
BRANCH=none
TEST=Test with a zinger unplugged from the wall. Samus sends source
cap and doesn't get a response. Verify on console printout that we
retried 3 times.

Change-Id: Id273bf054655c2d24a791f4eaf4cb8d87253abe2
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210559
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-31 04:37:27 +00:00
Alec Berg
d5aaf91a7a samus_pd: increase stack size for pd tasks
Increase stack size to account for pd communication errors. With
lots of pd communication errors, I see a max stack usage of 520
bytes, which is larger than the old stack size of 488 and was
causing stack overflows.

BUG=none
BRANCH=none
TEST=load onto samus and generate pd errors by plugging in an
unpowered zinger (samus sends source cap every 100ms, but no
response). measure task usage.

Change-Id: Iab2b0f781cb39d8e1ea906de48bd5b37e229d291
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210580
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-31 04:37:20 +00:00
ChromeOS Developer
dbf62710f7 Make board names in flash_ec less prone to conflicts
BUG=None
BRANCH=None
TEST=Run util/flash_ec on peppy, spring, link. Verify flashing
complete successfully.

Change-Id: Ib388af6800ae208934d5b026a63f0567d31ef86e
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/191304
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-07-31 02:17:06 +00:00
Vic Yang
68dd21c560 Fix flash_ec so that it finds stm32mon
If chromeos-ec package hasn't been built, flash_ec tries to find
stm32mon in local build/ directory. However, this is broken in the last
CL when we move away from crosutils. Let's fix it.

BUG=chromium:397202
TEST=Flash samus_pd
BRANCH=None

Change-Id: I05395a727fa965032a24f51c07deaebf2d7c7e51
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210419
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-07-30 23:42:32 +00:00
Randall Spangler
947f7ff936 stm32f0: Fix buffer size for i2c host command receive
Packets can be 128 bytes, and are preceded by a prefix byte.  So we
need a 129-byte buffer, not a 128-byte buffer.

BUG=chrome-os-partner:30079
BRANCH=none
TEST=do pd software sync; see that 128-byte packets transfer correctly

Change-Id: Ic1e6cfec2c042537768d1cd0eecea509cc90c052
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210502
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-07-30 23:42:16 +00:00
Gwendal Grignou
61d0caf338 ryu: Use get_base to access flash location
Previous assumption assumed that the flash was remapped
to address 0.
This is not the case anymore since cl/210063

BUG=chrome-os-partner:30997
TEST=Check we can boot the EC now.
BRANCH=None

Change-Id: I46e1dc0ad840b21661aa5d87817369b29a659c9b
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210407
2014-07-30 08:39:56 +00:00
Vic Yang
5871a19f5c Remove dependency of flash_ec on crosutils
The script currently depends on common.sh from crosutils, which is not
installed on beaglebone and also pulls in dependency on other
repositories. Let's switch to shared shflags library and include output
formatting functions in flash_ec script. This way we are independent
from crosutils.

BUG=chromium:397202
TEST=Run the script to flash EC
BRANCH=None

Change-Id: Ib18987410eb32d773d55fb4e53133adf230167b9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209827
Reviewed-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-07-30 05:31:50 +00:00
Vic Yang
139a9c6880 Host command for USB PD role and mux control
This allows us to control PD role and type-C mux through ectool.

BUG=None
TEST=Change role/mux on samus using ectool:
     $ ./ectool --interface=lpc --dev 1 usbpd 0 usb
     -> In EC console, 'typec 0' shows 'Superspeed USB1'
     $ ./ectool --interface=lpc --dev 1 usbpd 0 sink
     -> In EC console, 'pd 0 state' shows 'force sink'
BRANCH=None

Change-Id: I5b90fb53ea1c30e3bc269c12d61e4398c5dcee6c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209956
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-07-30 05:31:35 +00:00
Anton Staaf
9797f654d9 Makefile: Add support for per-board symlinks to top level
Previously if you were working on a single board you had to add BOARD=
to all of your make command lines.  Now if you are in a board directory
you can just use "make", or "make clean", or any other top level make
command.

This commit also adds support for a top level "make flash" command that
can be used from the board directories as well.  This command uses
openocd and requires that the board provides an openocd-flash.cfg file.

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

BRANCH=none
TEST=(from a few board directories) make clean; make -j
     (from the discovery-stm32f072 directory) make flash

Change-Id: Ie09a74881371169a2c3cd9cd9922f39f4873f1a6
Reviewed-on: https://chromium-review.googlesource.com/209669
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-07-30 03:10:06 +00:00
Randall Spangler
a528f89291 Use mutex for EC->PD host commands
Host commands can be generated by either the PDCMD task (in response
to PD interrupts), or the HOSTCMD task (in response to passthru
requests).  Use a mutex to serialize access to the EC->PD interface.

BUG=chrome-os-partner:30079
BRANCH=none
TEST=Boot samus

Change-Id: If65d5eb4bbef91e6c811a06ea2e1487e17143dc7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210401
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-07-30 03:09:59 +00:00
Randall Spangler
4692a1387a i2c: add support for timeout configuration at runtime
When the EC sends longer commands to the PD chip (such as flash
erase/write over the passthru from AP), allow it to take a second
instead of the default 100ms timeout.

BUG=chrome-os-partner:30935
BRANCH=none
TEST=samus boots
     battery command works from EC console
     ectool passthru of flash erase to PD works (requires hacked ectool)

Change-Id: I08ff94f7ac6aee351aa73c9d28b5fd715d463b3a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209936
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-07-30 00:23:25 +00:00
Randall Spangler
e449a42f08 Enable vboot hash calculation
This is necessary for PD software sync.  Also need to increase the
hook task size to avoid stack overflow.

BUG=chrome-os-partner:30079
BRANCH=none
TEST=boot samus; on PD console, see hash calculated.

Change-Id: I37e571f9cd03a31eb4eaad903c3dda72f7e51fc1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209812
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-07-30 00:22:45 +00:00
Alec Berg
ab8a50b84e zinger: change behavior of pin PA0 for wakeup functionality
Zinger EVT units will have hardware change for PA0 to be able to
wake up from standby. Part of the change is that we have to output
high on PA0 in order for the comparator to compare against 0.65V, which
is inverted from the previous version.

BUG=chrome-os-partner:28335
BRANCH=none
TEST=reworked a p2 zinger with PA0 changes, plugged into samus,
and verified we still charge.

Change-Id: I7344f1d1decddc4e6600e41c313e1e7a5a5de067
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209832
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 19:17:43 +00:00
Vic Yang
b466ab4c67 ryu: Use firmware long press power-off timer
On Ryu, we are using TPS65913, which doesn't support the 8-second long
key press power-off. Let's switch to firmware timer.

BUG=None
TEST=Do a long power button key press, and see the AP powering off and
not restarting.
BRANCH=None

Change-Id: Ic9eb6d525498c7cdedf8f053dd0a2fa2b568a443
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209850
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 06:43:38 +00:00
Vic Yang
c557f7b7b9 Unify 'typec' console commands in different boards
We have three copies of 'typec' commands in three different boards. The
commands current mix hardware-specific logic and console command logic
together. Adding a board_get_usb_mux() interface to separate the logic
and deduplicate the console command logic.

BUG=None
TEST=make buildall
TEST=Test 'typec' command and verify GPIO settings.
BRANCH=None

Change-Id: Ie1825f49d32609c732db384679cb917f2f1a4082
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209955
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-07-29 06:43:34 +00:00
Alec Berg
0e402965fa cortex-m0: stm32f0: use RW vector table when running RW code
Currently, on stm32f cortex-m0 systems, interrupts are always being
directed to the RO vector table. This can cause strange problems when
running RW software because it is still calling IRQ handlers in the RO
code.

Unfortunately, on cortex-m0 the ability to specify the vector table
location in flash (VTOR register) is optional, and stm32f0 parts do not
have it. Instead, in order to run RW IRQ handlers, at init time, this
CL copies the vector table from flash to the base address of SRAM
(0x20000000), and then selects SRAM to be mapped to 0x00000000 where
the core looks to find the vector table.

BUG=none
BRANCH=none
TEST=Tested on zinger.
- Verified that vector table is copied to SRAM by printing out 48 words
from SRAM base address 0x20000000 in main() and verifying that it matches
the vector table in flash in the disassembly.
- Verified the vector table at SRAM 0x20000000 points to the RW handlers
when in RW and the RO handlers when in RO.
- Also printed out PC in one IRQ handler and verified it was in the
appropriate section of code.

Also, ran on samus_pd and did a sysjump RW to make sure at least one other
system works.

Change-Id: I22aff1b5e0de9b23fd3324f0cbe4f6c45a81967e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210063
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 04:36:44 +00:00
Alec Berg
eb3dee374e pd: zinger: add sending hard reset on pd_board_check() falut
Add back in sending hard reset on board fault.

BUG=none
BRANCH=none
TEST=Using zinger and firefly, create an overvoltage error by down
stepping with a 0 VOLTAGE_DOWN_STEP_TIME, and make sure that a hard
reset is received by firefly and that we re-establish negotiation
after the OVP fault is cleared.

Also tested with zinger and samus. On samus I set the input current
to 3.5A, which immediately triggers an OCP, and verified that we
get a HARD RESET from zinger and that after the reset we negotiate
correctly and get back to normal (note that when VBUS goes down, the
EC resets the input current limit to default 2A, so that's why we
don't continue getting OCP).

Change-Id: I991b15411c4ce05c1086851b1e2e56e2effab749
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209865
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 04:36:27 +00:00
Alec Berg
f7ed411926 pd: allow sink to request new voltage w/o dropping negotiation
Allow a sink to request a new voltage without dropping the established
negotiation. For this to work the sink must save the last received
source cap packet and use that to make a new RDO from the SNK_READY
state.

BUG=chrome-os-partner:30389
BRANCH=none
TEST=Tested on a firefly connected to zinger. made sure we can press
buttons to change voltage and we don't lose the existing negotiation.
Also tested on samus, ports 0 and 1, using pd x dev 5/12/20 to switch
between voltages and verified we don't lose existing negotiation.

Change-Id: I5a550b667f3aff7975185e091f3caac4555a907e
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209864
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 04:36:23 +00:00
Alec Berg
909c3236de zinger: fix down voltage transitions to keep output enabled
Fix bug in which output was disabled on down voltage transitions.
This also changes the behavior of the OVP protection. On down-step
transitions, the OVP threshold is not lowered for a specified amount
of time after the transition to allow the output to dissipate down to
the new voltage. This will still catch a problem if the voltage goes
up instead of down, but avoid OVPing immediately on a normal down
transition.

BUG=chrome-os-partner:30389
BRANCH=none
TEST=Attach to firefly and probe output voltage. Make sure we
transition smoothly going down in voltage.

Change-Id: I7f3a0c17cc8b392a25d24d56d2b7155b806acb64
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209863
2014-07-29 04:36:15 +00:00
Louis Yung-Chieh Lo
f93f1cfe77 hadoken: initial commit.
Board bring up. GPIO / UART / timer / console / task / hook are
working now.

BRANCH=tot
BUG=none
TEST=run on evaluation board and see LED 0/1 are blinking.
Console commands are available to use.

Change-Id: If93a2c94b8abe1c2c931c03a7a12ddd2bed9d9f6
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209403
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-07-29 02:21:22 +00:00
Vincent Palatin
bbb5b0636b ryu: limit input current to 1A
Limit the total input current to 1A, so we can power the board from a
workstation USB port when doing update with A-A cable.

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

BRANCH=none
BUG=none
TEST=connect the Ryu type-C port to a Z620 workstation USB port, and
verify that VBUS is not browning out

Change-Id: I05e65bd7feeb5e18f48c99bca9db43284e91251c
Reviewed-on: https://chromium-review.googlesource.com/207352
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2014-07-29 02:21:01 +00:00
Vincent Palatin
a36a871d12 tegra: Support firmware long-press power off timer
Some PMIC chip (e.g. TPS65913) doesn't support the 8-second long key
press power-off. For this, we have to check the state of the power
button in firmware, and do not assert PMIC_PWRON during the shutdown
sequence to prevent the AP from restarting.

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

BRANCH=none
BUG=none
TEST=with the next CL, on Ryu, do a long power button key press, and see
the AP powering off and not restarting.

Change-Id: I03f703b4ff6d86edea150dfa32f60d30f1ddffd9
Reviewed-on: https://chromium-review.googlesource.com/207381
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2014-07-29 02:20:54 +00:00
Vic Yang
e9d8a8cfb5 Bug fixes for USB PD policies
We used the incorrect src_caps index when choosing PD voltage. Let's fix
it to ask for all available power until we are able to ask only for what
we need.

BUG=None
TEST=make buildall
BRANCH=None

Change-Id: I068264246c2586b8192220eff47838da438899b0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207802
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 02:20:30 +00:00
Vic Yang
6e9cd48917 ryu: Lower battery charging voltage
The design voltage is 4.35V and the current charging voltage, 4.4V, is
too high. Let's lower this to 4.34V to meet the designed voltage.

BUG=none
BRANCH=none
TEST=none

Change-Id: Id5ab111d7ef390fe509adbb75112c78de1aab8a9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207687
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 02:20:23 +00:00
Vincent Palatin
4ecdf8fc0b ryu: add power sequencing
Update the Ryu board configuration to re-use the Tegra power state
machine.
Add the new HOLD GPIO which is wired to PE14 (TP2).

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

BRANCH=none
BUG=none
TEST=on Ryu, use the power button to switch on and off the AP.

Change-Id: I310438e0b923956d1539fb919c266a94909e3461
Reviewed-on: https://chromium-review.googlesource.com/206854
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2014-07-29 02:20:19 +00:00
Vincent Palatin
d7cc6d5911 power_button: allow to modify the active level
On most platforms, the power button is active low,
but the power button on Ryu is active high.
Add CONFIG_POWER_BUTTON_ACTIVE_STATE to override the default active
state.

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

BRANCH=none
BUG=none
TEST=on Ryu, use the servo pwr_button to start and stop the AP.

Change-Id: I11c6bb3c700bccd3606ce1fa1a69905671792990
Reviewed-on: https://chromium-review.googlesource.com/207274
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2014-07-29 02:20:15 +00:00
Vincent Palatin
63429076b3 battery: fix BQ27541/BQ27741 gas gauge driver
Update the code to be compatible with charge v2 expectations :
never return EC_ERROR_UNIMPLEMENTED for battery information else the
charge code continuously tries to read them again.

Fix the State Of Charge reading : on BQ27741 the gas gauge gets confused
if we do a 16-bit I2C read while a 8-bit read works perfectly.

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

BRANCH=none
BUG=none
TEST=run a Ryu connected to a Kirby battery and check the output of the
"battery" command.

Change-Id: Ic1d6128dc02efa47662fa5ca5b9e5de62420ebe8
Reviewed-on: https://chromium-review.googlesource.com/207273
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2014-07-29 02:20:11 +00:00
Vic Yang
f4ebbb821b stm32f0: Fix EC slave I2C interrupt
The interrupt handler is hardcoded to I2C1. We should choose between
I2C1 and I2C2 based on I2C_PORT_EC.

BUG=chrome-os-partner:30707
TEST=On Ryu, ectool hello and see ACK.
BRANCH=None

Change-Id: I07055b0ee7459e6cac5585737e200ff2d5814a34
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209960
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 00:02:47 +00:00
Alec Berg
f307874380 pd: sink change sending getSourceCap to hard reset after timeout
Changes to match this part of the spec:

The Sink shall support the SinkWaitCapTimer. When a Sink observes an
absence of Source Capabilities messages, after VBUS is present, for a
duration of tTypeCSinkWaitCap for the Type-C connector and
tSinkWaitCap after VBUS is present,for all other connectors the Sink
shall issue Hard Reset signaling in order to restart the sending of
Source Capabilities messages by the Source (see Section 6.6.4).

tTypeCSinkWaitCap shall be between 210 and 250 ms

Also set send source cap period appropriately:
tTypeCSendSourceCap shall be between 100 and 200 ms

This should help avoid transmission collisions during negotiation.

BUG=chrome-os-partner:30135
BRANCH=none
TEST=load onto zinger and samus and verify they negotiate correctly
10 times. Then loaded custom code to zinger to not send source cap
and verified we send hard reset. Also tested plankton to samus
negotiation works.

Change-Id: Idd6118e3e0a9f7a96ebeae9518c8b10457232c70
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209558
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-29 00:01:56 +00:00
Vic Yang
e852161dc4 plankton: Support 5V only mode
When Plankton is in 5V only mode, we should only advertise 5V
capability.

BUG=None
TEST=Connect to Samus. Check the PDO received on Samus.
BRANCH=None

Change-Id: Ia2b65c1b202aba291a008511801ede4d5c93aac5
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209481
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
2014-07-29 00:01:52 +00:00
Vic Yang
3a033a2bbf Plankton: console command for USB-C port control
The console commands will be used by the test host to control USB-C
port.

BUG=None
BRANCH=None
TEST=Manually verify the console command are working.

Change-Id: I4b229d9486bd970f6b73e9166ae1cb137d3530c6
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209347
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2014-07-28 21:53:17 +00:00
Alec Berg
537432085a Add board support for Plankton
Board support for Planton, the Raiden testing board for type-C
functional testing.

BUG=none
BRANCH=none
TEST=make BOARD=plankton, load onto a plankton, and verify
buttons are read correctly, and connect raiden to samus and
verify that PD communication is successful

Change-Id: I40922d5627d62f7f3540ac6a307596428d40baf5
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207724
2014-07-28 21:53:13 +00:00
Alexandru M Stan
3ac281f270 veyron: Sharing the single bicolor LED to also display power status
Veyron only has one bicolor led (green and orange) near the AC connector.

I dedicated the green channel for displaying power status:
	* Power on: Green
	* Suspend: Green in breeze mode ( 1 sec on/ 3 sec off)
	* Power off: OFF

Charging is now displayed only on the orange channel:
	 * Fully charged / idle: Off
	 * Under charging: Orange
	 * Battery low (10%): Orange in breeze mode (1 sec on, 3 sec off)
	 * Battery critical low (less than 3%) or abnormal battery
	   situation: Orange in blinking mode (1 sec on, 1 sec off)
	 * Using battery or not connected to AC power: OFF

The unfortunate side effect is that they have to share. So while the laptop is
charging in standby the led will blink orange(1s)-yellow(3s). While it's a
little ugly (it would have been nice to have 2 separate leds), it still provides
more information than how it was done before (where there was no indication of
power state).

BUG=None
TEST=Go through the various states (charging on/off/low and power on/off/
/suspend (warning: kernel doesn't report suspend to the EC properly yet, one can
still test this by reverting c/209668 "veyron: fixed SUSPEND_L line"))
BRANCH=None

Change-Id: I8ca0fb0909da1a186e4e5c451d8868e977b3ca1b
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209911
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Chris Zhong <zyw@rock-chips.com>
Commit-Queue: Doug Anderson <dianders@chromium.org>
2014-07-28 19:20:20 +00:00
Dominic Chen
3e993df474 usb: fix bug with multiple usb interfaces
for interface specific requests, the interface number is equivalent to
(wIndex & 0xff). this corresponds to ep0_buf_rx[2], since the setup
packet has format: bmRequestType (1), bRequest (1), wValue (2),
wIndex (2), wLength (2).

BUG=none
BRANCH=none
TEST=verify stm32 does not panic with multiple interfaces

Change-Id: Ied7750035f87fa81f9a6c03c6e73ae606c110398
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209903
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-28 19:19:53 +00:00
Vincent Palatin
47e74b8ca8 zinger: do not trigger OCP on transients
Ensure that the slow OCP (thermal/power protection) is not triggering
for power spikes below 20us, by sampling 4 times (with a 5us sampling
period).

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

BRANCH=none
BUG=chrome-os-partner:28331
TEST=connect Zinger to Firefly+electronic load, test with various
current pulse widths and amplitudes.

Change-Id: Ic8150dbbf191c002bba9e8d3f70beb47af4577b9
Reviewed-on: https://chromium-review.googlesource.com/204588
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2014-07-28 17:12:35 +00:00
Alec Berg
1faa6ee202 samus: include a force source mode for dual-role ports
Include a force source mode for dual-role ports to allow us to
force a dual-role port into being a source.

BUG=chrome-os-partner:28782
BRANCH=none
TEST=tested on plankton, verified using the pd 0 dualrole console
command.

Change-Id: Ic4c2a9e11984b34b1dec09d5c71e1fd15ed9198c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209071
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-07-28 17:12:20 +00:00
Alec Berg
3060d32ff9 samus: pd: dual USB-PD port support for samus
Adds dual USB-PD port support for samus. Both ports are in dual-role
and can perform either role.

Both ports work fine when only one of the ports is in use. But,
still having problems with PD errors on the lower priority port (port
0). If you have a charger plugged into port 0, and a type-C USB dongle
plugged into port 1, then port 1 has higher priority, and in the
SRC_DISCONNECTED state, every 1.5 seconds when it sends source cap
packet, we occasionally drop pings on port 0, which results in a
lot of start/stop charging.

BUG=chrome-os-partner:28585
BRANCH=none
TEST=Tested on samus to make sure both ports work when I
plug in a charger and a type-C USB dongle with a pull-down on the CC
line. Tested on plankton and zinger to make sure PD works as expected.

Change-Id: Ie7bde3e258f5cd23a0b82b626c0993a45b0df074
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200750
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2014-07-28 17:12:15 +00:00
Gwendal Grignou
d89d34516c [ryu_sh] Add option to flash the sensor hub
servo is already aware of the sensor hub.
Using samus_pd as an example, set the proper argument to flash
an image to the sensor hub.

BUG=chrome-os-partner:30801
BRANCH=None
TEST=None

Change-Id: I0c8465d1e34d515224675957c3e8482392585a56
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209232
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-07-28 07:18:42 +00:00
Alec Berg
5778a9943a stm32f07x: increase RAM space to 16kB
Increase RAM_SIZE for all stm32f07x chips to 16kB to use all of
on chip SRAM.

BUG=none
BRANCH=none
TEST=added 4000 byte array, verified in ec.RO.map that we are using
the new RAM space (bss size over 0x2000), loaded on samus and
verified that we could read and write to the 4000 byte array.

Change-Id: Ided3ce7c5fb353c9c37a01e6ed64f03786717e9b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209847
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-07-26 00:01:40 +00:00
Alexandru M Stan
762ad07cff veyron: fixed SUSPEND_L line
Pulled down line so it's not so erratic.
Fixes the issue where the EC doesn't know what state the AP is in.

BUG=None
TEST=EC should report S0 correctly(not S3 all the time). `power on` and
`power off` will also work correctly(instead of doing absolutelly nothing).
BRANCH=None

Change-Id: I69bd17b39d2bd8f7f0456c4babc4ad9f8f34c8bd
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209668
Reviewed-by: Chris Zhong <zyw@rock-chips.com>
2014-07-26 00:01:13 +00:00
Alexandru M Stan
37380d2312 veyron: renamed PMIC_THERM_H -> PMIC_SOURCE_PWR_H
It is now the proper name.

BUG=None
TEST=None, only name changed. EC should work as expected still.
BRANCH=None

Change-Id: Ia63db6fa0dc41750ebf31423c9870f8a463bf392
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209814
Reviewed-by: Chris Zhong <zyw@rock-chips.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-07-25 21:53:35 +00:00
Vic Yang
915224b6d7 ryu: Kick battery out of disconnect state when AC is attached
Like Samus, the battery can be placed into a disconnect state. This CL
implements the necessary function to determine if it is so and kick it
out of this state when possible.

BUG=chrome-os-partner:30633
TEST=Put a battery in this state. Plug in AC. Verify the battery is
revived.
BRANCH=None

Change-Id: I074a72a2efe3844cbdfb0eda16a25fd8d1755a9b
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209634
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-07-25 03:46:03 +00:00
Alec Berg
701bbe8764 zinger: fix USART register macro bug
Fix bug in which we were using the wrong index to the USART register
macros. This bug was recently introduced in:
https://chromium-review.googlesource.com/208488

BUG=none
BRANCH=none
TEST=load code on zinger and verify serial console works

Change-Id: I03142a8cafb68e0cbbcba4b720e7ec89fe20110b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209557
Reviewed-by: Anton Staaf <robotboy@chromium.org>
2014-07-25 03:42:38 +00:00
Vic Yang
7da0f8ff68 Disable building test binaries for samus_pd
We are running out of RAM space for samus_pd. Let's disable test
binaries for now. Note that this has nothing to do with unit tests.

BUG=None
TEST=make BOARD=samus_pd tests. Nothing happens.
BRANCH=None

Change-Id: I39db9b914e8539b4585a93a8732dc42248a9a6bf
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209781
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
2014-07-25 03:42:33 +00:00
zyw
51a53492ba veyron: copy battery info from rambi
Fixed "un-recognized battery Manuf:Simplo, Device:0C9".

BUG=None
TEST=Read the correct battery info in the log
BRANCH=None

Change-Id: I960729541203705c15157aae61833457b727efa4
Signed-off-by: zyw <zyw@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/209402
Reviewed-by: Alexandru Stan <amstan@google.com>
Commit-Queue: Alexandru Stan <amstan@google.com>
Tested-by: Alexandru Stan <amstan@google.com>
2014-07-23 20:41:36 +00:00
Alec Berg
c32c5571a5 samus_pd: stm32f0: check warm reboot before initializing ADC
Check for warm reboot before initializing ADC. Part of the initialization
process involves calibration of the ADC, which can only be done when the
ADC peripheral is disabled. This fixes a bug on samus_pd where jumping to
RW causes a watchdog because ADC reads hang.

BUG=chrome-os-partner:30079
BRANCH=none
TEST=on samus_pd, without this change running sysjump rw causes us to jump
to RW and then causes a watchdog. With this change sysjump rw works. Also
verified that PD communication works in RW, which means ADC channels are
being read correctly after jumping to RW.

Change-Id: Iaa41da4795c3d15a6db56b0d715e36c29417d9b6
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209331
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-07-23 18:35:42 +00:00
Dominic Chen
205f6f6746 spi_flash: add error checking for dma timeouts
BUG=none
BRANCH=none
TEST=verify timeouts are caught by spi_transaction_*()

Change-Id: I2e28ccbce58e555262bc4448a1c2e1a50253613e
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209116
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-07-23 11:09:06 +00:00
zyw
054c9fe6a6 veyron: Modify board config
This patch is base on new hardware board, veyron has not some stuff,
such as power led, charge en

BUG=None
TEST=Read log with servo board, it has reponse when type some commends
BRANCH=None

Change-Id: I45502fd1278f69db5e46fc9ab1deaee02fc8708f
Signed-off-by: zyw <zyw@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/209231
Reviewed-by: Alexandru Stan <amstan@google.com>
Commit-Queue: Alexandru Stan <amstan@google.com>
Tested-by: Alexandru Stan <amstan@google.com>
2014-07-23 02:30:10 +00:00
Shawn Nematbakhsh
b9677a48c8 samus: Kick battery out of disconnect state when AC is attached
The Samus battery can be placed into a disconnect state by asserting a
disconnect input signal. In this state, the battery will not function
until a charging current is applied. This patch adds detection of the
disconnect state. If a battery in disconnect state is found, a current
is force-applied to the battery to kick it out of disconnect.

BRANCH=None
TEST=Manual on Samus.
1. Put battery into disconnect state
2. Pull AC, then reattach AC
3. Verify "found battery in disconnect state" is seen on the
EC console.
4. Pull AC and verify that EC console is still accessable
Also verify that battery gets out of reset state:
1. Pull AC
2. Issue "i2cxfer w16 0 0x16 0x0 0x12" command on EC console
3. Re-attach AC
4. Pull AC and verify that EC console is still accessable
BUG=chrome-os-partner:29465

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ib4268887fb483094ac4e641749200268160d3014
Reviewed-on: https://chromium-review.googlesource.com/209013
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
2014-07-23 02:29:59 +00:00