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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [mips/] [idt79s334a/] [current/] [src/] [plf_misc.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      plf_misc.c
4
//
5
//      HAL platform miscellaneous functions
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    tmichals
43
// Contributors: 
44
// Date:         2002-09-01
45
// Purpose:      HAL miscellaneous functions
46
// Description:  This file contains miscellaneous functions provided by the
47
//               HAL.
48
//
49
//####DESCRIPTIONEND####
50
//
51
//========================================================================*/
52
 
53
#include <pkgconf/hal.h>
54
#include <pkgconf/system.h>
55
 
56
#include CYGBLD_HAL_PLATFORM_H
57
 
58
#include <cyg/infra/cyg_type.h>         // Base types
59
#include <cyg/infra/cyg_trac.h>         // tracing macros
60
#include <cyg/infra/cyg_ass.h>          // assertion macros
61
#include <cyg/hal/hal_arch.h>           // architectural definitions
62
#include <cyg/hal/hal_intr.h>           // Interrupt handling
63
#include <cyg/hal/hal_cache.h>          // Cache handling
64
 
65
/* This is the Reference board configuration */
66
#include <cyg/hal/idt79rc233x.h>
67
 
68
#include <cyg/io/pci_hw.h>
69
#include <cyg/io/pci.h>
70
 
71
void  hal_rc334PciInit (void);
72
static void mmuInit (void);
73
static void sysDisableBusError (void) ;
74
static void sysEnableBusError(void);
75
void   ecosPciConfigOutByte(  int busNo, int devFnNo,int regOffset,unsigned char data );
76
void   ecosPciConfigOutHalfWord( int busNo,int devFnNo,int regOffset,unsigned short data );
77
void   ecosPciConfigOutWord( int busNo,int devFnNo,int regOffset,unsigned int data );
78
unsigned char ecosPciConfigInByte(int busNo, int devFnNo,int regOffset);
79
unsigned short ecosPciConfigInHalfWord( int busNo,int devFnNo,int regOffset);
80
unsigned int ecosPciConfigInWord( int busNo, int devFnNo,int regOffset);
81
void displayLED(char *str, int count);
82
 
83
/*------------------------------------------------------------------------*/
84
 
85
  /* this is called from the kernel */
86
void hal_platform_init(void)
87
{
88
 
89
    HAL_ICACHE_INVALIDATE_ALL();
90
    HAL_ICACHE_ENABLE();
91
    HAL_DCACHE_INVALIDATE_ALL();
92
    HAL_DCACHE_ENABLE();
93
 
94
    displayLED("eCOS", 4);
95
    hal_if_init();
96
    mmuInit();
97
    hal_rc334PciInit();
98
}
99
 
100
 
101
 
102
/* PCI Configuration Registers */
103
#define  PCI_CFG_VENDORID         0x00
104
#define  PCI_CFG_DEVICEID         0x02
105
#define  PCI_CFG_COMMAND          0x04
106
#define  PCI_CFG_STATUS           0x06
107
#define  PCI_CFG_REVID            0x08 
108
#define  PCI_CFG_CLASS_CODE       0x09
109
#define  PCI_CFG_CACHELINE        0x0c
110
#define  PCI_CFG_LATENCY_TIMER    0x0d
111
#define  PCI_CFG_HEADER_TYPE      0x0e
112
#define  PCI_CFG_BIST             0x0f
113
#define  PCI_CFG_BAR0             0x10
114
#define  PCI_CFG_BAR1             0x14
115
#define  PCI_CFG_BAR2             0x18
116
#define  PCI_CFG_BAR3             0x1c
117
#define  PCI_CFG_BAR4             0x20
118
#define  PCI_CFG_BAR5             0x24
119
#define  PCI_CFG_CIS_POINTER      0x28
120
#define  PCI_CFG_SUB_VENDORID     0x2c
121
#define  PCI_CFG_SUB_SYSTEMID     0x2e
122
#define  PCI_CFG_EXP_ROM          0x30
123
#define  PCI_CFG_CAPABILITIES     0x34
124
#define  PCI_CFG_RESERVED1        0x35
125
#define  PCI_CFG_RESERVED2        0x38
126
#define  PCI_CFG_INT_LINE         0x3c
127
#define  PCI_CFG_INT_PIN          0x3d
128
#define  PCI_CFG_MIN_GRANT        0x3e
129
#define  PCI_CFG_MAX_LATENCY      0x3f
130
#define  PCI_CFG_TRDY_TIMEOUT     0x40
131
#define  PCI_CFG_RETRY_TIMEOUT    0x41
132
 
133
#define RC334_CONFIG0           0x80000000
134
/* Typical values used in this example */
135
#define RC334_PCI_CONFIG0 0x0204111D /* Device ID & Vendor ID */
136
#define RC334_PCI_CONFIG1       0x00200157   /* Command : MWINV, Enable bus master, 
137
                        memory I/O access       */
138
#define RC334_PCI_CONFIG2       0x06800001   /* Class Code & Revision ID */
139
#define RC334_PCI_CONFIG3       0x0000ff04   /* BIST, Header Type, Master Latency,
140
        Cache line size */
141
#define RC334_PCI_CONFIG4       0xA0000008    /* Memory Base Address Reg, prefetchable  */
142
#define RC334_PCI_CONFIG5       0x60000000    /* Integrated Controller Reg, non-prefetchable    */
143
#define RC334_PCI_CONFIG6       0x00800001    /* IO Base Address Reg      */
144
#define RC334_PCI_CONFIG7       0x00000000    /* Unused BAR space, assign some address 
145
        that never gets generated on PCI Bus      */
146
 
147
/* Reserved  registers */
148
#define RC334_PCI_CONFIG8       0x00000000
149
#define RC334_PCI_CONFIG9       0x00000000
150
#define RC334_PCI_CONFIG10      0x00000000
151
 
152
/* Subsystem ID and the subsystem Vendor ID */
153
#define RC334_PCI_CONFIG11      0x00000000
154
 
155
/* Reserved registers */
156
#define RC334_PCI_CONFIG12      0x00000000
157
#define RC334_PCI_CONFIG13      0x00000000
158
#define RC334_PCI_CONFIG14      0x00000000
159
 
160
/* Max latency, Min Grant, Interrupt pin and interrupt line */
161
#define RC334_PCI_CONFIG15      0x38080101
162
 
163
/* Retry timeout value, TRDY timeout value. Set to default 0x80 */
164
#define RC334_PCI_CONFIG16      0x00008080
165
 
166
/* Rc32334 specific PCI registers                  */
167
#define RC334_PCI_REG_BASE       0xb8000000
168
#define RC334_CPUTOPCI_BASE_REG1  (RC334_PCI_REG_BASE + 0x20B0)
169
#define RC334_CPUTOPCI_BASE_REG2  (RC334_PCI_REG_BASE + 0x20B8)
170
#define RC334_CPUTOPCI_BASE_REG3  (RC334_PCI_REG_BASE + 0x20C0)
171
#define RC334_CPUTOPCI_BASE_REG4    (RC334_PCI_REG_BASE + 0x20C8)
172
 
173
#define RC334_PCI_ARB_REG   (RC334_PCI_REG_BASE + 0x20E0)
174
#define RC334_PCITOCPU__BASE_REG1  (RC334_PCI_REG_BASE + 0x20E8)
175
#define RC334_PCITOCPU__BASE_REG2   (RC334_PCI_REG_BASE + 0x20F4)
176
#define RC334_PCITOCPU__BASE_REG3   (RC334_PCI_REG_BASE + 0x2100)
177
#define RC334_PCITOCPU__BASE_REG4   (RC334_PCI_REG_BASE + 0x210C)
178
 
179
/* Considering a typical case  */
180
#define CPUTOPCI_BASE_REG1_VAL      0x40000001
181
#define CPUTOPCI_BASE_REG2_VAL      0x00000000
182
#define CPUTOPCI_BASE_REG3_VAL      0x00000000
183
#define CPUTOPCI_BASE_REG4_VAL      0x18800001 
184
 
185
//TCM#define PCITOCPU_BASE_REG3_VAL      0x00000000
186
//TCM#define PCITOCPU_BASE_REG4_VAL      0x18000051    /*    Size field set to 0x14 : 1MB size    */
187
 
188
#define  RC334_PCITOCPU_BASE_REG1           (RC334_PCI_REG_BASE+0x20E8)
189
#define  RC334_PCITOCPU_BASE_REG2           (RC334_PCI_REG_BASE+0x20F4)
190
#define  RC334_PCITOCPU_BASE_REG3           (RC334_PCI_REG_BASE+0x2100)
191
#define  RC334_PCITOCPU_BASE_REG4           (RC334_PCI_REG_BASE+0x210C)
192
 
193
#define  PCITOCPU_MEM_BASE(addr)  ( (addr & 0xFFFFFF)<<8)
194
#define  PCITOCPU_SIZE(i)                      ( ( i & 0x1F) << 2 )
195
#define  PCITOCPU_EN_SWAP                 1
196
 
197
#define  SIZE_1MB                                      0x14
198
#define  SIZE_64MB                                    0x1A
199
 
200
#define SYS_MEM_BASE                          0x0              /* local sdram starting address */
201
#define RC32334_INT_REG_BASE           0x18000000 /* Integrated controller's internal registers */
202
 
203
/* PCI Target Control Register is provided in the RC32334 to utilize
204
eager prefetches and reduce target disconnects and retries. In the
205
following example, an optimized value is picked that enables eager
206
prefetch for all BAR's, enables Memory Write and Memory Write and
207
Invalidate (MWMWI), uses threshold for target write FIFO of 8 words,
208
and sets disconnect and retry timer to 40 PCI clocks */
209
 
210
#define  PCI_TARGET_CONTROL_REG           0xB80020A4
211
#define  PCI_TARGET_CONTROL_REG_VAL       0x7EF02828
212
 
213
/* BAR1 is selected as memory base register with 64 Mbyte address
214
range starting at physical address 0x0000_0000, allowing external PCI
215
masters to access the local SDRAM for data read and write. This
216
register setting works with the BAR1 register in the PCI configuration
217
register in the PCI bridge of the RC32334 which, in this example, has
218
been set to 0xA000_0000. With the given settings, the external PCI
219
masters can access addresses in the range 0xA000_0000 through
220
0xA3FF_FFFF using BAR1 which gets translated to address range
221
0x0000_0000 through 0x03FF_FFFF on the local CPU bus owing to the
222
PCITOCPU_BASE_REG1 settings. */
223
 
224
#define  PCITOCPU_BASE_REG1_VAL   ((PCITOCPU_MEM_BASE(SYS_MEM_BASE)) | \
225
                                              (PCITOCPU_SIZE(SIZE_64MB) ) | \
226
                                              (PCITOCPU_EN_SWAP) )
227
 
228
/* BAR2 is selected as memory base register with 1 Mbyte range
229
starting at the physical address 0x1800_0000. This maps to the RC32334
230
internal registers allowing external PCI masters to read/modify the
231
RC32334 registers. In this example, the BAR2 register in the PCI
232
configuration register of the RC32334 PCI bridge has been set to
233
0xB800_0000 (note that this address is in the PCI space and should not
234
be confused with the CPU address map). External PCI masters can access
235
memory range 0xB800_0000 through 0xB80F_FFFF, sufficient enough to
236
access all the RC32334 internal registers. The PCITOCPU_BASE_REG2
237
settings map all PCI cycles falling in the above range to physical
238
address range 0x1800_0000 — 0x180F_FFFF on the local CPU bus.  */
239
 
240
#define  PCITOCPU_BASE_REG2_VAL   ((PCITOCPU_MEM_BASE(RC32334_INT_REG_BASE)) | \
241
                                              (PCITOCPU_SIZE(SIZE_1MB) ) | \
242
                                              (PCITOCPU_EN_SWAP) )
243
 
244
/* BAR3 is selected as IO base register with 1 Mbyte range mapped to
245
address 0x1800_0000, providing another window for accessing the
246
Integrated controller registers. In this example, the value for the
247
BAR3 has been picked as 0x0000_0000 (address range 0x0000_00000
248
through 0x000F_FFFF). Any PCI IO cycles to this address range would
249
get translated to local CPU address range of 0x1800_0000 through
250
0x180F_FFFF using this register settings. */
251
 
252
#define  PCITOCPU_BASE_REG3_VAL   (        \
253
                                              (PCITOCPU_MEM_BASE(RC32334_INT_REG_BASE)) | \
254
                                              (PCITOCPU_SIZE(SIZE_1MB) ) | \
255
                                              (PCITOCPU_EN_SWAP) )
256
 
257
/* BAR4 register is not used. Therefore, it can be disabled by selecting the SIZE value 1-7 */
258
#define  PCITOCPU_BASE_REG4_VAL     ( PCITOCPU_SIZE( 1 ) )
259
 
260
/* Arbitration register value:
261
   Target Ready, internal arbiter, fixed priority
262
*/
263
#define PCI_ARB_REG_VAL           0x00000001
264
 
265
/*  Rc32334 config address/data definitions  */
266
#define PCI_CONFIG_ADDR_REG      0xb8002cf8
267
#define PCI_CONFIG_DATA_REG      0xb8002cfc
268
 
269
/* BYTE SWAP macros */
270
#define HALF_WORD_SWAP(x) \
271
             (  ( ( x  << 8 ) & 0xff00)    |  \
272
                 ( (x  >> 8 ) & 0x00ff )  )
273
 
274
#define WORD_SWAP(x)\
275
             ( ( ( x << 24 )  & 0xff000000 ) |  \
276
                ( (x << 8   )  & 0x00ff0000 ) |  \
277
                ( (x >> 8   )  & 0x0000ff00 ) |  \
278
                ( (x >> 24 )  & 0x000000ff )    )
279
 
280
/* PCI Functions */
281
unsigned int   pciConfigInWord( int busNo, int devNo, int funcNo, int regOffset);
282
unsigned short pciConfigInHalfWord( int busNo, int devNo, int funcNo, int regOffset);
283
unsigned char pciConfigInByte( int busNo, int devNo, int funcNo, int regOffset);
284
void   pciConfigOutWord ( int busNo, int devNo, int funcNo, int regOffset, unsigned int data );
285
void   pciConfigOutHalfWord ( int busNo, int devNo, int funcNo, int regOffset, unsigned short data );
286
void   pciConfigOutChar ( int busNo, int devNo, int funcNo, int regOffset, unsigned char data );
287
 
288
/* Rc32334 Bus error register. The bit7 of this register can be used
289
to enable or disable the BusError. The bus error is disabled briefly
290
at the time of pci Scanning and enabled thereafter. */
291
 
292
#define  RC334_BUS_ERR_CNTL_REG  0xb8000010
293
 
294
/*
295
    Function name       : hal_rc334PciInit
296
    Parameters passed  : none
297
    return value       : none
298
    The function initialises the configuration registers of    Rc32334 PCI interface controller.
299
*/
300
void hal_rc334PciInit ( )
301
{
302
 
303
        unsigned int pciConfigData[17];
304
        int index                     ;
305
        volatile unsigned int *configAddrReg   ;
306
        volatile unsigned int *configDataReg   ;
307
        volatile unsigned int  *regPointer     ;
308
 
309
        configAddrReg  = (volatile unsigned int*) PCI_CONFIG_ADDR_REG;
310
        configDataReg  = (volatile unsigned int*) PCI_CONFIG_DATA_REG;
311
 
312
        pciConfigData[0]    = RC334_PCI_CONFIG0;
313
        pciConfigData[1]    = RC334_PCI_CONFIG1;
314
        pciConfigData[2]    = RC334_PCI_CONFIG2;
315
        pciConfigData[3]    = RC334_PCI_CONFIG3;
316
        pciConfigData[4]    = RC334_PCI_CONFIG4;
317
        pciConfigData[5]    = RC334_PCI_CONFIG5;
318
        pciConfigData[6]    = RC334_PCI_CONFIG6;
319
        pciConfigData[7]    = RC334_PCI_CONFIG7;
320
        pciConfigData[8]    = RC334_PCI_CONFIG8;
321
        pciConfigData[9]    = RC334_PCI_CONFIG9;
322
        pciConfigData[10]  = RC334_PCI_CONFIG10;
323
        pciConfigData[11]  = RC334_PCI_CONFIG11;
324
        pciConfigData[12]  = RC334_PCI_CONFIG12;
325
        pciConfigData[13]  = RC334_PCI_CONFIG13;
326
        pciConfigData[14]  = RC334_PCI_CONFIG14;
327
        pciConfigData[15]  = RC334_PCI_CONFIG15;
328
        pciConfigData[16]  = RC334_PCI_CONFIG16;
329
 
330
        *configAddrReg = (unsigned int)RC334_CONFIG0 ;
331
/*   This example writes to all the configuration registers. Some of
332
the PCI configuration registers (such as Device ID, Vendor ID, Class
333
Code, Revision ID, BIST, Header Type, Subsystem Vendor ID, Maximum
334
Latency, Minimum Grant, Interrupt Pin) need not be initialized */
335
 
336
        for (index =0; index <17; index++ )
337
                {
338
                *configDataReg = pciConfigData[index];
339
                *configAddrReg = *configAddrReg + 4;
340
                }
341
 
342
       /* Park the Address Register */
343
       configAddrReg = ( volatile unsigned int*)0x0 ;
344
 
345
/* Set Rc32334 specific registers */
346
 
347
regPointer = ( volatile unsigned int*)(RC334_CPUTOPCI_BASE_REG1) ;
348
*regPointer = (unsigned int)(CPUTOPCI_BASE_REG1_VAL );
349
 
350
regPointer = (volatile unsigned int*)(RC334_CPUTOPCI_BASE_REG2) ;
351
*regPointer = (unsigned int)(CPUTOPCI_BASE_REG2_VAL );
352
 
353
regPointer = (volatile unsigned int*)(RC334_CPUTOPCI_BASE_REG3) ;
354
*regPointer = (unsigned int)(CPUTOPCI_BASE_REG3_VAL );
355
 
356
regPointer = (volatile unsigned int*)(RC334_CPUTOPCI_BASE_REG4) ;
357
*regPointer = (unsigned int)(CPUTOPCI_BASE_REG4_VAL );
358
 
359
regPointer = (volatile unsigned int*)(RC334_PCITOCPU_BASE_REG1) ;
360
*regPointer = (unsigned int)(PCITOCPU_BASE_REG1_VAL );
361
 
362
regPointer = ( volatile unsigned int*)(RC334_PCITOCPU_BASE_REG2) ;
363
*regPointer = (unsigned int)(PCITOCPU_BASE_REG2_VAL );
364
 
365
regPointer = (volatile unsigned int*)(RC334_PCITOCPU_BASE_REG3) ;
366
*regPointer = (unsigned int)(PCITOCPU_BASE_REG3_VAL );
367
 
368
regPointer = (volatile unsigned int*)(RC334_PCITOCPU_BASE_REG4) ;
369
*regPointer = (unsigned int)(PCITOCPU_BASE_REG4_VAL );
370
 
371
regPointer = (volatile unsigned int*)PCI_TARGET_CONTROL_REG ;
372
*regPointer = (unsigned int)PCI_TARGET_CONTROL_REG_VAL ;
373
 
374
regPointer = (volatile unsigned int*)(RC334_PCI_ARB_REG);
375
*regPointer = (unsigned int)(PCI_ARB_REG_VAL);
376
 
377
}
378
 
379
/*     Function name :   sysDisableBusError
380
                         Disables the Bus Error prior to pciScan.
381
*/
382
static void sysDisableBusError (  ) {
383
        unsigned int*  regPointer ;
384
        unsigned int    data      ;
385
        regPointer = (unsigned int*) ( RC334_BUS_ERR_CNTL_REG);
386
        data       = *regPointer  ;
387
        /* Set bit7 to disable busError */
388
        data   =  data |  0x00000080 ;
389
        *regPointer = data ;
390
}
391
 
392
/*  Function name :   sysEnableBusError
393
                      Enables the Bus Error after pciScan
394
*/
395
static void sysEnableBusError (  ) {
396
        unsigned int*  regPointer ;
397
        unsigned int    data      ;
398
        regPointer = (unsigned int*) ( RC334_BUS_ERR_CNTL_REG);
399
        data       = *regPointer  ;
400
        /* Reset bit7 to enable busError */
401
        data   =  data & 0xffffff7f;
402
        *regPointer = data ;
403
}
404
 
405
 
406
 
407
 
408
#define TLB_HI_MASK                          0xffffe000
409
#define TLB_LO_MASK                         0x3fffffff
410
#define PAGEMASK_SHIFT                        13
411
#define TLB_LO_SHIFT                                 6
412
#define PCI_PAGE_SIZE                          0x01000000    /* 16 Mbyte */
413
#define MMU_PAGE_UNCACHED        0x00000010
414
#define MMU_PAGE_DIRTY                  0x00000004
415
#define MMU_PAGE_VALID                  0x00000002
416
#define MMU_PAGE_GLOBAL              0x00000001
417
#define PCI_MMU_PAGEMASK             0x00000fff
418
#define PCI_MMU_PAGEATTRIB    (MMU_PAGE_UNCACHED|MMU_PAGE_DIRTY| MMU_PAGE_VALID|MMU_PAGE_GLOBAL)
419
#define PCI_MEMORY_SPACE1           0x40000000
420
#define PCI_MEMORY_SPACE2           0x60000000
421
#define PCI_IO_SPACE                           0x18000000
422
/*
423
   Function name : mmuInit
424
                  Tlb Initialisation for the PCI  memory/IO windows.
425
*/
426
static void mmuInit (  ) {
427
        unsigned int Tlb_Attrib ;
428
        unsigned int Tlb_Hi     ;
429
        unsigned int Tlb_Lo0    ;
430
        unsigned int Tlb_Lo1    ;
431
        unsigned int Page_Size  ;
432
        unsigned int pageFrame  ;
433
        unsigned int Tlb_Inx    ;
434
 
435
        /* Uncached, dirty, global and valid MMU page */
436
          Tlb_Attrib = PCI_MMU_PAGEATTRIB ;
437
 
438
        Page_Size = PCI_MMU_PAGEMASK   ;
439
        Page_Size = (Page_Size << (PAGEMASK_SHIFT));
440
        hal_setPageSize(Page_Size);
441
 
442
/*
443
 * MMU mapping for PCI_MEMORY_SPACE1
444
 * Map 16MB pages
445
 * Virtual 0x40000000-0x40ffffff to Physical 0x40000000 - 0x40ffffff
446
 * Virtual 0x41000000-0x41ffffff to Physical 0x41000000 - 0x41ffffff
447
 */
448
 
449
        Tlb_Hi     = PCI_MEMORY_SPACE1     ; /* VPN2:VirtualPageframeNumber%2 */
450
        Tlb_Hi     = (Tlb_Hi & TLB_HI_MASK)  ;
451
 
452
        pageFrame  = PCI_MEMORY_SPACE1       ;
453
                                                                                  /* Even PFN:Page Frame Number */
454
        pageFrame  = pageFrame >> TLB_LO_SHIFT;
455
        Tlb_Lo0     = pageFrame ;
456
        Tlb_Lo0    = ( Tlb_Lo0 | Tlb_Attrib) ;
457
        Tlb_Lo0    = ( Tlb_Lo0 & TLB_LO_MASK);
458
 
459
        pageFrame  = (PCI_MEMORY_SPACE1 | PCI_PAGE_SIZE) ;
460
                                                                                /* Odd PFN:Page Frame Number*/
461
        pageFrame  = pageFrame >> TLB_LO_SHIFT ;
462
        Tlb_Lo1    = pageFrame               ;
463
        Tlb_Lo1    = ( Tlb_Lo1 | Tlb_Attrib) ;
464
        Tlb_Lo1    = ( Tlb_Lo1 & TLB_LO_MASK);
465
        Tlb_Inx    =           0             ;
466
        hal_setTlbEntry(Tlb_Inx, Tlb_Hi, Tlb_Lo0, Tlb_Lo1);
467
 
468
/*
469
 * MMU mapping for PCI_MEMORY_SPACE2
470
 * Virtual 0x60000000-0x60ffffff to Physical 0x60000000 - 0x60ffffff
471
 * Virtual 0x61000000-0x61ffffff to Physical 0x61000000 - 0x61ffffff
472
 */
473
        Tlb_Hi     = PCI_MEMORY_SPACE2       ;   /* VPN2    */
474
        Tlb_Hi     = ( Tlb_Hi & TLB_HI_MASK );
475
 
476
        pageFrame  = PCI_MEMORY_SPACE2       ;
477
        pageFrame  = pageFrame >> TLB_LO_SHIFT ; /*Even PFN */
478
        Tlb_Lo0    = pageFrame               ;
479
 
480
        Tlb_Lo0    = ( Tlb_Lo0 | Tlb_Attrib) ;
481
        Tlb_Lo0    = ( Tlb_Lo0 & TLB_LO_MASK);
482
 
483
        pageFrame  = ( PCI_MEMORY_SPACE2 | PCI_PAGE_SIZE ) ;
484
        pageFrame  = pageFrame >> TLB_LO_SHIFT ; /* Odd PFN */
485
        Tlb_Lo1    = pageFrame               ;
486
        Tlb_Lo1    = ( Tlb_Lo1 | Tlb_Attrib) ;
487
        Tlb_Lo1    = ( Tlb_Lo1 & TLB_LO_MASK);
488
        Tlb_Inx    =           1             ;
489
        hal_setTlbEntry(Tlb_Inx, Tlb_Hi, Tlb_Lo0, Tlb_Lo1);
490
 
491
/*
492
 * MMU mapping PCI IO space
493
 * Virtual 0x18000000-0x18ffffff to Physical 0x18000000 - 0x18ffffff
494
 * Virtual 0x19000000-0x19ffffff to Physical 0x19000000 - 0x19ffffff
495
 */
496
        Tlb_Hi     = PCI_IO_SPACE            ;   /* VPN2   */
497
        Tlb_Hi     = ( Tlb_Hi & TLB_HI_MASK );
498
 
499
        pageFrame  = PCI_IO_SPACE            ;
500
 
501
        pageFrame  = pageFrame >> TLB_LO_SHIFT ; /* Even PFN */
502
        Tlb_Lo0    = pageFrame               ;
503
        Tlb_Lo0    = ( Tlb_Lo0 | Tlb_Attrib) ;
504
        Tlb_Lo0    = ( Tlb_Lo0 & TLB_LO_MASK);
505
 
506
        pageFrame  = (PCI_IO_SPACE | PCI_PAGE_SIZE) ;
507
        pageFrame  = pageFrame >> TLB_LO_SHIFT ; /* Odd PFN  */
508
        Tlb_Lo1    = pageFrame               ;
509
        Tlb_Lo1    = ( Tlb_Lo1 | Tlb_Attrib) ;
510
        Tlb_Lo1    = ( Tlb_Lo1 & TLB_LO_MASK);
511
        Tlb_Inx    =           2             ;
512
        hal_setTlbEntry(Tlb_Inx, Tlb_Hi, Tlb_Lo0, Tlb_Lo1);
513
    }
514
 
515
 
516
 
517
 
518
/* ecos PCI functions */
519
 
520
 
521
 void   ecosPciConfigOutByte
522
        (  int busNo,
523
           int devFnNo,
524
           int regOffset,
525
           unsigned char data ){
526
 
527
          unsigned int    address ;
528
 
529
          address   = (  ( (busNo << 16) & 0x00ff0000 ) |
530
                         ( ( devFnNo << 8 )  & 0x0000ff00 )
531
                            );
532
          address = ( address | 0x80000000 | (regOffset ) );
533
          hal_sysConfigOutByte(address, data, (regOffset & 0x3) );
534
}
535
 
536
void   ecosPciConfigOutHalfWord
537
       ( int busNo,
538
         int devFnNo,
539
         int regOffset,
540
         unsigned short data ){
541
 
542
         unsigned int       address ;
543
 
544
         address   = (  ( (busNo << 16) & 0x00ff0000 ) |
545
                        ( ( devFnNo << 8 ) & 0x0000ff00)
546
                            );
547
         address = ( address | 0x80000000 | (regOffset ) );
548
         hal_sysConfigOutHalfWord(address, data, (regOffset & 0x3) );
549
}
550
 
551
 
552
void   ecosPciConfigOutWord
553
        ( int busNo,
554
          int devFnNo,
555
          int regOffset,
556
          unsigned int data ){
557
 
558
          unsigned int    address ;
559
          address   = (  ( (busNo << 16) & 0x00ff0000 ) |
560
                         ( ( devFnNo << 8 ) & 0x0000ff00)
561
                            );
562
          address = ( address | 0x80000000 | (regOffset ) );
563
 
564
          hal_sysConfigOutWord(address, data);
565
}
566
 
567
unsigned char ecosPciConfigInByte
568
        (int busNo,
569
         int devFnNo,
570
         int regOffset
571
                  ){
572
 
573
          unsigned int    address ;
574
          unsigned char  retVal   ;
575
 
576
         address   = (  ( (busNo << 16) & 0x00ff0000 ) |
577
                        ( ( devFnNo << 8 ) & 0x0000ff00)
578
                     );
579
         address = ( address | 0x80000000 | (regOffset ) );
580
                 sysDisableBusError( );
581
         retVal  = (unsigned char)(hal_sysConfigInByte(address));
582
                 sysEnableBusError( );
583
         return ( retVal );
584
}
585
 
586
unsigned short ecosPciConfigInHalfWord
587
        ( int busNo,
588
          int devFnNo,
589
          int regOffset
590
                  ){
591
 
592
          unsigned int            address;
593
          unsigned short           retVal;
594
 
595
          address   = (  ( (busNo << 16) & 0x00ff0000 ) |
596
                         ( ( devFnNo << 8 ) & 0x0000ff00)
597
                       );
598
         address = ( address | 0x80000000 | (regOffset ) );
599
                 sysDisableBusError( );
600
         retVal = (unsigned short)hal_sysConfigInHalfWord(address);
601
                 sysEnableBusError( );
602
                 return retVal;
603
 
604
}
605
unsigned int ecosPciConfigInWord
606
        ( int busNo,
607
          int devFnNo,
608
          int regOffset
609
                  ){
610
 
611
          unsigned int            address;
612
          unsigned int           retVal;
613
 
614
          address   = (  ( (busNo << 16) & 0x00ff0000 ) |
615
                              ( ( devFnNo << 8 ) & 0x0000ff00)
616
                       );
617
         address = ( address | 0x80000000 | regOffset );
618
                 sysDisableBusError( );
619
         retVal  = hal_sysConfigInWord(address);
620
                 sysEnableBusError( );
621
                 return retVal;
622
}
623
 
624
 
625
void displayLED(char *str, int count)
626
{
627
        char *pChar = (char *)0xB4000000;
628
 
629
        char temp;
630
 
631
        /* clear */
632
        temp = pChar[0x400];
633
 
634
        if (count)
635
                pChar[0xf]= str[0];
636
        else
637
                return;
638
 
639
        if (--count)
640
                pChar[0xb]= str[1];
641
        else
642
                return;
643
 
644
        if (--count)
645
                pChar[0x7]= str[2];
646
        else
647
                return;
648
 
649
        if (--count)
650
                pChar[0x3]= str[3];
651
        else
652
                return;
653
 
654
}
655
 
656
/*------------------------------------------------------------------------*/
657
/* End of plf_misc.c                                                      */
658
 

powered by: WebSVN 2.1.0

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