summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/nvrm/core/ap15/ap15rm_init.c
blob: c5f849c6da984ef26afe2e10ca932d5b730ab535 (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
/*
 * Copyright (c) 2007-2010 NVIDIA Corporation.
 * All rights reserved.
 *
 * 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 the NVIDIA Corporation 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 HOLDER 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 "nvcommon.h"
#include "nvos.h"
#include "nvutil.h"
#include "nvassert.h"
#include "nvrm_drf.h"
#include "nvrm_init.h"
#include "nvrm_rmctrace.h"
#include "nvrm_configuration.h"
#include "nvrm_chiplib.h"
#include "nvrm_heap.h"
#include "nvrm_pmu_private.h"
#include "nvrm_processor.h"
#include "ap15rm_private.h"
#include "nvrm_structure.h"
#include "ap15rm_private.h"
#include "ap15rm_clocks.h"
#include "nvodm_query.h"
#include "nvodm_query_pins.h"
#include "common/nvrm_hwintf.h"
#include "ap15/armc.h"
#include "ap15/aremc.h"
#include "ap15/project_relocation_table.h"
#include "ap15/arapb_misc.h"
#include "ap15/arapbpm.h"
#include "nvrm_pinmux_utils.h"
#include "ap15/arfuse.h"
#include "nvbootargs.h"

static NvRmDevice gs_Rm;

extern NvRmCfgMap g_CfgMap[];

void NvRmPrivMemoryInfo( NvRmDeviceHandle hDevice );
extern NvError NvRmPrivMapApertures( NvRmDeviceHandle rm );
extern void NvRmPrivUnmapApertures( NvRmDeviceHandle rm );
extern NvError NvRmPrivPwmInit(NvRmDeviceHandle hRm);
extern void NvRmPrivPwmDeInit(NvRmDeviceHandle hRm);
extern NvU32 NvRmPrivGetBctCustomerOption(NvRmDeviceHandle hRm);
extern void NvRmPrivReadChipId( NvRmDeviceHandle rm );
extern NvU32 *NvRmPrivGetRelocationTable( NvRmDeviceHandle hDevice );
extern NvError NvRmPrivPcieOpen(NvRmDeviceHandle hDeviceHandle);
extern void NvRmPrivPcieClose(NvRmDeviceHandle hDeviceHandle);
static void NvRmPrivInitPinAttributes(NvRmDeviceHandle rm);
static void NvRmPrivBasicReset( NvRmDeviceHandle rm );
static NvError NvRmPrivMcErrorMonitorStart( NvRmDeviceHandle rm );
static void NvRmPrivMcErrorMonitorStop( NvRmDeviceHandle rm );

#if !NV_OAL
/* This function sets some performance timings for Mc & Emc.  Numbers are from
 * the Arch team.
 */
static void
NvRmPrivSetupMc(NvRmDeviceHandle hRm)
{
    switch (hRm->ChipId.Id) {
    case 0x15:
    case 0x16:
        NvRmPrivAp15SetupMc(hRm);
        break;
    case 0x20:
        NvRmPrivAp20SetupMc(hRm);
        break;
    default:
        NV_ASSERT(!"Unsupported chip ID");
        break;
    }
}
#endif

NvError
NvRmOpen(NvRmDeviceHandle *pHandle, NvU32 DeviceId ) {
    return NvRmOpenNew(pHandle);
}

void NvRmInit(
    NvRmDeviceHandle * pHandle )
{
    NvU32 *table = 0;
    NvRmDevice *rm = 0;
    rm = &gs_Rm;

    if( rm->bPreInit )
    {
        return;
    }

    /* Read the chip Id and store in the Rm structure. */
    NvRmPrivReadChipId( rm );

    /* parse the relocation table */
    table = NvRmPrivGetRelocationTable( rm );
    NV_ASSERT(table != NULL);

    NV_ASSERT_SUCCESS(NvRmPrivModuleInit( &rm->ModuleTable, table ));

    NvRmPrivMemoryInfo( rm );

    NvRmPrivInterruptTableInit( rm );

    rm->bPreInit = NV_TRUE;
    *pHandle = rm;

    return;
}

NvError
NvRmOpenNew(NvRmDeviceHandle *pHandle)
{
    NvError err;
    NvRmDevice *rm = 0;
    NvU32 *table = 0;

    NvU32 CarveoutBaseAddr;
    NvU32 CarveoutSize = 0;
    NvU32 BctCustomerOption = 0;
    NvU64 Uid = 0;

    NvOsMutexHandle rmMutex = NULL;

    /* open the nvos trace file */
    NVOS_TRACE_LOG_START;

    // OAL does not support these mutexes
    if (gs_Rm.mutex == NULL)
    {
        err = NvOsMutexCreate(&rmMutex);
        if (err != NvSuccess)
            return err;

        if (NvOsAtomicCompareExchange32((NvS32*)&gs_Rm.mutex, 0,
                (NvS32)rmMutex) != 0)
            NvOsMutexDestroy(rmMutex);
    }

    NvOsMutexLock(gs_Rm.mutex);
    rm = &gs_Rm;

    if(rm->refcount )
    {
        rm->refcount++;
        *pHandle = rm;
        NvOsMutexUnlock(gs_Rm.mutex);
        return NvSuccess;
    }

    rmMutex = gs_Rm.mutex;
    gs_Rm.mutex = rmMutex;

    // create the memmgr mutex
    err = NvOsMutexCreate(&rm->MemMgrMutex);
    if (err)
        goto fail;

    // create mutex for the clock and reset r-m-w top level registers access
    err = NvOsMutexCreate(&rm->CarMutex);
    if (err)
        goto fail;

    /* NvRmOpen needs to be re-entrant to allow I2C, GPIO and KeyList ODM
     * services to be available to the ODM query.  Therefore, the refcount is
     * bumped extremely early in initialization, and if any initialization
     * fails the refcount is reset to 0.
     */
    rm->refcount = 1;

    if( !rm->bBasicInit )
    {
        /* get the default configuration */
        err = NvRmPrivGetDefaultCfg( g_CfgMap, &rm->cfg );
        if( err != NvSuccess )
        {
            goto fail;
        }

        /* get the requested configuration */
        err = NvRmPrivReadCfgVars( g_CfgMap, &rm->cfg );
        if( err != NvSuccess )
        {
            goto fail;
        }
    }

    /* start chiplib */
    if (rm->cfg.Chiplib[0] != '\0')
    {
        err = NvRmPrivChiplibStartup( rm->cfg.Chiplib, rm->cfg.ChiplibArgs,
            NULL );
        if( err != NvSuccess )
        {
            goto fail;
        }
    }

    /* open the RMC file */
    err = NvRmRmcOpen( rm->cfg.RMCTraceFileName, &rm->rmc );
    if( err != NvSuccess )
    {
        goto fail;
    }

    if( !rm->bPreInit )
    {
        /* Read the chip Id and store in the Rm structure. */
        NvRmPrivReadChipId( rm );

        /* parse the relocation table */
        table = NvRmPrivGetRelocationTable( rm );
        if( !table )
        {
            goto fail;
        }

        err = NvRmPrivModuleInit( &rm->ModuleTable, table );
        if( err != NvSuccess )
        {
            goto fail;
        }
        NvRmPrivMemoryInfo( rm );

        // Now populate the logical interrupt table.
        NvRmPrivInterruptTableInit( rm );
    }

    if( !rm->bBasicInit && !NVOS_IS_WINDOWS_X86 )
    {
        err = NvRmPrivMapApertures( rm );
        if( err != NvSuccess )
        {
            goto fail;
        }

        // Initializing the ODM-defined key list
        //  This gets initialized first, since the RMs calls into
        //  the ODM query may result in the ODM query calling
        //  back into the RM to get this value!
        BctCustomerOption = NvRmPrivGetBctCustomerOption(rm);
        err = NvRmPrivInitKeyList(rm, &BctCustomerOption, 1);
        if (err != NvSuccess)
        {
            goto fail;
        }
    }

    // prevent re-inits
    rm->bBasicInit = NV_TRUE;
    rm->bPreInit = NV_TRUE;


    {
        NvBootArgsCarveout Carveout;
        if (NvOsBootArgGet(NvBootArgKey_Carveout, &Carveout,
            sizeof(Carveout)) == NvSuccess)
        {
            CarveoutSize = Carveout.size;
            CarveoutBaseAddr = (NvU32) Carveout.base;
        }
        else
        {
            CarveoutSize = NvOdmQueryCarveoutSize();
            CarveoutBaseAddr = rm->ExtMemoryInfo.base +
                NvOdmQueryMemSize(NvOdmMemoryType_Sdram) - CarveoutSize;
        }
    }

    NvRmPrivHeapCarveoutInit(CarveoutSize, CarveoutBaseAddr);
    NvRmPrivHeapIramInit(rm->IramMemoryInfo.size, rm->IramMemoryInfo.base);
    NvRmPrivPreservedMemHandleInit(rm);

    if (!NVOS_IS_WINDOWS_X86)
    {
        // Initialize the GART heap (size & base address)
        NvRmPrivHeapGartInit( rm );

        NvRmPrivCheckBondOut( rm );

        /* bring modules out of reset */
        NvRmPrivBasicReset( rm );

        /* initialize power manager before any other module that may access
         * clock or voltage resources
         */
        err = NvRmPrivPowerInit(rm);
        if( err != NvSuccess )
        {
            goto fail;
        }

        NvRmPrivInterruptStart( rm );

        // Initializing pins attributes
        NvRmPrivInitPinAttributes(rm);

        // Initialize RM pin-mux (init's the state of internal shadow
        // register variables)
        NvRmInitPinMux(rm, NV_TRUE);

        // Initalize the module clocks.
        err = NvRmPrivClocksInit( rm );
        if( err != NvSuccess )
        {
            goto fail;
        }
    }

    if (!NVOS_IS_WINDOWS_X86)
    {
        // FIXME: this crashes in simulation
        // Enabling only for the non simulation modes.
        if ((rm->ChipId.Major == 0) && (rm->ChipId.Netlist == 0))
        {
            // this is the csim case, so we don't do this here.
        }
        else
        {
            // Initializing the dma.
            err = NvRmPrivDmaInit(rm);
            if( err != NvSuccess )
            {
                goto fail;
            }

            // Initializing the Spi and Slink.
            err = NvRmPrivSpiSlinkInit(rm);
            if( err != NvSuccess )
            {
                goto fail;
            }

            //  Complete pin mux initialization
            NvRmInitPinMux(rm, NV_FALSE);

            // Initializing the dfs
            err = NvRmPrivDfsInit(rm);
            if( err != NvSuccess )
            {
                goto fail;
            }
        }

        // Initializing the Pwm
        err = NvRmPrivPwmInit(rm);
        if (err != NvSuccess)
        {
            goto fail;
        }

        // PMU interface init utilizes ODM services that reenter NvRmOpen().
        // Therefore, it shall be performed after refcount is set so that
        // reentry has no side-effects except bumping refcount. The latter
        // is reset below so that RM can be eventually closed.
        err = NvRmPrivPmuInit(rm);
        if( err != NvSuccess )
        {
            goto fail;
        }

        // set the mc & emc tuning parameters
        NvRmPrivSetupMc(rm);
        if (!NvRmIsSimulation())
        {
            // Configure PLL rails, boost core power and clocks
            // Initialize and start temperature monitoring
            NvRmPrivPllRailsInit(rm);
            NvRmPrivBoostClocks(rm);
            NvRmPrivDttInit(rm);
        }

        if (0)  /* FIXME Don't enable PCI yet */
        {
            err = NvRmPrivPcieOpen( rm );
            if (err != NvSuccess && err != NvError_ModuleNotPresent)
            {
                goto fail;
            }
        }
        // Asynchronous interrupts must be disabled until the very end of
        // RmOpen. They can be enabled just before releasing rm mutex after
        // completion of all initialization calls.
        NvRmPrivPmuInterruptEnable(rm);

        // Start Memory Controller Error monitoring.
        err = NvRmPrivMcErrorMonitorStart(rm);
        if( err != NvSuccess )
        {
            goto fail;
        }

        // WAR for bug 600821
        if ((rm->ChipId.Id == 0x20) && 
            (rm->ChipId.Major == 0x1) && (rm->ChipId.Minor == 0x2))
        {
            err = NvRmQueryChipUniqueId(rm, sizeof (NvU64), &Uid);
            if ((Uid>>32) == 0x08080105)
            {
                NV_REGW(rm, NvRmModuleID_Pmif, 0, 0xD0, 0xFFFFFFEF);
            }
        }
    }

    /* assign the handle pointer */
    *pHandle = rm;

    NvOsMutexUnlock(gs_Rm.mutex);
    return NvSuccess;

fail:
    // FIXME: free rm if it becomes dynamically allocated
    // BUG:  there are about ten places that we go to fail, and we make no
    // effort here to clean anything up.
    NvOsMutexUnlock(gs_Rm.mutex);
    NV_DEBUG_PRINTF(("RM init failed\n"));
    rm->refcount = 0;
    return err;
}

void
NvRmClose(NvRmDeviceHandle handle)
{
    if( !handle )
    {
        return;
    }

    NV_ASSERT( handle->mutex );

    /* decrement refcount */
    NvOsMutexLock( handle->mutex );
    handle->refcount--;

    /* do deinit if refcount is zero */
    if( handle->refcount == 0 )
    {
        if (!NVOS_IS_WINDOWS_X86)
        {
            // PMU and DTT deinit through ODM services reenters NvRmClose().
            // The refcount will wrap around and this will be the only reentry
            // side-effect, which is compensated after deint exit.
            NvRmPrivDttDeinit();
            handle->refcount = 0;
            NvRmPrivPmuDeinit(handle);
            handle->refcount = 0;

            if (0)  /* FIXME Don't enable PCIE yet */
            {
                NvRmPrivPcieClose( handle );
            }
        }

        if (!NVOS_IS_WINDOWS_X86)
        {
            /* disable modules */
            // Enabling only for the non simulation modes.
            if ((handle->ChipId.Major == 0) && (handle->ChipId.Netlist == 0))
            {
                // this is the csim case, so we don't do this here.
            }
            else
            {
                NvRmPrivDmaDeInit();

                NvRmPrivSpiSlinkDeInit();

                NvRmPrivDfsDeinit(handle);
            }

            /* deinit clock manager */
            NvRmPrivClocksDeinit(handle);

            /* deinit power manager */
            NvRmPrivPowerDeinit(handle);

            NvRmPrivDeInitKeyList(handle);
            NvRmPrivPwmDeInit(handle);
            // Stop Memory controller error monitoring.
            NvRmPrivMcErrorMonitorStop(handle);

            /* if anyone left an interrupt registered, this will clear it. */
            NvRmPrivInterruptShutdown(handle);

            /* unmap the apertures */
            NvRmPrivUnmapApertures( handle );

            if (NvRmIsSimulation())
                NvRmPrivChiplibShutdown();

        }

        NvRmPrivHeapCarveoutDeinit();
        NvRmPrivHeapIramDeinit();

        if (!NVOS_IS_WINDOWS_X86)
        {
            // De-Initialize the GART heap
            NvRmPrivHeapGartDeinit();
        }

        NvRmRmcClose( &handle->rmc );

        /* deallocate the instance table */
        NvRmPrivModuleDeinit( &handle->ModuleTable );

        /* free up the CAR mutex */
        NvOsMutexDestroy(handle->CarMutex);

        /* free up the memmgr mutex */
        NvOsMutexDestroy(handle->MemMgrMutex);

        /* close the nvos trace file */
        NVOS_TRACE_LOG_END;
    }
    NvOsMutexUnlock( handle->mutex );

#if NVOS_IS_WINDOWS && !NVOS_IS_WINDOWS_CE
    if( handle->refcount == 0 )
    {
        NvOsMutexDestroy(handle->mutex);
        gs_Rm.mutex = 0;
    }
#endif
}

void
NvRmPrivMemoryInfo( NvRmDeviceHandle hDevice )
{
    NvRmModuleTable *tbl;
    NvRmModuleInstance *inst;

    tbl = &hDevice->ModuleTable;

    /* Get External memory module info */
    inst = tbl->ModInst +
        (tbl->Modules)[NvRmPrivModuleID_ExternalMemory].Index;

    hDevice->ExtMemoryInfo.base = inst->PhysAddr;
    hDevice->ExtMemoryInfo.size = inst->Length;

    /* Get Iram Memory Module Info .Special handling since iram has 4 banks
     * and each has a different instance in the relocation table
     */

    inst = tbl->ModInst + (tbl->Modules)[NvRmPrivModuleID_Iram].Index;
    hDevice->IramMemoryInfo.base = inst->PhysAddr;
    hDevice->IramMemoryInfo.size = inst->Length;

    inst++;
    // Below loop works assuming that relocation table parsing compacted
    // scattered multiple instances into sequential list
    while(NvRmPrivDevToModuleID(inst->DeviceId) == NvRmPrivModuleID_Iram)
    {
        // The IRAM banks are contigous address of memory. Cannot handle
        // non-contigous memory for now
        NV_ASSERT(hDevice->IramMemoryInfo.base +
            hDevice->IramMemoryInfo.size == inst->PhysAddr);

        hDevice->IramMemoryInfo.size += inst->Length;
        inst++;
    }

    if (!(NVCPU_IS_X86 && NVOS_IS_WINDOWS))
    {
        /* Get GART memory module info */
        inst = tbl->ModInst +
            (tbl->Modules)[NvRmPrivModuleID_Gart].Index;
        hDevice->GartMemoryInfo.base = inst->PhysAddr;
        hDevice->GartMemoryInfo.size = inst->Length;
    }
}

NvError
NvRmGetRmcFile( NvRmDeviceHandle hDevice, NvRmRmcFile **file )
{
    NV_ASSERT(hDevice);

    *file = &hDevice->rmc;
    return NvSuccess;
}

NvRmDeviceHandle NvRmPrivGetRmDeviceHandle()
{
    return &gs_Rm;
}

/**
 * Initializes pins attributes
 * @param hRm The RM device handle
 */
static void
NvRmPrivInitPinAttributes(NvRmDeviceHandle rm)
{
    NvU32 Count = 0, Offset = 0, Value = 0;
    NvU32 Major = 0;
    NvU32 Minor = 0;
    NvOdmPinAttrib *pPinAttribTable = NULL;
    NvRmModuleCapability caps[4];
    NvRmModuleCapability *pCap = NULL;

    NV_ASSERT( rm );

    NvOsMemset(caps, 0, sizeof(caps));

    caps[0].MajorVersion = 1;
    caps[0].MinorVersion = 0;
    caps[0].EcoLevel = 0;
    caps[0].Capability = &caps[0];

    caps[1].MajorVersion = 1;
    caps[1].MinorVersion = 1;
    caps[1].EcoLevel = 0;

    caps[2].MajorVersion = 1;
    caps[2].MinorVersion = 2;
    caps[2].EcoLevel = 0;

    //  the pin attributes for v 1.0 and v1.1 of the misc module
    //  are fully compatible, so the version comparison is made against 1.0
    // Treating 1.2 same as 1.0/1.1.
    caps[1].Capability = &caps[0];
    caps[2].Capability = &caps[0];

    /* AP20 misc module pin attributes, set differently than AP15 as the pin
     * attribute registers in misc module changed */
    caps[3].MajorVersion = 2;
    caps[3].MinorVersion = 0;
    caps[3].EcoLevel = 0;
    caps[3].Capability = &caps[3];

    NV_ASSERT_SUCCESS(NvRmModuleGetCapabilities(
            rm,
            NvRmModuleID_Misc,
            caps,
            sizeof(caps)/sizeof(caps[0]),
            (void**)&pCap));

    Count = NvOdmQueryPinAttributes((const NvOdmPinAttrib **)&pPinAttribTable);

    for ( ; Count ; Count--, pPinAttribTable++)
    {
        Major = (pPinAttribTable->ConfigRegister >> 28);
        Minor = (pPinAttribTable->ConfigRegister >> 24) & 0xF;
        if ((Major == pCap->MajorVersion) && (Minor == pCap->MinorVersion))
        {
            Offset = pPinAttribTable->ConfigRegister & 0xFFFF;
            Value = pPinAttribTable->Value;
            NV_REGW(rm, NvRmModuleID_Misc, 0, Offset, Value);
        }
    }
}


static void NvRmPrivBasicReset( NvRmDeviceHandle rm )
{
    switch (rm->ChipId.Id) {
    case 0x15:
    case 0x16:
        NvRmPrivAp15BasicReset(rm);
        return;
    case 0x20:
        NvRmPrivAp20BasicReset(rm);
        return;
    default:
        NV_ASSERT(!"Unsupported chip ID");
        return;
    }
}

NvError NvRmPrivMcErrorMonitorStart( NvRmDeviceHandle rm )
{
    NvError e = NvError_NotSupported;

    switch (rm->ChipId.Id) {
    case 0x15:
    case 0x16:
        e = NvRmPrivAp15McErrorMonitorStart(rm);
        break;
    case 0x20:
        e = NvRmPrivAp20McErrorMonitorStart(rm);
        break;
    default:
        NV_ASSERT(!"Unsupported chip ID");
        break;
    }
    return e;
}

void NvRmPrivMcErrorMonitorStop( NvRmDeviceHandle rm )
{
    switch (rm->ChipId.Id) {
    case 0x15:
    case 0x16:
        NvRmPrivAp15McErrorMonitorStop(rm);
        break;
    case 0x20:
        NvRmPrivAp20McErrorMonitorStop(rm);
        break;
    default:
        NV_ASSERT(!"Unsupported chip ID");
        break;
    }
}