Commit Graph

2846 Commits

Author SHA1 Message Date
Alec Berg
6cfc7a68ae samus_pd: enable check for protected mode to prevent PD comm
Enable check for protected mode. If we are in RO and we are write
protected, then don't allow PD communication.

BUG=chrome-os-partner:31125
BRANCH=none
TEST=Booted with and without battery, made sure PD communication
works and we can boot (note we are currently not protected).

Then commnented out CONFIG_SYSTEM_UNLOCKED, and ran flashwp enable
from PD console to protect the system. Now when boot with battery,
we don't communicate over PD and just take VBUS 5V. Removed battery
and attempted to boot with just AC, but not enough power to boot
off just 5V. EC goes to S0 and back to G3 after about 100ms.

Change-Id: Ib26f8f0f5e9134d0337ebbd7f087f50fa41842d8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213738
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2014-08-23 02:43:38 +00:00
Duncan Laurie
9e79ca7949 Support inverted ILIM_SEL for smart USB port power
Some platforms may have active low ILIM_SEL that is per-port
and the output needs to be inverted.

BUG=chrome-os-partner:31549
BRANCH=samus
TEST=emerge-samus chromeos-ec, not used until EVT

Change-Id: I1e164d9aa46df119467113eb175e7deec4fd8a21
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213743
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-23 02:42:21 +00:00
Vincent Palatin
2e0de3c50f zinger: add voltage discharge
When the power supply voltage is transitioning to a lower value, use the
discharging FET to ensure that the voltage is acceptable before
re-enabling the output.

Note: when discharging, we must disable the fast OCP ADC interrupt, but
that is ok because we still have the slow OCP check in board_checks().

BRANCH=none
BUG=chrome-os-partner:28332
TEST=on Zinger, transition from 20V to 5V using Firefly buttons and
observe that we no longer have an over-voltage event. Also, verified
that fast OCP triggering still works after a discharge.

Change-Id: Ie327645e74819aebd1260f5ce16b2ba46a674a7b
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/201577
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-08-23 02:42:17 +00:00
Randall Spangler
6f22113a78 Request to hard-reboot EC should reboot PD as well
Software sync on the AP will ask the EC to reboot to RO after the AP
shuts down.  This allows the AP to do a clean shutdown before the EC
reboots.  The PD chip should be rebooted at the same time the EC
reboots itself, so that in a low-battery case the requested PD reboot
also takes place after AP shutdown.

BUG=chrome-os-partner:30079
BRANCH=none
TEST=From the EC console, 'reboot hard' also reboots the PD chip.

Change-Id: I109a495ca32ad1ac4aac42708935962d3226792e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210570
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-23 02:42:11 +00:00
Alec Berg
1b82905cfe Add hysteresis to host events for battery capacity changed
Adds a small threshold for sending a host event to battery whenever
the full capacity changes. This helps avoid constant host events
when the battery decides the capacity is going back and forth 1mAh

BUG=none
BRANCH=none
TEST=load on samus. set LFCC_EVENT_THRESHOLD to 1 and see host
events very often. set LFCC_EVENT_THRESHOLD to 5 and see no host
events.

Change-Id: I2dc38f04e1a634539837dfed19b10ccfcfd0a8a3
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213668
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-08-22 05:47:59 +00:00
Bill Richardson
e307172bd5 lightbar: Enable tap-for-battery even in G3
This adds an optional lb_power() function that the lightbar TAP sequence can
use to briefly power up the lightbar rails while the AP is shut down.

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

Shut the AP down, then from the EC console run "lightbar seq tap". The
lightbar should light up and briefly indicate the current power levels. You
can manully force the battery status with "lightbar demo on", then use the
arrow keys to change the state.

Note that the Samus that I tested on had trouble recognizing when it was
charging or not. That's a separate bug.

Change-Id: Iad3f08506d9e049e89d0711af00da2f1aa2337e0
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213664
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-22 05:47:54 +00:00
Alec Berg
c7c312d057 zinger: add custom VDM to read last measured current
Add custom VDM to read last measured output current in mA.

BUG=chrome-os-partner:30850
BRANCH=none
TEST=Run "pd 0 vdm curr" on samus pd console and verify
reasonable current

Change-Id: Ie1f1ab235560eb4e90f399ceac31c5cd93003d80
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212981
2014-08-22 05:47:49 +00:00
Alec Berg
445691932c pd: zinger: Turn off pings by default
Turn off sending pings in SRC_READY by default. Added custom VDM
to turn pings back on, which only zinger supports right now.
Changed the "pd ping" console command to be used to enabled/disable
pings in SRC_READY.

BUG=chrome-os-partner:31409
BRANCH=none
TEST=loaded onto samus and zinger. on samus_pd, enabled highest
level of debug info: "pd 0 debug 2" to allow printing ping received.
Then plugged in zinger. By default, we negotiate to SNK_READY and
receive no pings. Then send "pd 0 vdm ping 1" to send VDM to zinger
to enable pings, and verified we start receiving pings. Sending
"pd 0 vdm ping 0" sends VDM to stop sending pings.

Change-Id: I4f64c6fc59bb734146eeca5e3ea3a24954c786b2
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212965
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-08-22 05:47:44 +00:00
Alec Berg
08081ee2dc zinger: always disable adc watchdog before reading ADC channel
This fixes a bug where we were reading the CC line ADC without disabling
the adc watchdog, which caused misreads. Instead, I changed adc_read_channel
so that every ADC read disables and restores the ADC watchdog.

BUG=chrome-os-partner:31454
BRANCH=none
TEST=tested on EVT zinger. Added debug code to print out CC line voltage
after reading it in usb_pd_protocol.c. Before the change the CC voltage is
mostly wrong, unless you read the ADC twice back to back and look at the
second read value. After this change, the CC voltage ADC reading always
matches the real voltage.

Change-Id: I9d3aa02b3d22defb9cf6f5a866de2b846a6b8a35
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213253
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-08-22 01:03:19 +00:00
Alec Berg
3e844ec271 zinger: keyborg: fix runtime bug with task_wait_event()
Fix zinger and keyborg to use correct event mask when
timing out from task_wait_event(): TASK_EVENT_TIMER.

On zinger, move storing the last event to after enabling
interrupts. This gives an opportunity to interrupt
handler to set the wake event.

BUG=chrome-os-partner:30135
BRANCH=none
TEST=load on zinger, and test PD communication with samus.
notably tested sending rw_hash vdm from samus, which is known
to cause zinger to retry the following ping transmit. The
retry on the ping transmit uses task_wait_event(), and without
this fix we were getting false wake events that had been stored
up from the last rx received event. with this fix, the retry
mechanism works.

Change-Id: I9a6902ceaab49a00d3660f9813ca7761cf38f190
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213560
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-08-22 00:52:43 +00:00
Alec Berg
7b1a0dc795 pd: fix bug in pd transmit retry mechanism
This fixes a bug in the PD transmit retry mechanism. In the retry
mechanism, we were assuming that only a pd rx interrupt will wake
up this event. But, there are other events that could potentially
wake us up, so we need to check to make sure that pd rx started
when we first wake up.

BUG=chrome-os-partner:30135
BRANCH=none
TEST=load onto samus and zinger. run "pd 0 flash rw_hash" a bunch of
times manually from the console. Observe that we nearly always fail
the first receive, but succeed on next try, which prevents us from
dropping the negotiation.

Change-Id: I5f7261176c151c3185d76aa374b9b83ac9df9a7d
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213369
Reviewed-by: Todd Broch <tbroch@chromium.org>
Tested-by: Todd Broch <tbroch@chromium.org>
2014-08-22 00:52:38 +00:00
Alexandru M Stan
4ec6babda0 Veyron: Fix the polarity of the backlight override
Seems like we were always overriding the backlight to be off, preventing the AP
from turning on the backlight.

BRANCH=None
BUG=None
TEST=Boot a kernel that cares about the backlight and see if it turns on.

Change-Id: Ia8f12c5830854e37ffc5d6b41ef5b8fefbab4ed8
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213289
Reviewed-by: Doug Anderson <dianders@chromium.org>
Tested-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-21 08:02:21 +00:00
Alexandru M Stan
f191f051da Veyron: Removing some stale tegra code
There's no point in having these delays, they're not applicable to Veyron.

BUG=None
TEST=Everything should work the same.
BRANCH=None

Change-Id: Icc2aebae1a497dd4f46579c23e36750feca6d67a
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213248
Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-21 08:02:16 +00:00
Aaron Durbin
0539cc2ed5 ryu: detect recovery mode and set proper event
When the power button, volume up, and volume down buttons
are pressed during boot indicate to the AP that recovery mode
is enabled.

BUG=chrome-os-partner:31481
BRANCH=None
TEST=Benson tested this w/ his magic cables.

Change-Id: I2f285d6b8b71708eff53e8b46020e51c96f281a4
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213299
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-21 08:02:05 +00:00
Aaron Durbin
97a4fd2751 power_button: expose raw signal assertion
It's useful to expose the logic of the power button assertion
according to the CONFIG active level at the hardware input.
Therefore, provide power_button_signal_asserted().

BUG=chrome-os-partner:31481
BRANCH=None
TEST=Benson tested this on ryu since has the button cables.

Change-Id: Ica48bfe981550700a067406cb72908e14dbccba9
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213298
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-21 08:02:00 +00:00
Bill Richardson
f883354bba lightbar: correctly revert to the S0/S3/S5 patterns
This CL ensures that temporary "one-shot" sequences such as KONAMI, TEST,
TAP, etc. will revert to the previous "normal" sequences even when
interrupted by other one-shot sequences.

This also adds a test for those cases.

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

make runtests

Change-Id: Ie83908731acdf2f7c9108568a1ba047943175d26
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213230
2014-08-20 22:42:15 +00:00
Puthikorn Voravootivat
1b52de3e3c stfm32f0: Send 0xec over i2c until get NAK from host.
Host i2c driver in ryu does not allow to snoop the byte
stream to abort the transaction. This make host i2c
driver to be in the dead state if the response message from
ec is shorter than host expected length.

This patch will make ec to send 0xec after end of response
message until get the 'NAK' answer from host to fixed this
issue which occur in these 2 situations.
1. When ec encounters host command error.
2. When response message is a null terminated string.

BUG=chrome-os-partner:31367
TEST='ectool version' runs fine on ryu
BRANCH=none

Change-Id: Icad0f0fde6cca4abd9c833c6d179143e4c5c0561
Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213177
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-20 22:42:11 +00:00
Alexandru M Stan
5641bbfe3b Veyron: Fix force power-off
I readded the code that armed the power_off_deadline. The force power-off should
be controlled fully from the EC now.

BUG=None
TEST=When in S3/S0, hold the power button for 8 seconds; the system should shutdown.
BRANCH=None

Change-Id: I848ce6757e497c15296aa4eae9c05133950b4e45
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213249
Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
2014-08-20 22:39:08 +00:00
Alexandru M Stan
f7f9783e30 Veyron: Fix power signals
Seems that we were driving GPIO_PMIC_PWRON_H backwards. The only reason it
worked before is because of a stale feature from tegra which pretty much kept it
always disabled(enabled in our case due to _L).

Also removed old power signals and renamed signals so they're more semantic and
respect convention(no _H).

BUG=None
TEST=AP should boot as normal, gpioget will show both PMIC_*PWR* pins 0 when
system off and 1 when system is on. The system will also use 8mA less now
(no more current leak into the PMIC).
BRANCH=None

Change-Id: I81b7596cb39a5c2b45d53e05478396b91040cacf
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213246
Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
2014-08-20 22:39:04 +00:00
Todd Broch
f8fbd1e440 flash_pd.py: Add retries for commands for collision resilience.
The original version of the script worked but as the USB PD protocol
SM has been enhanced to handle more complicated scenarios the
occurrence of collisions on the baseband comm has grown and script
needs to account for that.

Script now checks status of ACK from zinger 'DONE 0' and retries two
additional times for commands that failed.  If those three attempts
are unsuccessful script raises exception and quits.

Also added some more logging around retries and progress of chunk
writes.

BRANCH=none
BUG=chrome-os-partner:30135
TEST=manual, util/flash_pd.py build/zinger/ec.RW.flat succeeds in
programming zinger even in light of some retries.

Change-Id: Iaa8a22c2510ea5f4ebd92e1715be5fe062e13c61
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213131
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-20 21:07:26 +00:00
Alec Berg
6a99f7d0a4 samus_pd: add WP_L gpio
Rename SPI_FLASH_WP_L to WP_L, the standard GPIO name for the WP
screw.

BUG=none
BRANCH=none
TEST=load on samus, make sure gpioget WP_L reflects state of
WP pin accurately

Change-Id: Ie5e6d705a7be6c18b0026b357745946da7390cfb
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213007
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-08-20 21:07:21 +00:00
Bill Richardson
4e8751372a Make lightbar simulation compile again
This just brings the competely unsupported but occasionally useful lightbar
simulation tool up to date with the rest of the source tree so it will
compile and run again.

BUG=none
BRANCH=ToT
TEST=manual

cd extra
make
./lightbar

Change-Id: Iafeaaa5ac56a4b711c63d2c64d8c51ab4b324104
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213206
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-20 21:07:15 +00:00
Mohammed Habibulla
df13541440 Auron: Initial EC commit
Clone of Peppy with only string changes

BUG=chrome-os-partner:31285
TEST=emerge-auron chromeos-ec
BRANCH=none

Change-Id: I1f7288e44cdc5ff1caa41de5ee299dbfa3411fa1
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212971
Reviewed-by: Bernie Thompson <bhthompson@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-20 02:12:53 +00:00
Shawn Nematbakhsh
a048d76e0d Refactor accel / gyro driver to accomodate various configurations
Previously our accel / gyro drivers assumed that we had exactly two of
each identical part in the system. Some systems may have different
configurations, so allow this to be specified at the board-level.

Note that our motion_sense algorithm currently assumes that we have one
accelerometer in the lid and one in the base -- we'll need to fix that
in another CL.

BUG=chrome-os-partner:27320
TEST=Compile-only. Tested in future Samus commit.
BRANCH=None.

Change-Id: I1fae1f6c578fedebe78b473a5d66a5794ccaae00
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212321
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-19 06:59:28 +00:00
Puthikorn Voravootivat
be060242e3 Fix ec detection for i2c protocol
ectool seems to looks at wrong location for ec.
This patch fix that

BRANCH=none
BUG=chromium:402581,chrome-os-partner:30707
TEST=ectool hello runs fine on ryu

Change-Id: I7b847b0eaf3fd39a8ba2948a87879b3f8223c582
Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212483
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2014-08-18 23:16:32 +00:00
Vic Yang
a25d675bc0 samus_pd: Enable both comparator at the same time
We use window mode to share the non-inverting input of the two
comparators. If COMP1 is not enabled, it causes problem on the operation
of COMP2. Fix this by enabling both comparator at the same time.

BUG=chrome-os-partner:31400
TEST=Reboot PD MCU, and plug into port 1. See SNK_READY state.
BRANCH=None

Change-Id: Icb7e7acdb8a09e094c24839c1d7b398b2c3fb9c0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212921
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-18 23:16:22 +00:00
Todd Broch
e1ff1a3cae hoho: Initial board configuration.
Create necessary boiler plate files for USB type-C to HDMI dongle.

BRANCH=none
BUG=chrome-os-partner:31192
TEST=manual
1. Compiles & can program via fruitpie.
2. Can access uart (w/ rework for tx/rx).
3. Can drive HDMI capable monitor.

test details ...

Programming:
------------
   # connect fruitpie + fruitpie std-adapter(red) with u-USB (CN3) & type-A
   # (CN1) both to host that will run servod.
   FPIE_PORT=9993
   sudo servod -p 0x5009 --port $FPIE_PORT

   dut-control --port $FPIE_PORT "ec_uart_cmd:gpioset USB_C_5V_EN 1"
   dut-control --port $FPIE_PORT "ec_uart_cmd:usbmux usb"
   util/flash_ec --board=hoho

Configuring samus for DPout on both ports:
------------------------------------------

    sudo servod -b samus

    for port 0 1; do
        dut-control "usbpd_uart_cmd:pd ${PORT} dualrole off"
        dut-control "usbpd_uart_cmd:gpioset USB_C${PORT}_CHARGE_EN_L 1"
        dut-control "usbpd_uart_cmd:typec ${PORT} dp"
        dut-control "usbpd_uart_cmd:gpioset USB_C${PORT}_5V_EN 1"
        dut-control "usbpd_uart_cmd:typec ${PORT}"
    done
Change-Id: I39bbe1e347d1cfd777b68f3fdac6c5c6dd22800d
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212523
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-16 05:26:40 +00:00
Dominic Chen
f3c308108b usb: add CONFIG_USB_INHIBIT to prevent automatically starting USB
BUG=none
BRANCH=none
TEST=usb does not autostart, and can be enabled/disabled

Change-Id: I22a7bf3ca9cb7013cc4964dbdabff7524985d9ba
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212509
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-16 05:22:50 +00:00
Vic Yang
29b18b820a tegra: Cancel timer if long power press is canceled
When long power press is canceled, we need to cancel the current running
timer. Otherwise, if the power button is pressed again before the
current running timer expires, the next deadline won't be set. This
causes the chipset task to wake up too early and miss the subsequent
long power press shutdown.

BUG=chrome-os-partner:31372
TEST=On Ryu, long press following a short press shuts down the system.
BRANCH=None

Change-Id: I9855b146d430e5babda727fcb429c516ca91e48e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212560
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-15 21:13:22 +00:00
Vic Yang
9534a15cd7 Revert "Add back unit test for usb_pd"
This reverts commit cb7468744d.

Apparently this test fails when running on a heavily loaded
system. Revert this for now.

BUG=chromium:402335,chrome-os-partner:31200
TEST=make buildall
BRANCH=None

Change-Id: I8b616d3915ee5c2f524530897758871cc0375d35
Reviewed-on: https://chromium-review.googlesource.com/212582
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Vic Yang <victoryang@chromium.org>
2014-08-15 21:13:09 +00:00
Dominic Chen
67281b9807 flash_ec: add support for closed-case debugging
Passing the "--usb" argument will now utilized case-closed
debugging for flashing the EC. Currently this is only supported
for the samus LM4-based board.

BRANCH=none
BUG=none
TEST=verify that when the case-closed debugging flag is set, the
alternate openocd config file is used for samus, and an error is
thrown for all other boards

Change-Id: I0642bc2e9c2657cd8dbd83ee6e282365275d665a
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211744
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-15 21:07:35 +00:00
Dominic Chen
fd9eed96fd openocd: update configuration files
1. use ftdi interface driver instead of deprecated ft2232
2. remove custom target config and use upstream stellaris target
3. replaced deprecated servo_v2.cfg with servo_v2_slower.cfg
4. deprecated openocd.cfg

BUG=none
BRANCH=none
TEST=flash samus works
CQ-DEPEND=CL:210778

Change-Id: I572a717613eedc3afc44009a0f1aba1f1d36d7f7
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210920
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-08-15 21:07:31 +00:00
Dominic Chen
5c5f832da9 fruitpie: enable usb mass storage
BRANCH=none
BUG=none
TEST=verify that usb mass storage functions

Change-Id: I141afb2f5797db769319a499ad8884be123d6116
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206304
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-15 17:55:08 +00:00
Dominic Chen
c9809547c2 usb: add support for mass storage (bulk-only)
implement USB mass storage class using the bulk-only transport
protocol with the transparent SCSI command set.

BRANCH=none
BUG=none
TEST=verify that usb mass storage functions on windows xp, 7, 8, mac os x, goobuntu precise

Change-Id: Ideecad55bd275df7b30aa4a3ed263304a3a109cd
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/206303
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-15 17:55:04 +00:00
Vic Yang
9262797ee6 pd: Print warning before flash erase if on PD power
During flash erase operation, read is stalled and thus interrupt might
be serviced later. This can cause PD communication to fail and thus the
board reboots if there is no battery. Print a warning message in this
case.

BUG=chrome-os-partner:31127,chrome-os-partner:31207,chrome-os-partner:31362
TEST=Boot Ryu, on software sync, see warning message before board
reboots.
BRANCH=None

Change-Id: If327a4f533fd2dfa83f92531148bd52ace927e03
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212264
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-14 22:44:44 +00:00
Dominic Chen
c8fa85d0b4 module: add constant MODULE_USB_DEBUG for closed-case debugging
BUG=none
BRANCH=none
TEST=make buildall -j

Change-Id: I0fdc166f1b2664da84c7e375b0670db32887807e
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212371
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-14 22:44:40 +00:00
Vic Yang
521dd8a8c7 pd: Fix bug in PD console command
The check on number of arguments is offset by 1. Fix it.

BUG=None
TEST=Run the commands with one parameter short. See error.
BRANCH=None

Change-Id: I2ac1fe022d22bbef2ee90fe54a7856766fc31dcc
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212352
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-14 22:42:36 +00:00
Vic Yang
87f2f10b8e pd: Guard console messages with log level
We're printing more and more log and this sometimes causes timing issue.
Let's guard the PD log with a log level. Currently there are three
different levels:
  - 0: Log state transition
  - 1: Level 0, plus packet info
  - 2: Level 1, plus packet dump on error
The default value is 0.

BUG=None
TEST=On Ryu, enable USB PD console channel and set different log levels.
Observe different amount of log message.
BRANCH=None

Change-Id: I49613d406bcb1ec20d3f242f724dc1c054478c7d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212351
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-14 22:42:31 +00:00
Aaron Durbin
776658d8a2 stfm32f0: always send bytes over i2c for EC command responses
Certain i2c host drivers don't allow one to snoop the byte
stream to abort a transaction. Allow those devices to make
forward progress by sending out the '0xec' byte for any
requests coming through after an EC host command error.

BUG=chrome-os-partner:30784
BRANCH=None
TEST=Ran on ryu. Allowed passthru probing which normally hung
     the system because of there not being a passthrue device
     on ryu -- error returned. Instead the command returns
     successfully by returning 0xec for the unfilled bytes.

Change-Id: Ibcab5ade1f727f3852995437105eb9fa693caadf
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212165
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-14 20:28:48 +00:00
Aaron Durbin
80f5d9e10a stm32f0: always initialize i2c_packet
The i2c_packet structure wasn't always being initialized
in the error path. It's possible to crash the EC if the first
command processed hit this error path. Instead, unconditionally
set all the i2c_packet fields.

BUG=chrome-os-partner:30784
BRANCH=None
TEST=Built and ran on ryu.

Change-Id: Ic6d7c63f61d59c4449fbb20f656c1bfb835db8be
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212164
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-14 15:29:35 +00:00
Aaron Durbin
0c635cc73e stm32f0: use proper bit checking I2C ISR transmitter empty status
The wrong define was being used when checking the I2C ISR status.
The wrong define just so happened to be the correct bit.

BUG=chrome-os-partner:30784
BRANCH=None
TEST=Built and ran on ryu.

Change-Id: I6c7aad34f5e7c7ace4db4442147023346b6285bc
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212163
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-14 15:29:31 +00:00
Vic Yang
116080b151 pd: issue PD soft reset on sysjump
On sysjump, we are losing all of our PD states. Instead of trying to
remember all the states and deal with on-going transmission, let's just
issue a soft reset so that the communication starts over.

BUG=chrome-os-partner:31207
TEST=With Ryu/Zinger, do 'sysjump rw' and check EC doesn't reboot.
BRANCH=None

Change-Id: I8779b74491a402434931b3455fa93ff2e178cb1f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212123
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-14 09:09:11 +00:00
Alexandru M Stan
aa3ca9bc53 STM32F0 SPI Fixes: 4x Dummy Bytes
Seems like STM32_SPI_CR2_FRXTH from 5d208b99(STM32F0 SPI Fixes) was not enough
to "disable" RX FIFO from the F0 series. There were still a few bytes stuck in
the FIFO just after a command with a long sequence of 00 bytes.

This increases the dummy bytes read just before a DMA transfer to 4(size of the
FIFO).

BUG=none
BRANCH=none
TEST=Veyron with the new EC should survive the AP booting. ectool version will
work right away after boot. This change should not affect other STM32 chips
because reading dummy bytes from an empty register is essentially a NOP.

Change-Id: I812208622a75ecce82433eb6c12595fee3c1428b
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212297
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-14 02:34:07 +00:00
Vic Yang
cb7468744d Add back unit test for usb_pd
Add back the test but only enable USB PD tasks for usb_pd test. This
should ensure that we do not break existing tests.

BUG=chrome-os-partner:31200,chromium:402335
TEST=make buildall
BRANCH=None

Change-Id: I4daa41a96a1067362b2c40a2a09fce733843bdff
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211923
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-13 21:36:12 +00:00
Vic Yang
589e7f9e10 pd: Implement PD soft reset
Currently, when we receive soft reset request, we only reset message ID.
According to the spec, we should also reset the state machine without
cutting power. This CL implements this, along with a console command to
issue soft reset request.

BUG=chrome-os-partner:31296
TEST=Issue soft reset from Ryu to Zinger. Check that we go back to
discovery state and re-negociate a contract.
BRANCH=None

Change-Id: Ib00b0d9dddaf6ac2a1ec5c46dbc2824d6d7814ed
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/212122
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-08-13 13:21:10 +00:00
Dominic Chen
fe1981a414 pi3usb9281: Implement driver for Pericom USB switch
BRANCH=none
BUG=none
TEST=verify that usb switch funcitons

Change-Id: Ie897a2ae94042abefbb349d30dfa183caaec9ed0
Signed-off-by: Dominic Chen <ddchen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/209846
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-08-13 13:21:00 +00:00
Alec Berg
283fe98939 samus: ryu: fix charge state machine init of input current
Currently charge state machine resets input current limit to default
every time AC is connected. Problem is by the time charge state machine
gets around to setting input current, it could have already been set
by successful PD negotiation, and this ends up overriding that value.
This fix has the state machine store desired input current limit, as
determined from PD negotation or any other place, and send last desired
input current limit on AC connect.

BUG=chrome-os-partner:24461
BRANCH=none
TEST=load on samus, test toggling between "pd 0 dev 5" and "pd 0 dev 20",
and test plugging and unplugging zinger numerous times, and verify charger
command always gives the expected input current limit based on PD
negotiation.

Change-Id: I18d8acc9e2085739e783c9c70c682d46bcce7fdb
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211639
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-08-12 05:11:39 +00:00
Alec Berg
adbd5a0c9a firefly: default to requesting 20V
Change default to request 20V.

BUG=none
BRANCH=none
TEST=Load onto a firefly. Plug in a zinger, make sure 20V LED
lights up. Press other buttons to make sure we can change the
requested voltage to 5V and 12V.

Change-Id: I3a3e63a6d0e4f01b9fe7c730468da75ad6783f41
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211872
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-12 02:50:29 +00:00
Alec Berg
49ee1cb872 pd: modify PD to allow sending VDMs anytime
Change the VDM implementation in the PD task to allow for VDMs
at any time when connected without disrupting any regular PD
communications.

BUG=none
BRANCH=none
TEST=load on a samus and on a zinger and test sending VDMs:
pd 0 flash version
pd 0 flash reboot

Also, test using the flash_pd.py script to write zinger RW using
VDMs.

Change-Id: I48352978d8c45f78e8a5a7735d65b013a853f3e2
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210746
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-08-11 22:05:21 +00:00
Alec Berg
dc1834593a pd: stop sending source cap after fixed number of attempts
As per the PD spec, give up on sending source cap packets
after nCapsCount number of attempts.

BUG=chrome-os-partner:28341
BRANCH=none
TEST=Connect samus to an unplugged zinger. Samus recognizes
a device has been plugged in and sends source cap for 5
seconds (50 attempts at 100ms retry period), then stops
sending source cap but remains in discovery state providing
VBUS.

Change-Id: I0aa25263f200299a0eb8d219883f825ae655129c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/211335
2014-08-11 22:05:18 +00:00