Commit Graph

132 Commits

Author SHA1 Message Date
Randall Spangler
2ad076f8a0 cleanup: Rename and move header files
Device-specific headers belong in driver/ or chip/.  The include/
directory should be for common interfaces.

Code should not normally need to include driver-specific headers.  If
it does, it should use the full relative path from the EC project root
(for example, drivers/charger/bq24715.h).

Change-Id: Id23db37a431e2d802a74ec601db6f69b613352ba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173746
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-23 21:27:40 +00:00
Vic Yang
99472d5cb5 Re-enable basic tests for most LM4-based boards
Basic tests are actually working for most LM4-based boards. Let's
re-enable them except for Bolt and Samus. These two boards have
board-specific chipset code, which fails test compilation.

BUG=chrome-os-partner:18598
TEST=Run affected tests on Link
TEST=util/make_all.sh
TEST='make tests' for all board
BRANCH=None

Change-Id: I46bc39c14ec43ccc29e9b0c46f349cac2755e684
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/172982
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Jeremy Thorpe <jeremyt@chromium.org>
2013-10-17 09:24:13 +00:00
Randall Spangler
99157c265c cleanup: Battery header files and filenames
battery.h is the high-level interface.  battery_smart.h is the
low-level interface.  Most things don't need the low-level interface,
but were including smart_battery.h solely to get at battery.h.  Fixed
this.  Also merged battery_pack.h into battery.h, since it was odd to
split that data across multiple header files.  Tidied the function
comments in battery.h as well.

No functional changes, just renaming files and adding comments.

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

Change-Id: I5ef372f0a5f8f5f36e09a3a1ce24008685c1fd0d
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171967
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-07 18:30:50 +00:00
Randall Spangler
90a6676ad5 cleanup: Move board-specific LED state machines to board dirs
The LED state machine ends up being very board-specific, as does the
specific configuration of LEDs and whether they're PWM'd or just
GPIOs.  dparker has some clever ideas for how to move more of the
functionality to common/led_common.c (used at present only by peppy);
that will be done as a follow-on to this CL.

There's a unit test for the spring LED implementation.  To keep that
compiling, just use a symlink to the spring-specific implementation.

No code changes; just moving around files.

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

Change-Id: I5973e701a29a72575db9a161dc146855ab21cca6
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171771
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-07 18:30:45 +00:00
Vic Yang
bd74ad1e20 Test more error cases of host command handling
This adds tests of invalid command version and invalid command.

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

Change-Id: I49ce1b4c8b31ef98d9ee8203e88adfa521471d6d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170935
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-10-01 08:16:38 +00:00
Vic Yang
c77575ac0d Emulator support of fake GPIO input
For all GPIOs, the current values are recorded. A test can then change
the value of a GPIO input by gpio_set_level(). The changed value is
recorded and also interrupt is fired if the change fits the interrupt
flags defined in board/host/board.c.

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

Change-Id: If8e547e5adf4a20dcb118f5fe2187293005d4ca3
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170907
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-10-01 08:16:34 +00:00
Bill Richardson
af34e526db Create samus board config
This just does a copy/rename from Bolt. Tweaking for Samus' peculiarities
will come next.

BUG=chrome-os-partner:22870
BRANCH=none
TEST=manual

The only thing we can check is that it compiles:

  cd src/platform/ec
  make BOARD=samus

Change-Id: Ied95ebdd1137548b21334b4a65a298c68482c517
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/171081
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-30 18:58:19 +00:00
Randall Spangler
84ba188120 Support backlight control via lid only
The old backlight_x86 code did

  (backlight enable) = (lid is open) && (GPIO request from AP)

Newer systems will AND those signals in hardware.  Support those
systems by separating CONFIG_BACKLIGHT_LID and
CONFIG_BACKLIGHT_REQ_GPIO, and add tests for the case where the enable
signal is dependent only on the lid position.

BUG=chrome-os-partner:22960
BRANCH=none
TEST=pass unit tests

Change-Id: I1909426e49f00a8acd5047fd88c801cba1dacd76
Reviewed-on: https://chromium-review.googlesource.com/170925
Tested-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Randall Spangler <rspangler@chromium.org>
2013-09-27 23:07:21 +00:00
Vic Yang
1e16031f75 Add a test for x86 backlight passthrough
This checks x86 backlight passthrough by toggling lid switch and PCH
backlight output, and also by host command.

Also fix a bug that backlight switch host command can never be invoked
due to incorrect version mask.

BUG=chrome-os-partner:19236
TEST=util/make_all.sh
BRANCH=None (unless some platform needs backlight switch host command)

Change-Id: Iefc5f4b7387c4d2aa43059d073bd70aed879fe34
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170758
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-27 04:33:40 +00:00
Vic Yang
1b1bf3f03f Test charging error state when battery is detached
This checks charge state machine goes into error state when battery is
not responding.

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

Change-Id: I61970c4d88cbb0d6242613cdc87b88da7ae3f2f4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170753
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-27 04:33:36 +00:00
Vic Yang
9ce364fce0 Add test for LP5562 LED control
This adds a test for LP5562 LED control. The test mocks charging and
battery status and check LED behavior is as expected.

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

Change-Id: Iac6b538b24c555bf48b6824f880091cd11a585d4
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170597
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-25 19:18:20 +00:00
Vic Yang
45bcffd91a Add test for memory-mapped switch information
This checks power button and lid switch states are updated correctly to
memory-mapped region.

BUG=chrome-os-partner:19236
TEST=Pass power_button and lid_sw tests
BRANCH=None

Change-Id: Ia49b5a3142b5fd47985bc6f53b1bbffd6d4bbeac
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170438
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-25 19:18:15 +00:00
Vic Yang
1e08d488bd Mock flash erase/write function at physical layer
This moves the mock function from common layer down to physical layer to
complete the test of common layer.

Also disable flash test for hardware tests, as this is only testing
common layer.

BUG=chrome-os-partner:19236
TEST=util/make_all.sh
BRANCH=None

Change-Id: Idd1c2c44591952894486f84d428872cfbf2cfdad
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170297
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-09-24 21:00:25 +00:00
Randall Spangler
6277f7e336 Fix thermal.c compilation if fans are not present.
Currently, it doesn't compile unless CONFIG_FAN is defined.

BUG=chrome-os-partner:22803
BRANCH=none
TEST=temporarily undefine CONFIG_FAN in board/link/board.h; code compiles
     and all unit tests pass

Change-Id: I251d670ccd299f7a50b1455364a817e07fad4cb1
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/170106
2013-09-23 21:26:26 +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
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
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
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
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
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
Bill Richardson
8c7a18616f Falco: throttle if battery current drain is too high
I missed this requirement the first time. Now it's here. Also adding a test
for it as well.

BUG=chrome-os-partner:20739
BRANCH=falco
TEST=manual

make BOARD=falco runtests

Change-Id: I88aac8d12d09f7970b04c4aa02b6986b5ea16306
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/66684
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2013-08-23 10:38:57 -07:00
Bill Richardson
fcce7223a5 Completely new thermal/fan implementation
Problems with existing thermal control loop:
* Not multi-board friendly. thermal.c only supports Link and needs
  refactoring. Temp thresholds and fan speeds are hard-coded.
* Only the PECI temp is used to determine the fan speed. Other temp sensors
  are ignored.
* Has confusing data structures. Values in the CPU temp thresholds array mix
  ACPI thresholds with fan step values.

With this change, the thermal task monitors all temp sensors in order to
perform two completely independent functions:

Function one: Determine if the host needs to be throttled by or informed of
              any thermal events.

For thermal events, each temp sensor will have three threshold levels.

TEMP_HOST_WARN
* When any sensor goes above this level, host_throttle_cpu(1) will be called
  to ask the CPU to slow itself down.
* When all sensors drop below this level, host_throttle_cpu(0) will be called.
* Exactly AT this level, nothing happens (this provides hysteresis).

TEMP_HOST_HIGH
* When any sensor goes above this level, chipset_throttle_cpu(1) will be
  called to slow the CPU down whether it wants to or not.
* When all sensors drop below this level, chipset_throttle_cpu(0) will be
  called.
* Exactly AT this level, nothing happens (this provides hysteresis).

TEMP_HOST_SHUTDOWN
* When any sensor is above this level, chipset_force_shutdown() will be
  called to halt the CPU.
* Nothing turns the CPU back on again - the user just has to wait for things
  to cool off. Pressing the power button too soon will just trigger shutdown
  again as soon as the EC can read the host temp.

Function two: Determine the amount of fan cooling needed

For fan cooling, each temp sensor will have two levels.

TEMP_FAN_OFF
* At or below this temperature, no active cooling is needed.

TEMP_FAN_MAX
* At or above this temperature, active cooling should be running at maximum.

The highest level of all temp sensors will be used to request the amount of
active cooling needed. The function pwm_fan_percent_to_rpm() is invoked to
convert the amount of cooling to the target fan RPM.

The default pwm_fan_percent_to_rpm() function converts smoothly between the
configured CONFIG_PWM_FAN_RPM_MIN and CONFIG_PWM_FAN_RPM_MAX for percentages
between 1 and 100. 0% means "off".

The default function probably provide the smoothest and quietest behavior,
but individual boards can provide their own pwm_fan_percent_to_rpm() to
implement whatever curves, hysteresis, feedback, or other hackery they wish.

BUG=chrome-os-partner:20805
BRANCH=none
TEST=manual

Compile-time test with

  make BOARD=falco runtests

On the EC console, the existing fan commands should work correctly:

  faninfo       - display the fan state
  fanduty NUM   - force the fan PWM to the specified percentage (0-100)
  fanset RPM    - force the fan to the specified RPM
  fanset NUM%   - force the fan to the specified percentage (0-100) between
                  its configured minimum and maximum speeds from board.h
                  (CONFIG_PWM_FAN_RPM_MIN and CONFIG_PWM_FAN_RPM_MAX)
  fanauto       - let the EC control the fan automatically

You can test the default pwm_fan_percent_to_rpm() with

  fanset 1%
  faninfo

The fan should be turning at CONFIG_PWM_FAN_RPM_MIN. Let the EC control it
automatically again with

  fanauto

Also on the EC console, the thermal settings can be examined or changed:

  > temps
  PECI                : 327 K = 54 C
  ECInternal          : 320 K = 47 C
  G781Internal        : 319 K = 46 C
  G781External        : 318 K = 45 C
  >
  > thermalget
  sensor  warn  high  shutdown   fan_off fan_max   name
    0      373   387    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
  >
  > help thermalset
  Usage: thermalset sensor warn [high [shutdown [fan_off [fan_max]]]]
  set thermal parameters (-1 to skip)
  >
  > thermalset 2 -1 -1 999
  sensor  warn  high  shutdown   fan_off fan_max   name
    0      373   387    383        333     363     PECI
    1        0     0      0          0       0     ECInternal
    2        0     0    999          0       0     G781Internal
    3        0     0      0          0       0     G781External
  >

From the host, ectool can be used to get and set these parameters with
nearly identical commands:

  ectool thermalget
  ectool thermalset 2 -1 -1 999

Change-Id: Idb27977278f766826045fb7d41929953ec6b1cca
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/66688
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-08-23 10:38:36 -07:00
Vic Yang
0e9d829e91 Add test for console command history
This tests that command history is as expected. Also fix a bug that some
checks in console_edit test are skipped.

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

Change-Id: Ifbd3d1690f25b35bf5efe523e656b013aa534d26
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64837
2013-08-18 04:27:27 -07:00
Dave Parker
2de1f07579 Remove board 'wolf' from master/ToT branch.
Firmware development for this board is happening on the
firmware-wolf-4389.24.B branch.

BUG=chrome-os-partner:21815
BRANCH=None
TEST=Run util/make_all.sh. Verify all is made.

Change-Id: I4b58a982a87562231453f3f201024b809c6a24fb
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65514
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-08-12 18:19:57 -07:00
Bill Richardson
0c8c2e453a Add abstract "cond_t" type to detect state transitions.
We often need to watch for transitions between one state and another, so
that we can issue warnings or take action ONCE. This abstracts that "have I
already reacted to this" stuff into a single set of functions.

For example, this code reads a GPIO every time through the loop, but it only
generates an event when the GPIO value changes from 0 to 1:

    cond_t c;

    cond_init_false(&c);

    while(1) {
        int val = read_some_gpio();
        cond_set(&c, val);

        if (cond_went_true(&c))
            host_event(SOMETHING_HAPPENED);

        sleep(1);
    }

BUG=none
BRANCH=falco,peppy
TEST=manual

make BOARD=falco runtests

Change-Id: I42393fcf3c4eb71b9551118a0f442d55c0691315
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/65071
2013-08-09 15:44:09 -07:00
Vic Yang
19e30d9c7d Remove proxy config flags for unit tests
This moves per-test config flags from test_config.mk to test_config.h,
where one can define/undefine config flags for individual test.

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

Change-Id: I096aded2007881433d3b6414d37f8bfdc6a2c45c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64367
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-08-04 13:11:08 -07:00
Bill Richardson
298a7276c2 Add turbo mode charger support, and tests for it.
Some chargers can run in a "turbo" mode, which lets it draw from the battery
to provide extra power to the AP in short bursts. In order for this to work
properly, the EC has to watch the current closely to make sure specific
limits are observed. It also has to recognize specific adapters, since those
limits vary depending on the rated power that the adapter can provide.

This adds the basic functionality, plus a test for it.

BUG=chrome-os-partner:20739
BRANCH=falco,peppy
TEST=manual

  make BOARD=${BOARD} runtests

On Falco, you can also use the "adapter" EC command to see what's going on.
Try replacing the adapters and running that command to be sure they're
correctly identified, too:

  > adapter
  Adapter 65W (590mv), turbo 1, AP_throttled 0
  >

We currently support 45W, 65W, and 90W adapters. Unknown adapters are
treated as 65W, but don't enable turbo mode.

Change-Id: I7e5407db825ce7e596cb495fb8cb4d1dd1ff639c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63372
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-25 15:50:13 -07:00
Bill Richardson
4231660869 Change macro names used for test configurations
We can't change CONFIG_ options from the gcc commandline, because
include/configs.h explicitly undefs them again. So for some tests, we add a
-DFOO to the command line and then put this in the source:

This change just uses TEST_FOO instead of FOO, so it's more obvious what's
happening.

BUG=chrome-os-partner:20739
BRANCH=falco,peppy
TEST=manual

No functional change, just renaming. Run

  make BOARD=${BOARD} runtests

Everything should still pass.

Change-Id: I17e10180f8d779dff0961cf411f5b61cfc70c316
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63371
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-25 15:50:12 -07:00
Rong Chang
6c280b1b32 Move TPSChrome charging temperature range to battery pack
This change moves vendor specific temperature ranges to battery pack
files or board setup files. And added a host test case to verify that
does not change x86 smart battery charging state machine behavior.

BUG=chrome-os-partner:21181
BRANCH=None
TEST=manual
  build test: util/ecmakeall.sh
  hosttests: make hosttests && make runtests

Change-Id: I48e76826b5555f64b78e3c063ce5f02416c72aa2
Signed-off-by: Rong Chang <rongchang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62978
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-07-24 13:07:13 -07:00
Aaron Durbin
7b95d397fe bolt: add prelimnary support
The preliminary bolt support allows the board to boot
with all the necessary peripherals working except for the
following things:
- Not all board temp sensors are added.
- WLAN is not powered on because of inrush issues.
- USB power chargers are fixed to normal mode for now.

BUG=chrome-os-partner:20372
BRANCH=None
TEST=Built and booted

Change-Id: Iea7a39e812bb396e5731f212630b7fe97c164bf2
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62210
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-24 12:09:50 -07:00
Vic Yang
eda52c4ab4 Lessen timing constraints in hooks test
HOOK_TICK and HOOK_SECOND aren't firing with precise interval. Let's
lessen the timing constraints.

BUG=chromium:263288
TEST=Pass all tests
BRANCH=None

Change-Id: Ic093c2a27ed1b8621469a4097e567b80d1eeb50d
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63144
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-23 19:02:33 -07:00
Vic Yang
f98def750d Test power button in kb_8042 test
This checks keycodes are sent correctly when power button is pressed.

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

Change-Id: Ibaa4ffce749167be5b8376aada0786f9760e7707
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62955
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-23 16:06:22 -07:00
Vic Yang
74abf36971 Test sysjump tag in kb_8042 test
This checks that keyboard state is preserved across system jump.

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

Change-Id: I53c5bb68246fd117b351d89c3907daf028bc4ef3
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62908
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-23 16:06:22 -07:00
Vic Yang
8218aa1346 Add system_common unit test
This tests reboot-on-ap-shutdown.

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

Change-Id: Ic1a07670f82646e85d014d52a2aba0835319c212
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62855
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-22 16:09:47 -07:00
Randall Spangler
873e4425c5 Remove unneeded direct includes of board.h and config.h
Both of these are included via common.h, which is in turn included by
most other header files.  Directly including board.h or config.h is
redundant and discouraged.

No code changes, just removing #includes.

This is in preparation for making a top-level config.h file, but that
change will be easier to review if it doesn't touch as many files.

BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms

Change-Id: I204bcebe5607c6e6808821eb071cfc31d2a93a7c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/62121
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-07-16 12:06:30 -07:00
Vic Yang
396cb8e69e Add console editing unit test
This tests console editing and history functionality.

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

Change-Id: Ia3edf2dd627d081fbcae7f775992d7570e5e1dd0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61555
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-11 22:32:53 -07:00
Vic Yang
7864372297 Add extpower-gpio unit test
This tests host event and hook are triggered when AC status changes.

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

Change-Id: I9e4263f3f6e273bfb0b24671a4e5c56b20a04e1a
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61554
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-11 22:32:52 -07:00
Vic Yang
2475cce9ad Add I8042 keyboard unit test
This tests I8042 scancode and typematic.

BUG=chrome-os-partner:19236
TEST=Pass all tests many times.
BRANCH=None

Change-Id: I8457b7b807b694b0bae32abf1647961f946dc5e1
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61553
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-11 22:32:52 -07:00
Vic Yang
4d270c1507 Add thermal host and console command test
This checks the functionality of thermal engine related host and
console commands.

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

Change-Id: I604ed3bfed3549b2573fac65da83450acd3f2797
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60964
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-11 04:26:14 -07:00
Vic Yang
62f2a33ff2 Add flash host read command test
This checks the correctness of data returned by flash read host command.

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

Change-Id: I3b97addb9b14922e9f33a71b865000ae9a8d40a8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60963
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-11 04:26:10 -07:00
Dave Parker
666bbdb3d7 Initial board commit for Wolf based on Slippy.
Additional fix-ups will come in subsequent CLs.

BUG=chrome-os-partner:20760
BRANCH=wolf
TEST=Verify "make BOARD=wolf" complete succesfully.

Change-Id: I24a37f3bebb1feb37c83c2c1b4f8f8db7bbcb2d8
Signed-off-by: Dave Parker <dparker@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61318
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
2013-07-09 16:20:14 -07:00
Randall Spangler
177dc398d3 Allow bigger flash write commands
Version 1 of EC_CMD_FLASH_WRITE will use as big a write as possible given
the available command parameter space.  Falls back to 64 byte writes on old
platforms.

BUG=chrome-os-partner:20571
BRANCH=none
TEST=Copy burn_my_ec onto a link and run it.  Write size should be 64 bytes
     for the first half of the update (since the old EC doesn't support ver.1
     of the write command) and 240 bytes for the second half of the update.

Change-Id: I5900de3a5700d7c82a2e0c3cf9921b7ced1c0343
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60511
2013-07-01 16:14:16 -07:00
Vic Yang
7381c7c5f6 More keyboard scan test
BUG=chrome-os-partner:19236
TEST=Pass the test
BRANCH=None

Change-Id: Ie0b0657c0bca2ec459cc8b04d9e06199b70414d9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58795
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-06-18 10:31:09 -07:00
Vic Yang
e03efaa475 More flash unit test
BUG=chrome-os-partner:19236
TEST=Pass the test
BRANCH=None

Change-Id: Idfbbdd40948ea4f8468cf9de95eee17e0d0773ed
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58794
2013-06-17 20:27:27 -07:00
Vic Yang
7de03b0f0e A method to mock host command
This will be used often, so let's move it to test_util.c.

BUG=chrome-os-partner:19235
TEST=Pass flash test.
BRANCH=None

Change-Id: I2f685f657f8742c2b29e3b9c88ba01daacf982f8
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58793
2013-06-17 20:27:27 -07:00
Vic Yang
aaac3935d2 Make target for test coverage report generation
By 'make coverage', lcov is used to generate test coverage report in
HTML format stored in coverage_rpt folder.

BUG=chrome-os-partner:19235
TEST=Generate a report.
BRANCH=None

Change-Id: I44142eaaeb897cf09179764781120370920144cd
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58203
2013-06-16 20:14:01 -07:00