Commit Graph

1044 Commits

Author SHA1 Message Date
Randall Spangler
ed3f2af50f Add real-time clock support
BUG=chrome-os-partner:12290
TEST=manual

From EC console,
   rtcget
   (wait a few sec)
   rtcget
   hibernate 3
   (wait for wake)
   rtcget
   (hold power+refresh; wait for reboot)
   rtcget
   rtcset 20000
   rtcget
   (wait a few sec)
   rtcget

Each rtcget should be a few seconds after the previous one.

Pull the battery and remove AC power.  Then restore AC power and
   rtcget
   (wait a few sec)
   rtcget
Should be close to 0.  That is, it should have reset to 0 when power
was lost.

From root shell,
   ectool rtcget
should match the time from rtcget, truncated to the nearest second.
   ectool rtcset 30000
should set the time (do a rtcget to check).

Change-Id: I535097feb7af8aa6583c8ef50ade66bb19bdff8f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29349
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-08-07 19:06:35 -07:00
Randall Spangler
45cd8463a3 Remove signature-based vboot support
Superseded by EC software sync (hash-based).

Sig-based vboot was correctly implemented, but ended up being too slow
to be useful given the limited processing power of the EC chips, and
we also couldn't come up with a manageable way to handle A/B
autoupdate of signed EC firmware.

This change and an associated vboot_reference change shrinks the EC
binary by ~2KB.

BUG=chrome-os-partner:11232
TEST=build link,snow; boot link and check that 'hash' command still works.

Change-Id: I3f03ae2d0a4030977826980d6ec5613181e154c2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29496
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-08-07 19:06:33 -07:00
Randall Spangler
29cbe51663 Add host events for shutdown due to thermal or battery
BUG=chrome-os-partner:12353
TEST=hack the thermal monitoring and/or battery code to trigger a shutdown
then see that the events get set

Change-Id: I5ef2ac03cdd793ab0c50c0db518cba1ede3ea036
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29429
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-08-07 13:30:49 -07:00
Charlie Mooney
a78bb5e560 Fix stack overflow in i2c stack for EC
There were a number of problems resulting from i2c crashes,
particularly when trying to access the battery.  The problem is that
the stack was overflowing on this particularly deep path, all the way
down to wait_status.  This in itself was fine, but if there was a
timeout, debugging information would be printed to the uart, and that
function would cause an exception and restart the EC.

To fix it, I stripped the debugging CPRINTFs from wait_status.  This
allows everything to work fine, but looses some information for
debugging.  To allow future developers to still see what event the i2c
was waiting for, I added an additional variable to store it in, so that
it can be displayed/handled further up the stack.

BUG=chrome-os-partner:12245
TEST=Boot the machine using a Servo.  On the AP's UART, run
"cros_test i2c" to start pounding the i2c bus.  Then from the EC, run
"pmu 1000" and then "battery 1000" there should be no error messages,
exceptions, and the EC should not restart.  Repeat this process with i2c
arbitration disabled (remove the flag in ./board/snow/board.h).  You
should suffer no fatal errors.  cros_test may report errors detected,
but the EC will never crash, restart, or throw exceptions.  These other
errors are the EC and the AP stepping on each other's toes now that you
have disabled arbitration.

Change-Id: Idd2f017d3557652bf3e8536c4ac776c1f70319cb
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29351
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-08-07 12:05:30 -07:00
Randall Spangler
80e36e0254 Enhance port 80 logging
- 'port80 intprint' toggles printing port 80 codes in interrupt
  handler (turning that off speeds up port 80 capture a bit, if you're
  sending port 80 codes very rapidly)

- 'port80 flush' flushes the log buffer

- log buffer expanded to 256 entries

- log buffer tracks S3->S0 power state transitions, so you can tell
  where each boot starts

This uses ~500 bytes more RAM on the EC, but we've got piles of RAM
(with this change we're using 17KB out of 32KB).

BUG=none
TEST=manual

- boot system
- port80 -> prints data
- port80 intprint -> now disabled
- reboot; wait for reboot; no port80 debug output during boot
- port80 -> prints data from previous boot AND this one
- port80 flush
- port80 -> nothing in log

Change-Id: I64ee72fb13ab0fdd85d04b9640b5390fdac31400
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29420
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2012-08-07 12:05:30 -07:00
Vic Yang
b383d4c6b8 Hibernate when in G3 for 24 hours
To save power, make the EC hibernate after we go into G3 for 24 hours.

BUG=chrome-os-partner:9386
TEST=Use "hibdelay 5" to change the delay to 5 seconds.
     Remove AC power, power down and check device hibernates after 5
     seconds in G3.
     Connect AC power, power down, wait for G3. Remove AC power and
     check device hibernates after 5 seconds.

Change-Id: I6fb907c904798076a763f22bd35f53f7424d6200
Reviewed-on: https://gerrit.chromium.org/gerrit/29400
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-08-07 09:35:18 -07:00
Vic Yang
687bd2cf39 Periodically set power LED
It is possible that power LED goes off while AC still connected. Let's
set power LED periodically to aviod this problem.

BUG=chrome-os-partner:10386
TEST=Disconnect power LED while leave AC connected. Check LED goes off.
Connect LED again and check it comes back after few seconds.

Change-Id: I2a199446be5da772af8027b735b9f431f697bacd
Reviewed-on: https://gerrit.chromium.org/gerrit/29403
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-08-07 09:35:18 -07:00
Vincent Palatin
dbc861c5f0 add a function to fast forward system timer
When we wake up from a deep sleep mode, the system timer clock might
have been stopped. We need to be able to set using another time source
(e.g. the RTC).

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

BUG=chrome-os-partner:8866
TEST=make BOARD=snow && make BOARD=link
on Snow, on a software implementing STOP mode, check the system time is
still accurate by comparing it to the wall clock.

Change-Id: Ieddbb423d052c7aceb398470866b25b25a74c0a0
Reviewed-on: https://gerrit.chromium.org/gerrit/29314
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-08-06 18:55:00 -07:00
Vincent Palatin
d8e04f0db7 snow daisy: compute RW firmware hash
Activate the VBOOT code to compute the SHA256 hash of the RW partition
of the EC firmware.

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

BUG=None
TEST=On Snow, reset the EC and see the hash is computed at startup.

Change-Id: Id1930f823ef516e459b4905c7d0f301568fddf0f
Reviewed-on: https://gerrit.chromium.org/gerrit/29279
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-08-06 12:06:44 -07:00
Vincent Palatin
7c5c4792e9 snow: remove debug features to save RAM
We need a bit more internal RAM for verified boot hash feature,
let's de-activate RAM hungry debug features.

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

BUG=chrome-os-partner:12271 chrome-os-partner:10895
TEST=make BOARD=snow
check RAM size with CONFIG_VBOOT and CONFIG_VBOOT_HASH activated.

Change-Id: I4d1d6c0f99a8b03011af6eb2d73455beba93c535
Reviewed-on: https://gerrit.chromium.org/gerrit/29278
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-08-06 12:06:44 -07:00
Vincent Palatin
5bc086d688 vboot: fix flash offset for hash
CONFIG_FW_RW_OFF is already relative to the base address of the flash,
we don't need to substract it.

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

BUG=None
TEST=on Snow, run with CONFIG_VBOOT and CONFIG_VBOOT_HASH activated and
see the hash is correctly computed and display.

Change-Id: I1643b07a59459baa973bfd7ee80cbf98963a85d4
Reviewed-on: https://gerrit.chromium.org/gerrit/29276
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-08-06 12:06:43 -07:00
Rong Chang
ea9a51856e Add TPSChrome comments on charging code
This change adds more comments on charging states and fixes battery
temperature out of range log messages.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:10900,12222
TEST=none

Change-Id: Ie3240dc246ad7590078929e41575c67798373aca
Reviewed-on: https://gerrit.chromium.org/gerrit/29253
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-08-06 00:05:52 -07:00
Rong Chang
6156c1b904 Change link charging profile
Change vendor specific charging current table to meet battery
specification.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:12012
TEST=run firmware_ECCharging

Change-Id: I41a8060834bd02153d8c722ae5ffed7749226b83
Reviewed-on: https://gerrit.chromium.org/gerrit/29258
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
2012-08-06 00:05:51 -07:00
Rong Chang
1a6a7336be Fix stm32 i2c timeout debug message
The i2c timeout error message is false positive warning. It happened
when wait_status() function got a good result, but took too long to
complete (> 1ms).

This warning message can be removed safely.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:9759,12222
TEST=none

Change-Id: I2a670b76a5d741dc82ea59eacc233c4719eb3263
Reviewed-on: https://gerrit.chromium.org/gerrit/29254
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-08-06 00:05:51 -07:00
Randall Spangler
cf20b3e4f0 Add x86indebug command
Prints all x86 signal power state transitions at interrupt level, so
we can see lines toggle more precisely.

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

1. power on system
2. no debug output that looks like [501.001742 x86 in 0x563f]
3. reboot
4. x86indebug 0xffff
5. power on system
6. should see lots of lines that look like [501.001742 x86 in 0x563f]

Change-Id: Ie3b346ee4d4beee3f13ac1245f1eb022b48dabf4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29192
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-08-03 16:51:14 -07:00
Charlie Mooney
5e996478c9 Fixing lid power behavior -- shutdowns vs reboots
When the user is logged in a closes/opens the lid of the laptop the
lid_changed flag gets set, but never cleared.  Normally, it would get
cleared when it powered back on from being opened, but without powerm
running or is the machine is only suspended, then that never happens.
This fixes the problem by additionally clearing the flag whenever the
computer is powered down.  This forces the computer to not turn on
based on anything that happened to its lid before it was turned off,
which is the behavior you'd expect.

BUG=chrome-os-partner:12189
TEST=Log in to your Chomebook completely.  Close, then open the lid.
Shut the computer down.  It should stay off now.  Once it's back on
close the lid and confirm that it still suspends correctly.  Now
open the lid and make sure it turns back on.  Repeat these steps, but
kill powerm first.

Change-Id: I2275b3125115b4eacc6a5d074978d7a1d51b0695
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/29111
Reviewed-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-08-03 09:52:22 -07:00
Vic Yang
29d478c92b Revert "Set power LED to green when we are trickle charging nearly full"
This reverts commit f322e1b96a.

Now that we notify kernel when charge_full changes, this workaround
should be abandoned.

BUG=chrome-os-partner:11248
TEST=Check power LED still works.

Change-Id: I87c269dcf4cb6b9f0da2472f139e39cced28232b
Reviewed-on: https://gerrit.chromium.org/gerrit/29147
Reviewed-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-08-03 08:04:16 -07:00
Vic Yang
0083ce5bea Notify kernel when charge_full changes
This way kernel always know the current value of charge_full.

BUG=chrome-os-partner:11248
TEST=Check charge_full is updated when it changes

Change-Id: I623d84a4d6e556097b9214672e016b0c2e6cfdb9
Reviewed-on: https://gerrit.chromium.org/gerrit/29133
Reviewed-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-08-03 08:04:16 -07:00
Vic Yang
4dc7496a98 Fix 'reboot' console command
BUG=chrome-os-partner:12155
TEST=Check 'reboot' command works with the following parameters:
       - No parameter
       - 'hard'
       - 'soft'
       - 'hard ap-off'
       - 'soft ap-off'
       - 'soft preserve'
       - 'hard ap-off preserve'

Change-Id: Ib54d6a0fe419ff7b47265698fae2fcd554f707d4
Reviewed-on: https://gerrit.chromium.org/gerrit/29017
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-08-02 19:41:58 -07:00
David Hendricks
985ff40583 snow: add keypress noise suppression
This was implemented for Daisy a long time ago, but left out on Snow
due to some confusion.

GPIO remapping is already handled because PD1 and PD0 (which is used
for ENTERING_RW) are remapped together. So all we need here is the
board_keyboard_suppress_noise() function definition which gets
called from the keyboard scanning code whenever a change is detected.

BUG=none
TEST=Verified using a scope that CODEC_INT line is driven
     when a key is pressed (15us pulse)

Signed-off-by: David Hendricks <dhendrix@chromium.org>
Change-Id: Ifd358eb89a9547c4f4b9536b8922c93d2c3b77a0
Reviewed-on: https://gerrit.chromium.org/gerrit/28989
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-08-01 19:17:19 -07:00
Randall Spangler
903dc92ec1 Add additional host command debug output
Prints when a host command returns an error code.

When 'hcdebug on', hex-dumps the host command params and response.

BUG=none
TEST=manual (> is ec console, $ is root shell)
  $ ectool gpioget foobar --> EC console shows error 2 returned
  > hcdebug on
  $ ectool hello --> EC console shows params and response as hex
  > hcdebug off
  $ ectool hello --> no extra output on EC debug console

Change-Id: I2dbc77be5b59125f394d970cf1c83c2a976e926e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28948
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-08-01 11:58:24 -07:00
Louis Yung-Chieh Lo
d02cc2c961 Snow has write protect pin (PB4) wired to EC.
Intend to keep fake_wp functions for test.

BUG=chrome-os-partner:9986
TEST=build only (success on link/snow/daisy/bds). Have no hardware to test.

Change-Id: I1e2ae923790d65b6c95819f5274dbe8c7f254429
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28793
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-08-01 09:07:06 -07:00
Rong Chang
776374b028 Wait STM I2C stop bit sent
This CL prevents the risk of CR1 write access causes duplicate STOP.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11974
TEST=manual
  console command "pmu 200"

Change-Id: I717336d87230139a1a17e6f39e70502c0e0c7a18
(cherry picked from https://gerrit.chromium.org/gerrit/#/c/26832)
Reviewed-on: https://gerrit.chromium.org/gerrit/28811
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-31 22:13:50 -07:00
Charlie Mooney
ae8e24acb7 Fixing bug: Keyboard locks up after 8s pwr press
The EC was not re-enabling keyboard scanning on boot if the power button
was released.  This works fine if the power button is released before
the shutdown is complete, but if the user holds it down until the device
is completed powered down the lock will never be released, and the next
time they turn on the computer, the keyboard won't work.

To fix this, all that is needed is to make the power event task keep
unlocking it whenever the power button isn't pressed down.  There's
no problem with unlocking multiple times, so it's not dangerous to do
this.

BUG=chrome-os-partner:12070
TEST=Boot the machine normally, then press and hold the power button
until the machine is entirely powered down before releasing it.  Press
the power button a second time to turn on the machine.  You should be
able to type as normal.

Change-Id: I88852ed228bd8f6a9446406bab642812ef1327db
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28871
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-07-31 16:42:06 -07:00
Randall Spangler
77000e73bc Fix setting initial debounced power button state
If it's pressed, need to track that or we'll ignore the release.  And
then we'll leave the power button signal asserted to the PCH, and
it'll shut down 4 seconds after the power button was pressed.

BUG=chrome-os-partner:11971
TEST=hibernate 10, then press power button for ~0.5 sec, then release
system should boot normally

Change-Id: Ibb9b8a8827cca6c81bac06dc9543de1a76fa5aad
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28863
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-31 16:07:27 -07:00
Bill Richardson
261beed560 security: Check for integer overflow in VbExMalloc()
Make sure we don't roll over when rounding up to align the requested size.

BUG=chrome-os-partner:11642
TEST=none

No test; if security guys approve code change, it's fixed.

Change-Id: I2e915a6e6b37fc315ab7adb435e2fce4eed670ba
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28729
Reviewed-by: Sumit Gwalani <sumitg@google.com>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
2012-07-31 11:59:25 -07:00
Vic Yang
37754f9b70 Rename TMP006 sensors
BUG=chrome-os-partner:12010
TEST=Build success

Change-Id: I2557ec1568bc0b13a4dd25bbd85dffb9dccd6468
Reviewed-on: https://gerrit.chromium.org/gerrit/28764
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-31 09:20:39 -07:00
Vic Yang
b13cf5de98 Fix a bug that a line longer than 80 char kills EC console
BUG=chrome-os-partner:11938
TEST=Type a command longer than 80 char and press enter. Check console
is still alive.

Change-Id: Ib86c5f97cc12220ac62ab8855ef8e5c65ecd2d82
Reviewed-on: https://gerrit.chromium.org/gerrit/28679
Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
Tested-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-30 20:32:16 -07:00
Randall Spangler
2da2e72dd3 Add support for ACPI read/write commands
This is needed to support the kernel keyboard backlight driver through ACPI.

Also adds a few other memory addresses for testing this interface -
version, test, and test-compliment.

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

    - query next ACPI event
    io_write8 0x66 0x84
    io_read8 0x62
    0x00
    - read ACPI memmap version
    io_write8 0x66 0x80
    io_write8 0x62 0
    io_read8 0x62
    0x01
    - extra command writes shouldn't crash
    io_write8 0x66 0x80
    io_write8 0x66 0x80
    io_write8 0x62 1
    - extra data writes shouldn't crash either
    io_write8 0x62 1
    io_write8 0x62 1
    - write test address
    io_write8 0x66 0x81
    io_write8 0x62 1
    io_write8 0x62 0x2a
    - read it back
    io_write8 0x66 0x80
    io_write8 0x62 1
    io_read8 0x62
    0x2a
    - read back test compliment
    io_write8 0x66 0x80
    io_write8 0x62 2
    io_read8 0x62
    0xd5
    - set keyboard backlight to 50%
    io_write8 0x66 0x81
    io_write8 0x62 3
    io_write8 0x62 50
    - read it back
    io_write8 0x66 0x80
    io_write8 0x62 3
    io_read8 0x62
    0x32

Change-Id: I619fdbd322cdef8ffffbb882b3bbb587e364334d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28714
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
2012-07-30 15:22:41 -07:00
Charlie Mooney
7adb0aad16 Remove "Sticky" recovery mode on Daisy
Previously, if you used Esc + Reload + Power to reboot into recovery
mode, you would be stuck in it until you manually rebooted the EC with
"Reload + Power."  This was because the button combo set a switch that
was never un-set.  To fix it, the keyboard_scan function now sets a host
event, that is serviced once, and then cleared.  As a result, the next
time you reboot after triggering recovery mode, it should boot as before
you triggered recovery mode.

BUG=chrome-os-partner:10889
TEST=Boot device in normal mode.  Press Esc + Reload + Power, and boot
from usb.  Power off the device and remove the usb media.  Power on the
device again, and there should be no recovery screens during the boot
process.  Next, repeat these same steps, but from starting in developer
mode.  After recovery, when you reboot, the device should return to
developer mode.

Change-Id: Idcb8dde6f8ba5f680f4d34e61ae0d12992281cbb
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28710
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-30 14:33:51 -07:00
Randall Spangler
30b2bd27f6 Improve hostcmd command
Version and params fields are optional.
Output uses "%h" format code.

BUG=none
TEST=manual

    > hostcmd 0
    Response: 02000000
    > hostcmd 0 0
    Response: 02000000
    > hostcmd 0 1
    Command returned 6
    > hostcmd 1 0 10203040
    Response: 14233241

Change-Id: I8b3ff0f7d9a1131f942604724e04c59ff818396d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28705
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-30 14:15:03 -07:00
Sameer Nanda
c846102714 Add a userland thermal loop
This is a temporary hack to implement a userland thermal loop.  This
code really belongs in the BIOS and will move there once we have
gathered enough data to prove the efficacy (or otherwise) of doing such
throttling. So, please pardon the ugliness of the code -- it's meant to
be short-lived and therefore we wouldn't want to spend too much time on
optimizing it or making it pretty.

BUG=none
TEST="initctl start temp_metrics" and then monitor various parameters
such as CPU min/max frequency, GPU frequency, duty cycle and package
power limits to ensure they are doing the right thing.

Change-Id: I407e4826b4db801298f08fa72c4f2330e127322b
Signed-off-by: Sameer Nanda <snanda@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28634
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-07-30 14:15:03 -07:00
Randall Spangler
7d06db201f Enhance printf()
1. Add precision to limit string length.
   ccprintf("%.4s", "foobar") prints "foob"

2. Handle '*' for length, precision fields.
   ccprintf("%.*s", 3, "foobar") prints "foo"

3. Add hex-dump code "%h"
   ccprintf("%.*s", 4, "foobar") prints 666f6f62

BUG=none
TEST=at ec console, 'hash' prints the current hash

Change-Id: I568310f2727495b021081bf58df2a0bbb3c74e73
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28704
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-30 13:41:33 -07:00
Rong Chang
25e1ebf671 Revert "Enable snow I2C host auto detection"
This reverts commit 024c44cd96.
	board/snow/board.c
	board/snow/board.h

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:10622
TEST=build snow ec image without warning

Change-Id: I65660383873907722933b41249e17dd1f83d8fde
Reviewed-on: https://gerrit.chromium.org/gerrit/28698
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-07-30 08:49:01 -07:00
Rong Chang
709f6d8b2e Set TPSCHROME temp range configuration
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11627
TEST=manual
  Check pmu registers under uart console: "pmu"
  TPSCHROME version < 3:
    reg(7) == 0xbd
    reg(8) == 0xfd
  TPSCHROME version >= 3:
    reg(7) == 0xbf
    reg(8) == 0xff

Change-Id: Ifeda54aa142b362aa224575c55220913b0ee7436
Reviewed-on: https://gerrit.chromium.org/gerrit/28587
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-07-29 22:35:45 -07:00
Louis Yung-Chieh Lo
e533adccb7 The jtag_buf_en was not set.
The dut_control function only accepts the first parameter. Thus,
the jtag_buf_en:on is actually dropped in flash_link. This caused
flash_ec script failed sometimes.

BUG=None
TEST=tested on link.
util/flash_ec --board=link --image=...

Change-Id: Ib7f8cdcd651a573ad4bdc6e446f3c715dce29b71
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28569
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-07-26 23:11:30 -07:00
Vic Yang
314beee450 stm32: Add kbpress command
This command is needed by keyboard test.

BUG=chrome-os-partner:11747
TEST=Keyboard test passed.

Change-Id: I752f8a8f672f4ef2214ff60c8946a1a74745c586
Reviewed-on: https://gerrit.chromium.org/gerrit/28387
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-26 19:38:40 -07:00
Vic Yang
435bec37e2 Modify Gaia power message to match x86 power module
Message from power modules should be similar for easier testing.

BUG=chrome-os-partner:11815
TEST=none

Change-Id: I07e061a34e7d8f8c1f1547d6e15f22f29ee22b84
Reviewed-on: https://gerrit.chromium.org/gerrit/28394
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-26 18:51:46 -07:00
Vic Yang
00799d5bc1 stm32f: Flash write protect
Implement STM32F write protect to match refactored flash module.
Also move fake write-protect pin to use backup register to preserve
value across reboot.

BUG=chrome-os-partner:11699
TEST=1. 'flashinfo'      -> no flags
     2. 'fakewp 1'       -> 'wp_gpio_asserted'
     3. 'flashwp enable' -> 'wp_gpio_asserted ro_at_boot'
     4. 'reboot'         -> 'wp_gpio_asserted ro_at_boot ro_now'
     5. 'fakewp 0'       -> 'ro_at_boot ro_now'
     6. 'reboot'         -> 'ro_at_boot'
     7. 'fakewp 1'       -> 'wp_gpio_asserted ro_at_boot'
     8. 'flashwp rw'     -> 'wp_gpio_asserted ro_at_boot rw_at_boot'
     9. 'reboot'         -> 'wp_gpio_asserted ro_at_boot ro_now
                             rw_at_boot rw_now'
     10.'flashwp disable'-> error 7
     11.'flashwp norw'   -> 'wp_gpio_asserted ro_at_boot ro_now rw_now'
     12.'reboot'         -> 'wp_gpio_asserted ro_at_boot ro_now'

Change-Id: I40405c266e30b10793ccae2f1d26fb9710ce304b
Reviewed-on: https://gerrit.chromium.org/gerrit/28372
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-26 18:28:14 -07:00
Charlie Mooney
82cd5b0daa Stop keyboard scans from triggering ARM EC reset
The ARM EC was being rebooted when both the power and one of several other keys
were pressed. (LCtrl, Tab, Reload, t, [, ], y, Dim Screen and Mute) It should
only do this when the key combo PWR + Reload is pressed.

To fix it, keyboard scanning is disabled whenever the power button is
pressed.  It locks a mutex indicating that scanning should be disabled,
and the main keyboard scanning task blocks on the step where it sets up
the keyboard and waits for the mutex to unlock.

BUG=chrome-os-partner:10889
TEST=Pick one of the troublesome keys.  First press it, then quickly
press the power button.  Then press the power button followed
by the troublesome key.  Repeat this process several times for each key,
it should not reset the system.
Press power + reload, this should still reset the system.
Pressing and holding power should initiate a shutdown.

Change-Id: Ib60d2ebbb57eb8a3c135662514ec622c37a7eb07
Signed-off-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28402
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2012-07-26 16:50:10 -07:00
Randall Spangler
247fdaf13d Change host command params/response pointers to void *
This removes a bunch of unnecessary typecasts, since you can assign
to/from void * without them.  This also uncovered a few cases where
const was being cast away for the input params; now fixed.

BUG=none
TEST=mkbp hash from u-boot console, and/or system boots ok

Change-Id: Ic314b9d2ca06226ea8a09703ef5c1a912eb7146d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28500
2012-07-26 16:25:34 -07:00
Louis Yung-Chieh Lo
d0d50b6da7 Change some FMAP area_offset to be related to the start of flash.
The area_offset of following area are wrong which is related to the CPU
view in the STM32 chip:

  FMAP
  RO_FRID
  RW_FWID

Add a macro RELATIVE() to calculate the real offset in flash.

BUG=chrome-os-partner:11269
TEST=build in chroot for link and snow.
Those fmap afddress are related to the start of flash.

Change-Id: I691814e2f53b1de0ecf9fd385bed8d5c598373a7
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28388
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
2012-07-25 21:52:04 -07:00
Randall Spangler
3cc4745be2 Don't protect firmware now if protect-ro-at-boot is not set
Otherwise, EC software sync protects the entire firmware except in recovery mode, regardless of the WP pin.

BUG=chrome-os-partner:11847
TEST=boot with WP enabled but RO-at-boot disabled; flashinfo should show
entire flash still writable

CQ-DEPEND=28444

Change-Id: I58d60adfaa952b127e8695213f95f6da0e34821d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28445
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-25 18:07:17 -07:00
Vincent Palatin
36a3989fc4 don't crash when receiving ACPI query on legacy channel
When updating the EC and BIOS, we have to run for some times the new EC
with the old BIOS (after we have upgraded the first half of the EC and
before rebooting the machine), let's handle the ACPI request so the
kernel is not sending them into a loop triggering a reboot of the
machine.

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

BUG=chrome-os-partner:11821
TEST=update a Link EVT using "chromeos-firmware --mode=factory" from
current BCS binaries (EC v1.1.104-b8d7d8f / Firmware 2476) to next
candidates ( EC v1.1.301 / Firmware 2657).

Change-Id: I115a42e6c33c143cbdc38341dcf7e0f61a8bd771
Reviewed-on: https://gerrit.chromium.org/gerrit/28409
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-07-25 13:40:56 -07:00
Luigi Semenzato
0e82420f12 Add upstart script to collect temperature statistics.
This is used only in selected platforms, and installed
by the temp-metrics package in the private overlay for
those platforms.

BUG=chrome-os-partner:11631
TEST=manually using about:histograms
Signed-off-by: Luigi Semenzato <semenzato@chromium.org>

Change-Id: I89dffed6aa34d683ff78a360988fdfb84c2dc641
Reviewed-on: https://gerrit.chromium.org/gerrit/28311
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
Commit-Ready: Luigi Semenzato <semenzato@chromium.org>
2012-07-25 09:49:02 -07:00
Louis Yung-Chieh Lo
89f6448982 Change the path check of --image in util/flash_ec.
BUG=None
TEST=test on link.
% util/flash_ec --board=link --image=a/random/file/path
flash successfully.

Change-Id: I82980783585ac7d2979cf195b7eb820dbf072156
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28252
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-07-24 23:05:17 -07:00
Randall Spangler
f94f8a01e1 Fix order of init hooks so chipset is called before power button
BUG=chrome-os-partner:11779
TEST=manual

1. power on system
2. sysjump RW
3. system should stay powered on

Change-Id: Idf238c0567daa6137324e91e58279329865a2d42
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28346
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
2012-07-24 22:32:03 -07:00
Louis Yung-Chieh Lo
3ab8ed4124 Add RW offset query interface (EC_CMD_FLASH_RW_OFFSET).
BUG=chrome-os-partner:11149
TEST=build only.

Originally-Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Change-Id: I35ad1e0a49c95a2d6cffbe49b2013a1b8050aabc
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28166
2012-07-24 17:38:10 -07:00
Vic Yang
7884868846 Set correct name for new TMP006 sensors
BUG=chrome-os-partner:11491
TEST=none

Change-Id: I00a59554fb5819c0942d917f8d558c1a00570a73
Reviewed-on: https://gerrit.chromium.org/gerrit/28251
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-24 17:38:09 -07:00
Luigi Semenzato
8c4ce35fbe Add "all" command for sensor temperatures and sensor info.
This change makes it easier and less costly for the metrics daemon
to collect sensor temperatures.

BUG=chrome-os-partner:11631
TEST=manually verified that it works as expected

Signed-off-by: Luigi Semenzato <semenzato@google.com>

Change-Id: Iee7ca971f53d65f07589173322b55b0d87ab5363
Reviewed-on: https://gerrit.chromium.org/gerrit/28026
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Luigi Semenzato <semenzato@chromium.org>
Tested-by: Luigi Semenzato <semenzato@chromium.org>
2012-07-24 17:02:25 -07:00