mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 02:20:48 +00:00
PWM and temp sensor monitoring want to happen every second, vs. several times a second for watchdog and LPC. This is still considerably simpler than having tick functions declare an interval at which they want to be called, which would require a RAM-based array of pending tick functions and alarm times. If you need that level of complexity, you still need a task. BUG=chrome-os-partner:15714 BRANCH=none TEST=temporarily add HOOK_TICK and HOOK_SECOND hooks and see that on LM4, HOOK_TICK is called 4x a second and HOOK_SECOND is called every second. Change-Id: I5c09842fd356d3254021486949b2799142068b4f Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/36938 Commit-Ready: Simon Glass <sjg@chromium.org>
85 lines
2.9 KiB
C
85 lines
2.9 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.
|
|
*/
|
|
|
|
/* System hooks for Chrome EC */
|
|
|
|
#ifndef __CROS_EC_HOOKS_H
|
|
#define __CROS_EC_HOOKS_H
|
|
|
|
#include "common.h"
|
|
|
|
enum hook_priority {
|
|
/* Generic values across all hooks */
|
|
HOOK_PRIO_FIRST = 1, /* Highest priority */
|
|
HOOK_PRIO_DEFAULT = 5000, /* Default priority */
|
|
HOOK_PRIO_LAST = 9999, /* Lowest priority */
|
|
|
|
/* Specific hook vales for HOOK_INIT */
|
|
/* LPC inits before modules which need memory-mapped I/O */
|
|
HOOK_PRIO_INIT_LPC = HOOK_PRIO_FIRST + 1,
|
|
/* Chipset inits before modules which need to know its initial state. */
|
|
HOOK_PRIO_INIT_CHIPSET = HOOK_PRIO_FIRST + 2,
|
|
};
|
|
|
|
enum hook_type {
|
|
HOOK_INIT = 0, /* System init */
|
|
HOOK_FREQ_CHANGE, /* System clock changed frequency */
|
|
HOOK_SYSJUMP, /* About to jump to another image. Modules
|
|
* which need to preserve data across such a
|
|
* jump should save it here and restore it in
|
|
* HOOK_INIT.
|
|
*
|
|
* NOTE: This hook is called with interrupts
|
|
* disabled! */
|
|
HOOK_CHIPSET_PRE_INIT, /* Initialization for components such as PMU to
|
|
* be done before host chipset/AP starts up. */
|
|
HOOK_CHIPSET_STARTUP, /* System is starting up. All suspend rails are
|
|
* now on. */
|
|
HOOK_CHIPSET_RESUME, /* System is resuming from suspend, or booting
|
|
* and has reached the point where all voltage
|
|
* rails are on */
|
|
HOOK_CHIPSET_SUSPEND, /* System is suspending, or shutting down; all
|
|
* voltage rails are still on */
|
|
HOOK_CHIPSET_SHUTDOWN, /* System is shutting down. All suspend rails
|
|
* are still on. */
|
|
HOOK_AC_CHANGE, /* AC power plugged in or removed */
|
|
HOOK_LID_CHANGE, /* Lid opened or closed. Based on debounced lid
|
|
* state, not raw lid GPIO input. */
|
|
HOOK_TICK, /* Periodic tick, every HOOK_TICK_INTERVAL */
|
|
HOOK_SECOND, /* Periodic tick, every second */
|
|
};
|
|
|
|
struct hook_data {
|
|
/* Hook processing routine. */
|
|
void (*routine)(void);
|
|
/* Priority; low numbers = higher priority. */
|
|
int priority;
|
|
};
|
|
|
|
/**
|
|
* Call all the hook routines of a specified type.
|
|
*
|
|
* @param type Type of hook routines to call.
|
|
*/
|
|
void hook_notify(enum hook_type type);
|
|
|
|
/**
|
|
* Register a hook routine.
|
|
*
|
|
* @param hooktype Type of hook for routine (enum hook_type)
|
|
* @param routine Hook routine, with prototype void routine(void)
|
|
* @param priority Priority for determining when routine is called vs.
|
|
* other hook routines; should be between HOOK_PRIO_FIRST
|
|
* and HOOK_PRIO_LAST, and should be HOOK_PRIO_DEFAULT
|
|
* unless there's a compelling reason to care about the
|
|
* order in which hooks are called.
|
|
*/
|
|
#define DECLARE_HOOK(hooktype, routine, priority) \
|
|
const struct hook_data __hook_##hooktype##_##routine \
|
|
__attribute__((section(".rodata." #hooktype))) \
|
|
= {routine, priority}
|
|
|
|
#endif /* __CROS_EC_HOOKS_H */
|