summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-07-31 09:37:58 -0700
committerChromeBot <chrome-bot@google.com>2013-07-31 12:33:31 -0700
commit86bef29c3d1411c5dd9c3717432cd0bebb4fe45f (patch)
tree29061a4eeca21983b7a4fa1a80a55f871b34a724
parentaf777297370e971bd4ae64e0e947cb5a1774dbfe (diff)
downloadchrome-ec-86bef29c3d1411c5dd9c3717432cd0bebb4fe45f.tar.gz
Abstract polite AP throttling into a function
This wraps the EC_HOST_EVENT_THROTTLE_START/STOP host events in a new function called host_throttle_cpu(), similar to chipset_throttle_cpu(). That function requests the AP to throttle itself, which is less drastic than just smacking it down from the EC. BUG=chrome-os-partner:20805 BRANCH=falco,peppy TEST=manual This is a refactoring change only. All boards should still build, all tests should still pass. Change-Id: I871cce8f0e13230cb52eeb5e16955266f8461374 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/63909 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/extpower_falco.c11
-rw-r--r--common/host_event_commands.c15
-rw-r--r--include/host_command.h8
3 files changed, 24 insertions, 10 deletions
diff --git a/common/extpower_falco.c b/common/extpower_falco.c
index 4f2daedeaf..d7f1509a3a 100644
--- a/common/extpower_falco.c
+++ b/common/extpower_falco.c
@@ -185,19 +185,10 @@ bad:
CPRINTF("[%T ERROR: can't talk to charger: %d]\n", r);
}
-/* FIXME: There's already a chipset_throttle_cpu() function. However, it's a
- * fairly large hammer - on x86, it just asserts PROCHOT. That's less than
- * ideal for the turbo boost charger stuff. We might want to make this
- * function generic enough to use from other places. For now, meh. */
test_export_static int ap_is_throttled;
static void set_throttle(int on)
{
- if (on)
- host_set_events(EC_HOST_EVENT_MASK(
- EC_HOST_EVENT_THROTTLE_START));
- else
- host_set_events(EC_HOST_EVENT_MASK(
- EC_HOST_EVENT_THROTTLE_STOP));
+ host_throttle_cpu(on);
ap_is_throttled = on;
}
diff --git a/common/host_event_commands.c b/common/host_event_commands.c
index 1c13ee1377..4ee11a9de2 100644
--- a/common/host_event_commands.c
+++ b/common/host_event_commands.c
@@ -83,6 +83,21 @@ static void host_clear_events_b(uint32_t mask)
atomic_clear(&events_copy_b, mask);
}
+/**
+ * Politely ask the CPU to enable/disable its own throttling.
+ *
+ * @param throttle Enable (!=0) or disable(0) throttling
+ */
+void host_throttle_cpu(int throttle)
+{
+ if (throttle)
+ host_set_events(EC_HOST_EVENT_MASK(
+ EC_HOST_EVENT_THROTTLE_START));
+ else
+ host_set_events(EC_HOST_EVENT_MASK(
+ EC_HOST_EVENT_THROTTLE_STOP));
+}
+
/*****************************************************************************/
/* Console commands */
diff --git a/include/host_command.h b/include/host_command.h
index 4c994463f6..53e088e2e0 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -204,4 +204,12 @@ void host_packet_receive(struct host_packet *pkt);
__attribute__((section(".rodata.hcmds"))) \
= {routine, command, version_mask}
+
+/**
+ * Politely ask the CPU to enable/disable its own throttling.
+ *
+ * @param throttle Enable (!=0) or disable(0) throttling
+ */
+void host_throttle_cpu(int throttle);
+
#endif /* __CROS_EC_HOST_COMMAND_H */