1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// iq80321_pci.c
|
4 |
|
|
//
|
5 |
|
|
// HAL support code for IQ80321 PCI
|
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): msalter
|
44 |
|
|
// Contributors: msalter
|
45 |
|
|
// Date: 2002-01-04
|
46 |
|
|
// Purpose: PCI support
|
47 |
|
|
// Description: Implementations of HAL PCI interfaces
|
48 |
|
|
//
|
49 |
|
|
//####DESCRIPTIONEND####
|
50 |
|
|
//
|
51 |
|
|
//========================================================================*/
|
52 |
|
|
|
53 |
|
|
#include <pkgconf/hal.h>
|
54 |
|
|
#include <pkgconf/system.h>
|
55 |
|
|
#include CYGBLD_HAL_PLATFORM_H
|
56 |
|
|
#include CYGHWR_MEMORY_LAYOUT_H
|
57 |
|
|
|
58 |
|
|
#include <cyg/infra/cyg_type.h> // base types
|
59 |
|
|
#include <cyg/infra/cyg_trac.h> // tracing macros
|
60 |
|
|
#include <cyg/infra/cyg_ass.h> // assertion macros
|
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_diag.h>
|
66 |
|
|
#include <cyg/hal/hal_intr.h> // Interrupt names
|
67 |
|
|
#include <cyg/hal/hal_cache.h>
|
68 |
|
|
#include <cyg/io/pci_hw.h>
|
69 |
|
|
#include <cyg/io/pci.h>
|
70 |
|
|
|
71 |
|
|
#ifdef CYGPKG_IO_PCI
|
72 |
|
|
|
73 |
|
|
cyg_uint32 hal_pci_alloc_base_memory;
|
74 |
|
|
cyg_uint32 hal_pci_alloc_base_io;
|
75 |
|
|
cyg_uint32 hal_pci_physical_memory_base;
|
76 |
|
|
cyg_uint32 hal_pci_physical_io_base;
|
77 |
|
|
cyg_uint32 hal_pci_inbound_window_base;
|
78 |
|
|
cyg_uint32 hal_pci_inbound_window_mask;
|
79 |
|
|
|
80 |
|
|
//
|
81 |
|
|
// Verde ATU Window Usage:
|
82 |
|
|
// Inbound Window 0 - Access to Verde memory mapped registers.
|
83 |
|
|
// Inbound Window 1 - Used to reserve space for outbound window.
|
84 |
|
|
// Inbound Window 2 - Access to SDRAM
|
85 |
|
|
// Inbound Window 3 - Not used.
|
86 |
|
|
//
|
87 |
|
|
// Direct Outbound Window - Direct mapped.
|
88 |
|
|
// Outbound Translate Window 0 - Access to Inbound Window 1 PCI space
|
89 |
|
|
// Outbound Translate Window 1 - Unused.
|
90 |
|
|
// Outbound IO Window - Unused.
|
91 |
|
|
//
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
#ifdef CYG_HAL_STARTUP_ROM
|
95 |
|
|
#ifdef CYGSEM_HAL_ARM_IQ80321_CLEAR_PCI_RETRY
|
96 |
|
|
// state of retry bit in PCSR prior to bit being cleared at sdram scrub time.
|
97 |
|
|
extern int hal_pcsr_cfg_retry;
|
98 |
|
|
|
99 |
|
|
// Wait for BIOS to configure Verde PCI.
|
100 |
|
|
// Returns true if BIOS done, false if timeout
|
101 |
|
|
bool
|
102 |
|
|
cyg_hal_plf_wait_for_bios(void)
|
103 |
|
|
{
|
104 |
|
|
int delay = 200; // 20 seconds, tops
|
105 |
|
|
|
106 |
|
|
while (delay-- > 0) {
|
107 |
|
|
if (*ATU_ATUCMD & CYG_PCI_CFG_COMMAND_MEMORY)
|
108 |
|
|
return true;
|
109 |
|
|
hal_delay_us(100000);
|
110 |
|
|
}
|
111 |
|
|
return false;
|
112 |
|
|
}
|
113 |
|
|
#endif // CYGSEM_HAL_ARM_IQ80321_CLEAR_PCI_RETRY
|
114 |
|
|
#endif // CYG_HAL_STARTUP_ROM
|
115 |
|
|
|
116 |
|
|
void
|
117 |
|
|
cyg_hal_plf_pci_init(void)
|
118 |
|
|
{
|
119 |
|
|
cyg_uint32 dram_limit = (0xFFFFFFFF - (hal_dram_size - 1)) & 0xFFFFFFC0;
|
120 |
|
|
|
121 |
|
|
// Enable NIC through GPIO pin. This may not have an effect depending
|
122 |
|
|
// on switch settings.
|
123 |
|
|
*GPIO_GPOE &= ~(1 << IQ80321_GBE_GPIO_PIN);
|
124 |
|
|
*GPIO_GPOD |= (1 << IQ80321_GBE_GPIO_PIN);
|
125 |
|
|
|
126 |
|
|
hal_pci_inbound_window_mask = ~dram_limit;
|
127 |
|
|
|
128 |
|
|
#ifdef CYG_HAL_STARTUP_ROM
|
129 |
|
|
#ifdef CYGSEM_HAL_ARM_IQ80321_CLEAR_PCI_RETRY
|
130 |
|
|
if (!hal_pcsr_cfg_retry || !cyg_hal_plf_wait_for_bios())
|
131 |
|
|
#endif // CYGSEM_HAL_ARM_IQ80321_CLEAR_PCI_RETRY
|
132 |
|
|
{
|
133 |
|
|
// 64-bit prefetchable
|
134 |
|
|
*ATU_IABAR2 = SDRAM_PHYS_BASE | \
|
135 |
|
|
CYG_PRI_CFG_BAR_MEM_TYPE_64 | \
|
136 |
|
|
CYG_PRI_CFG_BAR_MEM_PREFETCH;
|
137 |
|
|
*ATU_IAUBAR2 = 0;
|
138 |
|
|
|
139 |
|
|
// Outbound window will be set based on the memory reserved
|
140 |
|
|
// by inbound window 1
|
141 |
|
|
*ATU_IABAR1 = _PCI_MEM_BASE | \
|
142 |
|
|
CYG_PRI_CFG_BAR_MEM_TYPE_64 | \
|
143 |
|
|
CYG_PRI_CFG_BAR_MEM_PREFETCH;
|
144 |
|
|
|
145 |
|
|
}
|
146 |
|
|
#endif // CYG_HAL_STARTUP_ROM
|
147 |
|
|
|
148 |
|
|
// allow ATU to act as a bus master, respond to PCI memory accesses,
|
149 |
|
|
// and assert S_SERR#
|
150 |
|
|
*ATU_ATUCMD = (CYG_PCI_CFG_COMMAND_SERR | \
|
151 |
|
|
CYG_PCI_CFG_COMMAND_PARITY | \
|
152 |
|
|
CYG_PCI_CFG_COMMAND_MASTER | \
|
153 |
|
|
CYG_PCI_CFG_COMMAND_MEMORY);
|
154 |
|
|
|
155 |
|
|
hal_pci_alloc_base_memory = *ATU_IABAR1 & CYG_PRI_CFG_BAR_MEM_MASK;
|
156 |
|
|
hal_pci_alloc_base_io = _PCI_IO_BASE;
|
157 |
|
|
|
158 |
|
|
hal_pci_inbound_window_base = *ATU_IABAR2 & CYG_PRI_CFG_BAR_MEM_MASK;
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
// set the outbound window PCI address
|
162 |
|
|
*ATU_OMWTVR0 = hal_pci_alloc_base_memory;
|
163 |
|
|
*ATU_OUMWTVR0 = 0;
|
164 |
|
|
|
165 |
|
|
// outbound I/O window
|
166 |
|
|
*ATU_OIOWTVR = hal_pci_alloc_base_io;
|
167 |
|
|
|
168 |
|
|
hal_pci_physical_memory_base = _PCI_MEM_BASE - hal_pci_alloc_base_memory;
|
169 |
|
|
hal_pci_physical_io_base = _PCI_IO_BASE - hal_pci_alloc_base_io;
|
170 |
|
|
|
171 |
|
|
#ifdef CYG_HAL_MEMORY_MAP_NORMAL
|
172 |
|
|
// Adjust for Virt - Phys in CPU space
|
173 |
|
|
hal_pci_physical_memory_base += 0x20000000;
|
174 |
|
|
hal_pci_physical_io_base += 0x20000000;
|
175 |
|
|
#endif
|
176 |
|
|
|
177 |
|
|
cyg_pci_set_memory_base(HAL_PCI_ALLOC_BASE_MEMORY);
|
178 |
|
|
cyg_pci_set_io_base(HAL_PCI_ALLOC_BASE_IO);
|
179 |
|
|
|
180 |
|
|
// enable outbound ATU
|
181 |
|
|
*ATU_ATUCR = 2;
|
182 |
|
|
|
183 |
|
|
*ATU_APMCSR = 3;
|
184 |
|
|
}
|
185 |
|
|
|
186 |
|
|
#endif // CYGPKG_IO_PCI
|
187 |
|
|
|
188 |
|
|
|