1 |
27 |
unneback |
//==========================================================================
|
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 Red Hat, 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 version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License along
|
23 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
// or inline functions from this file, or you compile this file and link it
|
28 |
|
|
// with other works to produce a work based on this file, this file does not
|
29 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
// License. However the source code for this file must still be made available
|
31 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
// this file might be covered by the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
// -------------------------------------------
|
39 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
//==========================================================================
|
41 |
|
|
//#####DESCRIPTIONBEGIN####
|
42 |
|
|
//
|
43 |
|
|
// Author(s): nickg
|
44 |
|
|
// Contributors: nickg, jlarmour, dmoseley, jskov
|
45 |
|
|
// Date: 2001-03-20
|
46 |
|
|
// Purpose: HAL miscellaneous functions
|
47 |
|
|
// Description: This file contains miscellaneous functions provided by the
|
48 |
|
|
// HAL.
|
49 |
|
|
//
|
50 |
|
|
//####DESCRIPTIONEND####
|
51 |
|
|
//
|
52 |
|
|
//========================================================================*/
|
53 |
|
|
|
54 |
|
|
#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS
|
55 |
|
|
#include <pkgconf/hal.h>
|
56 |
|
|
|
57 |
|
|
#include <cyg/infra/cyg_type.h> // Base types
|
58 |
|
|
#include <cyg/infra/cyg_trac.h> // tracing macros
|
59 |
|
|
#include <cyg/infra/cyg_ass.h> // assertion macros
|
60 |
|
|
|
61 |
|
|
#include <cyg/hal/hal_arch.h> // architectural definitions
|
62 |
|
|
|
63 |
|
|
#include <cyg/hal/hal_intr.h> // Interrupt handling
|
64 |
|
|
|
65 |
|
|
#include <cyg/hal/hal_cache.h> // Cache handling
|
66 |
|
|
|
67 |
|
|
#include <cyg/hal/hal_if.h>
|
68 |
|
|
#include <cyg/io/pci_hw.h>
|
69 |
|
|
#include <cyg/io/pci.h>
|
70 |
|
|
|
71 |
|
|
//--------------------------------------------------------------------------
|
72 |
|
|
|
73 |
|
|
externC void cyg_hal_init_superIO(void);
|
74 |
|
|
static void hal_init_irq(void);
|
75 |
|
|
|
76 |
|
|
//--------------------------------------------------------------------------
|
77 |
|
|
|
78 |
|
|
void hal_platform_init(void)
|
79 |
|
|
{
|
80 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_LEDBAR, 0xff);
|
81 |
|
|
#if defined(CYGPKG_CYGMON)
|
82 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS0, ' ');
|
83 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS1, 'C');
|
84 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS2, 'Y');
|
85 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS3, 'G');
|
86 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS4, 'M');
|
87 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS5, 'O');
|
88 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS6, 'N');
|
89 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS7, ' ');
|
90 |
|
|
#elif defined(CYGPKG_REDBOOT)
|
91 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS0, 'R');
|
92 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS1, 'e');
|
93 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS2, 'd');
|
94 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS3, 'B');
|
95 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS4, 'o');
|
96 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS5, 'o');
|
97 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS6, 't');
|
98 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS7, ' ');
|
99 |
|
|
#else
|
100 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS0, ' ');
|
101 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS1, ' ');
|
102 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS2, 'e');
|
103 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS3, 'C');
|
104 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS4, 'O');
|
105 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS5, 'S');
|
106 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS6, ' ');
|
107 |
|
|
HAL_WRITE_UINT32(HAL_DISPLAY_ASCIIPOS7, ' ');
|
108 |
|
|
#endif
|
109 |
|
|
|
110 |
|
|
// Initialize PCI before VV since serial registers need to be in
|
111 |
|
|
// place before that time.
|
112 |
|
|
cyg_hal_plf_pci_init();
|
113 |
|
|
|
114 |
|
|
// Init interrupt controller on PIIX4
|
115 |
|
|
hal_init_irq();
|
116 |
|
|
|
117 |
|
|
// Initialize super IO controller
|
118 |
|
|
cyg_hal_init_superIO();
|
119 |
|
|
|
120 |
|
|
// Set up eCos/ROM interfaces
|
121 |
|
|
hal_if_init();
|
122 |
|
|
|
123 |
|
|
HAL_ICACHE_INVALIDATE_ALL();
|
124 |
|
|
HAL_ICACHE_ENABLE();
|
125 |
|
|
HAL_DCACHE_INVALIDATE_ALL();
|
126 |
|
|
HAL_DCACHE_ENABLE();
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
/*------------------------------------------------------------------------*/
|
131 |
|
|
/* Reset support */
|
132 |
|
|
|
133 |
|
|
void hal_malta_reset(void)
|
134 |
|
|
{
|
135 |
|
|
*HAL_MALTA_SOFTRES = HAL_MALTA_GORESET;
|
136 |
|
|
for(;;); // wait for it
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
//--------------------------------------------------------------------------
|
141 |
|
|
// IRQ init
|
142 |
|
|
static void
|
143 |
|
|
hal_init_irq(void)
|
144 |
|
|
{
|
145 |
|
|
cyg_uint32 v;
|
146 |
|
|
|
147 |
|
|
// Enable SERIRQ on PIIX4
|
148 |
|
|
v = cyg_hal_plf_pci_cfg_read_dword(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,0),
|
149 |
|
|
CYG_PCI_CFG_PIIX4_GENCFG);
|
150 |
|
|
v |= CYG_PCI_CFG_PIIX4_GENCFG_SERIRQ;
|
151 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,0),
|
152 |
|
|
CYG_PCI_CFG_PIIX4_GENCFG, v);
|
153 |
|
|
|
154 |
|
|
// Enable SERIRQ and set to continous mode.
|
155 |
|
|
v = cyg_hal_plf_pci_cfg_read_byte(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,0),
|
156 |
|
|
CYG_PCI_CFG_PIIX4_SERIRQC);
|
157 |
|
|
v |= CYG_PCI_CFG_PIIX4_SERIRQC_ENABLE | CYG_PCI_CFG_PIIX4_SERIRQC_CONT;
|
158 |
|
|
cyg_hal_plf_pci_cfg_write_byte(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,0),
|
159 |
|
|
CYG_PCI_CFG_PIIX4_SERIRQC, v);
|
160 |
|
|
|
161 |
|
|
// Init master interrupt controller (4.2.2, pp 74-78)
|
162 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_MASTER_ICW1, HAL_PIIX4_ICW1_SEL | HAL_PIIX4_ICW1_WR);
|
163 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_MASTER_ICW2, CYGNUM_HAL_INTERRUPT_CTRL1_BASE - CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE);
|
164 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_MASTER_ICW3, HAL_PIIX4_ICW3_CASCADE);
|
165 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_MASTER_ICW4, HAL_PIIX4_ICW4_UPMODE);
|
166 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_MASTER_OCW3, HAL_PIIX4_OCW3_SEL | HAL_PIIX4_OCW3_ESSM | HAL_PIIX4_OCW3_REQ);
|
167 |
|
|
|
168 |
|
|
// Init slave interrupt controller
|
169 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_SLAVE_ICW1, HAL_PIIX4_ICW1_SEL | HAL_PIIX4_ICW1_WR);
|
170 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_SLAVE_ICW2, CYGNUM_HAL_INTERRUPT_CTRL2_BASE - CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE);
|
171 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_SLAVE_ICW3, HAL_PIIX4_ICW3_SLAVE);
|
172 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_SLAVE_ICW4, HAL_PIIX4_ICW4_UPMODE);
|
173 |
|
|
|
174 |
|
|
// Mask all sources
|
175 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_MASTER_OCW1,
|
176 |
|
|
0xff & ~(1<<(CYGNUM_HAL_INTERRUPT_CASCADE-CYGNUM_HAL_INTERRUPT_CTRL1_BASE)));
|
177 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_SLAVE_OCW1, 0xff);
|
178 |
|
|
|
179 |
|
|
// Set PCI interrupt routing and set those interrupts to level
|
180 |
|
|
// sense as per 4.1.10 page 59 in 82371AB doc.
|
181 |
|
|
v = ( (CYGNUM_HAL_INTERRUPT_PCI_AB-CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE) << 0
|
182 |
|
|
|(CYGNUM_HAL_INTERRUPT_PCI_AB-CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE) << 8
|
183 |
|
|
|(CYGNUM_HAL_INTERRUPT_PCI_CD-CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE) << 16
|
184 |
|
|
|(CYGNUM_HAL_INTERRUPT_PCI_CD-CYGNUM_HAL_INTERRUPT_EXTERNAL_BASE) << 24);
|
185 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,0),
|
186 |
|
|
CYG_PCI_CFG_PIIX4_PIRQR, v);
|
187 |
|
|
|
188 |
|
|
HAL_READ_UINT8(HAL_PIIX4_ELCR2, v);
|
189 |
|
|
v |= (1 << (CYGNUM_HAL_INTERRUPT_PCI_AB-CYGNUM_HAL_INTERRUPT_CTRL2_BASE))
|
190 |
|
|
|(1 << (CYGNUM_HAL_INTERRUPT_PCI_CD-CYGNUM_HAL_INTERRUPT_CTRL2_BASE));
|
191 |
|
|
HAL_WRITE_UINT8(HAL_PIIX4_ELCR2, v);
|
192 |
|
|
|
193 |
|
|
// Let south bridge interrupt
|
194 |
|
|
HAL_INTERRUPT_UNMASK(CYGNUM_HAL_INTERRUPT_SOUTH_BRIDGE_INTR);
|
195 |
|
|
}
|
196 |
|
|
|
197 |
|
|
/*------------------------------------------------------------------------*/
|
198 |
|
|
/* PCI support */
|
199 |
|
|
#if defined(CYGPKG_IO_PCI)
|
200 |
|
|
|
201 |
|
|
#define PCIMEM_START 0x08000000 // PCI memory address
|
202 |
|
|
#define PCIMEM_SIZE 0x10000000 // 256 MByte
|
203 |
|
|
#define PCIIO_START 0x18000000 // PCI io address
|
204 |
|
|
#define PCIIO_SIZE 0x03E00000 // 62 MByte
|
205 |
|
|
|
206 |
|
|
static int __check_bar(cyg_uint32 addr, cyg_uint32 size)
|
207 |
|
|
{
|
208 |
|
|
int n;
|
209 |
|
|
|
210 |
|
|
for (n = 0; n <= 31; n++)
|
211 |
|
|
if (size == (1 << n)) {
|
212 |
|
|
/* Check that address is naturally aligned */
|
213 |
|
|
if (addr != (addr & ~(size-1)))
|
214 |
|
|
return 0;
|
215 |
|
|
return size - 1;
|
216 |
|
|
}
|
217 |
|
|
return 0;
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
// One-time PCI initialization.
|
222 |
|
|
|
223 |
|
|
void cyg_hal_plf_pci_init(void)
|
224 |
|
|
{
|
225 |
|
|
cyg_uint32 bar_ena, start10, start32, end, size;
|
226 |
|
|
cyg_uint8 next_bus;
|
227 |
|
|
cyg_uint32 v;
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
static int initialized = 0;
|
231 |
|
|
if (initialized) return;
|
232 |
|
|
initialized = 1;
|
233 |
|
|
|
234 |
|
|
// Setup for bus mastering
|
235 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(0,0),
|
236 |
|
|
CYG_PCI_CFG_COMMAND,
|
237 |
|
|
CYG_PCI_CFG_COMMAND_IO |
|
238 |
|
|
CYG_PCI_CFG_COMMAND_MEMORY |
|
239 |
|
|
CYG_PCI_CFG_COMMAND_MASTER |
|
240 |
|
|
CYG_PCI_CFG_COMMAND_PARITY |
|
241 |
|
|
CYG_PCI_CFG_COMMAND_SERR);
|
242 |
|
|
|
243 |
|
|
// Setup latency timer field
|
244 |
|
|
cyg_hal_plf_pci_cfg_write_byte(0, CYG_PCI_DEV_MAKE_DEVFN(0,0),
|
245 |
|
|
CYG_PCI_CFG_LATENCY_TIMER, 6);
|
246 |
|
|
|
247 |
|
|
// Disable all BARs
|
248 |
|
|
bar_ena = 0x1ff;
|
249 |
|
|
|
250 |
|
|
// Check for active SCS10
|
251 |
|
|
start10 = HAL_GALILEO_GETREG(HAL_GALILEO_SCS10_LD_OFFSET) << 21;
|
252 |
|
|
end = ((HAL_GALILEO_GETREG(HAL_GALILEO_SCS10_HD_OFFSET) & 0x7f) + 1) << 21;
|
253 |
|
|
if (end > start10) {
|
254 |
|
|
if ((size = __check_bar(start10, end - start10)) != 0) {
|
255 |
|
|
// Enable BAR
|
256 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_SCS10_SIZE_OFFSET, size);
|
257 |
|
|
bar_ena &= ~HAL_GALILEO_BAR_ENA_SCS10;
|
258 |
|
|
}
|
259 |
|
|
}
|
260 |
|
|
|
261 |
|
|
// Check for active SCS32
|
262 |
|
|
start32 = HAL_GALILEO_GETREG(HAL_GALILEO_SCS32_LD_OFFSET) << 21;
|
263 |
|
|
end = ((HAL_GALILEO_GETREG(HAL_GALILEO_SCS32_HD_OFFSET) & 0x7f) + 1) << 21;
|
264 |
|
|
if (end > start32) {
|
265 |
|
|
if ((size = __check_bar(start32, end - start32)) != 0) {
|
266 |
|
|
// Enable BAR
|
267 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_SCS32_SIZE_OFFSET, size);
|
268 |
|
|
bar_ena &= ~HAL_GALILEO_BAR_ENA_SCS32;
|
269 |
|
|
}
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
bar_ena &= ~HAL_GALILEO_BAR_ENA_SCS10;
|
273 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_BAR_ENA_OFFSET, bar_ena);
|
274 |
|
|
|
275 |
|
|
|
276 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(0,0),
|
277 |
|
|
CYG_PCI_CFG_BAR_0, 0xffffffff);
|
278 |
|
|
|
279 |
|
|
end = cyg_hal_plf_pci_cfg_read_dword(0, CYG_PCI_DEV_MAKE_DEVFN(0,0),
|
280 |
|
|
CYG_PCI_CFG_BAR_0);
|
281 |
|
|
|
282 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(0,0),
|
283 |
|
|
CYG_PCI_CFG_BAR_0, start10);
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(0,0),
|
287 |
|
|
CYG_PCI_CFG_BAR_1, 0xffffffff);
|
288 |
|
|
|
289 |
|
|
end = cyg_hal_plf_pci_cfg_read_dword(0, CYG_PCI_DEV_MAKE_DEVFN(0,0),
|
290 |
|
|
CYG_PCI_CFG_BAR_1);
|
291 |
|
|
|
292 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(0,0),
|
293 |
|
|
CYG_PCI_CFG_BAR_1, start32);
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
// enable ISA bridge on PIIX4
|
297 |
|
|
v = cyg_hal_plf_pci_cfg_read_dword(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,_PIIX4_BRIDGE),
|
298 |
|
|
CYG_PCI_CFG_PIIX4_GENCFG);
|
299 |
|
|
v |= CYG_PCI_CFG_PIIX4_GENCFG_ISA;
|
300 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,_PIIX4_BRIDGE),
|
301 |
|
|
CYG_PCI_CFG_PIIX4_GENCFG, v);
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
v = cyg_hal_plf_pci_cfg_read_byte(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,_PIIX4_BRIDGE),
|
305 |
|
|
CYG_PCI_CFG_PIIX4_TOM);
|
306 |
|
|
v &= ~CYG_PCI_CFG_PIIX4_TOM_TOM_MASK;
|
307 |
|
|
v |= CYG_PCI_CFG_PIIX4_TOM_TOM_16M;
|
308 |
|
|
cyg_hal_plf_pci_cfg_write_byte(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,_PIIX4_BRIDGE),
|
309 |
|
|
CYG_PCI_CFG_PIIX4_TOM, v);
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
// Configure PCI bus.
|
313 |
|
|
next_bus = 1;
|
314 |
|
|
cyg_pci_configure_bus(0, &next_bus);
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
// Check for configuration error.
|
319 |
|
|
static int pci_config_errcheck(void)
|
320 |
|
|
{
|
321 |
|
|
cyg_uint32 irq;
|
322 |
|
|
|
323 |
|
|
// Check for master or target abort
|
324 |
|
|
irq = HAL_GALILEO_GETREG(HAL_GALILEO_IRQ_CAUSE_OFFSET);
|
325 |
|
|
|
326 |
|
|
if (irq & (HAL_GALILEO_IRQCAUSE_MASABT | HAL_GALILEO_IRQCAUSE_TARABT)) {
|
327 |
|
|
// Error. Clear bits.
|
328 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_IRQ_CAUSE_OFFSET,
|
329 |
|
|
~(HAL_GALILEO_IRQCAUSE_MASABT | HAL_GALILEO_IRQCAUSE_TARABT));
|
330 |
|
|
return 1;
|
331 |
|
|
}
|
332 |
|
|
return 0;
|
333 |
|
|
}
|
334 |
|
|
|
335 |
|
|
cyg_uint32 cyg_hal_plf_pci_cfg_read_dword (cyg_uint32 bus,
|
336 |
|
|
cyg_uint32 devfn,
|
337 |
|
|
cyg_uint32 offset)
|
338 |
|
|
{
|
339 |
|
|
cyg_uint32 config_data;
|
340 |
|
|
|
341 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET,
|
342 |
|
|
HAL_GALILEO_PCI0_CONFIG_ADDR_ENABLE |
|
343 |
|
|
(bus << 16) | (devfn << 8) | offset);
|
344 |
|
|
|
345 |
|
|
config_data = HAL_GALILEO_GETREG(HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET);
|
346 |
|
|
|
347 |
|
|
if (pci_config_errcheck())
|
348 |
|
|
return 0xffffffff;
|
349 |
|
|
return config_data;
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
cyg_uint16 cyg_hal_plf_pci_cfg_read_word (cyg_uint32 bus,
|
353 |
|
|
cyg_uint32 devfn,
|
354 |
|
|
cyg_uint32 offset)
|
355 |
|
|
{
|
356 |
|
|
cyg_uint32 config_dword;
|
357 |
|
|
|
358 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET,
|
359 |
|
|
HAL_GALILEO_PCI0_CONFIG_ADDR_ENABLE |
|
360 |
|
|
(bus << 16) | (devfn << 8) | (offset & ~3));
|
361 |
|
|
|
362 |
|
|
config_dword = HAL_GALILEO_GETREG(HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET);
|
363 |
|
|
|
364 |
|
|
if (pci_config_errcheck())
|
365 |
|
|
return 0xffff;
|
366 |
|
|
return (cyg_uint16)((config_dword >> ((offset & 3) * 8)) & 0xffff);
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
cyg_uint8 cyg_hal_plf_pci_cfg_read_byte (cyg_uint32 bus,
|
370 |
|
|
cyg_uint32 devfn,
|
371 |
|
|
cyg_uint32 offset)
|
372 |
|
|
{
|
373 |
|
|
cyg_uint32 config_dword;
|
374 |
|
|
|
375 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET,
|
376 |
|
|
HAL_GALILEO_PCI0_CONFIG_ADDR_ENABLE |
|
377 |
|
|
(bus << 16) | (devfn << 8) | (offset & ~3));
|
378 |
|
|
|
379 |
|
|
config_dword = HAL_GALILEO_GETREG(HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET);
|
380 |
|
|
|
381 |
|
|
if (pci_config_errcheck())
|
382 |
|
|
return 0xff;
|
383 |
|
|
return (cyg_uint8)((config_dword >> ((offset & 3) * 8)) & 0xff);
|
384 |
|
|
}
|
385 |
|
|
|
386 |
|
|
void cyg_hal_plf_pci_cfg_write_dword (cyg_uint32 bus,
|
387 |
|
|
cyg_uint32 devfn,
|
388 |
|
|
cyg_uint32 offset,
|
389 |
|
|
cyg_uint32 data)
|
390 |
|
|
{
|
391 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET,
|
392 |
|
|
HAL_GALILEO_PCI0_CONFIG_ADDR_ENABLE |
|
393 |
|
|
(bus << 16) | (devfn << 8) | offset);
|
394 |
|
|
|
395 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET, data);
|
396 |
|
|
|
397 |
|
|
(void)pci_config_errcheck();
|
398 |
|
|
}
|
399 |
|
|
|
400 |
|
|
void cyg_hal_plf_pci_cfg_write_word (cyg_uint32 bus,
|
401 |
|
|
cyg_uint32 devfn,
|
402 |
|
|
cyg_uint32 offset,
|
403 |
|
|
cyg_uint16 data)
|
404 |
|
|
{
|
405 |
|
|
cyg_uint32 config_dword, shift;
|
406 |
|
|
|
407 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET,
|
408 |
|
|
HAL_GALILEO_PCI0_CONFIG_ADDR_ENABLE |
|
409 |
|
|
(bus << 16) | (devfn << 8) | (offset & ~3));
|
410 |
|
|
|
411 |
|
|
config_dword = HAL_GALILEO_GETREG(HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET);
|
412 |
|
|
if (pci_config_errcheck())
|
413 |
|
|
return;
|
414 |
|
|
|
415 |
|
|
shift = (offset & 3) * 8;
|
416 |
|
|
config_dword &= ~(0xffff << shift);
|
417 |
|
|
config_dword |= (data << shift);
|
418 |
|
|
|
419 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET, config_dword);
|
420 |
|
|
|
421 |
|
|
(void)pci_config_errcheck();
|
422 |
|
|
}
|
423 |
|
|
|
424 |
|
|
void cyg_hal_plf_pci_cfg_write_byte (cyg_uint32 bus,
|
425 |
|
|
cyg_uint32 devfn,
|
426 |
|
|
cyg_uint32 offset,
|
427 |
|
|
cyg_uint8 data)
|
428 |
|
|
{
|
429 |
|
|
cyg_uint32 config_dword, shift;
|
430 |
|
|
|
431 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_ADDR_OFFSET,
|
432 |
|
|
HAL_GALILEO_PCI0_CONFIG_ADDR_ENABLE |
|
433 |
|
|
(bus << 16) | (devfn << 8) | (offset & ~3));
|
434 |
|
|
|
435 |
|
|
config_dword = HAL_GALILEO_GETREG(HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET);
|
436 |
|
|
if (pci_config_errcheck())
|
437 |
|
|
return;
|
438 |
|
|
|
439 |
|
|
shift = (offset & 3) * 8;
|
440 |
|
|
config_dword &= ~(0xff << shift);
|
441 |
|
|
config_dword |= (data << shift);
|
442 |
|
|
|
443 |
|
|
HAL_GALILEO_PUTREG(HAL_GALILEO_PCI0_CONFIG_DATA_OFFSET, config_dword);
|
444 |
|
|
|
445 |
|
|
(void)pci_config_errcheck();
|
446 |
|
|
}
|
447 |
|
|
#endif // defined(CYGPKG_IO_PCI)
|
448 |
|
|
|
449 |
|
|
|
450 |
|
|
/*------------------------------------------------------------------------*/
|
451 |
|
|
/* IDE support */
|
452 |
|
|
|
453 |
|
|
void cyg_hal_plf_ide_init(void)
|
454 |
|
|
{
|
455 |
|
|
cyg_uint32 v;
|
456 |
|
|
|
457 |
|
|
// enable IDE
|
458 |
|
|
v = cyg_hal_plf_pci_cfg_read_dword(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,_PIIX4_IDE),
|
459 |
|
|
CYG_PCI_CFG_PIIX4_IDETIM);
|
460 |
|
|
v |= (CYG_PCI_CFG_PIIX4_IDETIM_IDE << 16) | CYG_PCI_CFG_PIIX4_IDETIM_IDE;
|
461 |
|
|
cyg_hal_plf_pci_cfg_write_dword(0, CYG_PCI_DEV_MAKE_DEVFN(_PIIX4_PCI_ID,_PIIX4_IDE),
|
462 |
|
|
CYG_PCI_CFG_PIIX4_IDETIM, v);
|
463 |
|
|
}
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
/*------------------------------------------------------------------------*/
|
467 |
|
|
/* End of plf_misc.c */
|