Commit Graph

1012 Commits

Author SHA1 Message Date
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
Vic Yang
c26eb30863 stm32f: Fix some error in flash write protect
And also add a fake write protect pin command for futher development and
testing.

BUG=chrome-os-partner:11595
TEST=Enable pstate read/write for stm32f.
      1. 'flashinfo' -> WP pin deasserted. No blocks protected.
      2. 'flashwp enable' -> Nothing changes.
      3. 'fakewp 1'; 'flashinfo' -> WP pin asserted. No blocks
         protected.
      4. 'flashwp enable'; 'flashinfo' -> RO protected.

Change-Id: Id5b1997442d9104d9cb254a295e0bd2f8c83bc78
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28062
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-21 21:47:52 -07:00
Vic Yang
dde4e99faa Prevent parallel make from failing
When we do parallel 'make', it fails intermittently. We might be hitting
a make bug: http://savannah.gnu.org/bugs/?30653
Let's remove the intermediate file for now and see if this happens
again.

BUG=chrome-os-partner:11614
TEST=Repeatedly remove some file and parallel make. This originally
gave an error once every two time. It doesn't now.

Change-Id: Iaaf48e7d19b11dad30bc70cd50e73c195caf17b4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28105
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-07-20 18:57:06 -07:00
David Hendricks
1911400b8b daisy/snow: enable SUSPEND_L interrupt
This enables interrupts on SUSPEND_L.

Signed-off-by: David Hendricks <dhendrix@chromium.org>
BUG=none
TEST=Power LED on Snow throbs when powerd_suspend is used

Change-Id: I5f06e717ddc07d5c2f129ff59a108131da8dbf87
Reviewed-on: https://gerrit.chromium.org/gerrit/27968
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2012-07-19 20:41:54 -07:00
Vincent Palatin
f9c2d375c3 link: update fan policy
As per James advice :
- increase fan speed at low temperature up to maximum "silent RPM",
this will give us more margin for later operations.
- lower the maximum fan RPM threshold to 86 C to try to lower CPU
  temperature impact on skin temp.
- do not take into account "object" temp sensors, they are too random
  at the moment.

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

BUG=None
TEST=adhoc

Change-Id: I3b60570e33f82e4015c6588d9e2ae538a33ad14f
Reviewed-on: https://gerrit.chromium.org/gerrit/27921
Reviewed-by: Sameer Nanda <snanda@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-07-19 20:41:53 -07:00
Vic Yang
3036dcdb1e stm32f: Support hard reset
Now that we have hibernate ability, we can use this to perform a hard
reset.

BUG=chrome-os-partner:11579
TEST=Build success and working on 'snow':
       'reboot' and see reset cause is 'reset-pin soft'.
       'reboot hard' and see reset cause is 'hard'.
     Build success on 'daisy'.

Change-Id: I18132eee2f0d574d7d1674f7be25249dbe19749d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27930
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-19 17:01:55 -07:00
Vic Yang
b58c424a65 stm32f: Add hibernate support
This adds hibernate support to stm32f. Watchdog can wake us but cannot
be stopped unless system resets, so the longest time we can hibernate
for now is about 26s. And wake from wake pin is not working.
Nevertheless, we can use this for hard reset for now, and fix these
problems later.

BUG=chrome-os-partner:11579
TEST='hibernate 1' and see system wakes after 1 second. See reset cause
is 'hibernate'.

Change-Id: Iafa42012b59c12b70e18a7908c5d864c6e8bd2b4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27909
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-19 15:53:44 -07:00
Randall Spangler
e5bdf41f39 Add interface to charge_state for lightbar
Use these functions to get charging state and battery percent.  Use
power_ac_present() from power_button.h to find out if AC adapter is present.

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

Change-Id: Ied670c297be316b0b8fa56a450a1566470099b5b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27830
2012-07-19 11:35:21 -07:00
Vic Yang
812a58825f stm32: Support backup registers and preseving reset flags
This CL configures backup registers and add support of preseving reset
flags in backup registers before rebooting.

BUG=chrome-os-partner:11368
TEST=On snow there's always a reset-pin flag now, so test this with
     watchdog and soft reset.

1. reset with keyboard.    flags -> reset-pin
2. trigger watchdog reset. flags -> reset-pin watchdog
3. 'reboot soft preserve'  flags -> reset-pin watchdog soft
4. trigger watchdog reset. flags -> reset-pin watchdog
5. 'reboot soft'           flags -> reset-pin soft

Change-Id: I8b8a8abfbd69d8abb3386b188af73b9f662f4b38
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27848
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-19 11:35:19 -07:00
Duncan Laurie
a788fffd24 Disable keyboard backlight on suspend entry
In theory this should be done by a kernel driver,
but there is already a suspend hook so it is easy
to have the EC turn off the backlight if it is
not done by the host.

BUG=none
TEST=manual

1) boot Link device
2) log in and run 'powerd_suspend'
3) observe that keyboard backlight is turned off

Change-Id: I10b83505d681f5b6d9cb32c1bef62dc21dd038e1
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27721
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-07-19 09:59:13 -07:00
Vic Yang
c51466d0d0 Add host command to exit force idle charge state
Currently the only way to exit force idle state is to unplug AC power.
Let's add a host command to do so.

Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:9716
TEST=# ectool chargeforceidle 0
     - Check nothing happened
     # ectool chargeforceidle 1
     - Power LED blinking green. Check current = 0.
     # ectool chargeforceidle 0
     - Power LED back to yellow. Check charging.

Change-Id: Ia8f504b6cf9f42b7d57af3ce2d240f3b00a095f1
Reviewed-on: https://gerrit.chromium.org/gerrit/27768
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-18 22:36:42 -07:00
Vic Yang
35c349cca3 Add new TMP006 sensors
Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=chrome-os-partner:11491
TEST=Build success. System still works fine except with error when
reading currently non-existing sensors.

Change-Id: I2fa1298ab11296f8b492534b5a8893588df34c82
Reviewed-on: https://gerrit.chromium.org/gerrit/27766
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-18 22:36:40 -07:00