Commit Graph

3031 Commits

Author SHA1 Message Date
Todd Broch
03cbbb2be7 hoho: Add USB Billboard class device.
BRANCH=none
BUG=chrome-os-partner:31192
TEST=manual
Plug hoho into samus and see:
    # lsusb -d 18d1:5010 -v

    Bus 001 Device 007: ID 18d1:5010 Google Inc.
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               2.01
      bDeviceClass           17
      bDeviceSubClass         0
      bDeviceProtocol         0
      bMaxPacketSize0        64
      idVendor           0x18d1 Google Inc.
      idProduct          0x5010
      bcdDevice            2.00
      iManufacturer           1 Google Inc.
      iProduct                2 Hoho
      iSerial                 3 v0.001
      bNumConfigurations      1
      Configuration Descriptor:
	bLength                 9
	bDescriptorType         2
	wTotalLength           10
	bNumInterfaces          0
	bConfigurationValue     1
	iConfiguration          0
	bmAttributes         0x80
	  (Bus Powered)
	MaxPower              500mA
    Binary Object Store Descriptor:
      bLength                 5
      bDescriptorType        15
      wTotalLength           73
      bNumDeviceCaps          2
    FIXME: alloc bigger buffer for device capability descriptors
    Device Status:     0x0000
      (Bus Powered)

Change-Id: I1431829f926eaf86477b49591e9b0adf2b4cb3a6
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221571
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-11 02:22:36 +00:00
Todd Broch
8a6c72022f pd: Enable alternate mode support for DP.
Change effects:
1. samus_pd: Acts as initiator of SVDM discovery once its reaches source
             ready and upon identifying UFP with display port
	     alternate mode enters that mode.
2. hoho: Acts as responder for SVDM discovery providing its identity,
         svids and svid capabilities which are display port only.  If
	 asked to enter display port alternate mode it does.
3. fruitpie: Acts a initiator with mock display port mode.

BRANCH=none
BUG=chrome-os-partner:30645
TEST=manual,
Plug hoho into samus_pd
- see dpout
- from console
  > typec 0
  Port C0: CC1 451 mV  CC2 111 mV (polarity:CC1)
  Superspeed DP1

Change-Id: I1a76767353a69baeceffa3e79c37dcea77b8337d
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221354
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-11 02:22:28 +00:00
Todd Broch
44e4f7cfe7 usb: Groundwork for USB BOS & Billboard class descriptors.
The BOS (Binary Device Object Store) descriptor was added to the USB
specification (3.0) to allow a richer set of device capability
specific descriptors.

The Billboard class is meant to expose (read-only) the status of USB
devices capable of alternate mode functions.  It's required to use the
BOS descriptor type and at a high level looks like:

  - BOS Device Descriptor (5bytes)
    - Container ID Device Capability Descriptor (20bytes)
    - Billboard Device Capability Descriptor (44byte + 4 * numSVIDs)

This CL adds:
1. Ability for Get Descriptor on BOS descriptors.  Note hidden behind
CONFIG_USB_BOS as these descriptors change USB device requirements
to:
   - bcdUSB >= 0201
   - no interface descriptors

2. structures for all BOS, Container & Billboard descriptor elements
complete w/ CamelCase.

BRANCH=none
BUG=chrome-os-partner:32652
TEST=compiles with CONFIG_USB & CONFIG_USB_BOS enabled.

Change-Id: I1b24bc728f2ebba7d91840801d2ebe576e240e7c
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221570
2014-10-11 02:22:23 +00:00
Vincent Palatin
4d81320ed8 usb: allow reading descriptors larger than 64 bytes
When a control transfer requests a descriptor larger than 64 bytes, we
need to do several IN transfers to get the proper packet sequence :
SETUP IN IN IN .. IN OUT(null)

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

BRANCH=samus
BUG=chrome-os-partner:32652
TEST=set USB_STR_VERSION to "012345678901234567890123456789ABCDEF",
then do "lsusb -v" on the host and check the USB transfers
with the protocol analyzer.

Change-Id: I6940095008cb2a34c6896b337c5eda4fa267adc1
Reviewed-on: https://chromium-review.googlesource.com/222700
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-10-11 02:22:18 +00:00
Shawn Nematbakhsh
ac2b30d1e7 pi3usb9281: Add function for translating registers to current limit
Decode Pericom registers to current limits.

BUG=chrome-os-partner:32003
TEST=Manual on samus_pd. Insert 1A Apple charger, verify current limit
is correctly detected as 1A.
BRANCH=samus

Change-Id: I310d9f22cef80e97c1734e6a56f0034ebe01df31
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222638
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-10 06:54:22 +00:00
Alec Berg
358aeb2877 Revert "pd: samus: ryu: add Vconn support and enable for samus and ryu"
This reverts commit 61dc089e23.

Samus polarity is wrong on VCONN due to naming mismatch. Will fix in a later CL, but should revert now to avoid problems.

Change-Id: Icabcf2967e92caec94840df7e66a6658c7cde007
Reviewed-on: https://chromium-review.googlesource.com/222717
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-10 06:54:16 +00:00
Mohammed Habibulla
f92f70d04c Disable LEARN option during charger init
When charger is initialized disable the LEARN option i.e. reenable
charging on AC power

BUG=chrome-os-partner:32320
TEST=set DUT to discharge on AC and then reflash EC. Ensure that
charging begins again.
BRANCH=none

Change-Id: I3e83db27ab49548d5491548fa624899865c11bfb
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222644
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-10 04:36:46 +00:00
Shawn Nematbakhsh
fd7846fe09 usb_pd: Add port parameter to pd_set_input_current_limit
Some platforms may need to take different actions depending on which
port is requesting a limit. Add a new port parameter to the
pd_set_input_current_limit API to accomodate this.

BUG=chrome-os-partner:32003
TEST=Manual on samus_pd. Verify zinger charges battery.
BRANCH=samus

Change-Id: I1578252c751b3a80b4da6ca68e2a958934283cbf
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222621
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-10 02:43:39 +00:00
Alexandru M Stan
6f97b22ce7 Pinky: Pull up AC_PRESENT
We switched to an internal pullup in rev2 to conserve power.

BRANCH=None
BUG=None
TEST=AC adaptor works, "gpioget AC_PRESENT"

Change-Id: Idcf78d2632b9a43862539e45167173c175ac2aaa
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222593
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Chris Zhong <zyw@rock-chips.com>
Tested-by: Chris Zhong <zyw@rock-chips.com>
2014-10-10 02:43:35 +00:00
Eric Caruso
6713fa2d38 lightbar: Rename structs and macros for kernel cros_ec_commands
This prepends EC_ a macro exposed in ec_commands.h, moves a
macro into lbcc that is not used elsewhere, and changes lb_program
structs to lightbar_program.

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

Change-Id: I481562da72d91f846c64cf9af40338027641462c
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222406
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-09 23:29:42 +00:00
Vic Yang
e3e7999164 Don't hibernate on low battery if hiberante is not supported
If CONFIG_HIBERNATE is explicitly undefined for a board, the EC
shouldn't hibernate when the battery is running low. Otherwise, the EC
reboots because of the lack of hibernate support, and this actually
burns more power.

BUG=chrome-os-partner:32727, chrome-os-partner:32779
TEST=Drain the battery to 2% and verify the EC is behaving.
BRANCH=None

Change-Id: I2f9f5fd8fb4b5be4d8da113da4ef26c062869a07
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222615
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-09 23:29:34 +00:00
Alec Berg
61dc089e23 pd: samus: ryu: add Vconn support and enable for samus and ryu
Add support for enabling USB type-C Vconn by defining CONFIG_USBC_VCONN.
Enable Vconn support for samus, ryu, and fruitpie.

BUG=chrome-os-partner:30445
BRANCH=samus
TEST=make buildall

Change-Id: Ibe247286c96fd5a8fa12c88a4e3a5fea02997134
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222284
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-09 23:29:24 +00:00
Todd Broch
a194bede19 pd: VDM Alternate mode support.
Successfully communicate SVDM for discovery (identity, svids, modes)
and enter mode.

Still need to:
- Add same functionality on when power role is sink too.
- determine what connected events would require exit mode.
- do proper cleanup on disconnect.
- implement real display port 'enter' mode for samus_pd
- test & cleanup

Additionally the USB Billboard class functionality needs to be added
but will likely do that in a separate CL.

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

From fruitpie,
    [Image: RO, fruitpie_v1.1.2263-d79140d-dirty 2014-09-29 17:44:15 tbroch@brisket.mtv.corp.google.com]
    [0.000383 Inits done]
    C0 st2
    Console is enabled; type HELP for help.
    > [0.250551 USB PD initialized]
    pd dualrole source
    C0 st8
    > [8.366335 PD TMOUT RX 1/1]
    RX ERR (-1)
    [8.478308 PD TMOUT RX 1/1]
    RX ERR (-1)
    [8.590280 PD TMOUT RX 1/1]
    RX ERR (-1)
    C0 st9
    Switch to 5000 V 3000 mA (for 3000/3000 mA)
    C0 st10
    C0 st11
    C0 st12
    8.867593] SVDM/4 [1] ff008081 340018d1 00000000 17000008
    8.867906] DONE
    8.871006] SVDM/2 [2] ff008082 ff010000
    8.871224] DONE
    8.875092] SVDM/7 [3] ff018083 00100081 00000000 00000000 00000000 00000000 00000000
    Entering mode w/ vdo = 00100081
    8.875492] DONE
    8.878435] SVDM/1 [4] ff018144
    8.878612] DONE

    > pe 0 dump
    SVID[0]: ff01 [0] 00100081 [1] 00000000 [2] 00000000 [3] 00000000 [4] 00000000 [5] 00000000
    MODE[0]: svid:ff01 mode:1 caps:00100081

From hoho,
    [Image: RO, hoho_v1.1.2263-d79140d-dirty 2014-09-29 17:54:59 tbroch@brisket.mtv.corp.google.com]
    [0.000375 Inits done]
    C0 st2
    Console is enabled; type HELP for help.
    > [0.250542 USB PD initialized]
    C0 st3
    [0.264637 PD TMOUT RX 1/1]
    RX ERR (-1)
    Request [1] 5V 3000mA
    C0 st4
    C0 st5
    C0 st6
    0.487451] SVDM/1 [1] ff008001
    0.487628] DONE
    0.491190] SVDM/1 [2] ff008002
    0.491346] DONE
    0.494510] SVDM/1 [3] ff018003
    0.494667] DONE
    0.498777] SVDM/1 [4] ff018104
    0.498934] DONE

Change-Id: I5e2b7802c66b8aaad97e5120dca7a02820086bc1
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/219513
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-09 20:44:43 +00:00
Shawn Nematbakhsh
0938563284 zinger: Remove references to SHA1 hash
The PD protocol no longer uses a SHA1 RW hash. Instead, it uses the
first 20 bytes of the SHA-256 hash. Update constants and comments
accordingly.

BUG=chrome-os-partner:31361
TEST='make buildall -j'
BRANCH=samus

Change-Id: Ice74b841dbd1d81205c1ef0079a5e18fca2153b6
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222446
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-09 20:44:39 +00:00
Eric Caruso
6aba9b382b lightbar: extra test program
Gets a little more coverage on the SET_COLOR control operand.

BUG=None
BRANCH=ToT
TEST=On hardware and simulator. Should appear exactly the same
  as rainbow-shift.bin.

Change-Id: Id9c9948ae178884180e4d42e4fcceb58218423f8
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222004
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-09 16:42:09 +00:00
Bill Richardson
784b03edce samus: start fans a little sooner to keep things cool
This lowers the CPU temp at which the fans start up, from 55C to
43C. It also increases the slope a bit, so that they run a little
faster as well.

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

Visit www.fishgl.com/?full both before and after this CL.
Before, the keyboard got a little too warm. After, the fans come
on sooner and the keyboard is cooler.

Change-Id: I5c4947c5d2bb4a28c0ac449e109e2bd1af84068c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222171
Reviewed-by: Sameer Nanda <snanda@chromium.org>
2014-10-09 16:42:04 +00:00
Mohammed Habibulla
0fd73ae937 ectool: replace thermal_threshold_version with ec_cmd_version_supported
BUG=none
TEST='ectool thermalget' works as expected
BRANCH=none

Change-Id: Ie225ef0aaeae913162e8cd6c56193dedd9f56f2f
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221745
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-08 05:07:33 +00:00
Todd Broch
c1714dac12 dingdong: Initial board and USB PD support.
Allows dingdong to receive initial USB PD communication (source
capabilities payload) and with some manual manipulation (see 'TEST=')
drive DPout.

CL is based heavily off hoho dongle where all files were copied from
   board/hoho:
     7b1e58c ectool: Add host command support to set fan RPM for each
             fan separately

   Files gpio.inc, board.h & board.c were modified but others should
   be identical.

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

When attaching dingdong to samus_pd and configured via
  'pd dualrole source'

I see following on samus_pd console:
    C1 st9
    Switch to 5000 V 900 mA (for 900/900 mA)
    C1 st10
    C1 st11
    C1 st12

showing power constract and transition to SRC_RDY:
    > pd 1 state
    Port C1, Enabled - Role: SRC Polarity: CC1 State: SRC_READY

    > typec 1 dp

Also if I connect in CC1 configuration and get access to dingdong
console I can
   > gpioset PD_SBU_ENABLE 1

And see dingdong drive external monitor

Change-Id: I30ef6f8503a3fb015cfb8806bc36fb98f5150e40
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221913
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-08 05:07:29 +00:00
Vic Yang
7f55a51ced stm32f: stm32f0: guard hibernate function with CONFIG_HIBERNATE
If CONFIG_HIBERNATE is explicitly undefined for a platform, we shouldn't
try to hibernate.

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

Change-Id: Id0f93a3a694065478373e364d82589ff08e7d980
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/222013
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-08 05:07:24 +00:00
Alec Berg
1eec1e3cd4 stm32f0: fix potential hang in adc initialization
Fix bug that can cause ADC initialization to hang and eventually
watchdog. Problem was that you need at least 4 ADC clock cycles
between end of ADC calibration and enabling ADC (setting ADEN).
Fix is to (1) move some ADC configuration to between end of cal
and setting ADEN, and then just to be safe, (2) continually set
ADEN until we see ADRDY (ADC ready).

See bug report for more information.

BUG=chrome-os-partner:32561
BRANCH=samus
TEST=load onto a samus that regularly has ADC problems on boot.
Using power+refresh verify that without this change PD hangs
some of the time, and with this change it never hangs.

Change-Id: Ifa4c3240ad7e1612647cc74e2105e6545ed19db4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221984
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-10-08 05:07:20 +00:00
Sheng-Liang Song
ac261c00c1 samus: support sensor at different power state.
Design Goals:
1. Every time the AP boots, the same default sensor settings are configured.
2. If the AP goes to suspend (S3) and wakes back up (S0),
   then the AP sensor settings will be restored.
3. In S3 and in S5, only sample specific sensors that are needed.

BUG=chrome-os-partner:32368
BRANCH=ToT
TEST=Verified on Samus.

Verified suspend and resume logic with EC console messages.
- Test Case0: close lid & open lid
- Test Case1: powerd_dbus_suspend

Change-Id: I553c53e63ecfcb39d5e649a7189aa6ea02589471
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220371
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-08 02:51:17 +00:00
Alexandru M Stan
c5b30aa9f2 Renaming board veyron -> pinky
Seems that all previous boards used the subvariant specific name, and had an
alias from emerge-variant_subvariant to the ec subvariant folder.

BUG=chrome-os-partner:32331
BRANCH=None
TEST=cd board/pinky; make clean && make -j && ../../util/flash_ec --board=pinky

Change-Id: Ie6e0c977b6659687357a1b5aa2915cf0e40a5da7
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-10-08 02:51:13 +00:00
Mohammed Habibulla
72aee5c113 ectool: Fix help string for pwmsetfanrpm
BUG=none
TEST='ectool pwmsetfanrpm' prints correct help command
BRANCH=none

Change-Id: I6b1ecc7a581bb916563177f878f6361841e3ed90
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221957
2014-10-08 02:51:10 +00:00
Sheng-Liang Song
ac1c82a35b samus: Fixed a bug in host_sensor_id_to_motion_sensor
BUG=chrome-os-partner:32368
BRANCH=ToT
TEST=Verified on Samus.

cd /sys/bus/iio/devices/iio:device0
cat *peak_scale

Change-Id: I2b0606e55bfa5e498255c6c42240ee3f9236e4f1
Signed-off-by: Sheng-Liang Song <ssl@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220991
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-08 02:51:00 +00:00
Vic Yang
91cfdd0dac Remove PULSE and TEST sequences from lightbar module
PULSE and TEST sequences are not used anywhere. Remove them to save
flash space. Also, fix msleep(MSEC) calls in the unit test; it's
essentially usleep(SECOND) written in an incorrect way.

BUG=chrome-os-partner:32203
TEST=make buildall
BRANCH=None

Change-Id: I61ba897df632538eb89364a4c913d5fee87f3864
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220711
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-10-08 02:50:54 +00:00
Anton Staaf
a3ddf04ca9 stm32-USB: USB GPIO control driver
Simple control of GPIOs over USB.

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

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

Change-Id: Ic5deccd1a70080742d5ac745b537ebecd56d7443
Reviewed-on: https://chromium-review.googlesource.com/217528
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
2014-10-08 02:50:48 +00:00
Vic Yang
bd59d5bfb6 Add support for STM32F373
This mostly reuses chip drivers for STM32F and STM32F0. Since this chip
doesn't fit either STM32F or STM32F0, let's use symlink to specify which
drivers to use for STM32F3.

This is just the preparatory work and it's not verified on a chip yet.

BUG=chrome-os-partner:32660
TEST=make buildall to make sure this doesn't break anything
BRANCH=None

Change-Id: I709ed49265e8f84552251a97d03b9b98496de99e
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221412
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 20:58:52 +00:00
Todd Broch
08c53f231d hoho: Make HDMI SPI CS input by default.
Also corrected typo in GPIO name.

BRANCH=none
BUG=chrome-os-partner:31192
TEST=manual, compiles & runs on hoho.

Change-Id: Ib41803c48795d5fc4cdbd15e9a977f78bb029405
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221572
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-07 20:58:44 +00:00
Mohammed Habibulla
5c8da35f87 ectool: hostcmd support to set fans auto control individually
ectool autofanctrl 1 - set auto fan control for fan 1

BUG=chrome-os-partner:23803
TEST=Tested the above EC command on Auron
BRANCH=none

Change-Id: Idcd3690ad98d7965420f26f7cc445207fe73704d
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221816
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-07 20:58:33 +00:00
Shawn Nematbakhsh
7cde31850d stm32: pwm: Fix duty cycle / frequency calculation
Correct frequency + duty cycle register calculations according to
datasheet.

BUG=chrome-os-partner:32089
TEST=Manual on Samus. Set 50% duty cycle and probe on scope, verify that
duty cycle is actually 50% and frequency is exactly 100 Hz.
BRANCH=samus.

Change-Id: I1e2c0bb7e53110367c38987b369fbef44af90a7d
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221790
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-07 18:31:34 +00:00
Alec Berg
7b305b752b zinger: samus_pd: increment zinger hardware id minor revision
Add a minor revision to the PD device hardware ID field in the info
custom VDM and set increment this minor ID from 0 to 1 for zinger.
This differentiates zingers for the auto-update payload, so we can
update only those with a specific major and minor ID version.

BUG=none
BRANCH=samus
TEST=load onto samus and zinger. when connect zinger, see on PD
console: Dev:0x0401 SW:2289 RW:0, which shows the appropriate
device ID.

Change-Id: I482ee2d850332b608cdd81537f68d4dc509bfc1a
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221320
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 05:53:26 +00:00
Alec Berg
a67adf4af5 samus_pd: send host event when we recv info VDM from PD device
Send host event to AP when we receive info VDM from a PD device.
This allows the AP to potentially send an update to the device.

BUG=none
BRANCH=samus
TEST=load onto samus. when zinger is attached, verify that
EC sends host event to AP.

Change-Id: I10961ab60fb752e2e40a21d9351bd1ba98cc11da
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221162
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-10-07 05:53:19 +00:00
Alec Berg
d5d2a71c96 pd: zinger: move sending info VDM from UFP to DFP
Changed sending of info VDM from the UFP side in SNK_DISCONNECTED
to the DFP side in SRC_READY to match the PD spec. Only the DFP
is supposed to send VDMs, and by default the power source is the
DFP. This affects simple DFPs such as power adapters, they must
initiate the info VDM once a power contract has been negotiated.

BUG=none
BRANCH=samus
TEST=load onto samus_pd and zinger and make sure that when you
attached zinger to samus, samus receives info VDM and prints out
something like:
VDM/7 [11] 18d1000b
Dev:1 SW:2280 RW:0

Change-Id: I16ceac31939fdc1c74be7323e628dd8706e1283b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221174
Reviewed-by: Todd Broch <tbroch@chromium.org>
2014-10-07 05:53:13 +00:00
Vincent Palatin
c817472c07 Update Zinger flashing process
Convert the Zinger flash update commands to the new RSA signature
mechanism.

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

BRANCH=samus
BUG=chrome-os-partner:28336
TEST=from the workstation:
./util/flash_pd.py -m 1 build/zinger/ec.RW.bin
from Samus command-line :
ectool --name=cros_pd flashpd 0 1 ec.RW.bin

Change-Id: Ie8cd7f644ec94e461c5775a4dbbcd408782c72e1
Reviewed-on: https://chromium-review.googlesource.com/221560
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 03:37:48 +00:00
Alec Berg
01c331fd33 zinger: add config option for hibernate and disable by default
Disable hibernate by default on zinger because some EVT zingers
do not wake up on connect due to hardware problem.

BUG=chrome-os-partner:28335
BRANCH=samus
TEST=load onto zinger, leave disconnected for 60s, make sure it
doesn't go into hibernate

Change-Id: I9f5f9fb1ce349ea862652cd38aa5d1e521234b30
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221478
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 01:29:39 +00:00
Mohammed Habibulla
876b0f0bdc ectool: Add hostcmd support to set fan duty cycle for each fan separately
ectool fanduty <percent>	- set all fans to <percent> duty cycle
ectool fanduty <fan> <percent>	- set <fan> to <percent> duty cycle

BUG=chrome-os-partner:23803
TEST=Tested the above EC commands on Auron
BRANCH=none

Change-Id: I06ca1552bd8f3412f6e90245da302c9f86ab6103
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221505
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-07 01:29:36 +00:00
Alec Berg
e541eeb294 cortex-m0: disallow rescheduling if task_start() has not yet run
Do not allow rescheduling tasks if task_start() has not been called.
This fixes a bug in which if console input occurs between uart_init()
and task_start(), the MCU crashes because uart_init() enables uart
interrupts which attempts to wake up the console task when RX data
is received, which then tries to task switch before we initialized
task scheduling.

BUG=chrome-os-partner:32561
BRANCH=samus
TEST=add while(1) loop to adc_init() to simulate stalled ADC
initialization. When stalled, send console character and observe
that without this CL MCU crashes, and with this CL the MCU does
not crash.

Change-Id: I34418e88ebe0063acf1cc55ab5a57b5fddcd9d23
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221599
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-07 01:29:33 +00:00
Vic Yang
f0dc012cf7 Add back unit test for usb_pd"
This is mostly the same as previous commits, but with increased delay.
Previously, we have short delays (e.g. 3ms) which is too short and may
cause instability.

Now that we have slowed down the time when running unit tests and
increased the delay, this shouldn't cause problems anymore.

BUG=chrome-os-partner:31200
TEST=Repeatedly run multiple unit tests in parallel.
BRANCH=Samus

Change-Id: Ib55e3adc5fd27a8e233996b4799dab3cefd62318
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220734
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-04 21:08:48 +00:00
Eric Caruso
15eced0374 lightbar: refactoring RAMP_ONCE and CYCLE_ONCE
These opcodes basically do the same thing, but with minor
changes. We can factor this out to avoid code duplication.
Saves 90 bytes.

BUG=None
BRANCH=ToT
TEST=Inspected programs that use RAMP_ONCE and CYCLE_ONCE with
  both nonzero and zero ramp delay.

Change-Id: I0105dbd4fc0af86beea993dbef85a0e0f01a0a90
Signed-off-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220604
Reviewed-by: Vic Yang <victoryang@chromium.org>
2014-10-04 21:08:45 +00:00
Vic Yang
7bbf6d7bb3 Slow down time when running unit tests
When a timing sensitive test run on a heavily loaded system, sometimes a
task runs for longer than it usually does and causes the test to fail.
All the timing requirements in the unit tests are trying to verify the
various delays in our codebase, and mostly we don't care about the time
taken by active running code (as they are very quick.) To improve the
stability of tests, let's slow down the time. To a test, it's as if the
code runs faster. If a test uses udelay() and exceeds the 10-second time
limit, we can make that single test faster by setting the time scale.

BUG=None
TEST=Repeatedly run 'make runtests'
BRANCH=None

Change-Id: I9bc5c77e0d34d04c8630d495387a751ef29c7bd5
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220717
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-04 21:08:38 +00:00
Mohammed Habibulla
7b1e58cc43 ectool: Add host command support to set fan RPM for each fan separately
First case is for legacy support
ectool pwmsetfanrpm <targetrpm>		- set all fans to <targetrpm>
ectool pwmsetfanrpm <fan> <targetrpm>	- set <fan> to <targetrpm>

BUG=chrome-os-partner:23803
TEST=Tested the above EC commands on Auron
BRANCH=none
CQ-DEPEND=CL:220960

Change-Id: I8f447f53289abaa9c5cc1285f9f0921328fbf32c
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221291
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 22:27:03 +00:00
Todd Broch
f93c3e83e4 hoho: updates for rev2.0
BRANCH=none
BUG=chrome-os-partner:31192
TEST=manual,

- compiles & installs & runs on hoho rev2.0
- see RFUx -> SBU gpio change
> gpioget PD_SBU_ENABLE
  1  PD_SBU_ENABLE

Change-Id: Ice6963e05463670653470b24d451d41a35e249f3
Signed-off-by: Todd Broch <tbroch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220181
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-03 22:26:58 +00:00
Mohammed Habibulla
75d7e31b9c ectool: add new host command to get number of fans
BUG=chrome-os-partner:23803
TEST="ectool pwmgetnumfans" returns correct number of fans on Auron
BRANCH=none

Change-Id: I2a1930a8f0965b08558bfb3c6424c571a6149bbb
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220960
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 22:26:52 +00:00
Mohammed Habibulla
938ba82bd7 ectool: Fix fanduty help
BUG=none
BRANCH=none
TEST=none

Change-Id: Iff09a24064d4245d2660dd307084cd701d03676b
Signed-off-by: Mohammed Habibulla <moch@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221202
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-10-03 04:30:01 +00:00
Alec Berg
ba624e7241 zinger: add hibernate if disconnected for 60s
Automatically go into hibernate (standby mode) if not powering
anything for 60 seconds. Will wake up when it is plugged into
something (senses pull-down on CC line).

BUG=chrome-os-partner:28335
BRANCH=samus
TEST=load onto zinger. if disconnected for 60s, see hibernate
print on zinger console. when connected to a device, verified
it boots again.

Change-Id: I2564c6192395bb5e4f6d7586c2725f13a4581049
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220837
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-03 04:29:57 +00:00
Vincent Palatin
beaddbf1a3 zinger: check RW firmware signature
The Zinger RW is now signed with 2048-bit RSA key (using SHA-256 as
digest).
This CL implements the verification mechanism.

note: the RSA key used for signing must be provided as a .pem file.
The path to .pem file must be provided in the PEM environment variable.
By default, it's using the dev key stored in zinger_dev_key.pem.

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

BRANCH=samus
BUG=chrome-os-partner:28336
TEST=on Zinger, run with properly signed RW firmware and corrupted
firmware and check the serial traces.

Change-Id: Ia58482458904a3ed72d6b0e95996cae86a0ead83
Reviewed-on: https://chromium-review.googlesource.com/220178
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2014-10-02 23:18:25 +00:00
Alec Berg
0330d9adf2 zinger: minimuffin: add board support for minimuffin
Minimuffin is identical to zinger, same MCU, same gpio, same
circuitry aroundt the MCU with two differences:
- Rated current is 2.25A instead of 3A
- USB PD hardware device ID needs to be different so that host
can differentiate between the two.

Due to the similarity between the two, minimuffin is defined
as a symlink to the zinger board.

BUG=none
BRANCH=samus
TEST=make BOARD=minimuffin
load onto a zinger and verify that samus reads device ID correctly
and limits input current limit to 2.25mA.

Change-Id: Ie39ec43262c7d14663eb68abff073bfeec451a24
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220689
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2014-10-02 20:51:10 +00:00
Chris Zhong
4be45e962c stm32: invert keyboard col2 option
Silego variant in pinky rev2 require the signal to be inverted.

BUG=None
TEST=on pinky-rev2: all keys from col2 work correctly
BRANCH=None

Change-Id: I83a029b4e9c6b4770e83f30b170595d45ea40cca
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220314
2014-10-02 20:51:05 +00:00
Chris Zhong
7a8891268d Veyron: power on 5v drv for pinky-rev2
EC need to enable 5v_drv when power on AP, disable it when power off AP.

BUG=None
TEST=USB host works well
BRANCH=None

Change-Id: Ie18679a5a2d3c676daf0af4da599fa010d98161d
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Reviewed-on: https://chromium-review.googlesource.com/220162
Reviewed-by: Alexandru Stan <amstan@chromium.org>
Tested-by: Alexandru Stan <amstan@chromium.org>
Commit-Queue: Alexandru Stan <amstan@chromium.org>
2014-10-02 20:51:02 +00:00
Vic Yang
cac05af1aa Remove 'param' option in lightbar console command
We can use ectool to set/get lightbar parameters and don't need a huge
console command option for this. Let's get rid of it to save flash
space.

BUG=chrome-os-partner:32203
TEST=make buildall
BRANCH=None

Change-Id: Ifbc122c887a36accaf3f8dce43f091d7d1333550
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/220710
2014-10-02 18:24:43 +00:00