1 |
27 |
unneback |
//=============================================================================
|
2 |
|
|
//
|
3 |
|
|
// pci_serv.c - Cyclone Diagnostics
|
4 |
|
|
//
|
5 |
|
|
//=============================================================================
|
6 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
7 |
|
|
// -------------------------------------------
|
8 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
9 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
|
10 |
|
|
//
|
11 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
12 |
|
|
// the terms of the GNU General Public License as published by the Free
|
13 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
14 |
|
|
//
|
15 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
16 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
17 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
18 |
|
|
// for more details.
|
19 |
|
|
//
|
20 |
|
|
// You should have received a copy of the GNU General Public License along
|
21 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
22 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
23 |
|
|
//
|
24 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
25 |
|
|
// or inline functions from this file, or you compile this file and link it
|
26 |
|
|
// with other works to produce a work based on this file, this file does not
|
27 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
28 |
|
|
// License. However the source code for this file must still be made available
|
29 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
30 |
|
|
//
|
31 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
32 |
|
|
// this file might be covered by the GNU General Public License.
|
33 |
|
|
//
|
34 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
35 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
36 |
|
|
// -------------------------------------------
|
37 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
38 |
|
|
//=============================================================================
|
39 |
|
|
//#####DESCRIPTIONBEGIN####
|
40 |
|
|
//
|
41 |
|
|
// Author(s): Scott Coulter, Jeff Frazier, Eric Breeden
|
42 |
|
|
// Contributors:
|
43 |
|
|
// Date: 2001-01-25
|
44 |
|
|
// Purpose:
|
45 |
|
|
// Description:
|
46 |
|
|
//
|
47 |
|
|
//####DESCRIPTIONEND####
|
48 |
|
|
//
|
49 |
|
|
//===========================================================================*/
|
50 |
|
|
|
51 |
|
|
/********************************************************************************/
|
52 |
|
|
/* PCI_SERV.C - PCI driver for IQ80310 */
|
53 |
|
|
/* */
|
54 |
|
|
/* History: */
|
55 |
|
|
/* 15sep00 ejb Ported to Cygmon on IQ80310 */
|
56 |
|
|
/* 18dec00 snc */
|
57 |
|
|
/********************************************************************************/
|
58 |
|
|
#include <redboot.h>
|
59 |
|
|
#include <cyg/hal/hal_iop310.h> // Hardware definitions
|
60 |
|
|
#include "iq80310.h"
|
61 |
|
|
#include "pci_bios.h"
|
62 |
|
|
|
63 |
|
|
#undef DEBUG_PCI
|
64 |
|
|
|
65 |
|
|
#define IB_MA_ERROR 0x2000
|
66 |
|
|
|
67 |
|
|
/*==========================================================================*/
|
68 |
|
|
/* Globals */
|
69 |
|
|
/*==========================================================================*/
|
70 |
|
|
ULONG memspace_ptr[NUM_PCI_BUSES];
|
71 |
|
|
ULONG iospace_ptr[NUM_PCI_BUSES];
|
72 |
|
|
ULONG memspace_limit[NUM_PCI_BUSES];
|
73 |
|
|
ULONG iospace_limit[NUM_PCI_BUSES];
|
74 |
|
|
UINT nextbus;
|
75 |
|
|
UINT secondary_busno = SECONDARY_BUS_NUM;
|
76 |
|
|
UINT primary_busno = PRIMARY_BUS_NUM;
|
77 |
|
|
UINT lastbus;
|
78 |
|
|
unsigned long dram_size; /* global storing the size of DRAM */
|
79 |
|
|
int bus0_lastbus; /* last secondary bus number behind bus 0 */
|
80 |
|
|
int bus1_lastbus; /* last secondary bus number behind bus 1 */
|
81 |
|
|
|
82 |
|
|
int nmi_verbose; /* global flag to indicate whether or not PCI Error messages should be
|
83 |
|
|
printed. This flag is used to prevent a painful deluge of messages
|
84 |
|
|
when performing PCI configuration reads/writes to possibly non-existant
|
85 |
|
|
devices. */
|
86 |
|
|
|
87 |
|
|
int pci_config_error = FALSE; /* becomes TRUE if an NMI interrupt occurs due to a PCI config cycle */
|
88 |
|
|
|
89 |
|
|
#define PRINT_ON() nmi_verbose = TRUE
|
90 |
|
|
#define PRINT_OFF() nmi_verbose = FALSE
|
91 |
|
|
|
92 |
|
|
/*==========================================================================*/
|
93 |
|
|
/* Function prototypes */
|
94 |
|
|
/*==========================================================================*/
|
95 |
|
|
|
96 |
|
|
typedef struct
|
97 |
|
|
{
|
98 |
|
|
FUNCPTR handler;
|
99 |
|
|
int arg;
|
100 |
|
|
int bus;
|
101 |
|
|
int device;
|
102 |
|
|
} INT_HANDLER;
|
103 |
|
|
|
104 |
|
|
#define NUM_PCI_XINTS 4 /* XINT0 - XINT3 */
|
105 |
|
|
#define MAX_PCI_HANDLERS 8 /* maximum handlers per PCI Xint */
|
106 |
|
|
|
107 |
|
|
extern void hexIn(void);
|
108 |
|
|
extern int pci_config_cycle;
|
109 |
|
|
extern void _enableFiqIrq(void);
|
110 |
|
|
extern void config_ints(void); /* configure interrupts */
|
111 |
|
|
|
112 |
|
|
/*********************************************************************************
|
113 |
|
|
* pci_to_xint - convert a PCI device number and Interrupt line to an 80312 XINT
|
114 |
|
|
*
|
115 |
|
|
* This function converts a PCI slot number (0 - 7) and an Interrupt line
|
116 |
|
|
* (INTA - INTD) to a i960 processor XINT number (0 - 3)
|
117 |
|
|
*
|
118 |
|
|
* RETURNS: OK or ERROR if arguments are invalid
|
119 |
|
|
*
|
120 |
|
|
*/
|
121 |
|
|
STATUS pci_to_xint(int device, int intpin, int *xint)
|
122 |
|
|
{
|
123 |
|
|
int device_base; /* all devices mod 4 follow same interrupt mapping scheme */
|
124 |
|
|
|
125 |
|
|
/* check validity of arguments */
|
126 |
|
|
if ((intpin < INTA) || (intpin > INTD) || (device > 31))
|
127 |
|
|
return (ERROR);
|
128 |
|
|
|
129 |
|
|
device_base = device % 4;
|
130 |
|
|
|
131 |
|
|
/* interrupt mapping scheme as per PCI-to-PCI Bridge Specification */
|
132 |
|
|
switch (device_base) {
|
133 |
|
|
case 0:
|
134 |
|
|
switch (intpin) {
|
135 |
|
|
case INTA:
|
136 |
|
|
*xint = XINT0;
|
137 |
|
|
break;
|
138 |
|
|
case INTB:
|
139 |
|
|
*xint = XINT1;
|
140 |
|
|
break;
|
141 |
|
|
case INTC:
|
142 |
|
|
*xint = XINT2;
|
143 |
|
|
break;
|
144 |
|
|
case INTD:
|
145 |
|
|
*xint = XINT3;
|
146 |
|
|
break;
|
147 |
|
|
}
|
148 |
|
|
break;
|
149 |
|
|
case 1:
|
150 |
|
|
switch (intpin) {
|
151 |
|
|
case INTA:
|
152 |
|
|
*xint = XINT1;
|
153 |
|
|
break;
|
154 |
|
|
case INTB:
|
155 |
|
|
*xint = XINT2;
|
156 |
|
|
break;
|
157 |
|
|
case INTC:
|
158 |
|
|
*xint = XINT3;
|
159 |
|
|
break;
|
160 |
|
|
case INTD:
|
161 |
|
|
*xint = XINT0;
|
162 |
|
|
break;
|
163 |
|
|
}
|
164 |
|
|
break;
|
165 |
|
|
case 2:
|
166 |
|
|
switch (intpin) {
|
167 |
|
|
case INTA:
|
168 |
|
|
*xint = XINT2;
|
169 |
|
|
break;
|
170 |
|
|
case INTB:
|
171 |
|
|
*xint = XINT3;
|
172 |
|
|
break;
|
173 |
|
|
case INTC:
|
174 |
|
|
*xint = XINT0;
|
175 |
|
|
break;
|
176 |
|
|
case INTD:
|
177 |
|
|
*xint = XINT1;
|
178 |
|
|
break;
|
179 |
|
|
}
|
180 |
|
|
break;
|
181 |
|
|
case 3:
|
182 |
|
|
switch (intpin) {
|
183 |
|
|
case INTA:
|
184 |
|
|
*xint = XINT3;
|
185 |
|
|
break;
|
186 |
|
|
case INTB:
|
187 |
|
|
*xint = XINT0;
|
188 |
|
|
break;
|
189 |
|
|
case INTC:
|
190 |
|
|
*xint = XINT1;
|
191 |
|
|
break;
|
192 |
|
|
case INTD:
|
193 |
|
|
*xint = XINT2;
|
194 |
|
|
break;
|
195 |
|
|
}
|
196 |
|
|
break;
|
197 |
|
|
}
|
198 |
|
|
return (OK);
|
199 |
|
|
}
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
/******************************************************************************
|
203 |
|
|
*
|
204 |
|
|
* Checks to see if the "bus" argument identifies a PCI bus which is located
|
205 |
|
|
* off of the Primary PCI bus of the board.
|
206 |
|
|
*/
|
207 |
|
|
int off_ppci_bus (int busno)
|
208 |
|
|
{
|
209 |
|
|
if (busno == primary_busno)
|
210 |
|
|
return (TRUE);
|
211 |
|
|
else if (busno == secondary_busno)
|
212 |
|
|
return (FALSE);
|
213 |
|
|
else if (busno <= bus0_lastbus)
|
214 |
|
|
return (TRUE);
|
215 |
|
|
else
|
216 |
|
|
return (FALSE);
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
/******************************************************************************
|
220 |
|
|
* sys_set_pci_irq - connect a PCI interrupt to a processor IRQ.
|
221 |
|
|
*
|
222 |
|
|
* The PCI Interrupt routing fabric on the Cyclone Hardware is not
|
223 |
|
|
* reconfigurable (fixed mapping relationships) and therefore, this function
|
224 |
|
|
* is not supported.
|
225 |
|
|
*
|
226 |
|
|
*/
|
227 |
|
|
STATUS sys_set_pci_irq (int int_pin, int irq_num, int bus_dev)
|
228 |
|
|
{
|
229 |
|
|
return (FUNC_NOT_SUPPORTED);
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
/* check if host of backplane */
|
233 |
|
|
int isHost(void)
|
234 |
|
|
{
|
235 |
|
|
if (*BACKPLANE_DET_REG & BP_HOST_BIT)
|
236 |
|
|
return TRUE;
|
237 |
|
|
else
|
238 |
|
|
return FALSE;
|
239 |
|
|
}
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
|