summaryrefslogtreecommitdiff
path: root/common/throttle_ap.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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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>
* 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>
* throttle_ap: Add option to gate PROCHOT based on suspendJacky_Wang2022-07-011-1/+1
| | | | | | | | | | | | | | | | | The PROCHOT signal is not valid while system is on power off process. Add an option to gate if PROCHOT is asserted in the S3 state. BUG=b:237362268 BRANCH=firmware-volteer-13672.B TEST=make BOARD=drobit 1. Check fan will not full run while system power off. Signed-off-by: Jacky_Wang <jacky5_wang@pegatron.corp-partner.google.com> Change-Id: I0ec6c6b9fc1961a9b555bdf2ded98620fa7ba017 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3720838 Commit-Queue: caveh jalali <caveh@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* common/throttle_ap.c: Format with clang-formatJack Rosenthal2022-06-291-12/+9
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I29a63a1849bb23b0dbd2d592e289f551b27a81f1 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729755 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* throttle_ap: Add option to gate PROCHOT based on C10Keith Short2022-04-281-12/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For some x86 boards, the PROCHOT signal is not valid once the AP enters the C10 state. Add an option to gate PROCHOT detection if the C10 state is asserted. When the AP exits C10, the EC rechecks the PROCHOT state. Note that only the Volteer baseboard enables the PROCHOT interrupt, so it is the only board that is updated to call throttle_ap_config_prochot(). All gpio.inc files that connect to throttle_ap_prochot_input_interrupt() all use the pin name EC_PROCHOT_IN_L. Confirmed with these searches: $ grep -r "GPIO_INT.*throttle_ap_prochot_input_interrupt" . \ | wc -l 31 $ grep -r "EC_PROCHOT_IN_L.*throttle_ap_prochot_input_interrupt" . \ | wc -l 31 $ grep -r "gpio_enable_interrupt.*EC_PROCHOT_IN_L" . ./baseboard/volteer/power.c: \ gpio_enable_interrupt(GPIO_EC_PROCHOT_IN_L); BUG=b:185810479 BRANCH=volteer TEST=make buildall Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I73fb328675d9faade13fe0192570dc838de028a6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3615479 Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* gpio: cleanup header usage for chipset taskKeith Short2022-02-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | chipset.h only requires the enum gpio_signal, so use gpio_signal.h instead of gpio.h. The build doesn't compare due to an ASSERT() call in throttle_ap.c after the number of lines increased by 1. From prochot_input_deferred() before the change: 1009b592: 2158 movs r1, #88 ; 0x58 1009b594: f7fd ff76 bl 10099484 <panic_assert_fail> After the change 1009b592: 2159 movs r1, #89 ; 0x59 1009b594: f7fd ff76 bl 10099484 <panic_assert_fail> BUG=b:218856245 BRANCH=none TEST=compare_build.sh Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I30dcdec6985d51279512c25889f03b5f9b1955e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3489093 Reviewed-by: Tristan Honscheid <honscheid@google.com>
* throttle_ap: convert throttle_mutex to use K_MUTEX_DEFINEJack Rosenthal2021-03-231-6/+1
| | | | | | | | | | | | | | | | | | | | | K_MUTEX_DEFINE creates a statically-initialized mutex, and is now available for both Zephyr and CrOS EC OS. The previous way of initializing this mutex required a boolean variable, which could potentially be the cause of a race condition if the mutex had been initialized in two threads (this condition has not been observed, though). Change to K_MUTEX_DEFINE to demonstrate the new way to do this. BUG=b:177677037 BRANCH=none TEST=compile for zephyr and CrOS EC OS Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: Id27e6bff975809a2ea51bb5e9ddb0e9e6971f066 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2782232 Reviewed-by: Simon Glass <sjg@chromium.org>
* zephyr: Add support for CPU throttlingSimon Glass2021-01-221-1/+6
| | | | | | | | | | | | | | Add the required Kconfig options to allow this code to be built for Zephyr. Update the mutex since Zephyr needs this to be inited. BUG=b:173787365 BRANCH=none TEST=make BOARD=volteer build zephyr on volteer Change-Id: Ib25808faf82b3f1b2f426ad5f09acb37f1b79d65 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2631100
* eldrid: ignore PROCHOT when system offScott Chao2020-12-111-0/+10
| | | | | | | | | | | BUG=b:173180788 BRANCH=firmware-volteer-13521.B-master TEST=make buildall Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com> Change-Id: I0896dc0e9dcb45a232d7109588b95bf4ee1e6bb8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2550110 Reviewed-by: Keith Short <keithshort@chromium.org>
* throttle_ap: Turn on fans during PROCHOT eventsKeith Short2020-06-111-2/+11
| | | | | | | | | | | | | | | | | For platforms the monitor the PROCHOT signal as an input to the EC, turn on the fans at 100% duty cycle while PROCHOT is active. BUG=b:157916121 BRANCH=none TEST=make buildall TEST=On Volteer, force EC_PROCHOT_IN signal high, verify fan turns on. Verify fan reverts to automatic mode once PROCHOT clears. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Iba24daef4211d4b0d51833a569b78a9e40c71271 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2237917 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: caveh jalali <caveh@chromium.org>
* Volteer: add monitoring for PROCHOT inputKeith Short2020-03-281-0/+50
| | | | | | | | | | | | | | | | Add monotoring of the PROCHOT input to the EC. BUG=b:152340521 BRANCH=none TEST=makebuild all TEST=Assert PROCHOT output from the EC and confirm EC console logging or PROCHOT input. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Ib28537a227ea40ac947f7b999a85354b1ae4c111 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2120067 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@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>
* console_channel.inc: Add more ifdef to reduce number of channelsNicolas Boichat2018-05-261-2/+2
| | | | | | | | | | | | | | | There are still more ifdef than can be added: this just takes out the low hanging fruits. BRANCH=poppy BUG=b:35647963 TEST=make buildall -j, see that we gain from 0 to 64 bytes on many boards. Change-Id: Ibe85b8bfa5d5c22c160e4a6656104256067beee9 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1070948 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* cleanup: DECLARE_CONSOLE_COMMAND only needs 4 argsBill Richardson2016-08-241-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Kunimitsu: remove console commands for code sizeKyoung Kim2016-04-141-2/+2
| | | | | | | | | | | | | | | | | | | | | Remove following EC console commands to reduce code size: - battfake - apthrottle And none of commands above are used in 'auto test'. This is a squash of - https://chromium-review.googlesource.com/337657 - https://chromium-review.googlesource.com/338018 BUG=none BRANCH=firmware-glados-7820.B TEST=make -j buildall Change-Id: I11d2c5514f2714f0a46416feec2b2c47666fb462 Signed-off-by: Kyoung Kim <kyoung.il.kim@intel.com> Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/338893 Reviewed-by: Shawn N <shawnn@chromium.org>
* Add cprints() and ccprints()Vic Yang2014-05-211-2/+2
| | | | | | | | | | | | | | | | | | | | | Our code base contains a lot of debug messages in this pattern: CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n") The strings are taking up spaces in the EC binaries, so let's refactor this by adding cprints() and ccprints(). cprints() is just like cprintf(), except that it adds the brackets and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...) This saves us hundreds of bytes in EC binaries. BUG=chromium:374575 TEST=Build and check flash size BRANCH=None Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/200490 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* Handle multiple independent sources and types of CPU throttlingBill Richardson2013-09-111-0/+96
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