Commit Graph

393 Commits

Author SHA1 Message Date
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
Simon Glass
fb425cf11f Unify the watchdog API over stm32 and lm4
Use the same prototype for watchdog_init() everywhere. One version takes
a parameters and one doesn't. We don't need the parameter since we have
a #define. Tidy this up.

Also move watchdog defines into watchdog.h.

BUG=chrome-os-partner:10145
TEST=build for all boards

Change-Id: I38ae63d7cc137b93017c850e767703d5f90f56ad
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/24394
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2012-06-05 09:30:21 -07:00
Randall Spangler
4568bc7dbd Release keyboard recovery button on next power-on
Keyboard recovery used to persist until the next time the EC was
reset.  It should release the next time the user turns on the system
via the lid or power button.

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

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

1. power system on normally.  not in recovery.
2. press Power+Esc+Refresh.  System turns on into recovery.
3. shut system down
4. power system on with lid-open.  System boots normally.

5. repeat steps 2-3, then power system on with power button.  System boots normally.

Change-Id: I455c7191d128614629c50ba27d7ef977e414fe90
Reviewed-on: https://gerrit.chromium.org/gerrit/24409
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2012-06-04 17:07:15 -07:00
David Hendricks
422b081285 Send success code when rebooting EC using I2C host commands
This causes the reboot command to respond to the host via I2C with
EC_RES_SUCCESS.

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

BUG=none
TEST=tested on Snow and Link using ectool and flashrom

Both machines were able to reboot the EC and go thru an EC update via
Flashrom successfully:

localhost ~ # ectool reboot_ec RO ; echo $?
done.
0

Flashrom is also able to do a fully automatic update, without the
user specifying a layout:
Reading old contents from flash chip... done.
Found 'RO_SECTION' in image.
Found 'RW_SECTION_A' in image.
GEC is jumping to [RO_SECTION]
GEC has jumped to [RO_SECTION]
Erasing and writing flash chip...
...
GEC is jumping to [RW_SECTION_A]
GEC has jumped to [RW_SECTION_A]
GEC needs 2nd pass.
...

Change-Id: Id723c26caa8f352a7ddc6ebfae664448c38300f0
Reviewed-on: https://gerrit.chromium.org/gerrit/24290
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
2012-06-01 14:45:57 -07:00
Vic Yang
3f129c161e Add host command to switch LCD backlight and WLAN/Bluetooth
We need to be able to toggle these signals to increase test coverage.

BUG=chrome-os-partner:9967
TEST=Toggle 'ectool wireless' and see GPIO signal changes.
     'ectool backlight 0' and see LCD backlight turn off.

Change-Id: Ic96fe26aa82c33b0e51e1f973280a0edc322f158
Reviewed-on: https://gerrit.chromium.org/gerrit/23625
Commit-Ready: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
2012-06-01 08:15:47 -07:00
Randall Spangler
26b4a9e1a0 Assorted keyboard module cleanup
Const- and static-ifying data and pointers.

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

BUG=none
TEST=kblog on, then boot system, then kblog; should print log

Change-Id: I2e1da8e3d614b66dad8749b18c43bd77dc75928d
Reviewed-on: https://gerrit.chromium.org/gerrit/24233
Commit-Ready: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2012-05-31 15:03:17 -07:00
Vic Yang
53e8d3201c Fix a typo in thermal engine temperature setting
Signed-off-by: Vic Yang <victoryang@chromium.org>

BUG=none
TEST=none

Change-Id: I369522c00724c959d1eac18ca9c3ce57bd55aeff
2012-05-31 21:35:13 +08:00
Rong Chang
29b9a28c9d PMU tps65090 driver
This is an initial commit of tps65090 pmu driver. An empty charging
task added.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:9756
TEST=manual
  When connected to a battery, the EC uart console will display
  battery status on value change.
  Check pmu register with 'i2c r 0x90 4'. Output should be '0x03'.

Change-Id: I99e243d203c438751af0c3647556cbf9a94e928f
2012-05-31 18:56:47 +08:00
Rong Chang
ee495ac6a6 Add stm32 I2C master driver
A polling mode I2C master driver. Interfaces for read/write byte
and word are implemented. i2c_read_string() is currently an empty
function.

CONFIG_SMART_BATTERY added to daisy board for testing.

Move smart_battery.o back to CONFIG_SMART_BATTERY since it is not
depended on charging state machine.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:9724
TEST=manual/host commands
  > battery
    Temp:      0x0bad = 298.9 K (25.8 C)
    Manuf:
    Device:
    Chem:
    Serial:    0x0001
    V:         0x1cb7 = 7351 mV
    V-desired: 0x20d0 = 8400 mV
    V-design:  0x1c20 = 7200 mV
    I:         0x0000 = 0 mA
    I-desired: 0x0bb8 = 3000 mA
    Mode:      0x6001
    Charge:    49 %
      Abs:     47 %
    Remaining: 2705 mAh
    Cap-full:  5575 mAh
      Design:  5800 mAh
    Time-full: 0h:0
      Empty:   0h:0

Change-Id: I9f4e9e8819955ad1b107fb3b70ac2559d9b02b55
2012-05-31 18:00:17 +08:00
Vincent Palatin
1545262c9b Detect recovery key combination
Check if ESC+Power+Refresh is pressed at startup, if the recovery
combination is detected, record it to allow U-Boot to go into recovery.

The status of the keyboard recovery can be read from the response of the
EC_CMD_MKBP_INFO command.

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

BUG=chrome-os-partner:9916
TEST=On Snow, do a recovery reset by pressing ESC+Refresh+Power and see
the trace, try other resets and don't see it.

Change-Id: I0e1a8214781a6e74bd90bf8313887a9dcf4df56d
2012-05-31 00:42:02 +00:00
Gerrit
7c229f92fb Merge "stm32: assert/de-assert GPIO_PMIC_PWRON_L with keyboard power event" 2012-05-30 17:01:21 -07:00