Commit Graph

4661 Commits

Author SHA1 Message Date
Ben Lok
b1a3d8eda5 oak: handle the warm reset key from servo board
Warm reset key from servo board lets the POWER_GOOD signal
deasserted temporarily (about 1~2 seconds) since Oak rev4.
In order to detect this case, check the AP_RESET_L status,
ignore the transient state if reset key is pressing.

BUG=chrome-os-partner:46655
BRANCH=none
TEST=make buildall -j;
Press warm reset key of servo board, AP should reset normally.

Change-Id: Ib9f111d2273cde61354e72367fe74d4ee15d2291
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/307201
Tested-by: Yidi Lin <yidi.lin@mediatek.com>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-11-03 09:08:20 -08:00
Kyoung Kim
80b997dc27 mec1322: fix gpio_disable_interrupt
MEC1322_INT_DISABLE(interrupt enable clear register) is 'Write 1 to Clear'
for each bit. To disable interrupt for specific GPIO pin, only specific
bit should be written with 1.

BUG=NONE
BRANCH=NONE
TEST=NONE

Change-Id: Ibf40a20656c4c99f9625b516cff3e7da9bf2f69d
Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/309979
Commit-Ready: Kyoung Il Kim <kyoung.il.kim@intel.com>
Tested-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-11-03 09:08:07 -08:00
Ben Lok
59fd91317c oak: Adding 2S and 3S battery support
The default battery type of Oak is 3S, in order to compatible to
2S battery, set the minimum voltage of battery to 6V rather than 9V.

BRANCH=none
BUG=chrome-os-partner:46540
TEST=manual
1. connect 2S battery to rev4
2. check the battery info with EC command:
   > battery
3. confirm the voltage of battery is match to setting of battery_info.

Change-Id: Ieb7e39817bb0cefa523f73039b68943adb50f045
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/306381
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-11-03 09:08:00 -08:00
Dino Li
2ea7b194d9 nds32: fix interrupt
1. To enable INT_PRI (hardware interrupt priority level 0~3)
   register, bit0@INT_CTRL = 0.
2. GIE need to be enabled before UART is initialized.
   [symptom]
   To define CONFIG_RWSIG / CONFIG_RSA / CONFIG_SHA256, then power on:
   after RW image is verified, firmware stuck in uart_flush_output().

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

BRANCH=none
BUG=none
TEST=1. bit0@INT_CTRL = 0.
     2. The RW image is verified and jump to image RW.

Change-Id: I393a3d5f87ea257885b872c91bfce43aecbaea8b
Reviewed-on: https://chromium-review.googlesource.com/309400
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-01 19:45:58 -08:00
Dino Li
ba63ef190e it8380dev: fix irq, jtag and system
[irq]
1. The chip_init_irqs() function clears all IERx and EXT_IERx registers.

[jtag]
2. Enable debug mode through SMBus.

[system]
3. remove console_force_enabled functions.
4. implement __no_hibernate, scratchpad and nvcontext functions.

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

BRANCH=none
BUG=chrome-os-partner:23575
TEST=1. IERx and EXT_IERx registers are all cleared after chip_init_irqs().
     2. console command "scratchpad" and "hibernate".
     3. bram bank0 index 0x10 ~ 0x1F (16 bytes) for
        system_get_vbnvcontext() and system_set_vbnvcontext functions.

Change-Id: If044d50c69ae80b013ab646a3a6931cec7560ec4
Reviewed-on: https://chromium-review.googlesource.com/309390
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-01 19:45:57 -08:00
Mulin Chao
aa2db44011 nuc: Add state machines to handle i2c master stall bus and call i2c_xfer again.
Create two state machines SMB_WRITE_SUSPEND and SMB_READ_SUSPEND to handle i2c
master stall bus and call i2c_xfer again. Notice we should disable i2c
interrupt since cannot read/write SDA reg to clear interrupt pending bit.

Modified drivers:
1. i2c.c: Modified to handle calling i2c_xfer twice or more.

BUG=chrome-os-partner:34346
TEST=make buildall -j; test nuvoton IC specific drivers
BRANCH=none

Change-Id: I781f6f8227867ea9c0e265b3064f48602c0f5f07
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/309381
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-01 10:08:50 -08:00
Shawn Nematbakhsh
9258886bd3 glower: Remove board
Glower is no longer in use or useful, so remove it.

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

Change-Id: I8f9868e37a759fa7c1229d5ad2531bc947108010
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309976
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-30 23:02:23 -07:00
Alec Berg
a023d6b0c1 glados: oak: chell: enable USB PD logging
Enable USB PD logging.

BUG=chrome-os-partner:45933
BRANCH=none
TEST=make -j buildall
make -j BOARD=glados tests
Load on glados and test that PDLOG events show up in dmesg

Change-Id: I61dbc5019ea3228542c2c244228bbb483cf51ead
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309881
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-10-30 17:51:20 -07:00
Shawn Nematbakhsh
813e56e10a stm32f0: i2c: Set timing register values by port clock source
I2C1 may be clocked by HSI or SCLK. I2C2 is always clocked by PCLK.
Therefore, apply different timing register values according to the
selected clock source for a port.

BUG=chrome-os-partner:46188
BRANCH=None
TEST=Manual on glados_pd. Verify slave i2c communication is functional.

Change-Id: Icd2306d25d5863b0fc3379e46885a227efb23cca
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309781
Commit-Ready: Gwendal Grignou <gwendal@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2015-10-30 14:33:29 -07:00
Vadim Bendebury
e4d78afafb cr50: upgrade to the latest FPGA image 20151029_41713@78167
This patch updates the EC codebase to match the latest USB build which
now provides ability to programatically tell between different FPGA
flavors. It also changes the polarity of the 'cold bootsrap' pin, so
using the latest spiflash utility is mandatory.

Note that there has been no signer changes.

BRANCH=none
BUG=none
TEST=as follows:

    - programmed the FPGA, it now reports the following when reset:
      FPGA |20151029_041713@78167
    - booted the new image using the latest spiflash version. Note
      that the bootrom now reports the FPGA image it comes from
    - disconnected the FPGA upgrade port, rebooted the device, entered
      on the device console:
       > spstp off
       > spste
     run on the workstation:
       $ examples/spiraw.py -l 10 -f 800000
       FT232H Future Technology Devices International, Ltd initialized at 857142 hertz
     and observe on the DUT console:
       Processed 10 frames
       rx count 11574, tx count 5497, tx_empty 10, max rx batch 11
       >

Change-Id: I66596061731d9abcf41c5f5984ac479bbc1648e8
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309963
Commit-Ready: Vadim Bendebury <vbendeb@google.com>
Tested-by: Vadim Bendebury <vbendeb@google.com>
Reviewed-by: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Nagendra Modadugu <ngm@google.com>
2015-10-30 14:33:28 -07:00
Alec Berg
832b2cc58b samus: increase POWERBTN task stack size
BUG=chromium:547879
BRANCH=samus
TEST=make BOARD=samus

Change-Id: Iba29d53918245714ffcf6c87f42d1fa98be028b8
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309142
Reviewed-by: Shawn N <shawnn@chromium.org>
(cherry picked from commit 12d924b7a05ddcd64a6d845faba5d6dc348c4bbd)
Reviewed-on: https://chromium-review.googlesource.com/309553
2015-10-30 13:09:41 -07:00
Alec Berg
c6b22f0ab7 pd: turn on CONFIG_USB_PD_LOW_POWER by default
Define CONFIG_USB_PD_LOW_POWER by default to save power on both
TCPM and TCPC side by waking PD task less often when possible.

BUG=none
BRANCH=none
TEST=test on glados and samus.

Change-Id: I04441fb8339652cf073689177175a98f28807897
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309311
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-10-30 13:09:32 -07:00
Alec Berg
e080de3c48 pd: add more power improvements to PD task
Added more improvements to power consumption when using
CONFIG_USB_PD_LOW_POWER. On the TCPC, when this option is
defined, then decrease the PD task wake interval when
we are presenting Rd, we don't have a connection, AND we
haven't dual-role toggled recently. This shouldn't affect
connection time because we will get an interrupt when VBUS
is detected.

Note: we can't use the low power task wake interval when
we are connected because we need to monitor CC line for
Rp change and we can't do this when we are presenting Rp
because we need to quickly detect loss of Rd.

BUG=chrome-os-partner:45010
BRANCH=none
TEST=tested on glados. verified we connect to a charger in
S0 and S5. and verified that in S5, we spend >99% of our
time in deepsleep (as measured by idlestats console command).
note, that when testing EC and PD must both define
CONFIG_USB_PD_LOW_POWER to get maximum power improvements.

Change-Id: I661110cc7021f6d17937688787ea4f5f4b82973d
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309310
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-10-30 13:09:32 -07:00
Mary Ruthven
49d4254bd4 Jerry: enable virtual battery
BUG=chromium:484841
BRANCH=none
TEST=check power_supply_info works properly on Jerry

Change-Id: I166fd4fc876b2d71f82e8fc7b33e4268a30be567
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309264
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-29 10:31:40 -07:00
Ben Lok
b347f36b10 oak: ensure PMIC power button is released after SYSJUMP.
There is a race condition between SYSJUMP and function
release_pmic_pwron_deferred().
Process of EC SW Sync will delay the execution time of
release_pmic_pwron_deferred(). PMIC will shutdown the power, if
PMIC power button can not be released within 8 seconds (depends
on PMIC spec). In order to ensure PMIC power button will be
released in time, just release it after SYSJUMP.

BUG=chrome-os-partner:46392
BUG=chrome-os-partner:46656
BRANCH=none
TEST=make buildall -j;
Enable EC SW sync and normal mode in coreboot,
Kernel should bootup successfully.

Change-Id: I45d4aa0f0d4280e68282ea11ccfda05201f88aae
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/307220
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-10-28 11:45:08 -07:00
Ryan Zhang
b86e256fb7 Lars: enable USB-A port power control
Lars: enable USB-A port power control

dumb mode is used since lars ec only have control over
the two usb-a ports' power enable/disable functionality.

BUG=none
BRANCH=lars
TEST=Run "make -j BOARD=lars", "make -j BOARD=lars_pd" and
 "make buildall -j" to build code and ec.bin can be generated.

Change-Id: I0231b36e3875b56bc822dbae1de37da2182e5736
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/309005
Commit-Ready: 志偉 黃 <David.Huang@quantatw.com>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-10-28 00:23:51 -07:00
Gwendal Grignou
21c46e7b13 motion: Remove duplicate shutdown code
Call shutdown() entry point at init() and remove duplicate code.
shutdown would init the sensor so they would be ready if needed.
Set S5 flag to include G3 (hard off) state, not only S5 (soft off).

BUG=chrome-os-partner:45722
BRANCH=smaug
TEST=When doing a RO->RW transition while AP is in G3, check the sensors
are initialized properly. This issue was found while testng the magic
sequence code.

Change-Id: I647f83580240bf5ba0c340fca3184220abe4c12e
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308561
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-28 00:23:48 -07:00
Gwendal Grignou
7253e57b3c driver: si114x: Fail init of proximity sensor if light sensor fails.
If init of the light sensor fails (for instance, the chip is not present
on the i2c bus), we need to fail the init of the proximity sensor.
Otherwise, the EC will report an unexistent sensor to the AP.

BRANCH=smaug
BUG=chrome-os-partner:46638
TEST=check the proximity sensor is not reported if sensor is disconnected from the
main board.

Change-Id: Ie6b1d74eaac4d6c38d52641626966b5d3ce63bd3
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308560
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-28 00:23:48 -07:00
Gwendal Grignou
8238dfa27d driver: bmi160: Add magic sequence to unlock
If init() is interrupted while we are setting the link to the compass,
the BMI160 may be in paging mode and will only answer to registers 7Eh
and 7Fh. Other registers access will return 00h.
To get out of this state, run the sequence to move back from the paging
mode in the error handler. If successful, a subsequent call to init()
will work.

BRANCH=smaug
BUG=chrome-os-partner:45722
TEST=use a special firmware that exists in the middle of the compass
init sequence. Check that the FIFO and all other registers return 0.
Issue 'accelinit 1' (to reset the Gyro): the command succeeds and the
accelerometer is operational again (double tap works).
Check the sequence can be issued after sysjump to RW/RO.

Change-Id: I3455a8cbdcf1c88699ae90f7c09e4438e1268d47
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308184
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-27 16:29:33 -07:00
Bernie Thompson
df038776b4 Remove cyan ec configuration
We no longer need to build cyan on ToT, so we can remove it.

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

Change-Id: Ifaad4570cb8e1c427e0c341073e4bacd29462974
Signed-off-by: Bernie Thompson <bhthompson@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/309000
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-27 13:19:52 -07:00
Shawn Nematbakhsh
2bd7dce32e charger: Add LIMIT_POWER charger param for low bat + weak charger
Add support for two new configs to specify critical energy battery
percentage and critical external charger power. When we are under both
thresholds, set the LIMIT_POWER charger parameter to inform the AP that it
should conserve power to avoid brownout, and consider jumping to EC RW
to negotiate PD.

In addition, modify the existing CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
to allow power-up regardless of power level if a 15W+ charger is
attached, since there is a reasonable chance it may speak PD and provide
sufficient power to boot the AP.

BUG=chromium:537269
TEST=Manual on Glados. Set CHG_MW thresh to 20000, BAT_PCT to 50. Verify
that LIMIT_POWER charger param is set until Zinger negotiates to 20V. Also
veify that system can boot with Donette.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic963c82fea4ad10e8a5d7e476c5ce3e5ae525dad
Reviewed-on: https://chromium-review.googlesource.com/306774
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-27 13:19:51 -07:00
Mary Ruthven
cb4a76e802 i2c: get battery information from charge state
ARM systems currently use SBS kernel driver which talks to the battery
through I2C passthu in the EC. Instead when asking for battery
information try getting it from the charge state machine first, and
then try the battery if charge state does not have the information.
This reduces latency by cutting out the battery response time.

BUG=chromium:484841
BRANCH=none
TEST=check that power_supply_info works properly on Jerry

Change-Id: If4da15ccabe412adc31fc94b189089ebb3e9265c
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307905
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-27 11:52:34 -07:00
Duncan Laurie
95e8bc2e0b chell: Set SPI flash chip to W25X40
Chell was still set to use W25Q64 instead of the W25X40 that is
actually on the board.

BUG=chrome-os-partner:46289
BRANCH=none
TEST=successfully run "flash_ec --board=chell"

Change-Id: If21e5f9a00600c97d81d2bb2a8700801ae5c2fd6
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308727
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-27 01:22:57 -07:00
Duncan Laurie
1361a78311 flash_ec: Add support for flashing chell PD
Add chell_pd to the STM32 list and the USBPD override list.

BUG=chrome-os-partner:46289
BRANCH=none
TEST=successfully run "flash_ec --board=chell_pd"

Change-Id: Ic4ddbe51a0586c563211fd76f20a85428e565546
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308726
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-27 01:22:57 -07:00
Dino Li
2fa6f3e590 it8380dev: gpio - remove comment about E4
E4 pin has two output options, INTC WKO25 and WKO114. We can use
any of them. So we enable E4's output to INTC WKO114.

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

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

Change-Id: I1c24d3f5aa7c5ca0fc90fcafc3f0a5edc237ce53
Reviewed-on: https://chromium-review.googlesource.com/307215
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-10-25 09:17:44 -07:00
Dino Li
ad1d33778f it8380dev: Increase DLM size
1. Total DLM size is 48KB.

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

BRANCH=none
BUG=none
TEST=DLM 0x84000 ~ 0x8BFFF read/write OK.

Change-Id: I2340aeefca60ad59062254ddd363c703c30cfd24
Reviewed-on: https://chromium-review.googlesource.com/307006
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-10-25 07:40:31 -07:00
Dino Li
19c1e9905d it8380dev: fix clock module
1. Implement deep doze mode for CONFIG_LOW_POWER_IDLE.

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

BRANCH=none
BUG=none
TEST=test the following items in deep doze mode.
     1. WUI interrupts wake-up OK. (For example, power button, lid,
        uart rx, keyboard ksi, and so on)
     2. LPC access interrupt wake-up OK.
     3. Enabled Hook debug, no warning message received (48hrs).

Change-Id: I8702a112632cb6c1c0fa75d682badf272130a7d4
Reviewed-on: https://chromium-review.googlesource.com/307060
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-10-25 04:34:36 -07:00
Alec Berg
9acd84460e glados: oak: reboot EC if PD MCU crashes
If PD MCU crashes, it will go back to RO code and stay there
until the next AP boot. So, if EC detects PD has crashed, then
EC should panic reboot with debug message that it detected
a PD crash.

PD MCU crash is detected by EC by seeing the PD MCU transition
from RW to RO, without it setting the flag that it got there
from a sysjump.

This CL also makes minor changes to oak_pd and glados_pd board.c
files to make them identical, other than the few minor real
differences between them.

BUG=none
BRANCH=none
TEST=tested on glados using pdcmd console command on EC to test
sysjumps and reboots:

sysjump to RW: pdcmd 0xd2 0 2 0
sysjump to RO: pdcmd 0xd2 0 1 0
cold reboot:   pdcmd 0xd2 0 4 0

Verified that PD can jump back and forth between RO and RW
without EC panicing. Verified that if PD MCU is in RW and
reboots, then the EC will panic and print 'PD crash'. Verify
if PD MCU reboots while in RO, without ever going to RW first,
then EC does not panic.

Change-Id: Id3191f4005e70a6c61a9322bf535b4374e85eb9a
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308586
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-10-23 22:49:29 -07:00
Alec Berg
71e12124e5 pd: remove unnecessary delay in phy init
Remove unnecessary 250ms delay in USB PD phy init

BUG=none
BRANCH=none
TEST=test on glados and samus. verify we negotiate with
zinger after EC or PD reboots.

Change-Id: I561e41fb0b8bbfeacdd7d6a9ceaf67a1606f65e5
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308535
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-10-23 19:29:27 -07:00
Vincent Palatin
3f567a9869 ryu: fix lid close detection
Now we are using LID_OPEN *and* BASE_PRES_L for lid close detection,
we need an interrupt on both to debounce arbitrarily long delay between
the transitions of the 2 GPIOs.

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

BRANCH=smaug
BUG=chrome-os-partner:46189
TEST=manual: activate manually LID_OPEN and BASE_PRES_L hall sensors in
very slow sequences and see the proper "lid close"/"lid open" traces,
whatever sequence I do.

Reviewed-on: https://chromium-review.googlesource.com/308513
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 659d826b4efcd391eced3d4dda319d502d028457)

Change-Id: I2ee91370205a4bfc0f4b4d224cb55207f745af25
Reviewed-on: https://chromium-review.googlesource.com/308515
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-23 19:29:26 -07:00
Vincent Palatin
b3911e8eef ryu: do not pull EN_PP3300
Modify the former workaround for board revisions missing an external
pull-up to 1.8V on EN_PP3300 :
the 100kOhm resistor between GPE13 and EN_PP3300 is still stuffed even
on boards which don't need the workaround, so tri-state the pin to avoid
driving the net.

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

BRANCH=smaug
BUG=chrome-os-partner:46799
TEST=probed EN_3300 voltage level.

Change-Id: I48f2b2fa9a716cdbe07fbc8a006ba4d3fcfaa63d
Reviewed-on: https://chromium-review.googlesource.com/307868
Reviewed-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit 53e49d6d6541183349bb7267fa5ec2b1db250d99)
Reviewed-on: https://chromium-review.googlesource.com/308514
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-10-23 18:03:13 -07:00
Gwendal Grignou
81d269dc00 common: lightbar: Add histeresis to prevent flickering
When ALS is enabled, if light is around one threshold (say 40 lux),
the lightbar will flicker between readings.
Add a histeresis to prevent the flickering.
The current setting is:

setting    ^
(dim)    2 | ------+---->---+
         1 |       +----<---+--->---+
(bright) 0 |                +---<---+---------
           +-------+--------+-------+--------> lux
               20       40      60

BRANCH=smaug
BUG=chrome-os-partner:44400
TEST=check in a dark room (30~40 lux) there is no flickering.
Add unit test.

Change-Id: I4018e2c2ed764abf9c9ed28e2d50a3e94a7d5f75
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308205
2015-10-23 18:03:12 -07:00
Gwendal Grignou
3fc374b7fd board: ryu: Compass and Gyro stays up in S5
Gyro and compass is suspended but still powered on.
Therefore they don't need to be reinitialized.
Note that their init() does not do much, most is done when
initializing the accelerometer part of the BMI160.

BRANCH=smaug
BUG=none
TEST=Check that Gyro: MS Done Init... message are not present
when powering up the system in a loop.

Change-Id: If92727830c32407df49213db46b1d5f1cb0369af
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308204
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-23 16:32:45 -07:00
Aseda Aboagye
daca039e2a mec1322: Remove CONFIG_PORT80_TASK_EN from boards.
There is no port 80 task for the MEC1322 anymore,  therefore no board
should be using this define.  I forgot to remove these at the time.

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

CQ-DEPEND=CL:308450

Change-Id: Ie44474470edb40bc94ec95be9663b509e0ba299a
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/308451
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-23 14:46:03 -07:00
Alec Berg
94ed0b2cfa lars: remove port80 task
The port80 task has been removed recently and replaced with a timer
interrupt (CL:305591). Fix lars to match the new scheme.

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

Change-Id: I602ef1306b9889732e77cbb32753ca0286123e2b
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308450
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-10-23 13:19:01 -07:00
Alec Berg
776bedc3f8 glados: chell: add VCONN swap ability
Add VCONN swap ability and accept VCONN_SWAP requests as long
as we have the ability to provide VCONN.

BUG=none
BRANCH=none
TEST=test on glados. ask for vconn swap and make sure vconn swap
is successful.

Change-Id: I7340e6253dcde4cdbe333a9622d7826e7ccbe6b4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308238
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-10-23 13:18:58 -07:00
Alec Berg
964534b91e pd: change battery and variable sink cap for voltage inaccuracy
Change battery and variable sink capabilities for all boards
to account for +/-5% voltage inaccuracy.

BUG=none
BRANCH=none
TEST=test glados with third party variable power supply and make
sure it see's our sink capabilities as 4.75V-21V.

Change-Id: I2481ccbe6c47bfed1a6b8b237329e70bd0f8e4ac
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308237
Reviewed-by: Todd Broch <tbroch@chromium.org>
2015-10-23 13:18:58 -07:00
Alec Berg
847978564a pd: send soft reset on boot if VBUS is present
On boot, if VBUS is present, then when PD protocol gets to
SNK_DISCOVERY state, if it times out waiting for source cap,
then send attempt to send a soft reset first instead of
directly sending a hard reset. This allows us to not lose
VBUS in the case that we were in a stable contract as a sink
before this boot (for example a sysjump or EC reboot).

BUG=chrome-os-partner:44085, chrome-os-partner:44952
BRANCH=none
TEST=test on glados and samus. test by sysjumping between
RO and RW with zinger plugged in and no battery, and verify
that we don't lose power. also test rebooting with a battery
and verify we don't lose power. also tested with a third
party PD charger.

Change-Id: Ib7ce46d8b9843db66805ba3237d8919d611324e0
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308201
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-10-23 10:10:56 -07:00
YH Huang
accc98d7c3 oak: revise suspend gpio setting for rev4
Revise gpio setting of suspend signal for rev4 hardware.

BUG=chrome-os-partner:46579
TEST=run "make BOARD=oak -j" and enable SW sync in bootloader
  EC SW sync works fine.

Change-Id: I8864dfaa8ae7ef9a47d0a08499d88eb8999160c5
Signed-off-by: YH Huang <yh.huang@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/308351
Reviewed-by: Rong Chang <rongchang@chromium.org>
2015-10-23 08:47:25 -07:00
Rong Chang
c5f9f00dfb oak: stm32f0: implement i2c_set_timeout
EC communicates with PD through I2C host command. This CL adds
i2c_set_timeout implementation.

BRANCH=none
BUG=chrome-os-partner:41608
TEST=manual
  build and load on oak, check PD host command.

Change-Id: I05259b40223b435eaf2a0c38954573e97ea4b32b
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/306909
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-23 05:12:09 -07:00
Bill Richardson
d8b81cdc0f Cr50: Support USB on 15MHz FPGA image
The latest Cr50 FPGA release runs at 15MHz, but supports USB
operations. This CL includes changes to make that work.
Specifically:

* Enable the security features and select the correct PHY
* Adjust the turnaround time for the slower clock speed
* Handle the SET ADDRESS command specially for this SoC
* Remove all printfs from interrupt handlers (but add #ifdef code
  to print debug messages later if desired).

BUG=chrome-os-partner:34893
BRANCH=none
TEST=make buildall, manual test of Cr50 USB:

1. Plug into a USB jack on a Linux host.
2. In src/platform/ec/extra/usb_console, run

  make
  ./usb_console -p 5014 -e 1

3. Type something, hit return
4. See whatever you typed come back with swapped case
5. ^D to quit

Change-Id: I848e96d19df056a453d30d4b5537481046fe852d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308062
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-10-22 22:36:03 -07:00
Ryan Zhang
061abcea96 Lars: Init board
Preparing for new board, Lars
Copy kunimitsu setting to init board.

BUG=none
BRANCH=lars
TEST=Run "make -j BOARD=lars", "make -j BOARD=lars_pd" and
 "make buildall -j" to build code and ec.bin can be generated.

Change-Id: Ic0ab3e57679fc7ea98a7b73527ce2276e706db1d
Signed-off-by: Ryan Zhang <Ryan.Zhang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/305128
Commit-Ready: 志偉 黃 <David.Huang@quantatw.com>
Tested-by: 志偉 黃 <David.Huang@quantatw.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-22 19:16:16 -07:00
Tom Wai-Hong Tam
4247678ed6 flash_ec: Use the chip name to check stm32 board
FAFT and the lab infra calls the flash_ec by giving the chip name as
an argument, instead of the board name. The script should use the
chip name to check if it is a stm32 board.

BUG=chromium:546063
BRANCH=none
TEST=Call the script: flash_ec --chip stm32 --image /tmp/ec.bin

Change-Id: I8e9a029fb6e0aca5ea0f65876f48f6f465664c1c
Signed-off-by: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307822
Commit-Ready: Wai-Hong Tam <waihong@chromium.org>
Tested-by: Wai-Hong Tam <waihong@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-22 17:40:33 -07:00
Alec Berg
7e81bebb48 tcpc: re-initialize tcpc if it reboots while tcpm is running
On TCPC startup, set an alert to notify TCPM that we have been
reset. When TCPM gets this notification, it should re-send
initial TCPC parameters. If we were in a stable contract as
a sink, make sure we don't reset connection. If not, then
reset PD protocol state machine to the default state.

This fixes a bug where if the TCPC reboots while the TCPM is
still running, then the TCPC would not get re-initialized and
therefore no PD communication would not work. This also fixes
it such that if we are in a stable contract as a sink and the
TCPC reboots, then we don't lose power.

BUG=chrome-os-partner:46676
BRANCH=none
TEST=tested on glados. reboot PD MCU with and without a charger
plugged in and verify that PD communication works after the
reboot. verify that with a charger, we don't lose power.
also tested with a hoho plugged in during reboot.

Change-Id: I84fec4577b0daf5891bd8461d3f3d925014a5ecf
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307187
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-22 17:40:31 -07:00
Bill Richardson
0f4e6d217d Cr50: Support FPGA image m3.dist_20151021_054409
This enables support for a new FPGA image with tighter timing
constraints. Some USB functions perform better using this model.

There are also changes to the signing code.

BUG=chrome-os-partner:34893
BRANCH=none
TEST=make buildall

Change-Id: I608c2424d76b4ea566bf56fa0fed3810436216bb
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/308063
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2015-10-22 00:17:37 -07:00
Duncan Laurie
5ef8956169 ps8740: Make revision check a minimum instead of explicit value
With a new PS8740 chip revision 0xb the explicit check for 0xa
is failing.  Change this to allow revisions >= 0xa to pass.

BUG=chrome-os-partner:46728
BRANCH=none
TEST=boot on chell and confirm lack of mux init errors

Change-Id: I0847bb9953920569922183ed4c83da2370ef40e4
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307932
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-21 17:31:24 -07:00
Duncan Laurie
695026da7a flash_ec: Add chell and lars boards
Add chell and lars to the mec1322 board list.

BUG=chrome-os-partner:46289
BRANCH=none
TEST=flash_ec --board=chell

Change-Id: Ia89e4914086d01150fab8abe2877a7583cf0af44
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307931
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-21 17:31:24 -07:00
Vijay Hiremath
07c0a192c3 Kunimitsu: Add support to enable L3GD20H gyrometer
BUG=none
TEST=Enabled the config to test the L3GD20H sensor.
     Able to read the gyro data from "accelinfo" console command.
     Rotated the sensor in X,Y,Z axis, respective axis values change.
BRANCH=none

Change-Id: Ib1b06bffaf4f5f33d87b9062a1eb22658d3c9987
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/307234
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-10-21 16:01:45 -07:00
Kevin K Wong
47ff569b68 kunimitsu: enable USB-A port power control
dumb mode is used since kunimitsu ec only have control over
the two usb-a ports' power enable/disable functionality.

BUG=none
BRANCH=none
TEST=verified with "ectool usbchargemode <port 0-based> <0=dis, 4=en>"
     and check with DMM to see if +5V is toggled when enabled/disabled.

Change-Id: I122c99b4067a873313b892715078188e800b979a
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/307476
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2015-10-21 12:53:05 -07:00
Gwendal Grignou
7340e804a1 common: Add lightbar dimming based on outside light.
Unless the lid is closed, the ALS is used for lightbar dimming.
Change the google colors depending on the light sensor result.

BUG=chrome-os-partner:44400
BRANCH=smaug
TEST=Check all 3 levels of brightness of the lightbar.
Check value using "adb shell ectool lightbar"
Check double tap color are not affected and is using full brightness.

Change-Id: I7b5e2890c3557f1dd3ae719f5f82ffb5fe7b24fb
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301216
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-10-20 22:09:05 -07:00