Commit Graph

16 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
907c09ee38 task: Don't propagate TASK_EVENT_TIMER between between waits
In __wait_evt(), if a timer expiration occurs after we read event
status, before the timer is canceled, then TASK_EVENT_TIMER will be
propagated to the next task wait, likely leading to premature timeout.
Prevent this by clearing TASK_EVENT_TIMER after canceling our timer.

BUG=chrome-os-partner:58658
BRANCH=gru
TEST=Manual on gru, run 'pd # hard' for 12 hours with charger attached,
verify no TCPC I2C read errors occur.

Change-Id: Iac2f05a768b4ef29f82e7c3eb899f4c7dd5c3744
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400968
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-10-26 01:45:25 -07:00
Bill Richardson
0a4bb34bcd Add more CONFIG_CMD_* options for console commands
We have a large number of config.h options to enable/disable
specific console commands. This adds a few more that we will want
to control.

BUG=chrome-os-partner:57408
BRANCH=none
TEST=make buildall; try on Gru with and without CR50_DEV=1

Change-Id: Id41f0e9f44fc77feaf56853f357a6b33bb685b0c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/391614
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-10-01 00:02:01 -07:00
Bill Richardson
8c4421759d Cr50: Mark several console commands as safe
Even when CONFIG_RESTRICTED_CONSOLE_COMMANDS is enabled, there
are many commands that can't do anything dangerous. This marks
some of those commands as safe to use, even when restrictions are
enforced.

I'm only marking commands that are used by the Cr50, since that's
the only board that has restrictions.

BUG=chrome-os-partner:55322
BRANCH=none
TEST=make buildall, test on Cr50 hardware

Change-Id: I6289d332830175b6adcb6b20cb4c21d01d27a25e
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/376188
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-31 17:20:26 +00:00
Bill Richardson
bb15561db5 cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args
Since pretty much always, we've declared console commands to take
a "longhelp" argument with detailed explanations of what the
command does. But since almost as long, we've never actually used
that argument for anything - we just silently throw it away in
the macro. There's only one command (usbchargemode) that even
thinks it defines that argument.

We're never going to use this, let's just get rid of it.

BUG=none
BRANCH=none
CQ-DEPEND=CL:*279060
CQ-DEPEND=CL:*279158
CQ-DEPEND=CL:*279037
TEST=make buildall; tested on Cr50 hardware

Everything builds. Since we never used this arg anyway, there had
better not be any difference in the result.

Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374163
Reviewed-by: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-24 16:30:10 +00:00
nagendra modadugu
f623eaf077 timer: fix clock() implementation to match TPM2 library expectations
The clock() function was introduced to provide free running clock for
the TPM2 library, which expects this clock to run with a millisecond
resolution.

This patch fixes the bug where the function in fact was returning the
clock running at a microsecond resolution.

BRANCH=none
BUG=chrome-os-partner:43025,chrome-os-partner:47524
BUG=chrome-os-partner:50115
TEST=with the appropriate modification of the user of this function
      all lockout related TCG tests pass.

Signed-off-by: nagendra modadugu <ngm@google.com>
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361180
(cherry picked from commit b4e78b309900402499b8742199fb4536570d3000)
(cherry picked from commit fefaa02a4f2c807a3ad50137bd7dba7f5f081c31)
Change-Id: Ic02fffca610426d22e58609eb8c3693aec96ad5c
Reviewed-on: https://chromium-review.googlesource.com/362118
2016-07-21 17:32:28 -07:00
Gwendal Grignou
1d8fcfcd0d common: Add __fls function
Returns the most significant bit set.
Replace 31 - __builtin_clz(x), so x must be different from 0.
Use get_next_bit when not on the performance path,
on performance path set the bit field just after reading it.

BRANCH=smaug
BUG=none
TEST=compile, check Ryu still works.

Change-Id: Ie1a4cda4188f45b4bf92d0549d5c8fb401a30e5d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301300
2015-09-21 01:13:54 -07:00
Anton Staaf
7bdb69c464 UART: Remove unused uart.h header includes
Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j

Change-Id: Ife068807f79f6435292643c49afa1a9a30ae7080
Reviewed-on: https://chromium-review.googlesource.com/296733
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-08 10:38:20 -07:00
Vadim Bendebury
73a8098d79 export MSDN clock() function
TPM implementation requires a free running clock with granularity
better than a 10 us. clock_t definition comes from the toolchain
includes.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=none yet

Change-Id: Id3de5fd055aa598afe15657011b88d2c6be4cdfb
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289953
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-08-14 21:04:32 +00:00
Alec Berg
a90f4dd25e samus_pd: disable timerinfo command to save space
Disable the timerinfo command on samus_pd to save flash space

BUG=none
BRANCH=samus
TEST=make -j buildall
From .map file, 256 bytes saved

Change-Id: I6731967741cb28268499126f1753916319a1dcb4
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/264939
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-10 22:08:31 +00:00
Alec Berg
eb775b49b8 timer: usleep: Use HW clock to detect elapsed sleep time
If a non-timer task event is received while in usleep, we will again
attempt to sleep for the entire duration. This can cause an infinite
sleep in cases where a periodic task event occurs. Fix this by checking
the HW clock for our elapsed duration.

BUG=chrome-os-partner:36864
TEST=Manual on Samus. Verify that we don't get stuck in usleep during
VCORE_PGOOD interrupt storm.
BRANCH=Samus

Change-Id: Ie3ab8ce3c22822095845a3d9a6f33bd4b1273c6e
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/251311
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-02-21 00:49:32 +00:00
Myles Watson
04de0d4c61 common: Add a forcetime console command
BUG=chrome-os-partner:35312
BRANCH=none
TEST=make buildall -j
I added a debug message to nrf51/hwtimer.c to show when the timer overflowed.
"forcetime 4 0xfffff000" overflows to 5.00000000 in 4096 microseconds.

Define CONFIG_CMD_FORCETIME to enable it.

Change-Id: I30835d038ef8cd639565ffb7a638979d95d0a684
Signed-off-by: Myles Watson <mylesgw@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/239968
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-01-14 03:16:29 +00:00
Kenji Chen
be2ed33b19 EC: Ensure the udelay function waits at least the time indicated.
Udelay function might get delay less than the time indicated by the 
input parameter. udelay(4) sometimes get the tick like, 6->7->7->
8->8->9->A and then the udelay return. But, the sampling point of 6 
could be at the end of 6(close to 7) and the point of A could be 
right at the beginning of A(close to A). This function could get 
delay from (us - 1) to (us + 1). This change is to ensure the delay 
at least over the parameter, us.

BRANCH=master
BUG=None
TEST=Build an EC FW iamge and run on Rambi to ensure at the time
duration indicated by the parameter is elaspsed and satisfied.
Signed-off-by: Kenji Chen <kenji.chen@intel.com>
Change-Id: I797f80c577d7e29e75a304aec1e02d2c750f8a23
Reviewed-on: https://chromium-review.googlesource.com/224660
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
2014-10-23 22:41:08 +00:00
Vincent Palatin
4cf4fcf1cb ite: Add initial support for ITE IT8380 chip
Initial support for the ITE IT8380 chip with the following peripherals :
- 8250-like UART module.
- HW timer (with a 128-us tick period).
- GPIO with pins initialization and edge interrupt support.
other functions are stubbed.
- Clock : basic fixed frequency setup only.
It also add the dev board configuration as a test vehicle.

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

BRANCH=none
BUG=chrome-os-partner:23575
TEST=make BOARD=it8380dev
on IT8380 dev board, use the EC serial console, use gettime from
console.

Change-Id: Id4bf37d1beb21d1a4bee404c9a0bc500025fe787
Reviewed-on: https://chromium-review.googlesource.com/175481
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Alec Berg <alecaberg@chromium.org>
Tested-by: Alec Berg <alecaberg@chromium.org>
2014-01-08 02:24:23 +00:00
Randall Spangler
6ab8e91658 cleanup: Remove checkpatch warnings
This make minor syntactic changes and renames some camel-cased symbols
to keep checkpatch from complaining.  The goal is to reduce the
temptation to use 'repo upload --no-verify'.

This is a big furball of find/replace, but no functional changes.

BUG=chromium:322144
BRANCH=none
TEST=build all boards; pass unit tests

Change-Id: I0269b7dd95836ef9a6e33f88c003ab0f24f842a0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180495
2013-12-19 00:12:28 +00:00
Alec Berg
ebb8c88a59 Changed timer module to expire timers on deadline match
Modified the commond timer module to expire timers as soon as time matches
the deadline instead of only after the deadline is passed.

BRANCH=none
BUG=chrome-os-partner:24490
TEST=On a peppy:
- Run EC tests on host.
- Run all EC tests on the target.
- Keep the system on for days and occasionally verify that system is up and the keyboard is working.

On a spring:
- Run all EC tests on the target.

Change-Id: Ieabfb769cf22ff8b04ca6d0a306312b90ea20ff3
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/179460
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-12-12 23:07:48 +00:00
Vincent Palatin
1762de9d19 extract common core code
Move the non-core dependent code out of core/$(CORE) directory to
common/ directory.

Put all panic printing code in common/panic_output.c
Put timer management code in common/timer.c

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

BRANCH=none
BUG=chrome-os-partner:23574
TEST=./util/make_all.sh
use "crash divzero" and "panicinfo" on Link.

Change-Id: Ia4e1ebc74cd53da55fe24f69e96f39f512b9336d
Reviewed-on: https://chromium-review.googlesource.com/178871
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Jeremy Thorpe <jeremyt@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2013-12-05 22:30:58 +00:00