Commit Graph

847 Commits

Author SHA1 Message Date
Alexandru Stan
423c40c5a0 Created Veyron board folder based on Big
The 2 boards are similar enough to test stuff on big for now, at least
until the new hardware comes.

Also added veyron to flash_ec.

Also cleaned up the style: pre-upload.py was giving errors on files
that were unmodified from big(spaces instead of tabs).
I had to ignore this though:
> ERROR: Macros with complex values should be enclosed in parenthesis
> #471: FILE: board/veyron/board.h:35:
> +#define KB_OUT_PORT_LIST GPIO_A, GPIO_B, GPIO_C

BRANCH=none
BUG=chrome-os-partner:30167
TEST=~/trunk/src/platform/ec $ make BOARD=veyron clean &&
make -j BOARD=veyron && util/flash_ec --board=veyron --ro
verify ec is alive and version is reported as veyron

Change-Id: I1f4bd562c0ab55360a2160a753ad8ad9b58f8c47
Signed-off-by: Alexandru Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/207270
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
2014-07-11 01:56:17 +00:00
Alec Berg
6ab38d8715 samus: use real AC_PRESENT signal
Revert
- https://chromium-review.googlesource.com/#/c/205145/2
- https://chromium-review.googlesource.com/#/c/205147/4

Now using the real AC_PRESENT gpio signal instead of whether or
not the PD MCU negotiated for 20V.

BUG=chrome-os-partner:29841, chrome-os-partner:29842
BRANCH=none
TEST=tested on a board with reworked AC_PRESENT signal. Verified
that gpio is correctly reporting state of AC and is charging when
AC is plugged in. Tested the no battery case to make sure
board powers on and stays on with just a charger. Also tested the
dead battery case by plugging in a dead battery, then plugging in
a charger and making sure system powers on and starts charging.

Change-Id: I4424771c91c8a2aa19eda68a8b5194e9265d529c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206598
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-07-11 01:55:13 +00:00
Vincent Palatin
bc4973c1f9 ryu: bringup fixes
- tune stack sizes
- re-order properly the ADC definitions
- select the right battery gas gauge

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

BRANCH=none
BUG=none
TEST=on Ryu, exercise ADC and battery using the EC command-line.

Change-Id: Idc307b1c1ce1d35e7b5fa2c86f956cc4c8b08783
Reviewed-on: https://chromium-review.googlesource.com/207272
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-07-10 21:21:00 +00:00
Anton Staaf
c14b0644e3 discovery-stm32f072: Initial working version
This version of the EC firmware just provides a console and some
blinking lights for the stm32f0 discovery board.  This is a
convenient board to work with for peripheral bringup.

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

BRANCH=none
TEST=make buildall -j

Change-Id: I9ae87235e8a505d58fa7a5c996528c4dd6c3f2ac
Reviewed-on: https://chromium-review.googlesource.com/207130
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
2014-07-09 20:30:21 +00:00
Vincent Palatin
88e0d79cf2 Add board support for Ryu
Add the Ryu board configuration and USB Power Delivery configuration.

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

BRANCH=none
BUG=none
TEST=make BOARD=ryu

Change-Id: I61f6f19dc9fe19e1d9f9017c1050fc8a30a862e7
Reviewed-on: https://chromium-review.googlesource.com/206586
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-09 05:32:00 +00:00
Vincent Palatin
d195d0b60a samus_pd: fix type-C ports muxing
The HW signals to control the type-C ports muxing have changed between
Fruitpie and Samus, update the code to match the HW.

Also add the docking mux option and update the board muxing code to
prepare for the automatic mode detection :
- the polarity will be determined by the PD code.
- the port muxing will be enable/disable by the common alternate mode PD
  code.

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

BRANCH=none
BUG=none
TEST=make buildall

Change-Id: I0706626270c73d2a5e3f85b86e65a7c4fc21f9ec
Reviewed-on: https://chromium-review.googlesource.com/206685
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-09 05:31:56 +00:00
Vincent Palatin
9463fdcb1a firefly: add interrupt to detect VBUS transitions quickly
Use the interrupt as faster detection when VBUS is going off, so we are
not missing when the source is cutting its output due to a fault.

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

BRANCH=none
BUG=none
TEST=Connect Firefly to Zinger, trigger a short OCP with the electronic
load, once Zinger has recovered from the fault, see Firefly
re-negotiating voltage.

Change-Id: I4d273a0007d1e79884e0acbf75509ab9c8578893
Reviewed-on: https://chromium-review.googlesource.com/207031
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-07-09 03:29:53 +00:00
Vincent Palatin
eaddeb502e firefly: add VBUS detection
Enable the VBUS detection to be able to re-negociate a PD contract when
we are losing power.
The VBUS_WAKE GPIO is broken on the current hardware (not triggered when
VBUS is 5V), so we fall back on using the ADC on VBUS_SENSE.

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

BRANCH=none
BUG=none
TEST=With a Firefly connected to a Zinger,"fault" the power supply to
get it to turn off its output. See Firefly detecting the cut-off and
re-negotiating voltage.

Change-Id: Ia5f0734cbd8f20d84ce170cea191410bb72a87c3
Reviewed-on: https://chromium-review.googlesource.com/206944
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-07-08 19:30:36 +00:00
Vincent Palatin
2d1509cd16 firefly: switch on 5V LED by default
The default VBUS voltage is 5V, let's switch on the matching LED rather
no LED when no voltage has been selected.
This allows to know that the board is powered.

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

BRANCH=none
BUG=none
TEST=power up Firefly and see the 5V LED ON (if the cable is plug) or
blinking (if the cable is unplug).

Change-Id: I8f6525bc6f901daf21af9b20eede2a9b1e8dbfdf
Reviewed-on: https://chromium-review.googlesource.com/206940
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-07-08 04:24:38 +00:00
Dominic Chen
8291fd3841 fruitpie: restore PD_TX_EN GPIO on exit from debug mode
this fixes the previous patch to correctly restore the GPIO

BRANCH=none
BUG=none
TEST=verify that GPIO state after restore matches default

Change-Id: I42f73d21399f5e9429dfb50aacb6aba59ba33315
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206905
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-08 02:17:54 +00:00
Louis Yung-Chieh Lo
66f4c2e700 Increase stack size of charger and chipset tasks.
(cherry-pick back to ToT)

The comment #20 of issue 29162 looks like a stack overflow to me.
The issue 29067 also shows the stack is overflowed in some case.
Let's increase that.

BUG=chrome-os-partner:29067,chrome-os-partner:29162
BRANCH=nyan,tot
TEST=build only. Should run RunIn.DozingStress.SuspendResume/RunIn.Reboot2.

Change-Id: Ic7fc7c8fa9e817b2db497ebedcdff6cb8c49c565
Origin-Change-Id: If3b97af578362eb6d2794b331716f499be7ad066
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204277
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206921
2014-07-08 02:13:30 +00:00
Alec Berg
9ba7bd4284 pd: clean up beg/end transitions of PD comms
Fix the beginning and end of BMC PD communication:
- Initial transmission within 1us of taking control of CC line
- CC line released between 1us and 23us after last edge
- If final bit is a 0, then add two 1 bits to the end
- No garbage after the final bit

BUG=chrome-os-partner:30132
BRANCH=none
TEST=tested with a fruitpie, samus, and zinger.
verified timing on scope.

Change-Id: Ie45695eb367a7554cf5d5b76b6fbdf1e3fc85d29
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206453
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-03 05:25:13 +00:00
Vincent Palatin
6473343075 better unhandled exception panic without runtime
On panic, reboot properly the CPU rather than just jumping to the reset
vector as that might lead to some incorrect initializations.

Properly plug the div by 0 to the panic handling.

Add a small trace if the debug output is activated.

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

BRANCH=none
BUG=chrome-os-partner:29840
TEST=add adhoc code triggering a data abort and see the firmware
printing a trace, then rebooting immediatly in a working state.

Change-Id: I1d5a98d9113c8ae08e05588a40f941d1ed22cebe
Reviewed-on: https://chromium-review.googlesource.com/206268
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-07-03 02:56:52 +00:00
Vincent Palatin
f9c24c37c4 zinger: update OVP latch condition
The Over Voltage Protection was de-activated when the output is disabled
to avoid false positive when doing a down voltage transition,
but as a side effect, we might reset the OVP while the fault is still
present since the OVP first disables the output.
So, we want to keep testing the OVP fault condition if there is a
pre-existing fault.

Also add a hysteris and ensure we recover from OVP only when we go under
the new threshold.

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

BRANCH=none
BUG=chrome-os-partner:28331
TEST=trigger an OVP using a voltage source and see the output is not
re-enabled until we shutdown the voltage source.

Change-Id: Idef3f630c3cfeb301e62f1e75c2a424b56bc98dd
Reviewed-on: https://chromium-review.googlesource.com/206185
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-07-03 02:55:38 +00:00
Dominic Chen
73ad1f30c8 fruitpie: add board specific initialization and debug code
remap DMA at startup, add function to switch mux and set gpio for usb debug

BRANCH=none
BUG=none
TEST=verify that gpio/mux set correctly for debug

Change-Id: I2ca39025c0cba3b5d04946ec4685a81c4de2d49f
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203493
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-07-02 00:45:25 +00:00
Anton Staaf
3500c28b50 gpio: Reformat gpio.inc files to use longer than 80-column lines
These files are tabular data more than source code.  We discussed
and concluded that the 80-column limit makes them harder to read,
not easier.  This commit reformats them to take advantage of
longer lines, mainly by putting per GPIO comments on the end of
the line that defines the GPIO.

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

BRANCH=none
TEST=make buildall -j

Change-Id: I60f3e3620680196eb9462f97b34c453289240465
Reviewed-on: https://chromium-review.googlesource.com/205672
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-07-01 00:43:04 +00:00
Alec Berg
9924b19d6f samus: set various GPIOs to interrupt on deep sleep
Set input points to interrupt on deep sleep as necessary.

BUG=none
BRANCH=none
TEST=make -j buildall and run on system without any notable
differences.

Change-Id: I7bcf336a676e259dfa4c73ffc7152f16f14093d2
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205146
2014-06-27 22:54:16 +00:00
Duncan Laurie
635a57eede samus: hack to read AC present state from PD
The ACOK input to the EC is not connected to the charger so
that signal cannot be relied on for AC presence.  Instead
have the PD report when it negotiates to 20V and when it
disconnects and have the EC use that for AC presence.

BUG=chrome-os-partner:29841
BRANCH=none
TEST=test charging with zinger on samus system.

Change-Id: Ia9096a24ab05d110e31910218dc8c214a846a9a4
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205145
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-27 18:31:31 +00:00
Vic Yang
ae15dc8ce5 mec1322: Add SPI master driver
This allows us to use the two SPI ports as SPI master. Also, to save CPU
time on reading large amount of data, let's add an async interface for
SPI transaction.

BUG=chrome-os-partner:29805
TEST=Read manufacturer ID from SPI flash with sync/async interface
BRANCH=None

Change-Id: I427f4215602cccc55c4151f4116226b1e0ccc15e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204719
2014-06-26 06:48:37 +00:00
Anton Staaf
9ccfd4553e gpio: Replace duplication in gpio declarations with X-macro file
Previously each board.h and board.c contained an enum and an array
for gpio definitons that had to be manually kept in sync, with no
compiler assistance other than that their lengths matched.

This change adds a single gpio.inc file that declares all gpio's
that a board uses and is used as an X-macro include file to
generate both the gpio_signal enum and the gpio_list array.

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

BRANCH=none
TEST=make buildall -j

Change-Id: If9c9feca968619a59ff9f20701359bcb9374e4da
Reviewed-on: https://chromium-review.googlesource.com/205354
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-06-26 02:43:01 +00:00
Vincent Palatin
f2b9ba0ac9 zinger: tune over-current protection
As per the new spec, use the fast OCP to protect against the
short-circuits by putting the threshold at 4.5A.
Set the slow OCP (a few dozen milliseconds latency) at 3.6A to limit the
accepted current range.

Also sample the current/voltage over a larger period (5us) to limit
noise issues.

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

BRANCH=none
BUG=chrome-os-partner:28331
TEST=plug Zinger on an electronic load and trigger the OCP with various
pulses.

Change-Id: Ia66cd186716aebf88646cbf5fd340388f8cdd48d
Reviewed-on: https://chromium-review.googlesource.com/204590
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-06-26 02:42:27 +00:00
Duncan Laurie
a56f966556 samus_pd: Allow samus PD MCU to negotiate before battery is detected.
This is a temporary hack to allow PD MCU to negotiate for 20V before
EC tells it that the battery is present. This is currently necessary
because at 5V, we don't have enough power to boot the AP, and we can't
wait to boot the AP until we negotiate because the zinger tends to
get stuck in an infinite reboot loop when the AP is off.

Note that this will need to be removed when we implement PD software
sync because the whole point of that is to not talk to outside world
until we verify our code.

BUG=chrome-os-partner:29840
BRANCH=none
TEST=Tested on samus 2A and 2B boards, made sure system could boot
with and without battery.

Change-Id: I03f319bf81b4e90758132e774848dff5542f4ce5
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205144
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-24 20:07:57 +00:00
Duncan Laurie
447eafb55a samus: fix input current to 2048
This changes the input current limit to 2048mA with no ramp up.
Problem is that the bq24773 is doing a really poor job of measuring
input current, so even though the zinger side can support 3A, the
samus side can cause over currents down to 2300mA. This is set
consertavily to avoid over current errors and will need to be
updated when the hardware allows.

BUG=chrome-os-partner:24461
BRANCH=none
TEST=Used bench top power supply to power multiple samus 2A proto
boards and gathered data on max current samus was drawing based on
input current setting. Samus was often underestimating current by
300-700mA.

Change-Id: Iabeb0d026f2b72a9ee539d92579ee6d11aeaa56b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205143
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-24 20:04:55 +00:00
Duncan Laurie
88a5589c0e samus: Increase charger task stack size
Increase the stack size for the charger task to work around I2C
battery communication issues.

BUG=chrome-os-partner:29839
BRANCH=None
TEST=watch for I2C0 transation failures and ensure that the charger
task does not stack overflow and reset the EC+system.

Change-Id: Iabae3e2c302b68eb9e25a604dd72ef48128866df
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205142
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-24 20:04:51 +00:00
Doug Anderson
68abc0f428 watchdog: Give more leeway to the independent watchdog
It would be really nice to be guaranteed to see watchdog warnings
before we actually hit a watchdog reset even if something strange is
going on with the CPU.  Let's increase the margin between the timer
and the independent so that the hardware watchdog is really hit as a
last resort.

It seems like a 1.6 second hardware watchdog wouldn't be the end of
the world so let's bump that way rather than increasing the number of
warnings.

BRANCH=ToT
BUG=chrome-os-partner:29162
TEST="waitms 1000" on EC console no longer ever reboots and "waitms
2000" usually does.

Change-Id: Ic5e5ddec22fb8484cc7c552b19d3f2043c105d0c
Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204895
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-23 21:48:42 +00:00
Duncan Laurie
a5e93651fb samus: Remove PP1800_PGOOD check
The PP1800_PGOOD pullup resistor was no-stuff on P2B boards so
the input value is floating and cannot be relied on for proper
sequencing.

Before P2B it was always pulled up so it was not a useful signal
to wait on anyways.

BUG=chrome-os-partner:29502
BRANCH=None
TEST=buid and boot on samus proto2b

Change-Id: I29167d55bb0ef36683282946b912dd8cf5b405cf
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205140
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-06-22 00:24:42 +00:00
Duncan Laurie
6232d78df5 samus: Support both Proto2A and Proto2B sequencing
Use the board version to implement both power sequence behaviors
in order to support both boards with one EC image.

The order of bits used to calculate board version was swapped so
update the GPIO table to reflect that.

BUG=chrome-os-partner:29502
BRANCH=None
TEST=build and boot on samus proto2a

Change-Id: Ib0f6010163af4b3bf9b39f64c26220aee43618ef
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204869
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-06-22 00:24:38 +00:00
Alec Berg
323273daeb zinger: fix bug, increase watchdog timeout to 1.8s
Fix bug and actually increase watchdog timeout to 1.8s.

BUG=none
BRANCH=none
TEST=put a 3 second blocking delay in pd_task and make
sure watchdog reboots. set blocking delay to 1.5seconds
and make sure no reboot.

Change-Id: Ie66621a3bd98354f9fd22b9b10a866d004277340
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204471
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-20 18:27:26 +00:00
Vincent Palatin
1a4bf7fdaa zinger: update current and voltage sensing gains
On the P2 boards, the operational amplifier gain for current sensing is
exactly x100 rather than x101.
(non-inverter configuration with R1=1.8kOhm R2=178kOhm)

The voltage gain constant had a typo introducing a 10% error.
the voltage divider is 10k/100k,so it's x11 gain.
ie it should be written (10+100)/10 rather than (10+110).

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

BRANCH=none
BUG=chrome-os-partner:28331
TEST=make BOARD=zinger
checked manually with a voltmeter and traces.

Change-Id: I8097ab50149fee319efc11ebae75802e8a49a7f8
Reviewed-on: https://chromium-review.googlesource.com/204540
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-20 18:27:16 +00:00
Vic Yang
94acd01e0c Keyborg: implement methods needed for touch wake
In order to wake the chips from STOP/SLEEP mode with a touch, we need to
put the two chips in correct state before going into STOP/SLEEP mode.
Also, when one of the chips wakes up, it needs to wake the other chip
with GPIO interrupt.

This CL implements the necessary methods and also adds a sample routine
that put the chips in STOP mode and wait for a touch using the
implemented methods.

BUG=None
TEST=Build and boot. Touch the panel and see the response in console.
BRANCH=None

Change-Id: Ia5f7df8b550ee2459bcae1840f8a2717c8d947ce
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204482
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-19 03:25:12 +00:00
Vic Yang
6c8e451ff0 IRQ list support for enabling specific IRQs without common runtime
This adds back DECLARE_IRQ() support when building without common
runtime. With this, we can enable only a subset of IRQs and avoid
linking in other unused IRQ handlers.

Note that after this change, all boards without common runtime need to
have a ec.irqlist file.

BUG=None
TEST=Build Keyborg and check it still works.
TEST=make buildall
BRANCH=None

Change-Id: If68062a803b9a78f383027a1625cf99eb3370d3f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203264
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-19 03:25:08 +00:00
Vincent Palatin
b162ac513a twinkie: initialize INAs at startup
Disable INA1 to avoid leaking current from VCONN2.
Put the calibration in INA0.

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

BRANCH=none
BUG=chrome-os-partner:28337
TEST=plug Twinkie and measure VBUS current/voltage.

Change-Id: I6b063460a86a7a3dd87ec5e3c2c9b992b66db146
Reviewed-on: https://chromium-review.googlesource.com/204468
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-06-18 21:11:15 +00:00
Vincent Palatin
4957dcbd87 twinkie: fix GPIO settings
The high FET on the TX path should be driven low to disable it by
default.
The SCK pin (SPI clock input for TX) is on PA5.

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

BRANCH=none
BUG=chrome-os-partner:28337
TEST=scope outputs

Change-Id: I72fa52a170ae0e4043beb88d4fd82680ed4aefa2
Reviewed-on: https://chromium-review.googlesource.com/204165
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-06-18 01:36:46 +00:00
Alec Berg
0d0b53e7ca zinger: change watchdog timeout to 1.8 second
Increase watchdog timeout to 1.8 second. The pd_task can delay up
to 1.5 seconds, so the watchdog must be at least that value.
On Zinger, the new timeout period will be 2 seconds with LSI clock at 50kHz
and 3.36 seconds with LSI clock at 30kHz.
Note: the LSI frequency range is tighter on STM32F0 and cannot go up to
56kHz.

BUG=none
BRANCH=none
TEST=add 1.5 second blocking delay to pd_task and make sure
watchdog is normally not firing.

Change-Id: I444639ccacd3452181a5fb6caab8e5df7ef3c847
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/204333
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-17 18:34:03 +00:00
Vic Yang
21aa3f7a48 Keyborg: improve async slave response
Currently the master and the slave must synchronize before starting
slave response. This is to make sure the previous slave response is done
and the slave is ready for the next response. By enabling interrupt on
the master side to capture slave ready event, we can get rid of the
extra sync's. This saves about 1300 us per frame.

BUG=None
TEST=Build and boot. Measure time. Examine heat map.
BRANCH=None

Change-Id: I3c319d8a3636f1f6ae905d7021433c3ba220c9b0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203789
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-15 11:53:25 +00:00
Duncan Laurie
a0119238c7 samus: Power sequence changes for P2 boards
- Wait for SLP_SUS to deassert before bringing up PP1050 to avoid
leakage when PP1050 is enabled before the PCH is ready.
- CPU PGOOD is now connected to RSMRST_L on PCH.  Configure this
GPIO as an output and hook it into the power sequencing.
- Add a "chipset_force_g3()" function to use for aborting G3->S5
transitions when there is an issue with a rail not coming up.

BUG=chrome-os-partner:29502
BRANCH=samus
TEST=build for samus, tested on reworked p1.9 board

Change-Id: Ib0251943864594ee89a4a9f2c71c45da2c01f44e
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203081
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-06-13 20:37:26 +00:00
Alec Berg
6c41e626e2 fruitpie: detect source disconnect and go to disconnected state
Detect when VBUS is disconnected when acting as a sink and go to
the disconnected state.

BUG=none
BRANCH=none
TEST=Connect a zinger to fruitpie, run pd state from console to
verify it is in SNK_READY, then remove zinger and verify the state
changes to SNK_DISCONNECTED.

Change-Id: I0b46cfe3ac129f1ec9c11327c9e0d45c0c6761e8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203564
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-13 05:35:16 +00:00
Vic Yang
9e7cca1625 Keyborg: remove unneeded 64-bit integer operation
The timer on Keyborg is only of 32-bit width, so we should always use
get_time().le.lo instead of get_time().val to avoid unneeded 64-bit
integer operations. This saves about 0.66 us per call to
master_slave_sync(), which is called about 500 times per frame.

BUG=None
TEST=Measure the time used on master_slave_sync().
TEST=Boot and check touch scanning still works.
BRANCH=None

Change-Id: I6668cda3c6c00d1af971fc55fcc8d643b83a4578
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203670
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-13 05:35:12 +00:00
Vic Yang
9359462f44 Keyborg: always send max size packet on slave response
In order to make SPI CRC work, we had to ensure the master and the slave
agree on the size of slave response. This required us to first send the
response size and then send the full response. The downside of this is
that we cannot take full advantage of DMA.

Given the SPI bus is fast enough, let's add an option to always transfer
max size packet on slave response. This incurs some overhead as unused
bytes are also sent, but the overhead doesn't affect us when the slave
is busy with touch scanning. (The scanning time is longer than
transferring 64 bytes over SPI.) This situation may change in the
future, so make it a compile time option for now.

Also removed the use of RX channel on the slave side when the slave is
sending response. The RX channel is useless in this case.

BUG=None
TEST=Build and measure scan rate w/ and w/o
CONFIG_KEYBORG_SPI_FULL_PACKET flag.
BRANCH=None

Change-Id: I4b23b1d89903dd022b445eb81667679276858008
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203660
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-13 05:34:53 +00:00
Alec Berg
507bbda444 samus_pd: extend typec console cmd to work for both type C ports
Added extra arg to typec console command to give the port number (0 or 1)
in order to set the muxes appropriately for both ports.

BUG=none
BRANCH=none
TEST=make -j buildall

Change-Id: I7abddb9f27c22082aed0fbf09a301ca2d5e7c5fc
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203653
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-13 05:34:24 +00:00
Alec Berg
7b27c02a24 samus_pd: board file changes for version 2 and 2B
Samus PD MCU board file changes for version 2 and 2B of the
samus board.

Adds more I/O for case closed debugging, adds sensing of
VBUS voltage (boostin), and moves USB C0 BC12 interrupt pin.

BUG=none
BRANCH=none
TEST=none

Change-Id: I545ff518add19919d1747de91318c33363d99403
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203314
2014-06-13 05:34:20 +00:00
Vic Yang
054d4772d0 Keyborg: disable fast scan at compile time instead of run time
This slightly reduces binary size and increases scan rate when running
without fast scan.

BUG=None
TEST=Build and boot w/ and w/o fast scan.
BRANCH=None

Change-Id: I66683dce9c8f5e74f86764d8a4f33f4e1a161e08
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203633
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-13 03:12:41 +00:00
Alec Berg
dcd905802b samus_pd: add PCH inputs to GPIO list
Add PCH inputs to GPIO list but don't enable interrupt.

BUG=none
BRANCH=none
TEST=make -j BOARD=samus_pd

Change-Id: Ife43375f8e8369516d9b363a39f9b3b9ab8a11ef
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203528
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-06-12 04:31:23 +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