/
audit44xx.c
1996 lines (1846 loc) · 57.7 KB
/
audit44xx.c
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*
* @Component OMAPCONF
* @Filename audit44xx.c
* @Description OMAP4 Power Audit Functions
* @Author Patrick Titiano (p-titiano@ti.com)
* @Date 2010
* @Copyright Texas Instruments Incorporated
*
*
* Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the
* distribution.
*
* Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <audit.h>
#include <audit44xx.h>
#include <lib_android.h>
#include <uc_audit44xx.h>
#include <module44xx.h>
#include <lib.h>
#include <lib44xx.h>
#include <autoadjust_table.h>
#include <cpufreq.h>
#include <cpuinfo.h>
#include <help.h>
#include <interrupts.h>
#include <timer_stats.h>
#include <cstate.h>
#include <emif44xx.h>
#include <dep44xx.h>
#include <cm44xx.h>
#include <prm44xx.h>
#include <unistd.h>
#include <vp44xx.h>
#include <pads44xx.h>
/* #define AUDIT44XX_DEBUG */
#ifdef AUDIT44XX_DEBUG
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#else
#define dprintf(format, ...)
#endif
static const char pass[5] = "Pass";
static const char fail[5] = "FAIL";
static const char ignore[12] = "Ignored (1)";
static const char warning[8] = "Warning";
/* #define MODULE_AUTOIDLE_MODE_AUDIT44XX_DEBUG */
#ifdef MODULE_AUTOIDLE_MODE_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#endif
/* ------------------------------------------------------------------------*//**
* @FUNCTION module_autoidle_mode_audit44xx
* @BRIEF module autoidle mode audit.
* @RETURNS pointer to global pass string in case of successfull
* audit
* pointer to global fail string in case of failing audit
* pointer to global ignore string in case of unavailable
* or internal error
* @param[in] mod_id: module ID
* @param[in,out] mode: module autoidle mode (returned)
* @param[in,out] mode_por: expected module autoidle mode (returned)
* @param[in,out] err_nbr: error number (returned)
* @param[in,out] wng_nbr: warning number (returned)
* @DESCRIPTION module autoidle mode audit.
*//*------------------------------------------------------------------------ */
char *module_autoidle_mode_audit44xx(mod44xx_id mod_id,
mod_autoidle_mode *mode, mod_autoidle_mode *mode_por,
unsigned int *err_nbr, unsigned int *wng_nbr)
{
int ret;
char mod_name[MOD44XX_MAX_NAME_LENGTH];
CHECK_CPU(44xx, (char *) ignore);
CHECK_NULL_ARG(mode, (char *) ignore);
CHECK_NULL_ARG(mode_por, (char *) ignore);
CHECK_NULL_ARG(err_nbr, (char *) ignore);
CHECK_NULL_ARG(wng_nbr, (char *) ignore);
*err_nbr = 0;
*wng_nbr = 0;
*mode = MOD_AUTOIDLE_MODE_MAX;
*mode_por = MOD_AUTOGATING;
/* Get module autoidle mode */
ret = mod44xx_get_autoidle_mode(mod_id, mode);
if (ret == 1) {
if (*mode != *mode_por) {
dprintf("%s(): %s AUTOIDLE mode disabled.\n", __func__,
mod44xx_get_name(mod_id, mod_name));
(*err_nbr)++;
return (char *) fail;
} else {
dprintf("%s(): %s AUTOIDLE mode enabled.\n", __func__,
mod44xx_get_name(mod_id, mod_name));
return (char *) pass;
}
} else if (ret == 0) {
dprintf(
"%s(): %s disabled. Module registers cannot be audited.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
return (char *) ignore;
} else if (ret == OMAPCONF_ERR_NOT_AVAILABLE) {
dprintf("%s(): %s has no AUTOIDLE bit\n",
__func__, mod44xx_get_name(mod_id, mod_name));
return (char *) ignore;
} else {
fprintf(stderr,
"omapconf: internal error while checking module %s AUTOIDLE bit! (%d)\n",
mod44xx_get_name(mod_id, mod_name), ret);
return (char *) ignore;
}
}
#ifdef MODULE_AUTOIDLE_MODE_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...)
#endif
/* #define MODULE_IDLE_MODE_AUDIT44XX_DEBUG */
#ifdef MODULE_IDLE_MODE_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#endif
/* ------------------------------------------------------------------------*//**
* @FUNCTION module_idle_mode_audit44xx
* @BRIEF module idle mode audit.
* @RETURNS pointer to global pass string in case of successfull
* audit
* pointer to global fail string in case of failing audit
* pointer to global warning string in case of sub-optimal
* configuration
* pointer to global ignore string in case of unavailable
* or internal error
* @param[in] mod_id: module ID
* @param[in,out] mode: module idle mode (returned)
* @param[in,out] mode_por: expected module idle mode (returned)
* @param[in,out] err_nbr: error number (returned)
* @param[in,out] wng_nbr: warning number (returned)
* @DESCRIPTION module idle mode audit.
*//*------------------------------------------------------------------------ */
char *module_idle_mode_audit44xx(mod44xx_id mod_id,
mod_idle_mode *mode, mod_idle_mode *mode_por,
unsigned int *err_nbr, unsigned int *wng_nbr)
{
int ret;
char mod_name[MOD44XX_MAX_NAME_LENGTH];
char *status;
CHECK_CPU(44xx, (char *) ignore);
CHECK_NULL_ARG(mode, (char *) ignore);
CHECK_NULL_ARG(mode_por, (char *) ignore);
CHECK_NULL_ARG(err_nbr, (char *) ignore);
CHECK_NULL_ARG(wng_nbr, (char *) ignore);
*err_nbr = 0;
*wng_nbr = 0;
*mode = MOD_IDLE_MODE_MAX;
*mode_por = MOD_SMART_IDLE;
/* Get module IDLE mode */
ret = mod44xx_get_idle_mode(mod_id, mode);
switch (ret) {
case 1:
break;
case 0:
dprintf(
"%s(): %s disabled. Module registers cannot be audited.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
status = (char *) ignore;
goto module_idle_mode_audit44xx_end;
case OMAPCONF_ERR_NOT_AVAILABLE:
dprintf("%s(): %s has no IDLE bit\n",
__func__, mod44xx_get_name(mod_id, mod_name));
status = (char *) ignore;
goto module_idle_mode_audit44xx_end;
default:
fprintf(stderr,
"omapconf: internal error while checking module %s IDLE mode! (%d)\n",
mod44xx_get_name(mod_id, mod_name), ret);
status = (char *) ignore;
goto module_idle_mode_audit44xx_end;
}
switch (*mode) {
case MOD_SMART_IDLE_WAKEUP:
dprintf(
"%s(): %s IDLE mode correctly configured to SMART-IDLE WAKEUP.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
status = (char *) pass;
goto module_idle_mode_audit44xx_end;
case MOD_SMART_IDLE:
if (mod44xx_has_smart_idle_wakeup_mode(mod_id)) {
dprintf(
"%s(): %s IDLE mode set to SMART-IDLE instead of SMART-IDLE WAKEUP!\n",
__func__, mod44xx_get_name(mod_id, mod_name));
status = (char *) fail;
(*err_nbr)++;
} else {
dprintf(
"%s(): %s IDLE mode correctly configured to SMART-IDLE.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
status = (char *) pass;
}
goto module_idle_mode_audit44xx_end;
case MOD_FORCE_IDLE:
dprintf(
"%s(): %s IDLE mode = FORCE-IDLE instead of SMART-IDLE.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
if (mod_id == OMAP4_SYNCTIMER) {
/* This module has no Smart-Idle mode */
status = (char *) pass;
} else {
status = (char *) warning;
(*wng_nbr)++;
}
goto module_idle_mode_audit44xx_end;
default:
if ((mod_id == OMAP4_UART1) ||
(mod_id == OMAP4_UART2) ||
(mod_id == OMAP4_UART3) ||
(mod_id == OMAP4_UART4)) {
/*
* UART IP idle management is buggy (cf errata).
* When active, must be used in no-idle mode.
*/
status = (char *) pass;
} else {
dprintf(
"%s(): %s IDLE mode not set to SMART-IDLE but %s!\n",
__func__, mod44xx_get_name(mod_id, mod_name),
mod_idle_mode_name_get(*mode));
status = (char *) fail;
(*err_nbr)++;
}
goto module_idle_mode_audit44xx_end;
}
module_idle_mode_audit44xx_end:
return status;
}
#ifdef MODULE_IDLE_MODE_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...)
#endif
/* #define MODULE_STANDBY_MODE_AUDIT44XX_DEBUG */
#ifdef MODULE_STANDBY_MODE_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#endif
/* ------------------------------------------------------------------------*//**
* @FUNCTION module_standby_mode_audit44xx
* @BRIEF module standby mode audit.
* @RETURNS pointer to global pass string in case of successfull
* audit
* pointer to global fail string in case of failing audit
* pointer to global warning string in case of sub-optimal
* configuration
* pointer to global ignore string in case of unavailable
* or internal error
* @param[in] mod_id: module ID
* @param[in,out] mode: module standby mode (returned)
* @param[in,out] mode_por: expected module standby mode (returned)
* @param[in,out] err_nbr: error number (returned)
* @param[in,out] wng_nbr: warning number (returned)
* @DESCRIPTION module standby mode audit.
*//*------------------------------------------------------------------------ */
char *module_standby_mode_audit44xx(mod44xx_id mod_id,
mod_standby_mode *mode, mod_standby_mode *mode_por,
unsigned int *err_nbr, unsigned int *wng_nbr)
{
int ret;
char mod_name[MOD44XX_MAX_NAME_LENGTH];
CHECK_CPU(44xx, (char *) ignore);
CHECK_NULL_ARG(mode, (char *) ignore);
CHECK_NULL_ARG(mode_por, (char *) ignore);
CHECK_NULL_ARG(err_nbr, (char *) ignore);
CHECK_NULL_ARG(wng_nbr, (char *) ignore);
*err_nbr = 0;
*wng_nbr = 0;
*mode = MOD_STANDBY_MODE_MAX;
*mode_por = MOD_SMART_STANDBY;
/* Get module STANDBY mode */
ret = mod44xx_get_standby_mode(mod_id, mode);
switch (ret) {
case 1:
switch (*mode) {
case MOD_SMART_STANDBY:
dprintf(
"%s(): %s STANDBY mode correctly configured to MOD_SMART_STANDBY.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
return (char *) pass;
case MOD_FORCE_STANDBY:
(*wng_nbr)++;
dprintf(
"%s(): %s STANDBY mode = FORCE-IDLE instead of SMART-STANDBY.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
return (char *) warning;
case MOD_STANDBY_MODE_RESERVED:
if (mod_id == OMAP4_FSUSBHOST) {
dprintf(
"%s(): FSUSBHOST STANDBY mode correctly set to SMART-STANDBY WITH WAKEUP\n",
__func__);
return (char *) pass;
} else {
(*err_nbr)++;
#ifdef MODULE_STANDBY_MODE_AUDIT44XX_DEBUG
dprintf(
"%s(): %s STANDBY mode not set to SMART-STANDBY but %s!\n",
__func__,
mod44xx_get_name(mod_id, mod_name),
mod_standby_mode_name_get(*mode));
#endif
return (char *) fail;
}
default:
(*err_nbr)++;
#ifdef MODULE_STANDBY_MODE_AUDIT44XX_DEBUG
dprintf(
"%s(): %s STANDBY mode not set to SMART-STANDBY but %s!\n",
__func__, mod44xx_get_name(mod_id, mod_name),
mod_standby_mode_name_get(*mode));
#endif
return (char *) fail;
}
case 0:
dprintf(
"%s(): %s disabled. Module registers cannot be audited.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
return (char *) ignore;
case OMAPCONF_ERR_NOT_AVAILABLE:
dprintf("%s(): %s has no STANDBY mode\n",
__func__, mod44xx_get_name(mod_id, mod_name));
return (char *) ignore;
default:
fprintf(stderr,
"omapconf: internal error while checking module %s STANDBY mode! (%d)\n",
mod44xx_get_name(mod_id, mod_name), ret);
return (char *) ignore;
}
}
#ifdef MODULE_STANDBY_MODE_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...)
#endif
/* #define MODULE_CLOCKACTIVITY_BIT_AUDIT44XX_DEBUG */
#ifdef MODULE_CLOCKACTIVITY_BIT_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#endif
/* ------------------------------------------------------------------------*//**
* @FUNCTION module_clockactivity_bit_audit44xx
* @BRIEF module clock activity mode audit.
* @RETURNS pointer to global pass string in case of successfull
* audit
* pointer to global fail string in case of failing audit
* pointer to global warning string in case of sub-optimal
* configuration
* pointer to global ignore string in case of unavailable
* or internal error
* @param[in] mod_id: module ID
* @param[in,out] mode: module clock activity mode (returned)
* @param[in,out] mode_por: expected module clock activity mode (returned)
* @param[in,out] err_nbr: error number (returned)
* @param[in,out] wng_nbr: warning number (returned)
* @DESCRIPTION module clock activity mode audit.
*//*------------------------------------------------------------------------ */
char *module_clockactivity_bit_audit44xx(mod44xx_id mod_id,
mod_clock_activity_mode *mode,
mod_clock_activity_mode *mode_por,
unsigned int *err_nbr, unsigned int *wng_nbr)
{
int ret;
char mod_name[MOD44XX_MAX_NAME_LENGTH];
CHECK_CPU(44xx, (char *) ignore);
CHECK_NULL_ARG(mode, (char *) ignore);
CHECK_NULL_ARG(mode_por, (char *) ignore);
CHECK_NULL_ARG(err_nbr, (char *) ignore);
CHECK_NULL_ARG(wng_nbr, (char *) ignore);
*err_nbr = 0;
*wng_nbr = 0;
*mode = MOD_CLOCK_ACTIVITY_MODE_MAX;
*mode_por = MOD_FCLK_AUTO_ICLK_AUTO;
/* Get module CLOCKACTIVITY mode */
ret = mod44xx_get_clock_activity_mode(mod_id, mode);
switch (ret) {
case 1:
switch (*mode) {
case MOD_FCLK_AUTO_ICLK_AUTO:
/*
* Functional clock can be switched-off;
* L4 clock can be switched-off
*/
dprintf(
"%s(): CLOCKACTIVITY bit correctly configured\n",
__func__);
return (char *) pass;
case MOD_FCLK_AUTO_ICLK_ON:
/*
* Functional clock can be switched-off;
* L4 clock is maintained during wake-up period
*/
case MOD_FCLK_ON_ICLK_AUTO:
/*
* Functional clock is maintained during wake-up period;
* L4 clock can be switched-off
*/
(*wng_nbr)++;
#ifdef MODULE_CLOCKACTIVITY_BIT_AUDIT44XX_DEBUG
dprintf("%s(): Warning: %s CLOCKACTIVITY = %s\n",
__func__,
mod44xx_get_name(mod_id, mod_name),
mod_clock_activity_mode_name_get(*mode));
#endif
return (char *) warning;
case MOD_FCLK_ON_ICLK_ON:
/*
* Functional clock is maintained during wake-up period;
* L4 clock is maintained during wake-up period
*/
default:
(*err_nbr)++;
#ifdef MODULE_CLOCKACTIVITY_BIT_AUDIT44XX_DEBUG
dprintf("%s(): Warning: %s CLOCKACTIVITY = %s\n",
__func__,
mod44xx_get_name(mod_id, mod_name),
mod_clock_activity_mode_name_get(*mode));
#endif
return (char *) fail;
}
case 0:
dprintf(
"%s(): %s disabled. Module registers cannot be audited.\n",
__func__, mod44xx_get_name(mod_id, mod_name));
return (char *) ignore;
case OMAPCONF_ERR_NOT_AVAILABLE:
dprintf("%s(): %s has no CLOCKACTIVITY mode\n", __func__,
mod44xx_get_name(mod_id, mod_name));
return (char *) ignore;
default:
fprintf(stderr,
"omapconf: internal error while checking %s CLOCKACTIVITY mode! (%d)\n",
mod44xx_get_name(mod_id, mod_name), ret);
return (char *) ignore;
}
}
#ifdef MODULE_CLOCKACTIVITY_BIT_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...)
#endif
/* ------------------------------------------------------------------------*//**
* @FUNCTION audit44xx_dpll
* @BRIEF audit DPLL Configuration
* @RETURNS 0 in case of success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_NOT_AVAILABLE
* @param[in] stream: output file (NULL: no output (silent))
* @param[in] dpll_id: DPLL ID
* (use DPLL44XX_ID_MAX to audit all DPLLs)
* @param[in] opp_id: OPP ID
* (use OPP44XX_ID_MAX to audit all OPPs)
* @param[in] curr_opp: audit current OPP only (=1) or all OPPs (=0)
* @param[in,out] err_nbr: audit error number
* @param[in,out] wng_nbr: audit warning number
* @DESCRIPTION audit DPLL Configuration
*//*------------------------------------------------------------------------ */
int audit44xx_dpll(FILE *stream, dpll44xx_id dpll_id, opp44xx_id opp_id,
unsigned short curr_opp, unsigned int *err_nbr, unsigned int *wng_nbr)
{
int ret = 0;
char s[256];
char logfilename[256];
FILE *fp;
unsigned int row;
char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
char prev_gov[CPUFREQ_GOV_MAX_NAME_LENGTH] = "";
char prev_gov2[CPUFREQ_GOV_MAX_NAME_LENGTH] = "";
opp44xx_id opp;
double freq_mpu;
unsigned int _err_nbr = 0, _wng_nbr = 0;
CHECK_CPU(44xx, OMAPCONF_ERR_CPU);
CHECK_ARG_LESS_THAN(dpll_id, DPLL44XX_ID_MAX + 1, OMAPCONF_ERR_ARG);
CHECK_ARG_LESS_THAN(opp_id, OPP44XX_ID_MAX + 1, OMAPCONF_ERR_ARG);
CHECK_ARG_LESS_THAN(curr_opp, 2, OMAPCONF_ERR_ARG);
CHECK_NULL_ARG(err_nbr, OMAPCONF_ERR_ARG);
CHECK_NULL_ARG(wng_nbr, OMAPCONF_ERR_ARG);
*err_nbr = 0;
*wng_nbr = 0;
/* Create audit report log file */
strcpy(logfilename, "dpll_audit_report.txt");
fp = workdir_fopen(logfilename, "w+");
if (fp == NULL) {
fprintf(stderr, "Could not create %s file!\n\n", logfilename);
return 0;
}
fprintf(fp,
"OMAPCONF DPLL Configuration Audit Detailed Log:\n\n");
omapconf_revision_show(fp);
chips_info_show(fp, 1);
release_info_show(fp);
if (curr_opp == 1) {
ret = dpll44xx_audit(dpll_id, opp_id, fp, err_nbr, wng_nbr);
if (ret != 0)
goto audit44xx_dpll_end;
ret = dpll44xx_audit(dpll_id, opp_id, stream, err_nbr, wng_nbr);
if (ret != 0)
goto audit44xx_dpll_end;
if (*err_nbr == 0)
sprintf(s, "SUCCESS! DPLL Configuration audit "
"completed with 0 error (%u warning(s))"
".\n\n", *wng_nbr);
else
sprintf(s, "FAILED! DPLL Configuration audit "
"completed with %u error(s) and %u "
"warning(s).\n\n", *err_nbr, *wng_nbr);
if (stream != NULL) {
fprintf(stream, "Audit details saved in %s file.\n\n\n",
logfilename);
fputs(s, stream);
}
fputs(s, fp);
ret = 0;
goto audit44xx_dpll_end;
}
/* Save current governor (will be altered by cpufreq_set() call) */
if (cpufreq_scaling_governor_get(prev_gov) == NULL) {
ret = OMAPCONF_ERR_NOT_AVAILABLE;
goto audit44xx_dpll_end;
}
/* Retrieve number of available MPU OPPs */
if (cpufreq_opp_nbr_get() == 0) {
ret = OMAPCONF_ERR_NOT_AVAILABLE;
goto audit44xx_dpll_end;
}
row = 0;
autoadjust_table_init(table);
snprintf(table[row][0], TABLE_MAX_ELT_LEN,
"DPLL Configuration AUDIT Summary");
autoadjust_table_strncpy(table, row, 1, "Audit STATUS");
row++;
for (opp = OMAP4_OPP50; (unsigned int) opp <= cpufreq_opp_nbr_get();
opp++) {
_err_nbr = 0;
_wng_nbr = 0;
/* Set MPU OPP */
ret = mod44xx_get_por_clk_speed(OMAP4_MPU, opp, &freq_mpu);
if (ret != 0) {
err_internal_msg_show();
goto audit44xx_dpll_end;
}
ret = cpufreq_set((unsigned int) (freq_mpu * 1000));
if (ret != 0) {
err_internal_msg_show();
goto audit44xx_dpll_end;
}
fprintf(fp, "DPLLs Configuration Audit at MPU %s:\n\n",
opp44xx_name_get(opp, OMAP4_VDD_MPU));
snprintf(table[row][0], TABLE_MAX_ELT_LEN, "At MPU %s",
opp44xx_name_get(opp, OMAP4_VDD_MPU));
/* Run audit at this OPP */
ret = dpll44xx_audit(dpll_id, OPP44XX_ID_MAX, fp,
&_err_nbr, &_wng_nbr);
if (ret != 0) {
err_internal_msg_show();
goto audit44xx_dpll_end;
}
if (_err_nbr == 0)
snprintf(table[row][1], TABLE_MAX_ELT_LEN,
"PASS (0 error, %u warning(s))", _wng_nbr);
else
snprintf(table[row][1], TABLE_MAX_ELT_LEN,
"FAIL (%u error, %u warning(s))",
_err_nbr, _wng_nbr);
(*err_nbr) += _err_nbr;
(*wng_nbr) += _wng_nbr;
row++;
fprintf(fp, "\n\n\n");
}
/* Report final audit status */
autoadjust_table_fprint(fp, table, row, 2);
sprintf(s, "NB: DPLL IVA may not have been audited accross all "
"IVA OPPs (no kernel interface to control IVA OPP "
"available).\n\n");
fputs(s, fp);
if (stream != NULL) {
autoadjust_table_fprint(stream, table, row, 2);
fputs(s, stream);
}
if (*err_nbr == 0)
sprintf(s, "\nSUCCESS! DPLLs Configuration "
"audit completed with 0 error (%u warning(s))"
".\n\n\n", *wng_nbr);
else
sprintf(s, "\nFAILED! DPLLs Configuration "
"audit completed with %u error(s) and %u "
"warning(s).\n\n\n", *err_nbr, *wng_nbr);
fputs(s, fp);
if (stream != NULL) {
fprintf(stream, "DPLLs Configuration audit details saved "
"in %s file.\n", logfilename);
fputs(s, stream);
}
audit44xx_dpll_end:
/* Restore CPUFreq governor */
if (strlen(prev_gov) != 0)
cpufreq_scaling_governor_set(prev_gov, prev_gov2);
/* Close opened file */
if (fp != NULL)
fclose(fp);
return ret;
}
/* ------------------------------------------------------------------------*//**
* @FUNCTION audit44xx_dpll_main
* @BRIEF analyze command-line arguments & call DPLL audit with
* selected options.
* @RETURNS 0 on success
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_ARG
* OMAPCONF_ERR_INTERNAL
* OMAPCONF_ERR_NOT_AVAILABLE
* @param[in] argc: shell input argument number
* @param[in] argv: shell input argument(s)
* @DESCRIPTION analyze command-line arguments & call DPLL audit with
* selected options.
*//*------------------------------------------------------------------------ */
int audit44xx_dpll_main(int argc, char *argv[])
{
int ret = 0;
dpll44xx_id dpll_id;
opp44xx_id opp_id;
unsigned int err_nbr = 0, wng_nbr = 0;
unsigned short pos_opp_id, pos_dpll_id, curr_opp;
CHECK_CPU(44xx, OMAPCONF_ERR_CPU);
CHECK_NULL_ARG(argv, OMAPCONF_ERR_ARG);
/* Retrieve user options */
dprintf("%s(): argc=%u\n", __func__, argc);
#ifdef AUDIT44XX_DEBUG
for (curr_opp = 0; curr_opp < argc; curr_opp++) {
dprintf("%s(): argv[%u]=%s\n", __func__,
curr_opp, argv[curr_opp]);
}
#endif
if (argc == 0) {
/* Audit all DPLLs at current OPP by default */
dpll_id = DPLL44XX_ID_MAX;
opp_id = OPP44XX_ID_MAX;
curr_opp = 1;
goto audit44xx_dpll_audit;
} else if (argc == 2) {
if (strcmp(argv[0], "-d") == 0) {
opp_id = OPP44XX_ID_MAX;
curr_opp = 1;
dpll_id = dpll44xx_s2id(argv[1]);
if (dpll_id == DPLL44XX_ID_MAX) {
if (strcmp(argv[1], "all") == 0)
dpll_id = DPLL44XX_ID_MAX;
else
goto audit44xx_dpll_err_arg;
}
goto audit44xx_dpll_audit;
} else if (strcmp(argv[0], "-o") == 0) {
dpll_id = DPLL44XX_ID_MAX;
curr_opp = 1;
opp_id = opp44xx_s2id(argv[1]);
if (opp_id == OPP44XX_ID_MAX) {
if (strcmp(argv[1], "all") == 0) {
opp_id = OPP44XX_ID_MAX;
curr_opp = 0;
} else {
goto audit44xx_dpll_err_arg;
}
}
goto audit44xx_dpll_audit;
} else {
goto audit44xx_dpll_err_arg;
}
} else if (argc == 4) {
curr_opp = 1;
if (strcmp(argv[0], "-d") == 0)
pos_dpll_id = 1;
else if (strcmp(argv[2], "-d") == 0)
pos_dpll_id = 3;
else
goto audit44xx_dpll_err_arg;
dpll_id = dpll44xx_s2id(argv[pos_dpll_id]);
if (dpll_id == DPLL44XX_ID_MAX) {
if (strcmp(argv[pos_dpll_id], "all") == 0)
dpll_id = DPLL44XX_ID_MAX;
else
goto audit44xx_dpll_err_arg;
}
if (strcmp(argv[0], "-o") == 0)
pos_opp_id = 1;
else if (strcmp(argv[2], "-o") == 0)
pos_opp_id = 3;
else
goto audit44xx_dpll_err_arg;
opp_id = opp44xx_s2id(argv[pos_opp_id]);
if (opp_id == OPP44XX_ID_MAX) {
if (strcmp(argv[pos_opp_id], "all") == 0) {
opp_id = OPP44XX_ID_MAX;
curr_opp = 0;
} else {
goto audit44xx_dpll_err_arg;
}
}
goto audit44xx_dpll_audit;
} else {
goto audit44xx_dpll_err_arg;
}
audit44xx_dpll_audit:
dprintf("%s(): dpll_id=%s, opp_id=%s curr_opp=%u\n", __func__,
dpll44xx_name_get(dpll_id),
opp44xx_name_get(opp_id, OMAP4_VDD_MPU), curr_opp);
ret = audit44xx_dpll(stdout, dpll_id, opp_id, curr_opp,
&err_nbr, &wng_nbr);
goto audit44xx_dpll_end;
audit44xx_dpll_err_arg:
help(HELP_AUDIT);
ret = OMAPCONF_ERR_ARG;
audit44xx_dpll_end:
return ret;
}
/* #define SYSCONFIG_AUDIT44XX_DEBUG */
#ifdef SYSCONFIG_AUDIT44XX_DEBUG
#undef dprintf
#define dprintf(format, ...) printf(format, ## __VA_ARGS__)
#endif
/* ------------------------------------------------------------------------*//**
* @FUNCTION sysconfig_audit44xx
* @BRIEF OMAP4 SYSCONFIG registers audit.
* @RETURNS 0 in case of success
* OMAPCONF_ERR_REG_ACCESS
* OMAPCONF_ERR_CPU
* OMAPCONF_ERR_INTERNAL
* @param[in,out] stream: output file - NULL: no output (silent)
* @param[in,out] err_nbr: pointer to return audit error number
* @param[in,out] wng_nbr: pointer to return audit warning number
* @DESCRIPTION OMAP4 SYSCONFIG registers audit.
*//*------------------------------------------------------------------------ */
int sysconfig_audit44xx(FILE *stream, unsigned int *err_nbr,
unsigned int *wng_nbr)
{
mod44xx_id i;
mod_autoidle_mode autoidle_mode, autoidle_mode_por;
mod_idle_mode idle_mode, idle_mode_por;
mod_interface_type type;
mod_standby_mode standby_mode, standby_mode_por;
mod_clock_activity_mode clock_activity_mode,
clock_activity_mode_por;
char *status;
unsigned int err_nbr_tmp = 0, wng_nbr_tmp = 0;
char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
unsigned int row;
char mod_name[MOD44XX_MAX_NAME_LENGTH];
CHECK_CPU(44xx, OMAPCONF_ERR_CPU);
CHECK_NULL_ARG(err_nbr, OMAPCONF_ERR_ARG);
CHECK_NULL_ARG(wng_nbr, OMAPCONF_ERR_ARG);
*err_nbr = 0;
*wng_nbr = 0;
autoadjust_table_init(table);
row = 0;
strncpy(table[row][0], "MODULES SYSCONFIG AUDIT", TABLE_MAX_ELT_LEN);
strncpy(table[row][1], "AUTOIDLE", TABLE_MAX_ELT_LEN);
strncpy(table[row][2], "IDLE", TABLE_MAX_ELT_LEN);
strncpy(table[row][3], "STANDBY", TABLE_MAX_ELT_LEN);
strncpy(table[row][4], "CLOCKACTIVITY", TABLE_MAX_ELT_LEN);
row++;
for (i = 0; i < OMAP4_MODULE_ID_MAX; i++) {
dprintf("\n%s(): Module #%d name = %s\n", __func__,
i, mod44xx_get_name(i, mod_name));
switch (i) {
case OMAP4_CRYPTODMA:
case OMAP4_AES1:
case OMAP4_AES2:
case OMAP4_SHA2MD5_1:
case OMAP4_RNG:
case OMAP4_DES3DES:
case OMAP4_PKAEIP29:
case OMAP4_USIM:
case OMAP4_WDT1:
case OMAP4_TIMER12:
case OMAP4_CUST_EFUSE:
/*
* Secure Modules, not accessible on HS,
* not referenced on GP
*/
dprintf("\tSecure Modules (not accessible (HS) / not "
"referenced (GP)\n");
continue;
case OMAP4_ICONT1:
case OMAP4_ICONT2:
case OMAP4_VDMA:
case OMAP4_IME3:
case OMAP4_IPE3:
case OMAP4_ILF3:
case OMAP4_MC3:
case OMAP4_CALC3:
case OMAP4_ECD3:
case OMAP4_ICONT1_SB:
case OMAP4_ICONT2_SB:
case OMAP4_ILF3_SB:
case OMAP4_IME3_SB:
case OMAP4_CALC3_SB:
case OMAP4_IPE3_SB:
case OMAP4_MC3_SB:
case OMAP4_ECD3_SB:
case OMAP4_SIMCOP:
case OMAP4_SIMCOP_DMA:
case OMAP4_SIMCOP_DCT:
case OMAP4_SIMCOP_VLCDJ:
case OMAP4_SIMCOP_ROT:
case OMAP4_MPU_M3:
/*
* These are HW accelerators IP. During AV record,
* modules are changing state quicker than omapconf
* code, causing from time to time incorrect access to
* a disabled module (i.e. bus error).
* Workaround: skip these internal HW IPs.
*/
dprintf("\tHW accelerators IP, skipped.\n");
continue;
case OMAP4_DISPC:
/* With clock autogating enabled, DISPC I-CLK is getting
* gated at such high pace (bursts) that there is a
* probability of bus error */
dprintf("\tDISPC, skipped.\n");
continue;
case OMAP4_BB2D:
if (!cpu_is_omap4470())
continue;
else
goto sysconfig_audit44xx_default;
case OMAP4_FSUSBHOST:
if (cpu_is_omap4470())
continue;
else
goto sysconfig_audit44xx_default;
sysconfig_audit44xx_default:
default:
/* Get module interface type */
mod44xx_get_interface_type(i, &type);
if (type == MOD_INTERFACE_NONE) {
dprintf("\tNo SYSCONFIG register to audit.\n");
continue;
}
/* Check if module is accessible */
if (mod44xx_is_accessible(i) != 1) {
snprintf(table[row][0], TABLE_MAX_ELT_LEN,
"%s", mod44xx_get_name(i, mod_name));
snprintf(table[row][1], TABLE_MAX_ELT_LEN,
"NA");
snprintf(table[row][2], TABLE_MAX_ELT_LEN,
"NA");
snprintf(table[row][3], TABLE_MAX_ELT_LEN,
"NA");
snprintf(table[row][4], TABLE_MAX_ELT_LEN,
"NA");
row++;
dprintf("\tModule is not accessible.\n");
continue;
}
snprintf(table[row][0], TABLE_MAX_ELT_LEN,
"%s", mod44xx_get_name(i, mod_name));
/* Audit module's autoidle bit */
status = module_autoidle_mode_audit44xx(i,
&autoidle_mode, &autoidle_mode_por,
&err_nbr_tmp, &wng_nbr_tmp);
if (status == pass) {
strncpy(table[row][1], status,
TABLE_MAX_ELT_LEN);
} else if ((i == OMAP4_ICR_MDM) ||
(i == OMAP4_ICR_MPU)) {
/* by default no C2C driver */
status = (char *) warning;
(*wng_nbr)++;
snprintf(table[row][1], TABLE_MAX_ELT_LEN,
"Warning (%s)",
mod_autoidle_mode_name_get(
autoidle_mode));
} else if (status == fail) {
(*err_nbr)++;
strncpy(table[row][1], status,
TABLE_MAX_ELT_LEN);
} /* else do nothing in case of status == ignore */
dprintf("\tAutoidle audit: mode=%s, status=%s\n",
mod_autoidle_mode_name_get(autoidle_mode),
status);
dprintf("\t\tTotal error number=%u, total warning "
"number=%u\n", *err_nbr, *wng_nbr);
/* Audit module's IDLE mode */
status = module_idle_mode_audit44xx(i,
&idle_mode, &idle_mode_por,
&err_nbr_tmp, &wng_nbr_tmp);
if (status == pass) {
strncpy(table[row][2], status,
TABLE_MAX_ELT_LEN);
} else if (status == warning) {
(*wng_nbr)++;
snprintf(table[row][2], TABLE_MAX_ELT_LEN,