Commit Graph

8284 Commits

Author SHA1 Message Date
Hung-Te Lin
9de2d245cf gsctool: Add option '--any' to auto-detect -s/-t availability.
For partners and developers, it's usually better to have a single simple
instruction to invoke commands. Currently gsctool needs either -s (if
/dev/tpm is not locked) or -t (if trunksd is running) and partners have
to either try both commands (-s or -t) or read the error messages and
try to figure out which option to use.

For example, see the extra logic in CL:831787.

Instead of putting the check everywhere in scripting, it seems easier
and more convenient to have a simple switch - "--any (-a)" that
automatically selects between -s and -t.

BUG=b:70184153
TEST=gsctool -f -a; stop trunksd; gsctool -f -a

Change-Id: Ie1590b0b8fef882178465ceee64a7150eda6b0dd
Reviewed-on: https://chromium-review.googlesource.com/851612
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-05 03:14:37 -08:00
Nicolas Boichat
cfc69f6fb8 ec_ec_comm_master: Functions for EC-EC communication master
This adds functions required for the master in EC-EC communication,
requesting base battery static and dynamic information, and charger
control.

BRANCH=none
BUG=b:65526215
TEST=Flash lux and wand, EC-EC communication works.

Change-Id: I7a46ee3f5848d22c2c9bea7870cbd7e74141cf3d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/839201
2018-01-05 00:51:29 -08:00
Nicolas Boichat
3fecdbdcf9 chell: Enable CONFIG_LTO
Saves about 4K of flash space. Note that LTO has been enabled
on glados for a long time, so hopefully this is safe.

build/chell/RO/ec.RO.flat shrank by 4096 bytes: (106200 to 102104)
build/chell/RW/ec.RW.flat shrank by 4264 bytes: (105988 to 101724)

BRANCH=none
BUG=chromium:798914
TEST=Flash both chell and chell_pd, system boots to OS, keyboard
     works, charging works.

Change-Id: Id97f2e73959ced16d6579f6c05f3ce4cd21f4062
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848594
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-04 21:52:05 -08:00
Nicolas Boichat
f14879eae1 charger/isl923x: Protect CONTROL1 read-modify-write with a mutex
CONTROL1 bits can be modified from multiple tasks:
 - charger_enable_otg_power (charger or pd task)
 - charger_discharge_on_ac (host command or console)
 - charger_enable/disable_psys (chipset task)
 - print_amon_bmon (console)

Since we use I2C read, modify, then I2C write access pattern,
there is a small chance of races between these accesses:
let's protect them with a mutex.

Also, the current code sometimes uses charger_get_option/set_option
instead of manipulating CONTROL0 directly: fix those to regain
a bit of the extra code size caused by the mutex.

BRANCH=none
BUG=b:67029560
TEST=Flash lux, battery charges, amon works fine.
TEST=Flash elm, battery charges.

Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>

Change-Id: If375d9922db53dd582582bfa44d6218fe0b416ec
Reviewed-on: https://chromium-review.googlesource.com/848486
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-04 21:52:05 -08:00
Nicolas Boichat
51b6222520 npcx/uart: Pull up communication line during transaction
Boards needs to define GPIO_EC_COMM_PU, which needs to be driven
high during EC-EC transaction. This makes sure that the line does
not go low, even when the base goes away during the transaction.

BRANCH=none
BUG=b:68954760
TEST=EC-EC communication works with this change.
TEST=With signal analyzer, check that UART line is always kept
     high while transaction is in progress.

Change-Id: Iad7b26a9a93b674aa4fff0bc3a72a13e6782515d
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/845544
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-04 21:52:01 -08:00
Nicolas Boichat
6bbb5adab1 charge_state_v2: Add charge_set_output_current_limit function
This function sets up and enables "OTG" mode on the charger chip
(i.e. use the charger to provide power from the battery).

It also records the output current in curr.output_current, to
make sure that the charger loop is aware that current is provided
externally.

We also add a CONFIG_CHARGER_OTG to remove these functions on
boards that do not require it.

BRANCH=none
BUG=b:65697962
TEST=On wand, when discharging, battery status is updated every
     5 seconds (and not every 60 seconds).

Change-Id: Ibf93933436f3eb24552a8e1eb9d97522fca2ce79
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/842743
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-04 21:52:01 -08:00
Nicolas Boichat
41af1bf27c wand: Make sure battery is cut-off when critical
Modify chipset_in_state to always say that the chipset is off,
when we do not actually have a chipset (like on hammer): that
makes sure the battery can actually be cut off (else the EC
would just wait forever for the chipset to turn off).

Also, wake the charger state on "AC" change, that is, when
charging_allowed changes state, to make sure the charging loop
is executed after lux tries to charge it (else the charging loop
would wait until timeout expires, and wand would ask the battery
to be cut off again).

BRANCH=none
BUG=b:65697962
TEST=Deplete wand battery, reboot without providing external power
     to it.
     After 30 seconds, battery is cut off:
[1.354683 Low battery: 2%, 6866mV]
[1.354888 charge warn shutdown due to critical battery]
[31.381410 Low battery: 2%, 6865mV]
[31.381643 charge force battery cut-off due to critical level]
TEST=Upon providing power to wand, charging loop is executed
     regularly, and battery is charging.

Change-Id: I7154b25bd852b8422a0ae3b506675a297a948132
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/842742
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-04 21:52:00 -08:00
Nicolas Boichat
113602c06e ec_commands: battery_dynamic_info: Rename current to actual_current
current is actually a reserved keyword in the Linux kernel,
replace it by actual_current. And voltage by actual_voltage for
consistency.

BRANCH=none
BUG=b:65697962
BUG=b:65697620
TEST=make buildall -j

Change-Id: I8b8115174d15a1cc4b1189a54104bfec559ed72c
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848460
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2018-01-04 21:52:00 -08:00
Daisuke Nojiri
069182f5e4 USB/PD: Request discover identity on boot
This patch makes the TCPM request discover identity on boot instead of
resume.

BUG=chromium:644663,b:70165261
BRANCH=none
TEST=Verified display works in the following cases:
1. On Fizz, plug in Dell type-c HDMI adapter in S0, shutdown, boot.
2. On Fizz, plug in Dell type-c HDMI adapter in S5, boot.
3. On Fizz, plug in type-c monitor in S0, suspend, resume.
4. On Fizz, plug in type-c monitor in S5, boot.
5. On elm, S5. Plug adapter with power+HDMI, boot.

Change-Id: Ib068c60bc51ebddc461378028a48c64662bc5b81
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/847970
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-04 19:17:57 -08:00
Aseda Aboagye
eb15d23f3e meowth: zoombini: Add support for OPT3001.
These boards are using the OPT3001 ALS.  Enable the drivers for them as
well as the motionsense stack.

BUG=b:70290036, b:69140267
BRANCH=None
TEST=Flash meowth and zoombini; verify that they still boot okay.

Change-Id: Iddbf0af5cc01973999703de4a75ad461bc6a025f
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/833168
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2018-01-04 19:17:57 -08:00
Marius Schilder
1c1af98e40 g: fix flaky timeout check for spi transfer.
Typically this routine runs on low priority hook task.
A pre-emption by a higher priority task might be mistaken for timeout.
Double check the transfer done status after the timeout time has passed.

Also clear the TXDONE status before starting a fresh transaction to make sure
we wait for the current transaction to complete; an errand TXDONE status
at start of the transaction will pre-empt waiting for the current transaction
and return stale data.

BRANCH=none
TEST=mn50 stress test fails within minutes vs. now stable.
	Main test component is higher priority console task
	that does intermittent compute during usb-spi transfers.
Change-Id: Ide4390e42d3957bc45eea8160617a52dd31ed866
Reviewed-on: https://chromium-review.googlesource.com/849662
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-04 14:35:21 -08:00
Marius Schilder
c69f4dfad5 g: allow for other values of DCRYPTO_CALL_TIMEOUT_US
Some dependent projects use larger RSA keys, which require
larger timeout values.
Let them pick their timeouts in their board.h

BRANCH=none
TEST=make buildall
Change-Id: I7cf018938f76daccd79e8bed49d48ffb5fbebe21
Reviewed-on: https://chromium-review.googlesource.com/849757
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-04 12:31:29 -08:00
Marius Schilder
5c8b6391e4 g: allow for other values of RSA_MAX_BYTES
Some dependent projects need larger than 2K RSA computation.
Allow their board.h to pre-define RSA_MAX_BYTES to suit their needs.

BRANCH=none
TEST=make buildall
Change-Id: Ia00def60ea359e150285e7851a462531f40f5b18
Reviewed-on: https://chromium-review.googlesource.com/849756
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-01-04 12:31:29 -08:00
Nicolas Boichat
f163121039 poppy: Disable PULL_UP on BOARD_VERSION4
All shipping products will have board ID >= 8, so the board ID
strap 3 will never be left floating. In particular, board ID 8-15
will have an external pull-down on that pin, so leaving the
internal pull-up enabled is detrimental to power.

BUG=b:64503543
BRANCH=none
TEST=Boot poppy rev6.

Change-Id: I810b2a68ab8d35e9cea6fa18f1eeafa10e7039ea
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/845240
Tested-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Reviewed-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
2018-01-03 22:43:03 -08:00
Nicolas Boichat
eb781cc377 driver/bc12/pi3usb9281: Make a few functions static
Old oak boards that still use these functions have long been
deprecated, let's make the unneeded functions static.

BRANCH=none
BUG=b:35573263
TEST=make buildall -j => makes newsizes: up to 64 bytes saved on
     a few boards.

Change-Id: I8f2503ce324e34b87b3bbfa3c509079357880c9e
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848574
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-03 22:43:02 -08:00
CHLin
e358a5521d util/openocd: modify the openocd srcipts for npcx UUT
In the CL:826909, the name and the restore address of ec_spiflash lfw
are modified becaue of introducing the UUT. This CL modified the openocd
scripts to follow the changes of the lfw.

BRANCH=none
BUG=none
TEST=Apply CL:826906 and "BOARD=npcx7_evb make";
Run cmd "./util/flash_ec --board=npcx7_evb" to flash ec image;
Make sure the ec firmware can be updated with the new npcx_minotor lfw
+ this CL via JTAG on Servo v2.

Change-Id: If622f83e2d2132d66b390bcee30c77e7a9d5f7bd
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/828341
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-03 22:42:59 -08:00
CHLin
5b1c4868d7 npcx: modify the npcxspiflash little firmware to support UUT
The original ec_npcxspiflash lfw is used by the openocd to program SPI
flash via Servo JTAG. In order to support UUT mode to program SPI flash,
this CL modified the lfw with the following changes:
1. Rename the lfw ec_npcxflash to npcx_monitor to unify the naming.
2. The npcx_monitor will read the first 4 bytes from the area of monitor
header. If the monitor identifies the first 4 bytes is a UUT tag, it
will read parameters(SPI_OFFSET/IMAGE_SIZE) from the relative offset of
monitor header. Otherwise, it will read parameter from the general
register r0/r1 which will be restored by openocd script in advance.
3. Add monitor_hdr.c to generate the monitor header binary files
(monitor_hdr_ro.bin/monitor_hdr_rw.bin)) automatically after compiled.

The memory layout to restore the reuqired binaries are listed below:
ec firmware(RO/RW) - the start address of Code RAM area.
monitor header - 0x200C3000
npcx_monitor - 0x200C3020

BRANCH=none
BUG=none
TEST=No build errors for "make buildall".
TEST=Follow instructions in CL:826763; make sure the ec firmware is
updated and ec can boot up.
CQ-DEPEND=CL:828341

Change-Id: I5de997a4dee5449d578972e2f929c6e08c5dff67
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/826909
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-03 22:42:59 -08:00
Vadim Bendebury
5789d69257 g: simulate open drain GPIO behavior
Some upcoming designs based on the g chip require GPIOs connected to
open drain circuits.

Even though the chip explicitly provides only two open drain GPIOs,
the desired behavior of the rest of the pins when configured as 'open
drain' could be simulated by software if when 'high' is required the
output is disabled instead of driving the pin value.

To make sure there is no fallout from RO driving the pins, also add an
explicit 'disable output' initialization in case a GPIO is configured
for open drain and the initial output value is 'high'.

BRANCH=cr50
BUG=none
TEST=verified that Cr50 booted successfully, also confirmed that on
     the test board that GPIOs defined as Open Drain allow we set
     output to 1 only if pulled up.

Change-Id: Id2daa19b992bab7fb01148b6fa7b57fd0728b33d
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/848152
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-03 16:54:35 -08:00
Alec Thilenius
27f92a378a Add SB-TSI temp sensor driver
This adds the driver for the SB-TSI temp sensor.

This is a sensor on the AMD AP SOC (Stoney Ridege FT2) that acts like an
8-pin temp sensor with an I2C interface.

BUG=b:69379715
BRANCH=None
TEST=Build

Change-Id: Iaafe6c7beb3e02e4e341617e8f117c03c0a882a2
Signed-off-by: Alec Thilenius <athilenius@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/833346
Commit-Ready: Alec Thilenius <athilenius@google.com>
Tested-by: Alec Thilenius <athilenius@google.com>
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-03 16:54:31 -08:00
Alec Thilenius
bb11331227 kahlee: Switch thermal I2C over to 1.8V
The SB-TSI temp sensor on the FT4 requires the 1.8V for the I2C bus.

BUG=b:69379715
BRANCH=None
TEST=Build, deploy, over servo: `temps`

Change-Id: I9929d7f5ac4a029f7314bac6eae50ee2c54b8ea4
Reviewed-on: https://chromium-review.googlesource.com/849275
Commit-Ready: Alec Thilenius <athilenius@google.com>
Tested-by: Alec Thilenius <athilenius@google.com>
Reviewed-by: Edward Hill <ecgh@chromium.org>
2018-01-03 16:54:31 -08:00
Nicolas Boichat
3ce0b8b924 wand: Increase PWM frequency to 50kHz
RT4531 wants PWM input frequency between 20 and 100 kHz.

BRANCH=none
BUG=b:66575472
TEST=Flash wand, pwm 0 50, check with oscilloscope that frequency
     is around 50kHz, and that duty cycle is 50%.

Change-Id: I6a37ef435a51cf730805ef57a0e3ebd05f9820a3
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/845541
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2018-01-02 21:32:23 -08:00
CHLin
749632d30f util/flash_ec: npcx7 supports programming SPI flash via UART
This CL adds scripts to support updating ec image to the SPI flash by
UUT(UART Update Tool) for npcx ec. A new array BOARDS_NPCX_UUT is
introduced to include the board name which will use the UUT mechanism.

The detail of test setup/procedure is listed below:
1. Connect the following singals between npcx7 evb and Servo board v2.
   NPCX7 EVB            Servo V2
   ---------------------------------------
   GPIO64/CR_SIN  <-->  UART1_SERVO_DUT_TX
   GPIO65/CR_SOUT <-->  UART1_DUT_SERVO_TX
   VDD_3.3V       <-->  PPDUT_UART1_VREF
2. Manually pull the UUT mode strap pin(GPIO65/CR_SOUT) to ground with a
10 KOhm resistor.
3. Assert a EC VCC1_RST reset or issue a Power-Up reset.
4. Remove the pull-down in step 2.
5. Move npcx7_evb from array BOARDS_NPCX_7M6X_JTAG to BOARDS_NPCX_UUT in
flash_ec.
6. ./util/flash_ec --board=npcx7_evb.

BRANCH=none
BUG=none
TEST=Follow the steps above. Dump the SPI flash content to a file via
JTAG. Compare the file and ec image. Make sure their content is all
the same. Check the ec can reboot after programming.
Run "sysjump rw"; make sure RW image works well.

Change-Id: Iada5acb53179bdb78459c4fea7488fd2691575b6
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/826763
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2018-01-02 21:32:18 -08:00
Scott Worley
f4700dac61 ec_chip_mchp: Add I2C controller
Add Microchip MEC17xx family I2C controller.
Controller supports master/slave but is used
as master only.

BRANCH=none
BUG=
TEST=Review only.

Change-Id: I66c130943de6574a5f4acff56b88fca69bbb2663
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/840646
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-02 15:48:23 -08:00
Scott Worley
a92647b9ce ec_chip_mchp: Add LPC and eSPI files.
Add Microchip MEC17xx family LPC and eSPI
support files. Fix fault when host sends
old style command packet.

BRANCH=none
BUG=
TEST=Review only.

Change-Id: I35c33be407e093b19c456b5a78c2c4e19a267b95
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/840647
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-02 15:48:21 -08:00
Daisuke Nojiri
f147f61f38 Nami: Update board directory
Made board.c, board.h, gpio.inc match the schematics. Sensors anren't
implemented.

BUG=b:70157960
BRANCH=none
TEST=Verify Nami boots to S0.

Change-Id: Id8c800c8b78c66d558e0f664b54d47c4c808f643
Reviewed-on: https://chromium-review.googlesource.com/831121
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2018-01-02 15:48:21 -08:00
Scott Worley
d813935b82 espi: Add API to test if signal is eSPI virtual wire
Add espi_signal_is_vw in new file common/espi.c for
testing if a signal is an eSPI virtual wire. API used
in power common and intel_x86.
Fix CONFIG_BRINGUP support for eSPI (off by default).
Add espi_vw_get_wire_name returning a pointer to
constant string. Chip modules do not need to maintain
names of eSPI signals.

BRANCH=none
BUG=
TEST=Build poppy and other eSPI enabled boards. Test
power state machine.

Change-Id: I13319e79d208c69092a02ec3ac655477d3043d61
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/836818
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2018-01-02 15:48:20 -08:00
Alexandru M Stan
b74f6a576a motion_sense: Fix indentation in header
BUG=None, while looking at b/67743747
TEST=None

Change-Id: I8799c66e236c697c570bfb123531696483ef6db8
Signed-off-by: Alexandru M Stan <amstan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/807330
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2018-01-02 13:19:37 -08:00
Philip Chen
ef4c9f2cc1 scarlet: Implement custom charging profile
Because Scarlet doesn't use smart battery, in the current
implementation of charging algorithm, we simply provide constant
voltage/current to the battery.

However, the datasheets of Scarlet battery packs do state different
desired voltage/current in different temperature range.

So we should implement the custom charging profile for the battery.

BUG=b:65597565
BRANCH=none
TEST=override measured temperature to confirm zone changing is fine
on rev2

Change-Id: I188578fd46e28f1f05fbce2150af23aaae457cc5
Signed-off-by: Philip Chen <philipchen@google.com>
2017-12-28 19:21:31 -08:00
Scott Worley
9f5a155650 ec_chip_mchp: Add MCHP TFDP trace debug files
Add Microchip MEC17xx family trace fifo debug
(TFDP) files. TFDP is a MCHP specific two pin,
output only software message port.
Added TFDP module ID.

Change-Id: Ibe2399a8c3618b207a89552450d80b7901e85f23
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 19:21:31 -08:00
Scott Worley
c56df0d831 ec_chip_mchp: Add other hardware files
Add Micorchip MEC17xx family files for
hardware timers, keyboard scan, host
port 80h, UART, and watch dog timer.

BRANCH=none
BUG=
TEST=Review only.

Change-Id: Iac8a912af4d29521964f606637041b06fa7238ee
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:32 -08:00
Scott Worley
f8dc461712 ec_flash: Add W25Q128 SPI flash
Add W25Q128 flash device support.

BRANCH=none
BUG=
TEST=Modify a board build for W25Q128 and check
SPI code sets flash security bits correctly.

Change-Id: I6173f4cf751f3fbf68af75983f44d357a0b954f6
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:32 -08:00
Scott Worley
940dd625b9 ec_driver: Add ADT7481 and TMP411 I2C sensors
Added I2C sensors ADT7481 and TMP411 with config
items and build rules.

BRANCH=none
BUG=
TEST=Define CONFIG_TEMP_SENSOR_ADT7481 or _TMP411
and build board.

Change-Id: I4d1eb55ee56ad3f42787538bb839193e683d0a60
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:31 -08:00
Scott Worley
eb29ab7acd ec_chip_mchp: Add PWM and fan files
Add Microchip MEC17xx family PWM and fan
source files for review

BRANCH=none
BUG=
TEST=Review only.

Change-Id: I91439ab999a4662d690b58b0fbbb887f643b3673
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:31 -08:00
Scott Worley
0a6a7be572 ec_chip_mchp: Add SPI files
Add Microchip MEC17xx family SPI master
controllers and flash files. SPI implements
public interface wrapper for QMSPI and GPSPI.
MEC17xx family uses QMSPI for loading
EC firmware. GPSPI is for general use (sensor).

BRANCH=none
BUG=
TEST=Review only.

Change-Id: I23001e254dd437caa0917949f4dd2eb903f1adb1
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:30 -08:00
Divya Sasidharan
bc8fda9e0f glkrvp: Enable discharge on AC config
This CONFIG DISCHARGE_ON_AC enables discharging
battery even when AC is connected.

BUG=b:71364739
BRANCH=glkrvp
TEST=On glkrvp EC console, execute command
     "chgstate discharge on" and verify if battery
     is discharging with "battery" command.

Change-Id: I709c7b5ccfea9058961d387a1575db9aebe70707
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
2017-12-28 14:50:30 -08:00
Divya Sasidharan
d41766df11 glkrvp: Fix hibernate <sec> to allow wakeup from hibernation
Issue was found when EC would not wake up from hibernate after
specified time period.

The infinite while loop blocks further hibernate functions
that needs to be executed after the board specific
hibernate method.
Remove this while loop to complete hibernation logic.

Also in hibernate function we should not be cutting down power
to EC (SMC_SHUTDOWN) as this will limit supporting wake sources
feature. Removing it in this patch.

BRANCH=master
BUG=b:70690772
TEST=On glkrvp EC console, check if "hibernate 30" wakes up EC
     after 30 sec, with only battery, only AC, with AC+battery.

Change-Id: Iae735cc26eeef8e205771d2f3c6e5260918e093e
Signed-off-by: Divya Sasidharan <divya.s.sasidharan@intel.com>
2017-12-28 14:50:29 -08:00
Scott Worley
304bb8b09c ec_als: ALS now uses CPRINT macros
Modify ALS module to use CPRINT macros with
channel support.

BRANCH=none
BUG=
TEST=Build board(s) with ALS support such glados.
Test ALS CPRINT messages go out over EC UART and
can be masked off by channel mask UART command.

Change-Id: I65ffc889d63a778f3fb8995f508773842ba875ef
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 14:50:29 -08:00
Scott Worley
5b6ec95320 ec_gpio: Add GPIO power down support
Experimental and disabled by default feature for
powering down GPIO pins on those EC's supporting it.
Pins may be powered down by module ID or pin name.
Goal is to make use of common GPIO pin table.
If enabled, developer must implement power down
support in chip level. Developer re-powers module
pin(s) by calling the current gpio module enable
API in the wake path.

BRANCH=none
BUG=
TEST=Feature is disabled by default. Build all
boards with feature disabled.

Change-Id: Ifacd08e51def6424baf5c78c84b24f1d9f4bc4aa
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 12:35:08 -08:00
Scott Worley
4e9588ddcf ec_chip_mchp: Add MCHP chip folder
BRANCH=none
BUG=
TEST=Review only. Committing small pieces until
all code passes review.

Change-Id: I9d16f95314a7c97b11c4fe61602c6db2621e6024
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 12:35:07 -08:00
Scott Worley
c334f648bd ec_chip_mchp: Add ADC and DMA files
Add Microchip MEC17xx family ADC and DMA
source files for review.

BRANCH=none
BUG=
TEST=Review only.

Change-Id: Iccf19223ddd3f6774b90d5fca32079be9b0c4bcc
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 12:35:06 -08:00
Scott Worley
2f1f5a5551 ec_chip_mchp: Add LFW files
Add Microchip MEC17xx family little-firmware
(LFW) folder and files.

Change-Id: I9142266d41234574730fadccd5a2cc27fe3d8fd7
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 12:35:06 -08:00
Daisuke Nojiri
137a0e850a Nami: Derive board files from Nautilus
BUG=b:70157960
BRANCH=none
TEST=make buildall

Change-Id: Iecbca185a3575818892f66f988ad36b0b175f317
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
2017-12-27 15:32:03 -08:00
Shawn Nematbakhsh
1c87ad4153 charger: Use shorter poll timeouts when on-ac
If AC is present but we're not charging yet, it's very possible this
status is transient (eg. due to cut-off battery, brief spike in current
useage, etc), so don't use very long task timeout.

BUG=b:70554834
BRANCH=None
TEST=Verify soraka doesn't take over a minute to boot when exiting from
ship mode.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I9dbfd8cb7dfc54cb8017bb0c7d633c5d64a15025
2017-12-27 13:18:41 -08:00
Vincent Palatin
90d735c3c3 stm32: re-factor registers.h addresses
Move all the peripheral blocks base addresses in a common block rather
than spread among the register definitions.
This will help making a cleaner STM32H7 implementation whose base
addresses are all different from other families.

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

BRANCH=none
BUG=b:67081508
TEST=compare all the ec.bin generated by 'make buildall' and verify
they are bit-identical with and without the change.

Change-Id: I52cafd2f3c9145dbcd585166df3fc78e38573bb4
2017-12-25 17:17:26 -08:00
Vincent Palatin
b8313fa5ae eve_fp: enable %li printf format
libfpsensor is using it.

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

BRANCH=none
BUG=b:70320279
TEST=run on Eve FP MCU with external library and see its traces are
correctly printed.

Change-Id: Iea1bc04d7ea7931478d14d655a7e986a0839a51a
2017-12-25 17:17:25 -08:00
Vincent Palatin
5e93965e94 printf: add %li format for compatibility
For compatibility/convenience, implement the '%li' printf format
as a *32-bit* integer format, as it might be expected by non-EC code.

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

BRANCH=none
BUG=b:70320279
TEST=run on Eve EVT with unspecified external binary and see its traces
are correctly printed.

Change-Id: Iac20e823c74aac4f659176416eebd804c321d47c
2017-12-25 17:17:25 -08:00
Nicolas Boichat
809244140d nautilus/poppy: Drop comment about thermistor
NCP15WB is actually the correct thermistor, let's drop that
copy-pasted comment.

BRANCH=none
BUG=b:35585396
TEST=make buildall -j

Change-Id: I5577bb70e354a6f2ef6338894793b808fe4b0e9a
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
2017-12-24 07:17:56 -08:00
Nicolas Boichat
292b4e1bcf fizz/nami: Drop CONFIG_THERMISTOR_NCP15WB
Nothing in fizz/nami code uses that thermistor: the 2 places that
would use it (ec_adc.c and bd99992gw.c) are not compiled in on
fizz/nami.

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

Change-Id: Ib2af8ad066eb05cd9510669600feb26641433eed
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
2017-12-21 22:50:38 -08:00
Nicolas Boichat
7eacce9720 ec_ec_comm_slave: Define extpower_is_present
On dual-battery slave, we use the charging allowed signal from
master to indicate whether external power is present.

In most cases, this actually matches the external power status
of the master (slave battery charging when AC is connected, or
discharging when slave battery still has enough capacity), with
one exception: when we do master to slave battery charging (in
this case the "external" power is the master).

BRANCH=none
BUG=b:65697962
TEST=Deplete wand battery to 5%, see that lux still provides power
     to it but the battery does not charge.

Change-Id: I8bd9f52c386a0a9edfae3837ba33725b3101a008
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
2017-12-21 22:50:34 -08:00
Nicolas Boichat
6040852eb7 poppy: Do not print base detection value if base stays connected
Reduces amount of spam during EC-EC communication.

BRANCH=none
BUG=b:65697962
TEST=Flash lux and wand, less spam on console

Change-Id: Ie66a3d0f4711741bf3d605f13e7595373c5246f5
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/725124
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-21 20:33:02 -08:00