summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/occ/occ_procedures/p8_oha_init.C
blob: 303aef3d4d6b2176be96effb36524172126a5987 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/hwpf/hwp/occ/occ_procedures/p8_oha_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                                                     */
/* begin_generated_IBM_copyright_prolog                            */
/*                                                                 */
/* This is an automatically generated copyright prolog.            */
/* After initializing,  DO NOT MODIFY OR MOVE                      */
/* --------------------------------------------------------------- */
/* IBM Confidential                                                */
/*                                                                 */
/* Licensed Internal Code Source Materials                         */
/*                                                                 */
/* (C)Copyright IBM Corp.  2014, 2014                              */
/*                                                                 */
/* 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.                       */
/*  -------------------------------------------------------------- */
/*                                                                 */
/* end_generated_IBM_copyright_prolog                              */
// $Id: p8_oha_init.C,v 1.3 2012/10/04 10:23:00 rmaier Exp $
// $Source: /afs/awd.austin.ibm.com/projects/eclipz/KnowledgeBase/.cvsroot/eclipz/chips/p8/working/procedures/ipl/fapi/p8_oha_init.C,v $
//------------------------------------------------------------------------------
// *! (C) Copyright International Business Machines Corp. 2011
// *! All Rights Reserved -- Property of IBM
// *! *** IBM Confidential ***
//------------------------------------------------------------------------------
// *! OWNER NAME: Ralf Maier         Email: ralf.maier@de.ibm.com
// *!
// *! General Description:
// *!
// *!    The purpose of this procedure is to do a initial setup of OHA
// *!
// *! Procedure Prereq:
// *!   o completed istep procedure
// *!
//------------------------------------------------------------------------------
/// \file p8_oha_init.C
/// \brief Setup OHA ( AISS_HANG_DETECT_TIMER,  Power Proxy Trace Timer and Low Activity detect range)
///
///
///
///
/// \version
/// \version --------------------------------------------------------------------------
/// \version 1.3  rmaier 10/04/12 Replacing genHex*Str function
/// \version --------------------------------------------------------------------------
/// \version 1.1  rmaier 08/23/12 Renaming proc_ to p8_
/// \version --------------------------------------------------------------------------
/// \version 1.13 rmaier 08/02/12 Included review feedback Set 6
/// \version --------------------------------------------------------------------------
/// \version 1.12 rmaier 07/17/12 Included review feedback Set 5
/// \version --------------------------------------------------------------------------
/// \version 1.11 rmaier 07/17/12 Included review feedback Set 4
/// \version --------------------------------------------------------------------------
/// \version 1.10 rmaier 07/13/12 Included new review feedback
/// \version --------------------------------------------------------------------------
/// \version 1.9 rmaier 05/24/12 Included review feedback
/// \version --------------------------------------------------------------------------
/// \version 1.8 rmaier 05/15/12 Changed Error return code handling for SCOM access
/// \version --------------------------------------------------------------------------
/// \version 1.7 rmaier 05/09/12 Removed global variables
/// \version --------------------------------------------------------------------------
/// \version 1.6 rmaier 04/24/12 Updated Config-mode
/// \version --------------------------------------------------------------------------
/// \version 1.5 rmaier 03/20/12 Added AISS-reset
/// \version --------------------------------------------------------------------------
/// \version 1.4 rmaier 03/13/12 Added modes-structure
/// \version --------------------------------------------------------------------------
/// \version 1.0 rmaier 12/01/11 Initial Version
/// \version ---------------------------------------------------------------------------
///
///
///
///
///
///
///
///
/// High-level procedure flow:
///
/// \verbatim
///
///  Procedure Prereq:
///  - completed istep procedure
///
///
///  loop over all valid chiplets {
///
///    Setup aiss hang time  in oha_mode_reg
///      set aiss_timeout to max              --  oha_mode_reg (11:14) ,            ADR 1002000D (SCOM)
///                                          --  9 => longest time  512 ms
///    Setup low activity  in oha_low_activity_detect_mode_reg
///                                          -- oha_low_activity_detect_mode_reg,   ADR 10020003 (SCOM)
/// \todo  when should we enable the low activity detection or just setup the ranges??
///      set lad_enable = 1??
///      set lad_entry = 16                  -- bit index of a 24 bit counter based on base counter  0: longest, 23: shortest interval
///      set lad_exit  = 17                  -- bit index of a 24 bit counter based on base counter  0: longest, 23: shortest interval
///
///
///    Setup Power Proxy Trace  in activity_sample_mode_reg
///      set  ppt_int_timer_select           -- activity_sample_mode_reg (36:37)    ADR 10020000 (SCOM)
///                                          -- select precounter for ppt timer ( 0=0.25us, 1=0.5us, 2=1us, 3=2us )
///
///     if PM_CONFIG {
///
///                                            convert_ppt_time() - Convert Power Proxy Trace Time to Power Proxy Trace Time Select and Match feature attributes
///                                            With ATTR_PM_POWER_PROXY_TRACE_TIMER (binary in nanoseconds) to produce  ATTR_PM_PPT_TIMER_MATCH_VALUE and ATTR_PM_PPT_TIMER_TICK
///                                             0=0.25us , 1=0.5us, 2=1us, and 3=2us
///
///     else if PM_INIT {
///
///             Timer settings if not able to be done in the init file
///             - PPT timer
///             - AISS hang timer
///
///     } else if PM_RESET {
///
///             AISS reset
///
///       }   //end PM_RESET -mode
///
///

///  \endverbatim
///
//------------------------------------------------------------------------------
//----------------------------------------------------------------------
//  eCMD Includes
//----------------------------------------------------------------------


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




extern "C" {



using namespace fapi;

 //------------------------------------------------------------------------------
 //Start scan zero value
 //------------------------------------------------------------------------------



// ----------------------------------------------------------------------
// Function prototypes
// ----------------------------------------------------------------------


typedef struct {
  int8_t   AISS_HANG_DETECT_TIMER_SEL;     //  oha_mode_reg (11:14) - 0=1ms, 1=2ms, 3=4ms, ...9=512ms. others illegal
  int8_t   PPT_TIMER_SELECT;               //  activity_sample_mode_reg (36:37) 0=0.25us, 1=0.5us, 2=1us, and 3=2us
  int8_t   LAD_ENTRY;
  int8_t   LAD_EXIT;
} struct_i_oha_val_init_type;


// ----------------------------------------------------------------------
// Function definitions
// ----------------------------------------------------------------------

// Reset function
fapi::ReturnCode p8_oha_init_reset    (const Target  &i_target, uint32_t i_mode);
// Config function
fapi::ReturnCode p8_oha_init_config   (const fapi::Target&  i_target) ;
// INIT
fapi::ReturnCode  p8_oha_init_init    (const fapi::Target& i_target, struct_i_oha_val_init_type i_oha_val_init) ;


// ----------------------------------------------------------------------
// p8_oha_init wrapper to fetch the attributes and pass it on to p8_oha_init_core
// ----------------------------------------------------------------------

fapi::ReturnCode
p8_oha_init(const fapi::Target &i_target, uint32_t i_mode)
{
  fapi::ReturnCode rc;





  if ( i_mode == PM_CONFIG ) {

    FAPI_DBG("*************************************");
    FAPI_INF("MODE:  CONFIG , Calling: p8_oha_init_config");
    FAPI_DBG("*************************************");
    rc=p8_oha_init_config(i_target);

    if (rc) {
        FAPI_ERR(" p8_oha_init_config failed. With rc = 0x%x", (uint32_t)rc); return rc;
    }

  } else if ( i_mode == PM_INIT )  {


    FAPI_DBG("*************************************");
    FAPI_INF("MODE:  INIT , Calling: p8_oha_init_init");
    FAPI_DBG("*************************************");

    //  ******************************************************************
    /// \todo   should this values be attributes?? The get those attributes here
    //#ifndef ATTRIBUTES_AVAIL

          //Declare parms struct
          struct_i_oha_val_init_type i_oha_val_init;

          //Assign values to parms in struct
          // should come from MRWB
          i_oha_val_init.AISS_HANG_DETECT_TIMER_SEL = 9;  //  oha_mode_reg (11:14) - 0=1ms, 1=2ms, 3=4ms, ...9=512ms. others illegal
          i_oha_val_init.PPT_TIMER_SELECT = 3;            //  activity_sample_mode_reg (36:37) 0=0.25us, 1=0.5us, 2=1us, and 3=2us
          i_oha_val_init.LAD_ENTRY = 16;
          i_oha_val_init.LAD_EXIT = 17;


    //#else
    //      FAPI_ATTR_GET("IVRMS_ENABLED", i_target,(unit8_t) ivrms_enabled);         //VENICE or SALERNO

    //#endif

    //  ******************************************************************



    rc=p8_oha_init_init(i_target,  i_oha_val_init);

    if (rc) {
        FAPI_ERR(" p8_oha_init_init failed. With rc = 0x%x", (uint32_t)rc); return rc;
    }


  } else if ( i_mode == PM_RESET )  {
    FAPI_DBG("*************************************");
    FAPI_INF("MODE:  RESET");
    FAPI_DBG("*************************************");




              //Declare parms struct
              struct_i_oha_val_init_type __attribute__((unused)) i_oha_val_init; // HACK

              //Assign values to parms in struct
              // should come from MRWB
              i_oha_val_init.AISS_HANG_DETECT_TIMER_SEL = 9;  //  oha_mode_reg (11:14) - 0=1ms, 1=2ms, 3=4ms, ...9=512ms. others illegal
              i_oha_val_init.PPT_TIMER_SELECT = 3;            //  activity_sample_mode_reg (36:37) 0=0.25us, 1=0.5us, 2=1us, and 3=2us
              i_oha_val_init.LAD_ENTRY = 16;
              i_oha_val_init.LAD_EXIT = 17;

              //  ******************************************************************
              /// \todo   should this values be attributes?? The get those attributes here

              #ifndef ATTRIBUTES_AVAIL


              #else
              //      FAPI_ATTR_GET("IVRMS_ENABLED", i_target,(unit8_t) ivrms_enabled);         //VENICE or SALERNO

              #endif

              //  ******************************************************************




    //FAPI_DBG("*************************************");
    FAPI_INF("Calling: p8_oha_init_reset");
    //FAPI_DBG("*************************************");
    rc = p8_oha_init_reset( i_target, i_mode);

    if (rc) {
      FAPI_ERR(" p8_oha_init_reset failed. With rc = 0x%x", (uint32_t)rc); return rc;
    }

  } else {
    //FAPI_DBG("*************************************");
    FAPI_ERR("Unknown mode passed to p8_oha_init. Mode %x ....\n", i_mode);
    FAPI_SET_HWP_ERROR(rc, RC_PROC_OHA_CODE_BAD_MODE);
    //FAPI_DBG("*************************************");
  };



  return rc;

}



fapi::ReturnCode
p8_oha_init_config(const fapi::Target& i_target)
{
  fapi::ReturnCode rc;

    uint8_t  attr_pm_aiss_timeout;
    uint32_t attr_pm_power_proxy_trace_timer;
    uint32_t attr_pm_ppt_timer_tick;
    uint32_t attr_pm_ppt_timer_match_value;


        //  ******************************************************************
        //  Get Attributes for OHA Timers Delay
        //  ******************************************************************
        //  set defaults  if not available

               attr_pm_ppt_timer_tick           = 2;           // Default 2: 1us



        /// \todo PLAT attr ... not there yet
                 attr_pm_aiss_timeout             = 5;           // Default 5: 32ms
        //               rc = FAPI_ATTR_GET(ATTR_PM_AISS_TIMEOUT, &i_target, attr_pm_aiss_timeout);
        //               if (rc) { FAPI_ERR("fapiGetAttribute of ATTR_PM_AISS_TIMEOUT with rc = 0x%x", (uint32_t)rc);  return rc; }
        //

        /// \todo PLAT attr ... not there yet
                 attr_pm_power_proxy_trace_timer  = 64000;       // Default 1us,,, 32us...64ms
        //               rc = FAPI_ATTR_GET(ATTR_PM_POWER_PROXY_TRACE_TIMER, &i_target, attr_pm_power_proxy_trace_timer);
        //               if (rc) { FAPI_ERR("fapiGetAttribute of ATTR_PM_POWER_PROXY_TRACE_TIMER with rc = 0x%x", (uint32_t)rc);  return rc; }




        //  ******************************************************************
        //  Calculate OHA timer settings
        //  ******************************************************************
        //FAPI_DBG("*************************************");
        FAPI_DBG("Calculate OHA timer settings");
        //FAPI_DBG("*************************************");
        //FAPI_DBG("*************************************");
        FAPI_DBG("Calculate:");
        FAPI_DBG("        ATTR_PM_PPT_TIMER_MATCH_VALUE");
        FAPI_DBG("        ATTR_PM_PPT_TIMER_TICK");
        FAPI_DBG("using:");
        FAPI_DBG("        ATTR_PM_POWER_PROXY_TRACE_TIMER");
        //FAPI_DBG("**************************************************************************");
        FAPI_DBG("        Set  ATTR_PM_AISS_TIMEOUT   to 5 (32ms)");
        //FAPI_DBG("**************************************************************************");




        //
        attr_pm_ppt_timer_match_value  = attr_pm_power_proxy_trace_timer / 32  ;    //time in us / 32us





          FAPI_DBG("*************************************");
          FAPI_DBG("attr_pm_aiss_timeout                    :  %X", attr_pm_aiss_timeout);
          FAPI_DBG("attr_pm_ppt_timer_match_value           :  %X", attr_pm_ppt_timer_match_value);
          FAPI_DBG("*************************************");


        //  ******************************************************************
        //  Set Attributes for OHA timers
        //  ******************************************************************

        //     rc = FAPI_ATTR_SET(ATTR_PM_AISS_TIMEOUT, &i_target, attr_pm_aiss_timeout);
        //     if (rc) { FAPI_ERR("fapiGetAttribute of ATTR_PM_AISS_TIMEOUT with rc = 0x%x", (uint32_t)rc);  return; }

            rc = FAPI_ATTR_SET(ATTR_PM_PPT_TIMER_MATCH_VALUE, &i_target, attr_pm_ppt_timer_match_value);
            if (rc) { FAPI_ERR("fapiSetAttribute of ATTR_PM_PPT_TIMER_MATCH_VALUE with rc = 0x%x", (uint32_t)rc);  return rc; }
            rc = FAPI_ATTR_SET(ATTR_PM_PPT_TIMER_TICK, &i_target, attr_pm_ppt_timer_tick);
            if (rc) { FAPI_ERR("fapiSetAttribute of ATTR_PM_PPT_TIMER_TICK with rc = 0x%x", (uint32_t)rc);  return rc; }



  return rc;

}  //end CONFIG






fapi::ReturnCode
p8_oha_init_init(const fapi::Target& i_target, struct_i_oha_val_init_type i_oha_val_init)
{
    fapi::ReturnCode rc;

    ecmdDataBufferBase data(64);
    ecmdDataBufferBase mask(64);

    std::vector<fapi::Target>      l_chiplets;
    std::vector<Target>::iterator  itr;


    // Variables
//TODO RTC: 68461 - refresh procedures uint32_t c  = 0 ;
    uint32_t l_rc;


    uint8_t  attr_pm_aiss_timeout;
    uint32_t attr_pm_ppt_timer_tick;
    uint32_t attr_pm_ppt_timer_match_value;

    FAPI_INF("");
    //FAPI_DBG("********* ******************* *********");
    FAPI_INF("Executing  ....p8_oha_init");
    //FAPI_DBG("********* ******************* *********");
    FAPI_INF("");




    rc = fapiGetChildChiplets (i_target, TARGET_TYPE_EX_CHIPLET, l_chiplets); if (rc) return rc;
    FAPI_DBG("  chiplet vector size          => %u", l_chiplets.size());




    //FAPI_DBG("***********************************************");
    FAPI_INF(" Welcome to p8_oha_init INIT-mode ");
    //FAPI_DBG("***********************************************");



    //  ******************************************************************
    //  Get Attributes for OHA Timers Delay
    //  ******************************************************************
     #ifndef ATTRIBUTES_AVAIL
         //  ******************************************************************
         //  set defaults  if not available
         attr_pm_ppt_timer_tick           = 2;           // Default 2: 1us
         attr_pm_ppt_timer_match_value    = 0x7FF;       // Default 0x7FF: 64ms
         attr_pm_aiss_timeout             = 5;           // Default 5: 32ms
     #else
/// \todo PLAT attr ... not there yet
        //rc = FAPI_ATTR_GET(ATTR_PM_AISS_TIMEOUT, &i_target, attr_pm_aiss_timeout);
        //if (rc) { FAPI_ERR("fapiGetAttribute of ATTR_PM_AISS_TIMEOUT with rc = 0x%x", (uint32_t)rc);  return rc; }
        rc = FAPI_ATTR_GET(ATTR_PM_PPT_TIMER_TICK, &i_target, attr_pm_ppt_timer_tick);
        if (rc) { FAPI_ERR("fapiGetAttribute of ATTR_PM_PPT_TIMER_TICK with rc = 0x%x", (uint32_t)rc);  return rc; }
        rc = FAPI_ATTR_GET(ATTR_PM_PPT_TIMER_MATCH_VALUE, &i_target, attr_pm_ppt_timer_match_value);
        if (rc) { FAPI_ERR("fapiGetAttribute of ATTR_PM_PPT_TIMER_MATCH_VALUE with rc = 0x%x", (uint32_t)rc);  return rc; }
    #endif



    //  ******************************************************************
    //  initialize all oha_reg with scan-zero values upfront
    //  ******************************************************************



    for (itr = l_chiplets.begin(); itr != l_chiplets.end(); itr++){


              // HACK - FAPI_DBG("Content Loop Variable C : %d ", c);



              //  ******************************************************************
              //  AISS hang timer setup
              //  ******************************************************************
              //  ******************************************************************

              //  - set aiss_timeout to max time
              //  ******************************************************************
              //FAPI_DBG("**********************************************");
              FAPI_INF(" Setup aiss hang time in oha_mode_reg 1002000D");
              //FAPI_DBG("**********************************************");

              // Read register content
              rc = fapiGetScom( (*itr), EX_OHA_MODE_REG_RWx1002000D , data );
              if (rc) {FAPI_ERR("fapiGetScom(EX_OHA_MODE_REG) failed. With rc = 0x%x", (uint32_t)rc);  return rc;    }

              FAPI_DBG ("Content of EX_OHA_MODE_REG_0x1002000D  :  %016llX", data.getDoubleWord(0));




              //data.flushTo0();
              l_rc = data.insertFromRight(attr_pm_aiss_timeout    ,11,4);
              if (l_rc) { FAPI_ERR("Bit operation failed. With rc = 0x%x", (uint32_t)l_rc);  rc.setEcmdError(l_rc); return rc;    }

              rc = fapiPutScom( (*itr), EX_OHA_MODE_REG_RWx1002000D , data );
              if (rc) {
                FAPI_ERR("fapiPutScom(EX_OHA_MODE_REG) failed. With rc = 0x%x", (uint32_t)rc); return rc;
              }




              //  ******************************************************************
              //  Low Activity Detect (LAD) setup
              //  ******************************************************************
              //  ******************************************************************
              //  - enable LAD
              //  - set LAD for entry
              //  - set LAD for exit
              //  ******************************************************************
              //FAPI_DBG("**********************************************************************************************");
              FAPI_INF(" Setup Low Activity Detect (LAD) in oha_low_activity_detect_mode_reg 10020003, but NOT ENABLED");
              //FAPI_DBG("**********************************************************************************************");

              // Read register content
              //if (VERBOSE) {
                rc = fapiGetScom( (*itr), EX_OHA_LOW_ACTIVITY_DETECT_MODE_REG_RWx10020003 , data );
                if (rc) { FAPI_ERR("fapiGetScom(EX_OHA_LOW_ACTIVITY_DETECT_MODE_REG_RWx10020003) failed. With rc = 0x%x", (uint32_t)rc);  return rc;     }
                FAPI_DBG(" Pre write content of EX_OHA_LOW_ACTIVITY_DETECT_MODE_REG_RWx10020003  :  %016llX", data.getDoubleWord(0));
              //}

              //
              l_rc = data.setByte(0, i_oha_val_init.LAD_ENTRY);   // 16
              l_rc |= data.setByte(1, i_oha_val_init.LAD_EXIT);    // 17
              l_rc |= data.shiftRight(1);                         // LAD entry/exit starts at bit 1
              l_rc |= data.clearBit(0);
              if (l_rc) { FAPI_ERR("Bit operation failed. With rc = 0x%x", (uint32_t)l_rc);  rc.setEcmdError(l_rc); return rc;    }
              //FAPI_DBG(" !!!!!!!!!!!!!!!!!!!!!!returncode   :  %d", rc);





              rc = fapiPutScom((*itr), EX_OHA_LOW_ACTIVITY_DETECT_MODE_REG_RWx10020003 , data );
              if (rc) {
                FAPI_ERR("fapiGetScom(EX_OHA_LOW_ACTIVITY_DETECT_MODE_REG) failed. With rc = 0x%x", (uint32_t)rc);  return rc;
              }

              // if debug mode read back
              //if (VERBOSE) {
              //  rc = fapiGetScom((*itr), EX_OHA_LOW_ACTIVITY_DETECT_MODE_REG_RWx10020003, data); if (rc) return rc;
              //  FAPI_DBG(" Post write content of EX_OHA_LOW_ACTIVITY_DETECT_MODE_REG_RWx10020003  :  %016llX", data.getDoubleWord(0));
              //}
              FAPI_INF ("Done LAD setup. LAD Disabled " );



              //  ******************************************************************
              //  Power Proxy Trace (PPT) setup
              //  ******************************************************************
              //  ******************************************************************
              //  - set ppt_timer_select
              //  - set ppt_trace_timer_match_val
              //  ******************************************************************
              //FAPI_DBG("********************************************************************************");
              FAPI_INF(" Setup  Power Proxy Trace (PPT) in oha_activity_sample_mode_reg 10020000");
              //FAPI_DBG("********************************************************************************");

              // Read register content
              rc = fapiGetScom( (*itr), EX_OHA_ACTIVITY_SAMPLE_MODE_REG_RWx10020000 , data );
              if (rc) {
                FAPI_ERR("fapiGetScom(EX_OHA_ACTIVITY_SAMPLE_MODE_REG) failed. With rc = 0x%x", (uint32_t)rc);  return rc;
              }
              FAPI_DBG(" Pre write content of EX_OHA_ACTIVITY_SAMPLE_MODE_REG_RWx10020000  :  %016llX", data.getDoubleWord(0));


              // set ppt_int_timer_select to longest interval "11" = 2us
              //l_rc = data.setBit(36);
              //if (l_rc) { FAPI_ERR("Bit operation failed.");  FAPI_SET_HWP_ERROR(rc, RC_PROC_OHA_CODE_BITOP_FAILED);       }
              //l_rc = data.setBit(37);
              //if (l_rc) { FAPI_ERR("Bit operation failed.");  FAPI_SET_HWP_ERROR(rc, RC_PROC_OHA_CODE_BITOP_FAILED);       }

              l_rc = data.insertFromRight(attr_pm_ppt_timer_match_value    ,24,11);
              l_rc |= data.insertFromRight(attr_pm_ppt_timer_tick           ,36,2);
              if (l_rc) { FAPI_ERR("Bit operation failed. With rc = 0x%x", (uint32_t)l_rc);  rc.setEcmdError(l_rc); return rc;    }



              rc = fapiPutScom((*itr), EX_OHA_ACTIVITY_SAMPLE_MODE_REG_RWx10020000 , data );
              if (rc) {
                FAPI_ERR("fapiGetScom(EX_OHA_ACTIVITY_SAMPLE_MODE_REG) failed. With rc = 0x%x", (uint32_t)rc);  return rc;
              }

              // if debug mode read back
              //if (VERBOSE) {
                rc = fapiGetScom((*itr), EX_OHA_ACTIVITY_SAMPLE_MODE_REG_RWx10020000, data); if (rc) return rc;
                FAPI_DBG(" Post write content of EX_OHA_ACTIVITY_SAMPLE_MODE_REG_RWx10020000  :  %016llX", data.getDoubleWord(0));
              //}
              FAPI_INF ("Done PPT timer setup." );
    }



    return rc;

}  //end INIT




ReturnCode
p8_oha_init_reset(const Target &i_target,  uint32_t i_mode)
{
    ReturnCode rc;

//std::string PROCEDURE = "p8_oha_init";            // procedure name
//std::string REVISION  = "$Revision: 1.3 $";        // procedure CVS revision


    ecmdDataBufferBase data(64);
    ecmdDataBufferBase mask(64);

    std::vector<fapi::Target>      l_chiplets;
    std::vector<Target>::iterator  itr;


    // Variables
//TODO RTC: 68461 - refresh procedures  uint32_t c  = 0 ;
    uint32_t l_rc;

   FAPI_DBG("");
   //FAPI_DBG("********* ******************* *********");
   FAPI_INF("Executing p8_oha_init...");
   //FAPI_DBG("********* ******************* *********");
   FAPI_DBG("");






    // rc = fapiGetExistingChiplets (i_target, TARGET_TYPE_EX_CHIPLET, l_chiplets); if (rc) return rc;
    rc = fapiGetChildChiplets (i_target, TARGET_TYPE_EX_CHIPLET, l_chiplets); if (rc) return rc;
    FAPI_DBG("  chiplet vector size          => %u", l_chiplets.size());






              //FAPI_DBG("***********************************************");
              FAPI_INF(" Welcome to p8_oha_init_reset ");
              //FAPI_DBG("***********************************************");


for (itr = l_chiplets.begin(); itr != l_chiplets.end(); itr++){


              // HACK - FAPI_DBG("Content Loop Variable C : %d ", c);





              //FAPI_DBG("*************************************");
              FAPI_INF("Reset AISS  ");
              FAPI_INF("Write to register OHA_ARCH_IDLE_STATE_REG  ");
              //FAPI_DBG("*************************************");



              rc = fapiGetScom( (*itr), EX_OHA_ARCH_IDLE_STATE_REG_RWx10020011, data);
              if (rc) {
                FAPI_ERR("fapiGetScom(EX_OHA_ARCH_IDLE_STATE_REG) failed. With rc = 0x%x", (uint32_t)rc);  return rc;
              }
              FAPI_DBG(" Pre write content of EX_OHA_ARCH_IDLE_STATE_REG_RWx10020011 :  %016llX",  data.getDoubleWord(0) );

              l_rc = data.setBit(9);   //reset_idle_state_sequencer_in ... reset pulse gets generated. Not unsetting required
              if (l_rc) { FAPI_ERR("Bit operation failed. With rc = 0x%x", (uint32_t)l_rc);  rc.setEcmdError(l_rc); return rc;    }

              rc = fapiPutScom((*itr), EX_OHA_ARCH_IDLE_STATE_REG_RWx10020011 , data );
              if (rc) {
                FAPI_ERR("fapiPutScom(EX_OHA_ARCH_IDLE_STATE_REG) failed. With rc = 0x%x", (uint32_t)rc);  return rc;
              }

              // if debug mode read back
              //if (VERBOSE) {
                rc = fapiGetScom( (*itr), EX_OHA_ARCH_IDLE_STATE_REG_RWx10020011, data); if (rc) return rc;
                FAPI_DBG(" Post write content of EX_OHA_ARCH_IDLE_STATE_REG_RWx10020011 :  %016llX",  data.getDoubleWord(0) );
              //}
              if (rc) {
                FAPI_ERR("fapiGetScom(EX_OHA_ARCH_IDLE_STATE_REG) failed. With rc = 0x%x", (uint32_t)rc);  return rc;
              }






}



   FAPI_INF("");
   FAPI_INF("Executing proc_OHA_init  ....\n");


  return rc;
}









} //end extern C

OpenPOWER on IntegriCloud