summaryrefslogtreecommitdiff
path: root/common/timer.c
Commit message (Collapse)AuthorAgeFilesLines
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* tree-wide: const-ify argv for console commandsCaveh Jalali2022-09-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | This updates the API for console commands from "int cmd(int argc, char **argv)" to "int cmd(int argc, const char **argv)" which is more accurate and in line with common convention. BRANCH=none BUG=b:244387210 TEST="make buildall" passes TEST="zmake build -a" passes TEST="util/compare_build.sh -b all" passes TEST="./twister -v -T zephyr/test" passes Cq-Depend: chrome-internal:4960125 Cq-Depend: chrome-internal:4959932 Change-Id: I57de9f35b85b8f3c7119df36aefb2abf25d2625f Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863941 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* common/timer: Make passing negative values to `waitms` an errorRobert Zieba2022-08-181-0/+3
| | | | | | | | | | | | | | | | This commit updates the `waitms` command so that passing a negative value will result in an error. BRANCH=none BUG=b:236074108 TEST=Built, ran subsequent zephyr test Change-Id: Ib1e9a05a5dc865b2bce71a2449016aa6863b289c Signed-off-by: Robert Zieba <robertzieba@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840650 Reviewed-by: Tristan Honscheid <honscheid@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
* util: remove unused includesYuval Peress2022-08-051-0/+1
| | | | | | | | | | | | | | | | Remove these includes as they're not needed in this header. Instead, the includes should go where they're actually being used. BRANCH=none BUG=b:240574048 TEST=make buildall -j TEST=zmake build -a Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I64b10af3216654b2a20caa1cabd267661a0bca39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3791980 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
* common/timer.c: Format with clang-formatJack Rosenthal2022-06-281-19/+13
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I335a82435cd3001f24d5eef7e209baf97b3d5016 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729756 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* zephyr: add a zephyr/ prefix to all zephyr includesFabio Baltieri2022-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This adds a zephyr/ prefix to all #include path pointing to Zephyr header files, so that we could drop LEGACY_INCLUD_PATH once all upstream code has been converted. Generated using something similar to the script in: c7b5b3c419 samples: migrate includes to contain <zephyr/...> prefix BRANCH=none BUG=none TEST=cq dry run Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I5ba2c859fe10a34ea8d3a49a612132ea4d02f2cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3634345 Reviewed-by: Yuval Peress <peress@google.com>
* common/timer: Disable interrupts when timer is updatedPatryk Duda2022-01-111-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | On systems with 32 bit counters, first clksrc_high variable (higher 32 bits) is updated then hardware counter is updated. When interrupts are enabled then eg. timer overflow could occur during update which leads to unpredictable behaviour. To avoid this problem, just make sure that interrupts are disabled before update. State is restored after timer update is finished. BUG=b:200828093 BRANCH=none TEST=make -j buildall TEST=Compile EC with CONFIG_CMD_FORCETIME enabled. Use 'forcetime' command to set time, then use 'timerinfo' to check if correct time is set. Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I4f36507d20ebd01d1d407812a3c4a2690163ed1b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3347658 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Patryk Duda <patrykd@google.com>
* common/timer: Make clksrc_high volatilePatryk Duda2022-01-111-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This variable is updated from interrupt context (process_timers() function, called from __hw_clock_source_irq()) and read in get_time() which is called when CPU is not in interrupt context. get_time() checks to see if clksrc_high was modified while obtaining lower 32 bits of the timestamp (__hw_clock_source_read() call): ts.le.hi = clksrc_high; ts.le.lo = __hw_clock_source_read(); if (ts.le.hi != clksrc_high) { ts.le.hi = clksrc_high; ts.le.lo = __hw_clock_source_read(); } Even though clksrc_high is not volatile, this works as-is because there is a call to a function outside the file (__hw_clock_source_read) between the first clksrc_high read and the second read in the if statement. The compiler doesn't know what the function outside the file does, so it assumes that clksrc_high could be updated. However, if the code was changed so that it didn't have the external call between the first clksrc_high read and the second, the compiler could optimize the code and assume that clksrc_high was not changed, which would eliminat the second read (and never execute the code in the if statement). To make sure that compiler does the right thing, add volatile keyword in clksrc_high variable declaration. BUG=b:200828093 BRANCH=none TEST=make -j buildall TEST=Disassemble get_time() function using following command: arm-none-eabi-objdump --disassemble=get_time \ ./build/bloonchipper/RW/ec.RW.elf Result before applying patch: 080690cc <get_time>: 80690cc: b570 push {r4, r5, r6, lr} 80690ce: 4d07 ldr r5, [pc, #28] 80690d0: 4604 mov r4, r0 80690d2: 686e ldr r6, [r5, #4] 80690d4: f7f8 fcc3 bl 8061a5e <__hw_clock_source_read> 80690d8: 686d ldr r5, [r5, #4] 80690da: 42ae cmp r6, r5 80690dc: d001 beq.n 80690e2 <get_time+0x16> 80690de: f7f8 fcbe bl 8061a5e <__hw_clock_source_read> 80690e2: e9c4 0500 strd r0, r5, [r4] 80690e6: 4620 mov r0, r4 80690e8: bd70 pop {r4, r5, r6, pc} 80690ea: bf00 nop 80690ec: 200013c0 .word 0x200013c0 Result after applying patch: 080690cc <get_time>: 80690cc: b5f8 push {r3, r4, r5, r6, r7, lr} 80690ce: 4e07 ldr r6, [pc, #28] 80690d0: 4604 mov r4, r0 80690d2: 6877 ldr r7, [r6, #4] 80690d4: f7f8 fcc3 bl 8061a5e <__hw_clock_source_read> 80690d8: 6875 ldr r5, [r6, #4] 80690da: 42af cmp r7, r5 80690dc: d002 beq.n 80690e4 <get_time+0x18> 80690de: 6875 ldr r5, [r6, #4] 80690e0: f7f8 fcbd bl 8061a5e <__hw_clock_source_read> 80690e4: e9c4 0500 strd r0, r5, [r4] 80690e8: 4620 mov r0, r4 80690ea: bdf8 pop {r3, r4, r5, r6, r7, pc} 80690ec: 200013c0 .word 0x200013c0 Please note that there is additional clksrc_high load before second call to __hw_clock_source_read() (inside the if statement). Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ie701af387107bf76f07874d9eff1dc65fc844cf4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3347655 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Patryk Duda <patrykd@google.com>
* atomic: cast pointers to atomic_t* for atomic_* callsDawid Niedzwiecki2021-11-291-3/+3
| | | | | | | | | | | | | | | | | Some atomic_* calls use pointers to different types of variables than atomic_t. Cast those to atomic_t* to avoid compilation errors. It shouldn't change the generated code. BUG=b:207082842 TEST=make buildall && zmake testall && build_compare.sh -b all BRANCH=main Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I5d8e8eca7c5d7fe661c75bc75f82c49083c88be0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3300319 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
* zephyr: test: Make get_time mockableAaron Massey2021-10-281-0/+9
| | | | | | | | | | | | | | | | | | Some driver code paths require control of the return value of get_time in order to be properly tested. Now get_time can be mocked during tests. BRANCH=none BUG=b:184856083 TEST=zmake testall and make runhosttests Signed-off-by: Aaron Massey <aaronmassey@chromium.org> Change-Id: I7f66542aaef015263af66d872978c40746a77292 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3219471 Commit-Queue: Aaron Massey <aaronmassey@google.com> Tested-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Yuval Peress <peress@google.com>
* tree: Make all console commands staticTom Hughes2021-10-151-1/+1
| | | | | | | | | | | | | | Almost all of the console commands were already static. This change makes all of them static for consistency. BRANCH=none BUG=b:172020503 TEST=make buildall -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I0ac46358b6fbafa65504c648ce4de0365cdbf723 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3224372 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* mchp: Check parameter us in void usleep(unsigned us)martin yan2021-09-221-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Check parameter us in void usleep(unsigned us) under common, to avoid triggering ASSERT(us), it may be a good idea to figure out which caller to pass 0 parameter, but it may be difficult during run-time. remove ASSERT(us) in this usleep() routine BUG=none BRANCH=none TEST=Tested on ADL RVP and MCHP1727 MECC system without parameter 0 checking, ASSERT(us) is triggered as POR: [0.482657 power_chipset_init: power_signal=0x0] [0.484735 SW 0x01] ASSERTION FAILURE 'us' in usleep() at common/timer.c:184 === PROCESS EXCEPTION: 00 ====== xPSR: 000cfb43 === r0 :000000b8 r1 :000e9aa6 r2 :000e9ad0 r3 :000d1a51 r4 :dead6663 r5 :000000b8 r6 :000765f4 r7 :00040314 r8 :00118e00 r9 :000e4aa8 r10:000e456c r11:00000000 r12:00000000 sp :0011b420 lr :00000030 pc :00000030 after checking is added, ASSERT(us) is not hit Signed-off-by: martin yan <martin.yan@microchip.corp-partner.google.com> Change-Id: I2f58ea132da7bf7a5dd315a69675013617eb0a64 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3138620 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
* common/timer: Fallback to udelay when interrupt conditions are not metPatryk Duda2021-09-081-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | To call usleep() we must be sure that interrupts are enabled and we are not in interrupt context. This is required because hardware timer is used to make sleeping task ready. Also on Cortex-M task switching is not working properly when interrupts are disabled. If above conditions are not met, just print warning and use udelay(). BUG=b:190597666 BRANCH=none TEST=make -j buildall TEST=Call usleep() when interrupts are disabled and make sure that warning is printed and EC doesn't crash. One can implement console command to test this. Perform this test on following cores: cortex-m - this is the most common core, eg. bloonchipper minute-ia - this is used for Intel Sensor Hub (cros_ish) eg. drallion board riscv-rv32i - hayato (asurada family) has EC chip based on risc-v nds32 - ampton (octopus family) has EC chip based on it Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Ia38ef0f0511ca1298d3153fa77e169019f4c4c31 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2953235 Tested-by: Patryk Duda <patrykd@google.com> Commit-Queue: Marcin Wojtas <mwojtas@google.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* zephyr: implement task timersJack Rosenthal2021-03-201-0/+3
| | | | | | | | | | | | | | | | | | | | | CrOS EC OS provides one implicit timer associated with every task (see docs/core_runtime.md). As luck has it, we never needed these implicit timers for volteer, but ARM power sequencing code uses it. This implements the timer_arm and timer_cancel functions, which function equivalently to how they would in CrOS EC OS. (Note: we previously were compiling timer_arm and timer_cancel from CrOS EC, but these definitions were non-functional as we never call process_timers from Zephyr). BUG=b:183058135 BRANCH=none TEST=provided unit tests pass Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Ibad20002c489a8149efde713d8273adae835f653 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2774362 Reviewed-by: Simon Glass <sjg@chromium.org>
* task_set_event: remove the wait argumentDawid Niedzwiecki2020-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | There is an option in the task_set_event function which force the calling task to wait for an event. However, the option is never used thus remove it. This also will help in the Zephyr migration process. BUG=b:172360521 BRANCH=none TEST=make buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ic152fd3d6862d487bcc0024c48d136556c0b81bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2521599 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
* tree: Use new atomic_* implementationDawid Niedzwiecki2020-10-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | | It is done as a part of porting to Zephyr. Since the implementation of atomic functions is done for all architectures use atomic_* instead of deprecated_atomic_*. Sometimes there was a compilation error "discards 'volatile' qualifier" due to dropping "volatile" in the argument of the functions, thus some pointers casts need to be made. It shouldn't cause any issues, because we are sure about generated asm (store operation will be performed). BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949 Tested-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* core: rename atomic_clear to atomic_clear_bitsDawid Niedzwiecki2020-10-061-2/+2
| | | | | | | | | | | | | | | | | | Change the name of atomic_clear to atomic_clear_bits to make to name more clear - the function clears only selected bits, but the name may suggest that it clears the whole variable. It is done as a part of porting to Zephyr, where atomic_clear zeros the variable. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I7b0b47959c6c54af40f61bca8d9baebaa0375970 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2428943 Reviewed-by: Jett Rink <jettrink@chromium.org>
* zephyr: shim in the timer moduleJack Rosenthal2020-10-011-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | This enables building timer.c in the Zephyr shim. In addition, we provide definitions for the symbols __hw_clock_source_read64 and __hw_clock_event_get defined for Zephyr to provide times to the CrOS EC. The event timer does not make sense for Zephyr code, but we need it defined to prevent link errors (timerinfo uses it). Perhaps the solution to this is to add a new config option (e.g., CONFIG_EVENT_TIMER) which can be used to selectively enable/disable the event timer in the CrOS EC. But punting this work for now and just adding a fake definition. BUG=b:167590251 BRANCH=none TEST=compile for posix-ec, run gettime and timerinfo commands Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I58990a6295625f9c34ec080360470431b46155bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427100 Reviewed-by: Jett Rink <jettrink@chromium.org>
* tree: rename atomic_* functions to deprecated_atomic_*Jack Rosenthal2020-09-291-5/+5
| | | | | | | | | | | | | | | | We will move to an API compatible with Zephyr's API. See the bug for complete rationale and plan. BUG=b:169151160 BRANCH=none TEST=buildall Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id611f663446abf00b24298a669f2ae47fef7f632 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2427507 Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
* waitms: Reload watchdog before spin waitingCraig Hesling2020-03-211-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | This CL moved the reload watchdog operation to before the spin wait operation. This still achieves the goal of allowing back-to-back waitms calls and adds the ability to time watchdog behavior. Without this modification, you can't accurately test the watchdog timeout period. BRANCH=none BUG=b:151475816, b:151528646 TEST=make proj-nucleo-h743zi # Flash > clock hsi > waitms 10000 # Should see watchdog helper message at ~9 seconds Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: Id471a2667c913889c1aeba8bc14bb0f33458ed59 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2104494 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* printf: Convert %l to %llEvan Green2019-10-051-5/+5
| | | | | | | | | | | | | | | | | | | | | In order to make our printf more standard, utilize %ll for long long arguments, rather than %l. This does cost a little bit in flash space for that extra l in a couple of places, but enables us to turn on compile-time printf format checking. For this commit only, the semantics are such that both %l and %ll take 64-bit arguments. In the next commit, %l goes to its correct behavior of taking a sizeof(long) argument. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Cq-Depend:chrome-internal:1863686,chrome-internal:1860161,chrome-internal:1914029 Change-Id: I18081b55a8dbf5ef8ec15fc499ca75e59d31da58 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819652 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* common: change clksrc_high to use STATIC_IF_NOTJack Rosenthal2019-08-201-10/+2
| | | | | | | | | | | | | | | This is an example of using STATIC_IF_NOT to assert a config option when a variable wil go unused. BUG=chromium:989786 BRANCH=none TEST=buildall Change-Id: I727505a26580506c04b26888030924253bb5fb2f Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1733017 Reviewed-by: Raul E Rangel <rrangel@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* common: provide config option for 64-bit hwtimerJack Rosenthal2019-06-241-27/+68
| | | | | | | | | | | | | | | | | | | This adds a config option, CONFIG_HWTIMER_64BIT, which when enabled expects the chip implementation to define __hw_clock_source_read64 and __hw_clock_source_set64. This allows for support of native 64-bit hardware clock when available on hardware instead of a rollover interrupt style. BUG=chromium:976804 BRANCH=none TEST=made implementation of 64-bit hardware timer for ISH (child CL), and working great Change-Id: Idb2c3bb8f804e6c83a33901c953ddd5f1ae89784 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1668055 Reviewed-by: Yuval Peress <peress@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
* LICENSE: remove unnecessary (c) after CopyrightTom Hughes2019-06-191-1/+1
| | | | | | | | | | | | | | | | Ran the following command: git grep -l 'Copyright (c)' | \ xargs sed -i 's/Copyright (c)/Copyright/g' BRANCH=none BUG=none TEST=make buildall -j Change-Id: I6cc4a0f7e8b30d5b5f97d53c031c299f3e164ca7 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1663262 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* common: bit change 1 << constants with BIT(constants)Gwendal Grignou2019-03-261-1/+1
| | | | | | | | | | | | | | | | | Mechanical replacement of bit operation where operand is a constant. More bit operation exist, but prone to errors. Reveal a bug in npcx: chip/npcx/system-npcx7.c:114:54: error: conversion from 'long unsigned int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '16777215' to '255' [-Werror=overflow] BUG=None BRANCH=None TEST=None Change-Id: I006614026143fa180702ac0d1cc2ceb1b3c6eeb0 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518660 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* timer: Allow disabling gettime console commandNicolas Boichat2018-05-241-0/+2
| | | | | | | | | | | | | hammer does not need that command, let's just remove it. BRANCH=poppy BUG=b:35647963 TEST=make newsizes, saves 112 bytes of flash Change-Id: I24ed979f8a9053128d4eb56fc5af00429f7ba0ae Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1070950 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Allow repeated waitms commands without resettingSimon Glass2018-03-081-1/+14
| | | | | | | | | | | | | | | | | | | | At present issuing several 'waitms 1000' commands immediately after each other trips the watchdog. Add a watchdog reload to avoid this. Also document the behaviour in the command help. BUG=b:72542719 BRANCH=none TEST=manually on grunt, pasting these three lines in: waitms 1000 waitms 1000 waitms 1000 and see that it does not reset now. Change-Id: I453708299e4e26c1bbdb5fc406f26e916e7389af Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/955927 Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Martin Roth <martinroth@chromium.org>
* timer: Add note about `forcetime` command being unsafeShawn Nematbakhsh2017-09-011-0/+5
| | | | | | | | | | | | | BUG=b:63909040 TEST=None BRANCH=None Change-Id: If1022655bc283377fa804e524d36ca0cca716250 Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/595042 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* common: add decimal real number seconds value to timeirnfo outputVadim Bendebury2017-02-031-2/+2
| | | | | | | | | | | | | | | | | | | | | The timerinfo command shows the number of microseconds since boot, expressed as a hexadecimal value. Some of us are not as good in converting hexadecimal seconds value into decimal number of seconds and microseconds. This patch adds the decimal value to the output. BRANCH=none BUG=none TEST=verified that timerinfo output makes sense: > time Time: 0x000000000b66d280 us, 191.287936 s ... > time Time: 0x000000000caec680 us, 212.780672 s Change-Id: I3bd4ba16f3cfb74ba8fcec4899fbff0ab259007c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/436804 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* task: Don't propagate TASK_EVENT_TIMER between between waitsShawn Nematbakhsh2016-10-261-2/+2
| | | | | | | | | | | | | | | | | | | | 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>
* Add more CONFIG_CMD_* options for console commandsBill Richardson2016-10-011-0/+2
| | | | | | | | | | | | | | | 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>
* Cr50: Mark several console commands as safeBill Richardson2016-08-311-6/+6
| | | | | | | | | | | | | | | | | | | 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>
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* timer: fix clock() implementation to match TPM2 library expectationsnagendra modadugu2016-07-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | 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
* common: Add __fls functionGwendal Grignou2015-09-211-1/+1
| | | | | | | | | | | | | | | 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
* UART: Remove unused uart.h header includesAnton Staaf2015-09-081-1/+0
| | | | | | | | | | | | | | 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>
* export MSDN clock() functionVadim Bendebury2015-08-141-0/+5
| | | | | | | | | | | | | | | | 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>
* samus_pd: disable timerinfo command to save spaceAlec Berg2015-04-101-0/+6
| | | | | | | | | | | | | | 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>
* timer: usleep: Use HW clock to detect elapsed sleep timeAlec Berg2015-02-211-1/+9
| | | | | | | | | | | | | | | | | | | 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>
* common: Add a forcetime console commandMyles Watson2015-01-141-0/+28
| | | | | | | | | | | | | | | | 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>
* EC: Ensure the udelay function waits at least the time indicated.Kenji Chen2014-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | 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>
* ite: Add initial support for ITE IT8380 chipVincent Palatin2014-01-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* cleanup: Remove checkpatch warningsRandall Spangler2013-12-191-1/+1
| | | | | | | | | | | | | | | | 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
* Changed timer module to expire timers on deadline matchAlec Berg2013-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | 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>
* extract common core codeVincent Palatin2013-12-051-0/+278
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>