summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/occ/occ_procedures/p8_pba_init.C
blob: aa1b4dd8c28599cca73910762a46fa8018b3cc7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/occ/occ_procedures/p8_pba_init.C $           */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013                   */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
// $Id: p8_pba_init.C,v 1.11 2013/04/01 04:11:57 stillgs Exp $
// $Source: /afs/awd/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/p8_pba_init.C,v $
//------------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2011
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
//------------------------------------------------------------------------------
// *! OWNER NAME: Klaus P. Gungl         Email: kgungl@de.ibm.com
// *!  
// *! 
/// \file p8_pba_init.C
/// \brief Initialize PBA registers for modes PM_INIT, PM_RESET and PM_CONFIG 
// *!        
// *! Functional description: setup the PBA registers depending on mode
// *!   calling parameters:   
// *! :   Target i_target  // target according to calling conventions
// *!     uint64_t mode    // mode according to power_up spec: PM_CONFIG, PM_INIT, PM_RESET
// *! 
// *! high level flow:
// *!  if (mode == PM_CONFIG) { 
// *!      rc =  p8_pba_init_PM_CONFIG(i_target); 
// *!   } else {
// *!       if (mode == PM_INIT) { 
// *!          rc =  p8_pba_init_PM_INIT(i_target); 
// *!       } else { 
// *!          if (mode == PM_RESET) { 
// *!             rc =  p8_pba_init_PM_RESET(i_target); 
// *!          } else {
// *!             FAPI_SET_HWP_ERROR(rc,RC_P8_PBA_INIT_INCORRECT_MODE);
// *!          }  
// *!       }
// *!    } // endif
// *! } // endif  
// *!  
// *!  
// *! list of changes
// *! 2012/10/11 applied changes and error corrections according to Terry Opie and reformatting if-else
// *! 2012/10/11 applied changes according to Terry Opie
// *! 2012/07/26 applied the changes as recommended by Greg's second review, pbax attributes included, 
// *! 2012/07/18 applied the changes as recommended by Greg, attribute coding, TODO: correct constants
// *! 2012/05/09 global variables removed, "mode" used according to common rules.  
// *! 2012/05/17 temporary commented out the accesses assumed wrong address   
// *!
//------------------------------------------------------------------------------

    
// ----------------------------------------------------------------------
// Includes
// ----------------------------------------------------------------------
#include <fapi.H>
#include "p8_scom_addresses.H"
#include "p8_pba_init.H"
#include "p8_pm.H"

// get the constants from here
#include "pgp_pba.h"
#include "pgp_common.h" 
  
extern "C" {
 
using namespace fapi;  

// ----------------------------------------------------------------------
// Constant definitions
// ----------------------------------------------------------------------


// ----------------------------------------------------------------------
// Global variables
// ----------------------------------------------------------------------
// mandated: do not use global variables

// ----------------------------------------------------------------------
// local Function definitions / prototypes
// ----------------------------------------------------------
fapi::ReturnCode p8_pba_init_PM_CONFIG ( const Target& i_target );
fapi::ReturnCode p8_pba_init_PM_INIT ( const Target& i_target );
fapi::ReturnCode p8_pba_init_PM_RESET ( const Target& i_target );

fapi::ReturnCode pba_slave_setup_init ( const Target& i_target );
fapi::ReturnCode pba_slave_setup_reset ( const Target& i_target );
fapi::ReturnCode pba_slave_reset(const Target& i_target);

// from pgp_pba.h
//int pba_slave_reset(int id);


// **********************************************************************************************
// ----------------------------------------------- p8_pba_init --------------------------------
// function: 
// set the pba registers depending on "mode", no default mode
// returns: fapi return codes
fapi::ReturnCode
p8_pba_init(const Target& i_target, 
                uint64_t mode
             )
{
    fapi::ReturnCode rc;
    // calling the selected function from here
 
    if (mode == PM_CONFIG) 
    { 
       rc =  p8_pba_init_PM_CONFIG(i_target); 
    } 
    else if (mode == PM_INIT) 
    { 
       rc =  p8_pba_init_PM_INIT(i_target); 
    } 
    else if (mode == PM_RESET) 
    { 
       rc =  p8_pba_init_PM_RESET(i_target); 
    }
    else 
    {
      FAPI_ERR("Unknown mode passed to p8_pba_init. Mode %08llx ", mode);      
      FAPI_SET_HWP_ERROR(rc,RC_P8_PBA_INIT_INCORRECT_MODE);
    } // endif


    return rc;
}

// **********************************************************************************************
 // ******************************************************** mode = PM_RESET ********************

fapi::ReturnCode
p8_pba_init_PM_RESET(const Target& i_target)
{

    fapi::ReturnCode rc;
    ecmdDataBufferBase data(64);
    uint32_t l_rc;              // local returncode

    do
    {
        
        // Reset each slave and wait for completion.
        rc =  pba_slave_reset(i_target);
        if (rc) 
        {  
             FAPI_ERR("pba_slave_reset failed."); 
             break; 
        }
        
           
        FAPI_INF("mode = PM_RESET...");
        l_rc =  data.setDoubleWord(0, 0x0);
        if (l_rc) 
        { 
            FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc);
            rc.setEcmdError(l_rc); 
            break;    
        } // end if


        // For reset phase, write these with 0x0
        // No content for config or init phase as all initialization is done by OCC FW   
        rc = fapiPutScom(i_target, PBA_BCDE_CTL_0x00064010 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom(PBA_BCDE_CTL_0x00064010  ) failed. With rc = 0x%x", (uint32_t)rc);
            break; 
        }

        rc = fapiPutScom(i_target, PBA_BCDE_SET_0x00064011 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_BCDE_SET_0x00064011 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        } 

        rc = fapiPutScom(i_target, PBA_BCDE_STAT_0x00064012 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_BCDE_STAT_0x00064012 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_BCDE_PBADR_0x00064013 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_BCDE_PBADR_0x00064013 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_BCDE_OCIBAR_0x00064014 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_BCDE_OCIBAR_0x00064014 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_BCUE_CTL_0x00064015 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_BCUE_CTL_0x0006401 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_BCUE_SET_0x00064016 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_BCUE_SET_0x00064016 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_BCUE_STAT_0x00064017 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom(PBA_BCUE_STAT_0x00064017  ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_BCUE_PBADR_0x00064018 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom(PBA_BCUE_PBADR_0x00064018  ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_BCUE_OCIBAR_0x00064019 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_BCUE_OCIBAR_0x00064019  ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        // For reset, written with 0x0s to restore to fresh value.
        rc = fapiPutScom(i_target, PBA_SLVCTL0_0x00064004 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_SLVCTL0_0x00064004 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_SLVCTL1_0x00064005 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_SLVCTL1_0x00064005 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        rc = fapiPutScom(i_target, PBA_SLVCTL2_0x00064006 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom(  PBA_SLVCTL2_0x00064006 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        } 

        rc = fapiPutScom(i_target, PBA_SLVCTL3_0x00064007 , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_SLVCTL3_0x00064007 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        } 

        // Clear the PBA FIR (Reset) only
        l_rc = data.setDoubleWord(0, 0x0);
        if (l_rc) 
        { 
            FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc); 
            rc.setEcmdError(l_rc); 
            break;    
        }   // end if
        
        rc = fapiPutScom(i_target, PBA_FIR_0x02010840   , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_FIR_0x02010840 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        // For reset, this register should be written with the value from figtree
        // to restore the initial hardware state.  Therefore fix this constant.
        // For init, needs detailing for performance and/or CHSW enable/disable
        // reset case
        // data still 0
        rc = fapiPutScom(i_target, PBA_CONFIG_0x0201084B  , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_CONFIG_0x0201084B  ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        // pba slave register handling for PM_RESET
        rc = pba_slave_setup_reset(i_target);
        if (rc) 
        {  
            FAPI_ERR("pba_slave_setup_reset failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        // For reset, written with 0x0s to restore to fresh value.
        rc = fapiPutScom(i_target, PBA_ERR_RPT0_0x0201084C  , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_ERR_RPT0_0x0201084C ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        // the following operations are not required, keep this in mind, don't erase them here
        //    l_rc = fapiPutScom(i_target, PBA_ERR_RPT1_0x0201084D  , data);
        //    if(l_rc) { FAPI_SET_HWP_ERROR(l_rc, RC_PROC_PBA_INIT_PUTSCOM_FAILED); return l_rc; }
        //      else {FAPI_INF("Done with PBA_ERR_RPT1_0x0201084D  \n ") };

        //    l_rc = fapiPutScom(i_target, PBA_ERR_RPT2_0x0201084E   , data);
        //     if(l_rc) { FAPI_SET_HWP_ERROR(l_rc, RC_PROC_PBA_INIT_PUTSCOM_FAILED); return l_rc; }
        //       else {FAPI_INF("Done with PBA_ERR_RPT2_0x0201084E  \n ") };


        // The following apply to Reset mode
        rc = fapiPutScom(i_target, PBA_SLVRST_0x00064001 , data);
        if (rc) 
        {  
             FAPI_ERR("fapiPutScom( PBA_SLVRST_0x00064001 ) failed. With rc = 0x%x", (uint32_t)rc); 
             break; 
        } 

        // last step: pba slave setup for reset
        rc = pba_slave_setup_reset (i_target);
        if (rc) 
        {  
             FAPI_ERR("fapi pba_slave_setup_reset failed. With rc = 0x%x", (uint32_t)rc); 
             break; 
        }
    } while(0);
     
    return rc;

 } // endif (mode == PM_RESET)
  

  
// ***********************************************************************************************
// ************************************************************ mode = PM_INIT *******************
// call pba_slave_setup
fapi::ReturnCode
p8_pba_init_PM_INIT(const Target& i_target)
{

    fapi::ReturnCode rc;
    ecmdDataBufferBase data(64);
    uint32_t l_rc;              // local returncode

    uint8_t ATTR_PM_PBAX_RCV_RESERV_TIMEOUT_value = 0 ;
    uint8_t ATTR_PM_PBAX_SND_RETRY_COUNT_OVERCOMMIT_ENABLE_value = 0 ;
    uint8_t ATTR_PM_PBAX_SND_RETRY_THRESHOLD_value = 0 ;
    uint8_t ATTR_PM_PBAX_SND_RESERV_TIMEOUT_value = 0 ;

    pbaxcfg_t pbaxcfg_setup ;
    pbaxcfg_setup.value = 0;
    do
    {
        // if (mode == PM_INIT) {
        FAPI_INF("mode = PM_INIT...");
        l_rc =  data.setDoubleWord(0, 0x0);
        if (l_rc) 
        { 
            FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc);  
            rc.setEcmdError(l_rc); 
            break;    
        } // end if  

        // For reset, this register should be written with the value from figtree to restore the
        // initial hardware state.
        // For init, needs detailing for performance and/or CHSW enable/disable TODO
        // init case
	        FAPI_INF("flusing PBA_CONFIG register ");

        rc = fapiPutScom(i_target, PBA_CONFIG_0x0201084B  , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_CONFIG_0x0201084B ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        // Clear the PBA FIR (Reset) only
        // data still 0
	        FAPI_INF("flusing PBA_FIR register ");
        rc = fapiPutScom(i_target, PBA_FIR_0x02010840   , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom( PBA_FIR_0x02010840 ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        // The following registers are ROX, hence need not be touched:
        // PBA_RBUFVAL0_0x02010850
        // PBA_RBUFVAL1_0x02010851
        // PBA_RBUFVAL2_0x02010852
        // PBA_RBUFVAL3_0x02010853
        // PBA_RBUFVAL4_0x02010854
        // PBA_RBUFVAL5_0x02010855
        // PBA_WBUFVAL0_0x02010858
        // PBA_WBUFVAL1_0x02010859

        // These PowerBus Overcommit regs are read-only, therefore no action required:
        // PBA_PBOCR0_0x00064020
        // PBA_PBOCR1_0x00064021
        // PBA_PBOCR2_0x00064022
        // PBA_PBOCR3_0x00064023
        // PBA_PBOCR4_0x00064024
        // PBA_PBOCR5_0x0006402

        // The PBA BARs and their associated Masks are done outside of this FAPI set.  Thus, during
        // a reset, the BARS/MASKS are retained. this applies to
        // PBA_BAR0_0x02013F00
        // PBA_BARMSK0_0x02013F04
        // PBA_BARMSK1_0x02013F05
        // PBA_BAR1_0x02013F01
        // PBA_BAR2_0x02013F02
        // PBA_BAR3_0x02013F03
        // PBA_TRUSTMODE_0x02013F08   

        // any checkreads => NO
        
        rc = FAPI_ATTR_GET ( ATTR_PM_PBAX_RCV_RESERV_TIMEOUT   , &i_target, ATTR_PM_PBAX_RCV_RESERV_TIMEOUT_value  );
        if (rc) 
        {  
            FAPI_ERR("fapi_attr_get( ATTR_PM_PBAX_RCV_RESERV_TIMEOUT ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        } // end if

        rc = FAPI_ATTR_GET ( ATTR_PM_PBAX_SND_RETRY_COUNT_OVERCOMMIT_ENABLE , &i_target, ATTR_PM_PBAX_SND_RETRY_COUNT_OVERCOMMIT_ENABLE_value );
        if (rc) 
        {  
            FAPI_ERR("fapi_attr_get( ATTR_PM_PBAX_SND_RETRY_COUNT_OVERCOMMIT_ENABLE ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        } // end if

        rc = FAPI_ATTR_GET ( ATTR_PM_PBAX_SND_RETRY_THRESHOLD , &i_target, ATTR_PM_PBAX_SND_RETRY_THRESHOLD_value  ); 
        if (rc) 
        {  
            FAPI_ERR("fapi_attr_get( ATTR_PM_PBAX_SND_RETRY_THRESHOLD ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        } // end if

        rc = FAPI_ATTR_GET ( ATTR_PM_PBAX_SND_RESERV_TIMEOUT  , &i_target, ATTR_PM_PBAX_SND_RESERV_TIMEOUT_value ); 
        if (rc) 
        {  
            FAPI_ERR("fapi_attr_get( ATTR_PM_PBAX_SND_RESERV_TIMEOUT ) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        } // end if
        
        
        
        // assemble the attributes
        // 20:24, ATTR_PM_PBAX_RCV_RESERV_TIMEOUT_value
        // 27; ATTR_PM_PBAX_SND_RETRY_COUNT_OVERCOMMIT_ENABLE_value
        // 28:35; ATTR_PM_PBAX_SND_RETRY_THRESHOLD_value
        // 36:40  ATTR_PM_PBAX_SND_RESERV_TIMEOUT_value
        pbaxcfg_setup.fields.ATTR_PM_PBAX_RCV_RESERV_TIMEOUT = ATTR_PM_PBAX_RCV_RESERV_TIMEOUT_value;
        pbaxcfg_setup.fields.ATTR_PM_PBAX_SND_RETRY_COUNT_OVERCOMMIT_ENABLE = ATTR_PM_PBAX_SND_RETRY_COUNT_OVERCOMMIT_ENABLE_value;
        pbaxcfg_setup.fields.ATTR_PM_PBAX_SND_RETRY_THRESHOLD = ATTR_PM_PBAX_SND_RETRY_THRESHOLD_value;
        pbaxcfg_setup.fields.ATTR_PM_PBAX_SND_RESERV_TIMEOUT = ATTR_PM_PBAX_SND_RESERV_TIMEOUT_value;

        // put the attribute values into PBAXCFG
        l_rc = data.setDoubleWord(0, pbaxcfg_setup.value); 
        if (l_rc) 
        { 
            FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc); 
            rc.setEcmdError(l_rc); 
            break;    
        }  // end if

        rc = fapiPutScom(i_target, PBAXCFG_00064021   , data);
        if (rc) 
        {  
            FAPI_ERR("fapiPutScom(PBAXCFG_00064021) failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }

        // last step: pba slave setup for init
        rc = pba_slave_setup_init (i_target);
        if (rc) 
        {  
            FAPI_ERR("fapi pba_slave_setup_init failed. With rc = 0x%x", (uint32_t)rc); 
            break; 
        }
    } while(0);

    return rc;

} // end PM_INIT

  
// *************************************************************************************************
// ************************************************************* mode = PM_CONFIG ******************
//  
/// Configuration:  perform translation of any Platform Attributes into
/// Feature Attributes that are applied during Initalization of PBAX
fapi::ReturnCode
p8_pba_init_PM_CONFIG(const Target& i_target)
{
    fapi::ReturnCode rc;
    ecmdDataBufferBase data(64);
    uint32_t l_rc;              // local returncode
    FAPI_INF("mode = PM_CONFIG...");
    l_rc = data.setDoubleWord(0, 0x0);
    if (l_rc) 
    { 
        FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc); 
        rc.setEcmdError(l_rc); 
        return rc; 
    }   

    FAPI_INF("PBAX configuration...");
    FAPI_INF("Getting PBAX configuration values via attribute settings."); 
 
 return rc;
}; 


// ************************************************************************************************
// **************************************************** pba_slave_setup ***************************
/// PgP PBA Setup
///
/// The PBA is 'set up' twice. The first set up is via scan-0 settings or
/// SBE-IPL code to enable the Host Boot image to be injected into the cache
/// of the IPL core.
///
/// This procedure documents the second setup that will normally be done by a
/// FAPI procedure prior to releasing the OCC from reset.  This setup serves
/// both for the initial boot of OCC as well as for the OCC (GPE), SLW and FSP
/// runtime.  This procedure documents how the PBA should be set up the second
/// time.
///
/// PBA slave 0 is reserved to the GPE engines, which must be able to switch
/// modes to read from mainstore or Centaur inband SCOM spaces, and write
/// Centaur inband SCOMs and also write into mainstore using IMA to support
/// the Power Proxy Trace application.
///
/// PBA slave 1 is dedicated to the 405 ICU/DCU. This PBA slave is used for
/// the initial boot, and for the initial runtime code that manages the OCC
/// applet table.  Once OCC has initialzied applets, OCC FW will remove all
/// TLB mappings associated with mainstore, effectively disabling this slave.
///
/// PBA Slave 2 is dedicated to the PORE-SLW.  Since 24x7 performance
/// monitoring code now runs on PORE-SLW, the PORE-SLW is no longer a
/// read-only master, but instead serves as a generic read-write master like
/// all of the others.
///
/// PBA Slave 3 is mapped to the OCB in order to service FSP direct read/write
/// of mainstore.
///
/// The design of PBA allows read buffers to be dedicated to a particular
/// slave, and requires that a slave have a dedicated read buffer in order to
/// do aggressive prefetching. In the end there is little reason to partition
/// the resources.  The PORE-SLW will be running multiple applications that
/// read and write main memory so we want to allow PORE-SLW access to all
/// resources.  It also isn't clear that aggressive prefetching provides any
/// performacne boost. Another wrinkle is that the BCDE claims read buffer C
/// whenever it runs, and the 405 I + D sides never run after the initial OCC
/// startup. For these reasons all slaves are programmed to share all
/// resources.
///
/// \bug Need to disable slave prefetch for now for all shared buffers until a
/// mode bit gets added too the PBA logic.
///
/// \bug The dis_slvmatch_order bit is going away

fapi::ReturnCode
pba_slave_setup_init(const Target& i_target)
{
    pba_mode_t pm;
    pba_slvctln_t ps;
    fapi::ReturnCode rc;
    uint32_t l_rc;              // local returncode
    ecmdDataBufferBase data(64);

    // Set the PBA_MODECTL register. It's not yet clear how PBA BCE
    // transaction size will affect performance - for now we go with the
    // largest size.  The HTM marker space is enabled and configured. Slave
    // fairness is enabled. The setting 'dis_slvmatch_order' ensures that PBA
    // will correctly flush write data before allowing a read of the same
    // address from a different master on a different slave.  The second write
    // buffer is enabled.
    // prepare the value to be set:
    pm.value = 0;
    pm.fields.pba_region = PBA_OCI_REGION;
    pm.fields.bcde_ocitrans = PBA_BCE_OCI_TRANSACTION_64_BYTES;
    pm.fields.bcue_ocitrans = PBA_BCE_OCI_TRANSACTION_64_BYTES;
    pm.fields.en_marker_ack = 1; 
    pm.fields.oci_marker_space = (PBA_OCI_MARKER_BASE >> 16) & 0x7;
    pm.fields.en_slave_fairness = 1; 
    pm.fields.dis_slvmatch_order = 1; 
    pm.fields.en_second_wrbuf = 1;

    l_rc = data.setDoubleWord(0, pm.value);
    if (l_rc) 
    { 
       FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc);   
       rc.setEcmdError(l_rc); 
       return rc;    
    }

    // write the prepared value
    rc = fapiPutScom(i_target, PBA_MODE_0x00064000 , data);
    if (rc) 
    {  
       FAPI_ERR("fapiPutScom( PBA_MODE_0x00064000 ) failed. With rc = 0x%x", (uint32_t)rc); 
       return rc; 
    } 

    // Slave 0 (PORE-GPE).  This is a read/write slave. We only do 'static'
    // setup here. Dynamic setup will be done by each GPE program that needs
    // to access mainstore, before issuing any trasactions targeting the PBA
    // bridge.  

    //   pba_slave_reset(PBA_SLAVE_PORE_GPE);
    ps.value = 0;
    ps.fields.enable = 1;
    ps.fields.mid_match_value = OCI_MASTER_ID_PORE_GPE;
    ps.fields.mid_care_mask = 0x7;
    ps.fields.buf_alloc_a = 1;
    ps.fields.buf_alloc_b = 1;
    ps.fields.buf_alloc_c = 1;
    ps.fields.buf_alloc_w = 1;
    l_rc = data.setDoubleWord(0, ps.value);
    if (l_rc) 
    { 
       FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc);   rc.setEcmdError(l_rc); 
       return rc;    
    } // end if  
    
    rc = fapiPutScom(i_target, PBA_SLVCTL0_0x00064004 , data);
    if (rc) 
    {  
       FAPI_ERR("fapiPutScom( PBA_SLVCTL0_0x00064004 ) failed. With rc = 0x%x", (uint32_t)rc); 
       return rc; 
    } 

    // Slave 1 (405 ICU/DCU).  This is a read/write slave.  Write gethering is
    // allowed, but with the shortest possible timeout. This slave is
    // effectively disabled soon after IPL.

    //    pba_slave_reset(PBA_SLAVE_OCC);
    ps.value = 0;
    ps.fields.enable = 1;
    ps.fields.mid_match_value = OCI_MASTER_ID_OCC_ICU & OCI_MASTER_ID_OCC_DCU;
    ps.fields.mid_care_mask = OCI_MASTER_ID_OCC_ICU & OCI_MASTER_ID_OCC_DCU;
    ps.fields.read_ttype = PBA_READ_TTYPE_CL_RD_NC;
    ps.fields.read_prefetch_ctl = PBA_READ_PREFETCH_NONE;
    ps.fields.write_ttype = PBA_WRITE_TTYPE_DMA_PR_WR;
    ps.fields.wr_gather_timeout = PBA_WRITE_GATHER_TIMEOUT_2_PULSES;
    ps.fields.buf_alloc_a = 1;
    ps.fields.buf_alloc_b = 1;
    ps.fields.buf_alloc_c = 1;
    ps.fields.buf_alloc_w = 1;
    
    l_rc = data.setDoubleWord(0, ps.value);
    if (l_rc) 
    { 
       FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc);   
       rc.setEcmdError(l_rc); 
       return rc;    
    } // end if 
    
    rc = fapiPutScom(i_target, PBA_SLVCTL1_0x00064005 , data);
    if (rc) 
    {  
       FAPI_ERR("fapiPutScom( PBA_SLVCTL1_0x00064005 ) failed. With rc = 0x%x", (uint32_t)rc); 
       return rc; 
    } 
    
    // Slave 2 (PORE-SLW).  This is a read/write slave. Write gathering is
    // allowed, but with the shortest possible timeout.  The slave is set up
    // to allow normal reads and writes at initialization.  The 24x7 code may
    // reprogram this slave for IMA writes using special code sequences that
    // restore normal DMA writes after each IMA sequence.

    //   pba_slave_reset(PBA_SLAVE_PORE_SLW);
    ps.value = 0;
    ps.fields.enable = 1;
    ps.fields.mid_match_value = OCI_MASTER_ID_PORE_SLW;
    ps.fields.mid_care_mask = 0x7;
    ps.fields.read_ttype = PBA_READ_TTYPE_CL_RD_NC;
    ps.fields.read_prefetch_ctl = PBA_READ_PREFETCH_NONE;
    ps.fields.write_ttype = PBA_WRITE_TTYPE_DMA_PR_WR;
    ps.fields.wr_gather_timeout = PBA_WRITE_GATHER_TIMEOUT_2_PULSES;
    ps.fields.buf_alloc_a = 1;
    ps.fields.buf_alloc_b = 1;
    ps.fields.buf_alloc_c = 1;
    ps.fields.buf_alloc_w = 1;
    l_rc = data.setDoubleWord(0, ps.value);
    if (l_rc) 
    { 
       FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc);  
       rc.setEcmdError(l_rc); 
       return rc;    
    } // end if 
    
    rc = fapiPutScom(i_target, PBA_SLVCTL2_0x00064006 , data);
    if (rc) 
    {  
       FAPI_ERR("fapiPutScom( PBA_SLVCTL2_0x00064006 ) failed. With rc = 0x%x", (uint32_t)rc); 
       return rc; 
    }

    // Slave 3 (OCB).  This is a read/write slave. Write gathering is
    // allowed, but with the shortest possible timeout.

    //   pba_slave_reset(PBA_SLAVE_OCB);
    ps.value = 0;
    ps.fields.enable = 1;
    ps.fields.mid_match_value = OCI_MASTER_ID_OCB;
    ps.fields.mid_care_mask = 0x7;
    ps.fields.read_ttype = PBA_READ_TTYPE_CL_RD_NC;
    ps.fields.read_prefetch_ctl = PBA_READ_PREFETCH_NONE;
    ps.fields.write_ttype = PBA_WRITE_TTYPE_DMA_PR_WR;
    ps.fields.wr_gather_timeout = PBA_WRITE_GATHER_TIMEOUT_2_PULSES;
    ps.fields.buf_alloc_a = 1;
    ps.fields.buf_alloc_b = 1;
    ps.fields.buf_alloc_c = 1;
    ps.fields.buf_alloc_w = 1;
    
    l_rc = data.setDoubleWord(0, ps.value);
    if (l_rc) 
    { 
       FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc);   rc.setEcmdError(l_rc); return rc;    
    } // end if
    
    rc = fapiPutScom(i_target, PBA_SLVCTL3_0x00064007 , data);
    if (rc) 
    {  
       FAPI_ERR("fapiPutScom( PBA_SLVCTL3_0x00064007 ) failed. With rc = 0x%x", (uint32_t)rc); return rc; 
    }

    return rc;
}  // end pba_slave_setup_init


// ************************************************************************************************
// **************************************************** pba_slave_setup_reset *********************
// for reset, set all register contents to zero
fapi::ReturnCode
pba_slave_setup_reset(const Target& i_target)
{
    fapi::ReturnCode rc;
    uint32_t l_rc;              // local returncode
    ecmdDataBufferBase data(64);

    do
    {
        l_rc= data.setDoubleWord(0, 0x00000000);
        if (l_rc) 
        { 
           FAPI_ERR("data.setDoubleWord ( ) failed. With rc = 0x%x", (uint32_t)l_rc);
           rc.setEcmdError(l_rc);  
           break;    
        } // end if  

        rc = fapiPutScom(i_target, PBA_MODE_0x00064000 , data);
        if (rc) 
        {  
           FAPI_ERR("fapiPutScom( PBA_MODE_0x00064000 ) failed. With rc = 0x%x", (uint32_t)rc); 
           break; 
        } 

        rc = fapiPutScom(i_target, PBA_SLVCTL0_0x00064004 , data);
        if (rc) 
        {  
           FAPI_ERR("fapiPutScom( PBA_SLVCTL0_0x00064004 ) failed. With rc = 0x%x", (uint32_t)rc); 
           break; 
        }
        rc = fapiPutScom(i_target, PBA_SLVCTL1_0x00064005 , data);
        if (rc) 
        {  
           FAPI_ERR("fapiPutScom( PBA_SLVCTL1_0x00064005 ) failed. With rc = 0x%x", (uint32_t)rc); 
           break; 
        }

        rc = fapiPutScom(i_target, PBA_SLVCTL2_0x00064006 , data);
        if (rc) 
        {  
           FAPI_ERR("fapiPutScom( PBA_SLVCTL2_0x00064006 ) failed. With rc = 0x%x", (uint32_t)rc); 
           break; 
        }

        rc = fapiPutScom(i_target, PBA_SLVCTL3_0x00064007 , data);
        if (rc) 
        {  
           FAPI_ERR("fapiPutScom( PBA_SLVCTL3_0x00064007 ) failed. With rc = 0x%x", (uint32_t)rc); 
           break; 
        }
    } while(0);
    
    return rc;

}  // end pba_slave_setup_reset




// ************************************************************************************************
// **************************************************** pba_slave_reset ***************************
// Walk each slave to hit the respective reset and then poll for completion
fapi::ReturnCode
pba_slave_reset(const Target& i_target)
{
    fapi::ReturnCode    rc;
    ecmdDataBufferBase  data(64);
    bool                error_flag = false;
    bool                poll_failure = false;

   
    do
    {        
        for (int s=0; s<= 3; s++)
        {           
            
            FAPI_INF("Reseting PBA Slave %x", s);
            poll_failure = true;
	    //           for (int p=0; p<MAX_PBA_RESET_POLLS; p++)
            for (int p=0; p<=16; p++)
            {
            
                // Set the reset for the selected slave
                data.setDoubleWord(0, PBA_SLVRESETs[s]);

                rc = fapiPutScom(i_target, PBA_SLVRST_0x00064001 , data);
                if (rc) 
                {  
                     FAPI_ERR("fapiPutScom( PBA_SLVRST_0x00064001 ) failed. With rc = 0x%x", (uint32_t)rc); 
                     break ;
                } 
            
                // Read the reset register to check for reset completion
                rc = fapiGetScom(i_target, PBA_SLVRST_0x00064001 , data);               
                if (rc) 
                {  
                     FAPI_ERR("fapiGetPutScom( PBA_SLVRST_0x00064001 ) failed. With rc = 0x%x", (uint32_t)rc); 
                     error_flag = true;
                     break; 
                } 
                FAPI_DBG("Slave %x reset poll data = 0x%16llu", s, data.getDoubleWord(0));
                
                // If slave reset in progress, wait and then poll
                if (data.isBitClear(4+s))
                {
                    poll_failure = false; 
                    break;               
                }
                else
                {
                    rc = fapiDelay(PBA_RESET_POLL_DELAY*1000, 200000);   // In microseconds
                }
    
            }
            if (error_flag)
            {
                 break; 
            }
            
            if (poll_failure)
            {
                 FAPI_ERR("fapiGetPutScom( PBA_SLVRST_0x00064001 ) failed. With rc = 0x%x", (uint32_t)rc); 
                 // NEED SET RC
                 break; 
            }
            
            // Check if the slave is still actually busy.  Consider whether this should be polled
            if (data.isBitSet(8+s))
            {
                FAPI_ERR("Slave %x still busy after reset", s); 
                 // NEED SET RC
                break;           
            }

        }
        
    } while(0);
    
    return rc;

}  // end pba_slave_setup_reset


} //end extern C

OpenPOWER on IntegriCloud