Commit Graph

29 Commits

Author SHA1 Message Date
Alec Berg
10bd1db6d7 lm4: Use low speed clock in deep sleep.
Changed the low power idle task to use the low speed clock in deep
sleep. The low power idle task is currently only enabled for Peppy,
Slippy, and Falco. This change decreases power consumption when
the AP is not running.

Note that the low speed clock is slow enough that the JTAG cannot be
used and the EC console UART cannot be used. To work around that,
this commit detects when the JTAG is in use and when the EC console
is in use, and will not use the low speed clock if either is in use.
The JTAG in use never clears after being set and the console in use
clears after a fixed timeout period.

BUG=None
BRANCH=None
TEST=Passes all unit tests.
Tested that the EC console works when in deep sleep.
Tested that it is possible to run flash_ec when in deep sleep and
using the low speed clock.

Change-Id: Ia65997eb8e607a5df9b2c7d68e4826bfb1e0194c
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173326
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-10-21 23:59:38 +00:00
Alec Berg
c5b90d7e77 lm4: Add a low power idle task.
First implementation of a low power idle task for the LM4 chip. The
low power mode is selected by defining CONFIG_LOW_POWER_IDLE in a
board.h file. This commit turns it on for Peppy, Slippy, and Falco
only because those are the only boards tested.

When using the low power idle task, the chip goes in to deep sleep
when it can. Deep sleep disables clocks to most peripherals and puts
the onboard flash and RAM into a low power mode. The chip is woken
out of deep sleep using the RTC in the hibernate module. Increased
the idle task stack size to handle more involved idle task.

In board.c, the array of GPIO info can be used to select which GPIO
points can wake up the EC from deep sleep. Currenlty selected are
the power button, lid open, AC present, PCH_SLP_S3, and PCH_SLP_S5.
Additionally the port with the KB scan row GPIO point is also
enabled to wake up the EC from deep sleep.

Signed-off-by: Alec Berg <alecaberg@chromium.org>

BUG=None
BRANCH=none
TEST=Passes all unit tests. Runs on slippy, peppy, and falco with no
noticeable side affects. Verified that the power consumed by the EC
is lower when in S3, S5 and G3 by scoping the sense resistor
powering the chip.

Change-Id: I83fa9a159a4b79201b99f2c32678dc4fc8921726
Reviewed-on: https://chromium-review.googlesource.com/172183
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
2013-10-15 00:27:14 +00:00
Randall Spangler
f8955d14b6 Remove unused board_version enums
These were briefly used on link, and are not used by any other
platform.  The values for those platforms are almost certainly wrong,
and incorrect information is worse than no information.

This does not remove reading the stuffing resistors - it just removes
the assumption that they map to PROTO1 and EVT.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=compile all platforms

Change-Id: I2ba19fd52660559bfd1d8e3b8a9949e9b8abbddf
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61929
2013-07-16 12:06:30 -07:00
Vic Yang
c8b7b430fe Add console command to force enable console
When system is locked, the console is disabled. However, we need console
for debugging and testing. This CL uses a bit from back-up register to
indicate if the console should always be enabled. (This bit is currently
used by fake WP, which is removed in this CL.) With this, we can set
this bit with console command 'forceen 1' to ensure console is never
disabled.

To prevent device shipped in this state, the chip name is postfixed with
'-unsafe' so that the device is not able to pass HWID check.

BUG=chrome-os-partner:19293
TEST=Manual
BRANCH=spring

Change-Id: I88556e973ca542c1bdc27ba64988718291e01a26
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/51086
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-15 20:12:47 -07:00
Vic Yang
5007bbc009 Use uintptr_t when converting integer from/to pointer
Perviously we use uint32_t for this, but this doesn't compile for 64-bit
environment (and likely doesn't for 16-bit either.) Use uintptr_t so that
we don't get size mismatch errors.

BUG=chrome-os-partner:19257
TEST=Run host emulated tests
BRANCH=None

Change-Id: I3cd66a745fa171c41a5f142514284ec106586acb
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50358
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-07 20:59:53 -07:00
Randall Spangler
78b0e9863d Use chipset_reset() interface instead of system_warm_reboot()
We have a common chipset interface for performing a warm reset of the
AP, so move the implementation from system_warm_reboot() there.  (It
was never a system function anyway; system = EC+AP; chipset = AP)

No functional change; just renaming functions.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build daisy,snow,spring,mccroskey

Change-Id: Ibc2c5efced5660c4335cd1868470184397800acd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/45891
2013-03-20 15:23:29 -07:00
Randall Spangler
f48f9a6228 Clean up system module
No functional changes.  (it might look like
SYSTEM_HIB_MINIMUM_DURATION is a change, but it's not used at present)

BUG=chrome-os-partner:15579
BRANCH=none
TEST=version; chip info should print successfully

Change-Id: Idd7f60a29528e9f6af4f91cd5a556e7336acee9f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36599
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-10-25 17:03:43 -07:00
Che-Liang Chiou
8a9471e5ef stm32: Store VbNvContext in backup registers
This would improve boot speed when compared to storing in eMMC because
initialing eMMC is slow.

So far other platforms do not have this need because CMOS is quite
efficient; thus it is left unimplemented in lm4.

Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>

BRANCH=snow
BUG=chrome-os-partner:10660,13094
TEST=On Snow, see VbNvContext is preserved across power cycles (you have
     to patch U-Boot to test this)

Change-Id: If5072c678b87bc47a3a82a1dff2afa3896304f36
Reviewed-on: https://gerrit.chromium.org/gerrit/31832
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
2012-09-05 16:00:28 -07:00
Sameer Nanda
73e439dc87 gaia: Add a warm reboot function
Added a warm reboot function that reboots the AP while preserving
RAM contents. This will be helpful in debugging AP/OS hard hangs since
in conjunction with PSTORE_CONSOLE in the kernel, the kernel log messages
from the previous boot will be preserved.

BUG=chrome-os-partner:13249
TEST=1. From EC console issue the "warm_reboot" command. Upon rebooting
"cat /dev/pstore/console-ramoops" and ensure that the contents are dmesg
of previous boot.
2. Reboot the system using alt-volume_up-r key combination. Upon
rebooting, check pstore contents in the same manner as case#1 above.
BRANCH=snow

Change-Id: Ic8f0415da6182f4c1bc2d35b91302ceda5c19569
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/31523
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-08-28 12:09:23 -07:00
Randall Spangler
521e97fd13 Clean up EC hibernate logic
system_hibernate(0, 0) now hibernates until a wake pin assert, with no
RTC wake.

BUG=none
TEST=manual

command -> expected reset flags from 'sysinfo'
1. reboot -> soft
2. reboot hard -> power-on hard
3. hibernate (and press power button) -> power-on wake-pin
4. hibernate 3 (and wait for timeout) -> power-on rtc-alarm
5. hibernate 10 (and press power button before 10 sec) -> power-on wake-pin

hibdelay 10
then shut system down and run on battery
10 sec later, system should hibernate.

Change-Id: I399413d265f6fcf808adf9ed1db7b812a1b12fc2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29923
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-08-13 14:22:23 -07:00
Randall Spangler
319d433d68 Calculate the hash only of the actual RW code
No need to hash a bunch of 0xff's at the end.  We explicitly set a
0xea byte after the end of the code in firmware_image.lds.S.

BUG=chrome-os-partner:11087
TEST=look for the hash start line in the EC debug output:

   [0.011543 hash start 0x00014000 0x00011590]

The second number is the code size.  It should be the same size as
ec.RW.bin, instead of 0x14000.

Change-Id: Ibc94851dc1a09eb46cad46bb97dc5762f9c521f0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28300
2012-07-24 15:55:31 -07:00
Randall Spangler
085b31222b Refactor reboot command to add ap-off and cancel options
Also add 'preserve' flag, for tracking when flags have been preserved
from a previous boot.

BUG=chrome-os-partner:11663
TEST=manual

  reboot -> flags = soft
  reboot preserve -> flags = soft preserve

From ectool, 'ectool reboot_ec cold at-shutdown'

  sysinfo -> shows reboot at shutdown: 4
  reboot cancel
  sysinfo -> no longer shows pending reboot
  reboot ap-off -> flags = soft ap-off, AP is not powered on

Change-Id: I117f33fe21048edb2261be4dcdc6c828a5794d54
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28139
2012-07-23 11:03:33 -07:00
Randall Spangler
eb93d200be Rename section A to RW, to match other platforms
BUG=chrome-os-partner:11149
TEST=make link, snow, bds; on reboot,
  sysjump rw
  sysinfo   <- should indicate current image is rw
Then on root shell,
  ectool version  <- should indicate rw

Change-Id: I833fcb814165379dd044e4cb46ae338e5da81212
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27660
2012-07-17 14:40:59 -07:00
Randall Spangler
fc7b64e186 Remove firmware B
BUG=chrome-os-partner:11449
TEST=build link, snow, bds; ectool reboot_ec cold to make sure enums line up

Change-Id: Ie09db2080a00f1a7e2c05579b9b41ea5137c1af0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27658
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-17 13:11:44 -07:00
Randall Spangler
7ee63359b8 Support preserving reset flags across a reset
This is needed for flash pre-init to be able to hard reset to clear
uncommitted write protect flags without losing the reset flags.

BUG=chrome-os-partner:11368
TEST=manual

Use reboot and sysinfo commands...

1. reset with keyboard.  flags -> reset-pin
2. 'reboot soft preserve'  flags -> soft reset-pin power-on
3. 'reboot hard preserve'  flags -> hard soft reset-pin power-on
4. 'reboot soft'.  flags -> soft
5. 'reboot hard'.  flags -> hard power-on

Change-Id: I6164a78d99c5c10330f90f651148c5795e7afdda
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27418
2012-07-16 10:20:58 -07:00
Randall Spangler
0e933d1ce9 Refactor reset reasons
Reasons are really bitflags, not a single reason.  This will make it
easier to implement flash protection on LM4, where hibernate is a
subset of power-on reasons.

Also added some additional flags we pass in a hibernate register so...
1) We don't recognize spurious RTC wake reasons
2) Hard reset via system_reset(1) is detected as a hard reset, not a RTC wake

BUG=chrome-os-partner:11368
TEST=manual

1. Keyboard reset = power-on reset-pin
2. Pull battery = power-on
3. reboot = soft
4. reboot hard = power-on rtc-alarm
5. hibernate 10 then push power button = power-on wake-pin
6. reboot 3 sec later = soft
7. hibernate 1 = power-on rtc-alarm

Change-Id: Icbbdbcf6dfd13c8a6a4f80a23f64cebebbfba26e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27417
2012-07-16 10:17:09 -07:00
Randall Spangler
80fa2da908 Add reboot-at-shutdown flag
Also removes unused recovery request, since AP handles that internally now.

BUG=chrome-os-partner:10685
TEST=manual.  From root shell,

ectool reboot_ec RO                 -> EC reboots to RO, AP stays up
ectool reboot_ec A                  -> EC reboots to A, AP stays up
ectool reboot_ec cold               -> EC reboots, AP shuts down
ectool reboot_ec cold at-shutdown   -> (EC stores request, but doesn't reboot)
shutdown -P now                     -> EC reboots when AP shuts down
ectool reboot_ec cold at-shutdown   -> (EC stores request, but doesn't reboot)
ectool reboot_ec cancel             -> (EC stores cancel-request)
shutdown -P now                     -> AP shuts down, but EC doesn't reboot

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I51bbf997f6b7f94fe61f06a8a1804c3cc5c319b8
Reviewed-on: https://gerrit.chromium.org/gerrit/25791
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-20 23:30:02 -07:00
Randall Spangler
7ecd1d6d3c Add system_is_locked() to prevent sysjump on consumer systems
This returns true when both HW and SW write protect are enabled.

Once WP is enabled, sysjump will be locked out.

system_is_locked() can be used to gate other dangerous-ish commands too.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7468
TEST=manual

sysinfo -> unlocked, copy A
sysjump B -> works
flashwp lock
reboot
(make sure flashinfo shows WP asserted and flash locked; note there is a
 HW bug on proto1 which makes this flaky)
sysinfo -> locked, copy A
sysjump B -> fails
(remove WP screw)
reboot hard
flashwp unlock

Change-Id: I849b573675c2c1cb4c44b9a05d6973e38247ca23
2012-05-25 15:03:47 -07:00
Randall Spangler
b1bb8314bd Add LM4 support for hard reset
(And add STM32 support for disabling interrupts before reset, which
got missed before.)

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:7470
TEST=from console, "reboot", then "reboot hard"

Change-Id: Ib98792abc0c91a01e2230b419fc876052380655a
2012-05-21 09:17:43 -07:00
Randall Spangler
8ea7983c29 Add gpio_set_flags() and system_get_board_version()
Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9117
TEST=version; board version should be 0 on proto1 and 1 on EVT

Change-Id: Ic64ad0d009151fbda09f5c1605ef50ae708cb6ae
2012-05-08 21:00:38 -07:00
Vadim Bendebury
0467763f5a Enhance LPC EC REBOOT reset command to allow to request recovery
When the host reboots the EC it should be able to request the EC to
force recovery mode after reset. This is achieved by extending the
REBOOT EC command with a bitmask byte, with bit 0 dedicated to
recovery request.

So, when BIOS on the way up determines that recovery is requested, but
the EC is not running from the RO space, the BIOS would reset the EC
forcing it to run from RO and to request recovery mode through the LPC
bitmask. Then BIOS will restart itself ensuring that the system comes
up in consistent state.

Some refactoring was also done to make the code a bit more compact.

BUG=chrome-os-partner:9040
TEST=manual
  . tested along with coreboot changes (test described in the coerboot CL).

Change-Id: I29801b6aec80da0901ba0e8db8e92e615cc778bd
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
2012-04-30 15:36:41 -07:00
Randall Spangler
13ad1c007b Implement HOOK_SYSJUMP and use it to preserve LPC host event mask
This also changes shared_mem to use all the remaining RAM, instead of
reserving a fixed-size buffer.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=chrome-os-partner:9161
TEST=manual

hostevent  --> all masks should be 0
hostevent smi 0x12300000
hostevent  --> should confirm SMI mask was set
sysjump b
hostevent  --> should confirm SMI mask is still set
reboot
hostevent  --> should confirm SMI mask is back to 0

Change-Id: Iccb6da6ccc93ee5036a3f478d24b717a462d9150
2012-04-19 18:15:18 -07:00
Randall Spangler
ee3edc0116 Clean up inits
We can clear the reset cause in system pre-init now because of a
previous change which preserves it across a sysjump.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

BUG=none
TEST=if it boots, it works

Change-Id: I1d8b99df5a0be0de9545d22ad1a6b7fb3140f813
2012-04-19 11:08:28 -07:00
Louis Yung-Chieh Lo
1a9a415cf6 Support chipinfo command (ectool/host commands)
Add a host command returning chip information. The interface is in common/
while the implementations are in chip-specific code (note: added simple
value for stm).

BUG=chrome-os-partner:8567
TEST=on board
% ectool chipinfo
Chip info:
  vendor:    xx
  name:      yyyy
  revision:  zzzzz

Change-Id: I5030a03a6fcfbfc080d5acd8efb763fde7eefde5
2012-04-09 14:25:30 +08:00
Randall Spangler
ed33516e2e Preserve reset cause when jumping between EC images
BUG=chrome-os-partner:8718
TEST=manual

1) Use 'reboot' command from console to boot image.  Should end up in
image A, with last reset reason soft cold.  'sysinfo' should show we
jumped to this image.

2) sysjump RO.  Should end up in RO; otherwise same as 1)

3) reboot using Power+Esc+Reload.  Should end up in image RO, with last
reset reason reset pin.  'sysinfo' should show we did not jump to this
image.

4) sysjump A.  Should end up in A with reset reason reset pin.
'sysinfo' should show we jumped here.

Change-Id: I2dd5595eab4ba2c91bfe8b2b2e9677d7732aca63
Signed-off-by: Randall Spangler <rspangler@chromium.org>
2012-04-03 09:26:25 -07:00
Louis Yung-Chieh Lo
b71837716d flash write and erase commands protect the active image.
Comapre the range to be write (erase) with the range of active image.
If overlap, return error to indicate the access denied.

Note that we actually protect only runtime code and ro data.
FMAP is intentional unprotected so that flashrom can update to new map
before jumping. Since the vector table and init code are in the same
erase page, they are unprotected as well.

BUG=chrome-os-partner:7478
TEST=

Change-Id: Icb5cc89836432a11cef80e18eb66bb39a6c9b1d9
2012-03-27 14:36:45 +08:00
Vincent Palatin
a94e3277b3 update versioning information stored in the EC
Add build information (date/time/builder) which can be displayed at the
EC console.

Generate a version from the board name and the branch tag.

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

BUG=chromium-os:27013
TEST=on BDS, run version command on the console.
inspect the built binary.

Change-Id: Idb1f68898ba6b811d02919f17ab4536ed9f8934a
2012-03-02 16:46:26 +00:00
Vincent Palatin
84dc68283e Split reset cause and image copy code.
Preparatory work to introduce a second SoC : 3rd series 2/2

All the RO/A/B firmware copy code could be generic to all our platforms.
The console commands are a 'standard' API.

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

BUG=None
TEST=on BDS EC console, check the reset cause with the 'sysinfo' command.

Change-Id: Ieeb84571085d88b5747a09da4c33d3852bb0da96
2012-01-26 22:34:41 +00:00
Randall Spangler
bdf7da5b08 Initial sources import 1/3
source files mainly done by Randall.

Signed-off-by: Randall Spangler <rspangler@chromium.org>

Change-Id: Iaff83a842b17f3350fb6f2a3f1597ad4c29bd12a
2011-12-07 19:10:02 +00:00