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

Subversion Repositories openrisc

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

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):    dmoseley
47
// Contributors: dmoseley, jskov
48
// Date:         2001-03-20
49
// Purpose:      Malta platform IO support
50
// Description: 
51
// Usage:        #include <cyg/hal/plf_io.h>
52
//
53
//####DESCRIPTIONEND####
54
//
55
//=============================================================================
56
 
57
#include <pkgconf/hal.h>
58
#include <cyg/hal/hal_misc.h>
59
#include <cyg/hal/hal_arch.h>
60
#include <cyg/hal/plf_intr.h>
61
 
62
#ifdef __ASSEMBLER__
63
#define HAL_REG(x)              x
64
#define HAL_REG8(x)             x
65
#define HAL_REG16(x)            x
66
#else
67
#define HAL_REG(x)              (volatile CYG_WORD *)(x)
68
#define HAL_REG8(x)             (volatile CYG_BYTE *)(x)
69
#define HAL_REG16(x)            (volatile CYG_WORD16 *)(x)
70
#endif
71
 
72
//-----------------------------------------------------------------------------
73
 
74
/* Malta Memory Definitions */
75
#define HAL_MALTA_RAM_BASE                      0x00000000
76
#define HAL_MALTA_PCI_MEM0_BASE                 0x08000000
77
#define HAL_MALTA_PCI_MEM0_SIZE                 0x08000000  // 128 MB
78
#define HAL_MALTA_PCI_MEM1_BASE                 0x10000000
79
#define HAL_MALTA_PCI_MEM1_SIZE                 0x08000000  // 128 MB
80
 
81
#define HAL_MALTA_PCI_IO_BASE                   0x18000000
82
#define HAL_MALTA_PCI_IO_SIZE                   0x03d00000  //  62 MB
83
#define HAL_MALTA_CONTROLLER_BASE               0x1BE00000
84
#define HAL_MALTA_CONTROLLER_BASE_ISD_CONFIG    (HAL_MALTA_CONTROLLER_BASE >> 21)
85
#define HAL_MALTA_FLASH_BASE                    0x1E000000
86
#define HAL_MALTA_FLASH_SIZE                    SZ_4M
87
#define HAL_MALTA_MAX_BANKSIZE                  SZ_128M
88
 
89
#define HAL_MALTA_NULL_DEVNUM                   0x0
90
#define HAL_MALTA_MEMERROR                      1
91
 
92
// PCI registers
93
#define _PIIX4_PCI_ID   10
94
#define _PIIX4_BRIDGE    0
95
#define _PIIX4_IDE       1
96
#define _PIIX4_USB       2
97
#define _PIIX4_POWER     3
98
 
99
#define CYG_PCI_CFG_PIIX4_PIRQR          0x60
100
#define CYG_PCI_CFG_PIIX4_SERIRQC        0x64
101
#define CYG_PCI_CFG_PIIX4_TOM            0x69
102
#define CYG_PCI_CFG_PIIX4_GENCFG         0xb0
103
 
104
#define CYG_PCI_CFG_PIIX4_IDETIM         0x40
105
#define CYG_PCI_CFG_PIIX4_IDETIM_IDE     0x8000
106
#define CYG_PCI_CFG_PIIX4_IDETIM_SITRE   0x4000
107
#define CYG_PCI_CFG_PIIX4_IDETIM_DTE1    0x0080
108
#define CYG_PCI_CFG_PIIX4_IDETIM_PPE1    0x0040
109
#define CYG_PCI_CFG_PIIX4_IDETIM_IE1     0x0020
110
#define CYG_PCI_CFG_PIIX4_IDETIM_TIME1   0x0010
111
#define CYG_PCI_CFG_PIIX4_IDETIM_DTE0    0x0008
112
#define CYG_PCI_CFG_PIIX4_IDETIM_PPE0    0x0004
113
#define CYG_PCI_CFG_PIIX4_IDETIM_IE0     0x0002
114
#define CYG_PCI_CFG_PIIX4_IDETIM_TIME0   0x0001
115
 
116
#define CYG_PCI_CFG_PIIX4_SERIRQC_ENABLE 0x80
117
#define CYG_PCI_CFG_PIIX4_SERIRQC_CONT   0x40
118
 
119
#define CYG_PCI_CFG_PIIX4_TOM_TOM_MASK 0xf0
120
#define CYG_PCI_CFG_PIIX4_TOM_TOM_16M  0xf0
121
 
122
#define CYG_PCI_CFG_PIIX4_GENCFG_ISA    0x00000001
123
#define CYG_PCI_CFG_PIIX4_GENCFG_SERIRQ 0x00010000
124
 
125
 
126
 
127
/* Malta Registers */
128
#define HAL_MALTA_REGISTER_BASE                 0xBF000000
129
 
130
#define HAL_MALTA_NMISTATUS_OFFSET              0x00000024
131
#define HAL_MALTA_NMIACK_OFFSET                 0x00000104
132
#define HAL_MALTA_SOFTRES_OFFSET                0x00000500
133
#define HAL_MALTA_BRKRES_OFFSET                 0x00000508
134
#define HAL_MALTA_REVISION_OFFSET               0x00C00010
135
 
136
#define HAL_MALTA_NMISTATUS                     HAL_REG(HAL_MALTA_REGISTER_BASE + HAL_MALTA_NMISTATUS_OFFSET)
137
#define HAL_MALTA_NMIACK                        HAL_REG(HAL_MALTA_REGISTER_BASE + HAL_MALTA_NMIACK_OFFSET)
138
#define HAL_MALTA_SOFTRES                       HAL_REG(HAL_MALTA_REGISTER_BASE + HAL_MALTA_SOFTRES_OFFSET)
139
#define HAL_MALTA_BRKRES                        HAL_REG(HAL_MALTA_REGISTER_BASE + HAL_MALTA_BRKRES_OFFSET)
140
#define HAL_MALTA_REVISION                      HAL_REG(HAL_MALTA_REGISTER_BASE + HAL_MALTA_REVISION_OFFSET)
141
 
142
/* Malta NMI controller fields */
143
#define HAL_MALTA_NMISTATUS_FLAG                0x00000001
144
#define HAL_MALTA_NMIACK_FLAG                   0x00000001
145
 
146
/* Malta softreset fields */
147
#define HAL_MALTA_GORESET                       0x42
148
 
149
/* Malta brkreset fields */
150
#define HAL_MALTA_BRKRES_DEFAULT_VALUE          0xA
151
 
152
// PIIX4 registers
153
#define HAL_PIIX4_REGISTER_BASE        0xb8000000
154
 
155
// PIIX4 interrupt controller stuff
156
#define HAL_PIIX4_MASTER_ICW1          HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x0020)
157
#define HAL_PIIX4_MASTER_ICW2          HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x0021)
158
#define HAL_PIIX4_MASTER_ICW3          HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x0021)
159
#define HAL_PIIX4_MASTER_ICW4          HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x0021)
160
#define HAL_PIIX4_MASTER_OCW3          HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x0020)
161
#define HAL_PIIX4_MASTER_OCW1          HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x0021)
162
 
163
#define HAL_PIIX4_SLAVE_ICW1           HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x00a0)
164
#define HAL_PIIX4_SLAVE_OCW3           HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x00a0)
165
#define HAL_PIIX4_SLAVE_ICW2           HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x00a1)
166
#define HAL_PIIX4_SLAVE_ICW3           HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x00a1)
167
#define HAL_PIIX4_SLAVE_ICW4           HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x00a1)
168
#define HAL_PIIX4_SLAVE_OCW1           HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x00a1)
169
 
170
#define HAL_PIIX4_MASTER_SLAVE_OFFSET  0x80
171
 
172
#define HAL_PIIX4_ELCR1                HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x04d0)
173
#define HAL_PIIX4_ELCR2                HAL_REG(HAL_PIIX4_REGISTER_BASE + 0x04d1)
174
 
175
#define HAL_PIIX4_ICW1_SEL             0x10
176
#define HAL_PIIX4_ICW1_WR              0x01
177
#define HAL_PIIX4_ICW3_CASCADE         0x04
178
#define HAL_PIIX4_ICW3_SLAVE           0x02
179
#define HAL_PIIX4_ICW4_UPMODE          0x01
180
 
181
#define HAL_PIIX4_OCW3_ESSM            0x40
182
#define HAL_PIIX4_OCW3_SEL             0x08
183
#define HAL_PIIX4_OCW3_REQ             0x02
184
#define HAL_PIIX4_OCW3_IS              0x03
185
 
186
#define HAL_PIIX4_ELCR1_MASK           0xf8
187
#define HAL_PIIX4_ELCR2_MASK           0xde
188
 
189
// PIIX4 IDE interface
190
#define HAL_PIIX4_IDE_PRI_CMD          (HAL_PIIX4_REGISTER_BASE + 0x01f0)
191
#define HAL_PIIX4_IDE_PRI_CTL          (HAL_PIIX4_REGISTER_BASE + 0x03f4)
192
#define HAL_PIIX4_IDE_SEC_CMD          (HAL_PIIX4_REGISTER_BASE + 0x0170)
193
#define HAL_PIIX4_IDE_SEC_CTL          (HAL_PIIX4_REGISTER_BASE + 0x0374)
194
 
195
/* Galileo Registers */
196
#define HAL_GALILEO_REGISTER_BASE               0xB4000000
197
#define HAL_GALILEO_PCI0_MEM0_BASE              0xB2000000
198
 
199
#define HAL_GALILEO_CPU_INTERFACE_CONFIG_OFFSET 0x0
200
#define HAL_GALILEO_INT_SPACE_DECODE_OFFSET     0x68
201
#define HAL_GALILEO_CS3_HIGH_DECODE_OFFSET      0x43c
202
#define HAL_GALILEO_CSBOOT_LOW_DECODE_OFFSET    0x440
203
#define HAL_GALILEO_CSBOOT_HIGH_DECODE_OFFSET   0x444
204
 
205
/* Galileo CPU Interface config fields */
206
#define HAL_GALILEO_BYTE_SWAP                   (BIT16 | BIT0)
207
 
208
#define HAL_GALILEO_CACHEOPMAP_MASK             0x000001FF
209
#define HAL_GALILEO_CACHEPRES_MASK              0x00000200
210
#define HAL_GALILEO_WRITEMODE_MASK              0x00000800
211
#define HAL_GALILEO_ENDIAN_MASK                 0x00001000
212
#define HAL_GALILEO_R5KL2_MASK                  0x00004000
213
#define HAL_GALILEO_EXT_HIT_DELAY_MASK          0x00008000
214
#define HAL_GALILEO_CPU_WRITERATE_MASK          0x00010000
215
#define HAL_GALILEO_STOP_RETRY_MASK             0x00020000
216
#define HAL_GALILEO_MULTI_GT_MASK               0x00040000
217
#define HAL_GALILEO_SYSADCVALID_MASK            0x00080000
218
 
219
/* Galileo Memory Controller registers */
220
#define HAL_GALILEO_SDRAM_DUPLICATE_BANK_ADDR   BIT20
221
#define HAL_GALILEO_SDRAM_BANK_INTERLEAVE_DIS   BIT14
222
#define HAL_GALILEO_CPU_DECODE_SHIFT            21
223
#define HAL_GALILEO_DEV_DECODE_SHIFT            20
224
#define HAL_GALILEO_SDRAM_SRAS_TO_SCAS_DELAY_3C BIT10
225
#define HAL_GALILEO_SDRAM_WIDTH_64BIT           BIT6
226
#define HAL_GALILEO_SDRAM_SRAS_PRECHARGE_3C     BIT3
227
#define HAL_GALILEO_SDRAM_BANK0_CASLAT_2        BIT0
228
#define HAL_GALILEO_SDRAM_BANK0_SZ_64M          BIT11
229
#define HAL_GALILEO_SDRAM_NUM_BANKS_4           BIT5
230
#define HAL_GALILEO_SDRAM_BANK0_PARITY          BIT8
231
#define HAL_GALILEO_SDRAM_CFG_RAM_WIDTH         BIT15
232
#define HAL_GALILEO_PCI0_CONFIG_ADDR_ConfigEn   BIT31
233
#define HAL_GALILEO_PCI0_STATUS_COMMAND_REGNUM  0x04
234
#define HAL_GALILEO_PCI0_BIST_REGNUM            0x0C
235
#define HAL_GALILEO_PCI0_SCS32_BASE_REGNUM      0x14
236
#define HAL_GALILEO_PCI0_CONFIG_IOEn            0x1
237
#define HAL_GALILEO_PCI0_CONFIG_MEMEn           0x2
238
#define HAL_GALILEO_PCI0_CONFIG_MasEn           0x4
239
#define HAL_GALILEO_PCI0_CONFIG_SErrEn          0x100
240
#define HAL_GALILEO_PCI0_LAT_TIMER_VAL          0x800
241
#define HAL_GALILEO_PCI0_TIMEOUT_RETRY_VALUE    0x00ffffff
242
 
243
#define HAL_GALILEO_SDRAM_BANK0_OFFSET          0x44c
244
#define HAL_GALILEO_SDRAM_BANK2_OFFSET          0x454
245
#define HAL_GALILEO_SDRAM_CONFIG_OFFSET         0x448
246
 
247
#define HAL_GALILEO_SCS10_LD_OFFSET             0x008
248
#define HAL_GALILEO_SCS10_HD_OFFSET             0x010
249
#define HAL_GALILEO_SCS32_LD_OFFSET             0x018
250
#define HAL_GALILEO_SCS32_HD_OFFSET             0x020
251
#define HAL_GALILEO_CS20_LD_OFFSET              0x028
252
#define HAL_GALILEO_CS20_HD_OFFSET              0x030
253
#define HAL_GALILEO_PCIIO_LD_OFFSET             0x048
254
#define HAL_GALILEO_PCIIO_HD_OFFSET             0x050
255
#define HAL_GALILEO_PCIMEM0_LD_OFFSET           0x058
256
#define HAL_GALILEO_PCIMEM0_HD_OFFSET           0x060
257
#define HAL_GALILEO_PCIMEM1_LD_OFFSET           0x080
258
#define HAL_GALILEO_PCIMEM1_HD_OFFSET           0x088
259
#define HAL_GALILEO_PCI1IO_LD_OFFSET            0x090
260
#define HAL_GALILEO_PCI1IO_HD_OFFSET            0x098
261
#define HAL_GALILEO_PCI1MEM0_LD_OFFSET          0x0a0
262
#define HAL_GALILEO_PCI1MEM0_HD_OFFSET          0x0a8
263
#define HAL_GALILEO_PCI1MEM1_LD_OFFSET          0x0b0
264
#define HAL_GALILEO_PCI1MEM1_HD_OFFSET          0x0b8
265
#define HAL_GALILEO_PCI_IO_REMAP                0x0f0
266
 
267
#define HAL_GALILEO_SCS0_LD_OFFSET              0x400
268
#define HAL_GALILEO_SCS0_HD_OFFSET              0x404
269
#define HAL_GALILEO_SCS1_LD_OFFSET              0x408
270
#define HAL_GALILEO_SCS1_HD_OFFSET              0x40c
271
#define HAL_GALILEO_SCS2_LD_OFFSET              0x410
272
#define HAL_GALILEO_SCS2_HD_OFFSET              0x414
273
#define HAL_GALILEO_SCS3_LD_OFFSET              0x418
274
#define HAL_GALILEO_SCS3_HD_OFFSET              0x41c
275
#define HAL_GALILEO_CS0_LD_OFFSET               0x420
276
#define HAL_GALILEO_CS0_HD_OFFSET               0x424
277
#define HAL_GALILEO_CS1_LD_OFFSET               0x428
278
#define HAL_GALILEO_CS1_HD_OFFSET               0x42c
279
#define HAL_GALILEO_CS2_LD_OFFSET               0x430
280
#define HAL_GALILEO_CS2_HD_OFFSET               0x434
281
 
282
// GALILEO PCI Internal
283
#define HAL_GALILEO_PCI_INTERNAL_COMMAND_OFFSET 0xC00
284
#define HAL_GALILEO_PCI0_TIMEOUT_RETRY_OFFSET   0xc04
285
#define HAL_GALILEO_PCI0_SCS10_SIZE_OFFSET      0xc08
286
#define HAL_GALILEO_PCI0_SCS32_SIZE_OFFSET      0xc0c
287
#define HAL_GALILEO_PCI0_SCS20_SIZE_OFFSET      0xc10
288
#define HAL_GALILEO_PCI0_CS3_SIZE_OFFSET        0xc14
289
#define HAL_GALILEO_BAR_ENA_OFFSET              0xc3c
290
#  define HAL_GALILEO_BAR_ENA_SWCS3  (1 << 0)
291
#  define HAL_GALILEO_BAR_ENA_SWCS32 (1 << 1)
292
#  define HAL_GALILEO_BAR_ENA_SWCS10 (1 << 2)
293
#  define HAL_GALILEO_BAR_ENA_IO     (1 << 3)
294
#  define HAL_GALILEO_BAR_ENA_MEM    (1 << 4)
295
#  define HAL_GALILEO_BAR_ENA_CS3    (1 << 5)
296
#  define HAL_GALILEO_BAR_ENA_CS20   (1 << 6)
297
#  define HAL_GALILEO_BAR_ENA_SCS32  (1 << 7)
298
#  define HAL_GALILEO_BAR_ENA_SCS10  (1 << 8)
299
#define HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET     0xcf8
300
#  define HAL_GALILEO_PCI0_CONFIG_ADDR_ENABLE (1 << 31)
301
#define HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET     0xcfc
302
 
303
// GALILEO Interrupts
304
#define HAL_GALILEO_IRQ_CAUSE_OFFSET            0xc18
305
#  define HAL_GALILEO_IRQCAUSE_INTSUM   (1 << 0)
306
#  define HAL_GALILEO_IRQCAUSE_MEMOUT   (1 << 1)
307
#  define HAL_GALILEO_IRQCAUSE_DMAOUT   (1 << 2)
308
#  define HAL_GALILEO_IRQCAUSE_CPUOUT   (1 << 3)
309
#  define HAL_GALILEO_IRQCAUSE_DMA0     (1 << 4)
310
#  define HAL_GALILEO_IRQCAUSE_DMA1     (1 << 5)
311
#  define HAL_GALILEO_IRQCAUSE_DMA2     (1 << 6)
312
#  define HAL_GALILEO_IRQCAUSE_DMA3     (1 << 7)
313
#  define HAL_GALILEO_IRQCAUSE_T0       (1 << 8)
314
#  define HAL_GALILEO_IRQCAUSE_T1       (1 << 9)
315
#  define HAL_GALILEO_IRQCAUSE_T2       (1 << 10)
316
#  define HAL_GALILEO_IRQCAUSE_T3       (1 << 11)
317
#  define HAL_GALILEO_IRQCAUSE_MASRD    (1 << 12)
318
#  define HAL_GALILEO_IRQCAUSE_SLVWR    (1 << 13)
319
#  define HAL_GALILEO_IRQCAUSE_MASWR    (1 << 14)
320
#  define HAL_GALILEO_IRQCAUSE_SLVRD    (1 << 15)
321
#  define HAL_GALILEO_IRQCAUSE_AERR     (1 << 16)
322
#  define HAL_GALILEO_IRQCAUSE_MERR     (1 << 17)
323
#  define HAL_GALILEO_IRQCAUSE_MASABT   (1 << 18)
324
#  define HAL_GALILEO_IRQCAUSE_TARABT   (1 << 19)
325
#  define HAL_GALILEO_IRQCAUSE_RETRY    (1 << 20)
326
#  define HAL_GALILEO_IRQCAUSE_CPUSUM   (1 << 30)
327
#  define HAL_GALILEO_IRQCAUSE_PCISUM   (1 << 31)
328
#define HAL_GALILEO_HIRQ_CAUSE_OFFSET           0xc98
329
#define HAL_GALILEO_CPUIRQ_MASK_OFFSET          0xc1c
330
#define HAL_GALILEO_CPUHIRQ_MASK_OFFSET         0xc9c
331
 
332
 
333
#define HAL_I2CFPGA_BASE                        0x1f000b00
334
#define HAL_I2CFPGA_INP                         0x00
335
#define HAL_I2CFPGA_OE                          0x08
336
#define HAL_I2CFPGA_OUT                         0x10
337
#define HAL_I2CFPGA_SEL                         0x18
338
 
339
#define HAL_I2CFPGA_SEL_FPGA                    0x00000001
340
#define HAL_I2CFPGA_SEL_SB                      0x00000000
341
 
342
#define HAL_I2CFPGA_OE_SCL_OUT                  0x00000002
343
#define HAL_I2CFPGA_OE_SCL_TRI                  0x00000000
344
#define HAL_I2CFPGA_OE_SDA_OUT                  0x00000001
345
#define HAL_I2CFPGA_OE_SDA_TRI                  0x00000000
346
 
347
#define HAL_I2CFPGA_OUT_SCL_HIGH                0x00000002
348
#define HAL_I2CFPGA_OUT_SCL_LOW                 0x00000000
349
#define HAL_I2CFPGA_OUT_SDA_HIGH                0x00000001
350
#define HAL_I2CFPGA_OUT_SDA_LOW                 0x00000000
351
 
352
 
353
#define HAL_I2CFPGA_IN_SDA_MASK                 0x00000001
354
 
355
#define HAL_I2CFPGA_OUT_SDA_ACK                 0x00000000
356
#define HAL_I2CFPGA_OUT_SDA_NACK                0x00000001
357
#define HAL_I2CFPGA_OUT_SDA_WAIT_ACK            0x00000001
358
 
359
 
360
#define HAL_I2C_WRITE                           0x00
361
#define HAL_I2C_READ                            0x01
362
 
363
#define HAL_I2C_SPD_ADDRESS                     0xa0
364
 
365
#define HAL_I2C_COUT_DOUT                       (HAL_I2CFPGA_OE_SCL_OUT|HAL_I2CFPGA_OE_SDA_OUT)
366
#define HAL_I2C_COUT_DIN                        (HAL_I2CFPGA_OE_SCL_OUT|HAL_I2CFPGA_OE_SDA_TRI)
367
#define HAL_I2C_CIN_DIN                         (HAL_I2CFPGA_OE_SCL_TRI|HAL_I2CFPGA_OE_SDA_TRI)
368
#define HAL_I2C_CHIGH_DHIGH                     (HAL_I2CFPGA_OUT_SCL_HIGH|HAL_I2CFPGA_OUT_SDA_HIGH)
369
#define HAL_I2C_CHIGH_DLOW                      (HAL_I2CFPGA_OUT_SCL_HIGH|HAL_I2CFPGA_OUT_SDA_LOW)
370
#define HAL_I2C_CLOW_DLOW                       (HAL_I2CFPGA_OUT_SCL_LOW|HAL_I2CFPGA_OUT_SDA_LOW)
371
#define HAL_I2C_CLOW_DHIGH                      (HAL_I2CFPGA_OUT_SCL_LOW|HAL_I2CFPGA_OUT_SDA_HIGH)
372
 
373
 
374
#define HAL_SPD_GET_NUM_ROW_BITS                3
375
#define HAL_SPD_GET_NUM_COL_BITS                4
376
#define HAL_SPD_GET_NUM_MODULE_BANKS            5
377
#define HAL_SPD_GET_SDRAM_WIDTH                 6
378
#define HAL_SPD_GET_CONFIG_TYPE                 11
379
#define HAL_SPD_GET_REFRESH_RATE                12
380
#define HAL_SPD_GET_ERROR_CHECK_WIDTH           14
381
#define HAL_SPD_GET_BURST_LENGTH                16
382
#define HAL_SPD_GET_NUM_DEVICE_BANKS            17
383
#define HAL_SPD_GET_CAS_LAT                     18
384
#define HAL_SPD_GET_ROW_DENSITY                 31
385
#define HAL_SPD_CONFIG_TYPE_PARITY              BIT0
386
#define HAL_SPD_CONFIG_TYPE_ECC                 BIT1
387
#define HAL_SPD_REFRESH_RATE_125                5
388
#define HAL_SPD_REFRESH_RATE_62_5               4
389
#define HAL_SPD_REFRESH_RATE_31_3               3
390
#define HAL_SPD_REFRESH_RATE_15_625             0
391
#define HAL_SPD_REFRESH_RATE_7_8                2
392
#define HAL_SPD_REFRESH_RATE_3_9                1
393
 
394
#define HAL_SPD_REFRESH_COUNTER_125             (125*2)
395
#define HAL_SPD_REFRESH_COUNTER_62_5            (62*2)
396
#define HAL_SPD_REFRESH_COUNTER_31_3            (31*2)
397
#define HAL_SPD_REFRESH_COUNTER_15_625          (15*2)
398
#define HAL_SPD_REFRESH_COUNTER_7_8             (7*2)
399
#define HAL_SPD_REFRESH_COUNTER_3_9             (3*2)
400
 
401
/* Malta Display Registers */
402
#define HAL_DISPLAY_BASE                        (HAL_MALTA_REGISTER_BASE + 0x400)
403
 
404
#define HAL_DISPLAY_LEDGREEN_OFFSET             0x00
405
#define HAL_DISPLAY_LEDBAR_OFFSET               0x08
406
#define HAL_DISPLAY_ASCIIWORD_OFFSET            0x10
407
#define HAL_DISPLAY_ASCIIPOS0_OFFSET            0x18
408
#define HAL_DISPLAY_ASCIIPOS1_OFFSET            0x20
409
#define HAL_DISPLAY_ASCIIPOS2_OFFSET            0x28
410
#define HAL_DISPLAY_ASCIIPOS3_OFFSET            0x30
411
#define HAL_DISPLAY_ASCIIPOS4_OFFSET            0x38
412
#define HAL_DISPLAY_ASCIIPOS5_OFFSET            0x40
413
#define HAL_DISPLAY_ASCIIPOS6_OFFSET            0x48
414
#define HAL_DISPLAY_ASCIIPOS7_OFFSET            0x50
415
 
416
#define HAL_DISPLAY_LEDGREEN                    HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_LEDGREEN_OFFSET)
417
#define HAL_DISPLAY_LEDBAR                      HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_LEDBAR_OFFSET)
418
#define HAL_DISPLAY_ASCIIWORD                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIWORD_OFFSET)
419
#define HAL_DISPLAY_ASCIIPOS0                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIPOS0_OFFSET)
420
#define HAL_DISPLAY_ASCIIPOS1                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIPOS1_OFFSET)
421
#define HAL_DISPLAY_ASCIIPOS2                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIPOS2_OFFSET)
422
#define HAL_DISPLAY_ASCIIPOS3                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIPOS3_OFFSET)
423
#define HAL_DISPLAY_ASCIIPOS4                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIPOS4_OFFSET)
424
#define HAL_DISPLAY_ASCIIPOS5                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIPOS5_OFFSET)
425
#define HAL_DISPLAY_ASCIIPOS6                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIPOS6_OFFSET)
426
#define HAL_DISPLAY_ASCIIPOS7                   HAL_REG(HAL_DISPLAY_BASE + HAL_DISPLAY_ASCIIPOS7_OFFSET)
427
 
428
#ifdef __ASSEMBLER__
429
 
430
#  define DEBUG_ASCII_DISPLAY(register, character)             \
431
        li      k0, CYGARC_UNCACHED_ADDRESS(register);                 \
432
        li      k1, character;                                         \
433
        sw      k1, 0(k0);                                             \
434
    nop;                                                       \
435
    nop;                                                       \
436
    nop
437
 
438
#  define DEBUG_LED_IMM(val)                                   \
439
    li k0, HAL_DISPLAY_LEDBAR;                                 \
440
    li k1, val;                                                \
441
    sw k1, 0(k0)
442
 
443
#  define DEBUG_LED_REG(reg)                                   \
444
    li k0, HAL_DISPLAY_LEDBAR;                                 \
445
    sw reg, 0(k0)
446
 
447
#  define DEBUG_HEX_DISPLAY_IMM(val)                           \
448
    li k0, HAL_DISPLAY_ASCIIWORD;                              \
449
    li k1, val;                                                \
450
    sw k1, 0(k0)
451
 
452
#  define DEBUG_HEX_DISPLAY_REG(reg)                           \
453
    li k0, HAL_DISPLAY_ASCIIWORD;                              \
454
    sw reg, 0(k0)
455
 
456
#  define DEBUG_DELAY()                                        \
457
     li k0, 0x20000;                                           \
458
0:        sub k0, k0, 1;                                            \
459
     bnez k0, 0b;                                              \
460
     nop
461
 
462
#else
463
 
464
#  define DEBUG_ASCII_DISPLAY(register, character)             \
465
    *(register) = character
466
 
467
#  define DEBUG_LED_IMM(val)                                   \
468
    *HAL_DISPLAY_LEDBAR = val
469
 
470
#  define DEBUG_HEX_DISPLAY_IMM(val)                           \
471
    *HAL_DISPLAY_ASCIIWORD = val
472
 
473
#  define DEBUG_DELAY()                                        \
474
   {                                                           \
475
     volatile int i = 0x20000;                                 \
476
     while (--i) ;                                             \
477
   }
478
 
479
#  define DEBUG_DISPLAY(str)                                   \
480
   {                                                           \
481
     DEBUG_ASCII_DISPLAY(HAL_DISPLAY_ASCIIPOS0, str[0]);       \
482
     DEBUG_ASCII_DISPLAY(HAL_DISPLAY_ASCIIPOS1, str[1]);       \
483
     DEBUG_ASCII_DISPLAY(HAL_DISPLAY_ASCIIPOS2, str[2]);       \
484
     DEBUG_ASCII_DISPLAY(HAL_DISPLAY_ASCIIPOS3, str[3]);       \
485
     DEBUG_ASCII_DISPLAY(HAL_DISPLAY_ASCIIPOS4, str[4]);       \
486
     DEBUG_ASCII_DISPLAY(HAL_DISPLAY_ASCIIPOS5, str[5]);       \
487
     DEBUG_ASCII_DISPLAY(HAL_DISPLAY_ASCIIPOS6, str[6]);       \
488
     DEBUG_ASCII_DISPLAY(HAL_DISPLAY_ASCIIPOS7, str[7]);       \
489
   }
490
 
491
 
492
#define HAL_GALILEO_PUTREG(x,y) \
493
    (*((volatile unsigned *)(CYGARC_UNCACHED_ADDRESS(HAL_MALTA_CONTROLLER_BASE) + (x))) = (y))
494
#define HAL_GALILEO_GETREG(x)   \
495
    (*((volatile unsigned *)(CYGARC_UNCACHED_ADDRESS(HAL_MALTA_CONTROLLER_BASE) + (x))))
496
 
497
 
498
extern cyg_uint32 cyg_hal_plf_pci_cfg_read_dword (cyg_uint32 bus,
499
                                                  cyg_uint32 devfn,
500
                                                  cyg_uint32 offset);
501
extern cyg_uint16 cyg_hal_plf_pci_cfg_read_word  (cyg_uint32 bus,
502
                                                  cyg_uint32 devfn,
503
                                                  cyg_uint32 offset);
504
extern cyg_uint8 cyg_hal_plf_pci_cfg_read_byte   (cyg_uint32 bus,
505
                                                  cyg_uint32 devfn,
506
                                                  cyg_uint32 offset);
507
extern void cyg_hal_plf_pci_cfg_write_dword (cyg_uint32 bus,
508
                                             cyg_uint32 devfn,
509
                                             cyg_uint32 offset,
510
                                             cyg_uint32 val);
511
extern void cyg_hal_plf_pci_cfg_write_word  (cyg_uint32 bus,
512
                                             cyg_uint32 devfn,
513
                                             cyg_uint32 offset,
514
                                             cyg_uint16 val);
515
extern void cyg_hal_plf_pci_cfg_write_byte   (cyg_uint32 bus,
516
                                              cyg_uint32 devfn,
517
                                              cyg_uint32 offset,
518
                                              cyg_uint8 val);
519
 
520
// Initialize the PCI bus.
521
externC void cyg_hal_plf_pci_init(void);
522
#define HAL_PCI_INIT() cyg_hal_plf_pci_init()
523
 
524
// leave gap at start of IO and mem for southbridge which is beyond standards
525
// and not only ignores writes to the BAR, but also does not advertise use of
526
// any IO/memory space. That is, southbridge is hardwired at 0x18000000
527
 
528
// Map PCI device resources starting from these addresses in PCI space.
529
#define HAL_PCI_ALLOC_BASE_MEMORY    (HAL_MALTA_PCI_MEM0_BASE + 0x20000)
530
#define HAL_PCI_ALLOC_BASE_IO        0x10000
531
 
532
// This is where the PCI spaces are mapped in the CPU's address space.
533
// 
534
#define HAL_PCI_PHYSICAL_MEMORY_BASE CYGARC_UNCACHED_ADDRESS(0)
535
#define HAL_PCI_PHYSICAL_IO_BASE     CYGARC_UNCACHED_ADDRESS(HAL_MALTA_PCI_IO_BASE)
536
 
537
// Read a value from the PCI configuration space of the appropriate
538
// size at an address composed from the bus, devfn and offset.
539
#define HAL_PCI_CFG_READ_UINT8( __bus, __devfn, __offset, __val )  \
540
    __val = cyg_hal_plf_pci_cfg_read_byte((__bus),  (__devfn), (__offset))
541
 
542
#define HAL_PCI_CFG_READ_UINT16( __bus, __devfn, __offset, __val ) \
543
    __val = cyg_hal_plf_pci_cfg_read_word((__bus),  (__devfn), (__offset))
544
 
545
#define HAL_PCI_CFG_READ_UINT32( __bus, __devfn, __offset, __val ) \
546
    __val = cyg_hal_plf_pci_cfg_read_dword((__bus),  (__devfn), (__offset))
547
 
548
// Write a value to the PCI configuration space of the appropriate
549
// size at an address composed from the bus, devfn and offset.
550
#define HAL_PCI_CFG_WRITE_UINT8( __bus, __devfn, __offset, __val )  \
551
    cyg_hal_plf_pci_cfg_write_byte((__bus),  (__devfn), (__offset), (__val))
552
 
553
#define HAL_PCI_CFG_WRITE_UINT16( __bus, __devfn, __offset, __val ) \
554
    cyg_hal_plf_pci_cfg_write_word((__bus),  (__devfn), (__offset), (__val))
555
 
556
#define HAL_PCI_CFG_WRITE_UINT32( __bus, __devfn, __offset, __val ) \
557
    cyg_hal_plf_pci_cfg_write_dword((__bus),  (__devfn), (__offset), (__val))
558
 
559
 
560
// Translate the PCI interrupt requested by the device (INTA#, INTB#,
561
// INTC# or INTD#) to the associated CPU interrupt (i.e., HAL vector).
562
#define HAL_PCI_TRANSLATE_INTERRUPT( __bus, __devfn, __vec, __valid)          \
563
    CYG_MACRO_START                                                           \
564
    cyg_uint8 __req;                                                          \
565
    HAL_PCI_CFG_READ_UINT8(__bus, __devfn, CYG_PCI_CFG_INT_PIN, __req);       \
566
    if (0 != __req) {                                                         \
567
        /* Interrupt assignment as Galileo sees them.                     */  \
568
        /* (From Malta User's Manual, 6.1 PCI Bus)                        */  \
569
        CYG_ADDRWORD __translation[4] = {                                     \
570
            CYGNUM_HAL_INTERRUPT_PCI_AB,  /* INTB# */                         \
571
            CYGNUM_HAL_INTERRUPT_PCI_CD,  /* INTC# */                         \
572
            CYGNUM_HAL_INTERRUPT_PCI_CD,  /* INTD# */                         \
573
            CYGNUM_HAL_INTERRUPT_PCI_AB}; /* INTA# */                         \
574
                                                                              \
575
        /* The PCI lines from the different slots are wired like this  */     \
576
        /* on the PCI backplane:                                       */     \
577
        /*                PCI_AB    PCI_AB   PCI_CD  PCI_CD            */     \
578
        /* AMD PCnet                INTA#                              */     \
579
        /* I/O Slot 1     INTA#     INTB#    INTC#   INTD#             */     \
580
        /* I/O Slot 2     INTD#     INTA#    INTB#   INTC#             */     \
581
        /* I/O Slot 3     INTC#     INTD#    INTA#   INTB#             */     \
582
        /* I/O Slot 4     INTB#     INTC#    INTD#   INTA#             */     \
583
        /*                                                             */     \
584
        /* Devsel signals are wired to, resulting in device IDs:       */     \
585
        /* AMD PCnet      AD21 / dev 11      [(11+1)&3 = 0]            */     \
586
        /* I/O Slot 1     AD28 / dev 18      [(18+1)&3 = 3]            */     \
587
        /* I/O Slot 2     AD29 / dev 19      [(19+1)&3 = 0]            */     \
588
        /* I/O Slot 3     AD30 / dev 20      [(20+1)&3 = 1]            */     \
589
        /* I/O Slot 4     AD31 / dev 21      [(21+1)&3 = 2]            */     \
590
                                                                              \
591
        __vec = __translation[((__req+CYG_PCI_DEV_GET_DEV(__devfn))&3)];      \
592
        __valid = true;                                                       \
593
    } else {                                                                  \
594
        /* Device will not generate interrupt requests. */                    \
595
        __valid = false;                                                      \
596
    }                                                                         \
597
    CYG_MACRO_END
598
 
599
// Galileo GT64120 on MIPS MALTA requires special processing.
600
// First, it will hang when accessing device 31 on the local bus.
601
// Second, we need to ignore the GT64120 so we can set it up
602
// outside the generic PCI library.
603
#define HAL_PCI_IGNORE_DEVICE(__bus, __dev, __fn) \
604
    ((__bus) == 0 && ((__dev) == 0 || (__dev) == 31))
605
 
606
// Bus address translation macros
607
#define HAL_PCI_CPU_TO_BUS(__cpu_addr, __bus_addr)        \
608
    CYG_MACRO_START                                       \
609
    (__bus_addr) = CYGARC_PHYSICAL_ADDRESS((cyg_uint32)__cpu_addr);   \
610
    CYG_MACRO_END
611
 
612
#define HAL_PCI_BUS_TO_CPU(__bus_addr, __cpu_addr)        \
613
    CYG_MACRO_START                                       \
614
    (__cpu_addr) = CYGARC_UNCACHED_ADDRESS(__bus_addr);   \
615
    CYG_MACRO_END
616
 
617
 
618
// IDE interface macros
619
//
620
#define HAL_IDE_NUM_CONTROLLERS 2
621
 
622
// Initialize the IDE controller(s).
623
externC void cyg_hal_plf_ide_init(void);
624
#define HAL_IDE_INIT() cyg_hal_plf_ide_init()
625
 
626
#define HAL_IDE_READ_UINT8( __ctlr, __regno, __val )  \
627
    __val = *HAL_REG8(((__ctlr) ? HAL_PIIX4_IDE_SEC_CMD : HAL_PIIX4_IDE_PRI_CMD) + (__regno))
628
#define HAL_IDE_READ_UINT16( __ctlr, __regno, __val )  \
629
    __val = *HAL_REG16(((__ctlr) ? HAL_PIIX4_IDE_SEC_CMD : HAL_PIIX4_IDE_PRI_CMD) + (__regno))
630
#define HAL_IDE_READ_ALTSTATUS( __ctlr, __val )  \
631
    __val = *HAL_REG16(((__ctlr) ? HAL_PIIX4_IDE_SEC_CTL : HAL_PIIX4_IDE_PRI_CTL) + 2)
632
 
633
#define HAL_IDE_WRITE_UINT8( __ctlr, __regno, __val )  \
634
    *HAL_REG8( ((__ctlr) ? HAL_PIIX4_IDE_SEC_CMD : HAL_PIIX4_IDE_PRI_CMD) + (__regno)) = (__val)
635
#define HAL_IDE_WRITE_UINT16( __ctlr, __regno, __val )  \
636
    *HAL_REG16( ((__ctlr) ? HAL_PIIX4_IDE_SEC_CMD : HAL_PIIX4_IDE_PRI_CMD) + (__regno)) = (__val)
637
#define HAL_IDE_WRITE_CONTROL( __ctlr, __val )  \
638
    *HAL_REG8( ((__ctlr) ? HAL_PIIX4_IDE_SEC_CTL : HAL_PIIX4_IDE_PRI_CTL) + 2) = (__val)
639
 
640
#endif
641
 
642
//-----------------------------------------------------------------------------
643
// end of plf_io.h
644
#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.