Commit Graph

403 Commits

Author SHA1 Message Date
Vic Yang
d29ec56d41 Remove hardcoded size in temp_sensor_command_get_info()
BUG=chrome-os-partner:11053
TEST='ectool tempsinfo 0' works.

Change-Id: Ia4f33f2fce3b38ac7bfeaff0fdd4ef0840a0b58f
Reviewed-on: https://gerrit.chromium.org/gerrit/26639
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-03 10:50:46 -07:00
Vic Yang
fda2466816 Prevent strzcpy access out-of-bound
When parameter 'len' is smaller or equal to 0, do not null-terminate.

BUG=chrome-os-partner:11041
TEST=Build success.

Change-Id: Ia5267e7d31e3ade8828ba0bc2d68405b4cd236be
Reviewed-on: https://gerrit.chromium.org/gerrit/26640
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-07-03 10:50:45 -07:00
Simon Glass
9a4eff992f flash: Provide direct flash access with flash_dataptr()
Sometimes it is useful to get access to the flash directly, without using
flash_read(). Add a function to do this.

Since the range checking is done in every function in flash_common,
use the new function to do it for us. That way we get a slight (64 byte)
code size reduction.

BUG=chrome-os-partner:10146
TEST=manual:
build and boot on snow with SPI flash emulation, in U-Boot:

See that the 32KB of flash has been provided correctly.

Change-Id: I6622a24234edaed371dd5b9bf43d1f3974d55e39
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26174
2012-07-02 22:35:51 -07:00
Simon Glass
184eeb65ac Add a repeat count parameter to the battery command
This allows us to repeatedly read the battery for testing.

BUG=chrome-os-partner:10888
TEST=manual:
build for all boards
boot on snow (cannot test i2c as it is

Change-Id: I0ed99d59355e1f228486070dcf37863563b16023
Reviewed-on: https://gerrit.chromium.org/gerrit/26290
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
2012-07-02 22:35:51 -07:00
Rong Chang
10873682a8 Retry to update power led after 1wire error
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:10779
TEST=manual
  plug/unplug ac power and check powerled

Change-Id: I1f75a67aa20fd076f1c367d7086bfc54fb050dc9
Reviewed-on: https://gerrit.chromium.org/gerrit/26564
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-07-02 21:10:25 -07:00
Simon Glass
e723318ec1 Remove unnecessary host_send_result()
This seems to be a hangover from the LPC protocol. We can send a result
just by sending a response with no data.

Drop this function and remove all uses of it.

Also use 'enum ec_status' instead of int, since this is the correct
response type.

BUG=chrome-os-partner:10533
TEST=manual:
build for all boards
build and boot on daisy

Change-Id: I93a029bd6ba8cec567b61af3b410bcead015b5c0
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25980
2012-07-02 20:36:57 -07:00
David Hendricks
1bedd55970 Daisy/Snow: Drive power LED with PWM
This drives the power LED for Snow (PB3) using TIM2 in PWM mode.

Since timer setup and manipulation is STM32-specific, the power LED
logic moved to to chip/stm32/power_led.c.

This also adds a "powerled" console command for testing.

Signed-off-by: David Hendricks <dhendrix@chromium.org>

BUG=chrome-os-partner:10647
TEST=Tested on Snow with powerled command, compiled for Daisy

Change-Id: I5a7dc20d201ea058767e3e76d54e7c8567a3b83c
Reviewed-on: https://gerrit.chromium.org/gerrit/26267
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
2012-07-02 15:26:02 -07:00
Rong Chang
f429744005 Fix multiple charging issues on snow
This change fixes mutiple snow charging issues. Including:
  - disable i2c host auto selection
  - i2c_read8 got wrong output value
  - pmu CHARGE_EN control workaround

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:11010
TEST=Only test on snow dvt with AP turned off
  plug/unplug ac adapter and check charging led
  check console command 'battery'

Change-Id: I29d554b3daa4cfc538bd5bf5ba5233976d381861
Reviewed-on: https://gerrit.chromium.org/gerrit/26529
Tested-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-07-01 15:45:09 -07:00
Randall Spangler
208023afd7 Remove flash checksum host command
This is now superseded by the hash command, which uses a more robust
SHA-256 check.

BUG=none
TEST=if it compiles it's fine

Change-Id: I5ad9256e7af346464301252d62b47bd37852d24a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26452
2012-06-29 15:01:40 -07:00
Randall Spangler
70718f97e3 Add x86shutdown console command
Now that the EC powers on the AP unconditionally on startup, we need a
way to quickly shut the AP down if it's running without a heatsink.

(Also cleaned up comments and line spacing to kernel style)

BUG=none
TEST=boot system; when x86 is booting, type 'x86shutdown'.

Change-Id: I4dd5a2d5d27b624d0d0f9228baac257587b4808a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26274
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-29 10:22:50 -07:00
Vic Yang
67c9f4547e Fix a bug in battery temperature cut off
When battery temperature is too low, charging should be paused.

BUG=none
TEST=none

Change-Id: I0de87143f5da810cee70c14ee3c52614b5cf3d3b
Reviewed-on: https://gerrit.chromium.org/gerrit/26380
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-28 23:44:41 -07:00
Randall Spangler
2e0ae57990 Use __packed instead of __attribute__((packed))
The presubmit script for linux kernel style prefers the former.

BUG=none
TEST=none

Change-Id: I0a0a1eb039f45975ada075c1302d868071a7cfb1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26361
2012-06-28 17:40:39 -07:00
Vic Yang
b38e3405ea Do not trickle charge when battery ask for no current
When battery ask for no current, we should go back to init state to
determine what to do next.

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

Change-Id: Idf3ac7554a0774655138c5efe9c5e6de7f6cb7a0
Reviewed-on: https://gerrit.chromium.org/gerrit/26310
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-28 06:39:46 -07:00
Vic Yang
21aaa0b406 Fix a bug of temperature unit mismatch
We set battery temperature limit in deci-Kelvin but use them as Celsius.
Let's fix this so that battery is cut off correctly.

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

Change-Id: I2320b5e9f19ccc17f0cec7664133544c25a745f8
Reviewed-on: https://gerrit.chromium.org/gerrit/26302
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-27 23:59:39 -07:00
Vic Yang
0e261504aa Stub smart battery read/write functions
For better testability, let's move smart battery read/write functions to
a stub so that we can easily mock them.

BUG=chrome-os-partner:10270
TEST=build success

Change-Id: I416580c6dc7911e376bc232e5f0560117d9353c2
Reviewed-on: https://gerrit.chromium.org/gerrit/26227
Reviewed-by: Rong Chang <rongchang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-06-27 03:22:17 -07:00
Vic Yang
8b3634ee1f Add a test of i8042 scancode set
This test check correct scan code is sent when I8042_XLATE is enabled or
disabled.

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

Change-Id: I939963cbecddb22506e64cb374667c7c2e5b4f8b
Reviewed-on: https://gerrit.chromium.org/gerrit/26096
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-06-27 00:55:04 -07:00
Vincent Palatin
108aab99d4 tpschrome: skip bad I2C read
When an I2C read fails, we don't want to switch off the system or even
print verbose warnings.
Indeed, we are failing all I2C reads and writes to the charger and
battery when they are on the same bus as the AP and the AP is ON.

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

BUG=chrome-os-partner:9724
TEST=on Lucas DVT, run the system and see we have no spurious switch off
or verbose EC traces.

Change-Id: Ieb2f7836c70a0d2ad2c4a0f775aa190ce81a6932
Reviewed-on: https://gerrit.chromium.org/gerrit/26064
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-26 18:15:37 -07:00
Rong Chang
c56b1a7bdb TPSChrome charging loop
This change contains a basic charging loop that follows Chromium
battery charging flow. The temperature range constants, loop delay
time will be move to battery pack later.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:9724,9757,9759
TEST=manual, uart console
  Plug AC adapter:
    > pmu event: 0000000000001110
    [batt] state discharging -> idle
    [batt] state idle -> charging
    > battery
      I:         0x04fd = 1277 mA(CHG)a

  Unplug AC adapter:
    > pmu event: 0000000000000110
    [batt] state charging -> idle
    [batt] state idle -> discharging
    > battery
      I:         0xffcb = -53 mA(DISCHG)

Change-Id: Ifed594d78c0ed08c5e4821a9c8581c1a87526729
Reviewed-on: https://gerrit.chromium.org/gerrit/25618
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-26 18:15:35 -07:00
Randall Spangler
7b155fb8ac Refactor boot key detection
Keyboard scan module now owns the recovery key state on all platforms.

And clean up a few comments to linux kernel style

BUG=chrome-os-partner:10890
TEST=manual
- Power on system.  Should boot normally.
- Power+Refresh+D.  Should turn dev switch on.
- Power+Refresh+F.  Should turn dev switch off.
- Power+Esc.  Should reboot system.  Power button should power on normally.
- Power+Refresh+Esc.  Should power on into recovery mode.
- Then press power to shut system down.
- Power button should power on normally (not back into recovery mode).

Change-Id: I4d16e1e8b039efeacbd41e8acec115844bc8457d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26147
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-26 17:01:52 -07:00
Randall Spangler
fb123b4838 Only one RW image is now the default
And if RW B isn't enabled, it's not even linked.

BUG=chrome-os-partner:10881
TEST=on link, should be no B image, and 'sysjump B' should fail
On BDS, still should be A and B images

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: Icb2af07881cc7e28b9b877f45824486a22fde8d7
Reviewed-on: https://gerrit.chromium.org/gerrit/26116
2012-06-26 13:58:54 -07:00
Randall Spangler
90afebac64 Strip out vboot signature code and stay in RO for link
BUG=chrome-os-partner:10880
TEST=boot EC; should stay in RO and not do signature check
(verify via debug console output)

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

Change-Id: I831aa91f8273bc7fb1a624cf36d9f21d52d8f3d8
Reviewed-on: https://gerrit.chromium.org/gerrit/26115
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Randall Spangler <rspangler@chromium.org>
2012-06-26 13:58:53 -07:00
Randall Spangler
900c0215b4 Add hash support
EC computes a SHA-256 hash of its RW code on boot.  Also adds host and
console commands to tell the EC to recompute the hash, or hash a
different section of flash memory.

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

1) ectool echash -> should match what the EC precomputed
2a) ectool echash recalc 0 0x10000 5
2b) on EC console, 'hash 0 0x10000 5'
2c) results should agree
3a) on ec console, 'hash 0 0x3e000' then quickly 'hash abort'
3b) ectool echash -> status should be unavailable
4) ectool echash start 0 0x3e000 6 && ectool echash && ectool echash abort && sleep 2 && ectool echash
status should be busy, then unavailable

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I6806d7b4d4dca3a74f476092551b4dba875d558e
Reviewed-on: https://gerrit.chromium.org/gerrit/26023
2012-06-25 15:37:42 -07:00
Randall Spangler
24395bcc87 Remove proto1 workarounds
At this point, EC code requires EVT.  If you still have a proto1,
here's what'll break:
  1) Keyboard recovery mode checks refresh key, and may read unreliably due
     to proto1 silego reset circuit.
  2) Lightbar may not start in the correct state.
  3) EC 'hibernate' command will not work.
  4) Board version may read incorrectly.

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

1) powerbtn -> system powers on, lightbar displays proper sequence
2) version -> board version 1 (EVT)
3) power+refresh+esc -> system boots into recovery mode
4) power+refresh, then power button -> system reboots, then boots normally

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I699946e365d15ae38622b69da1a0241e72d05f61
Reviewed-on: https://gerrit.chromium.org/gerrit/26053
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-06-25 15:37:41 -07:00
Vic Yang
7eabcb4e69 Add a test of checking power button handling
This test checks power button is correctly debounced, and also check
power button press of different length are handled correctly.

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

Change-Id: I18595c60896255d36326731d28bab55e64c6bca2
Reviewed-on: https://gerrit.chromium.org/gerrit/25505
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-25 07:15:52 -07:00
Vic Yang
7ae80c0552 Thermal engine unit test
This test checks for the functionality of thermal engine.

BUG=chrome-os-partner:10241
TEST=Test passed
     Disable thermal engine overheating warning and test failed

Change-Id: Ideb0ff9ee4bd1617b11c56dfa2578a3f406381ff
Reviewed-on: https://gerrit.chromium.org/gerrit/25370
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-25 07:15:50 -07:00
Bill Richardson
80c635ecab Add 'fanduty' command both EC console and ectool.
This forces the fan PWM duty cycle to a fixed percentage (0-100). It's only
used for airflow testing.

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

Using this ectool, try

  ectool fanduty 0
  ectool pwmgetfanrpm
  ectool fanduty 50
  ectool pwmgetfanrpm
  ectool fanduty 100
  ectool pwmgetfanrpm

You should see (and hear) the fan speed up.  If you have an EC console, you
can run

  faninfo

and it should show that the 'Target:' is unrelated to the 'Actual:' value.

Change-Id: Iac332fb3ba63f96726cf7f64061b3ce22d2e76fd
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25965
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-22 15:56:57 -07:00
Vincent Palatin
e61af38f55 link: update VR settings
Update a couple of IR3571 settings :
- remove the PS override bit which is a leftover from the debug session.
- modify VR_READY and CODE REV

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

BUG=chrome-os-partner:10171
TEST=run several Link EVT with this EC and check we have no kernel
warnings.

Change-Id: I873dc23ddb3ff8ac9fcdf24cd769414cb12689e5
Reviewed-on: https://gerrit.chromium.org/gerrit/25967
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2012-06-22 15:35:41 -07:00
Vincent Palatin
bc672dd30c IR357x core/gfx regulator support
add function read/write the IR3570/71 voltage regulator settings.

This includes new settings for the IR3571 to avoid the freeze observed
on new Link boards.
Currently, these settings are not flashed permanently inside the IR3571,
they are just applied at CPU startup (when the VR powered).

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

BUG=chrome-os-partner:10171
TEST=on Link EVT, check in the kernel log that we are longer seeing the
warnings from the GPU driver and the jankyness.
on Link proto-1, check the IR chip version detection.

Change-Id: I0781f5285aac7a9f03c7c4eb953bf97273c6d404
Reviewed-on: https://gerrit.chromium.org/gerrit/24674
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-22 11:34:19 -07:00
Vincent Palatin
b84ef3b1f2 stm32: drive the keyboard power LED
Put the power LED in the right state (off, on, breathing) depending on
the AP state (off, running, suspending).

The power LED is connected to GPIO B3.
The AP suspend detection is done through GPIO A7.
(so we no longer configure it as SPI alternate function)

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

BUG=chrome-os-partner:10647
TEST=on Lucas DVT, boot/stop the board and see the LED on and off.

Change-Id: I42121aacab35e9da7a751dc9f56bcc5af7850783
Reviewed-on: https://gerrit.chromium.org/gerrit/25880
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-22 11:34:17 -07:00
Vic Yang
23d9defb2b Disable thermal thresholds for TMP006 sensor near CPU
This sensor doesn't provide accurate case temperature. Let's
disable thermal thresholds for the object tempearture reading from this
sensor.

BUG=chrome-os-partner:9599
TEST=Build success. System works fine.

Change-Id: I9408de59a3349f944c5e215085da93f23965ebc9
Reviewed-on: https://gerrit.chromium.org/gerrit/25824
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-06-22 11:12:43 -07:00
Simon Glass
d5cb026142 Enable checking for divide by 0 and alignment faults
These likely indicate errors, so we shold trap them. Possibly this
should be reconsidered for production.

BUG=chrome-os-partner:10148
TEST=manual:
build on all boards
build and boot on snow with a special rw command containing a division
by 0. See that it is trapped:
> rw 0

=== EXCEPTION: 03 ====== xPSR: 01000000 ===========
r0 :0000000b r1 :08005eba r2 :00000000 r3 :20001048
r4 :00000000 r5 :08004fd4 r6 :08004f8c r7 :200012a8
r8 :08004fd4 r9 :00000002 r10:00000000 r11:00000000
r12:00000000 sp :200009a0 lr :08002861 pc :0800368a
Divide by 0, Forced hard fault, Vector catch
mmfs = 02000000, shcsr = 00000000, hfsr = 40000000, dfsr = 00000008

Turn off the cpu_init() setup, and see that it is ignored.

> rw 0
read 0x0 = 0x00000000
>

Similarly, try an unaligned access with the rw command with this enabled:

> rw 1

=== EXCEPTION: 03 ====== xPSR: 01000000 ===========
r0 :0000000b r1 :00000041 r2 :00000001 r3 :200012ac
r4 :00000000 r5 :08004fd4 r6 :08004f8c r7 :200012a8
r8 :08004fd4 r9 :00000002 r10:00000000 r11:00000000
r12:00000000 sp :200009a0 lr :08002861 pc :08003686
Unaligned, Forced hard fault, Vector catch
mmfs = 01000000, shcsr = 00000000, hfsr = 40000000, dfsr = 00000008

but disabled it works:

> rw 1
read 0x1 = 0x5d200010
>

Change-Id: Id84f737301e467b3b56a7ac22790e55d672df7d8
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25410
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-21 06:01:22 -07:00
Randall Spangler
80fa2da908 Add reboot-at-shutdown flag
Also removes unused recovery request, since AP handles that internally now.

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

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

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I51bbf997f6b7f94fe61f06a8a1804c3cc5c319b8
Reviewed-on: https://gerrit.chromium.org/gerrit/25791
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-20 23:30:02 -07:00
Rong Chang
b2181b1238 Fix deep discharging poweroff function
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:10614
TEST=manual
  Boot link with test image. Disconnect AC. Check EC console log.
  When battery charge drop from 3% to 2%. EC will soft reset and
  restart system in S5.

Change-Id: Iff2e67ad689bb2eecaf0f8efa46eb3a5f1f28911
Reviewed-on: https://gerrit.chromium.org/gerrit/25504
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2012-06-20 06:27:25 -07:00
Louis Yung-Chieh Lo
bdf3ea3b09 Support KBC I8042_TEST_KB_PORT (0xab) command.
Lack of this command could make u-boot pc_keyb.c failed to init (see
lines around line 143 of u-boot/files/drivers/input/pc_keyb.c).

  static char * kbd_initialize(void)
  {
        ...
        kbd_write_command_w(KBD_CCMD_KBD_TEST);
        if (kbd_wait_for_input() != 0x00)
                return "Kbd:   interface failed self test";

Change-Id: I0a906e0ee4419be74a79ce983c025ce42f02cb81
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
BUG=chrome-os-partner:10358
TEST=tested on link.
Reviewed-on: https://gerrit.chromium.org/gerrit/25619
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
2012-06-19 21:38:52 -07:00
Randall Spangler
ebf79b00a9 Set GPIO_ENTERING_RW before jumping between images.
BUG=chrome-os-partner:10662
TEST=manual

1) Boot system with power+esc+refresh.  gpioget ENTERING_RW --> 0
2) reboot, then gpioget ENTERING_RW --> 1
3) Check EC_IN_RW signal on AP, if possible

Change-Id: I9de43eecf71654bf337d7a0e8b21f0cbcf386cc7
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25624
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-06-19 10:48:21 -07:00
Rong Chang
e14d961407 Implement x86 force shutdown
Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:8242
TEST=manual
  Switch to dev mode VT2 console. Increase CPU load:
    cat /dev/urandom > /dev/null &
    cat /dev/urandom > /dev/null &
  Check CPU PECI temperature and wait for auto shutdown:
    ectool temps 9

Change-Id: I62ad6efd6621bf5ddcde55424c39ac897271a94a
Reviewed-on: https://gerrit.chromium.org/gerrit/25503
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
2012-06-19 09:53:03 -07:00
Randall Spangler
4aa13dbef9 If port 80 buffer isn't full, only print partial contents
BUG=chromium-os:31902
TEST=manual

1. reboot ec
2. port80; nothing there
3. powerbtn
4. retype port80 repeatedly during boot and see it fill and then scroll

Change-Id: Id227d5debbdd635332ed2f42bc0f163833031b5c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25442
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2012-06-18 11:48:15 -07:00
Randall Spangler
9c08e8994e Add kbd command to print/set keyboard enable status
(And maybe other keyboard status in the future...)

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

reboot
kbd -> should show disabled
power on system, wait for it to boot
ctrl+alt+F2 -> should be able to type at console
kbd -> should show enabled
kbd disable -> should no longer be able to type at console
kbd enable -> should again be able to type at console

Change-Id: Icdb38b09f318a47b0413609294b44cd810e8f389
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25353
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
2012-06-15 13:39:22 -07:00
Randall Spangler
3e14c8f8be Split console output into its own module
No code changes, just rearranging source in preparation for an
experiment to see how much the binary shrinks if we disable the
interactive console.

BUG=none
TEST=none

Change-Id: Ie21f1b3dcd04272e80fd40b2ed54d1eaf7fb1cdf
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/25232
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2012-06-13 13:17:33 -07:00
Vic Yang
3367d02f1f Add option to adjust delay for indiviual temperature sensor
Perviously we have a 10-second delay for all temperature sensor. This is
not suitable for CPU temperature. Let's change that to have an option to
set the delay length for each temperature sensor. And also shorten the
delay of TMP006 sensor to 7 seconds, that of EC internal temperature to
4 seconds, and that of PECI CPU temperature to 0 second.

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

BUG=chrome-os-partner:10233
TEST=Check EC issued warning as soon as CPU temperature reached the
threshold.

(cherry picked from commit cf24df7f3ee24eaa5dbeae3b304d11ddada9a914)

Change-Id: Id2cc4a437bde15697afe4020b6153e5d13466759
Reviewed-on: https://gerrit.chromium.org/gerrit/24694
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
2012-06-08 08:57:35 -07:00
Louis Yung-Chieh Lo
210ddfefcf Refactor the i8042 module to be thread-safe.
Any command/data coming from host will be placed in from_host queue, and
the interrupt handler returns immediately. The i8042_command_task() will
handle them later.

Data reply to the host will be protected by the mutex.

BUG=chrome-os-partner:10090
TEST=randomly play around on the link board.

Change-Id: Ic19d5abd1abf8dc261ddaad4224cd9305c2f36a4
Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24299
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-06-07 20:48:51 -07:00
Randall Spangler
8fcfec5f7f Fix printing hex numbers
Off-by-one is not my friend.

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

1. rw 0x20000000
2. ww back the same number printed
3. rw 0x20000000.  should match

Signed-off-by: Randall Spangler <rspangler@chromium.org>
Change-Id: I61e0d26cf4cb274a88326d4e7d24ff1c82d6e515
Reviewed-on: https://gerrit.chromium.org/gerrit/24756
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-07 14:33:26 -07:00
Simon Glass
153fb897ca console: Support delete as well as backspace
Some terminals do not generate backspace correctly, so accept delete
as a substitute.

BUG=chrome-os-partner:10147
TEST=manual:
ssh into workstation, then telnet to serial port (with ser2net running)
See that the backspace key now works correctly, instead of injecting
strange characters into the terminal.

Change-Id: Ief6f2bcab9b8e82cb5720d18c596326b49ffc336
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24715
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-07 12:07:38 -07:00
Randall Spangler
c8eb271d6a Stay in G3 when power applied
We were going straight to S5.  When the PCH first goes into S5 after
power-loss, it decides to boot for some reason.  So, stay in G3.

Still exit G3 if waking from hibernate or if the power button is
pressed when the EC boots on a power-on reset.

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

1) Unplug battery and AC power.  Plug in AC power.  System does not boot.
2) Press power button.  System boots now.
3) From console, 'hibernate 10'.  Close and open lid.  System boots.
4) From console, 'hibernate 10'.  Press power button.  System boots.
5) Hold power+esc+refresh.  System boots into recovery.
6) Hold power+esc.  EC reboots.  Release esc.  System stays off.
7) Unplug battery and AC power.  Plug in AC power while holding power button.
   System boots.

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

Change-Id: I7612a40ab5ebe41d356ac3a6b89cedf1174125f4
Reviewed-on: https://gerrit.chromium.org/gerrit/24729
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-07 12:07:38 -07:00
Randall Spangler
b804daf651 Misc keyboard module cleanup
Should be no functional changes; this is just rearranging code.

BUG=none
TEST=boot system and type on console; should still work

Change-Id: I1c0d44db2d32048b1aaf458728b887b4a008c8cd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24644
2012-06-07 09:59:55 -07:00
Bill Richardson
12eecc012b Put correct RO_FRID, RW_FWID_A, RW_FWID_B entries in FMAP
BUG=chrome-os-partner:9495
TEST=manual

Build image, run dump_fmap. Look for those entries.

Change-Id: I6dfc38e00ce1e11ea24c8392d1691fab32a59d1f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24696
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
2012-06-07 01:20:16 -07:00
Randall Spangler
c7f2e0246e Move printf() formatting to its own file to enable re-use
Also add snprintf(), and %X format code.

BUG=chrome-os-partner:10206
TEST=timerinfo; should print correctly.  'ectool battery' on host side should print same serial as 'battery' on EC console.

Change-Id: I5c9f69d1a20ee5d0a59440c122655adbf62c9aea
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24635
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2012-06-07 00:54:02 -07:00
Randall Spangler
3073c60078 Flash host command functions should be static
Since they're not used outside of this source file.

BUG=none
TEST=if it builds, it worked

Change-Id: I92c13c7d58e0e6977c2696746c9d95cbdcb6dbd5
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24638
Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
2012-06-06 21:19:14 -07:00
Randall Spangler
d053605d94 Fix setting PROCHOT level
BUG=chrome-os-partner:10205
TEST=boot system; still works

Change-Id: I05808068954af40ef8d259e5dc5c94324e8e256d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24621
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-06 16:35:04 -07:00
Bill Richardson
3a10cd37bb Add powerinfo command to display CPU state
BUG=chrome-os-partner:10194
TEST=manual

Run "powerinfo" at the EC console.

Change-Id: I4c8fe8bc32ae6600bd8f0729e81bd239198c73fc
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24578
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-06 08:02:04 -07:00