OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [xscale/] [iq80310/] [v2_0/] [src/] [diag/] [xscale_test.c] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//=============================================================================
2
//
3
//      xscale_test.c - Cyclone Diagnostics
4
//
5
//=============================================================================
6
//####ECOSGPLCOPYRIGHTBEGIN####
7
// -------------------------------------------
8
// This file is part of eCos, the Embedded Configurable Operating System.
9
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
10
//
11
// eCos is free software; you can redistribute it and/or modify it under
12
// the terms of the GNU General Public License as published by the Free
13
// Software Foundation; either version 2 or (at your option) any later version.
14
//
15
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
16
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18
// for more details.
19
//
20
// You should have received a copy of the GNU General Public License along
21
// with eCos; if not, write to the Free Software Foundation, Inc.,
22
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23
//
24
// As a special exception, if other files instantiate templates or use macros
25
// or inline functions from this file, or you compile this file and link it
26
// with other works to produce a work based on this file, this file does not
27
// by itself cause the resulting work to be covered by the GNU General Public
28
// License. However the source code for this file must still be made available
29
// in accordance with section (3) of the GNU General Public License.
30
//
31
// This exception does not invalidate any other reasons why a work based on
32
// this file might be covered by the GNU General Public License.
33
//
34
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
35
// at http://sources.redhat.com/ecos/ecos-license/
36
// -------------------------------------------
37
//####ECOSGPLCOPYRIGHTEND####
38
//=============================================================================
39
//#####DESCRIPTIONBEGIN####
40
//
41
// Author(s):   Scott Coulter, Jeff Frazier, Eric Breeden
42
// Contributors:
43
// Date:        2001-01-25
44
// Purpose:     
45
// Description: 
46
//
47
//####DESCRIPTIONEND####
48
//
49
//===========================================================================*/
50
 
51
/************************************************************************/
52
/* iq80310_test.c - Main diagnostics for IQ80310 board                  */
53
/*                                                                      */
54
/* Modification History                                                 */
55
/* --------------------                                                 */
56
/* 11oct00, ejb, Created for IQ80310 StrongARM2                         */
57
/* 18dec00  jwf                                                         */
58
/* 02feb01  jwf added tests: _coy_tight_loop, cache_loop, LoopMemTest,  */
59
/*              special_mem_test written by snc                         */
60
/* 07feb01  jwf added function calls to a variable delay time generator */
61
/* 09feb01  jwf added function version_info to show version information */
62
/*              about OS, BOARD, CPLD, 80200 ID, 80312 ID.              */
63
/************************************************************************/
64
 
65
#include <redboot.h>
66
#include <cyg/io/pci_hw.h>
67
#include <cyg/io/pci.h>
68
 
69
#include "7_segment_displays.h"
70
#include "test_menu.h"
71
#include "iq80310.h"
72
#include "pci_bios.h"
73
 
74
extern void __disableDCache(void);
75
extern void __enableDCache(void);
76
extern void _enableFiqIrq(void);
77
extern void _usec_delay(void);
78
extern void _msec_delay(void);
79
extern void _enable_timer(void);
80
extern void _disable_timer(void);
81
extern int  xgetchar_timeout(char *ch, int msec);
82
extern char xgetchar(void);
83
 
84
 
85
/* 02/02/01 jwf */
86
extern long decIn(void);
87
extern long hexIn(void);
88
extern void hex32out(unsigned long num);
89
extern char* sgets(char *s);
90
 
91
extern void flash_test(MENU_ARG arg) RAM_FUNC_SECT;
92
 
93
extern STATUS pci_isr_connect (int intline, int bus, int device, int (*handler)(int), int arg);
94
extern STATUS pci_to_xint(int device, int intpin, int *xint);
95
extern void timer_test (MENU_ARG arg);
96
 
97
extern void delay_ms(int msecs);
98
 
99
extern int memTest (long startAddr, long endAddr);
100
 
101
/* 02/02/01 jwf */
102
extern int LoopMemTest (long    startAddr, long endAddr);
103
 
104
extern void uart_test(MENU_ARG arg);
105
extern void pci_ether_test (UINT32 busno, UINT32 devno, UINT32 funcno);
106
extern void config_ints(void);  /* configure interrupts */
107
extern int eeprom_write (unsigned long pci_base, int eeprom_addr, unsigned short *p_data, int nwords);
108
extern int enable_external_interrupt (int int_id);
109
extern int disable_external_interrupt (int int_id);
110
extern int isr_connect(int int_num, void (*handler)(int), int arg);
111
extern int isr_disconnect(int int_num);
112
extern void init_external_timer(void);
113
extern void uninit_external_timer(void);
114
extern int isHost(void);
115
 
116
void pci_int_test (MENU_ARG arg);
117
void hdwr_diag (void);
118
void rotary_switch (MENU_ARG arg);
119
void seven_segment_display (MENU_ARG arg);
120
void backplane_detection(MENU_ARG arg);
121
void battery_status(MENU_ARG arg);
122
void ether_test (MENU_ARG arg);
123
void gpio_test (MENU_ARG arg);
124
 
125
/* 02/02/01 jwf */
126
void static cache_loop (MENU_ARG arg);
127
 
128
/* 02/09/01 jwf */
129
void version_info (MENU_ARG arg);
130
void read_coyanosa_id_reg (void);
131
char board_revision (void);
132
 
133
static void battery_test_menu (MENU_ARG arg);
134
static void battery_test_write (MENU_ARG arg);
135
static void battery_test_read (MENU_ARG arg);
136
 
137
/* 01/11/01 jwf */
138
void select_host_test_system (void);
139
 
140
void internal_timer(MENU_ARG arg);
141
static void enet_setup (MENU_ARG arg);
142
static void memory_tests (MENU_ARG arg);
143
static void repeat_mem_test (MENU_ARG arg);
144
 
145
/* 02/02/01 jwf */
146
static void special_mem_test (MENU_ARG arg);
147
 
148
static void spci_tests (MENU_ARG arg), ppci_tests (MENU_ARG arg);
149
 
150
#define VENDOR_INTEL    0x8086
151
#define INTEL_NAME      "Intel Corporation Inc."
152
 
153
#define I80303_BRIDGE   0x0309
154
#define I80303_NAME0    "80303 PCI-PCI Bridge"
155
 
156
#define I80303_ATU      0x5309
157
#define I80303_NAME1    "80303 Address Translation Unit"
158
 
159
#define I82557          0x1229
160
#define I82557_NAME     "82557/82558/82559 10/100 LAN Controller"
161
 
162
#define I82559ER        0x1209
163
#define I82559ER_NAME   "82559ER 10/100 LAN Controller"
164
 
165
 
166
/* Test Menu Table */
167
static MENU_ITEM testMenu[] = {
168
    {"Memory Tests",                            memory_tests,         0},
169
    {"Repeating Memory Tests",                  repeat_mem_test,      0},
170
    {"16C552 DUART Serial Port Tests",          uart_test,            0},
171
    {"Rotary Switch S1 Test",                   rotary_switch,        0},
172
    {"7 Segment LED Tests",                     seven_segment_display,0},
173
    {"Backplane Detection Test",                backplane_detection,  0},
174
    {"Battery Status Test",                     battery_status,       0},
175
    {"External Timer Test",                     timer_test,           0},
176
#ifdef CYGPKG_IO_FLASH
177
    {"Flash Test",                              flash_test,           0},
178
#endif
179
    {"i82559 Ethernet Configuration",           enet_setup,           0},
180
    {"i82559 Ethernet Test",                    ether_test,           0},
181
    {"i960Rx/303 PCI Interrupt Test",           pci_int_test,         0},
182
    {"Internal Timer Test",                     internal_timer,       0},
183
    {"Secondary PCI Bus Test",                  spci_tests,           0},
184
    {"Primary PCI Bus Test",                    ppci_tests,           0},
185
    {"Battery Backup SDRAM Memory Test",        battery_test_menu,    0},
186
    {"GPIO Test",                               gpio_test,            0},
187
/* 02/02/01 jwf */
188
    {"Repeat-On-Fail Memory Test",              special_mem_test,     0},
189
    {"Coyonosa Cache Loop (No return)",         cache_loop,           0},
190
/* 02/09/01 jwf */
191
    {"Show Software and Hardware Revision",     version_info,         0}
192
};
193
 
194
#define NUM_MENU_ITEMS  (sizeof (testMenu) / sizeof (testMenu[0]))
195
 
196
#define MENU_TITLE      "\n  IQ80310 Hardware Tests"
197
 
198
extern void __reset(void);
199
 
200
void hdwr_diag (void)
201
{
202
    unsigned char* led0 = (unsigned char*)MSB_DISPLAY_REG;
203
    unsigned char* led1 = (unsigned char*)LSB_DISPLAY_REG;
204
 
205
    *led0 = LETTER_S;
206
    *led1 = LETTER_S;
207
 
208
    printf ("Entering Hardware Diagnostics - Disabling Data Cache!\n\n");
209
 
210
    __disableDCache();
211
 
212
    _enableFiqIrq(); /* enable FIQ and IRQ interrupts */
213
 
214
    config_ints();  /* configure interrupts for diagnostics */
215
 
216
    /* 01/11/01 jwf */
217
    select_host_test_system();
218
 
219
    menu (testMenu, NUM_MENU_ITEMS, MENU_TITLE, MENU_OPT_NONE);
220
 
221
    printf ("Exiting Hardware Diagnostics - Reenabling Data Cache!\n\n");
222
 
223
    *led0 = ZERO;
224
    *led1 = ZERO;
225
 
226
    __reset();  /* reset the board so RedBoot starts with a clean slate */
227
}
228
 
229
/* 02/02/01 jwf */
230
static void cache_loop (MENU_ARG arg)
231
{
232
    printf ("Putting Processor in a Tight Loop Forever...\n\n");
233
 
234
    asm ( "0: mov r0,r0\n"
235
          "b 0b\n");
236
    /* not reached */
237
}
238
 
239
 
240
/************************************************/
241
/* Secondary PCI Bus Test                       */
242
/*                                              */
243
/* This test assumes that a IQ80303 eval board  */
244
/* is installed in a secondary PCI slot. This   */
245
/* second board must be configured with 32 Meg  */
246
/* of SDRAM minimum.                            */
247
/*                                              */
248
/************************************************/
249
static void spci_tests (MENU_ARG arg)
250
{
251
    long  start_addr;
252
    long  mem_size;
253
    long  end_addr;
254
    cyg_pci_device_id  devid = CYG_PCI_NULL_DEVID;
255
    int bus, devfn;
256
 
257
    /* Look for ATU on the secondary PCI Bus */
258
    printf("\nLooking for a IQ80303 board on the Secondary PCI bus:\n");
259
    while (TRUE) {
260
        if (cyg_pci_find_device(VENDOR_INTEL, I80303_ATU, &devid)) {
261
            bus = CYG_PCI_DEV_GET_BUS(devid);
262
            devfn = CYG_PCI_DEV_GET_DEVFN(devid);
263
            if (bus != SECONDARY_BUS_NUM)
264
                continue;
265
            printf("An IQ80303 board has been detected: bus[%d] devive[%d] fn[%d].",
266
                   bus, CYG_PCI_DEV_GET_DEV(devfn), CYG_PCI_DEV_GET_FN(devfn));
267
            break;
268
        } else {
269
            printf("No IQ80303 board detected on the SPCI bus!\n");
270
            return;
271
        }
272
    }
273
 
274
    /* read the PCI address which corresponds to the start of DRAM */
275
    cyg_pci_read_config_uint32(devid, 0x10, (UINT32 *)&start_addr);
276
 
277
    /* strip off indicator bits */
278
    start_addr &= 0xfffffff0;
279
 
280
    printf ("i80303 DRAM starts at PCI address 0x%08X\n", start_addr);
281
 
282
    /* skip over 1st Mbyte of target DRAM */
283
    start_addr += 0x100000;
284
 
285
    mem_size = 0x1f00000;
286
    end_addr = start_addr + mem_size;
287
 
288
    printf("\n\nTesting memory from $");
289
    hex32out(start_addr);
290
    printf(" to $");
291
    hex32out(end_addr);
292
    printf(".\n");
293
 
294
    memTest(start_addr, end_addr);
295
    printf("\n");
296
 
297
    printf ("\nMemory test done.\n");
298
    printf ("Press return to continue.\n");
299
    (void) hexIn();
300
}
301
 
302
/************************************************/
303
/* Primary PCI Bus Test                         */
304
/*                                              */
305
/* This test assumes that a IQ80303 eval board  */
306
/* is installed in a primary PCI slot. This     */
307
/* second board must be configured with 32 Meg  */
308
/* of SDRAM minimum.                            */
309
/*                                              */
310
/************************************************/
311
static void ppci_tests (MENU_ARG arg)
312
{
313
    long        start_addr;
314
    long        mem_size;
315
    long        end_addr;
316
    cyg_pci_device_id  devid = CYG_PCI_NULL_DEVID;
317
    int bus, devfn;
318
 
319
    /* check to see if we are the host of the backplane, if not
320
       return an error */
321
    if (isHost() == FALSE) {
322
        printf ("Invalid test configuration, must be PCI host!\n");
323
        return;
324
    }
325
 
326
    /* Look for ATU on the primary PCI Bus */
327
    printf("\nLooking for a IQ80303 board on the Primary PCI bus:\n");
328
    while (TRUE) {
329
        if (cyg_pci_find_device(VENDOR_INTEL, I80303_ATU, &devid)) {
330
            bus = CYG_PCI_DEV_GET_BUS(devid);
331
            devfn = CYG_PCI_DEV_GET_DEVFN(devid);
332
            if (bus != PRIMARY_BUS_NUM)
333
                continue;
334
            printf("An IQ80303 board has been detected: bus[%d] devive[%d] fn[%d].",
335
                   bus, CYG_PCI_DEV_GET_DEV(devfn), CYG_PCI_DEV_GET_FN(devfn));
336
            break;
337
        } else {
338
            printf("No IQ80303 board detected on the PPCI bus!\n");
339
            return;
340
        }
341
    }
342
 
343
    /* read the PCI address which corresponds to the start of DRAM */
344
    cyg_pci_read_config_uint32(devid, 0x10, (UINT32 *)&start_addr);
345
 
346
    /* strip off indicator bits */
347
    start_addr &= 0xfffffff0;
348
 
349
    printf ("i80303 DRAM starts at PCI address 0x%08X\n", start_addr);
350
 
351
    /* skip over 1st Mbyte of target DRAM */
352
    start_addr += 0x100000;
353
 
354
    mem_size = 0x1f00000;
355
    end_addr = start_addr + mem_size;
356
 
357
    printf("\n\nTesting memory from $");
358
    hex32out(start_addr);
359
    printf(" to $");
360
    hex32out(end_addr);
361
    printf(".\n");
362
 
363
    memTest(start_addr, end_addr);
364
    printf("\n");
365
 
366
    printf ("\nMemory test done.\n");
367
    printf ("Press return to continue.\n");
368
    (void) hexIn();
369
}
370
 
371
 
372
/*****************************************************************************
373
* memory_tests - Basic Memory Tests
374
*
375
* Memory tests can be run one of two ways - with the cache turned OFF to test
376
* physical memory, or with cache turned ON to test the caching
377
*/
378
static void memory_tests (MENU_ARG arg)
379
{
380
    long        start_addr;
381
    long        mem_size;
382
    long        end_addr;
383
 
384
    printf ("Base address of memory to test (in hex): ");
385
    start_addr = hexIn();
386
    printf("\n");
387
    printf ("Size of memory to test (in hex): ");
388
    mem_size = hexIn();
389
    printf("\n");
390
    end_addr = start_addr + mem_size;
391
 
392
    printf("Testing memory from $");
393
    hex32out(start_addr);
394
    printf(" to $");
395
    hex32out(end_addr);
396
    printf(".\n");
397
    memTest(start_addr, end_addr);
398
    printf("\n");
399
 
400
    printf ("\nMemory test done.\n");
401
    printf ("Press return to continue.\n");
402
    (void) xgetchar();
403
}
404
 
405
 
406
/*****************************************************************************
407
* repeat_mem_test - Repeating Memory Tests
408
*
409
*/
410
static void repeat_mem_test (MENU_ARG arg)
411
{
412
    unsigned long start_addr, mem_size, end_addr;
413
    char        cache_disable[10];
414
 
415
    printf ("Turn off Data Cache? (y/n): ");
416
    sgets (cache_disable);
417
    printf ("\n");
418
    printf ("Base address of memory to test (in hex): ");
419
    start_addr = hexIn();
420
    printf("\n");
421
    printf ("Size of memory to test (in hex): ");
422
    mem_size = hexIn();
423
    printf("\n");
424
    end_addr = start_addr + mem_size;
425
    printf("Testing memory from $");
426
    hex32out(start_addr);
427
    printf(" to $");
428
    hex32out(end_addr);
429
    while (memTest (start_addr, end_addr))
430
        ;
431
}
432
 
433
/* 02/02/01 jwf */
434
/*****************************************************************************
435
* special_mem_test - Repeat-On-Fail Memory Test
436
*
437
* Memory tests can be run one of two ways - with the cache turned OFF to test
438
* physical memory, or with cache turned ON to test the caching
439
*/
440
static void special_mem_test (MENU_ARG arg)
441
{
442
    long        start_addr;
443
    long        mem_size;
444
    long        end_addr;
445
 
446
    printf ("Base address of memory to test (in hex): ");
447
    start_addr = hexIn();
448
    printf("\n");
449
    printf ("Size of memory to test (in hex): ");
450
    mem_size = hexIn();
451
    printf("\n");
452
    end_addr = start_addr + mem_size;
453
 
454
    printf("Testing memory from $");
455
    hex32out(start_addr);
456
    printf(" to $");
457
    hex32out(end_addr);
458
    printf(".\n");
459
    LoopMemTest(start_addr, end_addr);
460
    printf("\n");
461
 
462
    printf ("\nMemory test done.\n");
463
    printf ("Press return to continue.\n");
464
    (void) xgetchar();
465
}
466
 
467
const unsigned char SevSegDecode[] = {
468
    ZERO, ONE, TWO, THREE, FOUR,
469
    FIVE, SIX, SEVEN, EIGHT, NINE,
470
    LETTER_A, LETTER_B, LETTER_C, LETTER_D,
471
    LETTER_E, LETTER_F, DECIMAL_POINT,
472
    DISPLAY_OFF
473
};
474
 
475
/* sequential test for LSD and MSD 7 segment Leds */
476
void seven_segment_display (MENU_ARG arg)
477
{
478
    int DisplaySequence;
479
    int SelectLed;
480
 
481
    *MSB_DISPLAY_REG = DISPLAY_OFF;     /* blank MSD 7 segment LEDS */
482
    *LSB_DISPLAY_REG = DISPLAY_OFF;     /* blank LSD 7 segment LEDS  */
483
 
484
    SelectLed=0; /* initialize 7 segment LED selection */
485
 
486
    do {
487
        /* run test data sequence for a 7 segment LED */
488
        for (DisplaySequence = 0; DisplaySequence <= 17; ++DisplaySequence) {
489
 
490
            /* display test data on selected 7 segment LED */
491
            /* the test data sequence for a 7 segment led will be seen as:*/
492
            /* 0 1 2 3 4 5 6 7 8 9 A b C d e F . */
493
            if (SelectLed)
494
                *MSB_DISPLAY_REG = SevSegDecode[DisplaySequence];
495
            else
496
                *LSB_DISPLAY_REG = SevSegDecode[DisplaySequence];
497
 
498
            delay_ms(400);
499
 
500
        } /* end for(DisplaySequence~) */
501
        ++SelectLed;    /* select next 7 segment LED */
502
    } while (SelectLed < 2);     /* tests a pair of 7 segment LEDs */
503
 
504
    *MSB_DISPLAY_REG = LETTER_S;
505
    *LSB_DISPLAY_REG = LETTER_S;
506
}
507
 
508
 
509
/* 12/18/00 jwf */
510
/* tests rotary switch status, S1 positions 0-3, a 2 bit output code */
511
void rotary_switch (MENU_ARG arg)
512
{
513
    const unsigned char MAX_SWITCH_SAMPLES = 9;
514
    unsigned char RotarySwitch[MAX_SWITCH_SAMPLES];
515
    unsigned char index;           /* index for Rotary Switch array */
516
    unsigned char debounce;        /* keeps tally of equal rotary switch data reads in a loop */
517
    char ch;
518
 
519
    *MSB_DISPLAY_REG = DISPLAY_OFF;
520
    *MSB_DISPLAY_REG = DISPLAY_OFF;
521
 
522
    printf("\n\nThe 7-Segment LSD LED shows the Rotary Switch position selected, i.e., 0-F.");
523
    printf("\n\nSlowly dial the Rotary Switch through each position 0-F and confirm reading.");
524
 
525
    printf( "\n\nStrike <CR> to exit this test." );
526
    do {
527
        do {    /* debounce the switch contacts */
528
            for (index = 0; index <= MAX_SWITCH_SAMPLES; index++) {
529
                /* read rotary switch code */
530
                RotarySwitch[index] = *(volatile unsigned char *)0xfe8d0000;
531
                RotarySwitch[index] &= 0x0f;
532
            }
533
            debounce = 0;
534
            for (index = 1; index <= MAX_SWITCH_SAMPLES; index++)
535
                if (RotarySwitch[0] == RotarySwitch[index])
536
                    debounce++;
537
 
538
            /* exit when all rotary switch code readings are equal,
539
               when debounce = MAX_SWITCH_SAMPLES-1 */
540
        } while (debounce < (MAX_SWITCH_SAMPLES - 1));
541
 
542
        /* display the rotary switch position on the 7 segment LSD LED as: 0, 1, 2, 3 */
543
        *LSB_DISPLAY_REG = SevSegDecode[RotarySwitch[0]];
544
 
545
    } while (!xgetchar_timeout(&ch, 200) || ch != 0x0d); /* run until User types a <CR> to exit */
546
 
547
    *MSB_DISPLAY_REG = LETTER_S;
548
    *LSB_DISPLAY_REG = LETTER_S;
549
 
550
}
551
 
552
 
553
/* test backplane detection, connector socket J19 pin 7 */
554
/* BP_DET#=0, no backplane */
555
/* BP_DET#=1, backplane installed */
556
/* b0 <--> BP_DET# */
557
void backplane_detection(MENU_ARG arg)
558
{
559
    unsigned char BpDetStatus;  /* L = pci700 board installed on backplane */
560
 
561
    BpDetStatus = *( unsigned char * ) 0xfe870000;      /* read backplane detection status port */
562
 
563
    BpDetStatus &= 0x01;                /* isolate bit b0 */
564
 
565
    /* examine bit 0 */
566
    switch( BpDetStatus ) {
567
    case 0x00:          /* BpDetStatus = !(BP_DET#=1) = 0 */
568
        printf("\nBackplane detection bit read Low, no backplane installed\n");
569
        printf("\nPlace a jumper across J19.7 to J19.1, then run this test again.\n");
570
        break;
571
 
572
    case 0x01:          /* BpDetStatus = !(BP_DET#=0) = 1 */
573
        printf("\nBackplane detection bit read High, 1 backplane detected.\n");
574
        printf("\nRemove jumper from J19\n");
575
        break;
576
 
577
    default:
578
        break;
579
    }
580
 
581
    /* 12/18/00 jwf */
582
    printf ("\n\nStrike <CR> to exit this test.\n\n");
583
    hexIn();
584
}
585
 
586
 
587
/* test battery status */
588
/* b0 - !(BATT_PRES#=0). A battery is installed.*/
589
/* b1 - BATT_CHRG=1. The battery is fully charged. */
590
/* b2 - BATT_DISCHRG=1. The battery is fully discharged. */
591
void battery_status(MENU_ARG arg)
592
{
593
    unsigned char BatteryStatus;
594
 
595
    BatteryStatus = *(unsigned char *)0xfe8f0000;       /* read battery status port */
596
 
597
    /* examine bit b0 BATT_PRES# */
598
    if (BatteryStatus & 0x01)   /* TestBit=!(BATT_PRES#=0)=1 */
599
        printf("\nBATT_PRES#=0. A battery was detected.\n");
600
    else
601
        printf("\nBATT_PRES#=1. No battery installed.\n");
602
 
603
    /* examine bit b1 BATT_CHRG */
604
    if (BatteryStatus & 0x02)   /* BATT_CHRG=1 */
605
        printf("\nBATT_CHRG=1. Battery is fully charged.\n");
606
    else                        /* BATT_CHRG=0 */
607
        printf("\nBATT_CHRG=0. Battery is charging.\n");
608
 
609
    /* examine bit b2 BATT_DISCHRG */
610
    if (BatteryStatus & 0x04)
611
        printf("\nBATT_DISCHRG=1. Battery is fully discharged.\n");
612
    else
613
        printf("\nBATT_DISCHRG=0. Battery voltage measures with in normal operating range.\n");
614
 
615
    printf ("\n\nStrike <CR> to exit this test.\n\n");
616
    hexIn();
617
}
618
 
619
 
620
 
621
/* GPIO test */
622
/* Header J16 pin out is: J16.1=b0, J16.3=b1, J16.5=b2, J16.7=b3, J16.9=b4, J16.11=b5, J16.13=b6, J16.15=b7 */
623
/* This test will require use of 2 special test sockets wired as follows for the output and input tests. */
624
/* Intel specifies that each GPIO pin must be pulled down after P_RST# deasserts to swamp out their weak internal active pull up */
625
/* Note that the internal weak active pull up tends to have more of an affect on the GPIO input port rather than the output port */
626
/* Therefore for the input test, jumper J16 pins: 1-2, 3-4, 5-6, 7-8, 9-10, 11-12, 13-14, 15-16, and (TBD) provide an input source for each bit */
627
/* For the output test, jumper J16 pins: 1-2, 3-4, 5-6, 7-8, 9-10, 11-12, 13-14, 15-16 */
628
/* each jumpered pin connects a weak pull down resistor, resident on board, to each GPIO pin */
629
void gpio_test (MENU_ARG arg)
630
{
631
    /*unsigned char GpioInputPort;*/
632
    unsigned char GpioOutputPort;
633
    unsigned char GpioOutputEnablePort;
634
 
635
    /* GPIO output port test */
636
 
637
    printf("\n\nPlug output test socket into header J16, strike 'Enter' to continue" );
638
    while(xgetchar()!=0x0d);
639
 
640
    /* write test data pattern to GPIO Output Enable Register at address 0x0000171c */
641
    *( unsigned char * ) 0x0000171c = 0x55;
642
 
643
    /* read GPIO Output Enable Register from address 0x0000171c */
644
    GpioOutputEnablePort = *( unsigned char * ) 0x0000171c;
645
 
646
    if (GpioOutputEnablePort==0x55)
647
        printf("\nGPIO Output Enable first write/read test PASSED.");
648
    else
649
        printf("\nGPIO Output Enable first write/read test FAILED.");
650
 
651
    /* write test data pattern to GPIO Output Enable Register at address 0x0000171c */
652
    *( unsigned char * ) 0x0000171c = 0xaa;
653
 
654
    /* read GPIO Output Enable Register from address 0x0000171c */
655
    GpioOutputEnablePort = *( unsigned char * ) 0x0000171c;
656
 
657
    if (GpioOutputEnablePort==0xaa)
658
        printf("\nGPIO Output Enable second write/read test PASSED.");
659
    else
660
        printf("\nGPIO Output Enable second write/read test FAILED.");
661
 
662
    /* enable output bits b0-b7, write test pattern to GPIO Output Enable Register */
663
    *( unsigned char * ) 0x0000171c = 0x00;
664
 
665
    /* write test data pattern to GPIO Output Data Register at address 00001724h */
666
    *( unsigned char * ) 0x00001724 = 0x55;
667
 
668
    /* read test data pattern from GPIO Output Data Register at address 00001724h */
669
    GpioOutputPort = *( unsigned char * ) 0x00001724;
670
 
671
    if (GpioOutputPort==0x55)
672
        printf("\nGPIO Output Data Register first write/read test PASSED.");
673
    else
674
        printf("\nGPIO Output Data Register first write/read test FAILED.");
675
 
676
    /* write output data pattern to GPIO Output Data Register at address 00001724h */
677
    *( unsigned char * ) 0x00001724 = 0xaa;
678
 
679
    /* read output data pattern from GPIO Output Data Register at address 00001724h */
680
    GpioOutputPort = *( unsigned char * ) 0x00001724;
681
 
682
    if (GpioOutputPort==0xaa)
683
        printf("\nGPIO Output Data Register second write/read test PASSED.");
684
    else
685
        printf("\nGPIO Output Data Register second write/read test FAILED.");
686
 
687
    printf("\n\nRemove output test socket from header J16, strike 'Enter' to continue" );
688
    while(xgetchar()!=0x0d);
689
}
690
 
691
/* i82559 Ethernet test */
692
void ether_test (MENU_ARG arg)
693
{
694
    cyg_pci_device_id  devid[6];
695
    int unit = 0;
696
    int i, num_enet;
697
 
698
 
699
    for (i = 0, num_enet = 0; i < 6; i++, num_enet++) {
700
        if (i == 0)
701
            devid[0] = CYG_PCI_NULL_DEVID;
702
        else
703
            devid[i] = devid[i-1]; // start from last one found
704
        if (!cyg_pci_find_device(VENDOR_INTEL, I82557, &devid[i]))
705
            break;
706
    }
707
 
708
    for (; i < 6; i++, num_enet++) {
709
        if (i == 0)
710
            devid[0] = CYG_PCI_NULL_DEVID;
711
        else
712
            devid[i] = devid[i-1]; // start from last one found
713
        if (!cyg_pci_find_device(VENDOR_INTEL, I82559ER, &devid[i]))
714
            break;
715
    }
716
 
717
    if (num_enet == 0) {
718
        printf ("No supported Ethernet devices found\n");
719
        return;
720
    }
721
 
722
    printf ("Supported Ethernet Devices:\n\n");
723
 
724
    printf (" Unit#  Bus#  Device#\n");
725
    printf (" -----  ----  -------\n");
726
    for (i = 0; i < num_enet; i++)
727
        printf ("   %d     %d       %d\n", i,
728
                CYG_PCI_DEV_GET_BUS(devid[i]),
729
                CYG_PCI_DEV_GET_DEV(CYG_PCI_DEV_GET_DEVFN(devid[i])));
730
 
731
    printf ("\nEnter the unit number to test : ");
732
    unit = decIn();
733
    printf ("\n");
734
 
735
    pci_ether_test (CYG_PCI_DEV_GET_BUS(devid[unit]),
736
                    CYG_PCI_DEV_GET_DEV(CYG_PCI_DEV_GET_DEVFN(devid[unit])),
737
                    CYG_PCI_DEV_GET_FN(CYG_PCI_DEV_GET_DEVFN(devid[unit])));
738
}
739
 
740
 
741
 
742
 
743
/* Setup Serial EEPROM for Ethernet Configuration */
744
static void enet_setup (MENU_ARG arg)
745
{
746
    UINT32 adapter_ptr;   /* Ptr to PCI Ethernet adapter */
747
    cyg_pci_device_id  devid;
748
 
749
    UINT16 eepromData[3] = {
750
                0x4801,         /* Valid EEPROM, No Expansion ROM, Rev = ?, PHY Addr = 1 */
751
                0x0700,         /* Subsystem Id                 - PCI700 */
752
                0x113c          /* Subsystem Vendor Id  - Cyclone Microsystems */
753
    };
754
    int config_data_offset = 0x0a;      /* offset into EEPROM for config. data storage */
755
    int ia_offset = 0x00;                       /* offset into EEPROM for IA storage */
756
    UINT8  buffer[6];                           /* temporary storage for IA */
757
    UINT16 temp_node_addr[3] = {0,0,0};
758
    UINT16 serial_no;
759
    UINT8  revision_id = 0, port_id = 0;
760
    char rev_string[8];
761
 
762
    /* Cyclone identifier */
763
    buffer[0] = 0x00;
764
    buffer[1] = 0x80;
765
    buffer[2] = 0x4D;
766
    buffer[3] = 0x46;    /* board identifier - PCI700 = 70 = 0x46 */
767
 
768
    serial_no = 10000;
769
    while (serial_no >= 10000) {
770
        printf ("\nEnter the board serial number (1 - 9999): ");
771
        serial_no = decIn();
772
        printf ("\n");
773
    }
774
    revision_id = 8;
775
    while ((revision_id < 1) || (revision_id > 7)) {
776
        printf ("\nEnter the board revison (A - G)      : ");
777
        sgets (rev_string);
778
        rev_string[0] = (rev_string[0] & 0xdf);           /* convert to upper case */
779
        revision_id = (rev_string[0] - 'A') + 1; /* convert to a number 1 - 7 */
780
        printf ("\n");
781
    }
782
    revision_id &= 0x7;
783
    eepromData[0] |= (revision_id << 8); /* add the rev. id to data */
784
 
785
    /* we only want to set up on-board 559 */
786
    devid = CYG_PCI_DEV_MAKE_ID(2, CYG_PCI_DEV_MAKE_DEVFN(0,0));
787
    /* Get the PCI Base Address for mem. runtime registers */
788
    cyg_pci_read_config_uint32(devid, 0x10, &adapter_ptr);
789
 
790
    /* strip off indicator bits */
791
    adapter_ptr = adapter_ptr & 0xfffffff0;
792
 
793
    printf ("Writing the Configuration Data to the Serial EEPROM... ");
794
    if (eeprom_write (adapter_ptr,config_data_offset,eepromData,3) != OK) {
795
        printf ("Error writing the Configuration Data to Serial EEPROM\n");
796
        return;
797
    }
798
    printf ("Done\n");
799
 
800
    /* setup node's Ethernet address */
801
    port_id = ((0 << 6) & 0xc0); /* two bits of port number ID */
802
    buffer[4] = (UINT8) (((serial_no & 0x3FFF) >> 8) | port_id);
803
    buffer[5] = (UINT8) (serial_no & 0x00FF);
804
 
805
    temp_node_addr[0] = (UINT16) ((buffer[1] << 8) + buffer[0]);
806
    temp_node_addr[1] = (UINT16) ((buffer[3] << 8) + buffer[2]);
807
    temp_node_addr[2] = (UINT16) ((buffer[5] << 8) + buffer[4]);
808
 
809
    printf ("Writing the Individual Address to the Serial EEPROM... ");
810
    if (eeprom_write (adapter_ptr,ia_offset,temp_node_addr,3) != OK) {
811
        printf ("\nError writing the IA address to Serial EEPROM.\n");
812
        return;
813
    }
814
    printf ("Done\n");
815
 
816
    /* now that we have finished writing the configuration data, we must ask the
817
       operator to reset the PCI916 to have the configuration changes take effect.
818
       After the reset, the standard Enet. port diagnostics can be run on the 916
819
       under test */
820
 
821
    printf ("\n\n******** Reset the IQ80310 Now to Have Changes Take Effect ********\n\n");
822
 
823
    /* wait forever as a reset will bring us back */
824
    while ((volatile int)TRUE)
825
        ;
826
}
827
 
828
 
829
 
830
/* use the clock in the Performance Monitoring Unit to do delays */
831
void polled_delay (int usec)
832
{
833
    volatile int i;
834
 
835
    _enable_timer();
836
 
837
    for (i = 0; i < usec; i++)
838
        _usec_delay();
839
 
840
    _disable_timer();
841
}
842
 
843
 
844
 
845
void internal_timer(MENU_ARG arg)
846
{
847
    int j, i;
848
 
849
    printf ("\n");
850
 
851
    _enable_timer();
852
 
853
    printf ("Timer enabled...\n");
854
 
855
    for (j = 0; j < 20; j++) {
856
        printf (".");
857
        for (i = 0; i < 1000; i++)
858
            _msec_delay();
859
    }
860
 
861
    _disable_timer();
862
 
863
    printf ("\nTimer disabled...\n");
864
}
865
 
866
 
867
#define I80960RP_BRIDGE         0x0960
868
#define I80960RP_NAME0          "80960RP PCI-PCI Bridge"
869
 
870
#define I80960RP_ATU            0x1960
871
#define I80960RP_NAME1          "80960RP Address Translation Unit"
872
 
873
#define I80960RM_BRIDGE         0x0962
874
#define I80960RM_NAME0          "80960RM PCI-PCI Bridge"
875
 
876
#define I80960RM_ATU            0x1962
877
#define I80960RM_NAME1          "80960RM Address Translation Unit"
878
 
879
#define I80960RN_BRIDGE         0x0964
880
#define I80960RN_NAME0          "80960RN PCI-PCI Bridge"
881
 
882
#define I80960RN_ATU            0x1964
883
#define I80960RN_NAME1          "80960RN Address Translation Unit"
884
 
885
#define I80303_BRIDGE           0x0309
886
#define I80303_NAME0            "80303 PCI-PCI Bridge"
887
 
888
#define I80303_ATU              0x5309
889
#define I80303_NAME1            "80303 Address Translation Unit"
890
 
891
 
892
 
893
/******************************************************************/
894
/* The following functions are all part of the PCI Interrupt Test */
895
/******************************************************************/
896
/* definitions pertaining to PCI interrupt test */
897
#define MAX_I960RX 31
898
typedef struct
899
{
900
        UINT32 device_id;
901
        UINT32 busno;
902
        UINT32 devno;
903
        UINT32 funcno;
904
} I960RX_DEVICES;
905
I960RX_DEVICES i960Rx_devices[MAX_I960RX];
906
UINT32 num_rx_devices = 0;
907
UINT32  messagingUnitBase = (UINT32)NULL;
908
 
909
/* Outbound Interrupt Status Register bits */
910
#define OB_STAT_INTA    (1 << 4)
911
#define OB_STAT_INTB    (1 << 5)
912
#define OB_STAT_INTC    (1 << 6)
913
#define OB_STAT_INTD    (1 << 7)
914
 
915
/* Outbound Doorbell Register bits */
916
#define OB_DBELL_INTA   (1 << 28)
917
#define OB_DBELL_INTB   (1 << 29)
918
#define OB_DBELL_INTC   (1 << 30)
919
#define OB_DBELL_INTD   (1 << 31)
920
 
921
/***********************************************************************
922
*
923
* line_to_string - Returns name as string of particular XINT number
924
*
925
*/
926
static char *line_to_string (int intline)
927
{
928
    switch (intline) {
929
    case XINT0: return("XINT0");
930
    case XINT1: return("XINT1");
931
    case XINT2: return("XINT2");
932
    case XINT3: return("XINT3");
933
    default:    return("ERROR");
934
    }
935
}
936
 
937
 
938
/***************************************************************************
939
*
940
* PCI_IntHandler - Interrupt handler for PCI interrupt test
941
*
942
* Used to verify that an interrupt was recieved during the PCI interrupt
943
* test by the IQ80310 from the add-in i960Rx board.  This handler prints out
944
* which interrupt was recieved, and then clears the interrupt by clearing
945
* the doorbell register on the i960Rx card.
946
*
947
*/
948
int PCI_IntHandler (int IntPin)
949
{
950
    UINT32 *OutboundDbReg        = (UINT32 *)(messagingUnitBase + 0x2c);
951
    UINT32 *OutboundIstatReg = (UINT32 *)(messagingUnitBase + 0x30);
952
 
953
    switch (IntPin) {
954
    case INTA:
955
 
956
        /* check to see if we are looking at the correct interrupt */
957
        if (!(*OutboundIstatReg & OB_STAT_INTA)) {
958
            return (0);
959
        } else {
960
            printf ("PCI INTA generated/received\n\n");
961
            printf ("OISR OK!\n");
962
            printf ("OISR = 0x%X\n", *OutboundIstatReg);
963
            printf ("**** PCI INTA Success ****\n\n");
964
            *OutboundDbReg |= OB_DBELL_INTA;            /* try to clear specific source */
965
            return (1);
966
        }
967
        break;
968
 
969
    case INTB:
970
        /* check to see if we are looking at the correct interrupt */
971
        if (!(*OutboundIstatReg & OB_STAT_INTB)) {
972
            return (0);
973
        } else {
974
            printf ("PCI INTB generated/received\n\n");
975
            printf ("OISR OK!\n");
976
            printf ("OISR = 0x%X\n", *OutboundIstatReg);
977
            printf ("**** PCI INTB Success ****\n\n");
978
            *OutboundDbReg |= OB_DBELL_INTB;            /* try to clear specific source */
979
            return (1);
980
        }
981
 
982
        break;
983
 
984
    case INTC:
985
        /* check to see if we are looking at the correct interrupt */
986
        if (!(*OutboundIstatReg & OB_STAT_INTC)) {
987
            return (0);
988
        } else {
989
            printf ("PCI INTC generated/received\n\n");
990
            printf ("OISR OK!\n");
991
            printf ("OISR = 0x%X\n", *OutboundIstatReg);
992
            printf ("**** PCI INTC Success ****\n\n");
993
            *OutboundDbReg |= OB_DBELL_INTC;            /* try to clear specific source */
994
            return (1);
995
        }
996
 
997
        break;
998
 
999
    case INTD:
1000
        /* check to see if we are looking at the correct interrupt */
1001
        if (!(*OutboundIstatReg & OB_STAT_INTD)) {
1002
            return (0);
1003
        } else {
1004
            printf ("PCI INTD generated/received\n\n");
1005
            printf ("OISR OK!\n");
1006
            printf ("OISR = 0x%X\n", *OutboundIstatReg);
1007
            printf ("**** PCI INTD Success ****\n\n");
1008
            *OutboundDbReg |= OB_DBELL_INTD;            /* try to clear specific source */
1009
            return (1);
1010
        }
1011
 
1012
        break;
1013
 
1014
    default:
1015
        printf ("Unknown interrupt received\n");
1016
        return (0);
1017
        break;
1018
    }
1019
    return (1);         /* interrupt sharing support requirement */
1020
}
1021
 
1022
 
1023
/*******************************************************************************
1024
*
1025
* i960Rx_seek - look for i960Rx CPUs on the PCI Bus
1026
*
1027
* This function is used by the PCI interrupt test to find and print out
1028
* all PCI location of a particular i960Rx processor on the PCI bus.  Thses include
1029
* boards based on the RP, RD, RM, and RN processors.  The device ID of one of
1030
* these processors is the input to the function.
1031
*
1032
*/
1033
static void i960Rx_seek (UINT32 adapter_device_id)
1034
{
1035
    static char *i960Rx_name;
1036
    cyg_pci_device_id  devid = CYG_PCI_NULL_DEVID;
1037
    int bus, devfn;
1038
 
1039
    /* get the common name for the current Rx processor */
1040
    switch (adapter_device_id) {
1041
    case I80960RN_ATU:
1042
        i960Rx_name = " i960RN  ";
1043
        break;
1044
    case I80960RM_ATU:
1045
        i960Rx_name = " i960RM  ";
1046
        break;
1047
    case I80960RP_ATU:
1048
        i960Rx_name = "i960RP/RD";
1049
        break;
1050
    case I80303_ATU:
1051
    default:
1052
        i960Rx_name = " i80303  ";
1053
        break;
1054
    }
1055
 
1056
    while (cyg_pci_find_device(VENDOR_INTEL, adapter_device_id, &devid)) {
1057
        bus = CYG_PCI_DEV_GET_BUS(devid);
1058
        devfn = CYG_PCI_DEV_GET_DEVFN(devid);
1059
        /* set up this entry into the device array */
1060
        i960Rx_devices[num_rx_devices].device_id = adapter_device_id;
1061
        i960Rx_devices[num_rx_devices].busno = bus;
1062
        i960Rx_devices[num_rx_devices].devno = CYG_PCI_DEV_GET_DEV(devfn);
1063
        i960Rx_devices[num_rx_devices].funcno = CYG_PCI_DEV_GET_FN(devfn);
1064
 
1065
        printf ("   %d        %s  %d       %d         %d\n",
1066
                num_rx_devices, i960Rx_name,
1067
                i960Rx_devices[num_rx_devices].busno,
1068
                i960Rx_devices[num_rx_devices].devno,
1069
                i960Rx_devices[num_rx_devices].funcno);
1070
 
1071
        num_rx_devices++;       /* increment total number of i960Rx devices found */
1072
    }
1073
}
1074
 
1075
 
1076
/*********************************************************************************
1077
*
1078
* pci_int_test - tests PCI interrupts on IQ80310 PCI buses
1079
*
1080
* This test allows full testing of PCI interrupt routing to a particular
1081
* slot on the PCI bus.  It runs in conjunction with a Cyclone i960Rx-based
1082
* board plugged into the target slot.  A default interrupt handler is connected
1083
* for all four PCI interrupt pins on the target board.  The test then waits for
1084
* the target board to trigger each interrupt using the i960Rx doorbell registers.
1085
* The test passes if all four interrupts are recieved and properly handled by the
1086
* IQ80310.
1087
*
1088
*/
1089
void pci_int_test (MENU_ARG arg)
1090
{
1091
    int indexChoice = 0;
1092
    UINT32 long_data;
1093
    UINT32 *OutboundImaskReg;
1094
    int intline_INTA, intline_INTB, intline_INTC, intline_INTD;
1095
    cyg_pci_device_id  devid = CYG_PCI_NULL_DEVID;
1096
 
1097
    num_rx_devices = 0;
1098
 
1099
    printf ("Scanning PCI Bus for all supported i960Rx ATU Devices.....\n\n");
1100
 
1101
    printf (" Index    Processor   Bus   Device   Function\n");
1102
    printf (" -----    ---------   ---   ------   --------\n");
1103
 
1104
    i960Rx_seek (I80960RN_ATU);
1105
    i960Rx_seek (I80960RM_ATU);
1106
    i960Rx_seek (I80960RP_ATU);
1107
    i960Rx_seek (I80303_ATU);
1108
 
1109
    if (num_rx_devices == 0) {
1110
        printf ("\n*** No i960Rx ATU Found on PCI Bus ***\n");
1111
        return;
1112
    }
1113
 
1114
    printf ("Enter index number to use for test : ");
1115
    indexChoice = decIn();
1116
    printf ("\n\n");
1117
 
1118
    if (indexChoice >= num_rx_devices) {
1119
        printf ("Invalid index chosen, exiting\n");
1120
        return;
1121
    }
1122
 
1123
 
1124
    devid = CYG_PCI_DEV_MAKE_ID(i960Rx_devices[indexChoice].busno,
1125
                                CYG_PCI_DEV_MAKE_DEVFN(i960Rx_devices[indexChoice].devno,
1126
                                                       i960Rx_devices[indexChoice].funcno));
1127
 
1128
    cyg_pci_read_config_uint32(devid, REGION0_BASE_OFFSET,(UINT32*)&long_data);
1129
 
1130
    messagingUnitBase = long_data & 0xfffffff0;
1131
    printf ("Messaging Unit PCI Base Address = 0x%X\n", messagingUnitBase);
1132
    OutboundImaskReg = (UINT32 *)(messagingUnitBase + 0x34);
1133
 
1134
    /* Normally, we would just read the intline value from the configuration
1135
       space to determine where the interrupt is routed.  However, the i960Rx
1136
       only requested interrupt resources for one interrupt at a time... */
1137
 
1138
    /* compute interrupt routing values */
1139
    if ((pci_to_xint(i960Rx_devices[indexChoice].devno, INTA, (int*)&intline_INTA)) ||
1140
        (pci_to_xint(i960Rx_devices[indexChoice].devno, INTB, (int*)&intline_INTB)) ||
1141
        (pci_to_xint(i960Rx_devices[indexChoice].devno, INTC, (int*)&intline_INTC)) ||
1142
        (pci_to_xint(i960Rx_devices[indexChoice].devno, INTD, (int*)&intline_INTD)) == ERROR) {
1143
        printf ("Error: Unable to connect PCI interrupts with IQ80310 interrupts\n");
1144
        return;
1145
    }
1146
 
1147
    printf ("i960Rx INTA pin mapped to intLine %s on IQ80310\n", line_to_string(intline_INTA));
1148
    printf ("i960Rx INTB pin mapped to intLine %s on IQ80310\n", line_to_string(intline_INTB));
1149
    printf ("i960Rx INTC pin mapped to intLine %s on IQ80310\n", line_to_string(intline_INTC));
1150
    printf ("i960Rx INTD pin mapped to intLine %s on IQ80310\n", line_to_string(intline_INTD));
1151
 
1152
 
1153
    /* Connect i960Rx PCI INTA Handler */
1154
    if (pci_isr_connect (INTA, i960Rx_devices[indexChoice].busno,
1155
                         i960Rx_devices[indexChoice].devno, PCI_IntHandler, INTA)
1156
        == ERROR ) {
1157
        printf ("Error Connecting INTA interrupt handler\n");
1158
        return;
1159
    }
1160
    printf ("INTA Service Routine installed...\n");
1161
 
1162
    /* enable PCI INTA */
1163
    enable_external_interrupt(SINTA_INT_ID);
1164
 
1165
    /* Connect i960Rx PCI INTB Handler */
1166
    if (pci_isr_connect (INTA, i960Rx_devices[indexChoice].busno,
1167
                         i960Rx_devices[indexChoice].devno, PCI_IntHandler, INTB)
1168
        == ERROR) {
1169
        printf ("Error Connecting INTB interrupt handler\n");
1170
        return;
1171
    }
1172
    printf ("INTB Service Routine installed...\n");
1173
 
1174
    /* enable PCI INTB */
1175
    enable_external_interrupt(SINTB_INT_ID);
1176
 
1177
    /* Connect i960Rx PCI INTC Handler */
1178
    if (pci_isr_connect (INTA, i960Rx_devices[indexChoice].busno,
1179
                         i960Rx_devices[indexChoice].devno, PCI_IntHandler, INTC)
1180
        == ERROR) {
1181
        printf ("Error Connecting INTC interrupt handler\n");
1182
        return;
1183
    }
1184
    printf ("INTC Service Routine installed...\n");
1185
 
1186
    /* enable PCI INTC */
1187
    enable_external_interrupt(SINTC_INT_ID);
1188
 
1189
    /* Connect i960Rx PCI INTD Handler */
1190
    if (pci_isr_connect (INTA, i960Rx_devices[indexChoice].busno,
1191
                         i960Rx_devices[indexChoice].devno, PCI_IntHandler, INTD)
1192
        == ERROR) {
1193
        printf ("Error Connecting INTD interrupt handler\n");
1194
        return;
1195
    }
1196
    printf ("INTD Service Routine installed...\n");
1197
 
1198
    /* enable PCI INTD */
1199
    enable_external_interrupt(SINTD_INT_ID);
1200
 
1201
    /* make sure that the Outbound interrupts aren't masked */
1202
    *OutboundImaskReg &= ~(OB_STAT_INTA | OB_STAT_INTB | OB_STAT_INTC | OB_STAT_INTD);
1203
 
1204
    /* let the ISR do the rest of the work... */
1205
    printf ("Waiting for the PCI Interrupts to be received...\n\n");
1206
    printf ("Hit <CR> when the test is complete\n\n\n");
1207
 
1208
    hexIn();
1209
 
1210
    return;
1211
}
1212
 
1213
 
1214
/*******************************************/
1215
/*  Battery Backup SDRAM memory write test */
1216
/*******************************************/
1217
static void battery_test_write (MENU_ARG arg)
1218
{
1219
    unsigned long start_addr = SDRAM_BATTERY_TEST_BASE;  /* Address to write to */
1220
 
1221
    /* Data to be written to address and read after the board has been powered off and powered back on */
1222
    UINT32 junk = BATTERY_TEST_PATTERN;
1223
 
1224
    *(volatile UINT32 *)start_addr = junk;
1225
 
1226
    printf("\nThe value '");
1227
    hex32out(BATTERY_TEST_PATTERN);
1228
    printf ("' is now written in DRAM at address $");
1229
    hex32out(SDRAM_BATTERY_TEST_BASE);
1230
    printf(".\n\nYou can now power the board off, wait 60 seconds and power it back on.");
1231
    printf("\nThen come back in the battery test menu and select option 2 to check data from DRAM.\n");
1232
 
1233
    printf ("\nPress return to continue.\n");
1234
    (void) hexIn();
1235
}
1236
 
1237
 
1238
/******************************************/
1239
/*  Battery Backup SDRAM memory read test */
1240
/******************************************/
1241
static void battery_test_read (MENU_ARG arg)
1242
{
1243
    unsigned long start_addr = SDRAM_BATTERY_TEST_BASE;  /* Address to read from */
1244
    UINT32 value_written = BATTERY_TEST_PATTERN;  /* Data that was written */
1245
    UINT32 value_read;
1246
 
1247
    value_read = *(volatile UINT32 *)start_addr;
1248
 
1249
    printf ("Value written at address $");
1250
    hex32out(SDRAM_BATTERY_TEST_BASE);
1251
    printf (": ");
1252
    hex32out(BATTERY_TEST_PATTERN);
1253
    printf ("\nValue read at address $");
1254
    hex32out(SDRAM_BATTERY_TEST_BASE);
1255
    printf("   : ");
1256
    hex32out(value_read);
1257
 
1258
    if (value_read == value_written)
1259
        printf ("\n\nThe battery test is a success !\n");
1260
    else {
1261
        printf ("\n\n****************************\n");
1262
        printf ("* The battery test failed. *\n");
1263
        printf ("****************************\n");
1264
    }
1265
 
1266
    printf ("\nBattery test done.\n");
1267
    printf ("Press return to continue.\n");
1268
    (void) hexIn();
1269
}
1270
 
1271
 
1272
/*************************************/
1273
/*  Battery Backup SDRAM memory menu */
1274
/*************************************/
1275
static void battery_test_menu (MENU_ARG arg)
1276
{
1277
    /* Test Menu Table */
1278
    static MENU_ITEM batteryMenu[] = {
1279
        {"Write data to SDRAM",                 battery_test_write,             NULL},
1280
        {"Check data from SDRAM",               battery_test_read,              NULL},
1281
    };
1282
 
1283
    unsigned int num_menu_items =       (sizeof (batteryMenu) / sizeof (batteryMenu[0]));
1284
 
1285
    /*  char menu_title[15] = "\n Battery Backup SDRAM memory test."; */
1286
    char menu_title[36] = "\n Battery Backup SDRAM memory test.";
1287
 
1288
    printf ("\n*************************************************************************\n");
1289
    printf ("* This test will enable you to perform a battery test in 4 steps:       *\n");
1290
    printf ("*  1/  Select option 1 to write the value '");
1291
    hex32out(BATTERY_TEST_PATTERN);
1292
    printf ("' to DRAM at address *\n*      $");
1293
    hex32out(SDRAM_BATTERY_TEST_BASE);
1294
    printf (",                                                       *\n");
1295
    printf ("*  2/  Power the board off and wait 60 seconds,                         *\n");
1296
    printf ("*  3/  Power the board back on,                                         *\n");
1297
    printf ("*  4/  Select option 2 to read at address $");
1298
    hex32out(SDRAM_BATTERY_TEST_BASE);
1299
    printf (" and compare the     *\n*      value to the value written '");
1300
    hex32out(BATTERY_TEST_PATTERN);
1301
    printf ("'.                           *\n");
1302
    printf ("*************************************************************************");
1303
 
1304
    menu (batteryMenu, num_menu_items, menu_title, MENU_OPT_NONE);
1305
    printf ("\n");
1306
}
1307
 
1308
/* 01/11/01 jwf */
1309
/* Make the user select their host test platform type from a list of choices. */
1310
/* If the user picks a Cyclone SB923 then modify the Outbound PCI Translate Register on the IQ80310 for the SB923 */
1311
void select_host_test_system (void)
1312
{
1313
    char selection;
1314
 
1315
    printf("Select your Host test system\n\n");
1316
    printf("Make a selection by typing a number.\n\n");
1317
    printf("1 - Cyclone SB923\n");
1318
    printf("2 - Personal Computer or other\n");
1319
 
1320
    do {
1321
        selection = xgetchar();
1322
    } while( (selection != '1') && (selection != '2') );
1323
 
1324
    if (selection == '1') {
1325
        /* Modify the Outbound PCI Translate Register for a SB923, at address 0x1254 */
1326
        *(volatile UINT32 *) POMWVR_ADDR = 0xa0000000;
1327
    }
1328
}
1329
 
1330
 
1331
/* 02/09/01 jwf */
1332
/* Read the 80200 Coyanosa ID register */
1333
/* Use a base address equal to the fourth memory location from the last memory location */
1334
/* in a 32MB SDRAM DIMM */
1335
/* Store from coprocessor register 15 to memory. */
1336
/* ARM register R0 is the address after the transfer */
1337
void read_coyanosa_id_reg (void)
1338
{
1339
    __asm__ ("ldr r0, = 0xA1FFFFFC");
1340
    __asm__ ("mrc p15, 0, r1, c0, c0, 0");
1341
    __asm__ ("str r1, [r0], #0");
1342
}
1343
 
1344
 
1345
/* 02/09/01 jwf */
1346
/*
1347
*Display the following version information.
1348
*1. Software version of Red Boot or Cygnus Cygmon Rom Monitor.
1349
*2. Cpld version.  Located in the 0xFE840000 (Read)
1350
*3. Board Revision. Located at 0xFE830000 (Read)
1351
*4. 80200 ID data Located in CP15 Register 0
1352
*5. 80312 Stepping Located at 0x00001008
1353
*/
1354
void version_info (MENU_ARG arg)
1355
{
1356
    char board_rev;
1357
 
1358
/* show revision information for operating system */
1359
#if CYGNUS_CYGMON_OS
1360
    extern void version(void); /* is defined in monitor.c */
1361
    version();
1362
#endif
1363
 
1364
#if REDHAT_REDBOOT_OS
1365
    extern void do_version(int argc, char *argv[]);/* is defined in main.c */
1366
    do_version(0,0);
1367
#endif
1368
 
1369
    board_rev = board_revision();
1370
    if ( board_rev >= BOARD_REV_E ) {
1371
        /* read Board revision register and adjust numeric revision to letter revision, 0x1 <--> A */
1372
        printf("\nBoard Revision = %c\n",(*BOARD_REV_REG_ADDR & BOARD_REV_MASK) + 'A' - 1 );
1373
    } else {
1374
        /* Board letter revision might be A or B or C or D */
1375
        printf("\nBoard Revision Unknown!\n");
1376
    }
1377
 
1378
    /* read CPLD revision register and adjust numeric revision to letter revision, 0x1 <--> A */
1379
    printf("CPLD Revision = %c\n",(*CPLD_REV_REG_ADDR & BOARD_REV_MASK) + 'A' - 1 );
1380
 
1381
    /* Read the 80200 Coyanosa ID register */
1382
    read_coyanosa_id_reg();
1383
 
1384
    printf( "80200 Revision ID = 0x%x\n", ( *(volatile unsigned long *) COYANOSA_ID_BASE_ADDR) );
1385
 
1386
    /* read the 80312 Yavapai Revision ID register */
1387
    printf( "80312 Revision ID = %d\n", (*(volatile unsigned char *) RIDR_ADDR) );
1388
 
1389
    printf ("\n\nStrike <CR> to exit this test.\n\n");
1390
 
1391
    hexIn();
1392
}
1393
 
1394
 
1395
/* 02/09/01 jwf */
1396
/* Determine if the CPLD supports a Board Revision Register. */
1397
/* If a Board Revision Register exists then return the board revision number read from a dedicated CPLD register at memory address 0xfe830000 */
1398
/* Otherwise return a default board revision number. */
1399
char board_revision ()
1400
{
1401
    /* represents the ring indicator bit logic level in UART2 */
1402
    unsigned char ri_state;
1403
 
1404
    /* holds a board revision number */
1405
    char board_rev;
1406
 
1407
    /* access UART2 MSR at memory address 0xfe810006 through the CYGMON serial port, J9 */
1408
    ri_state = *( unsigned char * ) 0xfe810006;
1409
    ri_state &= RI_MASK;
1410
 
1411
    /* RI# pin on UART2 is grounded */
1412
    /* CPLD design supports a Board Revision Register implemention */
1413
    if(ri_state == RI_MASK) {
1414
        /* read Board Revision register and isolate LSN */
1415
        board_rev = (*BOARD_REV_REG_ADDR & BOARD_REV_MASK);
1416
 
1417
        /* Board Rev is at E or higher */
1418
        if (board_rev >= BOARD_REV_E)
1419
            return (board_rev);
1420
    }
1421
 
1422
    /* RI# pin on UART2 is pulled up to 3.3V. */
1423
    /* Unknown Board Revision! */
1424
    /* Unable to determine a board revision because the CPLD Board Revision Register */
1425
    /* was never implemented for IQ80310 PCI-700 board REVs A,B,C, or D. */
1426
    /* set a default board revision value of 0x2 <--> Rev B. */
1427
    board_rev = 0x2;
1428
 
1429
    /* return a default value */
1430
    return (board_rev);
1431
}
1432
 
1433
 
1434
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.