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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [xscale/] [iq80321/] [current/] [src/] [iq80321_pci.c] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.