Commit Graph

932 Commits

Author SHA1 Message Date
Randall Spangler
acf6f963a1 Flash pre-init reboots if it needs to clear protection registers
BUG=chrome-os-partner:11171
TEST=manual

1. Clear some of the writable-bits in the flash registers
> ww 0x400fe40c 0xffff1234
write 0x400fe40c = 0xffff1234
> rw 0x400fe40c
read 0x400fe40c = 0xffff1234
2. Reset using power+refresh
3. Register should be clear again
> rw 0x400fe40c
read 0x400fe40c = 0xffffffff
4. Sysinfo should indicate reset-pin reason AND hard-reset reason
> sysinfo
Reset flags: 0x0000000a (reset-pin power-on)
5. Reset using power+refresh
6. Sysinfo should indicate reset-pin reason only
> sysinfo
Reset flags: 0x00000002 (reset-pin)
7. Clear writable-bits again
> ww 0x400fe40c 0xffff1234
write 0x400fe40c = 0xffff1234
8. Jump to another image.  This should NOT trigger a hard reset.
> sysjump A
> sysinfo
Reset flags: 0x00000402 (reset-pin sysjump)

Change-Id: Ie1d6af2acc68217bb82faae464798ee85d63d1ea
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27540
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-16 17:49:10 -07:00
Duncan Laurie
a42edb86c5 Print console messages for overtemp and shutdown
I have a system with bad temperature sensors and the EC is
constantly shutting the system down, but provides no
visible indication that it is doing so.

I have serious concerns about the EC behavior in this case
as it seems to be doing things it shouldn't.  However just
providing indication via the console about what it is doing
is at least useful for development and debug.

BUG=none
TEST=boot on system with bad temp sensors and see that
the EC indicates it is initiating a shutdown.

[14.008340 critical temperature; shutting down]
[14.008660 x86 power force shutdown]
[14.009153 LPC RESET# asserted]

Change-Id: I6beeb269a135bd8c245c0357670fe29648d48968
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27553
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-16 17:49:10 -07:00
Randall Spangler
0e6daeb6ab Fix return code from ectool
lbplay and burn_my_ec didn't have this problem.

BUG=chrome-os-partner:11402
TEST=ectool lightbar init && echo $?
Should echo 0

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

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

Use reboot and sysinfo commands...

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

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

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

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

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

Change-Id: Icbbdbcf6dfd13c8a6a4f80a23f64cebebbfba26e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27417
2012-07-16 10:17:09 -07:00
Randall Spangler
1dc7241e3a Use openocd auto-erase when writing flash, and use sysresetreq to reset
According to its datasheet, LM4 doesn't support vectreset, but does
support sysresetreq.  Using sysresetreq properly resets all
peripherals and cleanly resets the LM4.

Auto-erase makes the flash command faster.

BUG=none
TEST=flash_link_ro, flash_link_a, flash_link, all with different images

Change-Id: I80b72de2ee0f42cee1b0f2f2a53062384d2c29aa
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27416
2012-07-16 10:16:00 -07:00
Randall Spangler
c1701c4f07 Refactor HIBDATA access so we can use multiple hibernate regs
BUG=chrome-os-partner:11368
TEST=none

Change-Id: I33ba317ce1cff957add7ebe34860fa4a3c686ca0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27380
2012-07-16 09:49:40 -07:00
Rong Chang
3b0e13173d Debounce charging voltage when cross 8.0V
Link battery pack specification suggested a lower charging current
when voltage pass 8.0V. But the lowering the current in constant
current phase leads voltage drop. And the battery goes back to
high current zone, < 8.0V.

This CL adds a 10 seconds debounce time to prevent charging current
change too quickly.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:9572
TEST=manual
  watch battery V+ on oscilloscope when charging voltage cross 8.0V

Change-Id: I002f941e33b029e38f813ab2e292c6b73a054352
Reviewed-on: https://gerrit.chromium.org/gerrit/27275
Commit-Ready: Rong Chang <rongchang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-07-15 22:01:14 -07:00
Randall Spangler
e95813c34f Define __packed inside ec_commands.h
Kernel and U-boot define it elsewhere, but coreboot doesn't.  So put
it here for greatest compatibility.

BUG=none
TEST=if it builds it works

Change-Id: I595910e9198e37bc97d23cd4c249454e1ed64cd8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27375
2012-07-13 17:28:22 -07:00
Bill Richardson
114b7010b6 Security fix: bounds check in vboot_hash_start()
Changed the parameters from int to uint32_t (which is how it was called
anyway).

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

No visible change. Nothing should break.

Change-Id: I4fbe34f67df7d37f5039987a7a89e626916d6eb6
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27382
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-13 15:24:18 -07:00
Bill Richardson
1b02654e62 Security fix: check lightbar_sequence num param
Make sure that a negative 'num' param won't be accepted if passed by a
malicious caller.

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

No visible changes, everything should continue to work.

Change-Id: I8128d24adc99e5ff954a6b8065e1bfa8bf20630e
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27386
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-13 15:24:17 -07:00
Bill Richardson
280aeb754d Security fix: validate index in controller_write()
Make sure it doesn't run off the end of the I2C device list.

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

No visible changes. Everything should continue to work.

Change-Id: I43182361cda6be578e57acef01afb27260cea80a
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27390
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-07-13 15:24:17 -07:00
Simon Glass
0939fffdeb charger: Add delay in tasker task to avoid lockup
The charger task relies on calc_next_state() performing a delay before
returning. My reading of the code suggests that this doesn't happen
always. For example:

When pre-charging:

		if (battery_temperature(&batt_temp) == EC_SUCCESS)
			return ST_CHARGING;

When discharging and capacity is low:

		/* Check remaining charge % */
		if (battery_state_of_charge(&capacity) == 0 && capacity < 10)
			return notify_battery_low();

I would like to suggest that the code be refactored to more like:

int next_checkms = 5000;  /* next time to check battery */

while (1) {
    int action = ACTION_NONE;

	err = get_state(&state);
	if (!err) {
	   action = calculate_action(&state);
	   err = perform_action(action, &next_check_ms);
    }

	usleep(next_check_ms * 1000);
}

so that the delays are really clear, the state is all read at once,
there is no reliance on earlier state, and we always delay even on
error.

In the meantime, this CL inserts a mandatory 5 second delay in the
loop, which should prevent the charger task lockup.

BUG=chrome-os-partner:11285
TEST=manual
(please do this test before committing)
1. boot to kernel, see that battery can be seen
2. suspend and resume device
3. see that the charger loop does not cause an EC watchdog reset and
AP power off/reset. There should be no watchdog warning message on the
EC console.

Change-Id: I141e374933c4dc0ec60bcdccf96443f57067c585
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27353
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Katie Roberts-Hoffman <katierh@chromium.org>
Commit-Ready: Katie Roberts-Hoffman <katierh@chromium.org>
2012-07-13 13:06:16 -07:00
Vic Yang
37f19ecc84 Add GPIO get/set host command
These commands are used in factory test. If system is locked, GPIO
commands are disabled for security reason.

BUG=chrome-os-partner:11164
TEST= - 'ectool gpioget enable_backlight' gives 1.
      - 'ectool gpioset enable_backlight 0' turns off display.
      - Lock system. Check these commands return error.

Change-Id: I3ea41285075ebe963ba7d30e4ae183cef9b1c105
Reviewed-on: https://gerrit.chromium.org/gerrit/27019
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-13 12:24:00 -07:00
Vic Yang
dbefb29f02 Fix unit tests
Recently, there have been several changes to LPC and host command modules.
This CL fixes unit tests after these changes.

BUG=none
TEST=All test passed.

Change-Id: I263716899af78a61e324fcd0b2636b948617a264
Reviewed-on: https://gerrit.chromium.org/gerrit/27354
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-13 02:10:46 -07:00
Vic Yang
1bd6146892 Add a test of flash read/write/erase test
This test checks physical read/write/erase functions are called
correctly.

BUG=chrome-os-partner:10261
TEST=Test passed.

Change-Id: Iff58f352bd732a0da9b7b7fe68c4bf87c84906a8
Reviewed-on: https://gerrit.chromium.org/gerrit/27144
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-13 01:13:20 -07:00
Vic Yang
23d031343f Add a host command to force charge state in IDLE mode
This command should only be accessible when flash write protect is
unlocked.

BUG=chrome-os-partner:9716
TEST= - Check we can charge and discharge normally.
      - Connect AC and force idle. Check battery current is 0 mA.

Change-Id: I74a318c1f5562d6a23b722736615fd1f883dc35a
Reviewed-on: https://gerrit.chromium.org/gerrit/27259
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-12 21:08:09 -07:00
Randall Spangler
8c701a7100 Add keyboard recovery event
This is set when the EC boots and sees the recovery key combo.

This is preferable to the memmap'd keyboard recovery switch, which the
host has no way of clearing.  The idea is that the host RO firmware
reads this event and sets the recovery reason.

I will be removing the memmap'd keyboard recovery switch once U-boot
and coreboot check this new event.

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

1. power+esc+refresh; should see this even in EC log
  [0.000838 event set 0x00004000]
(time of event may vary)

2. reboot EC; should NOT see the event

Change-Id: Id0672749f63c5022624a72ec91d30dcadfea5ef8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27328
2012-07-12 18:23:36 -07:00
Randall Spangler
a3701639fc Add ectool support for get/clear event B flags
BUG=chrome-os-partner:11172
TEST=from root shell
eventget b -> 0x2088
eventclear b 0x80
eventget b -> 0x2008

Change-Id: Ic0ad6475f2b770522b50b51f6695c6ea77ced19a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27322
2012-07-12 18:22:50 -07:00
Randall Spangler
7946a3eb3d Simplify host event processing
Now both copies of the event state live in host_event_commands.c, and
lpc / memmap just shadows the main copy.

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

Boot system.  should see events 0x2000, 0x80, 0x08 get set and then cleared.

At U-boot prompt, type on keyboard.  Should set event 0x1000 get set,
but only on the first keypress (because U-boot doesn't consume that
event).

Then from EC console,
hostevent clear 0x1000 -> see event 0x1000 clear
hostevent clear 0x1000 -> no debug output (it's already clear)
hostevent clearb 0x1000 -> see event copy B 0x1000 clear
hostevent clearb 0x1000 -> no debug output (copy B is already clear)

Change-Id: I855c035865649ba1490cd9027157d5bcdcc9895f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27321
2012-07-12 18:22:24 -07:00
Randall Spangler
89049421a6 Add second copy of event state
U-boot and ectool need this to see what events have occurred, in a way
which doesn't conflict with ACPI/SCI/SMI.

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

- boot EC
- look at event set / event clear debug output; that's for copy A
- from ec console,
   hostevent -> events=0, events-B = 0x2088
   hostevent clearb 0x2000 -> events-B = 0x88

Change-Id: If842b157914426df593d82af2bfb08a923caa34b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27317
2012-07-12 18:21:32 -07:00
Randall Spangler
02d820786c Support new-style LPC command interface in EC, ectool
Both EC and ectool are still backwards-compatible to the old interface.

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

From U-boot prompt: mkbp hash  // test old host talking to new EC
From root shell: ectool echash // test new host talking to new EC

You can also update just the OS and use an old EC, and verify that
'ectool echash' still works, which tests a new host talking to an old
EC.

Change-Id: I2afbb208cb16836f842ba119b74b1ab6a38ce5d5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27313
2012-07-12 18:10:30 -07:00
Randall Spangler
c304ff7d81 Use response pointer and size from host command args struct
Saves 2 params being passed around needlessly.

BUG=chrome-os-partner:11275
TEST=mkbp hash from u-boot console should still work

Change-Id: I958e4a09f16413e4d051e278dc0384aa9b791aa4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27312
2012-07-12 15:50:14 -07:00
Randall Spangler
c171fbe3dc Map 256 bytes of data for host command args/params
And retain compatibility for old requests.

BUG=chrome-os-partner:11275
TEST=from u-boot prompt, 'mkbp hash'
from root shell, 'ectool flashread 0 68084 /tmp/foo'
then compare to first 68084 bytes of ec.bin

Change-Id: Id82068773703543febde79fc820af7486502e01f
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27226
2012-07-12 14:48:50 -07:00
Randall Spangler
02f0ad7ea8 Pass maximum size of response buffer in via host command handler args
BUG=chrome-os-partner:11275
TEST=from u-boot prompt, 'mkbp hash'

Change-Id: I4cf37acfdd8e4edfe2cb6259b0fc6d0860ef0f79
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27225
2012-07-12 11:32:06 -07:00
Randall Spangler
347b5062a4 Initialize memory mapped data and add data versions
BUG=chrome-os-partner:11275
TEST=manual

localhost ~ # io_read8 0x920
0x45 // 'E'
localhost ~ # io_read8 0x921
0x43 // 'C'
localhost ~ # io_read8 0x922
0x01 // version 1
localhost ~ # io_read8 0x9fe
0x00 // unused data initialized to 0

Change-Id: If8de85ddc0e5f99b7c4213214d4b2d30b1439da8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27196
2012-07-12 11:32:06 -07:00
Vic Yang
0398874210 Add I2C read/write host command
These commands are only available when system is unlocked.

BUG=chrome-os-partner:9716
TEST=When system is unlocked, check we can read/write I2C bus.
     When system is locked, check the commands return error.

Change-Id: I8c4a8a42ab13d62c7e47bf33e2a7abc6f61e43fa
Reviewed-on: https://gerrit.chromium.org/gerrit/27254
Reviewed-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-12 02:35:21 -07:00
Rong Chang
54d14bf3fa Rename battery pack file and limit trickle charging current
The spec of link internal battery pack changed. This CL adds
parameter for new pack, and renames vendor specific source file
accordingly.

The new trickle charging current limit should fix the slow
pre-charging issue.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11298,10201
TEST=manual
  The minimum trickle charging current should be very close to
  0.01 C (85mA). Previous battery pack firmware uses 5mA in pre-
  charging.

Change-Id: I0bad679db7dd087894297e6eb0e85c9b12fdf444
Reviewed-on: https://gerrit.chromium.org/gerrit/27256
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-07-12 02:09:45 -07:00
Louis Yung-Chieh Lo
740ba3f576 Ensure at least one LPC status bit is 0 at init time.
Clear bit 8 of LM4_LPC_ST(LPC_CH_KERNEL) and LM4_LPC_ST(LPC_CH_USER) in
lpc_init(). Also defined other bit masks for future allocation.

BUG=chrome-os-partner:10963
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
TEST=build in chroot only.

Change-Id: Iaa61e18d38153cc25d064554df44d2a642e1bb40
Reviewed-on: https://gerrit.chromium.org/gerrit/27012
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-11 20:54:40 -07:00
Randall Spangler
bdf3ba5ded Move host_cmd_handler_args farther up the call chain
This is necessary for an imminent change which passes version data
from the host bus (LPC/I2C/SPI) into the host command handler.

BUG=chrome-os-partner:11275
TEST=from u-boot prompt, 'mkbp hash'

Change-Id: If34d0d7c6dc320ad5632becf512c30900fd61aca
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27190
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-11 17:22:57 -07:00
Randall Spangler
fe5c01cb6e Add host command to check what command versions are supported
BUG=chrome-os-partner:11275
TEST=manual

ectool cmdversions 0x08 -> should print 0x00000001
ectool cmdversions 0xdd -> should print command not supported

Change-Id: I7801be51492eb6a5321accaa2b66f0dc8d5a2797
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27181
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-11 14:46:31 -07:00
Randall Spangler
07ca0977fe Refactor API for host commands, and handle variable length data better
Added version mask field to DECLARE_HOST_COMMAND() because it's
convenient to do so when I'm touching all host command
implementations, but all commands simply declare version 0 and nothing
checks it yet.  Will add version support in a followup CL.

This change is internal to the EC; it does not change the data sent
over the host interface.

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

ectool version && ectool echash; should get sane data from both

ectool flashread 0x80 0x40 /tmp/foo && od -tx1 /tmp/foo
should match data from offset 0x80 of ec.bin (od -j128 -n64 -tx1 ec.bin)

Change-Id: I5699f72b8d5e1ac23929353c9a34158d76c44206
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27172
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-11 14:46:30 -07:00
Rong Chang
61e0e5508a Get AC state from GPIO instead of PMU
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=none
TEST=manual
  plug and unplug the ac adapter, check charging state

Change-Id: I933976d79bbd2da59449f0b9208656897713ebf2
Reviewed-on: https://gerrit.chromium.org/gerrit/27146
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-07-11 06:55:27 -07:00
Rong Chang
e904d1a78a Change STM32 I2C master wait status timeout from 100ms to 10ms
This change shorten the timeout period to 10ms.

Experiments showed that most master mode communication status bit
changed within 2000us. Hence 10ms timeout is much reasonable than
the original value.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=none
TEST=manual, with i2c scope

Change-Id: Ib26795bd2e4877b5c33719e96a2c2c7c11333eab
Reviewed-on: https://gerrit.chromium.org/gerrit/27145
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
2012-07-11 06:55:26 -07:00
Vic Yang
142b0073bc Set proper value for BOOTCFG
We choose PE2/USB1_CTL1 for BOOTCFG. If we somehow brick the EC, we can
pull this signal to ground and boot EC into boot loader to recover it.

BUG=chrome-os-partner:8769
TEST=On link:
      - Factory reset EC to clear BOOTCFG
      - Flash new EC binary and reboot
      - rw 0x400fe1d0 to check BOOTCFG value is correctly written
      - Boot normally and check EC is operating correctly
      - Pull the signal to ground and reset EC, check EC stays in boot
        loader. Check in this case we can program EC.
      - Attempt to write different value to BOOTCFG and check BOOTCFG
	doesn't change.

Change-Id: Ia6705114d495b18bd7ee4afc1e61e84a21b51198
Reviewed-on: https://gerrit.chromium.org/gerrit/27000
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-10 21:52:13 -07:00
Randall Spangler
29332907d4 Host command interface has only one slot now
Now that ACPI events are handled directly in the LPC interrupt
handler, we can simplify the host event code.

BUG=chrome-os-partner:11240
TEST=boot system; should boot
close lid; should send SMI and suspend system

Change-Id: I8c73ea31a66e94310e4460a008635a103220413e
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27100
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-10 21:52:07 -07:00
Randall Spangler
f2400b869e Move ACPI query-event handling to LPC interrupt
And only support it for port 62/66.

Also remove 'ectool queryec', because it can't touch port 62/66 once
the kernel/ACPI owns it, and query-event isn't supported on the user
command port.

BUG=chrome-os-partner:11240
TEST=boot system and check EC console output; should see event clears between
host commands 0x23, 0x8e, but no hostcmd 0x84.

[0.396780 LPC RESET# deasserted]
[0.486953 Port 80: 0x29]
[0.487415 hostcmd1 0x23]
[0.764407 Port 80: 0x88]
[0.764579 event clear 0x00000008 -> 00002080]
[0.764928 event clear 0x00000080 -> 00002000]
[0.765224 event clear 0x00002000 -> 00000000]
[0.765578 hostcmd1 0x8e]
[0.765868 hostcmd1 0x06]

Change-Id: I8ed161dbccd396d685ddf6829a27dfef87d919fb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27095
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-10 21:52:07 -07:00
Randall Spangler
2daf748e0e Get rid of double debug output for host commands
(in both command_process() and host_command_process())

BUG=none
TEST=none

Change-Id: I6eafe110b425afac9d94ace710efe5bbf7342073
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27080
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-10 16:18:59 -07:00
Randall Spangler
42187535e4 Remove fake dev switch
BUG=chrome-os-partner:9922
TEST=manual

Press power+refresh+d.
From ec console, 'optget'.  No reference to fake dev switch
From host, 'ectool vboot'.  Should see either 'fake_dev=0' or no mention of fake dev switch at all.

Change-Id: I66bc5e926d6e639b206563e764bcc730cce9227c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27061
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-10 14:56:05 -07:00
David Hendricks
ae648cc520 stm32: fix data buffer increment bug in flash_physical_write
This fixes a small bug introduced in a previous refactoring CL where
by the data buffer offset wasn't being incremented, thus causing
writes to repeatedly write the first two bytes of the incoming data
to each chunk of memory.

BUG=chrome-os-partner:11097
TEST=successfully wrote and verified data on Snow
Signed-off-by: David Hendricks <dhendrix@chromium.org>

Change-Id: I8dae00652f4d74bc6ef449297b6e78b13b21255f
Reviewed-on: https://gerrit.chromium.org/gerrit/26985
Reviewed-by: Katie Roberts-Hoffman <katierh@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2012-07-10 11:27:08 -07:00
David Hendricks
29af184eb7 copy reboot parameters in host_command_reboot()
Currently host_command_reboot() casts the supplied buffer and access
it directly. This works until about half-way thru the function when
the same buffer potentially gets overwritten when sending the response
code to the host.

This CL gets around that by copying the reboot parameters into a
separate buffer.

Signed-off-by: David Hendricks <dhendrix@chromium.org>
BUG=none
TEST=Tested using 'ectool reboot_ec' on Snow (see below)

Before, EC console displayed "[Executing host reboot command]" and
ectool showed no actual change (reboot command was being overwritten
with EC_REBOOT_CANCEL):
localhost ~ # ectool version | grep 'Firmware copy'
Firmware copy: RO
localhost ~ # ectool reboot_ec A
localhost ~ # ectool version | grep 'Firmware copy'
Firmware copy: RO

With the patch applied, the EC console shows the EC boot-up messages
and ectool confirms that the jump took place:
localhost ~ # ectool version | grep 'Firmware copy'
Firmware copy: RO
localhost ~ # ectool reboot_ec A
localhost ~ # ectool version | grep 'Firmware copy'
Firmware copy: A

Change-Id: I8aca8d468d1125c3fb8d320ec0fb79d2822b0b20
Reviewed-on: https://gerrit.chromium.org/gerrit/26998
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
2012-07-10 11:27:08 -07:00
Vic Yang
37b295fd6e Add a test of flash overwrite
This test checks we cannot overwrite current running system image.

BUG=chrome-os-partner:10262
TEST=Test passed

Change-Id: I72be277c9de2114e72000a102d8b885e842ef15a
Reviewed-on: https://gerrit.chromium.org/gerrit/27006
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-10 00:35:58 -07:00
Vic Yang
42d0270990 Clear UART FIFO when initializing to prevent reading garbage
When debug port is left unconnected, EC get garbage keypress input from
both UART ports due to UART pin floating. By clearing UART receive FIFO
when initializing UART module, this can be prevented.

BUG=chrome-os-partner:10235
TEST=Reset EC with debug port unconnected. Check u-boot doesn't get any
     keypress.

Change-Id: I3e84db1f2f95a0173c11180f6afb3edb705d0ae5
Reviewed-on: https://gerrit.chromium.org/gerrit/26908
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-07-09 19:50:22 -07:00
Vic Yang
80d92fd6dd Handle invalid parameter of fan duty cycle and keyboard backlight
If the 'percent' passed in is lower than 0, then set it to 0. If it is
higher than 100, set to 100.

BUG=chrome-os-partner:11052
TEST=Check with 'kblight', 'fanduty', and 'faninfo'.

Change-Id: If84ab12658bf136eaaf1adecc0522a977c94f98d
Reviewed-on: https://gerrit.chromium.org/gerrit/26904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-09 19:50:21 -07:00
Randall Spangler
95c999ad9b Lock out MKBP_SIMULATE_KEY host command when WP is enabled
BUG=chrome-os-partner:11046
TEST=manual

1. Try 'ectool kbpress' command from root shell with a few params when system is unlocked (WP disabled).  Should work.

2. Try again when WP is enabled and locked ('flashwp lock' then 'reboot' from EC console).  Should fail.

2b. Alternately, use 'syslock' to lock system for just the current boot.

Change-Id: Ic271b13b1973ff3cb83a113274d4e33655c0cf85
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26936
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-09 14:42:09 -07:00
Randall Spangler
2260adb1b9 Better arg checking for reboot command
Allows 'reboot cold' as an alias for 'reboot hard', since I keep
mis-typing that anyway.  Returns error for any other option.
('reboot' by itself still does a warm reboot).

BUG=none
TEST=manual

reboot -> does warm reboot
reboot hard -> does hard reboot (reason = rtc alarm)
reboot cold -> ditto
reboot foo -> prints error

Change-Id: I183714d4ba09abee3bd9a6f0d5df82389becf410
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26924
2012-07-09 13:38:24 -07:00
Randall Spangler
0249b50dd2 Jumping to same image as currently running shouldn't reboot.
BUG=chrome-os-partner:11147
TEST=manual

sysjump RO -> does not reboot/jump (no op)
sysjump A -> jumps to A
sysjump A -> does not reboot/jump (no op)

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

Change-Id: I3f1c9613237242b3cfd502127fb5b461f8d0fb22
Reviewed-on: https://gerrit.chromium.org/gerrit/26899
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2012-07-09 13:38:24 -07:00
Randall Spangler
0b69d0fd57 Add option to disable system jumps
This allows the console or AP to keep the EC in its RO code.
Previously, the EC could jump from RO to RW even if the system was
locked in pre-init.

Also, sysjump console command doesn't need to check if system is
disabled before calling system_run_image_copy(), because that function
also checks.  This now matches how the host command works.

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

syslock
sysjump A -> works
reboot
syslock
sysjump disable
sysjump A -> fails

Repeat, using 'ectool reboot_ec disable-jump' at root shell instead of
'sysjump disable' at EC console.

Change-Id: I0b168a93e97802ba30e7c225b01d70ea66e8db58
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26898
2012-07-09 13:38:23 -07:00
Randall Spangler
46bc2721c5 Remove unused UART defines
No longer needed since the rewrite of the panic handler in C.

BUG=none
TEST=link and snow still compile

Change-Id: Ib790004ae4d0ba11f0800e85e14ea372a53025f8
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26890
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-09 10:58:14 -07:00
Randall Spangler
f8a4b6bf51 Only disable sysjump in main if we're doing signature-based verified boot
EC software sync still needs to be able to sysjump later after the AP
decides which image the EC should be running.

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

sysjump A
sysjump RO
sysjump A
sysjump RO

Change-Id: I74eaf10dacf6eaa6aeabae2ff3b21ad387517605
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26896
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-07-09 10:58:14 -07:00