Commit Graph

1507 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
d2e77ddbc9 pd: Add config to disable PD communication in locked RO
The scheme to disable PD communication in locked RO needs to be
implemented on other platforms, so move it to common code, behind
CONFIG_USB_PD_COMM_LOCKED.

BUG=chrome-os-partner:52157
BRANCH=glados
TEST=Manual on chell. Lock system and boot to recovery, then verify PD
communication is functional. Enable CONFIG_USB_PD_COMM_LOCKED and verify
PD communication isn't functional under the same test conditions.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I8d1f24c0b60cf1c54e329af003b7083ee55ffc40
Reviewed-on: https://chromium-review.googlesource.com/338064
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2016-04-11 14:36:40 -07:00
Bill Richardson
2c26cad2ad Support RW_B in sysjump command when applicable
If we #define CONFIG_RW_B, the firmware image can have two RW
components. This CL expands the "sysinfo" command so that we can
see which image we're running from when RW_B is also a
possibility.

BUG=chrome-os-partner:50701
BRANCH=none
TEST=make buildall; test RW update on Cr50

Using test/tpm_test/tpmtest.py, update the RW firmware and reboot
several times to switch between RW_A and RW_B. Note that the
"sysjump" command reports the correct image each time.

Change-Id: Iba3778579587f6df198728d3783cb848b4fd199d
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/337664
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-04-08 12:34:29 -07:00
Mary Ruthven
fa643a9fc7 cr50: add support for creating multiple serial endpoints
CR50 will need three serial endpoints for the streaming AP and EC UART
and exporting its own console through USB. This change adds a macro to
create endpoints that can be recognized by the usb_serial driver.

BUG=chrome-os-partner:50702
BRANCH=none
TEST=Verify "/dev/google/Cr50*/serial/Blob" prints capital letters when
lower case letters are input.

Change-Id: Iddf2c957a00dc3cd5448a6a00de2cf61ef5dd84c
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336441
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-04-07 13:00:39 -07:00
Kevin K Wong
bf24d5b264 temp sensor: add support for G782
modify g781.c/.h to g78x.c/.h to suppor both G781/G782 temp sensor
based on CONFIG_TEMP_SENSOR_G781 or CONFIG_TEMP_SENSOR_G782

BUG=none
BRANCH=none
TEST=make buildall; able to get temperature data on board with G782

Change-Id: Ia32c85e9964bfd7c0c5263f04368bc001a27fe10
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334228
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-03 10:27:40 -07:00
Bill Richardson
9406cf384a Cr50: Sleep only when SPS has been quiet for a while
This adds the SPI slave bus and TPM task to the things that
can prevent deep sleep. Even when things are quiet, we wait at
least a second

With this CL, it will wait at least one second after the last SPS
transaction before sleeping. Since most TPM-protocol commands are
built up of a number of back-to-back SPS messages, if we don't
wait we'll keep trying to sleep in the middle of active commands.

Even if everything is quiet, we wait 0.2 seconds anyway to give
the UART buffers time to drain.

BUG=chrome-os-partner:49955, chrome-os-partner:50721
BRANCH=none
TEST=make buildall; extensive tests on Cr50

Testing is a pain.

In addition to ALL the steps listed in commit
d917d3f1867e96369ff25bf6906043a5f488a6fb, loading the firmware
with the spiflash tool leaves SPS_CS_L low, so you have to drive
it high manually. The easiest way is to build and run
test/tpm_test/tpmtest.py for a few seconds then interrupt it with
Ctrl-C.

Note that because the system wakes from deep sleep when it sees
SPS_CS_L go low but it can't get ready fast enough to capture the
incoming bits, that first SPI transaction will be garbled or
lost. You'll have to either retry it, or wake the system another
way first.

Change-Id: Iae2fe5ef33869c48e98a3afecd6b98991a51a488
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336690
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-04-03 10:27:39 -07:00
Shawn Nematbakhsh
33fd731ca1 charge_manager: Report UNKNOWN USB charger for 2 seconds after change
After a charger is attached, we may set a charge limit based upon BC1.2
or USB-C Rp before PD negotiation completes. Therefore, allow 2 seconds
for all negotiation to complete. Previously this behavior was implicit
when using SW charge ramp.

BUG=chrome-os-partner:51280
BRANCH=glados
TEST=Manual on chell. Insert stock charger, verify that it is detected
as TYPE_UNKNOWN until timeout.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I52f02de46fa92b66a9fbaddb94a062310688f028
Reviewed-on: https://chromium-review.googlesource.com/334312
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-03 10:27:36 -07:00
Shawn Nematbakhsh
257dab7491 console: Put additional console commands behind CONFIGs
Allow boards to save flash space by undef'ing CONFIGs which gate
'hcdebug' and 'md' console commands.

BUG=chrome-os-partner:34489
BRANCH=None
TEST=`make buildall -j`

Change-Id: I583b98ff1e4d9d6a26958c6895fb0c0305dddceb
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336813
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-04-03 10:27:36 -07:00
Devn Lu
93be0c3b0a ectool: Support keyboard factory scanning
This is keyboard test mechanism request for "multiple key press test",
we can thru the testing to scan out kso ksi pins shortting or keyboard has
multiple key pressing, below was the testing steps:

1. Turn off internal keyboard scan function.
2. Set all scan & sense pins to input and internal push up.
3. Set start one pin to output low.
4. check other pins status if any sense low level.
5. repeat step 3~4 for all keyboard KSO/KSI pins.
6. Turn on internal keyboard scan function.

BUG=chrome-os-partner:49235
BRANCH=ToT
TEST=manual
  Short any KSO or KSI pins and excute "ectool kbfactorytest", it shows failed.
  if no pins short together, it shows passed.

Change-Id: Id2c4310d45e892aebc6d2c0795db22eba5a30641
Signed-off-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/332322
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-01 00:21:35 -07:00
Kevin K Wong
55cd6e4c75 apollolake: initial chipset code
used chipset skylake as the initial code base for apollolake

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: If82f9bcd53ff44714f4b277637ff9f3c115ccc4d
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/331651
Reviewed-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-31 21:35:56 -07:00
Kevin K Wong
6711629163 sensor: update sensor driver to use I2C port from motion_sensor_t
this allow motion sensor devices to be locate on different I2C port

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Ia7ba2f5729ebb19561768ec87fdb267e79aafb6a
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334269
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-31 21:35:56 -07:00
Bill Richardson
9e0c450f72 Cr50: First attempt at USB suspend with deep sleep
This is still in testing mode, so you have to take special steps
to enable it (keep reading). But if you do the right dance, it
does go into deep sleep for USB suspend, and resumes correctly.

However, it doesn't yet wake for any other reason. That's coming next.

Normal sleep is not yet supported, either.

BUG=chrome-os-partner:49955, chrome-os-partner:50721
BRANCH=none
TEST=make buildall; extensive tests on Cr50

Testing is a pain.

First, you can't print anything in the idle task, because that
just makes it stop being idle, so the only way to detect when
it's triggered is by wiring up a GPIO and instrumenting things.

Second, you have to manually reenable USB suspend on the host
every time the Cr50 boots with

  echo auto > /sys/bus/usb/devices/<BLEH>/power/control

where <BLEH> is the correct device.

Third, for reasons probably related to the mysteries of HID
devices combined with crbug.com/431886, you have to build the
firmware without CONFIG_USB_HID (and the related items in
board.h)

Finally, because it's still a work in progress, you have to type

  idle d

at the serial console after every boot (or resume) to reenable
deep sleep in the idle task.

If you do all that, then you'll see that it does go into deep
sleep. Ping it again with "lsusb -v -d 18d1:5014" or
./test/usb_test/device_configuration, and it wakes up and
responds!

If you disconnect the USB while it's in deep sleep, it stays
asleep. When you plug it in again, it wakes up, but it correctly
recognizes that it shouldn't resume and does a normal reset
instead.

Change-Id: I3cc66e48ce671142a4d12edbe0eb9fdacecea0d9
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336279
Reviewed-by: Dominic Rizzo <domrizzo@google.com>
2016-03-31 14:53:52 -07:00
Bill Richardson
70378b86b4 Cr50: Include low-power exit triggers in reset causes
Some of the reset causes are found in another register when
resuming from a low-power state. We know we'll need to
distinguish among them eventually, so we might as well decode
them now.

BUG=chrome-os-partner:49955
BRANCH=none
TEST=make buildall; test on Cr50

I forced the system into deep sleep and observed that the reset
cause is accurately recorded on resume. Doing that requires a
fair amount of hacks and manual effort, and can't happen by
accident. Future CLs will make use of this.

The current, normal behavior is completely unaffected.

Change-Id: I5a7b19dee8bff1ff1703fbbcc84cff4e374cf872
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/336314
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-03-30 20:38:13 -07:00
chris wang
2295467659 usb_port_power_smart: Support variable port count
Use CONFIG_USB_PORT_POWER_SMART_PORT_COUNT to support more usb ports
(default 2).

BUG=None
BRANCH=firmware-strago-7287.B
TEST=build&flash ec,verify on wizpig,usb function work
Signed-off-by: Chris Wang <chriswang@ami.com.tw>

Change-Id: I2460d4a5755ef457249d728169c27fc6d00625d2
Reviewed-on: https://chromium-review.googlesource.com/333232
Reviewed-by: Shawn N <shawnn@chromium.org>
Tested-by: lehai deng <denglehai@ithaier.com>
Commit-Queue: Chris Wang <chriswang@ami.com.tw>
Tested-by: Chris Wang <chriswang@ami.com.tw>
(cherry picked from commit 1e7d3554f1bedbb839a0f4800286c9db0d27e4f1)
Reviewed-on: https://chromium-review.googlesource.com/334510
Commit-Ready: Chris Wang <chriswang@ami.com.tw>
2016-03-24 00:03:07 -07:00
Dino Li
ba6e37787a it83xx: keyboard: remove "CONFIG_IT83XX_KEYBOARD_KSI_WUC_INT" and fix ISR
1. Always use wake-up control interrupt for keyboard KSI. This can also
   wake-up EC from deep doze / sleep mode.
2. In keyboard ISR, we just clear interrupt status to prevent keyboard
   interrupt can't be re-enabled.
   (for example, a KSI interrupt wakes up keyboard scan task,
   but keyboard_raw_read_rows() got 0.)

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

BRANCH=none
BUG=none
TEST=keyboard function is normally.

Change-Id: If8c292189c6133b179a63dedcb7a18abbc091312
Reviewed-on: https://chromium-review.googlesource.com/333865
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>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-03-22 21:39:26 -07:00
Anton Staaf
57244d7708 Console: Fix channel enum values
The channel enum and string name array were out of sync (when
CONFIG_EXTENSION_COMMAND is defined).  This was caused by the two lists
being specified separately.  I argue that this is a good reason to merge
the lists into a separate X-Macro include file.

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

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

Change-Id: I81d143f550a0fe6ef0c64e3c8357ed18aee4bfdc
Reviewed-on: https://chromium-review.googlesource.com/334381
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-03-22 19:54:46 -07:00
Vijay Hiremath
4826d592ce Driver: bd99955: Add ROHM bd99955 initial charger driver
BUG=none
BRANCH=none
TEST=Manually tested on Amenia prototype.
     Used 'charger' console command to check the charger properties.
     Used 'battery' console command to check the battery charging.

Change-Id: Ic8787bfa3e0e3a615542b9cf72e6404fccc96e18
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/334021
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>
2016-03-22 19:54:44 -07:00
Anton Staaf
fa1653d240 GPIO: Rename and move board_set_gpio_hibernate_state
This function is no longer GPIO specific and fits better as part of the
system API, so this moves it there and renames it board_hibernate_late.

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

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

Change-Id: I39d3ecedadaaa22142cc82c79f5d25c891f3f38c
Reviewed-on: https://chromium-review.googlesource.com/330124
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-21 13:16:35 -07:00
Shawn Nematbakhsh
952b2a54e1 crc8: Support crc calculation across non-contiguous data
Building a single buffer for crc calculation is often inefficient, so
add a new function that calculates crc8 from an existing crc8.

BUG=chromium:576911
BRANCH=None
TEST=Manual on sentry with subsequent commit. Verify that smbus
communication with battery is functional.

Change-Id: I05ffedb81ffcf0c126acda5f6212b3147b1580a1
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/333786
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-03-18 22:16:53 -07:00
Nick Sanders
750b4525da servo_micro: add USB I2C interface
Add a usb endpoint and class for i2c control via USB.
Used for servo micro and servo_v4 to export USB control
through servod.

BUG=chromium:571477
BRANCH=None
TEST=updated servod is able to control gpio extender on servo_micro

Signed-off-by: Nick Sanders <nsanders@google.com>

Change-Id: Id44096f8c9e2da917c0574d28dfcbcc0adf31950
Reviewed-on: https://chromium-review.googlesource.com/329322
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-03-15 21:49:35 -07:00
Shawn Nematbakhsh
45919e6d72 power: Add support for rk3399 power sequencing
Add power-up sequencing for rk3399. This is very much a WIP and the
sequence will surely change greatly.

BUG=chrome-os-partner:50819
BRANCH=None
TEST=`make buildall -j`

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I3bacdc8516cfe081411032d55374dd1ab21b2d9d
Reviewed-on: https://chromium-review.googlesource.com/331658
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2016-03-14 20:11:25 -07:00
nagendra modadugu
88e0161583 CR50: move utility method reverse() to common/util.c
reverse() swaps the endian-ness of a buffer of
specified length.  This change moves the implementation
to a common location.

BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
TEST=compilation succeeds

Change-Id: If8c97f53cc199d63c1caebbd999e1c099814387e
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/331333
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-03-07 21:56:04 -08:00
Anton Staaf
faa870945e GPIO: Move STM32 specific gpio_enabled_clocks
This function should not be part of the public GPIO API.  It is only
available and used in the STM32 implementation.  This moves the
prototype to a chip specific gpio.h that is used within the STM32 chip
directoy.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Manually verify GPIO functionality on discovery board

Change-Id: If9c97f8038b26815318652ca62c1132c95519fa2
Reviewed-on: https://chromium-review.googlesource.com/329968
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-03-02 20:26:20 -08:00
Anton Staaf
325fe5ac60 GPIO: Move host and console commands to new file
These commands, like other users of GPIOs should be able to use the
public GPIO API, and thus do not need to be coupled directly to the
GPIO common code.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Manually verified console commands on discovery board

Change-Id: I6e38b9d103590d4f7c72813a33437067716a858c
Reviewed-on: https://chromium-review.googlesource.com/329992
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-03-02 18:03:43 -08:00
Anton Staaf
c86c7799dd NPCX: Refactor GPIO driver for functionality and size
Body 5678901234567890123456789012345678901234567890123456789012345678901
Previously the GPIO driver used quite redundant encodings for its WUI
and DEVALT mapping tables.  This refactor compresses those tables
significantly, while adding the ability to represent an inverted DEVALT
bit.  The resulting RO firmware image for Wheatley is 384 bytes smaller.

This commit also corrects the interpretation of the func parameter to
gpio_set_alternate_function.  Any non-negative func should be
interpreted as a request to switch a pin to an alternate mode.

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

BRANCH=None
BUG=None
TEST=make buildall -j
     Ran on Wheatley, manually verified basic functionality

Change-Id: I3a56a4b56d13a70a30c388e7e2c77dd7acd3838a
Reviewed-on: https://chromium-review.googlesource.com/329761
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-03-02 11:22:51 -08:00
Mary Ruthven
9b4f662a8e lucid: add support to detect BC1.2 suppliers
Use built-in USB periperal to detect BC1.2 suppliers and update the
charge manager.

BUG=chrome-os-partner:48658
BRANCH=None
TEST=manual for lucid. Use a samus as the supplier, and insert the
charger into Lucid. Verify that it identifies it as SDP. Use a wall
charger and verify that Lucid identifies it as DCP.

Change-Id: I7842e9f75874f727837df5bfc28690662caf821c
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/329236
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-26 21:22:07 -08:00
Anton Staaf
98b0e13f60 GPIO: Remove gpio_alt_funcs table from common header
Now that the cr50 no longer uses this array to store its pinmux config
we can move it out of the header file, removing it from the public
interface for GPIO code.  This allows us to start modifying this struct
more easily.

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

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

Change-Id: I9b4ca8b678b102bb9b63ccffe23bf2dc87aeb44a
Reviewed-on: https://chromium-review.googlesource.com/328824
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-22 23:50:53 -08:00
Kevin K Wong
5efbecb770 kunimitsu: hibernate: enable PseudoG3 support at board level
this is to move the existing code from chipset level to board level
since PseudoG3 is a board feature that required specific hardware.

BUG=none
BRANCH=glados
TEST=use hibernate command to enter PseudoG3

Change-Id: I309ef89e0ff7057ce46c634baa9791731a771984
Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/327677
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-18 17:35:16 -08:00
Dino Li
5a7767a20e config: it83xx: remove "CONFIG_IT83XX_PECI_WITH_INTERRUPT"
IT839x and the new series all support interrupt of PECI, so we remove it.

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

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

Change-Id: Ib126cb418a4ba5ef313ee93948bc2fbb96bc936d
Reviewed-on: https://chromium-review.googlesource.com/327643
Commit-Ready: Dino Li <dino.li@ite.com.tw>
Tested-by: Dino Li <dino.li@ite.com.tw>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-17 20:57:01 -08:00
Vadim Bendebury
93f2848eb9 cr50: upgrade command extension
This patch suggests a firmware upgrade mechanism implemented through
an extended TPM command.

The firmware is transmitted in chunks, each chunk accompanied by its
checksum (first 32 bits of SHA1) and the base address.

The first chunk is of size zero and has the base address set to zero.
When the first chunk is received, the command handler determines the
destination flash space (A or B), erases it, and returns its base
address to the caller, such that the firmware update agent can tell in
which of the two spaces it should write the update.

The ultimate verification happens after the device is reset - the
integrity and authentity of the firmware upgrade is verified at that
point, the new firmware will not be started unless it is properly
signed.

BRANCH=none
BUG=chrome-os-partner:37754
TEST=with all patches applied it is possible to upgrade firmware in
     both spaces A and B.

Change-Id: I6aedc587ec630d65ba81000496f372c9044959a0
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/327415
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-02-17 12:01:32 -08:00
Archana Patni
192806b8da skylake: set and clear wake masks in S0 <-> S0ix transitions
In the S0 <-> S3 transition, Coreboot sends EC messages to set/clear the
wake masks when the SMI is invoked. For S0ix, EC sets and clears the
wake mask via this patch.

These functions are directly invoked from the state machine transition states.
During S0ix entry, the wake mask for lid open is enabled. During S0ix exit,
the wake mask for lid open is cleared. All pending events are also cleared

BRANCH=none
BUG=chrome-os-partner:48834
TEST=test lidopen in S0ix

Signed-off-by: Archana Patni <archana.patni@intel.com>
Signed-off-by: Subramony Sesha <subramony.sesha@intel.com>
Change-Id: I52a15f502ef637f7b7e4b559820deecb831d818f
Reviewed-on: https://chromium-review.googlesource.com/320190
Commit-Ready: Divya Jyothi <divya.jyothi@intel.com>
Tested-by: Divya Jyothi <divya.jyothi@intel.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-10 12:44:15 -08:00
Shawn Nematbakhsh
9c053ea898 mec1322: clock: Use full-speed 48MHz processor clock during EC boot
EC boot / hash computing can be a bottleneck for system boot time.
Reduce this bottleneck by running our processor at 48 MHz through boot,
until vboot hashing of RW completes.

BUG=chrome-os-partner:49583
TEST=Boot chell, verify vboot hash completes within 1 sec of EC boot and
'cbmem' delta between 'vboot select&load kernel' and 'finished EC
verification' is reduced to ~250 ms (which includes sysjump time).
BRANCH=glados

Change-Id: I18d87e685b89decef761e51517bfcfc43dcf8ef0
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/326792
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-02-09 19:51:00 -08:00
nagendra modadugu
7ac69e594b CR50: Add initial elliptic curve crypto implementation.
This change adds support for NIST-P256 curve operations.

BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
TEST=new tests under test/tpm2/ pass.

Change-Id: I03a35ff3ab8af3c52282d882937880bfa2bdcd32
Signed-off-by: nagendra modadugu <ngm@google.com>
Reviewed-on: https://chromium-review.googlesource.com/324540
Commit-Ready: Nagendra Modadugu <ngm@google.com>
Tested-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2016-02-08 15:24:29 -08:00
Mulin Chao
f700e3bb0e nuc: Add support for CONFIG_LOW_POWER_S0.
To get better power consumption in S0, we add FW support for
CONFIG_LOW_POWER_S0.

Before entering deep idle in S0, we must enable Host interrupt to wake up
EC if it needs to service LPC bus.

This version also add a new bit of sleep_mask (SLEEP_MASK_FAN) in system.h
to prevent EC enter deep idle if fan's duty isn't zero. Normally, the freq of
PWM fan is 25 kHz. It means we must select apb2 clock as the source clock of
PWM fan. Or fan would stop when ec enters deep idle because of no PWM signal.

In hwtimer.c, we reset the preload counter to maximum value in ITEI32's ISR
since preload counter is changed by __hw_clock_source_set all the time.
We also found there're no event set if it's deadline is over 32 bits but
current source clock isn't. To prevent ec doesn't wake-up in deep-idle even if
ITIM32 expires, FW set an event for ITIM32 after process_timers().

Modified sources:
1. wheatley/board.h: Add CONFIG_LOW_POWER_S0 definition.
2. clock.c: Enable Host interrupt for LPC.
3. clock.c: Disable LP_WK_CTL for better power consumption.
4. gpio.c: Add ISR for Host interrupt.
5. uart.c: Introduce bit 6 of USTAT to make sure transmitting is completed.
6. register.h: Add uart_clear_pending_wakeup function.
7. hwtimer.c: Fixed watchdog issue when ITIM32 is closed to overflow.
8. fan.c: Enable deep sleep if duty cycle is zero.
9. include/system.h: Add SLEEP_MASK_FAN for fan control loop.
10. core/cortex-m/task.c: Add "isb" to flash the garbage data in the
    instruction pipeline.

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

Change-Id: Ibe3630d0d68cf3f32206adb2afa1b5958916a2be
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/324651
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-06 01:57:58 -08:00
Shawn Nematbakhsh
c5e0634054 cleanup: Fix signed vs unsigned typing
- ec_response_thermal_get_threshold.value is unsigned, so it can not be
  less than zero.
- make power_button_wait_for_release() take a signed int, to match its
  existing usage.

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

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie5748df3d9904d1e417adc38fee18f8cb3ce9750
Reviewed-on: https://chromium-review.googlesource.com/325840
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-02-03 21:34:47 -08:00
Stefan Reinauer
bc404c94b4 Enforce compilation without system headers
This patch introduces HOST_CPPFLAGS to be used for all
objects being compiled with HOSTCC rather then the target
compiler.

Since glibc is not linked into the EC, no glibc include files
should be included in the EC code base. Hence, create local
definitions for clock_t and wchar_t that match what the glibc
include would have done, and remove some unneeded includes.

Due to very eager optimization, we have to give gcc a little
notch to not kick out memset.

Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
BUG=chrome-os-partner:43025
BUG=chrome-os-partner:49517
BRANCH=none
TEST=compile tested

Change-Id: Idf3a2881fa8352756b0927b09c6a97473358f239
Reviewed-on: https://chromium-review.googlesource.com/322435
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2016-02-03 15:00:50 -08:00
Vijay Hiremath
33fe5e437d charger/Kunimitsu: Fix for boot from cut-off battery
Battery in cut-off mode wakes when voltage is applied to the PACK
and takes approximately 2 to 3 seconds to initialize before capable
of providing the power. Hence made the battery present status to
BP_NO in case of cut-off mode. Once the battery is ready new status
is updated as BP_YES.
When the battery status changes from BP_NO to BP_YES, charger input
current is set to board specific charger input current which is not
sufficient to boot the AP hence the system reboots. To avoid this
issue, added code to write charger manager negotiated current to
charger input current when the battery status changes from BP_NO to
BP_YES.

BRANCH=none
BUG=chrome-os-partner:49224
TEST=Manually tested on Kunimitsu.
     Used console command 'cutoff' to put the battery in cut-off mode.
     Inserted the adopter to wake the system, system doesn't reboot &
     the battery charges.

Change-Id: Ia5a1457506b4bef0b3dd27993e4b60ae64c8f746
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/322430
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-02-02 23:48:33 -08:00
Patrick Georgi
960cf45b3f Don't declare functions inline that aren't always defined as such
gcc 5.2 bails out on an inline declaration that isn't followed up with
a definition in the same compilation unit.

BRANCH=none
BUG=chrome-os-partner:49517
TEST=compile tested with coreboot's toolchain. samus, oak and others
that failed now build.

Change-Id: Ic9c28fc12c80e24ea0dbf85f35846fd6a0b56a2d
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/324970
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
2016-02-02 17:20:04 -08:00
Shawn Nematbakhsh
9148a4dc01 system: Add hibernate board-level callback
Allow boards to take action (such as entering a custom low-power
hibernate-like state) before putting the chip into hibernate state.

BUG=chrome-os-partner:48835
BRANCH=glados
TEST=Manual with subsequent commit on chell. Verify board-level
hibernate callback is called when "hibernate" is run on EC console.

Change-Id: Ie1da044037a74ff8bce5c822f28ce837c62ceec0
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/324086
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-01-28 22:54:54 -08:00
Nadim Taha
db7194fbe4 common: Fixes the SFDP_BITFIELD() macro.
BUG=none
BRANCH=none
TEST=<redacted>

Change-Id: If6e2732a29e084417ba1d2f80732ac412028342a
Signed-off-by: Nadim Taha <ntaha@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/324622
Reviewed-by: Ewout van Bekkum <ewout@chromium.org>
2016-01-29 02:59:58 +00:00
Ewout van Bekkum
99f62cb3a9 common: Adds a JEDEC SFDP v1.* based Serial NOR Flash driver
Adds a JEDEC SFDP v1.* compatible Serial NOR Flash driver to control
multiple Serial NOR Flash devices (NOR EEPROMs, etc.). The SFDP tables
are used to discover parts' page sizes and capacities.

This driver only supports parts with capacities under 4GiB. If the
parts are larger than 16MiB, then the 0xB7 4-Byte addressing mode
entry opcode and 0xE9 4-Byte addressing mode exit opcode are required.
This driver also assumes that a 4KiB erase opcode of 0x20 is always
available.

BRANCH=none
BUG=none
TEST=Tested on cr51 with multiple EEPROMs with various SFDP revs

Change-Id: I5c2b757267e23c4f22ac89c6d5048a54b04de0c3
Signed-off-by: Ewout van Bekkum <ewout@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/321922
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-28 21:45:37 +00:00
Ewout van Bekkum
f8f0618ca4 common: Adds JEDEC SFDP v1.0 & v1.5 encoding and decoding
Adds a header with JEDEC SFDP v1.0 (JESD216) & v1.5 (JESD216A)
encoding and decoding support to enable a part agnostic Serial NOR
Flash driver.

BRANCH=none
BUG=none
TEST=Tested through the spi_nor driver

Change-Id: I00b3f0434bfb8582aebad7cd0682445980b57773
Signed-off-by: Ewout van Bekkum <ewout@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/321921
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2016-01-28 12:19:31 -08:00
Vincent Palatin
7d0152a78b tcpc: add support for TCPC with integrated high-speed muxes
The TCPCI specification defines ane optional register
18h 'CONFIG_STANDARD_OUTPUT' providing a standardized way
of steering the high-speed muxes.

Implement the feature as a usb_mux_driver, under the conditional flag
CONFIG_USB_PD_TCPM_MUX.
The USB PD port index should be set in the port_addr field of the
'usb_mux' structure.

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

BRANCH=none
BUG=chrome-os-partner:49605
TEST=run pdeval-stm32f072 connected to a Parade PS8751 board and test USB/DP
muxing.

Change-Id: I7e5f0b8ec70b1910b2cff9d106514baca8c899e5
Reviewed-on: https://chromium-review.googlesource.com/322956
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-27 14:52:18 -08:00
Anton Staaf
0801ac67b9 GPIO: Remove gpio_get_level_reg function
After talking with Simon Glass about this we concluded that this was an
optimization that is not needed, as such, and since it is only used in
one location and only available from one chip family I'm removing it.
This further simplifies the GPIO API and removes more uses of port/mask
pairs.

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

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

Change-Id: I40754a385e0a4fa3a56d67fca1dd59fc8f3cc85a
Reviewed-on: https://chromium-review.googlesource.com/323827
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-27 08:44:22 -08:00
Anton Staaf
28eb478881 GPIO: Remove GPIO_TO_PORT_MASK_PAIR
This macro is no longer used, removing it so that it doesn't get used
as we work towards removing port/mask from the public GPIO API.

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

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

Change-Id: Ic924cd520689c0805a2784be5005dbecfe89f389
Reviewed-on: https://chromium-review.googlesource.com/323873
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-27 08:44:21 -08:00
Dino Li
72ad260847 chip: it83xx: update ec2i module
1. The previous EC2I module does not meet section
   '7.17.5 EC2I Programming Guide'. We need to correct it to prevent
   conflict with H2RAM (LPC I/O cycles 800h ~ 9ffh) which cause LPC keeps
   long wait states.
   NOTE:
   If EC is using EC2I internal bus to access PNPCFG registers while host
   accessing EC ram through H2RAM interface at the same time,
   the symptom will appear.

2. Remove 'CONFIG_IT83XX_PNPCFG_HOST_ACCESS'.
   We don't allow the host access PNPCFG registers.

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

BRANCH=none
BUG=none
TEST=1. To use console command 'rwreg' to r/w PNPCFG registers and
        there is no error code return.
     2. To create a stress test for this change.
        - EC use 'ec2i_read()' and 'ec2i_write()' to access PNPCFG
          registers per-10ms.
        - run ectool 'version' command per-100ms.
        Before the change was made, LPC will keep in long wait states
        immediately.
        After the change, we run the test of ectool 'version' command
        over 20000 times.

Change-Id: I84e86fc17ef624d4a60a1a051bc301ebdf56a3da
Reviewed-on: https://chromium-review.googlesource.com/323563
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>
2016-01-26 23:59:47 -08:00
Duncan Laurie
81efb83e95 ec: Add temporary secure storage for the host during boot
This adds a temporary secure storage interface for the EC to be able
to store small amounts of data from the host that is locked until the
chipset resets.  This is used by pre-memory verified boot on x86 systems
where we need to know which RW slot to boot and what the hash is to
ensure that we can resume from S3 safely.

BUG=chrome-os-partner:46049
BRANCH=none
TEST=tested on glados and samus

Change-Id: I5fa91046437479bcae69a8fca4c989b0ef554bbf
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315222
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-25 21:46:48 -08:00
Duncan Laurie
97713dba84 ec: Add a chipset reset hook
There are hooks for chipset power sequencing but not one to indicate
that the system has reset at runtime.  Add a hook for this and
implement for lm4 and mec1322.  The hook is notified on any platform
reset, including those that happen on the way into S3/S5 state.

There is a new config variable added because the hook is notified in
the interrupt handler and needs a deferrable function that needs to
be added to every board.

BUG=chrome-os-partner:46049
BRANCH=none
TEST=tested on glados and samus

Change-Id: I3be639414e18586344e0ec84632a50dfc1df586b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315221
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-25 21:46:48 -08:00
Shawn Nematbakhsh
8c9210b81e mec1322: hibernate: Don't reconfigure all GPIOs
Configuring all GPIOs to INPUT / PULL_UP in hibernate is not a good
idea:

- INPUT / PULL_UP is not necessarially the lowest-power state (for
  example, if there is an onboard pull-down).
- Most GPIOs should already be in lowest-power state when we're in S5.
- For the few GPIOs that need to be in a different state for hibernate,
  we can use a board-level callback.

In addition, remove mec1322 code related to restoring from hibernate
state, since we always reset coming out of hibernate.

BUG=chrome-os-partner:49608
BRANCH=glados, strago
TEST=`hibernate` on chell console when in S5 and AC removed. Verify that
EC power is roughly equivalent to low-power idle power. Attach Zinger,
verify that device wakes and boots, and charges from charger.

Change-Id: Ib00ef035bec32cea3847eb38d743f5c0cec896ca
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/322937
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
2016-01-25 19:48:21 -08:00
Duncan Laurie
bbe2d886dc skylake: Add support for asserting RTCRST if power sequencing fails
In order to pulse RTC reset to the PCH when power sequencing exit fails we
need to watch for SLP_S4 to deassert and if it does not then assert RTCRST
using a board specific method.  This is attempted up to 5 times before giving
up and staying in G3.

On skylake the RSMRST passthru needs to be honored when the task is woken up,
so while waiting call handle_rsmrst() if woken up early.  This is needed
because it is RSMRST that actually tells the PCH to try and wake.

This is all wrapped in a config option and board specific method because not all
boards have a GPIO to control RTCRST and if they do they may not all use the
same method to assert it.

BUG=chrome-os-partner:49564
BRANCH=glados
TEST=manually tested on chell EVT:
First, ensure board sequences properly if everything is OK for a normal boot.
Next, modify handle_rsmrst() to not pass through the signal in order to
simulate being stuck in S5, and ensure that the EC attempts to assert RTCRST
and power up again 5 times before giving up and staying in G3.

Change-Id: Ia3c13069c92762b51beb682a19e5a074194a3c26
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/322724
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-20 23:21:53 -08:00
Anton Staaf
4c290b058a GPIO: Simplify configuration
Previously there were only two uses of gpio_config_pins, one was
gpio_config_module, which passed in GPIO_CONFIG_ALL_PORTS (the only
place this is used), the other was the common I2C code when it needs to
return the SDA and SCL lines to their alternate function after unwedging
the bus.

These uses are so different that it doesn't make much sense to keep a
single API for them.  This change adds a gpio_config_pin that is
simpler to use as it just takes a gpio_signal enum to select the GPIO
to configure and makes gpio_config_pins and GPIO_CONFIG_ALL_PORTS
internal to gpio.c

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

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

Change-Id: I92bfb0b520b0aa2165655b2ff5076e428c88631f
Reviewed-on: https://chromium-review.googlesource.com/322437
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-01-20 14:25:32 -08:00