mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-15 17:41:25 +00:00
When EC sees discharge current hit BAT_MAX_DISCHG_CURRENT, we kick off a timer and ask AP to throttle. Then EC keeps monitoring discharge current. If the current doesn't drop below BAT_MAX_DISCHG_CURRENT - BAT_OCP_HYSTERESIS, we restart the timer and notify AP again, which shouldn't happen unless AP misses or ignores the first notification. When the timer expires, which means EC hasn't seen over-current for BAT_OCP_TIMEOUT_US, we ask AP to stop throttling. BUG=b:74321682, chromium:838754 BRANCH=scarlet TEST=manually test on scarlet, confirm EC sends EC_HOST_EVENT_THROTTLE_START and EC_HOST_EVENT_THROTTLE_STOP host events when entering/exiting OCP. Change-Id: I1e55fc23249596d8afec52a3885655ca9c1f2151 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/994188 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Common interface to throttle the AP */
|
|
|
|
#ifndef __CROS_EC_THROTTLE_AP_H
|
|
#define __CROS_EC_THROTTLE_AP_H
|
|
|
|
/**
|
|
* Level of throttling desired.
|
|
*/
|
|
enum throttle_level {
|
|
THROTTLE_OFF = 0,
|
|
THROTTLE_ON,
|
|
};
|
|
|
|
/**
|
|
* Types of throttling desired. These are independent.
|
|
*/
|
|
enum throttle_type {
|
|
THROTTLE_SOFT = 0, /* for example, host events */
|
|
THROTTLE_HARD, /* for example, PROCHOT */
|
|
NUM_THROTTLE_TYPES
|
|
};
|
|
|
|
/**
|
|
* Possible sources for CPU throttling requests.
|
|
*/
|
|
enum throttle_sources {
|
|
THROTTLE_SRC_THERMAL = 0,
|
|
THROTTLE_SRC_BAT_DISCHG_CURRENT,
|
|
};
|
|
|
|
/**
|
|
* Enable/disable CPU throttling.
|
|
*
|
|
* This is a virtual "OR" operation. Any caller can enable CPU throttling of
|
|
* any type, but all callers must agree in order to disable that type.
|
|
*
|
|
* @param level Level of throttling desired
|
|
* @param type Type of throttling desired
|
|
* @param source Which task is requesting throttling
|
|
*/
|
|
#if defined(CONFIG_THROTTLE_AP) || \
|
|
defined(CONFIG_THROTTLE_AP_ON_BAT_DISCHG_CURRENT)
|
|
|
|
void throttle_ap(enum throttle_level level,
|
|
enum throttle_type type,
|
|
enum throttle_sources source);
|
|
|
|
#else
|
|
static inline void throttle_ap(enum throttle_level level,
|
|
enum throttle_type type,
|
|
enum throttle_sources source)
|
|
{}
|
|
#endif
|
|
|
|
#endif /* __CROS_EC_THROTTLE_AP_H */
|