1 |
786 |
skrzyp |
#ifndef CYGONCE_PLF_IO_H
|
2 |
|
|
#define CYGONCE_PLF_IO_H
|
3 |
|
|
|
4 |
|
|
//=============================================================================
|
5 |
|
|
//
|
6 |
|
|
// plf_io.h
|
7 |
|
|
//
|
8 |
|
|
// Platform specific IO support
|
9 |
|
|
//
|
10 |
|
|
//=============================================================================
|
11 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
19 |
|
|
// version.
|
20 |
|
|
//
|
21 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
22 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License
|
27 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
28 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
|
|
//
|
30 |
|
|
// As a special exception, if other files instantiate templates or use
|
31 |
|
|
// macros or inline functions from this file, or you compile this file
|
32 |
|
|
// and link it with other works to produce a work based on this file,
|
33 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
34 |
|
|
// the GNU General Public License. However the source code for this file
|
35 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
36 |
|
|
// General Public License v2.
|
37 |
|
|
//
|
38 |
|
|
// This exception does not invalidate any other reasons why a work based
|
39 |
|
|
// on this file might be covered by the GNU General Public License.
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//=============================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): msalter
|
46 |
|
|
// Contributors: msalter, gthomas
|
47 |
|
|
// Date: 2002-01-10
|
48 |
|
|
// Purpose: Intel Xscale (PXA250) PCI IO support macros
|
49 |
|
|
// Description:
|
50 |
|
|
// Usage: #include <cyg/hal/plf_io.h>
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//
|
54 |
|
|
//=============================================================================
|
55 |
|
|
|
56 |
|
|
#include <pkgconf/hal.h>
|
57 |
|
|
#include <cyg/hal/hal_io.h> // IO macros
|
58 |
|
|
#include <cyg/hal/uE250.h>
|
59 |
|
|
|
60 |
|
|
#define PCI_CONTROL_BASE 0x37040000
|
61 |
|
|
|
62 |
|
|
#define PCI_CTL_IO(x) (*((volatile cyg_uint32*)(PCI_CONTROL_BASE+(x))))
|
63 |
|
|
#define PCI_CTL_IO_BYTE(x) (*((volatile cyg_uint8*)(PCI_CONTROL_BASE+(x))))
|
64 |
|
|
|
65 |
|
|
#define PCICTL_MEM_REMAP PCI_CTL_IO(0x0000)
|
66 |
|
|
#define PCICTL_IO_REMAP PCI_CTL_IO(0x0004)
|
67 |
|
|
#define PCICTL_CONFIG_REMAP PCI_CTL_IO(0x0008)
|
68 |
|
|
#define PCICTL_INT_RESET PCI_CTL_IO(0x0010)
|
69 |
|
|
#define PCICTL_STATUS_REG PCI_CTL_IO_BYTE(0x0010)
|
70 |
|
|
#define PCICTL_INT_EDGE PCI_CTL_IO_BYTE(0x0011)
|
71 |
|
|
#define PCICTL_IRQ_MASK PCI_CTL_IO(0x0014)
|
72 |
|
|
#define PCICTL_MISC PCI_CTL_IO(0x001C)
|
73 |
|
|
|
74 |
|
|
#define PCI_RESET (1 << 0)
|
75 |
|
|
#define PCI_WRITEBUF (1 << 1)
|
76 |
|
|
#define PCI_TIMER (1 << 2)
|
77 |
|
|
#define PCI_IDSEL_OFF (15 << 4)
|
78 |
|
|
#define PCI_IDSEL_0 (1 << 4)
|
79 |
|
|
#define PCI_IDSEL_1 (2 << 4)
|
80 |
|
|
#define PCI_IDSEL_2 (3 << 4)
|
81 |
|
|
#define PCI_IDSEL_3 (4 << 4)
|
82 |
|
|
#define PCI_IDSEL_4 (5 << 4)
|
83 |
|
|
#define PCI_IDSEL_5 (6 << 4)
|
84 |
|
|
#define PCI_SDRAM_64 (0 << 16)
|
85 |
|
|
#define PCI_SDRAM_128 (1 << 16)
|
86 |
|
|
#define PCI_SDRAM_256 (2 << 16)
|
87 |
|
|
#define PCI_SYSTEM_RESET (1 << 31)
|
88 |
|
|
|
89 |
|
|
#define PCI_INT_A (1 << 0)
|
90 |
|
|
#define PCI_INT_B (1 << 1)
|
91 |
|
|
#define PCI_INT_C (1 << 2)
|
92 |
|
|
#define PCI_INT_D (1 << 3)
|
93 |
|
|
#define PCI_TARGET_ABORT (1 << 4)
|
94 |
|
|
#define PCI_MASTER_ABORT (1 << 5)
|
95 |
|
|
#define PCI_PARITY_ERROR (1 << 6)
|
96 |
|
|
#define PCI_SYS_ERROR (1 << 7)
|
97 |
|
|
#define PCI_BUS_TIMEOUT (1 << 8)
|
98 |
|
|
|
99 |
|
|
#define PCI_INT_A_ENABLE (1 << 0)
|
100 |
|
|
#define PCI_INT_B_ENABLE (1 << 1)
|
101 |
|
|
#define PCI_INT_C_ENABLE (1 << 2)
|
102 |
|
|
#define PCI_INT_D_ENABLE (1 << 3)
|
103 |
|
|
|
104 |
|
|
#define PCI_IDSEL_SHIFT 4
|
105 |
|
|
|
106 |
|
|
// FIXME: Use virtual address
|
107 |
|
|
#define PCI_CONFIG_BASE 0x15000000
|
108 |
|
|
|
109 |
|
|
#define HAL_PCI_INIT() cyg_hal_plf_pci_init()
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
// Map PCI device resources starting from these addresses in PCI space.
|
113 |
|
|
#define HAL_PCI_PHYSICAL_MEMORY_BASE 0x0C000000 // CPU address
|
114 |
|
|
#define HAL_PCI_ALLOC_BASE_MEMORY 0x00000000 // PCI address
|
115 |
|
|
#define HAL_PCI_PHYSICAL_IO_BASE 0x16000000 // CPU address
|
116 |
|
|
#define HAL_PCI_ALLOC_BASE_IO 0x00000000 // PCI address
|
117 |
|
|
#define _PCI_READ_8 0x01000000 //
|
118 |
|
|
#define _PCI_READ_16 0x00000000 // Byte address munging
|
119 |
|
|
#define _PCI_READ_32 0x00800000 //
|
120 |
|
|
#define _PCI_WRITE_X 0x00000000
|
121 |
|
|
|
122 |
|
|
//-----------------------------------------------------------------------------
|
123 |
|
|
|
124 |
|
|
extern cyg_uint32 cyg_hal_plf_pci_cfg_read_dword (cyg_uint32 bus,
|
125 |
|
|
cyg_uint32 devfn,
|
126 |
|
|
cyg_uint32 offset);
|
127 |
|
|
extern cyg_uint16 cyg_hal_plf_pci_cfg_read_word (cyg_uint32 bus,
|
128 |
|
|
cyg_uint32 devfn,
|
129 |
|
|
cyg_uint32 offset);
|
130 |
|
|
extern cyg_uint8 cyg_hal_plf_pci_cfg_read_byte (cyg_uint32 bus,
|
131 |
|
|
cyg_uint32 devfn,
|
132 |
|
|
cyg_uint32 offset);
|
133 |
|
|
extern void cyg_hal_plf_pci_cfg_write_dword (cyg_uint32 bus,
|
134 |
|
|
cyg_uint32 devfn,
|
135 |
|
|
cyg_uint32 offset,
|
136 |
|
|
cyg_uint32 val);
|
137 |
|
|
extern void cyg_hal_plf_pci_cfg_write_word (cyg_uint32 bus,
|
138 |
|
|
cyg_uint32 devfn,
|
139 |
|
|
cyg_uint32 offset,
|
140 |
|
|
cyg_uint16 val);
|
141 |
|
|
extern void cyg_hal_plf_pci_cfg_write_byte (cyg_uint32 bus,
|
142 |
|
|
cyg_uint32 devfn,
|
143 |
|
|
cyg_uint32 offset,
|
144 |
|
|
cyg_uint8 val);
|
145 |
|
|
|
146 |
|
|
// Read a value from the PCI configuration space of the appropriate
|
147 |
|
|
// size at an address composed from the bus, devfn and offset.
|
148 |
|
|
#define HAL_PCI_CFG_READ_UINT8( __bus, __devfn, __offset, __val ) \
|
149 |
|
|
__val = cyg_hal_plf_pci_cfg_read_byte((__bus), (__devfn), (__offset))
|
150 |
|
|
|
151 |
|
|
#define HAL_PCI_CFG_READ_UINT16( __bus, __devfn, __offset, __val ) \
|
152 |
|
|
__val = cyg_hal_plf_pci_cfg_read_word((__bus), (__devfn), (__offset))
|
153 |
|
|
|
154 |
|
|
#define HAL_PCI_CFG_READ_UINT32( __bus, __devfn, __offset, __val ) \
|
155 |
|
|
__val = cyg_hal_plf_pci_cfg_read_dword((__bus), (__devfn), (__offset))
|
156 |
|
|
|
157 |
|
|
// Write a value to the PCI configuration space of the appropriate
|
158 |
|
|
// size at an address composed from the bus, devfn and offset.
|
159 |
|
|
#define HAL_PCI_CFG_WRITE_UINT8( __bus, __devfn, __offset, __val ) \
|
160 |
|
|
cyg_hal_plf_pci_cfg_write_byte((__bus), (__devfn), (__offset), (__val))
|
161 |
|
|
|
162 |
|
|
#define HAL_PCI_CFG_WRITE_UINT16( __bus, __devfn, __offset, __val ) \
|
163 |
|
|
cyg_hal_plf_pci_cfg_write_word((__bus), (__devfn), (__offset), (__val))
|
164 |
|
|
|
165 |
|
|
#define HAL_PCI_CFG_WRITE_UINT32( __bus, __devfn, __offset, __val ) \
|
166 |
|
|
cyg_hal_plf_pci_cfg_write_dword((__bus), (__devfn), (__offset), (__val))
|
167 |
|
|
|
168 |
|
|
// Initialize the PCI bus.
|
169 |
|
|
externC void cyg_hal_plf_pci_init(void);
|
170 |
|
|
#define HAL_PCI_INIT() cyg_hal_plf_pci_init()
|
171 |
|
|
|
172 |
|
|
externC void _uE250_pci_translate_interrupt(int bus, int devfn, int *vector, int *valid);
|
173 |
|
|
#define HAL_PCI_TRANSLATE_INTERRUPT(__bus, __devfn, __vector, __valid) \
|
174 |
|
|
_uE250_pci_translate_interrupt(__bus, __devfn, &__vector, &__valid)
|
175 |
|
|
|
176 |
|
|
// Special I/O access functions
|
177 |
|
|
externC cyg_uint8 pci_io_read_8(cyg_uint32 address);
|
178 |
|
|
externC cyg_uint16 pci_io_read_16(cyg_uint32 address);
|
179 |
|
|
externC cyg_uint32 pci_io_read_32(cyg_uint32 address);
|
180 |
|
|
externC void pci_io_write_8(cyg_uint32 address, cyg_uint8 value);
|
181 |
|
|
externC void pci_io_write_16(cyg_uint32 address, cyg_uint16 value);
|
182 |
|
|
externC void pci_io_write_32(cyg_uint32 address, cyg_uint32 value);
|
183 |
|
|
|
184 |
|
|
#define CYG_PCI_MAX_DEV 6
|
185 |
|
|
#define CYG_PCI_MAX_BUS 1
|
186 |
|
|
#define CYG_PCI_MAX_FN 1
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
#define HAL_IDE_NUM_CONTROLLERS 1 // Default card has two controllers - maybe should be 2?
|
190 |
|
|
|
191 |
|
|
#define HAL_IDE_READ_UINT8( __ctlr, __reg, __val) \
|
192 |
|
|
__val = cyg_hal_plf_ide_read_uint8((__ctlr), (__reg))
|
193 |
|
|
|
194 |
|
|
#define HAL_IDE_READ_UINT16( __ctlr, __reg, __val) \
|
195 |
|
|
__val = cyg_hal_plf_ide_read_uint16((__ctlr), (__reg))
|
196 |
|
|
|
197 |
|
|
#define HAL_IDE_WRITE_UINT8( __ctlr, __reg, __val) \
|
198 |
|
|
cyg_hal_plf_ide_write_uint8((__ctlr), (__reg), (__val))
|
199 |
|
|
|
200 |
|
|
#define HAL_IDE_WRITE_UINT16( __ctlr, __reg, __val) \
|
201 |
|
|
cyg_hal_plf_ide_write_uint16((__ctlr), (__reg), (__val))
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
#define HAL_IDE_WRITE_CONTROL( __ctlr, __val) \
|
205 |
|
|
cyg_hal_plf_ide_write_control((__ctlr), (__val))
|
206 |
|
|
|
207 |
|
|
#define HAL_IDE_INIT() cyg_hal_plf_ide_init()
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
// SDRAM is aliased as uncached memory for drivers.
|
211 |
|
|
#define CYGARC_UNCACHED_ADDRESS(_x_) \
|
212 |
|
|
(((((unsigned long)(_x_)) >> 29)==0x0) ? (((unsigned long)(_x_))|0xc0000000) : (_x_))
|
213 |
|
|
|
214 |
|
|
static inline unsigned cygarc_physical_address(unsigned va)
|
215 |
|
|
{
|
216 |
|
|
unsigned *ram_mmutab = (unsigned *)(SDRAM_BASE | 0x4000);
|
217 |
|
|
unsigned pte;
|
218 |
|
|
|
219 |
|
|
pte = ram_mmutab[va >> 20];
|
220 |
|
|
|
221 |
|
|
return (pte & 0xfff00000) | (va & 0xfffff);
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
// FIXME
|
225 |
|
|
#undef CYGARC_PHYSICAL_ADDRESS
|
226 |
|
|
#define CYGARC_PHYSICAL_ADDRESS(_x_) cygarc_physical_address(_x_)
|
227 |
|
|
|
228 |
|
|
static inline unsigned cygarc_virtual_address(unsigned pa)
|
229 |
|
|
{
|
230 |
|
|
if (0xa0000000 <= pa && pa < 0xc0000000)
|
231 |
|
|
return pa - 0xa0000000;
|
232 |
|
|
return pa;
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
#define CYGARC_VIRTUAL_ADDRESS(_x_) cygarc_virtual_address(_x_)
|
236 |
|
|
#define CYGARC_PCI_DMA_ADDRESS(_x_) (_x_)
|
237 |
|
|
|
238 |
|
|
//-----------------------------------------------------------------------------
|
239 |
|
|
// end of plf_io.h
|
240 |
|
|
#endif // CYGONCE_PLF_IO_H
|