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>
This commit is contained in:
Bill Richardson
2013-07-31 09:37:58 -07:00
committed by ChromeBot
parent af77729737
commit 86bef29c3d
3 changed files with 24 additions and 10 deletions

View File

@@ -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;
}

View File

@@ -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 */

View File

@@ -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 */