1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// uE250_plx.c
|
4 |
|
|
//
|
5 |
|
|
// HAL support code for NMI uEngine uE250 PCI Local Bus (PLX)
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 2003 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): David Mazur <david@mind.be>
|
43 |
|
|
// Contributors: gthomas
|
44 |
|
|
// Date: 2003-02-21
|
45 |
|
|
// Purpose: uPCI local bus (PLX/9080) support
|
46 |
|
|
// Description:
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//========================================================================*/
|
51 |
|
|
|
52 |
|
|
#include <pkgconf/hal.h>
|
53 |
|
|
#include <pkgconf/system.h>
|
54 |
|
|
#include CYGBLD_HAL_PLATFORM_H
|
55 |
|
|
#include CYGHWR_MEMORY_LAYOUT_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 |
|
|
#include <cyg/infra/diag.h>
|
61 |
|
|
|
62 |
|
|
#include <cyg/hal/hal_io.h> // IO macros
|
63 |
|
|
#include <cyg/hal/hal_if.h> // calling interface API
|
64 |
|
|
#include <cyg/hal/hal_arch.h> // Register state info
|
65 |
|
|
#include <cyg/hal/hal_intr.h> // Interrupt names
|
66 |
|
|
#include <cyg/hal/hal_cache.h>
|
67 |
|
|
#include <cyg/io/pci_hw.h>
|
68 |
|
|
#include <cyg/io/pci.h>
|
69 |
|
|
|
70 |
|
|
#ifdef CYGPKG_IO_PCI
|
71 |
|
|
|
72 |
|
|
externC void initialize_vga(void);
|
73 |
|
|
|
74 |
|
|
#define _DEFINE_VARS
|
75 |
|
|
#include <cyg/hal/plx.h>
|
76 |
|
|
|
77 |
|
|
/**
|
78 |
|
|
* Initial values for the configuration registers of the PLX 9080
|
79 |
|
|
*/
|
80 |
|
|
static struct plx_init {
|
81 |
|
|
cyg_uint32 address, value;
|
82 |
|
|
} plx_init_values[] = {
|
83 |
|
|
{ 0x0, 0xffe00000 },
|
84 |
|
|
{ 0x4, 0x80000001 },
|
85 |
|
|
{ 0x8, 0x0 },
|
86 |
|
|
{ 0xc, 0x0 },
|
87 |
|
|
{ 0x10,0xffe00000 },
|
88 |
|
|
{ 0x14,0x80000000 },
|
89 |
|
|
{ 0x18,0x40030141 },
|
90 |
|
|
{ 0x1c,0x0 },
|
91 |
|
|
{ 0x20,0x0 },
|
92 |
|
|
{ 0x24,0x0 },
|
93 |
|
|
{ 0x28,0x0 },
|
94 |
|
|
{ 0x2c,0x0 },
|
95 |
|
|
{ 0x78,0x0 },
|
96 |
|
|
{ 0x7c,0x0 },
|
97 |
|
|
{ 0xf0,0xffff8000 },
|
98 |
|
|
{ 0xf4,0x40008001 },
|
99 |
|
|
{ 0xf8,0x00000243 },
|
100 |
|
|
{ 0x900, 0x68 },
|
101 |
|
|
{ 0xFFFFFFFF,0}, // End marker
|
102 |
|
|
};
|
103 |
|
|
|
104 |
|
|
#ifdef CYGSEM_HAL_LOAD_VGA_FPGA
|
105 |
|
|
static unsigned char uE250_plx_bitstream[] = {
|
106 |
|
|
#include "uE250_plx_bitstream.h"
|
107 |
|
|
};
|
108 |
|
|
externC void load_vga(cyg_uint8 *base, int len);
|
109 |
|
|
#endif
|
110 |
|
|
|
111 |
|
|
#if 0
|
112 |
|
|
static void
|
113 |
|
|
_show_pci_device(cyg_pci_device_id devid)
|
114 |
|
|
{
|
115 |
|
|
int i, bus, devfn;
|
116 |
|
|
cyg_pci_device dev_info;
|
117 |
|
|
|
118 |
|
|
bus = CYG_PCI_DEV_GET_BUS(devid);
|
119 |
|
|
devfn = CYG_PCI_DEV_GET_DEVFN(devid);
|
120 |
|
|
cyg_pci_get_device_info(devid, &dev_info);
|
121 |
|
|
diag_printf("\n");
|
122 |
|
|
diag_printf("Bus: %d\n", CYG_PCI_DEV_GET_BUS(devid));
|
123 |
|
|
diag_printf("PCI Device: %d\n", CYG_PCI_DEV_GET_DEV(devid));
|
124 |
|
|
diag_printf("PCI Func : %d\n", CYG_PCI_DEV_GET_FN(devfn));
|
125 |
|
|
diag_printf("Vendor Id : 0x%08X\n", dev_info.vendor);
|
126 |
|
|
diag_printf("Device Id : 0x%08X\n", dev_info.device);
|
127 |
|
|
diag_printf("Command: %02x\n", dev_info.command);
|
128 |
|
|
for (i = 0; i < CYG_PCI_MAX_BAR; i++) {
|
129 |
|
|
diag_printf(" BAR[%d] 0x%08x /", i, dev_info.base_address[i]);
|
130 |
|
|
diag_printf(" probed size 0x%08x / CPU addr 0x%08x\n",
|
131 |
|
|
dev_info.base_size[i], dev_info.base_map[i]);
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
#endif
|
135 |
|
|
|
136 |
|
|
static /*__inline__*/ void
|
137 |
|
|
write_fdc37c672_configreg(cyg_uint8 regno, cyg_uint8 data)
|
138 |
|
|
{
|
139 |
|
|
localbus_writeb(regno, FDC37C672_INDEX);
|
140 |
|
|
localbus_writeb(data, FDC37C672_DATA);
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
static /*__inline__*/ cyg_uint8
|
144 |
|
|
read_fdc37c672_configreg(cyg_uint8 regno)
|
145 |
|
|
{
|
146 |
|
|
localbus_writeb(regno, FDC37C672_INDEX);
|
147 |
|
|
return localbus_readb(FDC37C672_DATA) & 0xff;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
/**
|
151 |
|
|
* Sets up the Base Address Registers of the PLX 9080
|
152 |
|
|
*/
|
153 |
|
|
void
|
154 |
|
|
initialize_plx_bridge(void)
|
155 |
|
|
{
|
156 |
|
|
cyg_pci_device_id plx_dev = CYG_PCI_NULL_DEVID;
|
157 |
|
|
struct plx_init *init = plx_init_values;
|
158 |
|
|
int bus, devfn;
|
159 |
|
|
cyg_pci_device dev_info;
|
160 |
|
|
|
161 |
|
|
// diag_printf("Initializing PLX-9080 localbus controller\n");
|
162 |
|
|
|
163 |
|
|
if (cyg_pci_find_device((cyg_uint16)0x10B5, (cyg_uint16)0x9080, &plx_dev)) {
|
164 |
|
|
cyg_pci_get_device_info(plx_dev, &dev_info);
|
165 |
|
|
bus = CYG_PCI_DEV_GET_BUS(plx_dev);
|
166 |
|
|
devfn = CYG_PCI_DEV_GET_DEVFN(plx_dev);
|
167 |
|
|
|
168 |
|
|
// Run PLX/9080 initialization sequence
|
169 |
|
|
_plx_config_addr = dev_info.base_map[0] + LOCALBUS_CONFIG_OFFSET;
|
170 |
|
|
while (init->address != (cyg_uint32)0xFFFFFFFF) {
|
171 |
|
|
plx_config_writel(init->value, init->address);
|
172 |
|
|
init++;
|
173 |
|
|
}
|
174 |
|
|
|
175 |
|
|
// Turn device off so it can be re-configured
|
176 |
|
|
cyg_hal_plf_pci_cfg_write_byte(bus, devfn, CYG_PCI_CFG_COMMAND, 0);
|
177 |
|
|
// This lets the library probe the device so it can be setup.
|
178 |
|
|
cyg_pci_get_device_info(plx_dev, &dev_info);
|
179 |
|
|
// Now, assign new resources to the device
|
180 |
|
|
cyg_pci_configure_device(&dev_info);
|
181 |
|
|
|
182 |
|
|
// Re-enable device now that is's been configured
|
183 |
|
|
cyg_hal_plf_pci_cfg_write_byte(bus, devfn, CYG_PCI_CFG_COMMAND,
|
184 |
|
|
CYG_PCI_CFG_COMMAND_IO | CYG_PCI_CFG_COMMAND_MEMORY);
|
185 |
|
|
|
186 |
|
|
// See what was assigned - for later use
|
187 |
|
|
cyg_pci_get_device_info(plx_dev, &dev_info);
|
188 |
|
|
_plx_config_addr = dev_info.base_map[0] + LOCALBUS_CONFIG_OFFSET;
|
189 |
|
|
_plx_localbus_addr = dev_info.base_map[3];
|
190 |
|
|
|
191 |
|
|
// A little commercial plug :-)
|
192 |
|
|
localbus_writeb('M', ASCII_DISPLAY_BASE+8);
|
193 |
|
|
localbus_writeb('I', ASCII_DISPLAY_BASE+12);
|
194 |
|
|
localbus_writeb('N', ASCII_DISPLAY_BASE+16);
|
195 |
|
|
localbus_writeb('D', ASCII_DISPLAY_BASE+20);
|
196 |
|
|
|
197 |
|
|
// Configure SMSC FDC36c672 Super I/O controller
|
198 |
|
|
|
199 |
|
|
localbus_writeb(0x55,FDC37C672_CONFIG); // Enter FDC37C672 configuration mode
|
200 |
|
|
|
201 |
|
|
write_fdc37c672_configreg(7, 3); // parallel port to IRQ 7, IO 0x378
|
202 |
|
|
write_fdc37c672_configreg(0x30, 1);
|
203 |
|
|
write_fdc37c672_configreg(0x70, 7);
|
204 |
|
|
write_fdc37c672_configreg(0x60, 0x3);
|
205 |
|
|
write_fdc37c672_configreg(0x61, 0x78);
|
206 |
|
|
|
207 |
|
|
write_fdc37c672_configreg(7, 4); // first serial port to IRQ4, IO 0x3f8
|
208 |
|
|
write_fdc37c672_configreg(0x30, 1);
|
209 |
|
|
write_fdc37c672_configreg(0x70, 4);
|
210 |
|
|
write_fdc37c672_configreg(0x60, 0x3);
|
211 |
|
|
write_fdc37c672_configreg(0x61, 0xf8);
|
212 |
|
|
|
213 |
|
|
write_fdc37c672_configreg(7, 5); // second serial port to IRQ5, IO 0x2f8
|
214 |
|
|
write_fdc37c672_configreg(0x30, 1);
|
215 |
|
|
write_fdc37c672_configreg(0x70, 3);
|
216 |
|
|
write_fdc37c672_configreg(0x60, 0x2);
|
217 |
|
|
write_fdc37c672_configreg(0x61, 0xf8);
|
218 |
|
|
|
219 |
|
|
write_fdc37c672_configreg(7, 7); // PS/2 Keyboard/mouse to IRQ 1/5, IO 0x60
|
220 |
|
|
write_fdc37c672_configreg(0x30, 1);
|
221 |
|
|
write_fdc37c672_configreg(0x70, 1);
|
222 |
|
|
write_fdc37c672_configreg(0x72, 5);
|
223 |
|
|
|
224 |
|
|
localbus_writeb(0xAA,FDC37C672_CONFIG); // Leave FDC37C672 configuration mode
|
225 |
|
|
|
226 |
|
|
#ifdef CYGSEM_HAL_LOAD_VGA_FPGA
|
227 |
|
|
load_vga(uE250_plx_bitstream, sizeof(uE250_plx_bitstream));
|
228 |
|
|
#endif
|
229 |
|
|
#ifdef CYGSEM_UE250_VGA_COMM
|
230 |
|
|
vga_comm_init(dev_info.base_map[2]);
|
231 |
|
|
#endif
|
232 |
|
|
} else {
|
233 |
|
|
diag_printf("Can't find PLX controller!\n");
|
234 |
|
|
}
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
#endif // CYGPKG_IO_PCI
|