Commit Graph

1023 Commits

Author SHA1 Message Date
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
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
187ea8f4ea hash command without args prints current hash
BUG=none
TEST=hash -> prints offset, size, (digest or in-progress)

Change-Id: Ic21319c522811b3b73ace3538adb5dda0e6324c2
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28301
2012-07-24 15:55:30 -07:00
Simon Glass
2de38e81a2 Revert "Revert "i2c: Support command version numbers""
This reverts commit 3bb4c6acf4ff327f956ee5e1b6deefcd84dc8fbb

Change-Id: I690baa9bcc0229502c103fc31314170bbc825f65
Reviewed-on: https://gerrit.chromium.org/gerrit/28189
Commit-Ready: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
2012-07-24 11:26:57 -07:00
Simon Glass
3120c479ec Revert "Revert "i2c: Move host command processing into a function""
This reverts commit 353bc6826033c0681394f0c49701dd5678422a0c

Change-Id: I9c7d7264db158f242b9b869f903e57b111d6f2c5
Reviewed-on: https://gerrit.chromium.org/gerrit/28188
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
2012-07-23 23:55:53 -07:00
Randall Spangler
1661f1cef0 Refactor flash module
This is a significant rewrite of the flash module, since it turns out
that much less of the flash logic is actually common between stm32 and
lm4.

BUG=chrome-os-partner:11699
TEST=on link,

(enable hardware wp)
flashinfo -> wp_gpio_asserted
flashwp enable
flashinfo -> wp_gpio_asserted ro_at_boot
reboot
flashinfo -> wp_gpio_asserted ro_at_boot ro_now
flashwp disable -> error 7
flashwp now
flashinfo -> wp_gpio_asserted ro_at_boot ro_now rw_now
reboot
flashinfo -> wp_gpio_asserted ro_at_boot ro_now
(disable hardware wp)
reboot
flashinfo -> ro_at_boot
flashwp disable
flashinfo -> (no flags)

Change-Id: If22b02373946ce1c080d49ccded4f8fa3e380115
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28200
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-07-23 23:30:33 -07:00
Vic Yang
0653aa011a Add console command to inject host command
For easier testing.

BUG=chrome-os-partner:11350
TEST=Try host command 0x01=CMD_HELLO.
      > hostcmd 0x01 0 00000000
      04030201
      > hostcmd 0x01 0 01020304
      05050505

Change-Id: I18becbd7d26241fa673fd46d9ce23a984ac47026
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28059
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-23 18:13:58 -07:00
Bill Richardson
97131838e8 Implement something close to final lightbar code.
BUG=chrome-os-partner:8039
TEST=manual

Boot the system, look at the lightbar. It should pulse colors slowly on
battery, faster on AC.

Change-Id: I0184973d11eda51db87d652aa2c92995f5a25588
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27810
2012-07-23 14:15:47 -07:00
Simon Glass
6147b158d5 host_command: Add send_result() to the arg structure
It's a bit odd that the drivers package up a command to be processed
by host_command, but then host_command calls a global function to
pass the response back.

This adds ambiguity in the host_send_response() implementations as to
whether the command being responded to really is using the same
buffers that the driver set up.

Add a function pointer to the command, and have host_command call
that. Add status to the args structure also, which removes some of
the special case logic for error handling.

BUG=chrome-os-partner:11317
TEST=manual and a bit ad-hoc:
(note, this testing is not completed yet)
Check that snow and link still process commands correctly over I2C
from U-Boot. At this stage only the old interface is supported.
SMDK5250 # mkbp test
Old interface:

New interface:
Version 0: ec_command() returned error
Test failed with error -1
SMDK5250 #

Change-Id: I816738150bce3f8d78e7cd32abf361621aa12312
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28154
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-23 13:23:06 -07:00
Bill Richardson
ff57dbce86 bitrot: disable VBOOT_SIG for BDS. It's broken.
BDS has been slowly rotting as we make changes for Link. I haven't been able
to test the BDS image for some time (I think due to openocd updates that no
longer like the BDS configs), and now it doesn't even compile. This is
gating the Link schedule, so I'm just turning it off. If we ever need the
BDS again, well, what fun.

BUG=none
TEST=none

It already doesn't work, so it should continue to not work.

Change-Id: I2b365623903590a56948dfceb986a2300699f541
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28181
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-23 13:23:05 -07:00
Randall Spangler
e27e2f0229 Add console functionality
Keys I keep hitting should work like I expect them to.

Home or Ctrl+A = move to beginning of line
End or Ctrl+E = move to end of line
Del = delete-right
Ctrl+K = delete to end of line
Ctrl+L = clear screen and reprint current line
Ctrl+N = next command
Ctrl+P = previous command

Also, improve filtering of escape sequences and non-printable
characters, so hitting unsupported keys or control codes doesn't mess
up the current line of input.

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

  type 'fhelpbar'
  home -> cursor moves to beginning of line
  Ctrl+E -> cursor moves to end of line
  Ctrl+A -> cursor moves to beginning of line
    (of course, if you're using Minicom, you'll need to type Ctrl+A A, since
     Minicom uses Ctrl+A as its control key)
  del -> 'helpbar'
  end -> cursor moves to end of line
  left-arrow 3 times -> cursor moves under 'b'
  Ctrl+L -> screen clears, cursor still under 'b'
  Ctrl+K -> 'help'
  Ctrl+Y Page-Up Page-Down -> nothing printed
  enter -> prints known commands (output of 'help' command)
  Ctrl+P -> 'help'
  Ctrl+N -> empty command line

Change-Id: Id893c93b26db8f3deed6ea8be5aab88a3daaead4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28143
2012-07-23 11:03:33 -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
93f2e82133 Fix unit tests not compiling for link
BUG=none
TEST=make link tests

Change-Id: I678b927d068bd7f1f43115a4495c16902588faa7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28140
2012-07-23 11:03:32 -07:00
Hung-Te Lin
7693bbd2e4 ec: Remove "_A" suffix in FMAP RW firmware areas.
Since we only have one RW firmware, let's remove _A to prevent confusion.
Also change "BOOT_STUB" to FR_MAIN to reflect the fact that it's not just
bootstub - it's a full firmware area just like FW_MAIN.

BUG=chrome-os-partner:11360
TEST=emerge-link chromeos-ec; dump_fmap -x /build/link/firmware/ec.bin

Change-Id: Ia84062ada5959164b2b4e0f9cc5fcc032ca6f71e
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27971
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2012-07-23 03:38:52 -07:00
Randall Spangler
ee71c0ae1b Revert "host_command: Add send_result() to the arg structure"
This reverts commit 18db93b25b05c871826fd1853a33a560e64ed247

Breaks link checksums.

Change-Id: Ieeb278b7d4da0600bdc9ced1476b67f23abce1a1
Reviewed-on: https://gerrit.chromium.org/gerrit/28136
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2012-07-22 13:17:04 -07:00
Randall Spangler
5fdf655b12 Revert "i2c: Move host command processing into a function"
This reverts commit b2772df970e422e7e31731d38813ee57635c8058

Dependent on reverted change.

Change-Id: I353bc6826033c0681394f0c49701dd5678422a0c
Reviewed-on: https://gerrit.chromium.org/gerrit/28137
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2012-07-22 13:17:03 -07:00
Randall Spangler
fbfc353cef Revert "i2c: Support command version numbers"
This reverts commit b983290238458f88a897ce3cfb06faae9ec79a40

Dependent on reverted change.

Change-Id: I3bb4c6acf4ff327f956ee5e1b6deefcd84dc8fbb
Reviewed-on: https://gerrit.chromium.org/gerrit/28138
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2012-07-22 13:17:03 -07:00
Randall Spangler
7143c4544c Clean up ectool
Assorted minor cleanup; make protocol a bit more efficient, and add a
missing line of output to flash protect status.

BUG=none
TEST=ectool flashprotect; should print valid bits = 0x3f on link

Change-Id: I9bea78506b3ed367df731d358982d3e2febb13af
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28097
Reviewed-by: Vic Yang <victoryang@chromium.org>
2012-07-22 13:17:03 -07:00
Randall Spangler
360d91573a Support up to 24 thermal sensors
And tidy reporting fan/thermal via memmap.

BUG=chrome-os-partner:11628
TEST=manual
  ectool pwmgetfanrpm -> should report fan speed
  ectool temps N ->
    should work for N=0-9
    reports error for N=15-23
    reports invalid sensor ID for N<0 or N>23

Change-Id: I484f81399f5e9dae9c759401091cc6f5acc733ff
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28032
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-22 13:17:02 -07:00
Simon Glass
bff14cac0b i2c: Support command version numbers
Currently, I2C commands look like this:

Input:
  cmd8 [params bytes] checksum
Output:
  response8 [response_ptr bytes] checksum

Use a prefix byte of (0xDC + cmd_version) to indicate the command
version.  This is compatible with the existing protocol, since there
are no host commands in the range 0xDC-0xFB.  If the first byte of
the from-host data is 0x00-0xDB, it's a version 0 command.

There is no change to the output format, since the EC needs to hand
back a response which matches the version requested by the host.

New input:
  (0xDC+ver8) cmd8 paramlen8 [params bytes] checksum
New output:
  response8 responselen8 [response_ptr bytes] checksum

If the host gets a response of EC_RES_INVALID_COMMAND, it knows it's
talking to an old EC, and at most version 0 of the command is supported.

BUG=chrome-os-partner:11317
TEST=manual and a bit ad-hoc:
(note, this testing is not completed yet, so far only snow is tested)
Check that snow and link still process commands correctly over I2C
from U-Boot.
SMDK5250 # mkbp test
Old interface:

New interface:
Test passed

Change-Id: I1c21f2b036091e9122b4f980ca5f5af34f7fc070
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27470
2012-07-22 00:36:39 -07:00
Simon Glass
37a6387fa9 i2c: Move host command processing into a function
We are about to add more logic here, so move it this code out of
the event handler and into its own function.

BUG=chrome-os-partner:11317
TEST=manual and a bit ad-hoc:
(note, this testing is not completed yet)
Check that snow and link still process commands correctly over I2C
from U-Boot. At this stage only the old interface is supported.
SMDK5250 # mkbp test
Old interface:

New interface:
Version 0: ec_command() returned error
Test failed with error -1
SMDK5250 #

Change-Id: I5387eb5533ab6faa27769f4cf21075387357371d
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27469
2012-07-22 00:36:39 -07:00
Simon Glass
949d525e2a host_command: Add send_result() to the arg structure
It's a bit odd that the drivers package up a command to be processed
by host_command, but then host_command calls a global function to
pass the response back.

This adds ambiguity in the host_send_response() implementations as to
whether the command being responded to really is using the same
buffers that the driver set up.

Add a function pointer to the command, and have host_command call
that. Add status to the args structure also, which removes some of
the special case logic for error handling.

BUG=chrome-os-partner:11317
TEST=manual and a bit ad-hoc:
(note, this testing is not completed yet)
Check that snow and link still process commands correctly over I2C
from U-Boot. At this stage only the old interface is supported.
SMDK5250 # mkbp test
Old interface:

New interface:
Version 0: ec_command() returned error
Test failed with error -1
SMDK5250 #

Change-Id: Ic4afdcd7689666cc0f6af228abc6cffe41b0fcbf
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27468
2012-07-22 00:36:39 -07:00