1/*
2 * PowerSrvSM.h
3 *
4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 *  * Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *  * Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in
15 *    the documentation and/or other materials provided with the
16 *    distribution.
17 *  * Neither the name Texas Instruments nor the names of its
18 *    contributors may be used to endorse or promote products derived
19 *    from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file PowerSrvSM.h
35 *  \brief This is the PowerSrv module API.
36 *  \author Assaf Azulay
37 *  \date 6-Oct-2005
38 */
39
40/****************************************************************************
41 *                                                                                                        *
42 *   MODULE:  PowerSrv                                                                              *
43 *   PURPOSE: Power Server State machine API                                                    *
44 *                                                                                                              *
45 ****************************************************************************/
46
47#ifndef _POWER_SRV_SM_H_
48#define _POWER_SRV_SM_H_
49
50#include "PowerSrv_API.h"
51#include "PowerSrv.h"
52
53
54
55/*****************************************************************************
56 **         Constants                                                       **
57 *****************************************************************************/
58
59#define POWER_SAVE_GUARD_TIME_MS            5000       /* The gaurd time used to protect from FW stuck */
60
61/*****************************************************************************
62 **         Enumerations                                                    **
63 *****************************************************************************/
64
65/** \enum PowerSrvSMEvents_e */
66typedef enum
67{
68        POWER_SRV_EVENT_REQUEST_ACTIVE ,
69    POWER_SRV_EVENT_REQUEST_PS ,
70    POWER_SRV_EVENT_SUCCESS,
71    POWER_SRV_EVENT_FAIL ,
72    POWER_SRV_SM_EVENT_NUM
73}PowerSrvSMEvents_e;
74
75/** \enum PowerSrvSMStates_e */
76typedef enum
77{
78    POWER_SRV_STATE_ACTIVE = 0,
79    POWER_SRV_STATE_PEND_PS ,
80    POWER_SRV_STATE_PS ,
81    POWER_SRV_STATE_PEND_ACTIVE ,
82    POWER_SRV_STATE_ERROR_ACTIVE,
83    POWER_SRV_SM_STATE_NUM
84}PowerSrvSMStates_e;
85
86
87
88/*****************************************************************************
89 **         Structures                                                      **
90 *****************************************************************************/
91
92/** \struct PowerSrvSM_t */
93typedef struct
94{
95    TI_HANDLE               hCmdBld;                    /**<
96                                                         * Handle to the power controller object via the command builder.
97                                                         * Need for configure the desired power mode policy in the system.
98                                                         */
99
100    TI_HANDLE               hOS;                        /**< Handle to the OS object. */
101
102    TI_HANDLE               hReport;                    /**< Handle to the Report module. */
103
104    TI_HANDLE               hFSM;                       /**< Handle to the State machine module. */
105
106    TI_HANDLE               hTimer;                     /**< Handle to the Timer module. */
107
108    TI_HANDLE               hPwrSrvSmTimer;             /**< Guard timer for PS commands sent to the FW */
109
110    PowerSrvSMStates_e      currentState;               /**< the current state of the state machine. */
111
112    powerSrvRequest_t*      pSmRequest;                 /**< pointer to the relevant request in the power server. */
113
114    TI_UINT8                hangOverPeriod;             /**< parameter for the FW */
115
116    TI_UINT8                numNullPktRetries;          /**< parameter for the FW */
117
118    EHwRateBitFiled         NullPktRateModulation;      /**< parameter for the FW */
119
120    TFailureEventCb         failureEventCB;             /**< Failure event callback */
121
122    TI_HANDLE               hFailureEventObj;           /**< Failure event object (supplied to the above callback) */
123} PowerSrvSM_t;
124
125
126
127
128
129
130
131/*****************************************************************************
132 **         External data definitions                                       **
133 *****************************************************************************/
134
135
136/*****************************************************************************
137 **         External functions definitions                                  **
138 *****************************************************************************/
139
140
141/*****************************************************************************
142 **         Public Function prototypes                                      **
143 *****************************************************************************/
144
145/**
146 * \author Assaf Azulay
147 * \date 6-Oct-2005\n
148 * \brief Creates the object of the PowerSrv.
149 *
150 * Function Scope \e Public.\n
151 * Parameters:\n
152 * 1) TI_HANDLE - handle to the OS.\n
153 * Return Value: TI_HANDLE - handle to the PowerSrv object.\n
154 */
155TI_HANDLE powerSrvSM_create(TI_HANDLE hOsHandle);
156
157/**
158 * \author Assaf Azulay
159 * \date 6-Oct-2005\n
160 * \brief Destroy the object of the PowerSrvSM.
161 *
162 * Function Scope \e Public.\n
163 * Parameters:\n
164 * 1) TI_HANDLE - handle to the PowerSrv object.\n
165 * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n
166 */
167TI_STATUS powerSrvSM_destroy(TI_HANDLE thePowerSrvSMHandle);
168
169/**
170 * \author Assaf Azulay
171 * \date 6-Oct-2005\n
172 * \brief Initialize the PowerSrvSM module.
173 *
174 * Function Scope \e Public.\n
175 * Parameters:\n
176 * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
177 * 2) TI_HANDLE - handle to the Report object.
178 * 3) TI_HANDLE - handle to the Command Builder object.
179 * 4) TI_HANDLE - handle to the Timer module object.
180 * Return Value: TI_STATUS - TI_OK on success else TI_NOK.\n
181 */
182TI_STATUS powerSrvSM_init (TI_HANDLE hPowerSrvSM,
183                           TI_HANDLE hReport,
184                           TI_HANDLE hCmdBld,
185                           TI_HANDLE hTimer);
186
187TI_STATUS powerSrvSM_config(TI_HANDLE hPowerSrvSM,
188                            TPowerSrvInitParams *pPowerSrvInitParams);
189/**
190 * \author Assaf Azulay
191 * \date 6-Oct-2005\n
192 * \brief return the component version.
193 *
194 * Function Scope \e Public.\n
195 * Parameters:\n
196 * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
197 * Return Value: TI_UINT32 - component version code.\n
198 */
199
200TI_STATUS powerSrvSM_SMApi(TI_HANDLE hPowerSrvSM,
201                                            PowerSrvSMEvents_e theSMEvent);
202
203
204/**
205 * \author Assaf Azulay
206 * \date 020-Oct-2005\n
207 * \brief This function sets the current SM working request.\n
208 *
209 * Function Scope \e Public.\n
210 * Parameters:\n
211 * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
212 * 2) powerSrvRequest_t* pSmRequest - desierd request./n
213 * Return Value: TI_STATUS -  TI_OK.\n
214 */
215TI_STATUS powerSrvSm_setSmRequest(TI_HANDLE hPowerSrvSM,powerSrvRequest_t* pSmRequest);
216
217
218
219/**
220 * \author Assaf Azulay
221 * \date 09-Jun-2004\n
222 * \brief get the current state of the state machine.
223 *
224 * Function Scope \e Public.\n
225 * Parameters:\n
226 * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
227 * Return Value: PowerCtrlSMStates_e.\n
228 */
229PowerSrvSMStates_e powerSrvSM_getCurrentState(TI_HANDLE hPowerSrvSM);
230
231
232/**
233 * \author Assaf Azulay
234 * \date 20-July-2004\n
235 * \brief sets rate modulation
236 *
237 * Function Scope \e Public.\n
238 * Parameters:\n
239 * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
240 * 2) rate_e rate modulation
241 * Return Value: void.\n
242 */
243void powerSrvSM_setRateModulation(TI_HANDLE hPowerSrvSM, TI_UINT16 rateModulation);
244
245/**
246 * \brief sets rate modulation
247 *
248 * Function Scope \e Public.\n
249 * Parameters:\n
250 * 1) TI_HANDLE - handle to the PowerSrvSM object.\n*
251 * Return Value: TI_UINT16 Rate.\n
252 */
253TI_UINT32 powerSrvSM_getRateModulation(TI_HANDLE hPowerSrvSM);
254
255/**
256 * \author Assaf Azulay
257 * \date 20-July-2004\n
258 * \brief print configuration of the PowerSrvSM object - use for debug!
259 *
260 * Function Scope \e Public.\n
261 * Parameters:\n
262 * 1) TI_HANDLE - handle to the PowerSrvSM object.\n
263 * Return Value: void.\n
264 */
265void powerSrvSM_printObject(TI_HANDLE hPowerSrvSM);
266
267/**
268 * \author Ronen Kalish
269 * \date 21-August-2006\n
270 * \brief Registers a failure event callback for power save error notifications (timer expiry).\n
271 *
272 * Function Scope \e Public.\n
273 * Parameters:\n
274 * - hPowerSrvSM      - handle to the PowerSrv object.
275 * - failureEventCB     - the failure event callback function.
276 * - hFailureEventObj   - handle to the object passed to the failure event callback function.
277*/
278void powerSrvSM_RegisterFailureEventCB( TI_HANDLE hPowerSrvSM,
279                                        void* failureEventCB, TI_HANDLE hFailureEventObj );
280#endif /*  _POWER_SRV_SM_H_  */
281
282