summaryrefslogtreecommitdiff
path: root/drivers/gpu/mali/mali400ko/driver/src/devicedrv/mali/common/pmm/mali_pmm_policy.h
blob: 83cb7f29a92b78b50470ab0040235a56e36df9b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * Copyright (C) 2010-2011 ARM Limited. All rights reserved.
 * 
 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
 * 
 * A copy of the licence is included with the program, and can also be obtained from Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

/**
 * @file mali_pmm_policy.h
 * Defines the power management module policies
 */

#ifndef __MALI_PMM_POLICY_H__
#define __MALI_PMM_POLICY_H__

#ifdef __cplusplus
extern "C"
{
#endif

/**
 * @addtogroup pmmapi Power Management Module APIs
 *
 * @{
 *
 * @defgroup pmmapi_policy Power Management Module Policies
 *
 * @{
 */

/** @brief Generic timer for use with policies
 */
typedef struct _pmm_policy_timer
{
	u32 timeout;                    /**< Timeout for this timer in ticks */
	mali_pmm_event_id event_id;     /**< Event id that will be raised when timer expires */
	_mali_osk_timer_t *timer;       /**< Timer */
	mali_bool set;                  /**< Timer set */
	mali_bool expired;              /**< Timer expired - event needs to be raised */
	u32 start;                      /**< Timer start ticks */
} _pmm_policy_timer_t;

/** @brief Policy timer initialization
 *
 * This will create a timer for use in policies, but won't start it
 * 
 * @param pptimer An empty timer structure to be initialized
 * @param timeout Timeout in ticks for the timer
 * @param id Event id that will be raised on timeout
 * @return _MALI_OSK_ERR_OK if the policy could be initialized, or a suitable
 * _mali_osk_errcode_t otherwise.
 */
_mali_osk_errcode_t pmm_policy_timer_init( _pmm_policy_timer_t *pptimer, u32 timeout, mali_pmm_event_id id );

/** @brief Policy timer termination
 *
 * This will clean up a timer that was previously used in policies, it
 * will also stop it if started
 * 
 * @param pptimer An initialized timer structure to be terminated
 */
void pmm_policy_timer_term( _pmm_policy_timer_t *pptimer );

/** @brief Policy timer start
 *
 * This will start a previously created timer for use in policies
 * When the timer expires after the initialized timeout it will raise 
 * a PMM event of the event id given on initialization
 * As data for the event it will pass the start time of the timer
 * 
 * @param pptimer A previously initialized policy timer
 * @return MALI_TRUE if the timer was started, MALI_FALSE if it is already started
 */
mali_bool pmm_policy_timer_start( _pmm_policy_timer_t *pptimer );

/** @brief Policy timer stop
 *
 * This will stop a previously created timer for use in policies
 * 
 * @param pptimer A previously started policy timer
 * @return MALI_TRUE if the timer was stopped, MALI_FALSE if it is already stopped
 */
mali_bool pmm_policy_timer_stop( _pmm_policy_timer_t *pptimer );

/** @brief Policy timer stop
 *
 * This raise an event for an expired timer
 * 
 * @param pptimer An expired policy timer
 * @return MALI_TRUE if an event was raised, else MALI_FALSE
 */
mali_bool pmm_policy_timer_raise_event( _pmm_policy_timer_t *pptimer );

/** @brief Policy timer valid checker
 *
 * This will check that a timer was started after a given time
 * 
 * @param timer_start Time the timer was started
 * @param other_start Time when another event or action occurred
 * @return MALI_TRUE if the timer was started after the other time, else MALI_FALSE
 */
mali_bool pmm_policy_timer_valid( u32 timer_start, u32 other_start );


/** @brief Common policy initialization
 * 
 * This will initialize the current policy
 *
 * @note Any previously initialized policy should be terminated first
 *
 * @return _MALI_OSK_ERR_OK if the policy could be initialized, or a suitable
 * _mali_osk_errcode_t otherwise.
 */
_mali_osk_errcode_t pmm_policy_init( _mali_pmm_internal_state_t *pmm );

/** @brief Common policy termination
 *
 * This will terminate the current policy.
 * @note This can be called when a policy has not been initialized
 */
void pmm_policy_term( _mali_pmm_internal_state_t *pmm );

/** @brief Common policy state changer
 *
 * Given the next available event message, this routine passes it to
 * the current policy for processing
 *
 * @param pmm internal PMM state
 * @param event PMM event to process
 * @return _MALI_OSK_ERR_OK if the policy state completed okay, or a suitable
 * _mali_osk_errcode_t otherwise.
 */
_mali_osk_errcode_t pmm_policy_process( _mali_pmm_internal_state_t *pmm, mali_pmm_message_t *event );


/** @brief Common policy checker
 *
 * If a policy timer fires then this function will be called to
 * allow the policy to take the correct action
 *
 * @param pmm internal PMM state
 */
void pmm_policy_check_policy( _mali_pmm_internal_state_t *pmm );

/** @} */ /* End group pmmapi_policy */
/** @} */ /* End group pmmapi */

#ifdef __cplusplus
}
#endif

#endif /* __MALI_PMM_POLICY_H__ */