Commit Graph

3158 Commits

Author SHA1 Message Date
Bill Richardson
41cde66516 Samus: Handle fan startup in the EC, not the fan controller
The fans on samus have a recommended minimum duty cycle of 20%
while running, but 30% in order to start. We've been using the
EC's built-in fan controller for the start requirement, but it
has a minimum fast-start duty cycle of 50%. It turns out that
that speed is noticeably noisy.

This change handles the startup with logic in the EC instead, so
that the fan only tries to spin at 30% initially (or if it drops
too much below the minimum turning speed).

BUG=chrome-os-partner:33429
BRANCH=ToT,samus
TEST=make buildall -j

Boot the system, let it idle with the browser windows closed, the
browse a bit, then idle. Listen for changes to the fans.

Before, I could hear the fans kick in and out as the AP load
changed. Now it's much quieter.

Change-Id: Id35215520c064eb6843686ec8bb5f3618dac6cf6
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/227658
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-11-06 02:28:22 +00:00
Bill Richardson
f0809a2399 Re-Calibrated lightbar values for Samus & Ryu
New values from lab testing with slightly higher intensity.

BUG=chrome-os-partner:33017
BRANCH=ToT,samus,ryu
TEST=manual

ectool lightbar brightness ff
ectool lightbar seq s3s0
ectool lightbar

Resulting current levels:

  15     00     2d
  16     2a     0a
  17     26     13
  18     10     0b
  19     10     26
  1a     1b     0d

Change-Id: I118bf2fda3dee67b27c5d6a5825b7a9a96dc66dd
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/227515
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-11-06 02:28:18 +00:00
Vic Yang
4bbbf04437 Do not try to wake the battery after battery cut-off
When the battery cut-off command is issued with external power present,
the battery can end up in one of the following two states:
  1. The battery stays responsive but is waiting for the external power
     to go away.
  2. The battery decides to cut itself off right away.
In case 1, we are already avoiding charging the battery again, so we're
good. However, in case 2, the charge state machine mistakenly thinks the
battery is dead and tries to revive it. Fix this by checking if the
battery is cut off before starting to revive it.

BRANCH=None
BUG=chrome-os-partner:33372
TEST=Cut off the battery with external power connected. Wait for a while
and then disconnect external power. Check the battery is sure cut off.
Repeat for several times.

Change-Id: Icf343b168a556a490bc1786802a8a6e230863a28
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/227521
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-11-05 21:14:40 +00:00
Gwendal Grignou
4792db413f ectool: compile LPC and i2C support by default.
Currently, LPC or I2C are compiled based on the board.h.
This is not really necessary, code can handle both at the same time.
Note that LPC and I2C access mode are backup modes, the main mode is
dev (accessing ECs through /dev/cros_XX).

BRANCH=None
BUG=chromium:408713
TEST=Compile, tested on Ryu and Samus.

Change-Id: I8b4730f0f5708c543dc034165e9b53de0e543860
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/227432
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-11-05 19:48:26 +00:00
Anton Staaf
8513e23df1 USB: Remove special case for iVersion string descriptor
Previously the version string was special cased in the USB stack
because the build system prevented the inclusion of ec_version.h in
any file other than common/version.c.  This lead to common/version.c
being the only place that the USB version string could be computed
and thus the special case of filling in the version string descriptor
at run time.  This made the USB stack more complex, and lead to the
common/version.c file including usb.h, which is actually STM32
specific.

Now, the portion of ec_version.h that is deterministic is only
updated when something in the tree actually changes (by way of a
conditional in the makefile), and ec_version.h no longer has to
depend on all object files (other than the special version.o).
This allows anyone to include ec_version.h as needed.  In particular,
each board that wants to define a USB version string can directly
include ec_version.h and do so.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     touch files and verify rebuilds happen correctly

Change-Id: Ic84d0b9da90f82ebb4630fb550ec841071e25a49
Reviewed-on: https://chromium-review.googlesource.com/227211
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-11-04 21:34:39 +00:00
Anton Staaf
bde06f7697 USB: stm32f3: use correct values for USB RAM size and usb_uint
The RAM size was copied from the STM32F0 definition which was
not correct, and the usb_uint computation was only checking for
the STM32F0 family, assuming that all others were the old
uint32_t access size.

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

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

Change-Id: I28951351601254ea6ebabaec2687d6bfe716b699
Reviewed-on: https://chromium-review.googlesource.com/227210
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-11-04 18:14:20 +00:00
Alec Berg
3a4f718f22 samus_pd: add dual-role port flag to power info host command
Add flag for whether or not device plugged into a given port is a
dual-role PD device. For now, the dual-role flag is always 0, but
need to add the flag to the host command now for compatibility
in the future.

BUG=chrome-os-partner:32650
BRANCH=samus
TEST=load onto samus, run ectool --name=cros_pd usbpdpower and
verify that for anything plugged in it says "dedicated charger"

Change-Id: I2d3c8c149802492f27a87a47aaa68fbf505ee7a9
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226820
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2014-10-31 22:32:54 +00:00
Bill Richardson
86c7e2e90a Add initial support for cr50 SoC
The serial console works. Nothing else is implemented yet.

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

To build,

  make BOARD=cr50 hex

Testing the result requires a development board. I have one. It
works with HW revision m3.dist_20140918_094011

Change-Id: I718d93572d315d13e96ef6f296c3c2796e928e66
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226268
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-31 22:32:50 +00:00
Sheng-Liang Song
327bfe2e58 Samus: Fixed sensor init when sysjump to between RO and RW code
When sysjump between RO and RW code, the motion sensor global
data structure get reset to 0.  The motion sensor task does not
get notification from the power state change event.

Added chipset S0 state check logic to re-init sensor active flag to S0.

BUG=chrome-os-partner:33370
BRANCH=ToT
TEST=sysjump RW; accelread 0
Test Cases:
  1 - press power cycle button; checked with powerinfo,accelread
  2 - press power cycle button + F3 (refresh) key; checked with powerinfo,accelread
  3 - Go to G3, S0, S3; checked with powerinfo, accelread
  4 - boot up to S0; sysjump RW; accelread 0|1|2

Change-Id: Ibfe4ba581c8b771be15adb7440374d09fdf03953
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226698
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Sheng-liang Song <ssl@chromium.org>
Tested-by: Sheng-liang Song <ssl@chromium.org>
2014-10-31 20:55:24 +00:00
Alec Berg
e6a2d4c044 samus_pd: add more host events and host cmd to get event status
Add support for more host events and add a host command for the host
to use to get which host events have fired. The EC only uses one
real host command to notify the AP whenever the PD MCU needs attention
so the EC_CMD_PD_HOST_EVENT_STATUS host command can be used to
differentiate the possible triggers for the host event.

Current events include: PD remote device needs update, type-C power info
changed, and PD identity response received.

Added host event for power info change, which fires whenever a charger
or device is plugged into a type-C port.

BUG=chrome-os-partner:32650
BRANCH=samus
TEST=tested on samus by connected various peripherals to type-C ports
and verifying on EC console that a host event is sent.

Change-Id: Ibfc2cafe5826a0ab41aee96a68fdb561c0a2b4ab
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225841
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2014-10-31 19:22:00 +00:00
Todd Broch
ce9ae08b68 pd: dingdong/hoho: Include product VDO in discovery identity.
Per table 6-24 of USB PD spec an alternate mode adapter (AMA) should
include both product & AMA VDOs.

BRANCH=samus
BUG=chrome-os-partner:31192,chrome-os-partner:31193
TEST=manual,

Connect hoho/dingdong to fpie/samus and see product VDO proceed the
AMA VDO in DFP_U console output:

    Product VDO -----------------------------v
                                          |------|
    SVDM/5 [1] ff008041 340018d1 00000000 50100001 1100000b

    Note, hoho's PID == 0x5010

    And dingdong (0x5011)
    SVDM/5 [1] ff008041 340018d1 00000000 50110001 1100000b

    Also see bcdDevice field in descriptor match above data.

    $ lsusb -v -d 18d1: | egrep -i "idproduct|bcddev"
    idProduct          0x5011
    bcdDevice            0.01

Change-Id: I4d898816a45c68c7ff75a54fd348fc11be408ae0
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226125
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-31 06:29:34 +00:00
Todd Broch
aac88442d7 pd: dingdong/hoho: inhibit USB Billboard.
USB Billboard class can be used to advertise an alternate mode capable
device that hasn't entered a mode.  Additionally it can remain after
mode entry providing its Billboard capabilities descriptor is
updated.

This CL postpones enumeration which previously occurred after boot
until tAMETimeout has passed and alternate mode has NOT been entered.
Future CL could choose to also (re)enumerate with mode capabilities
although this is not required by the USB PD specification.

BRANCH=none
BUG=chrome-os-partner:31192,chrome-os-partner:31193
TEST=manual,
With DFP_U which does not enter mode see Billboard class enumerate
else it does not.

Change-Id: I59a0815cd0ea551ba9a878907c0184df4ba9480c
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/224663
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-31 06:29:28 +00:00
Alec Berg
13579c3570 samus: accel: fix initialization bug in tap gesture
Fix bug in tap gesture. When turning on tap detection, don't
clear the history circular array index. This was causing inconsitent
tap for battery recognition because the inner window sum of z-axis
data (sum_z_inner) was relying on subtracting out old historical
data and adding in the new data, but when the array index changed,
it was subtracting out the wrong old data. This really only came in
to play if there was significant z motion before the last wakeup.

BUG=none
BRANCH=samus
TEST=keep going to sleep and waking up and test that tap for
battery works every time.

Change-Id: I55e00c805d504dd6d257a81f2cd25fe384a53257
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226591
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2014-10-31 04:29:16 +00:00
Todd Broch
1e7d66eabc pd: dingdong/hoho: assert USB billboard only in AMA VDO.
BRANCH=samus
BUG=chrome-os-partner:31192,chrome-os-partner:31193
TEST=manual

Attach hoho/dingdong to samus and see AMA VDO bits <2:0> set to 0x3
during the discover identity response.

                                        AMA VDO
                                        |------|
  SVDM/4 [1] ff008041 340018d1 00000000 1100000b

Change-Id: I1e2459b87cceca88ab3ae09440b689041ae03c7c
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226101
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-30 21:48:22 +00:00
Todd Broch
a3913d99d7 pd: dingdong/hoho: HPD over USB PD.
HPD needs to be transported of USB PD as both SBU lines are consumed
for differential AUX signalling.

This CL does the following:
1. Enables GPIO DP_HPD as interrupt
2. Sends debounced HPD across CC via the SVDM DP status message

BRANCH=none
BUG=chrome-os-partner:31192,chrome-os-partner:31193
TEST=manual,

From servo w/ GPIO attached to HPD drove the following transactions
after inserting with HPD low initially:

    # e1: hpd_high
    # e2: hpd_low
    # non-registered glitch
    # e3: hpd_high followed by hpd_low
    # e4: hpd high
    # non-registered glitch
    # e5: hpd_irq
    # e6: hpd_irq
    # e7: hpd_irq
    # e8: hpd_low followed by hpd_high

From fruitpie console (marked up to show result of above)
----> enter-mode, dp status, dp config
	    [6.774108 DONE]   SVDM/1 [4] ff018144
	    [6.777467 DONE]   SVDM/2 [16] ff018150 00000002
	    [6.780637 DONE]   SVDM/1 [17] ff018051
----> attentions start arriving
----> e1    [18.966741 DONE]  SVDM/2 [6] ff018106 0000008a
----> e2    [33.724367 DONE]  SVDM/2 [6] ff018106 0000000a
----> e3    [64.550398 DONE]  SVDM/2 [6] ff018106 0000008a
----> e3    [64.752452 DONE]  SVDM/2 [6] ff018106 0000000a
----> e4    [74.247127 DONE]  SVDM/2 [6] ff018106 0000008a
----> e5    [88.906254 DONE]  SVDM/2 [6] ff018106 0000010a
----> e6    [100.938738 DONE] SVDM/2 [6] ff018106 0000010a
----> e7    [123.693414 DONE] SVDM/2 [6] ff018106 0000010a
----> e8    [130.050074 DONE] SVDM/2 [6] ff018106 0000000a
----> e8    [130.254087 DONE] SVDM/2 [6] ff018106 0000008a

Change-Id: I976c268467ece84cedab7ba4943fb59d1e48c113
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223262
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-30 21:48:06 +00:00
Vincent Palatin
d4f3279db9 twinkie: fix CC2 reception in PD injector mode
Properly set the comparator output when using CC2.

Also add some basic LED color to display the current power contract when
we are a sink :
- green : 5V
- red : 20V
- blue : other voltage

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

BRANCH=none
BUG=none
TEST=plug to Zinger in each plug direction and see green then red LED.
type "pd 0 dev 12" and see the blue LED.

Change-Id: I4eb4339568eda5871c7f3df75bedebd97238e941
Reviewed-on: https://chromium-review.googlesource.com/226385
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-10-30 09:57:10 +00:00
Vincent Palatin
bd9a53f322 twinkie: fix INA reference in PD injector
Update the INA naming in the optional PD code to use Twinkie as PD
source/sink.

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

BRANCH=none
BUG=none
TEST=none

Change-Id: Ib06e274c0d916d6c84107546a8701fc80b4e6ab1
Reviewed-on: https://chromium-review.googlesource.com/226363
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-10-30 09:57:05 +00:00
Alec Berg
498abf833c samus_pd: add host command to get type-c port power info
Get type-c port power info including power role, charger type,
and charging info. Also added host command to get number of type-c
ports.

Also adds new charging suppliers for pericom identified chargers
including DCP, CDP, SDP, proprietary, and other chargers. Priority
of these for charging is set in samus board file.

BUG=chrome-os-partner:32650
BRANCH=samus
TEST=run 'ectool --name=cros_pd usbpdpower' and verify correct
status with minimuffin, zinger, and type-C to type-A adapter.

Change-Id: I1dabbe7de4185a23df5684a5ea9a2d944f1f6ff5
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/223523
Tested-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-30 04:31:34 +00:00
Vic Yang
cfbb9e51b2 ryu: Enable low power idle for P2 boards
Now that the problem with UART in STOP mode is fixed, let's enable low
power idle for Ryu P2 boards.

BRANCH=None
BUG=chrome-os-partner:33219
TEST=Shut down the AP and unplug AC power. Check the EC goes into
deep-sleep by 'idlestat'.
TEST=Power up the AP and check the EC stays awake.

Change-Id: Ib8ad3763407315ec0f95551fa0fdd258a060e113
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/226312
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-30 00:05:33 +00:00
Anton Staaf
e254b0a06f discovery-stm32f072: Rename USB console endpoint
This isn't really an EC as Vincent pointed out,
rename this endpoint serial interface to Shell.

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

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

Change-Id: Id4605b782cdb8e1be5293f4b6b88357bd653c770
Reviewed-on: https://chromium-review.googlesource.com/226331
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-10-30 00:05:27 +00:00
Gwendal Grignou
a86b4b0a78 gesture: Minor fixes
Set state or numeric when needed
Add debug for the idle state.

BUG=None
BRANCH=ToT
TEST=Check debug appears when enabled. Check tap still works.

Change-Id: Ic4660f70a27464dc68c02fdaef60dc36d7c2edad
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225487
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
2014-10-29 22:23:59 +00:00
Gwendal Grignou
66164f2784 Samus: Split motion sense and lid angle
Split motion_sense.c.
Translate the accel data in the Android coordinate right away.

BUG=chrome-os-partner:32002
BRANCH=ToT
TEST=On samus, check lid angle are still correct.

Change-Id: If743e25245dc1ce4cdacb8a4d5af22616c4a79e4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225486
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-29 22:23:54 +00:00
Gwendal Grignou
d5b32aa6e1 core: Add subcommands to MOTION_SENSE_CMD
These subcommands allow accessing sensor (accel+gyro)
over i2c.

BRANCH=ToT
BUG=chrome-os-partner:31071
TEST=Compile.

Change-Id: Ic6c3e9bf9c23f369de9f540c50daab7f2e4582ee
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225653
2014-10-29 22:23:49 +00:00
Gwendal Grignou
f3b29e3fec Samus: move gesture to common
Move gesture to common directory, 1st step to be reused by
other board.
Cleanup motion_sense shutdown path.

BUG=chrome-os-partner:33102
TEST=Double tap still works on Samus
BRANCH=ToT

Change-Id: I0a3b38c4a7dbe95c27dcdebff04c1176aaf932d1
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225235
Reviewed-by: Sheng-liang Song <ssl@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-29 22:23:43 +00:00
Anton Staaf
ac375d000e USB-console: Add Linux USB serial kernel module
This is a simple kernel module and Makefile for
building it out of tree.  This module just uses
the existing kernel usb serial driver and probes
for the Google VID/Class/SubClass/Protocol that
identifies a valid simple serial interface.

This code should be rolled into the existing kernel
driver at: drivers/usb/serial/usb-serial-simple.c

While that happens, this module is still useful to
developers.

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

BRANCH=None
BUG=None
TEST=cd extra/usb_serial; make; sudo insmod raiden.ko
     Connect the discovery-stm32f072 over USB and see
     that its console is discovered and works.

Change-Id: I83661b816643c43b3e2dc9fdc825bc3a796af2f4
Reviewed-on: https://chromium-review.googlesource.com/225923
Reviewed-by: Olof Johansson <olofj@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-10-29 18:38:27 +00:00
Anton Staaf
d7b99e993a discovery-stm32f072: Enable USB console
Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j
     Verify that the console is discovered and works.

Change-Id: I7bdf85c4435a6423acc915a61c1d1302052113a0
Reviewed-on: https://chromium-review.googlesource.com/225951
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-10-29 18:37:57 +00:00
Anton Staaf
450b882dee USB-console: Add string names for console interfaces
These names can be used to uniquely identify an interface
as being a console forwarded from the AP, or the EC's
console or some other console.  This makes it possible to
connect to the correct console from servo without knowing
what board is attached.  These strings could also be used
by udev rules to create appropriate symlinks.

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

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

Change-Id: I1abd36f952782a03606b09485917be8e154534ce
Reviewed-on: https://chromium-review.googlesource.com/225950
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-10-29 18:37:53 +00:00
Anton Staaf
4626fd37df USB: Add simple serial subclass support
This uses the newly allocated simple serial SubClass
and Protocol identifiers to make enumeration of serial
consoles over USB easier.  The simple usb serial kernel
driver can select based on vid/class/subclass/protocol,
making it trivial to attach to serial consoles.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Enable USB console on discovery-stm32f072 and verify
     that a new ttyUSB? device is discovered.

Change-Id: I6d3e414a20753573c2ee90a48fb1d5dce2c3972d
Reviewed-on: https://chromium-review.googlesource.com/225869
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-10-29 18:37:48 +00:00
Anton Staaf
ca74d14ea9 USB-console: Reclaim two bulk endpoints
Previously the USB console code used two separate
bidirectional endpoints.  Using the STM32 USB perihperals
endpoints in this manner means that there are only 8 total
endpoints available.  But the STM32 USB peripheral allows
for a single endpoint number to be used for both IN and
OUT transactions, and while this (re-using an endpoint
number for both IN and OUT endpoints) appears to be not
compliant with the letter of the law with respect to the
USB spec, it is supported by USB stacks, and is used in a
number of USB devices.

So this change makes the USB console driver share a single
endpoint number between the IN and OUT bulk endpoints used
to implement the console.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Enable USB console on discovery board and manually test.

Change-Id: I511e56de2162a6c04ddba80d26b37b4f0cd993fd
Reviewed-on: https://chromium-review.googlesource.com/225868
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-10-29 18:37:42 +00:00
Vincent Palatin
a25b9fa1ab usb: fix undefined USB endpoints
When calling the ep_undefined function, the linker was not considering
it as a Thumb function and not setting the LSB in the address pointer.
This was causing an exception at runtime.

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

BRANCH=all
BUG=none
TEST=inspect assembly

Change-Id: I8f4d1e351081032e138f593f0b61294031fc09b1
Reviewed-on: https://chromium-review.googlesource.com/226093
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-29 03:29:22 +00:00
Dino Li
b5bd5ed20d it8380dev: add pwm control module
Add pwm control module for emulation board.

Signed-off-by: Dino Li <dino.li@ite.com.tw>

BRANCH=none
BUG=none
TEST=console manual test, pwm channels output correctly.

Change-Id: I6eb1a9e4fdcb9279e9d0cbd67f7a92afed21c889
Reviewed-on: https://chromium-review.googlesource.com/223921
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
2014-10-29 03:29:17 +00:00
Kenji Chen
8a1f1b045a EC:KBC: Wait until LPC host senses the IRQ and gets the character.
BRANCH=master
BUG=chrome-os-partner:29139
TEST=Buiid an EC FW image and run on Rambi to test if key loss is
improved and any side effect somes with this change. Need more test
units to confirm this.
Signed-off-by: Kenji Chen <kenji.chen@intel.com>
Change-Id: I2399e33d2ca3defe8cd9b1f94ab0af1db7f84635
Reviewed-on: https://chromium-review.googlesource.com/225557
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
2014-10-28 22:30:19 +00:00
Anton Staaf
f899a3445d USB-console: Don't wait in interrupt contexts
Previously the USB console code would wait for up to
30 ms for the USB packet buffer to become available
for transmission, even if it was called from an interrupt
context.  This doesn't work because, even if we were OK
with waiting this long in interrupt contexts, which we are
not, we rightly assert that we are not in an interrupt
context in task_wait_event, which usleep calls.

This solution is a quick fix to only wait when not called
from within an interrupt context.  The correct solution
is likely to decouple the printf code from directly calling
the console driver code, instead we should place a queue
between the driver and printf logic.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Enable USB console on discovery board and manually test.

Change-Id: I5b6f7bbb77f75132c75935f8fda01e652a236ae0
Reviewed-on: https://chromium-review.googlesource.com/225867
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2014-10-28 22:30:09 +00:00
Vincent Palatin
b8e4f1b66a twinkie: dual channel CCx sniffing
Update the sniffer code to sample both CC lines at the same time.

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

BRANCH=none
BUG=chrome-os-partner:28337
TEST=make BOARD=twinkie
do an on a sample pattern from the function generator on both channels
and verify that the waveform looks good.

Change-Id: I30c607591775531e432e757f61209733804b55e5
Reviewed-on: https://chromium-review.googlesource.com/224583
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@google.com>
Tested-by: Vincent Palatin <vpalatin@google.com>
2014-10-28 06:12:39 +00:00
Vic Yang
682f7aabda stm32f0: stm32f3: Wake from STOP mode on UART start bit
By default, UART wakes the chip up on RXNE interrupt. This means when
the chip wakes up, RDR is full and only the shift register is empty, and
this leaves us only the time of a single character to process the
character in RDR. On some system, this is not enough and the first (or
even the second) character is overrun, and thus any multi-character keys
(e.g. arrow keys) break.

To avoid this problem, let's change the wake source to wake on start bit
detection. This gives us the time for one more character to wake up and
process the console input.

BRANCH=None
BUG=chrome-os-partner:33219
TEST=Enable low power mode on Ryu P2. In STOP mode, hit up arrow key and
see the last command show up.

Change-Id: Idce4c0bdfcf3e04ad84152ba525f704a0909f115
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225771
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@google.com>
2014-10-28 06:12:33 +00:00
Alec Berg
5f4ea79bb1 samus: use resulting current limit from charge manager
Send the current limit chosen by charge manager to the EC so
that it can set the current limit appropriately. Note, before
this change, only the PD negotiated current limit was sent to
EC.

BUG=none
BRANCH=samus
TEST=use a non-PD type-C charger and verify current limit gets
set appropriately on EC.

Change-Id: Ic4bfce052ec8150cad07d35e2cb2fcbfd3d3e6c8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225667
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-28 01:46:38 +00:00
Shawn Nematbakhsh
bf88b804ee usb_pd_protocol: Don't prematurely set PD charge supplier limit
Wait until we have a confirmed PD charger before setting the PD charge
limit to non-zero.

BUG=None
TEST=Manual on samus_pd. Insert type C non-PD charger, verify that
current limit is correctly set to to 3000 mA.
BRANCH=Samus

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ib4ec663d926e6ed955427e4a77123caac0e20252
Reviewed-on: https://chromium-review.googlesource.com/225691
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-28 01:46:32 +00:00
Shawn Nematbakhsh
2eb6cba5bd charge_manager: Move supplier list and priority hierarchy to board
Allow the list of charge suppliers and port selection priority to be
specified at the board level.

BUG=chrome-os-partner:32650
TEST=Manual on samus_pd. Plug + unplug PD and BC1.2 chargers, verify
that PD is always preferred and higher power port / supplier is always
selected.
BRANCH=Samus

Change-Id: Ic867a40120c809111bf76bf290ed6f204eab1168
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225292
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-26 23:47:14 +00:00
Alec Berg
a08c2d579e pd: for DP mode, only enter mode if device is DFP_U capable
Added return parameter to enter mode functions. For DP mode on
samus and fruitpie, only send enter mode if device is a DP
sink (DFP_U).

BUG=none
BRANCH=samus
TEST=make buildall. tested a simpler version of this with a
third-party DFP_D capable device and verified we don't send
enter mode.

Change-Id: I5caf008b7b3711232aeb1a1012cde2022584109b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225288
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-25 08:14:26 +00:00
Alec Berg
a019bf5853 pd: make transition out of hard reset shorter
Shorten the hard reset timeout so that we transition out of hard
reset state faster.

BUG=none
BRANCH=samus
TEST=test on third-party product that sends source cap very soon
after we send hard reset. without this patch we weren't responding
to the first few source caps, with this change we respond right
away.

Change-Id: I285aaf0296604da22438e31bc962629701694b7b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225247
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-25 08:14:21 +00:00
Katie Roberts-Hoffman
908b3f559b Add initial support for jerry
BUG=chrome-os-partner:33269
TEST=make BOARD=jerry; ./util/flash_ec BOARD=jerry
(on a pinky rev2 as a sanity)

Change-Id: I2c54e4044a65a0014adb32dd46f74bf5ed11b02d
Signed-off-by: Katie Roberts-Hoffman <katierh@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225300
Reviewed-by: Alexandru Stan <amstan@chromium.org>
2014-10-25 08:14:16 +00:00
Todd Broch
cadce20c1a pd: Add DFP parsing for alternate mode status & attention.
Once alternate mode is entered the DFP will make an initial status
request to the UFP.  Future status changes on the UFP are then sent to
the DFP via the attention command.  This VDM consists of the VDM
header plus another VDO containing mode specific information.

CL adds ability of DFP to consume the attention VDMs status message
and in the case of DisplayPort SID toggle the necessary HPD gpio
accordingly.

BRANCH=samus
BUG=chrome-os-partner:30645
TEST=manual, for DFP w/ HPD over CC see HPD toggle correctly without
manually driving it providing cable connected when AMA is inserted.

Change-Id: Ifef60b5d0170cbcc1b518e3b13e84bac99a17e32
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/224769
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-25 08:14:10 +00:00
Vic Yang
bf8335a0a3 stm32: Wait for UART Tx to complete before entering STOP mode
Before entering STOP mode, we need to ensure UART Tx has completed.
Otherwise, we may lose some characters or some bits within a character.
For Tx DMA mode, this is already done as we wait until TC (Tx complete)
is set before disabling Tx. However, when not using DMA, we enable sleep
when TXE is set. At this moment, the last character is still in the
shift register and going into sleep causes loss of the whole or part of
the last character.

To avoid this, let's enable TC interrupt and enable sleep only if we
have no more characters to send and TC is set.

BRANCH=None
BUG=chrome-os-partner:33219
TEST=Enable low power mode on Ryu P2. Type when the EC is in STOP mode
and check there is no broken character.

Change-Id: Ife42671882b7f1d1d17734d7d20fb4ba7dffb371
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225283
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-24 21:17:29 +00:00
Vic Yang
0dd653292c ryu: Enable watchdog helper for P2 boards
We have several unused timer. Let's use TIM19 for watchdog helper.

BRANCH=None
BUG=chrome-os-partner:32660
TEST='waitms 3000' and see debug message.

Change-Id: I638a4de7d2729ffb10cb5cf2b3fb9c458dd588a5
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225254
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-24 03:02:45 +00:00
Vic Yang
c72c86b9b1 stm32: Add watchdog debug message for hwtimer32
This adds the option to use one 16-bit timer for watchdog helper when
using 32-bit hwtimer. With this, a debug message is dumped before
watchdog fires and we can easily see the task hogging the processor.

BRANCH=None
BUG=None
TEST=On Ryu P2, 'waitms 3000' and see debug message before the EC
reboots.

Change-Id: I498f63a105a0ba1ab7ec7d274dc8b1f16a44140f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225253
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-24 03:02:40 +00:00
Vincent Palatin
6dc5e697aa pd: update DP pin configuration declaration
When we are a UFP with a plug, for the supported DisplayPort pinout,
we need to state which DFP pin configuration we support.
Update the field used for declaring pin configuration in our display
dongles.

HoHo is a protocol converter : update the pin assignment to C.

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

BRANCH=samus
BUG=chrome-os-partner:30645
TEST=none

Change-Id: Ie5484f228bd39666c6b01055bd11f68eb9acad88
Reviewed-on: https://chromium-review.googlesource.com/225231
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-24 03:02:33 +00:00
Vincent Palatin
9adf64478f pd: update DP mode signaling bits
A USB type-C to DisplayPort dongle can support either DPv1.3 or
USB Gen 2 signaling.
Our dongles need to advertise that they support DPv1.3 and only this.
Our DFP needs to request DPv1.3 signaling.

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

BRANCH=samus
BUG=chrome-os-partner:30645
TEST=Plug a type-C to DP dongle from another vendor to Samus and see a
display output.

Change-Id: Ie0ac16b675e86f635220a954a2c03442777cc527
Reviewed-on: https://chromium-review.googlesource.com/225250
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-24 03:02:27 +00:00
Vic Yang
e1a6096dbe ryu: properly enable UART Rx DMA for P2 boards
We defined the DMA channel for UART Rx DMA to use, but we didn't
actually enable it.

BRANCH=None
BUG=chrome-os-partner:32660
TEST=Check the console is still responsive

Change-Id: I0dcbeeccb3a4213305c84ec5238e6e9dbee09b33
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225280
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-24 03:02:16 +00:00
Vic Yang
791ead7aba stm32: Fix UART Rx DMA for USART2 and above
This modifies the stray hard-coded DMA channel for UART Rx to the
correct config flag.

BRANCH=None
BUG=chrome-os-partner:32660
TEST=On Ryu, enable UART Rx DMA and check console is still responsive

Change-Id: Icec2de6ad4d34c6e0f8df2a1d51d9fefd982c9f4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/225239
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-24 03:02:12 +00:00
Vic Yang
d1ed75815e MKBP event signalling implementation
This implements a new API for EC modules to define MKBP event sources
and send MKBP event to the AP. Also, a new host command
EC_CMD_GET_NEXT_EVENT is added for the AP to query the pending MKBP
events. Each event type may have custom event data sent along with the
event.

BRANCH=None
BUG=chrome-os-partner:33194
TEST=Enable MKBP event on Ryu. Set a host event from EC console, run
'ectool nextevent', and see MKBP event 0x01 (HOST_EVENT) and the set
host event.

Signed-off-by: Vic Yang <victoryang@chromium.org>
Change-Id: I28a1b7e826bcc102bbe39016c9bb3e37d125664c
Reviewed-on: https://chromium-review.googlesource.com/224905
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-24 01:37:58 +00:00