Commit Graph

1982 Commits

Author SHA1 Message Date
Randall Spangler
fa76d68ce9 Fix task priorities for console and hostcmd tasks
The console task should be higher priority than the host command task,
since that allows debugging problems with host commands.

The keyboard scanning task should be higher priority than both of
them, since it's extremely latency-sensitive.  As currently written,
long-running host commands such as I2C passthru can interfere with
keyboard scanning.

BUG=chrome-os-partner:22681
BRANCH=none (potentially affects pit, but apparently not noticeably)
TEST=type bursts of 6-8 characters quickly while doing a flash update
     of the EC; should not drop characters.

Change-Id: I48db014053750a5f1fae5d06df34768975bb8297
Reviewed-on: https://chromium-review.googlesource.com/169334
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Randall Spangler <rspangler@chromium.org>
2013-09-14 00:32:09 +00:00
Randall Spangler
40f4d61266 Remove unused uart functions
Nothing ever called uart_flush_input() or uart_gets(), so remove them.
They're dead code, and make implementing UART DMA input more complex.

BUG=chrome-os-partner:20485
BRANCH=none
TEST=build all platforms; pass unit tests

Change-Id: I94c2c372ac3f326b98e819b2c89b8995311b2868
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169345
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-09-13 23:23:48 +00:00
Bill Richardson
6bfeb49855 Falco: correct input current limit for 45W adapter, Turbo off
Change the charger's Input Current Register setting for the 45W adapter to
match the latest spec.

BUG=chrome-os-partner:20739
BRANCH=Falco,ToT
TEST=manual

Connect a 45W adapter, run the "battery" and "charger" commands on the EC
console.

When the battery charge is below 10% (turbo off), the "I_in" value displayed
by the "charger" command should be 1536. Before it was 2560.

Change-Id: I0483b5408aa2da352cd3aeda58e1656c095d86b2
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169323
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 3a2ef8cb38d9b0fcc638bbc9a5f7a465a8b14565)
Reviewed-on: https://chromium-review.googlesource.com/169392
2013-09-13 23:23:27 +00:00
Bill Richardson
87d694a906 Falco: Always update charger's input current limit.
I was just updating the input current limit when turbo mode was enabled and
disabled. However, it turns out that the charger can decide to change the
setting all by itself if the inrush current is too high. This happens pretty
much every time that the AC is applied.

We didn't notice this while the AP was on, but when the AP was off we were
exiting the watch_adapter_closely() function too soon and so we missed the
transition. This CL fixes that.

But just to be safe, instead of only updating when we think we need to,
we're going to just update the value every time we check on the adapter.
That way if we happen to miss a change due to a race condition or transient,
we'll catch it the next time through the loop.

BUG=chrome-os-partner:20739
BRANCH=Falco,ToT
TEST=manual

Before this CL, you can run "sbc 0x3f" on the EC console while plugging and
unplugging the AC adapter. When the AP is off and AC is reapplied, you'd see
the reported value mysteriously change.

After this CL, it doesn't.

Change-Id: I5661c548cccd4eb24ba4d8a0b8cd070acc2e49ef
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/169322
Reviewed-by: Randall Spangler <rspangler@chromium.org>
(cherry picked from commit 1bcdd0eb6ff353a7215efe0b24630148ea7a9f28)
Reviewed-on: https://chromium-review.googlesource.com/169391
2013-09-13 23:23:24 +00:00
Vic Yang
221ac6d379 Implement LED control host command
This enables 'ectool led' command.

BUG=chrome-os-partner:22056
TEST='ectool led battery query' and check brightness ranges are correct.
TEST='ectool led battery green' and LED turns green.
TEST='ectool led battery yellow' and LED turns yellow.
TEST='ectool led battery auto' and LED goes back to auto control.
TEST='ectool led power query' returns error.
BRANCH=None

Change-Id: Ide4d80851270fc17d474aee58ec46436a709745c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168870
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-12 19:10:30 +00:00
Derek Basehore
918b2dde3a pit: Change battery level warning and shutdown levels
This causes the EC to give a warning when the battery is less than 3.5% and
shutdown when the batteyr is less than 1.5%

BUG=chrome-os-partner:21926
TEST=check that warning happens at < 3.5% and shutdown happens at < 1.5% on the
EC console.

Change-Id: I1bd06f632e969b55bbb041c65ab106ef764e454b
Signed-off-by: Derek Basehore <dbasehore@chromium.org>
(cherry picked from commit 2f93978e5e5dcf841ef24fa6b9ba2fa9459d3d98)
(cherry picked from commit 447d69abcb3c61440d89b4aac8c4472a35b3b77d)
Reviewed-on: https://chromium-review.googlesource.com/169055
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-12 18:04:29 +00:00
Vic Yang
b28e92a855 kirby: Detect OTG dongle on EC boot
This fixes the problem that after an EC reboot, OTG dongle stops
working.

BUG=chrome-os-partner:21964
TEST=Reboot EC and boot from OTG dongle.
BRANCH=None

Change-Id: Ieec43f612d01114d13afb40293acfd0b3e324e8c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168737
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-12 13:28:57 +00:00
Bill Richardson
bd9d1746c7 Change get-set host command to be less generic
Having a per-device enum list for use by the EC_CMD_GET_SET_VALUE command
won't work when the one-and-only ectool tries to talk to different devices.
Any particular enum may be missing or have a completely different meaning.

Instead, we can do the same thing that EC_CMD_HOST_EVENT_* does - use the
same structs for a bunch of different commands.

If/when we run out of command numbers (it's currently only 8 bits), we'll
just switch to using EC protocol v3 (see crosbug.com/p/20820), which
provides 16 bits for the command.

This CL renames EC_CMD_GET_SET_VALUE to EC_CMD_GSV_PAUSE_IN_S5 (since that's
the one-and-only use of it at present), and renames the params/response
structs as well. Since only the names are changing, the implementation
remains backwards-compatible (assuming the flags value usage is preserved by
ectool for the EC_CMD_GSV_PAUSE_IN_S5 command, which it is).

If I can cherry-pick this change into the one place where it's being used, I
will.

BUG=chromium:287969
BRANCH=ToT
TEST=manual

Although this is primarily an internal name change, it also means that the
commands to invoke the previous usage of this feature have changed. To test:

On Haswell systems only.

To enable the pause in S5 at shutdown, do either of these:

  EC console:      pause_in_s5 on
  root shell:      ectool pause_in_s5 on

Shut the AP down politely, and it should pause in S5 for 10 seconds before
continuing to G3. You can see this by watching the EC console.

To disable the pause in S5 at shutdown, do any of these:

  EC console:      pause_in_s5 off
  root shell:      ectool pause_in_s5 off

or

  press Refresh + POWER

Boot the system, then politely shut down. This time it should go directly to
G3 without pausing in S5.

Change-Id: Ic614fed37ad89db794c2bbcca2b83d1603030ab2
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168816
2013-09-12 01:49:32 +00:00
Randall Spangler
af12f2f58c stm32: Support DMA-based UART output
This reduces the number of UART interrupts by a factor of 12, and
reduces the overall interrupt rate on STM32 by a factor of 2.

BUG=chrome-os-partner:20485
BRANCH=none (not required for pit branch)
TEST=Boot pit.  Ctrl+Q pauses debug output; Ctrl+S resumes it.
     'crash divzero' still prints a full crash dump.
     And util/makeall.sh passes builds all platforms and passes tests.

Change-Id: I86993e14b436150298dcb2c6d29086cc3c9db418
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168814
2013-09-11 22:41:22 +00:00
Randall Spangler
6b1dace9f4 Split uart_process() into input and output processing
This is a precursor to DMA-based UART transfers, which require
different processing for DMA vs PIO output types.

BUG=chrome-os-partner:20485
BRANCH=pit
TEST=Boot pit; verify EC console still works.

Change-Id: I6d6f55561eeebe9bd2928b2bfb25278c86f689d1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168811
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-09-11 19:46:10 +00:00
Vic Yang
eff7a1910a Support multi-bit mask in STM32L's GPIO functions
The definition of GPIO interface allows passing in multi-bit mask, and
this is what's done by gpio_config_module(). Fix STM32L's function so
that it doesn't accidentally set incorrect GPIO register values.

BUG=chrome-os-partner:22605
TEST=On Kirby, do 'led r 0' and check the value of 0x40020800 is
0x01540000.
BRANCH=None

Change-Id: I9a1c8074aab7345485a590ecf138bf99d0742997
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168739
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2013-09-11 19:45:38 +00:00
Vic Yang
876d4c0031 Fix a bug in BQ24192 charger driver
BUG=chrome-os-partner:22238
TEST=Check the return value is EC_SUCCESS
BRANCH=None

Change-Id: I6010d3f8b55938c5fc6526776bee536868a96b55
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168733
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-11 03:45:06 +00:00
Vic Yang
057d71ae79 Avoid charging over battery's maximum voltage
When the battery doesn't report desired voltage, we should charge at the
minimum value of charger maximum voltage and battery maximum voltage.

BUG=chrome-os-partner:22055
TEST=Boot Kirby and check we are charging at 4.2V instead of 4.4V.
BRANCH=None

Change-Id: Ie520aa223d85c0690cc959522c4a46691aaa9a66
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168732
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-11 03:45:04 +00:00
Bill Richardson
793b52f327 Handle multiple independent sources and types of CPU throttling
Depending on the system, the AP can be throttled in at least two different
ways - politely, where it's just asked to slow down a bit, and forcefully
using a hardware signal (like PROCHOT). In addition, the request for
throttling can come from multiple tasks.

This CL provides a single interface, specifying both the type of throttling
desired and the source of the throttling request.

For each type, any source can can start throttling, but all sources must
agree before it stops. The changes are protected by a mutex, so that
requests from multiple tasks don't interfere with each other.

BUG=chrome-os-partner:20739,chromium:287985,chromium:287983
BRANCH=ToT
TEST=manual

Build-time test:

  cd src/platform/ec
  make BOARD=falco runtests

Run-time test: Lower the temp thresholds, turn the fan off, and watch the
throttling turn off and on as things heat up. For example, on the EC
console:

  > temps
    PECI                : 339 K = 66 C
    ECInternal          : 324 K = 51 C
    G781Internal        : 328 K = 55 C
    G781External        : 327 K = 54 C
  > thermalset 0 341 343
  sensor  warn  high  halt   fan_off fan_max   name
    0      341   343    383    333     363     PECI
    1        0     0      0      0       0     ECInternal
    2        0     0      0      0       0     G781Internal
    3        0     0      0      0       0     G781External
  >
  > temps
    PECI                : 339 K = 66 C
    ECInternal          : 324 K = 51 C
    G781Internal        : 328 K = 55 C
    G781External        : 327 K = 54 C
  >
  > fanduty 0
  Setting fan duty cycle to 0%
  >
  > apthrottle
  AP throttling type 0 is off (0x00000000)
  AP throttling type 1 is off (0x00000000)
  >
  [430.152000 thermal WARN]
  [430.152233 event set 0x00020000]
  [430.152497 event clear 0x00020000]
  [430.152714 ACPI query = 18]
  [430.152444 sci 0x00020000]
  [430.153051 set AP throttling type 0 to on (0x00000001)]
  > gpioget CPU_PROCHOT
    0  CPU_PROCHOT
  >
  [436.153742 thermal HIGH]
  [436.153979 set AP throttling type 1 to on (0x00000001)]
  > gpioget CPU_PROCHOT
    1* CPU_PROCHOT
  > [441.155319 thermal no longer high]
  [441.155587 set AP throttling type 1 to off (0x00000000)]
  [442.155604 thermal HIGH]
  [442.155841 set AP throttling type 1 to on (0x00000001)]
  [446.156623 thermal no longer high]
  [446.156890 set AP throttling type 1 to off (0x00000000)]
  temps
    PECI                : 343 K = 70 C
    ECInternal          : 324 K = 51 C
    G781Internal        : 328 K = 55 C
    G781External        : 327 K = 54 C
  >
  [447.156827 thermal HIGH]
  [447.157064 set AP throttling type 1 to on (0x00000001)]
  apthrottle
  AP throttling type 0 is on (0x00000001)
  AP throttling type 1 is on (0x00000001)
  > gpioget CPU_PROCHOT
    1  CPU_PROCHOT
  >

Now turn the fan back on:

  > fanauto
  >
  [456.159306 thermal no longer high]
  [456.159574 set AP throttling type 1 to off (0x00000000)]
  > apthrottle
  AP throttling type 0 is on (0x00000001)
  AP throttling type 1 is off (0x00000000)
  > temps
    PECI                : 341 K = 68 C
    ECInternal          : 324 K = 51 C
    G781Internal        : 328 K = 55 C
    G781External        : 327 K = 54 C
  >
  [473.163905 thermal no longer warn]
  [473.164168 event set 0x00040000]
  [473.164453 event clear 0x00040000]
  [473.164670 ACPI query = 19]
  [473.164379 sci 0x00040000]
  [473.164987 set AP throttling type 0 to off (0x00000000)]
  temps
    PECI                : 340 K = 67 C
    ECInternal          : 324 K = 51 C
    G781Internal        : 328 K = 55 C
    G781External        : 327 K = 54 C
  >
  > apthrottle
  AP throttling type 0 is off (0x00000000)
  AP throttling type 1 is off (0x00000000)
  >

Change-Id: I9ee1491a637d7766395c71e57483fbd9177ea554
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168802
2013-09-11 01:49:48 +00:00
Randall Spangler
e6401d2e83 Initalize DMA before UART
This is in preparation for enabling DMA-based UART transfers, to
improve UART performance on STM32.

BUG=chrome-os-partner:20485
BRANCH=none
TEST=Boot pit.  Host commands should still be received; this verifies DMA
     is still operational.

Change-Id: Ibc3b2e2cd187547eb61b85e4a086704accd7f2fb
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168810
2013-09-10 23:46:07 +00:00
Vic Yang
462133fea5 Generalize 'charger' command to support BQ24192
This changes 'charger' to report '(unsupported)' when charger module
returns EC_ERROR_UNIMPLEMENTED, and continues even when there is an
error.

BUG=chrome-os-partner:22238
TEST=Run 'charger' command and check values are correct.
BRANCH=None

Change-Id: I5193ec436a10b2c3cbcc4013c846a7bea515864d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168734
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-10 19:40:08 +00:00
Vic Yang
db0b93609b kirby: Update battery voltage parameters
Nominal voltage is 3.7V and maximum voltage is 4.2V.

BUG=chrome-os-partner:22055
TEST=None
BRANCH=None

Change-Id: Ia1425ecebad49da676c1a22e4dcdbb43bebbd407
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168731
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-10 19:39:57 +00:00
Vic Yang
c0c90c6f18 kirby: Set LED color according to charging status
This sets LED to yellow for charging and battery-assist mode, green for
full and near-full, and red for error.

BUG=chrome-os-partner:22056
TEST=Unplug battery and see LED go red after 30 seconds
TEST=Charge battery and see yellow LED
TEST=See green LED when battery is charged
TEST=Unplug AC and see LED turned off
BRANCH=None

Change-Id: I7a512f3b0e6cbdf760c0cbd49cd63c26dc9f8539
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168182
2013-09-10 18:24:11 +00:00
Vic Yang
c2e8372b41 Show charging allowed info for 'battery' command
This will help us debug battery charging.

BUG=chrome-os-partner:22055
TEST=On Kirby, type 'battery' and check the output.
BRANCH=None

Change-Id: Id510ca7816f359e64072837df6464a412eb7739f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168181
2013-09-10 18:24:07 +00:00
Randall Spangler
8d921815bf Add comments about hooks and deferred functions
No code changes, only comments, and making gaia_suspend_deferred() static.

BUG=none
TEST=build pit
BRANCH=none

Change-Id: I96448bd3b7457f2a0ec25276167d2740d0cd0c52
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168231
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-09-06 19:16:23 +00:00
Wonjoon Lee
2dc4680dee pit: Add board specific keyscan config
This timing values act as most similar with 8042 which we used in snow
And some keyscan jig can not regognize current debounce timing, It based
on 8042 timing.

BUG=chrome-os-partner:22019
TEST= build and update ec, reboot and see keyscan is fine

Change-Id: I48f01f2e1247db5fa324b0896301616c42032585
Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/168003
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Randall Spangler <rspangler@chromium.org>
2013-09-06 17:27:18 +00:00
Aaron Durbin
06aebc4f95 falco: delay LCD VCC enable by 270ms
Much like the backlight signal the LCD VCC enable signal
needs to be delayed to ensure the panel timings are correct.
It's problematic because the LVDS bridge is a black box. The
signals need to be scoped to ensure everything eventually matches
up.

BUG=chrome-os-partner:21234
BRANCH=falco
TEST=Built and booted. Panels still come up. Dexter determined the
     proper delay.

Change-Id: I6e61d1dfa9ad03be1735d05d8d8ff2549a7b0db2
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167620
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-06 17:03:06 +00:00
Bill Richardson
2a31e2ac4b Add command for Haswell to pause in s5 at shutdown
At normal AP shutdown, Haswell systems skip S5 entirely and go directly to
G3. It's sometimes handy to pause in S5 as the other systems do, for things
like power-cycle tests that use the RTC to do a delayed wake from S5.

This CL adds a console command and a host command to enable/disable that
pause in S5.

The default is to skip S5, and the override value is not persistent across
EC reboots, so whenever the EC hibernates or reboots (Refresh + Power, software
sync), you'll have to re-enable it again.

BUG=chrome-os-partner:22346
BRANCH=falco,ToT
TEST=manual

On Haswell systems only.

To enable the pause in S5 at shutdown, do either of these:

  EC console:      gsv s5 1
  root shell:      ectool pause_in_s5 on

Shut the AP down politely, and it should pause in S5 for 10 seconds before
continuing to G3. You can see this by watching the EC console.

To disable the pause in S5 at shutdown, do any of these:

  EC console:      gsv s5 0
  root shell:      ectool pause_in_s5 off

or

  press Refresh + POWER

Boot the system, then politely shut down. This time it should go directly to
G3 without pausing in S5.

Change-Id: I324e6e2373bc20b61a731b4ef443d7bb8edb6b83
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168086
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2013-09-06 00:13:17 +00:00
Daisuke Nojiri
748154d55f Introducing MPU module for Cortex-M3
Preventing instruction fetch from RAM for Link except iram.text, which is used
for hibernation. Stm32 on Snow does not support MPU.

Tested on Link using commands 'crash nxtext/nxdata/nxstack', which run code from
.iram.text, .data section, and the stack, respectively:

...
RAM locked. Exclusion 20005980-200059a0
...

> crash nxtext
Running from 20005984

> crash nxdata

=== PROCESS EXCEPTION: 04 ====== xPSR: 61000000 ===
r0 :00000000 r1 :0000dff2 r2 :00000005 r3 :0000086d
r4 :00000000 r5 :00000032 r6 :2000544c r7 :00000000
r8 :00000000 r9 :20005456 r10:00000000 r11:00000000
r12:20005961 sp :20002748 lr :000008d7 pc :20005960
Instruction access violation
mmfs = 1, shcsr = 70001, hfsr = 0, dfsr = 0

=========== Process Stack Contents ===========
200027b0: 0000086d 00000002 0000d504 00009f27
200027c0: 2000544c 20005452 00000000 00000000
200027d0: 00000000 00000000 00000000 00000000
200027e0: 00000000 00000000 00000000 00000cbb

Rebooting...

> crash nxstack

=== PROCESS EXCEPTION: 04 ====== xPSR: 20000200 ===
r0 :00000070 r1 :00000047 r2 :00000000 r3 :200027a8
r4 :00000000 r5 :00000001 r6 :2000544c r7 :00000000
r8 :00000000 r9 :20005456 r10:00000000 r11:00000000
r12:00000002 sp :20002740 lr :00000913 pc :200027ac
Instruction access violation
mmfs = 1, shcsr = 70001, hfsr = 0, dfsr = 0

=========== Process Stack Contents ===========
200027ac: 00000070 00000047 00000002 0000d57c
200027bc: 00009f9f 2000544c 20005452 00000000
200027cc: 00000000 00000000 00000000 00000000
200027dc: 00000000 00000000 00000000 00000000

Rebooting...

BUG=chrome-os-partner:16904
BRANCH=master
TEST=stated above

Change-Id: I7c6593c527f29609442f33550f9d16755f32297c
Signed-off-by: Daisuke Nojiri <dnojiri@google.com>
Reviewed-on: https://chromium-review.googlesource.com/51337
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-05 19:06:27 +00:00
Vic Yang
b0d559a918 Enable charging on Kirby
Now that we have battery and charger drivers, let's enable charging.

BUG=chrome-os-partner:22055
TEST=Test charging/discharging on Kirby
TEST=Unplug battery and see 'error' state
TEST=Plug battery and doesn't see error anymore
BRANCH=None

Change-Id: Idff513b38c9f5bb90700877750f3d2e2154d4b23
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168007
2013-09-05 10:11:48 +00:00
Vic Yang
c4da0e4461 Set termination current to minimum for BQ24192 charger
The charger stops charging when charging current is smaller than this
value. To maximize battery life, let's set this value to its minimum so
that the battery is charged to as full as possible.

BUG=chrome-os-partner:22238
TEST=Test charging on Kirby with the next CL
BRANCH=None

Change-Id: I528dd0668244cba480538b825fff1cf28d7748ec
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168006
2013-09-05 10:11:44 +00:00
Vic Yang
b75a3ee153 Allow parallel unit testing in make_all.sh
We are already applying arguments of make_all.sh to building ec binary
for each board. Let's also apply them to 'make runtests'.

BUG=None
TEST=util/make_all.sh -j8
BRANCH=None

Change-Id: I267aee662c015e65b737640815dbbb0cb72c58ba
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167826
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-05 07:21:30 +00:00
Vic Yang
b448746bac Add boot key test
This checks boot key combination like Power-F3-ESC and Power-F3-Down can
be properly detected.

BUG=chrome-os-partner:19236
TEST=Pass kb_scan test
BRANCH=None

Change-Id: I180918977299219a8421798dac2ab9fed84ef9a2
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167802
2013-09-05 07:20:56 +00:00
Vic Yang
6c3be20539 Add multi-step test support
We already have a multi-step test. Let's move it to test_util.c so that
upcoming tests can also use it.

BUG=chrome-os-partner:19235
TEST=Pass all tests
BRANCH=None

Change-Id: I6b7a036297f3b4b2778687488d1dc5b5bb4fe255
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167950
2013-09-05 07:20:46 +00:00
Vic Yang
30136468c0 Extend charge state machine to accommodate Kirby
Currently only x86 platform uses charge_state.c, and it's been tailored
to fit smart battery and bq247xx charger family.

For Kirby, we have different types of battery and charger, and thus need
to make some change to accommodate them. This includes:
  - Abstract out smart battery specific bit mask
  - Implement missing functions required by GAIA chipset module
  - Add config flags for charging-enabled GPIO pin
  - Allow battery that doesn't report desired voltage and current

BUG=chrome-os-partner:22055
TEST=Build all boards
TEST=Boot Link and check it charges/discharges battery
TEST=Test charging/discharging on Kirby along with the next two CLs
BRANCH=None

Change-Id: I910c030a45b4f775afffec0127cdc31e89b9dd55
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168005
2013-09-05 07:20:18 +00:00
Vic Yang
0492ff9204 Temporary OTG and external power support
This is only for initial bringup that requires OTG to boot kernel. Note
that we are expecting firmware for USB ID detection and hardware change
to charger chip, so this is likely going to be thrown away.

BUG=chrome-os-partner:21964
TEST=Plug in OTG dongle and check VBUS voltage is ~5V
TEST=Unplug and check it's ~0V.
BRANCH=None

Change-Id: Iee66bef117188fea14a76459945be3bf5afef0dd
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167832
2013-09-05 07:20:13 +00:00
Vic Yang
4f09144839 kirby: Enable backlight in S0
When the AP is powered on, turn on backlight. Also turn off backlight
when going into S3/S5.

BUG=chrome-os-partner:21964
TEST=Power on and see backlight lit. Power off and see it turned off.
BRANCH=None

Change-Id: I77141848466db3209aa0eba2613057002bd3432a
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167800
2013-09-05 07:20:09 +00:00
Vic Yang
93cb494a7e Add BQ27541 battery driver
BQ27541 is not a smart battery IC, and thus we cannot use existing smart
battery driver. Let's add a driver that implements a smart-battery-like
interface.

The 'battery' console command is also moved to battery.c so that it can
be reused by different battery driver.

BUG=chrome-os-partner:22048
TEST=Type 'battery' and check the reported values are sane.
TEST=Check 'battery' command works fine on Spring.
BRANCH=None

Change-Id: I5d1eaeb3f801478f3b9473fd43c1f2a2eda75859
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/66340
2013-09-05 07:19:59 +00:00
Bill Richardson
3f2eba22c5 Add a generic get/set host command
This adds EC_CMD_GET_SET_VALUE to the list of host commands. We have a bunch
of single-value getter/setter commands, which is wasteful. This is a start
towards unifying them into a simpler command.

BUG=chromium:285358
BRANCH=ToT,falco
TEST=none

There's nothing to test just yet. This just adds the command and some basic
interfaces. A future commit will make use of it.

Change-Id: Iee986b9d273b422bb06f3a0c9b7af50617f03d7f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/168083
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-05 03:10:54 +00:00
Vic Yang
b36222723b kirby: Rename AC_PRESENT to AC_PRESENT_L
This signal is active low (1=no AC, 0=AC good.) Renaming it to
AC_PRESENT_L so that it's not confusing.

BUG=chrome-os-partner:21964
TEST=Build kirby
BRANCH=None

Change-Id: I17b555945c647f4a24b1920cdb8992b3a5767462
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167458
2013-09-05 03:10:19 +00:00
Vic Yang
ba57c3141a Add Kirby ADC channel definition
Kirby has the same ADC channels as Spring, but with different scales and
pin assignments.

BUG=chrome-os-partner:22055
TEST=Read ADC channel voltage
BRANCH=None

Change-Id: Ibb618a77647c0477eeb0e8d983df07a258fdb75a
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167460
2013-09-05 03:10:16 +00:00
Vic Yang
b57a5fe0ed STM32L ADC driver
ADC module on STM32L is clocked by HSI oscillator, and thus we need to
switch to HSI if using MSI. After the conversion, if the system is not
in S0, clock is switched back to MSI again.

There are several register bits that can only be written when ADC is
powered down. For now, let's just power down the ADC after each
conversion.

Currently ADC watchdog is not working and is disabled on STM32L.

BUG=chrome-os-partner:22242
TEST=Try multiple all-channel and single-channel reads in S0 and S5.
BRANCH=None

Change-Id: I769dda8a9c69ac9de1eb22d6d259034eef8c1ac4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167454
2013-09-05 03:10:09 +00:00
Vic Yang
c34d0cc8bf kirby: Add delay before enabling 3.3V rail
A delay between enabling PMIC_PWRON and 3.3V rail is needed so as to
prevent leakage.

BUG=chrome-os-partner:22101
TEST=Power cycle the AP.
BRANCH=None

Change-Id: I2dd1c7ebc71565fc64dacaeb5caa46b2d3801d50
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167582
2013-09-05 03:10:05 +00:00
Vic Yang
74b6f76872 Implement emulator clock fast-forwarding
When running an unit test, the emulator is sitting in idle task for most
of the time. Since we don't have interrupt support now, the emulator is
just waiting for the next wake-up timer to fire. To save time, we can
actually just figure out which task is the next to wake up, and then
fast-forward the system clock to that time.

With this, all tests run faster and we can remove time-scaling for all
current tests. This improves not only run time but also stability.

If one day we have interrupt support, then we will have to modify this
to take into account the fact that an interrupt might wake a task before
any wake-up timer fires.

BUG=chrome-os-partner:19235
TEST=Run all tests in parallel for 1000 times.
BRANCH=None

Change-Id: I4cd33b041230267c110af015d425dd78d124f963
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167801
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-04 20:32:55 +00:00
Vic Yang
844f4127e8 Add host command test
This test checks host command interface handles errors correctly.

BUG=chrome-os-partner:19236
TEST=Pass host_command test
BRANCH=None

Change-Id: I62764977d2063edf5abd37e78e074384eec5f0d4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167762
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-04 20:32:52 +00:00
Vic Yang
04d8465b75 Also test temp sensor read delegation in thermal test
Temperature sensor read is delegated to functions defined in board.c.
Let's mock that function instead of the one in temp_sensor module.

BUG=chrome-os-partner:19236
TEST=Pass thermal test.
BRANCH=None

Change-Id: Ic0387bd6a49e3f032e593c11c6f80bd36f8474e7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167761
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-04 20:32:49 +00:00
Vic Yang
f2046ce3dc Flush test coverage information before rebooting emulator
If we reboots the emulator without flushing test coverage information,
the test coverage report will be incorrect. Let's fix this by flushing
it before every reboot.

BUG=chrome-os-partner:19235
TEST=Generate test coverage report and check correctness.
BRANCH=None

Change-Id: I1eb060e419b767f382325bed841366c491ba56b7
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167770
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-04 20:32:45 +00:00
Vic Yang
1764246ee9 Add unit test for 'chan' command
Command 'chan' is used by servod. Let's add an unit test for it.

BUG=chrome-os-partner:19236
TEST=Pass console_edit test
BRANCH=None

Change-Id: If86e052fa6720d952a8d9fe8745432dc4a458869
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167614
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-04 20:32:37 +00:00
Vic Yang
4bdfc7eb7b Add more charge state machine test
This includes:
  - Charge mode control host command
  - Low battery shutdown/hibernate

Also, speed up the test by 20x since we now need to wait for more than
30 seconds for low battery state test.

BUG=chrome-os-partner:19236
TEST=Pass the test
BRANCH=None

Change-Id: If2e91a33f3a80f58da01a6c3da128cb603101dea
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167613
Reviewed-by: Rong Chang <rongchang@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-04 20:32:33 +00:00
Vic Yang
2270f2bb03 Fix a bug that GPIO cannot be set as input on stm32l
GPIO_INPUT is defined as 0, and any GPIO flag cannot be examined against
GPIO_INPUT. Change GPIO_INPUT to non-zero value to avoid this.

BUG=chrome-os-partner:22275
TEST=On Kirby, set a GPIO to output and pull it low, and then set it back to
input. Check it can be pull high externally.
TEST=Build all boards.
TEST=Boot link and spring.
BRANCH=None (unless this bug hits some other boards.)

Change-Id: I84b9936c24af538ac59c36129fda27ca879bf9d1
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167190
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-04 05:45:52 +00:00
Vic Yang
b99f913107 kirby: Pull XPSHOLD low to shut down the AP
On Kirby, the EC has no direct control over several power rails. To shut
down the AP, we need to pull low XPSHOLD from the EC so that PMIC would
turn off AP power.

BUG=chrome-os-partner:22101
TEST=Repeatedly do 'power on' and 'power off'.
TEST=Reboot the EC and see AP booted.
BRANCH=None

Change-Id: I21d04e46a6cfb455ced073389a928f2549d5212d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167201
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-09-04 05:45:47 +00:00
Dave Parker
04da610528 Peppy: Set battery pre-charge current to worst case value.
Which in this case is the max across batteries we plan to ship.

BUG=chrome-os-partner:20801
BRANCH=peppy
TEST=Difficult to test without a deeply discharged battery.

Change-Id: Ieeb8fafc1768accb3cd2cd85a919b232aab77343
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167555
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
2013-09-03 23:38:51 +00:00
Dave Parker
aead5bb502 Peppy: Clean up some outdated comments.
BUG=None
BRANCH=peppy
TEST=None

Change-Id: I9a218ce74f6e3210acf4fa6eb7595d4ccbaf2f77
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167701
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
2013-09-03 23:38:01 +00:00
Dave Parker
10f58e5f19 Peppy: Correct adc calculation of charger current
BUG=chrome-os-partner:22405
BRANCH=peppy
TEST=Run 'adc' command. Measure charger current reported against
actual current.

Change-Id: I1772a781d9d0100e69a5fd1e9a9590252ccd88d6
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167711
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Shawn Nematbakhsh <shawnn@chromium.org>
2013-09-03 23:37:44 +00:00
Bill Richardson
32045efb23 Add LIGHTBAR_CMD_VERSION command to detect lightbar features.
Most systems don't have a lightbar. Those that do need a way to detect that
one exists. That's easily done by just sending a EC_CMD_LIGHTBAR_CMD command
to the EC and checking the result. If the response is
EC_RES_INVALID_COMMAND, there isn't a lightbar.

But what .cmd value should we use in struct ec_params_lightbar? Future
lightbar implementations (if any), could remove existing functions or add
new ones, so there isn't a safe choice.

This change adds a LIGHTBAR_CMD_VERSION operation to determine if any new
implementation exists. Future systems should return some useful information
in response to this command. Existing systems will return
EC_RES_INVALID_PARAM, which is enough to distinguish them.

BUG=chromium:239205
BRANCH=none
TEST=manual

make BOARD=link
make BOARD=link runtests

There are no user-visible changes in functionality to anything.

Change-Id: Ibe37f74a4dcbf68dd6bfd1963530aec907e67534
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/167549
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-08-30 16:47:14 +00:00