Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  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
/*	$NetBSD: sequoia.c,v 1.14 2016/10/20 09:53:08 skrll Exp $	*/

/*
 * Copyright 1997
 * Digital Equipment Corporation. All rights reserved.
 *
 * This software is furnished under license and may be used and
 * copied only in accordance with the following terms and conditions.
 * Subject to these conditions, you may download, copy, install,
 * use, modify and distribute this software in source and/or binary
 * form. No title or ownership is transferred hereby.
 *
 * 1) Any source code used, modified or distributed must reproduce
 *    and retain this copyright notice and list of conditions as
 *    they appear in the source file.
 *
 * 2) No right is granted to use any trade name, trademark, or logo of
 *    Digital Equipment Corporation. Neither the "Digital Equipment
 *    Corporation" name nor any trademark or logo of Digital Equipment
 *    Corporation may be used to endorse or promote products derived
 *    from this software without the prior written permission of
 *    Digital Equipment Corporation.
 *
 * 3) This software is provided "AS-IS" and any express or implied
 *    warranties, including but not limited to, any implied warranties
 *    of merchantability, fitness for a particular purpose, or
 *    non-infringement are disclaimed. In no event shall DIGITAL be
 *    liable for any damages whatsoever, and in particular, DIGITAL
 *    shall not be liable for special, indirect, consequential, or
 *    incidental damages or damages for lost profits, loss of
 *    revenue or loss of use, whether such damages arise in contract,
 *    negligence, tort, under statute, in equity, at law or otherwise,
 *    even if advised of the possibility of such damage.
 */

/*
**
**  INCLUDE FILES
**
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sequoia.c,v 1.14 2016/10/20 09:53:08 skrll Exp $");

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/callout.h>
#include <sys/syslog.h>
#include <sys/types.h>
#include <sys/bus.h>
#include <sys/time.h>
#include <sys/kernel.h>


#include <dev/isa/isareg.h>
#include <machine/isa_machdep.h>
#include <shark/shark/sequoia.h>
#include <shark/shark/shark_fiq.h>
#include <arm/cpufunc.h>





/*
** 
** MACROS 
**
*/

/* define registers on sequoia used by pins  */
#define SEQUOIA_1GPIO       PMC_GPCR_REG         /* reg 0x007 gpio 0-3 */      
#define SEQUOIA_2GPIO       SEQ2_OGPIOCR_REG     /* reg 0x304 gpio 4.8 */

/* define pins on sequoia that talk to smart card reader */
#define SCR_DETECT_DIR      GPIOCR2_M_GPIOBDIR0
#define SCR_DETECT          GPIOCR2_M_GPIOBDATA0


#define SCR_POWER_DIR       GPCR_M_GPIODIR0
#define SCR_POWER           GPCR_M_GPIODATA0

#define SCR_RESET_DIR       GPCR_M_GPIODIR1
#define SCR_RESET           GPCR_M_GPIODATA1

#define SCR_CLOCK_DIR       OGPIOCR_M_GPIODIR6
#define SCR_CLOCK           OGPIOCR_M_GPIODATA6

#define SCR_DATA_IN_DIR     GPCR_M_GPIODIR2
#define SCR_DATA_IN         GPCR_M_GPIODATA2

#define SCR_DATA_OUT_DIR    OGPIOCR_M_GPIODIR5
#define SCR_DATA_OUT        OGPIOCR_M_GPIODATA5

#define SCR_BUGA_DIR        OGPIOCR_M_GPIODIR4
#define SCR_BUGA            OGPIOCR_M_GPIODATA4

#define SCR_BUGB_DIR        OGPIOCR_M_GPIODIR7
#define SCR_BUGB            OGPIOCR_M_GPIODATA7

                                 

/* define pins on sequoia that talk to leds */
#define LED_BILED_YELLOW_BIT    FOMPCR_M_PCON5
#define LED_BILED_GREEN_BIT     FOMPCR_M_PCON6

#define LED_DEBUG_YELLOW_BIT    FOMPCR_M_PCON7
#define LED_DEBUG_GREEN_BIT     FOMPCR_M_PCON8


/* define biled colors */
#define  LED_BILED_NONE     0
#define  LED_BILED_GREEN    1
#define  LED_BILED_YELLOW   2
#define  LED_BILED_RED      3

    
#define LED_TIMEOUT    hz / 20                       /* 20 times a second */
#define LED_NET_ACTIVE (1000000/hz) * LED_TIMEOUT   /* delay in us for net activity */
      
    
    

/*
**
** DATA
**
*/
static bus_space_handle_t sequoia_ioh;

static struct timeval ledLastActive;      /* last time we get net activity */
static int      ledColor;           /* present color of led */
static int      ledBlockCount;      /* reference count of block calles */                            
int sequoia_index_cache = -1;       /* set to silly value so that we dont cache on init */

static callout_t led_timo_ch;

/*
**
** FUNCITONAL PROTOTYPES
**
*/
static void ledSetBiled(int color);
static void ledTimeout(void *arg);

/*
** 
** FUNCITONS
**
*/
void sequoiaInit(void)
{
    u_int16_t  seqReg;

    callout_init(&led_timo_ch, 0);

    /* map the sequoi registers */
    if (bus_space_map(&isa_io_bs_tag, SEQUOIA_BASE, SEQUOIA_NPORTS, 0,  &sequoia_ioh))
    {
        panic("SequoiaInit: io mapping failed");
    }

    /*
    **
    ** setup the pins associated with the X server
    **
    */
    /* seems power on sets them correctly */



    /*
    ** setup the pins associated with the led
    */
    sequoiaRead(SEQR_SEQPSR1_REG,&seqReg);
    SET(seqReg,SEQPSR1_M_TAGDEN);           /* enable pc[4:9] */
    sequoiaWrite(SEQR_SEQPSR1_REG,seqReg);

    
    sequoiaRead(SEQR_SEQPSR3_REG,&seqReg);
    CLR(seqReg,SEQPSR3_M_PC5PINEN);      /* enable pc5, biled */
    CLR(seqReg,SEQPSR3_M_PC6PINEN);      /* enable pc6, biled */
    CLR(seqReg,SEQPSR3_M_PC7PINEN);      /* enable pc7, debug led yellow */
    CLR(seqReg,SEQPSR3_M_PC8PINEN);      /* enable pc8, debug led green  */
    sequoiaWrite(SEQR_SEQPSR3_REG,seqReg);
    
    sequoiaRead (PMC_FOMPCR_REG, &seqReg);
    CLR(seqReg,LED_BILED_YELLOW_BIT);
    CLR(seqReg,LED_BILED_GREEN_BIT);
    SET(seqReg,LED_DEBUG_YELLOW_BIT);
    CLR(seqReg,LED_DEBUG_GREEN_BIT);
    sequoiaWrite(PMC_FOMPCR_REG, seqReg);

    
    /* setup the biled info */
    ledColor = LED_BILED_GREEN;
    ledLastActive.tv_usec = 0;
    ledLastActive.tv_sec = 0;
    ledBlockCount = 0;
    callout_reset(&led_timo_ch, LED_TIMEOUT, ledTimeout, NULL);
    /* 
    ** 
    ** setup the pins associated with the smart card reader *
    **
    */
    /* sequoia 1 direction & data */

    sequoiaRead(SEQUOIA_1GPIO,&seqReg);

    SET(seqReg,SCR_POWER_DIR);      /* output */
    SET(seqReg,SCR_RESET_DIR); /* output */
    CLR(seqReg,SCR_DATA_IN_DIR);        /* input */

    CLR(seqReg,SCR_POWER);          /* 0V to card */
    SET(seqReg,SCR_RESET);          /* 0V to card */

    sequoiaWrite(SEQUOIA_1GPIO,seqReg);


    

    /* sequoia 2 pin enables */
    sequoiaRead(SEQ2_SEQ2PSR_REG,&seqReg);

    SET(seqReg,SEQ2PSR_M_DPBUSEN);
    CLR(seqReg,SEQ2PSR_M_GPIOPINEN);

    sequoiaWrite(SEQ2_SEQ2PSR_REG,seqReg);



    /* sequoia 2 direction & data */
    sequoiaRead(SEQUOIA_2GPIO,&seqReg);

    SET(seqReg,SCR_BUGA_DIR);       /* output */
    SET(seqReg,SCR_DATA_OUT_DIR);   /* output */
    SET(seqReg,SCR_CLOCK_DIR);      /* output */
    SET(seqReg,SCR_BUGB_DIR);       /* output */

    CLR(seqReg,SCR_BUGA);           /* 0 */
    CLR(seqReg,SCR_BUGB);           /* 0 */
    CLR(seqReg,SCR_CLOCK);           /* 0 */
    sequoiaWrite(SEQUOIA_2GPIO,seqReg);

     /* setup the wak0 pin to be detect */
    sequoiaRead(SEQR_SEQPSR2_REG,&seqReg);

    SET(seqReg,SEQPSR2_M_DIRTYPINEN);
    SET(seqReg,SEQPSR2_M_GPIOB0PINEN);

    sequoiaWrite(SEQR_SEQPSR2_REG,seqReg);


    sequoiaRead(PMC_GPIOCR2_REG,&seqReg);

    CLR(seqReg,SCR_DETECT_DIR);  /* input */

    sequoiaWrite(PMC_GPIOCR2_REG,seqReg);

    /* don't delay when setting PC bits.  this is particularly important
       for using PC[4] to clear the FIQ. */
    sequoiaRead(PMC_SCCR_REG, &seqReg);
    sequoiaWrite(PMC_SCCR_REG, seqReg | SCCR_M_PCSTGDIS);

}





/* X console functions */
void consXTvOn(void)
{
    u_int16_t savedPSR3;
    u_int16_t savedFMPCR;
    /* 
    ** Switch on TV output on the Sequoia, data indicates mode,
    ** but we are currently hardwired to NTSC, so ignore it.
    */

    sequoiaRead (SEQR_SEQPSR3_REG, &savedPSR3);
    sequoiaWrite(SEQR_SEQPSR3_REG, (savedPSR3 | SEQPSR3_M_PC3PINEN));

    sequoiaRead (PMC_FOMPCR_REG, &savedFMPCR);
    sequoiaWrite(PMC_FOMPCR_REG, (savedFMPCR | FOMPCR_M_PCON3));

}

void consXTvOff(void)
{
    u_int16_t savedPSR3;
    u_int16_t savedFMPCR;
    /* 
    ** Switch off TV output on the Seqoia 
    */
    sequoiaRead (SEQR_SEQPSR3_REG, &savedPSR3);
    sequoiaWrite(SEQR_SEQPSR3_REG, (savedPSR3 & ~SEQPSR3_M_PC3PINEN));

    sequoiaRead (PMC_FOMPCR_REG, &savedFMPCR);
    sequoiaWrite(PMC_FOMPCR_REG, (savedFMPCR & ~FOMPCR_M_PCON3));

}




  /* smart card routines */

int scrGetDetect (void)
{
    int r;
    u_int16_t  seqReg;

    sequoiaRead(PMC_GPIOCR2_REG,&seqReg);

    /* inverse logic, so invert */
    if (ISSET(seqReg,SCR_DETECT))
    {
        r = 0;
    } else
    {
        r = 1;
    }

    return r;
}


void scrSetPower (int value)
{
    u_int16_t  seqReg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif

    sequoiaRead(SEQUOIA_1GPIO,&seqReg);

    if (value)
    {
        SET(seqReg,SCR_POWER);
    } else
    {
        CLR(seqReg,SCR_POWER);
    }
    sequoiaWrite(SEQUOIA_1GPIO,seqReg);

#ifdef SHARK
    restore_interrupts(savedints);
#endif
}

void scrSetClock (int value)
{
    u_int16_t  seqReg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif

    sequoiaRead(SEQUOIA_2GPIO,&seqReg);

    if (value)
    {
        SET(seqReg,SCR_CLOCK);
    } else
    {
        CLR(seqReg,SCR_CLOCK);
    }
    sequoiaWrite(SEQUOIA_2GPIO,seqReg);
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}

void scrSetReset (int value)
{
    u_int16_t  seqReg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif

    sequoiaRead(SEQUOIA_1GPIO,&seqReg);

    if (value)                         
    {
        SET(seqReg,SCR_RESET);
    } else
    {
        CLR(seqReg,SCR_RESET);
    }
    sequoiaWrite(SEQUOIA_1GPIO,seqReg);

#ifdef SHARK
    restore_interrupts(savedints);
#endif
}


void scrSetDataHighZ (void)
{
    u_int16_t  seqReg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif

    sequoiaRead(SEQUOIA_2GPIO,&seqReg);

    /* set data to 5V, io pin is inverse logic */
    CLR(seqReg,SCR_DATA_OUT);

    sequoiaWrite(SEQUOIA_2GPIO,seqReg);
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}

void scrSetData (int value) 
{
    u_int16_t  seqReg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif

    sequoiaRead(SEQUOIA_2GPIO,&seqReg);
    /* inverse logic */
    if (value )
    {
        CLR(seqReg,SCR_DATA_OUT);
    } else
    {
        SET(seqReg,SCR_DATA_OUT);
    }
    sequoiaWrite(SEQUOIA_2GPIO,seqReg);
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}

int  scrGetData (void)
{
    int r;
    u_int16_t  seqReg;

    sequoiaRead(SEQUOIA_1GPIO,&seqReg);

    if (ISSET(seqReg,SCR_DATA_IN))
    {
        r = 1;
    } else
    {
        r = 0;
    }
    return r;
}








void ledNetActive (void)
{
    getmicrotime(&ledLastActive);
}

void ledNetBlock    (void)
{
    ledBlockCount++;
}

void ledNetUnblock  (void)
{
    ledBlockCount--;
}

void ledPanic       (void)
{
    /* we are in panic, timeout wont happen, so set led */
    ledSetBiled(LED_BILED_RED);
}

static void   ledTimeout(void *arg)
{
    int timeSpan;   /* in usec */
    struct timeval now;

    getmicrotime(&now);
    if(now.tv_sec == ledLastActive.tv_sec)
    {
        timeSpan = now.tv_usec -  ledLastActive.tv_usec;
    }
    
    else if (now.tv_sec - 10  < ledLastActive.tv_sec) /* stop rollover problems */
    {
        timeSpan = (1000000 + now.tv_usec) -  ledLastActive.tv_usec;
    }

    else
    {
        timeSpan =  LED_NET_ACTIVE * 2; /* ie big number */
    }
    
        
    
    /* check if we are blocked */
    if(ledBlockCount)
    {
        if(ledColor == LED_BILED_YELLOW)
        {
            ledSetBiled(LED_BILED_NONE);
        }
        else
        {
            ledSetBiled(LED_BILED_YELLOW);
        }
    }


    /* check if we have network activity */
    else if (timeSpan < LED_NET_ACTIVE)
    {
        if(ledColor == LED_BILED_GREEN)
        {
            ledSetBiled(LED_BILED_NONE);
        }
        else
        {
            ledSetBiled(LED_BILED_GREEN);
        }
    }

    /* normal operating mode */        
    else
    {
        if(ledColor != LED_BILED_GREEN)
        {
            ledSetBiled(LED_BILED_GREEN);
        }
    }

    /* resubmint the timeout */
    callout_reset(&led_timo_ch, LED_TIMEOUT, ledTimeout, NULL);

}


static void ledSetBiled(int color)
{
    u_int16_t  seqReg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif
    ledColor = color;


    sequoiaRead (PMC_FOMPCR_REG, &seqReg);
    switch(color)
    {
        case LED_BILED_NONE:
            SET(seqReg,LED_BILED_YELLOW_BIT);
            SET(seqReg,LED_BILED_GREEN_BIT);
            break;
    
        case LED_BILED_YELLOW:
            CLR(seqReg,LED_BILED_YELLOW_BIT);
            SET(seqReg,LED_BILED_GREEN_BIT);
            break;
    
        case LED_BILED_GREEN:
            SET(seqReg,LED_BILED_YELLOW_BIT);
            CLR(seqReg,LED_BILED_GREEN_BIT);
            break;
    
        case LED_BILED_RED:
            CLR(seqReg,LED_BILED_YELLOW_BIT);
            CLR(seqReg,LED_BILED_GREEN_BIT);
            break;
    
        default:
            panic("invalid color %x",color);
            break;
    }
    sequoiaWrite(PMC_FOMPCR_REG, seqReg);
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}


int hwGetRev(void)
{
    u_int16_t  seqReg;

    sequoiaRead(SR_POR_REG,&seqReg);
    
    seqReg = seqReg >> POR_V_MISCCF0;
    seqReg = seqReg & 0x7;

    return seqReg;
}





/* routines to read/write to sequoia registers */
void sequoiaWrite(int reg,u_int16_t  seqReg)     
{   
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif

    /*
       On SHARK, the fiq comes from the pmi/smi.  After receiving
       a FIQ, the SMI must be cleared.  The SMI gets cleared by
       changing to sleep mode, thereby lowering PC[4]. */
    // need to do the right thing with the cache if this is going to work */
    if (reg == PMC_FOMPCR_REG) {
      bus_space_write_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_INDEX_OFFSET,reg);
      bus_space_write_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_DATA_OFFSET,
			seqReg | (FOMPCR_M_PCON4));
      bus_space_write_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_INDEX_OFFSET,
			PMC_SLPMPCR_REG);
      bus_space_write_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_DATA_OFFSET,
			seqReg & ~(SLPMPCR_M_PCSLP4));
      sequoia_index_cache = PMC_SLPMPCR_REG;
    } else {
      /* normal case: just do the write */
      if(sequoia_index_cache != reg)
      {
        sequoia_index_cache = reg;
        bus_space_write_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_INDEX_OFFSET,reg);
      }
      bus_space_write_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_DATA_OFFSET,seqReg);
    }
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}

void sequoiaRead (int reg,u_int16_t * seqReg_ptr)     
{
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif
    if(sequoia_index_cache != reg)
    {
        sequoia_index_cache = reg;
        bus_space_write_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_INDEX_OFFSET,reg);
    }
    *seqReg_ptr = bus_space_read_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_DATA_OFFSET);
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}


void ledSetDebug(int command)
{
    u_int16_t  seqReg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif
    sequoiaRead (PMC_FOMPCR_REG, &seqReg);


    switch (command) 
    {
        case LED_DEBUG_STATE_0:    
            CLR(seqReg,LED_DEBUG_YELLOW_BIT);
            CLR(seqReg,LED_DEBUG_GREEN_BIT);
            break;

        case LED_DEBUG_STATE_1:
            SET(seqReg,LED_DEBUG_YELLOW_BIT);
            CLR(seqReg,LED_DEBUG_GREEN_BIT);
            break;

        case LED_DEBUG_STATE_2:
            CLR(seqReg,LED_DEBUG_YELLOW_BIT);
            SET(seqReg,LED_DEBUG_GREEN_BIT);
            break;

        case LED_DEBUG_STATE_3:
            SET(seqReg,LED_DEBUG_YELLOW_BIT);
            SET(seqReg,LED_DEBUG_GREEN_BIT);
            break;

        case LED_DEBUG_YELLOW_ON:
            SET(seqReg,LED_DEBUG_YELLOW_BIT);
            break;

        case LED_DEBUG_YELLOW_OFF:
            CLR(seqReg,LED_DEBUG_YELLOW_BIT);
            break;

        case LED_DEBUG_GREEN_ON:
            SET(seqReg,LED_DEBUG_GREEN_BIT);
            break;

        case LED_DEBUG_GREEN_OFF:
            CLR(seqReg,LED_DEBUG_GREEN_BIT);
            break;

        default:
            panic("ledSetDebug: invalid command %d",command);
            break;
    }
    sequoiaWrite(PMC_FOMPCR_REG, seqReg);
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}


#ifdef USEFULL_DEBUG  
void sequoiaOneAccess(void)
{
u_int16_t reg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif
    reg = bus_space_read_2(&isa_io_bs_tag,sequoia_ioh,SEQUOIA_DATA_OFFSET);
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}
#endif

int testPin=0;
void scrToggleTestPin (void)
{
    u_int16_t  seqReg;
#ifdef SHARK
    u_int savedints;

    savedints = disable_interrupts(I32_bit | F32_bit);
#endif

    sequoiaRead(SEQUOIA_2GPIO,&seqReg);

    if (testPin)
    {
        testPin = 0;
        CLR(seqReg,SCR_BUGA);
    } 
    else
    {
        SET(seqReg,SCR_BUGA);
        testPin = 1;
    }
    sequoiaWrite(SEQUOIA_2GPIO,seqReg);
#ifdef SHARK
    restore_interrupts(savedints);
#endif
}