summaryrefslogtreecommitdiff
path: root/common/pmu_tps65090_charger.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-10-26 14:31:47 -0700
committerGerrit <chrome-bot@google.com>2012-10-29 16:52:49 -0700
commit1d916d7c6b25de10c870cf7f35a44d3654d9f099 (patch)
tree5d7337654d86766324103217ab61ae0b71d65e0f /common/pmu_tps65090_charger.c
parent67aadcf614513353d7c9a0216fc70f7af18d8d05 (diff)
downloadchrome-ec-1d916d7c6b25de10c870cf7f35a44d3654d9f099.tar.gz
Use SECOND and MSEC constants
We'd defined them in a number of different files. This moves definitions to timer.h, and uses them everywhere we have large delays (since 10*SECOND is less typo-prone than 10000000). Also add msleep() and sleep() inline functions. No need for mdelay() or delay(), since any delays that long should use sleep funcs instead of spin-waiting. BUG=chrome-os-partner:15579 BRANCH=none TEST=boot system; taskinfo displays similar numbers to before Change-Id: I2a92a9f10f46b6b7b6571759b1f8ab4ecfbf8259 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36726
Diffstat (limited to 'common/pmu_tps65090_charger.c')
-rw-r--r--common/pmu_tps65090_charger.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index cfc218d7e5..a0575820a0 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -30,10 +30,10 @@
/* Maximum retry count to revive a extremely low charge battery */
#define PRE_CHARGING_RETRY 3
-/* Time delay in usec for idle, charging and discharging.
- * Defined in battery charging flow.
+/*
+ * Time delay in usec for idle, charging and discharging. Defined in battery
+ * charging flow.
*/
-#define SECOND (1000 * 1000)
#define T1_OFF_USEC (60 * SECOND)
#define T1_SUSPEND_USEC (60 * SECOND)
#define T1_USEC (5 * SECOND)
@@ -120,7 +120,7 @@ static int notify_battery_low(void)
if (chipset_in_state(CHIPSET_STATE_ON)) {
now = get_time();
- if (now.val - last_notify_time.val > 60000000) {
+ if (now.val - last_notify_time.val > MINUTE) {
CPUTS("[pmu] notify battery low (< 10%)\n");
last_notify_time = now;
/* TODO(rongchang): notify AP ? */
@@ -467,12 +467,11 @@ void pmu_charger_task(void)
}
/*
- * Throttle the charging loop. If previous loop was waked up
- * by an event, sleep 0.5 seconds instead of wait for next
- * event.
+ * Throttle the charging loop. If previous loop awakened due to
+ * an event, sleep 500 ms instead of waiting for next event.
*/
if (event & TASK_EVENT_WAKE) {
- usleep(0.5 * SECOND);
+ msleep(500);
event = 0;
} else {
event = task_wait_event(wait_time);