1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 // Software and any modification/derivatives thereof.
18 // No right, ownership, or interest to MStar Software and any
19 // modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 // supplied together with third party`s software and the use of MStar
23 // Software may require additional licenses from third parties.
24 // Therefore, you hereby agree it is your sole responsibility to separately
25 // obtain any and all third party right and license necessary for your use of
26 // such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 // MStar`s confidential information and you agree to keep MStar`s
30 // confidential information in strictest confidence and not disclose to any
31 // third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 // kind. Any warranties are hereby expressly disclaimed by MStar, including
35 // without limitation, any warranties of merchantability, non-infringement of
36 // intellectual property rights, fitness for a particular purpose, error free
37 // and in conformity with any international standard. You agree to waive any
38 // claim against MStar for any loss, damage, cost or expense that you may
39 // incur related to your use of MStar Software.
40 // In no event shall MStar be liable for any direct, indirect, incidental or
41 // consequential damages, including without limitation, lost of profit or
42 // revenues, lost or damage of data, and unauthorized system use.
43 // You agree that this Section 4 shall still apply without being affected
44 // even if MStar Software has been modified by MStar in accordance with your
45 // request or instruction for your use, except otherwise agreed by both
46 // parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 // services in relation with MStar Software to you for your use of
50 // MStar Software in conjunction with your or your customer`s product
51 // ("Services").
52 // You understand and agree that, except otherwise agreed by both parties in
53 // writing, Services are provided on an "AS IS" basis and the warranty
54 // disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 // or otherwise:
58 // (a) conferring any license or right to use MStar name, trademark, service
59 // mark, symbol or any other identification;
60 // (b) obligating MStar or any of its affiliates to furnish any person,
61 // including without limitation, you and your customers, any assistance
62 // of any kind whatsoever, or any information; or
63 // (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 // of Taiwan, R.O.C., excluding its conflict of law rules.
67 // Any and all dispute arising out hereof or related hereto shall be finally
68 // settled by arbitration referred to the Chinese Arbitration Association,
69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 // Rules of the Association by three (3) arbitrators appointed in accordance
71 // with the said Rules.
72 // The place of arbitration shall be in Taipei, Taiwan and the language shall
73 // be English.
74 // The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 ////////////////////////////////////////////////////////////////////////////////
79 //
80 // Copyright (c) 2008-2009 MStar Semiconductor, Inc.
81 // All rights reserved.
82 //
83 // Unless otherwise stipulated in writing, any and all information contained
84 // herein regardless in any format shall remain the sole proprietary of
85 // MStar Semiconductor Inc. and be kept in strict confidence
86 // ("MStar Confidential Information") by the recipient.
87 // Any unauthorized act including without limitation unauthorized disclosure,
88 // copying, use, reproduction, sale, distribution, modification, disassembling,
89 // reverse engineering and compiling of the contents of MStar Confidential
90 // Information is unlawful and strictly prohibited. MStar hereby reserves the
91 // rights to any and all damages, losses, costs and expenses resulting therefrom.
92 ////////////////////////////////////////////////////////////////////////////////
93 #define _HAL_PWS_C
94
95 ////////////////////////////////////////////////////////////////////////////////
96 /// @file halPWS.c
97 /// @author MStar Semiconductor Inc.
98 /// @brief power saving driver
99 ////////////////////////////////////////////////////////////////////////////////
100
101 //------------------------------------------------------------------------------
102 // Header Files
103 //------------------------------------------------------------------------------
104 #include <stdio.h>
105 #include <string.h>
106
107 #include "MsCommon.h"
108 #include "MsTypes.h"
109 #include "halPWS.h"
110 #include "MsOS.h"
111
112 #include "mhal_pws_table.h"
113 #include "mhal_pws_setting_info_table.h"
114 //------------------------------------------------------------------------------
115 // Define & data type
116 //------------------------------------------------------------------------------
117 #define DEBUG_INFO(y) //y
118
119 #define RunBefore 0
120 #define RunAfter 1
121 //------------------------------------------------------------------------------
122 // Local variable
123 //------------------------------------------------------------------------------
124 static MS_U32 _gPWS_MapBase = 0xA0000000;
125 MS_U8 PWS_flag[OutOfRange_PWS_Items];
126 MS_U16 u16PWS_First_Items=0;
127 MS_U16 u16OutOfRange_PWS_Items=0;
128 static E_PWS_SouceInfo SourceIndex = _NO_SOURCE_;
129 PWS_RegisterCallback PWS_RegCBinfo[PWS_Register_CB_size];
130 E_PWS_VIF_type SelectVifTable = E_PWS_VIF_DUAL_SAW;
131
132 //------------------------------------------------------------------------------
133 // Local Function
134 //------------------------------------------------------------------------------
HAL_PWS_ReadByte(MS_U32 u32RegAddr)135 MS_U8 HAL_PWS_ReadByte(MS_U32 u32RegAddr)
136 {
137 return ((volatile MS_U8*)(_gPWS_MapBase))[(u32RegAddr << 1) - (u32RegAddr & 1)];
138 }
139
HAL_PWS_Read2Byte(MS_U32 u32RegAddr)140 MS_U16 HAL_PWS_Read2Byte(MS_U32 u32RegAddr)
141 {
142 return ((volatile MS_U16*)(_gPWS_MapBase))[u32RegAddr];
143 }
144
HAL_PWS_Read4Byte(MS_U32 u32RegAddr)145 MS_U32 HAL_PWS_Read4Byte(MS_U32 u32RegAddr)
146 {
147 return (HAL_PWS_Read2Byte(u32RegAddr) | HAL_PWS_Read2Byte(u32RegAddr+2) << 16);
148 }
149
HAL_PWS_WriteByte(MS_U32 u32RegAddr,MS_U8 u8Val)150 MS_BOOL HAL_PWS_WriteByte(MS_U32 u32RegAddr, MS_U8 u8Val)
151 {
152 if (!u32RegAddr)
153 {
154 return FALSE;
155 }
156
157 ((volatile MS_U8*)(_gPWS_MapBase))[(u32RegAddr << 1) - (u32RegAddr & 1)] = u8Val;
158 return TRUE;
159 }
160
HAL_PWS_Write2Byte(MS_U32 u32RegAddr,MS_U16 u16Val)161 MS_BOOL HAL_PWS_Write2Byte(MS_U32 u32RegAddr, MS_U16 u16Val)
162 {
163 if (!u32RegAddr)
164 {
165 return FALSE;
166 }
167
168 ((volatile MS_U16*)(_gPWS_MapBase))[u32RegAddr] = u16Val;
169 return TRUE;
170 }
171
HAL_PWS_Write4Byte(MS_U32 u32RegAddr,MS_U32 u32Val)172 MS_BOOL HAL_PWS_Write4Byte(MS_U32 u32RegAddr, MS_U32 u32Val)
173 {
174 if (!u32RegAddr)
175 {
176 return FALSE;
177 }
178
179 HAL_PWS_Write2Byte(u32RegAddr, u32Val & 0x0000FFFF);
180 HAL_PWS_Write2Byte(u32RegAddr+2, u32Val >> 16);
181 return TRUE;
182 }
183
HAL_PWS_WriteRegBit(MS_U32 u32RegAddr,MS_BOOL bEnable,MS_U8 u8BitPos)184 MS_BOOL HAL_PWS_WriteRegBit(MS_U32 u32RegAddr, MS_BOOL bEnable, MS_U8 u8BitPos)
185 {
186 MS_U8 u8Val = HAL_PWS_ReadByte(u32RegAddr);
187 if (!u32RegAddr)
188 {
189 return FALSE;
190 }
191
192 u8Val = HAL_PWS_ReadByte(u32RegAddr);
193 u8Val = (bEnable) ? (u8Val | u8BitPos) : (u8Val & ~u8BitPos);
194 HAL_PWS_WriteByte(u32RegAddr, u8Val);
195 return TRUE;
196 }
197
HAL_PWS_WriteByteMask(MS_U32 u32RegAddr,MS_U8 u8Val,MS_U8 u8Mask)198 E_PWS_Result HAL_PWS_WriteByteMask(MS_U32 u32RegAddr, MS_U8 u8Val, MS_U8 u8Mask)
199 {
200 return (E_PWS_Result)HAL_PWS_WriteByte(u32RegAddr, (HAL_PWS_ReadByte(u32RegAddr) & (~u8Mask)) | (u8Val & u8Mask));
201 }
202
HAL_PWS_RunCallback(MS_U8 Position,MS_U8 OnOff_flag,MS_U16 index)203 void HAL_PWS_RunCallback(MS_U8 Position,MS_U8 OnOff_flag, MS_U16 index)
204 {
205 MS_U8 i;
206 MS_U8 temp = 0;
207
208 for(i=0;i<PWS_Register_CB_size;i++)
209 {
210 temp = (MS_U8)PWS_RegCBinfo[i].ctrl;
211 if(Position == RunAfter)
212 temp = temp - 2;
213 else
214 temp = temp;
215
216 if(temp == OnOff_flag) // ctrl
217 {
218 if(strcmp((char *)pws_setting_info_table[index].regName,(char *)PWS_RegCBinfo[i].regName) == 0) // regName
219 {
220 if(PWS_RegCBinfo[i]._PWSCallback != NULL) // callback
221 {
222 DEBUG_INFO(printf("%s, %s \r\n",__FUNCTION__,PWS_RegCBinfo[i].regName));
223 PWS_RegCBinfo[i]._PWSCallback();
224 }
225 }
226 }
227 }
228 }
229
HAL_PWS_SetXXX(MS_U8 OnOff_flag,MS_U16 index)230 E_PWS_Result HAL_PWS_SetXXX(MS_U8 OnOff_flag, MS_U16 index)
231 {
232 E_PWS_Result ret = PWS_FAIL;
233
234 DEBUG_INFO(printf("%s, %s, index %d\n",__FUNCTION__,pws_setting_info_table[index].regName, index));
235
236 if(pws_setting_info_table[index].bInvert == TRUE)
237 {
238 if(OnOff_flag)
239 {
240 // INVERT = Y , OFF = 0x00
241 HAL_PWS_RunCallback(RunBefore,OnOff_flag,index);
242 DEBUG_INFO(printf("[PWS OFF]0x00 %s, index %d\n",pws_setting_info_table[index].regName, index));
243 ret = HAL_PWS_WriteByteMask(pws_setting_info_table[index].u32RegAddr, 0x00, pws_setting_info_table[index].u8RegMask);
244 HAL_PWS_RunCallback(RunAfter,OnOff_flag,index);
245 }
246 else
247 {
248 // INVERT = Y , ON = 0x01
249 HAL_PWS_RunCallback(RunBefore,OnOff_flag,index);
250 DEBUG_INFO(printf("[PWS ON]0xFF %s, index %d\n",pws_setting_info_table[index].regName, index));
251 ret = HAL_PWS_WriteByteMask(pws_setting_info_table[index].u32RegAddr, 0xFF, pws_setting_info_table[index].u8RegMask);
252 HAL_PWS_RunCallback(RunAfter,OnOff_flag,index);
253 }
254 }
255 else
256 {
257 if(OnOff_flag)
258 {
259 // INVERT = N , OFF = 0x01
260 HAL_PWS_RunCallback(RunBefore,OnOff_flag,index);
261 DEBUG_INFO(printf("[PWS OFF]0xFF %s, index %d\n",pws_setting_info_table[index].regName, index));
262 ret = HAL_PWS_WriteByteMask(pws_setting_info_table[index].u32RegAddr, 0xFF, pws_setting_info_table[index].u8RegMask);
263 HAL_PWS_RunCallback(RunAfter,OnOff_flag,index);
264 }
265 else
266 {
267 // INVERT = N , ON = 0x00
268 HAL_PWS_RunCallback(RunBefore,OnOff_flag,index);
269 DEBUG_INFO(printf("[PWS ON]0x00 %s, index %d\n",pws_setting_info_table[index].regName, index));
270 ret = HAL_PWS_WriteByteMask(pws_setting_info_table[index].u32RegAddr, 0x00, pws_setting_info_table[index].u8RegMask);
271 HAL_PWS_RunCallback(RunAfter,OnOff_flag,index);
272 }
273 }
274
275 return ret;
276 }
277
278 //------------------------------------------------------------------------------
279 // Global Function
280 //------------------------------------------------------------------------------
HAL_PWS_SetIOMapBase(MS_U32 u32Base)281 void HAL_PWS_SetIOMapBase(MS_U32 u32Base)
282 {
283 DEBUG_INFO(printf("%s\n",__FUNCTION__));
284
285 if(u32Base == 0)
286 {
287 printf("Get PWS RIU base address failed\r\n");
288 }
289 else
290 {
291 _gPWS_MapBase = u32Base;
292 DEBUG_INFO(printf("PWS_MAP_BASE=%lx\n",_gPWS_MapBase));
293 }
294 }
295
HAL_PWS_GetIOMapBase(void)296 MS_U32 HAL_PWS_GetIOMapBase(void)
297 {
298 DEBUG_INFO(printf("%s\n",__FUNCTION__));
299 return _gPWS_MapBase;
300 }
301
HAL_PWS_GetSourceInfo(void)302 E_PWS_SouceInfo HAL_PWS_GetSourceInfo(void)
303 {
304 DEBUG_INFO(printf("%s\n",__FUNCTION__));
305 return SourceIndex;
306 }
307
HAL_PWS_Init(E_PWS_VIF_type eVifType)308 void HAL_PWS_Init(E_PWS_VIF_type eVifType)
309 {
310 MS_U16 pws_init_items_counter = 0;
311 MS_U16 PWS_flag_index=0;
312 MS_U8 PWS_CB_items;
313
314 DEBUG_INFO(printf("%s\n",__FUNCTION__));
315
316 if(eVifType > E_PWS_VIF_UNKNOWN)
317 {
318 SelectVifTable = E_PWS_VIF_DUAL_SAW;
319 }
320 else
321 {
322 SelectVifTable = eVifType;
323 }
324
325 for(PWS_CB_items = 0; PWS_CB_items < PWS_Register_CB_size; PWS_CB_items++)
326 {
327 PWS_RegCBinfo[PWS_CB_items].ctrl = E_PWS_IP_CALLBACK_UNKNOWN;
328 PWS_RegCBinfo[PWS_CB_items].regName[0] = '\n';
329 PWS_RegCBinfo[PWS_CB_items]._PWSCallback = NULL;
330 }
331
332 // default power save register setting (keep ON or OFF)
333 if(OutOfRange_PWS_Init_Items > 0)
334 {
335 u16PWS_First_Items= PWS_First_Items;
336 u16OutOfRange_PWS_Items= OutOfRange_PWS_Items;
337
338 // initial PWS_flag table
339 for(PWS_flag_index = u16PWS_First_Items ; PWS_flag_index < u16OutOfRange_PWS_Items ; PWS_flag_index++)
340 {
341 PWS_flag[PWS_flag_index] = 1;
342 }
343
344 DEBUG_INFO(printf("PWS init value setting\r\n"));
345 while(pws_init_items_counter < OutOfRange_PWS_Init_Items)
346 {
347 if(pws_init_setting_info_table[pws_init_items_counter].bInvert == TRUE)
348 {
349 if((pws_init_table[pws_init_items_counter] && 0xFFFF) == TRUE)
350 {
351 // INVERT = Y , OFF = 0x00
352 DEBUG_INFO(printf("[PWS OFF]0x00 %s, index %d, mask %x\r\n",pws_init_setting_info_table[pws_init_items_counter].regName, pws_init_items_counter, pws_init_setting_info_table[pws_init_items_counter].u8RegMask));
353 HAL_PWS_WriteByteMask(pws_init_setting_info_table[pws_init_items_counter].u32RegAddr, 0x00, pws_init_setting_info_table[pws_init_items_counter].u8RegMask);
354 }
355 else
356 {
357 // INVERT = Y , ON = 0x01
358 DEBUG_INFO(printf("[PWS ON]0xFF %s, index %d, mask %x\r\n",pws_init_setting_info_table[pws_init_items_counter].regName, pws_init_items_counter, pws_init_setting_info_table[pws_init_items_counter].u8RegMask));
359 HAL_PWS_WriteByteMask(pws_init_setting_info_table[pws_init_items_counter].u32RegAddr, 0xFF, pws_init_setting_info_table[pws_init_items_counter].u8RegMask);
360 }
361 }
362 else
363 {
364 if((pws_init_table[pws_init_items_counter] && 0xFFFF) == TRUE)
365 {
366 // INVERT = N , OFF = 0x01
367 DEBUG_INFO(printf("[PWS OFF]0xFF %s, index %d, mask %x\r\n",pws_init_setting_info_table[pws_init_items_counter].regName, pws_init_items_counter, pws_init_setting_info_table[pws_init_items_counter].u8RegMask));
368 HAL_PWS_WriteByteMask(pws_init_setting_info_table[pws_init_items_counter].u32RegAddr, 0xFF, pws_init_setting_info_table[pws_init_items_counter].u8RegMask);
369 }
370 else
371 {
372 // INVERT = N , ON = 0x00
373 DEBUG_INFO(printf("[PWS ON]0x00 %s, index %d, mask %x\r\n",pws_init_setting_info_table[pws_init_items_counter].regName, pws_init_items_counter, pws_init_setting_info_table[pws_init_items_counter].u8RegMask));
374 //HAL_PWS_WriteByte(pws_init_setting_info_table[pws_init_items_counter].u32RegAddr, (HAL_PWS_ReadByte(pws_init_setting_info_table[pws_init_items_counter].u32RegAddr) & ~pws_init_setting_info_table[pws_init_items_counter].u8RegMask));
375 HAL_PWS_WriteByteMask(pws_init_setting_info_table[pws_init_items_counter].u32RegAddr, 0x00, pws_init_setting_info_table[pws_init_items_counter].u8RegMask);
376 }
377 }
378 pws_init_items_counter++;
379 }
380 }
381 else
382 {
383 DEBUG_INFO(printf("PWS No init value setting\r\n"));
384 }
385 }
386
HAL_PWS_HandleSource(E_PWS_Operation operation,E_PWS_SouceInfo source)387 E_PWS_Result HAL_PWS_HandleSource(E_PWS_Operation operation,E_PWS_SouceInfo source)
388 {
389 E_PWS_Result ret = PWS_SUCCESS;
390 E_PWS_SouceInfo find_source;
391 MS_U16 PWS_flag_index=0;
392
393 DEBUG_INFO(printf("%s\n",__FUNCTION__));
394
395 if(operation >= PWS_INVAILD_OP)
396 {
397 ret = PWS_FAIL;
398 return ret;
399 }
400
401 if((source <= _NO_SOURCE_) || (source >= _UNKNOWN_))
402 {
403 ret = PWS_FAIL;
404 return ret;
405 }
406
407 u16PWS_First_Items= PWS_First_Items;
408 u16OutOfRange_PWS_Items= OutOfRange_PWS_Items;
409
410 // initial PWS_flag table
411 for(PWS_flag_index = u16PWS_First_Items ; PWS_flag_index < u16OutOfRange_PWS_Items ; PWS_flag_index++)
412 {
413 PWS_flag[PWS_flag_index] = 1;
414 }
415
416 // Get ON/OFF flag
417 // add or del PWS input/output data path
418 if(operation == PWS_ADD_SOURCE)
419 {
420 SourceIndex |= source;
421 }
422 else
423 {
424 SourceIndex &= (E_PWS_SouceInfo)(~source);
425 }
426 DEBUG_INFO(printf("SourceIndex = %d\n",SourceIndex));
427
428 // keep last source PWS register setting - avoid source change issue without PIP case
429 if(SourceIndex == _NO_SOURCE_)
430 {
431 return ret;
432 }
433
434 // first input/output data path
435 find_source = _USB_;
436 do
437 {
438 if((SourceIndex & find_source) > 0) // find out source
439 {
440 for(PWS_flag_index = u16PWS_First_Items ; PWS_flag_index < u16OutOfRange_PWS_Items ; PWS_flag_index++)
441 {
442 // ? 1 : 0; --> 1: OFF , 0:ON
443 // PWS_flag[PWS_flag_index] &= --> Src_A(OFF) PIP Src_B(ON) --> PWS = ON
444 PWS_flag[PWS_flag_index] &= ((pws_table[PWS_flag_index] & find_source) > 0) ? 1 : 0;
445 }
446 }
447 find_source = (E_PWS_SouceInfo)((MS_U16)(find_source) << 1); // USB ->SV->...
448 }while(find_source < _UNKNOWN_); // last input/output source
449
450 DEBUG_INFO(printf("PWS_FULL\n"));
451 for(PWS_flag_index = u16PWS_First_Items; PWS_flag_index < u16OutOfRange_PWS_Items ; PWS_flag_index++)
452 {
453 ret &= HAL_PWS_SetXXX(PWS_flag[PWS_flag_index], PWS_flag_index);
454 DEBUG_INFO(printf("func=%d,arg=%d, ret=%d\n",PWS_flag_index,PWS_flag[PWS_flag_index],ret));
455 }
456
457 return ret;
458 }
459
HAL_PWS_HandleIP(E_PWS_IpPowerCtrl IpPowerCtrl,const unsigned char * RegName)460 E_PWS_Result HAL_PWS_HandleIP(E_PWS_IpPowerCtrl IpPowerCtrl,const unsigned char *RegName)
461 {
462 MS_U16 PWS_flag_index = 0;
463 MS_U8 PWS_findString = 0;
464 E_PWS_Result ret = PWS_SUCCESS;
465
466 DEBUG_INFO(printf("%s\n",__FUNCTION__));
467
468 if(IpPowerCtrl > E_PWS_IP_OFF)
469 {
470 ret = PWS_FAIL;
471 return ret;
472 }
473
474 for(PWS_flag_index = u16PWS_First_Items ; PWS_flag_index < u16OutOfRange_PWS_Items ; PWS_flag_index++)
475 {
476 if(strcmp((char *)pws_setting_info_table[PWS_flag_index].regName,(char *)RegName) == 0)
477 {
478 DEBUG_INFO(printf("Regname is the same\r\n"));
479 PWS_findString = 1; // find out string
480 ret &= HAL_PWS_SetXXX((MS_U8)IpPowerCtrl, PWS_flag_index);
481 }
482 }
483
484 if(PWS_findString == 0)
485 {
486 ret = PWS_FAIL;
487 }
488
489 return ret;
490 }
491
HAL_PWS_RegisterCallback(MS_U8 index,E_PWS_CallbackCtrl cb_ctrl,unsigned char * RegName,P_PWS_Callback pfCallback)492 E_PWS_Result HAL_PWS_RegisterCallback(MS_U8 index, E_PWS_CallbackCtrl cb_ctrl, unsigned char *RegName, P_PWS_Callback pfCallback)
493 {
494 DEBUG_INFO(printf("%s\n",__FUNCTION__));
495
496 if(index >= PWS_Register_CB_size)
497 {
498 return PWS_FAIL;
499 }
500
501 if(cb_ctrl >= E_PWS_IP_CALLBACK_UNKNOWN)
502 {
503 return PWS_FAIL;
504 }
505
506 if(strlen((char *)RegName) > STR_LEN)
507 {
508 return PWS_FAIL;
509 }
510
511 if(pfCallback == NULL)
512 {
513 return PWS_FAIL;
514 }
515
516 PWS_RegCBinfo[index].ctrl = cb_ctrl;
517 strncpy((char *)PWS_RegCBinfo[index].regName,(char *)RegName,strlen((char *)RegName));
518 DEBUG_INFO(printf("Register IP name = %s\r\n",PWS_RegCBinfo[index].regName));
519 PWS_RegCBinfo[index]._PWSCallback = pfCallback;
520 return PWS_SUCCESS;
521 }
522
HAL_PWS_CancelCallback(MS_U8 index)523 E_PWS_Result HAL_PWS_CancelCallback(MS_U8 index)
524 {
525 DEBUG_INFO(printf("%s\n",__FUNCTION__));
526
527 if(index >= PWS_Register_CB_size)
528 {
529 return PWS_FAIL;
530 }
531
532 PWS_RegCBinfo[index].ctrl = E_PWS_IP_CALLBACK_UNKNOWN;
533 PWS_RegCBinfo[index]._PWSCallback = NULL;
534 return PWS_SUCCESS;
535 }
536
HAL_PWS_Stop_VDMCU(void)537 void HAL_PWS_Stop_VDMCU(void)
538 {
539
540 }
541
HAL_PWS_IpPowerControl(E_PWS_IP_name eIpName,E_PWS_IpPowerCtrl pwr_type)542 E_PWS_Result HAL_PWS_IpPowerControl(E_PWS_IP_name eIpName, E_PWS_IpPowerCtrl pwr_type)
543 {
544 MS_U32 i;
545 MS_BOOL bWriteRet;
546
547 bWriteRet = TRUE;
548
549 for (i = 0; pws_ip_info_table[i].eIpName != E_PWS_IP_MAX; ++i)
550 {
551 if ( pws_ip_info_table[i].eIpName == eIpName)
552 {
553 bWriteRet = HAL_PWS_Write2Byte (pws_ip_info_table[i].u32RegAddr, pws_ip_info_table[i].u16RegVal);
554
555 if (bWriteRet != TRUE)
556 {
557 return PWS_FAIL;
558 }
559 }
560 }
561
562 for (i = 0; pws_ip_mask_info_table[i].eIpName != E_PWS_IP_MAX; ++i)
563 {
564 if ( pws_ip_mask_info_table[i].eIpName == eIpName)
565 {
566 bWriteRet = HAL_PWS_WriteRegBit (pws_ip_mask_info_table[i].u32RegAddr, pws_ip_mask_info_table[i].bEnable, pws_ip_mask_info_table[i].u8BitPos);
567
568 if (bWriteRet != TRUE)
569 {
570 return PWS_FAIL;
571 }
572 }
573 }
574
575
576
577 return PWS_SUCCESS;
578 }
579