1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - PM - include
3 File: pm.h
4
5 Copyright 2003-2008 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2009-02-03#$
14 $Rev: 9957 $
15 $Author: nishimoto_takashi $
16 *---------------------------------------------------------------------------*/
17
18 #ifndef NITRO_PM_ARM9_H_
19 #define NITRO_PM_ARM9_H_
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 #ifdef SDK_NITRO
26 #include <nitro/misc.h>
27 #include <nitro/types.h>
28 #else
29 #include <twl/misc.h>
30 #include <twl/types.h>
31 #endif
32
33 #include <nitro/spi/common/pm_common.h>
34 #include <nitro/spi/common/type.h>
35 #include <nitro/pxi/common/fifo.h>
36
37 //================================================================
38 //---- callback for async function
39 typedef void (*PMCallback) (u32 result, void *arg);
40
41 //================================================================
42 // parameters for PM API
43 //================================================================
44 //---- LCD target
45 typedef enum
46 {
47 PM_LCD_TOP = 0,
48 PM_LCD_BOTTOM = 1,
49 PM_LCD_ALL = 2
50 }
51 PMLCDTarget;
52
53 //---- back light
54 typedef enum
55 {
56 PM_BACKLIGHT_OFF = 0,
57 PM_BACKLIGHT_ON = 1
58 }
59 PMBackLightSwitch;
60
61 //---- battery status (VDET terminal voltage)
62 typedef enum
63 {
64 PM_BATTERY_HIGH = 0,
65 PM_BATTERY_LOW = 1
66 }
67 PMBattery;
68
69 //---- programable gain amp
70 typedef enum
71 {
72 PM_AMP_OFF = 0,
73 PM_AMP_ON = 1
74 }
75 PMAmpSwitch;
76
77 //---- gain of programable gain amp
78 typedef enum
79 {
80 PM_AMPGAIN_20 = 0,
81 PM_AMPGAIN_40 = 1,
82 PM_AMPGAIN_80 = 2,
83 PM_AMPGAIN_160 = 3,
84 PM_AMPGAIN_DEFAULT = PM_AMPGAIN_40
85 }
86 PMAmpGain;
87
88 #define PM_GAINAMP_DEFAULT PM_AMPGAIN_DEFAULT // for compatible
89
90 //---- LCD power
91 typedef enum
92 {
93 PM_LCD_POWER_OFF = 0,
94 PM_LCD_POWER_ON = 1
95 }
96 PMLCDPower;
97
98 #ifdef SDK_TWL
99 //---- ExitFactor
100 typedef enum
101 {
102 PM_EXIT_FACTOR_NONE = 0,
103 PM_EXIT_FACTOR_PWSW = 1,
104 PM_EXIT_FACTOR_BATTERY = 2,
105 PM_EXIT_FACTOR_USER = 3
106 }
107 PMExitFactor;
108 #endif
109
110 //---- callback type
111 // general purpose
112 typedef void (*PMGenCallback) (void *);
113 // sleep
114 #define PMSleepCallback PMGenCallback
115 #ifdef SDK_TWL
116 // exit
117 #define PMExitCallback PMGenCallback
118 // batteryLow
119 #define PMBatteryLowCallback PMGenCallback
120 #endif
121
122 //---- callback info type
123 // general purpose
124 typedef struct PMiGenCallbackInfo PMGenCallbackInfo;
125 struct PMiGenCallbackInfo
126 {
127 PMGenCallback callback;
128 void* arg;
129 int priority;
130 PMGenCallbackInfo* next;
131 };
132
133 // sleep
134 #define PMSleepCallbackInfo PMGenCallbackInfo
135 #ifdef SDK_TWL
136 // exit
137 #define PMExitCallbackInfo PMGenCallbackInfo
138 // batteryLow
139 #define PMBatteryLowCallbackInfo PMGenCallbackInfo
140 #endif
141
142 //---- callback priority
143 #define PM_CALLBACK_PRIORITY_SYSMIN (-65535)
144 #define PM_CALLBACK_PRIORITY_MIN (-255)
145 #define PM_CALLBACK_PRIORITY_MAX 255
146 #define PM_CALLBACK_PRIORITY_SYSMAX 65535
147
148 #define PM_CALLBACK_PRIORITY_WM 1000
149 #define PM_CALLBACK_PRIORITY_DSP 1010
150 #define PM_CALLBACK_PRIORITY_CAMERA 1020
151 #define PM_CALLBACK_PRIORITY_NWM PM_CALLBACK_PRIORITY_SYSMAX
152 #define PM_CALLBACK_PRIORITY_FS PM_CALLBACK_PRIORITY_SYSMAX -1
153 #define PM_CALLBACK_PRIORITY_SNDEX PM_CALLBACK_PRIORITY_SYSMAX -2
154
155 //================================================================================
156 // INITIALIZE
157 //================================================================================
158 /*---------------------------------------------------------------------------*
159 Name: PM_Init
160
161 Description: initialize PM
162
163 Arguments: None
164
165 Returns: None
166 *---------------------------------------------------------------------------*/
167 void PM_Init(void);
168
169 //================================================================================
170 // SEND COMMAND TO ARM7
171 //================================================================================
172 /*---------------------------------------------------------------------------*
173 Name: PM_SendUtilityCommandAsync / PM_SendUtilityCommand
174
175 Description: send utility command to ARM7
176
177 Arguments: number : action number
178 parameter : parameter for utility command
179 retValue : buffer to store result
180 callback : callback function
181 arg : argument of callback
182
183 Returns: result of issueing command
184 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
185 PM_RESULT_SUCCESS : success
186 *---------------------------------------------------------------------------*/
187 u32 PM_SendUtilityCommandAsync(u32 number, u16 parameter, u16* retValue, PMCallback callback, void *arg);
188 u32 PM_SendUtilityCommand(u32 number, u16 parameter, u16* retValue);
189
190 /*---------------------------------------------------------------------------*
191 Name: PM_SetBackLightAsync / PM_SetBackLight
192
193 Description: change backlight switch
194
195 Arguments: targer : target LCD.
196 PM_LCD_TOP : top LCD
197 PM_LCD_BOTTOM : bottom LCD
198 PM_LCD_ALL : top and bottom LCD
199 sw : switch of top LCD.
200 PM_BACKLIGHT_OFF : off
201 PM_BACKLIGHT_ON : on
202 callback : callback function
203 arg : callback argument
204
205 Returns: result.
206 PM_RESULT_SUCCESS : success to exec command
207 PM_INVALID_COMMAND : bad status given
208 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
209 *---------------------------------------------------------------------------*/
210 u32 PM_SetBackLightAsync(PMLCDTarget target, PMBackLightSwitch sw, PMCallback callback, void *arg);
211 u32 PM_SetBackLight(PMLCDTarget target, PMBackLightSwitch status);
212
213 //================================================================================
214 // RESET HARDWARE (TWL)
215 //================================================================================
216 /*---------------------------------------------------------------------------*
217 Name: PM_ForceToPowerOffAsync / PM_ForceToPowerOff
218
219 Description: force to turn off main power
220
221 Arguments: callback : callback function
222 arg : callback argument
223
224 Returns: (PM_ForceToPowerOffAsync)
225 result.
226 PM_RESULT_SUCCESS : success to exec command
227 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
228
229 (PM_ForceToPowerOff)
230 PM_RESULT_SUCCESS : success to exec command
231
232 If success, maybe you cannot do anything because power if off.
233 *---------------------------------------------------------------------------*/
234 u32 PM_ForceToPowerOffAsync(PMCallback callback, void *arg);
235 u32 PM_ForceToPowerOff(void);
236
237 /*---------------------------------------------------------------------------*
238 Name: PM_SetAmpAsync / PM_SetAmp
239
240 Description: switch amp
241
242 Arguments: sw : switch of programable gain amp
243 PM_AMP_ON : on
244 PM_AMP_OFF : off
245 callback : callback function
246 arg : callback argument
247
248 Returns: result.
249 PM_RESULT_SUCCESS : success to exec command
250 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
251 *---------------------------------------------------------------------------*/
252 u32 PM_SetAmpAsync(PMAmpSwitch sw, PMCallback callback, void *arg);
253 u32 PM_SetAmp(PMAmpSwitch sw);
254
255 /*---------------------------------------------------------------------------*
256 Name: PM_SetAmpGainAsync / PM_SetAmpGain
257
258 Description: change amp gain
259
260 Arguments: gain : gain
261 PM_AMPGAIN_20 : gain=20
262 PM_AMPGAIN_40 : gain=40
263 PM_AMPGAIN_80 : gain=80
264 PM_AMPGAIN_160 : gain=160
265 callback : callback function
266 arg : callback argument
267
268 Returns: result.
269 PM_RESULT_SUCCESS : success to exec command
270 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
271 *---------------------------------------------------------------------------*/
272 u32 PM_SetAmpGainAsync(PMAmpGain gain, PMCallback callback, void *arg);
273 u32 PM_SetAmpGain(PMAmpGain gain);
274
275 #ifdef SDK_TWL
276 /*---------------------------------------------------------------------------*
277 Name: PM_SetAmpGainLevelAsync / PM_SetAmpGainLevel
278
279 Description: change amp gain
280
281 Arguments: level : gain. 0 - 119 (0dB - 59.5dB)
282 (119 is defined as PM_AMPGAIN_LEVEL_MAX)
283
284 callback : callback function
285 arg : callback argument
286
287 Returns: result.
288 PM_RESULT_SUCCESS : success to exec command
289 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
290 *---------------------------------------------------------------------------*/
291 u32 PM_SetAmpGainLevelAsync(u8 level, PMCallback callback, void *arg);
292 u32 PM_SetAmpGainLevel(u8 level);
293 #endif
294
295 //================================================================================
296 // GET STATUS FROM ARM7
297 //================================================================================
298 /*---------------------------------------------------------------------------*
299 Name: PM_GetBattery
300
301 Description: get battery status
302
303 Arguments: batteryBuf : buffer to store result
304
305 Returns: result.
306 PM_RESULT_SUCCESS : success to exec command
307 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
308 *---------------------------------------------------------------------------*/
309 u32 PM_GetBattery(PMBattery *batteryBuf);
310
311 /*---------------------------------------------------------------------------*
312 Name: PM_GetBatteryLevel
313
314 Description: get battery level
315
316 Arguments: levelBuf : buffer to store result
317 the value range is from PM_BATTERY_LEVEL_MIN to PM_BATTERY_LEVEL_MAX.
318
319 Returns: result.
320 PM_RESULT_SUCCESS : success to exec command
321 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
322 PM_RESULT_ERROR : cannot use this function (running NITRO mode)
323 *---------------------------------------------------------------------------*/
324 #ifdef SDK_TWL
325 u32 PM_GetBatteryLevel(PMBatteryLevel *levelBuf);
326 #else
PM_GetBatteryLevel(PMBatteryLevel * levelBuf)327 static inline u32 PM_GetBatteryLevel(PMBatteryLevel *levelBuf)
328 {
329 #pragma unused(levelBuf)
330 return PM_RESULT_ERROR;
331 }
332 #endif
333
334 /*---------------------------------------------------------------------------*
335 Name: PM_GetACAdapter
336
337 Description: check if AC power adaptor is connected
338
339 Arguments: isConnectedBuf : buffer to store result
340 TRUE ... connected
341 FALSE ... not connected
342
343 Returns: result.
344 PM_RESULT_SUCCESS : success to exec command
345 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
346 PM_RESULT_ERROR : cannot use this function (running NITRO mode)
347 *---------------------------------------------------------------------------*/
348 #ifdef SDK_TWL
349 u32 PM_GetACAdapter(BOOL *isConnectedBuf);
350 #else
PM_GetACAdapter(BOOL * isConnectedBuf)351 static inline u32 PM_GetACAdapter(BOOL *isConnectedBuf)
352 {
353 #pragma unused(isConnectedBuf)
354 return PM_RESULT_ERROR;
355 }
356 #endif
357
358 /*---------------------------------------------------------------------------*
359 Name: PM_GetBackLight
360
361 Description: get backlight status
362
363 Arguments: top : buffer to set result of top LCD
364 bottom : buffer to set result of bottom LCD
365
366 Returns: result.
367 PM_RESULT_SUCCESS : success to exec command
368 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
369 *---------------------------------------------------------------------------*/
370 u32 PM_GetBackLight(PMBackLightSwitch *top, PMBackLightSwitch *bottom);
371
372 /*---------------------------------------------------------------------------*
373 Name: PM_GetAmp
374
375 Description: get status of amp switch
376
377 Arguments: swBuf : buffer to store result
378
379 Returns: result.
380 PM_RESULT_SUCCESS : success to exec command
381 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
382 *---------------------------------------------------------------------------*/
383 u32 PM_GetAmp(PMAmpSwitch *swBuf);
384
385 /*---------------------------------------------------------------------------*
386 Name: PM_GetAmpGain
387
388 Description: get status of amp gain
389
390 Arguments: gainBuf : buffer to store result
391
392 Returns: result.
393 PM_RESULT_SUCCESS : success to exec command
394 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
395 *---------------------------------------------------------------------------*/
396 u32 PM_GetAmpGain(PMAmpGain *gainBuf);
397
398 #ifdef SDK_TWL
399 /*---------------------------------------------------------------------------*
400 Name: PM_GetAmpGainLevel
401
402 Description: get level of amp gain
403
404 Arguments: levelBuf : buffer to store result
405
406 Returns: result.
407 PM_RESULT_SUCCESS : success to exec command
408 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
409 *---------------------------------------------------------------------------*/
410 u32 PM_GetAmpGainLevel(u8 *levelBuf);
411 #endif
412
413 //================================================================================
414 // WIRELESS LED
415 //================================================================================
416 #ifdef SDK_TWL
417 /*---------------------------------------------------------------------------*
418 Name: PMi_SetWirelessLED
419
420 Description: get status of amp gain
421
422 Arguments: sw : PM_WIRELESS_LED_ON ... ON
423 PM_WIRELESS_LED_OFF ... OFF
424
425 Returns: result.
426 PM_RESULT_SUCCESS : success to exec command
427 PM_RESULT_ERROR : some error occurred in ARM7
428 *---------------------------------------------------------------------------*/
429 u32 PMi_SetWirelessLED( PMWirelessLEDStatus sw );
430 #endif //ifdef SDK_TWL
431
432 //================================================================================
433 // SLEEP
434 //================================================================================
435 /*---------------------------------------------------------------------------*
436 Name: PM_GoSleepMode
437
438 Description: go to be in sleep mode
439
440 Arguments: trigger : factors to return from being on sleep
441 logic : key logic to key interrupt
442 PM_PAD_LOGIC_AND : occur interrupt at all specified button pushed
443 PM_PAD_LOGIC_OR : occur interrupt at one of specified buttons pushed
444 keyPattern : keys to wakeup
445
446 Returns: None
447 *---------------------------------------------------------------------------*/
448 void PM_GoSleepMode(PMWakeUpTrigger trigger, PMLogic logic, u16 keyPattern);
449
450 //================================================================================
451 // CALLBACK for sleep mode
452 //================================================================================
453 /*---------------------------------------------------------------------------*
454 Name: PM_SetSleepCallbackInfo
455
456 Description: set up sleep callback info
457
458 Arguments: info : callback info
459 callback : callback to set
460 arg : arg to set
461
462 Returns: None
463 *---------------------------------------------------------------------------*/
PM_SetSleepCallbackInfo(PMSleepCallbackInfo * info,PMSleepCallback callback,void * arg)464 static inline void PM_SetSleepCallbackInfo(PMSleepCallbackInfo *info, PMSleepCallback callback, void *arg)
465 {
466 info->callback = callback;
467 info->arg = arg;
468 }
469
470 /*---------------------------------------------------------------------------*
471 Name: PM_AppendPreSleepCallback
472
473 Description: append callback info to pre-callback info list
474
475 Arguments: info : callback info to append
476
477 Returns: None
478 *---------------------------------------------------------------------------*/
479 void PM_AppendPreSleepCallback(PMSleepCallbackInfo *info);
480
481 /*---------------------------------------------------------------------------*
482 Name: PM_PrependPreSleepCallback
483
484 Description: prepend callback info to pre-callback info list
485
486 Arguments: info : callback info to prepend
487
488 Returns: None
489 *---------------------------------------------------------------------------*/
490 void PM_PrependPreSleepCallback(PMSleepCallbackInfo *info);
491
492 /*---------------------------------------------------------------------------*
493 Name: PM_AppendPostSleepCallback
494
495 Description: append callback info to post-callback info list
496
497 Arguments: info : callback info to append
498
499 Returns: None
500 *---------------------------------------------------------------------------*/
501 void PM_AppendPostSleepCallback(PMSleepCallbackInfo *info);
502
503 /*---------------------------------------------------------------------------*
504 Name: PM_PrependPostSleepCallback
505
506 Description: prepend callback info to post-callback info list
507
508 Arguments: info : callback info to prepend
509
510 Returns: None
511 *---------------------------------------------------------------------------*/
512 void PM_PrependPostSleepCallback(PMSleepCallbackInfo *info);
513
514 /*---------------------------------------------------------------------------*
515 Name: PM_InsertPreSleepCallback
516
517 Description: insert callback info to post-callback info list
518
519 Arguments: info : callback info to add
520 priority : pritory
521
522 Returns: None
523 *---------------------------------------------------------------------------*/
524 void PM_InsertPreSleepCallback(PMSleepCallbackInfo *info, int priority);
525
526 /*---------------------------------------------------------------------------*
527 Name: PM_InsertPostSleepCallback
528
529 Description: insert callback info to post-callback info list
530
531 Arguments: info : callback info to add
532 priority : pritory
533
534 Returns: None
535 *---------------------------------------------------------------------------*/
536 void PM_InsertPostSleepCallback(PMSleepCallbackInfo *info, int priority);
537
538 /*---------------------------------------------------------------------------*
539 Name: PM_DeletePreSleepCallback
540
541 Description: delete callback info from pre-callback info list
542
543 Arguments: info : callback info to delete
544
545 Returns: None
546 *---------------------------------------------------------------------------*/
547 void PM_DeletePreSleepCallback(PMSleepCallbackInfo *info);
548
549 /*---------------------------------------------------------------------------*
550 Name: PM_DeletePostSleepCallback
551
552 Description: delete callback info from post-callback info list
553
554 Arguments: info : callback info to delete
555
556 Returns: None
557 *---------------------------------------------------------------------------*/
558 void PM_DeletePostSleepCallback(PMSleepCallbackInfo *info);
559
560 /*---------------------------------------------------------------------------*
561 Name: PM_ClearPreSleepCallback
562
563 Description: clear pre-callback info list
564
565 Arguments: info : callback info to delete
566
567 Returns: None
568 *---------------------------------------------------------------------------*/
569 void PM_ClearPreSleepCallback(void);
570
571 /*---------------------------------------------------------------------------*
572 Name: PM_ClearPostSleepCallback
573
574 Description: clear post-callback info list
575
576 Arguments: info : callback info to delete
577
578 Returns: None
579 *---------------------------------------------------------------------------*/
580 void PM_ClearPostSleepCallback(void);
581
582
583 //================================================================================
584 // LCD
585 //================================================================================
586 /*---------------------------------------------------------------------------*
587 Name: PM_SetLCDPower
588
589 Description: turn on/off LCD power
590 when undefined SDK_NO_THREAD (= thread is valid),
591 Tick system and Alarm system are needed.
592
593 this function is sync version.
594
595 Arguments: sw : switch
596 PM_LCD_POWER_ON : on
597 PM_LCD_POWER_OFF : off
598
599 Returns: TRUE if success
600 FALSE if fail. maybe interval of LCD off->on is too short.
601 *---------------------------------------------------------------------------*/
602 BOOL PM_SetLCDPower(PMLCDPower sw);
603
604 /*---------------------------------------------------------------------------*
605 Name: PM_GetLCDPower
606
607 Description: get status of LCD power
608
609 Arguments: None
610
611 Returns: status.
612 PM_LCD_POWER_ON : on
613 PM_LCD_POWER_OFF : off
614 *---------------------------------------------------------------------------*/
615 PMLCDPower PM_GetLCDPower(void);
616
617
618 //================================================================================
619 // LED
620 //================================================================================
621 u32 PMi_SendLEDPatternCommandAsync(PMLEDPattern pattern, PMCallback callback, void *arg);
622 u32 PMi_SendLEDPatternCommand(PMLEDPattern pattern);
623 /*---------------------------------------------------------------------------*
624 Name: PM_SetLEDPatternAsync / PM_SetLEDPattern
625
626 Description: set up LED blink pattern
627
628 Arguments: pattern : LED blink pattern
629 callback : callback function
630 arg : callback argument
631
632 Returns: result of issueing command
633 PM_RESULT_SUCCESS : success
634 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
635 *---------------------------------------------------------------------------*/
PM_SetLEDPatternAsync(PMLEDPattern pattern,PMCallback callback,void * arg)636 static inline u32 PM_SetLEDPatternAsync(PMLEDPattern pattern, PMCallback callback, void *arg)
637 {
638 return PMi_SendLEDPatternCommandAsync(pattern, callback, arg);
639 }
PM_SetLEDPattern(PMLEDPattern pattern)640 static inline u32 PM_SetLEDPattern(PMLEDPattern pattern)
641 {
642 return PMi_SendLEDPatternCommand(pattern);
643 }
644
645 /*---------------------------------------------------------------------------*
646 Name: PM_GetLEDPatternAsync / PM_GetLEDPattern
647
648 Description: get current LED pattern
649
650 Arguments: patternBuf : area to set LED status
651 callback : callback function
652 arg : callback argument
653
654 Returns: result of issueing command
655 PM_RESULT_SUCCESS : success
656 PM_RESULT_BUSY : busy because other device or other PM function uses SPI
657 *---------------------------------------------------------------------------*/
658 u32 PM_GetLEDPatternAsync(PMLEDPattern *patternBuf, PMCallback callback, void *arg);
659 u32 PM_GetLEDPattern(PMLEDPattern *patternBuf);
660
661 #ifdef SDK_TWL
662 //================================================================================
663 // SHUTDOWN / RESET HARDWARE (TWL)
664 //================================================================================
665 /*---------------------------------------------------------------------------*
666 Name: PM_SetExitCallbackInfo
667
668 Description: set up exit callback info
669
670 Arguments: info : callback info
671 callback : callback to set
672 arg : arg to set
673
674 Returns: None
675 *---------------------------------------------------------------------------*/
PM_SetExitCallbackInfo(PMExitCallbackInfo * info,PMExitCallback callback,void * arg)676 static inline void PM_SetExitCallbackInfo(PMExitCallbackInfo *info, PMExitCallback callback, void *arg)
677 {
678 info->callback = callback;
679 info->arg = arg;
680 }
681
682 /*---------------------------------------------------------------------------*
683 Name: PM_ReadyToExit
684
685 Description: tell ARM7 that ARM9 is ready to exit
686
687 Arguments: None
688
689 Returns: None
690 (This function will never return.)
691 *---------------------------------------------------------------------------*/
692 void PM_ReadyToExit(void);
693
694 /*---------------------------------------------------------------------------*
695 Name: PM_GetExitFactor
696
697 Description: get a factor which caused to exit
698
699 Arguments: None
700
701 Returns: factor : PM_EXIT_FACTOR_PWSW ... pushed power switch
702 PM_EXIT_FACTOR_BATTERY ... battery low
703 PM_EXIT_FACTOR_USER ... called PM_ForceToResetHardware
704 PM_EXIT_FACTOR_NONE ... not set yet
705 *---------------------------------------------------------------------------*/
706 PMExitFactor PM_GetExitFactor(void);
707
708 /*---------------------------------------------------------------------------*
709 Name: PM_AppendPreExitCallback
710
711 Description: append exit callback info to pre-callback info list
712
713 Arguments: info : callback info to append
714
715 Returns: None
716 *---------------------------------------------------------------------------*/
717 void PM_AppendPreExitCallback( PMExitCallbackInfo *info );
718
719 /*---------------------------------------------------------------------------*
720 Name: PM_AppendPostExitCallback
721
722 Description: append exit callback info to post-callback info list
723
724 Arguments: info : callback info to append
725
726 Returns: None
727 *---------------------------------------------------------------------------*/
728 void PM_AppendPostExitCallback( PMExitCallbackInfo *info );
729
730 /*---------------------------------------------------------------------------*
731 Name: PM_PrependPreExitCallback
732
733 Description: prepend exit callback info to pre-callback info list
734
735 Arguments: info : callback info to prepend
736
737 Returns: None
738 *---------------------------------------------------------------------------*/
739 void PM_PrependPreExitCallback( PMExitCallbackInfo *info );
740
741 /*---------------------------------------------------------------------------*
742 Name: PM_PrependPostExitCallback
743
744 Description: prepend exit callback info to post-callback info list
745
746 Arguments: info : callback info to prepend
747
748 Returns: None
749 *---------------------------------------------------------------------------*/
750 void PM_PrependPostExitCallback( PMExitCallbackInfo *info );
751
752 /*---------------------------------------------------------------------------*
753 Name: PM_InsertPreExitCallback
754
755 Description: insert an exit callback info to pre-callback info list
756
757 Arguments: info : callback info to add
758 priority : pritory
759
760 Returns: None
761 *---------------------------------------------------------------------------*/
762 void PM_InsertPreExitCallback( PMExitCallbackInfo *info, int priority );
763
764 /*---------------------------------------------------------------------------*
765 Name: PM_InsertPostExitCallback
766
767 Description: insert an exit callback info to post-callback info list
768
769 Arguments: info : callback info to add
770 priority : pritory
771
772 Returns: None
773 *---------------------------------------------------------------------------*/
774 void PM_InsertPostExitCallback( PMExitCallbackInfo *info, int priority );
775
776 /*---------------------------------------------------------------------------*
777 Name: PM_DeletePreExitCallback
778
779 Description: delete exit callback info from pre-callback info list
780
781 Arguments: info : callback info to delete
782
783 Returns: None
784 *---------------------------------------------------------------------------*/
785 void PM_DeletePreExitCallback( PMExitCallbackInfo *info );
786
787 /*---------------------------------------------------------------------------*
788 Name: PM_DeletePostExitCallback
789
790 Description: delete exit callback info from post-callback info list
791
792 Arguments: info : callback info to delete
793
794 Returns: None
795 *---------------------------------------------------------------------------*/
796 void PM_DeletePostExitCallback( PMExitCallbackInfo *info );
797
798 /*---------------------------------------------------------------------------*
799 Name: PM_ClearPreExitCallback
800
801 Description: clear exit pre-callback info list
802
803 Arguments: None
804
805 Returns: None
806 *---------------------------------------------------------------------------*/
807 void PM_ClearPreExitCallback(void);
808
809 /*---------------------------------------------------------------------------*
810 Name: PM_ClearPostExitCallback
811
812 Description: clear exit post-callback info list
813
814 Arguments: None
815
816 Returns: None
817 *---------------------------------------------------------------------------*/
818 void PM_ClearPostExitCallback(void);
819
820 /*---------------------------------------------------------------------------*
821 Name: PM_SetAutoExit
822
823 Description: set flag to shutdown/reset (not) automatically after callback
824
825 Arguments: sw : TRUE ... shutdown/reset after callback automatically
826 FALSE ... not shutdown/reset after callback
827
828 Returns: None
829 *---------------------------------------------------------------------------*/
830 void PM_SetAutoExit( BOOL sw );
831
832 /*---------------------------------------------------------------------------*
833 Name: PM_GetAutoExit
834
835 Description: get the current setting of AutoExit
836
837 Arguments: None
838
839 Returns: TRUE ... shutdown/reset after callback automatically
840 FALSE ... not shutdown/reset after callback
841 *---------------------------------------------------------------------------*/
842 BOOL PM_GetAutoExit(void);
843
844 //================================================================================
845 // BATTERY CALLBACK
846 //================================================================================
847 /*---------------------------------------------------------------------------*
848 Name: PM_SetBatteryLowCallback
849
850 Description: set battery low callback
851
852 Arguments: callback : callback called in detecting battery low
853 arg : callback argument
854
855 Returns: None
856 *---------------------------------------------------------------------------*/
857 void PM_SetBatteryLowCallback( PMBatteryLowCallback callback, void* arg );
858
859 //================================================================================
860 // RESET HARDWARE (TWL)
861 //================================================================================
862 /*---------------------------------------------------------------------------*
863 Name: PM_ForceToResetHardware
864
865 Description: tell ARM7 to reset hardware
866
867 Arguments: None
868
869 Returns: None
870 *---------------------------------------------------------------------------*/
871 void PM_ForceToResetHardware(void);
872
873 #endif
874
875 //================================================================================
876 // DUMP (for DEBUG)
877 //================================================================================
878 /*---------------------------------------------------------------------------*
879 Name: PM_DumpSleepCallback
880
881 Description: dump sleep callbacks (for debug)
882
883 Arguments: None.
884
885 Returns: None.
886 *---------------------------------------------------------------------------*/
887 #ifndef SDK_FINALROM
888 void PM_DumpSleepCallback(void);
889 #else
890 #define PM_DumpSleepCallback() ((void)0)
891 #endif
892
893 /*---------------------------------------------------------------------------*
894 Name: PM_DumpExitCallback
895
896 Description: dump exit callbacks (for debug)
897
898 Arguments: None.
899
900 Returns: None.
901 *---------------------------------------------------------------------------*/
902 #ifdef SDK_TWL
903 #ifndef SDK_FINALROM
904 void PM_DumpExitCallback(void);
905 #else
906 #define PM_DumpExitCallback() ((void)0)
907 #endif
908 #endif
909
910 //================================================================
911 // internal functions
912 //================================================================
913 //
914 // these PMi_ functions are internal function.
915 // don't use these functions
916 //
917 //---- sound power
918 typedef enum
919 {
920 PM_SOUND_POWER_OFF = 0,
921 PM_SOUND_POWER_ON = 1
922 }
923 PMSoundPowerSwitch;
924
925 //---- sound volume control
926 typedef enum
927 {
928 PM_SOUND_VOLUME_OFF = 0,
929 PM_SOUND_VOLUME_ON = 1
930 }
931 PMSoundVolumeSwitch;
932
933 //---------------- set LCD and LED
934 BOOL PMi_SetLCDPower(PMLCDPower sw, PMLEDStatus led, BOOL skip, BOOL isSync);
935
936 //---------------- change sound power switch
937 u32 PMi_SetSoundPowerAsync(PMSoundPowerSwitch sw, PMCallback callback, void *arg);
938 u32 PMi_SetSoundPower(PMSoundPowerSwitch sw);
939
940 //---------------- change sound volume control switch
941 u32 PMi_SetSoundVolumeAsync(PMSoundVolumeSwitch sw, PMCallback callback, void *arg);
942 u32 PMi_SetSoundVolume(PMSoundVolumeSwitch sw);
943
944 //---------------- get status of sound power switch
945 u32 PMi_GetSoundPower(PMSoundPowerSwitch *swBuf);
946
947 //---------------- get status of sound volume control switch
948 u32 PMi_GetSoundVolume(PMSoundVolumeSwitch *swBuf);
949
950 //---------------- send data to ARM7
951 void PMi_SendPxiData(u32 data);
952
953 //---------------- callback
954 void PMi_CommonCallback(PXIFifoTag tag, u32 data, BOOL err);
955
956 //---------------- send sleep command / dispose sleep end
957 u32 PMi_SendSleepStart(u16 trigger, u16 keyIntrData);
958 u32 PMi_DisposeSleepEnd(void);
959
960 //---------------- set LED status
961 u32 PMi_SetLEDAsync(PMLEDStatus status, PMCallback callback, void *arg);
962 u32 PMi_SetLED(PMLEDStatus status);
963
964 //---------------- get counter value LCD turned off
965 u32 PMi_GetLCDOffCount(void);
966
967 #ifdef SDK_TWL
968 //---------------- execute callbacks registerd to info lists
969 void PMi_ExecuteAllListsOfExitCallback(void);
970 void PMi_ExecutePreExitCallbackList(void);
971 void PMi_ExecutePostExitCallbackList(void);
972 #endif
973
974 #ifndef SDK_FINALROM
975 //---------------- read register
976 u32 PMi_ReadRegisterAsync(u16 registerAddr, u16 *buffer, PMCallback callback, void *arg);
977 u32 PMi_ReadRegister(u16 registerAddr, u16 *buffer);
978
979 //---------------- write register
980 u32 PMi_WriteRegisterAsync(u16 registerAddr, u16 data, PMCallback callback, void *arg);
981 u32 PMi_WriteRegister(u16 registerAddr, u16 data);
982 #endif
983
984 //---------------- set sleep callback for system
985 void PMi_InsertPreSleepCallbackEx( PMSleepCallbackInfo *info, int priority );
986 void PMi_InsertPostSleepCallbackEx( PMSleepCallbackInfo *info, int priority );
987
988 #ifdef SDK_TWL
989 //---------------- set exit callback for system
990 void PMi_InsertPreExitCallbackEx( PMExitCallbackInfo *info, int priority );
991 void PMi_InsertPostExitCallbackEx( PMExitCallbackInfo *info, int priority );
992 #endif
993
994 //---------------- record disp off counter
995 void PMi_SetDispOffCount(void);
996
997 #ifdef SDK_TWL
998 //---------------- try to lock
999 BOOL PMi_TryLockForReset(void);
1000 #endif
1001
1002 #ifdef __cplusplus
1003 } /* extern "C" */
1004 #endif
1005
1006 /* NITRO_PM_ARM9_H_ */
1007 #endif
1008