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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mips/] [rm7000/] [ocelot/] [v2_0/] [include/] [plf_io.h] - Blame information for rev 638

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_PLF_IO_H
2
#define CYGONCE_PLF_IO_H
3
 
4
//=============================================================================
5
//
6
//      plf_io.h
7
//
8
//      Platform specific IO support
9
//
10
//=============================================================================
11
//####ECOSGPLCOPYRIGHTBEGIN####
12
// -------------------------------------------
13
// This file is part of eCos, the Embedded Configurable Operating System.
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under
17
// the terms of the GNU General Public License as published by the Free
18
// Software Foundation; either version 2 or (at your option) any later version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//=============================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):    hmt, jskov, nickg
47
// Contributors: hmt, jskov, nickg
48
// Date:         1999-08-09
49
// Purpose:      Ocelot/Galileo GT-64120A PCI IO support macros
50
// Description: 
51
// Usage:        #include <cyg/hal/plf_io.h>
52
//
53
// Note:         Based on information in 
54
//               "Galileo GT 64120A System Controller For 
55
//                RC4650/4700/5000 and RM526X/527X/7000 CPUs"
56
//####DESCRIPTIONEND####
57
//
58
//=============================================================================
59
 
60
#include <pkgconf/hal.h>
61
 
62
#include <cyg/hal/hal_arch.h>           // address macros
63
#include <cyg/hal/hal_io.h>             // IO macros
64
#include <cyg/hal/hal_intr.h>           // Interrupt vectors
65
 
66
//-----------------------------------------------------------------------------
67
// PCI access registers
68
 
69
//#define HAL_PCI_ADDRESS_WINDOW_1        0xAF000014
70
//#define HAL_PCI_ADDRESS_WINDOW_2        0xAF000018
71
//#define HAL_PCI_IO_WINDOW               0xAF000024
72
#define HAL_PCI_CONFIG_SPACE_DATA       0xb4000cfc
73
#define HAL_PCI_CONFIG_SPACE_ADDR       0xb4000cf8
74
//#define HAL_PCI_ENABLE_REG              0xAF000074
75
 
76
//-----------------------------------------------------------------------------
77
// Mappings for PCI memory and IO spaces
78
 
79
// These are the offsets programmed into the Galileo for setting up the
80
// CPU->PCI space mapping. These are put high to allow for 256MB RAM in
81
// kseg0/1 - but we'll probably have to put the RAM in kuseg anyway to get
82
// it all mapped (512MB). These mappings leave enough space for the
83
// PCI devices on the Ocelot regardless though.
84
//
85
// Note that the CPU addresses are going directly to the PCI bus, so
86
// the IO/MEM bases are the matching CPU address space locations, not
87
// zero.
88
 
89
#define HAL_OCELOT_PCI_IO_BASE                  0x10000000
90
#define HAL_OCELOT_PCI_IO_SIZE                  0x01000000  // 16 MB
91
#define HAL_OCELOT_PCI_MEM0_BASE                0x12000000
92
#define HAL_OCELOT_PCI_MEM0_SIZE                0x01000000  // 16 MB
93
#define HAL_OCELOT_PCI_MEM1_BASE                0x13000000
94
#define HAL_OCELOT_PCI_MEM1_SIZE                0x01000000  // 16 MB
95
 
96
// This is where the PCI spaces are mapped in the CPU's (virtual)
97
// address space. These are the uncached addresses.
98
#define HAL_PCI_PHYSICAL_MEMORY_BASE            CYGARC_UNCACHED_ADDRESS(0)
99
#define HAL_PCI_PHYSICAL_IO_BASE                CYGARC_UNCACHED_ADDRESS(0)
100
 
101
// Map PCI device resources starting from these addresses in PCI space.
102
#define HAL_PCI_ALLOC_BASE_MEMORY               HAL_OCELOT_PCI_MEM0_BASE
103
#define HAL_PCI_ALLOC_BASE_IO                   HAL_OCELOT_PCI_IO_BASE
104
 
105
 
106
// Uncached controller base
107
#define HAL_GALILEO_CONTROLLER_BASE             0xb4000000
108
 
109
//-----------------------------------------------------------------------------
110
 
111
#define HAL_GALILEO_PUTREG(r,d) \
112
    HAL_WRITE_UINT32((HAL_GALILEO_CONTROLLER_BASE + (r)), \
113
                     ((((d) & 0xff) << 24) | (((d) & 0xff00) << 8) | (((d) & 0xff0000) >> 8) | (((d) >> 24) & 0xff)))
114
#define HAL_GALILEO_GETREG(r)   \
115
    ({ cyg_uint32 d; HAL_READ_UINT32((HAL_GALILEO_CONTROLLER_BASE + (r)), d);\
116
       (((d & 0xff) << 24) | ((d & 0xff00) << 8) | ((d & 0xff0000) >> 8) | ((d >> 24) & 0xff)); })
117
 
118
// PCI config reads are special: all devices but the Galileo itself
119
// are in big-endian mode.  Fiddling the endian configs did not seem
120
// to make a difference.
121
#define HAL_GALILEO_PUTPCI(bus, devfn, r, data)                         \
122
    CYG_MACRO_START                                                     \
123
    if (0 == bus && 0 == devfn)                                         \
124
        HAL_GALILEO_PUTREG(r, data);                                    \
125
    else                                                                \
126
        HAL_WRITE_UINT32((HAL_GALILEO_CONTROLLER_BASE + (r)), data);    \
127
    CYG_MACRO_END
128
 
129
#define HAL_GALILEO_GETPCI(bus, devfn, r, data)                         \
130
    CYG_MACRO_START                                                     \
131
    if (0 == bus && 0 == devfn)                                         \
132
        data = HAL_GALILEO_GETREG(r);                                   \
133
    else                                                                \
134
        HAL_READ_UINT32((HAL_GALILEO_CONTROLLER_BASE + (r)), data);     \
135
    CYG_MACRO_END
136
 
137
 
138
extern cyg_uint32 cyg_hal_plf_pci_cfg_read_dword (cyg_uint32 bus,
139
                                                  cyg_uint32 devfn,
140
                                                  cyg_uint32 offset);
141
extern cyg_uint16 cyg_hal_plf_pci_cfg_read_word  (cyg_uint32 bus,
142
                                                  cyg_uint32 devfn,
143
                                                  cyg_uint32 offset);
144
extern cyg_uint8 cyg_hal_plf_pci_cfg_read_byte   (cyg_uint32 bus,
145
                                                  cyg_uint32 devfn,
146
                                                  cyg_uint32 offset);
147
extern void cyg_hal_plf_pci_cfg_write_dword (cyg_uint32 bus,
148
                                             cyg_uint32 devfn,
149
                                             cyg_uint32 offset,
150
                                             cyg_uint32 val);
151
extern void cyg_hal_plf_pci_cfg_write_word  (cyg_uint32 bus,
152
                                             cyg_uint32 devfn,
153
                                             cyg_uint32 offset,
154
                                             cyg_uint16 val);
155
extern void cyg_hal_plf_pci_cfg_write_byte   (cyg_uint32 bus,
156
                                              cyg_uint32 devfn,
157
                                              cyg_uint32 offset,
158
                                              cyg_uint8 val);
159
 
160
//-----------------------------------------------------------------------------
161
 
162
// Initialize the PCI bus.
163
externC void cyg_hal_plf_pci_init(void);
164
#define HAL_PCI_INIT() cyg_hal_plf_pci_init()
165
 
166
// Read a value from the PCI configuration space of the appropriate
167
// size at an address composed from the bus, devfn and
168
// offset.
169
#define HAL_PCI_CFG_READ_UINT8( __bus, __devfn, __offset, __val )  \
170
    __val = cyg_hal_plf_pci_cfg_read_byte((__bus),  (__devfn), (__offset))
171
 
172
#define HAL_PCI_CFG_READ_UINT16( __bus, __devfn, __offset, __val ) \
173
    __val = cyg_hal_plf_pci_cfg_read_word((__bus),  (__devfn), (__offset))
174
 
175
#define HAL_PCI_CFG_READ_UINT32( __bus, __devfn, __offset, __val ) \
176
    __val = cyg_hal_plf_pci_cfg_read_dword((__bus),  (__devfn), (__offset))
177
 
178
// Write a value to the PCI configuration space of the appropriate
179
// size at an address composed from the bus, devfn and offset.
180
#define HAL_PCI_CFG_WRITE_UINT8( __bus, __devfn, __offset, __val )  \
181
    cyg_hal_plf_pci_cfg_write_byte((__bus),  (__devfn), (__offset), (__val))
182
 
183
#define HAL_PCI_CFG_WRITE_UINT16( __bus, __devfn, __offset, __val ) \
184
    cyg_hal_plf_pci_cfg_write_word((__bus),  (__devfn), (__offset), (__val))
185
 
186
#define HAL_PCI_CFG_WRITE_UINT32( __bus, __devfn, __offset, __val ) \
187
    cyg_hal_plf_pci_cfg_write_dword((__bus),  (__devfn), (__offset), (__val))
188
 
189
 
190
//-----------------------------------------------------------------------------
191
// Resources
192
 
193
// Translate the PCI interrupt requested by the device (INTA#, INTB#,
194
// INTC# or INTD#) to the associated CPU interrupt (i.e., HAL vector).
195
// We don't actually know what the mappings are at present for this
196
// board. The following is therefore just a temporary guess until
197
// we can find out.
198
 
199
#define HAL_PCI_TRANSLATE_INTERRUPT( __bus, __devfn, __vec, __valid)          \
200
    CYG_MACRO_START                                                           \
201
    cyg_uint8 __req;                                                          \
202
    HAL_PCI_CFG_READ_UINT8(__bus, __devfn, CYG_PCI_CFG_INT_PIN, __req);       \
203
    if (0 != __req) {                                                         \
204
        CYG_ADDRWORD __translation[4] = {                                     \
205
            CYGNUM_HAL_INTERRUPT_PCI_INTA,  /* INTA# */                       \
206
            CYGNUM_HAL_INTERRUPT_PCI_INTB,  /* INTB# */                       \
207
            CYGNUM_HAL_INTERRUPT_PCI_INTC,  /* INTC# */                       \
208
            CYGNUM_HAL_INTERRUPT_PCI_INTD };/* INTD# */                       \
209
                                                                              \
210
        __vec = __translation[(((__req-1)+CYG_PCI_DEV_GET_DEV(__devfn))&3)];  \
211
                                                                              \
212
        __valid = true;                                                       \
213
    } else {                                                                  \
214
        /* Device will not generate interrupt requests. */                    \
215
        __valid = false;                                                      \
216
    }                                                                         \
217
    CYG_MACRO_END
218
 
219
// Galileo GT64120 on MIPS Ocelot requires special processing.
220
// First, it will hang when accessing device 31 on the local bus.
221
// Second, we need to ignore the GT64120 so we can set it up
222
// outside the generic PCI library.
223
#define HAL_PCI_IGNORE_DEVICE(__bus, __dev, __fn) \
224
    ((__bus) == 0 && ((__dev) == 0 || (__dev) == 31))
225
 
226
 
227
//-----------------------------------------------------------------------------
228
// PCI / Galileo register definitions
229
#define HAL_GALILEO_PCI0_CONFIG_ADDR_ConfigEn   BIT31
230
#define HAL_GALILEO_PCI0_STATUS_COMMAND_REGNUM  0x04
231
#define HAL_GALILEO_PCI0_BIST_REGNUM            0x0C
232
#define HAL_GALILEO_PCI0_SCS32_BASE_REGNUM      0x14
233
#define HAL_GALILEO_PCI0_CONFIG_MEMEn           0x2
234
#define HAL_GALILEO_PCI0_CONFIG_MasEn           0x4
235
#define HAL_GALILEO_PCI0_CONFIG_SErrEn          0x100
236
#define HAL_GALILEO_PCI0_LAT_TIMER_VAL          0x800
237
#define HAL_GALILEO_PCI0_TIMEOUT_RETRY_VALUE    0x00ffffff
238
 
239
#define HAL_GALILEO_PCI_INTERNAL_COMMAND_OFFSET 0xC00
240
#define HAL_GALILEO_PCI0_TIMEOUT_RETRY_OFFSET   0xc04
241
#define HAL_GALILEO_PCI0_SCS10_SIZE_OFFSET      0xc08
242
#define HAL_GALILEO_PCI0_SCS32_SIZE_OFFSET      0xc0c
243
#define HAL_GALILEO_PCI0_SCS20_SIZE_OFFSET      0xc10
244
#define HAL_GALILEO_PCI0_CS3_SIZE_OFFSET        0xc14
245
#define HAL_GALILEO_BAR_ENA_OFFSET              0xc3c
246
#  define HAL_GALILEO_BAR_ENA_SWCS3  (1 << 0)
247
#  define HAL_GALILEO_BAR_ENA_SWCS32 (1 << 1)
248
#  define HAL_GALILEO_BAR_ENA_SWCS10 (1 << 2)
249
#  define HAL_GALILEO_BAR_ENA_IO     (1 << 3)
250
#  define HAL_GALILEO_BAR_ENA_MEM    (1 << 4)
251
#  define HAL_GALILEO_BAR_ENA_CS3    (1 << 5)
252
#  define HAL_GALILEO_BAR_ENA_CS20   (1 << 6)
253
#  define HAL_GALILEO_BAR_ENA_SCS32  (1 << 7)
254
#  define HAL_GALILEO_BAR_ENA_SCS10  (1 << 8)
255
#define HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET     0xcf8
256
#  define HAL_GALILEO_PCI0_CONFIG_ADDR_ENABLE (1 << 31)
257
#define HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET     0xcfc
258
 
259
#define HAL_OCELOT_NULL_DEVNUM                   0x0
260
 
261
// GALILEO Interrupts
262
#define HAL_GALILEO_IRQ_CAUSE_OFFSET            0xc18
263
#  define HAL_GALILEO_IRQCAUSE_INTSUM   (1 << 0)
264
#  define HAL_GALILEO_IRQCAUSE_MEMOUT   (1 << 1)
265
#  define HAL_GALILEO_IRQCAUSE_DMAOUT   (1 << 2)
266
#  define HAL_GALILEO_IRQCAUSE_CPUOUT   (1 << 3)
267
#  define HAL_GALILEO_IRQCAUSE_DMA0     (1 << 4)
268
#  define HAL_GALILEO_IRQCAUSE_DMA1     (1 << 5)
269
#  define HAL_GALILEO_IRQCAUSE_DMA2     (1 << 6)
270
#  define HAL_GALILEO_IRQCAUSE_DMA3     (1 << 7)
271
#  define HAL_GALILEO_IRQCAUSE_T0       (1 << 8)
272
#  define HAL_GALILEO_IRQCAUSE_T1       (1 << 9)
273
#  define HAL_GALILEO_IRQCAUSE_T2       (1 << 10)
274
#  define HAL_GALILEO_IRQCAUSE_T3       (1 << 11)
275
#  define HAL_GALILEO_IRQCAUSE_MASRD    (1 << 12)
276
#  define HAL_GALILEO_IRQCAUSE_SLVWR    (1 << 13)
277
#  define HAL_GALILEO_IRQCAUSE_MASWR    (1 << 14)
278
#  define HAL_GALILEO_IRQCAUSE_SLVRD    (1 << 15)
279
#  define HAL_GALILEO_IRQCAUSE_AERR     (1 << 16)
280
#  define HAL_GALILEO_IRQCAUSE_MERR     (1 << 17)
281
#  define HAL_GALILEO_IRQCAUSE_MASABT   (1 << 18)
282
#  define HAL_GALILEO_IRQCAUSE_TARABT   (1 << 19)
283
#  define HAL_GALILEO_IRQCAUSE_RETRY    (1 << 20)
284
#  define HAL_GALILEO_IRQCAUSE_CPUSUM   (1 << 30)
285
#  define HAL_GALILEO_IRQCAUSE_PCISUM   (1 << 31)
286
#define HAL_GALILEO_HIRQ_CAUSE_OFFSET           0xc98
287
#define HAL_GALILEO_CPUIRQ_MASK_OFFSET          0xc1c
288
#define HAL_GALILEO_CPUHIRQ_MASK_OFFSET         0xc9c
289
 
290
/* Galileo Memory Controller registers */
291
#define HAL_GALILEO_SDRAM_DUPLICATE_BANK_ADDR   BIT20
292
#define HAL_GALILEO_SDRAM_BANK_INTERLEAVE_DIS   BIT14
293
#define HAL_GALILEO_CPU_DECODE_SHIFT            21
294
#define HAL_GALILEO_DEV_DECODE_SHIFT            20
295
#define HAL_GALILEO_SDRAM_SRAS_TO_SCAS_DELAY_3C BIT10
296
#define HAL_GALILEO_SDRAM_WIDTH_64BIT           BIT6
297
#define HAL_GALILEO_SDRAM_SRAS_PRECHARGE_3C     BIT3
298
#define HAL_GALILEO_SDRAM_BANK0_CASLAT_2        BIT0
299
#define HAL_GALILEO_SDRAM_BANK0_SZ_64M          BIT11
300
#define HAL_GALILEO_SDRAM_NUM_BANKS_4           BIT5
301
#define HAL_GALILEO_SDRAM_BANK0_PARITY          BIT8
302
#define HAL_GALILEO_SDRAM_CFG_RAM_WIDTH         BIT15
303
#define HAL_GALILEO_PCI0_CONFIG_ADDR_ConfigEn   BIT31
304
#define HAL_GALILEO_PCI0_STATUS_COMMAND_REGNUM  0x04
305
#define HAL_GALILEO_PCI0_BIST_REGNUM            0x0C
306
#define HAL_GALILEO_PCI0_SCS32_BASE_REGNUM      0x14
307
#define HAL_GALILEO_PCI0_CONFIG_MEMEn           0x2
308
#define HAL_GALILEO_PCI0_CONFIG_MasEn           0x4
309
#define HAL_GALILEO_PCI0_CONFIG_SErrEn          0x100
310
#define HAL_GALILEO_PCI0_LAT_TIMER_VAL          0x800
311
#define HAL_GALILEO_PCI0_TIMEOUT_RETRY_VALUE    0x00ffffff
312
 
313
#define HAL_GALILEO_SDRAM_BANK0_OFFSET          0x44c
314
#define HAL_GALILEO_SDRAM_BANK2_OFFSET          0x454
315
#define HAL_GALILEO_SDRAM_CONFIG_OFFSET         0x448
316
 
317
#define HAL_GALILEO_SCS10_LD_OFFSET             0x008
318
#define HAL_GALILEO_SCS10_HD_OFFSET             0x010
319
#define HAL_GALILEO_SCS32_LD_OFFSET             0x018
320
#define HAL_GALILEO_SCS32_HD_OFFSET             0x020
321
#define HAL_GALILEO_CS20_LD_OFFSET              0x028
322
#define HAL_GALILEO_CS20_HD_OFFSET              0x030
323
#define HAL_GALILEO_PCIIO_LD_OFFSET             0x048
324
#define HAL_GALILEO_PCIIO_HD_OFFSET             0x050
325
#define HAL_GALILEO_PCIMEM0_LD_OFFSET           0x058
326
#define HAL_GALILEO_PCIMEM0_HD_OFFSET           0x060
327
#define HAL_GALILEO_PCIMEM1_LD_OFFSET           0x080
328
#define HAL_GALILEO_PCIMEM1_HD_OFFSET           0x088
329
#define HAL_GALILEO_PCI1IO_LD_OFFSET            0x090
330
#define HAL_GALILEO_PCI1IO_HD_OFFSET            0x098
331
#define HAL_GALILEO_PCI1MEM0_LD_OFFSET          0x0a0
332
#define HAL_GALILEO_PCI1MEM0_HD_OFFSET          0x0a8
333
#define HAL_GALILEO_PCI1MEM1_LD_OFFSET          0x0b0
334
#define HAL_GALILEO_PCI1MEM1_HD_OFFSET          0x0b8
335
#define HAL_GALILEO_PCIIO_REMAP_OFFSET          0x0f0
336
#define HAL_GALILEO_PCIMEM0_REMAP_OFFSET        0x0f8
337
#define HAL_GALILEO_PCIMEM1_REMAP_OFFSET        0x100
338
#define HAL_GALILEO_SCS0_LD_OFFSET              0x400
339
#define HAL_GALILEO_SCS0_HD_OFFSET              0x404
340
#define HAL_GALILEO_SCS1_LD_OFFSET              0x408
341
#define HAL_GALILEO_SCS1_HD_OFFSET              0x40c
342
#define HAL_GALILEO_SCS2_LD_OFFSET              0x410
343
#define HAL_GALILEO_SCS2_HD_OFFSET              0x414
344
#define HAL_GALILEO_SCS3_LD_OFFSET              0x418
345
#define HAL_GALILEO_SCS3_HD_OFFSET              0x41c
346
#define HAL_GALILEO_CS0_LD_OFFSET               0x420
347
#define HAL_GALILEO_CS0_HD_OFFSET               0x424
348
#define HAL_GALILEO_CS1_LD_OFFSET               0x428
349
#define HAL_GALILEO_CS1_HD_OFFSET               0x42c
350
#define HAL_GALILEO_CS2_LD_OFFSET               0x430
351
#define HAL_GALILEO_CS2_HD_OFFSET               0x434
352
#define HAL_GALILEO_CPU_DECODE_SHIFT            21
353
 
354
//-----------------------------------------------------------------------------
355
// end of plf_io.h
356
#endif // CYGONCE_PLF_IO_H

powered by: WebSVN 2.1.0

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