1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_ARM_IXP425_VAR_IO_H
|
2 |
|
|
#define CYGONCE_HAL_ARM_IXP425_VAR_IO_H
|
3 |
|
|
|
4 |
|
|
/*=============================================================================
|
5 |
|
|
//
|
6 |
|
|
// var_io.h
|
7 |
|
|
//
|
8 |
|
|
// Platform specific 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, 2004 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
|
47 |
|
|
// Date: 2002-12-12
|
48 |
|
|
// Purpose: IXP425 specific support routines
|
49 |
|
|
// Description:
|
50 |
|
|
// Usage: #include <cyg/hal/hal_io.h>
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//
|
54 |
|
|
//===========================================================================*/
|
55 |
|
|
|
56 |
|
|
#include <cyg/hal/plf_io.h>
|
57 |
|
|
|
58 |
|
|
//-----------------------------------------------------------------------------
|
59 |
|
|
|
60 |
|
|
extern cyg_uint32 cyg_hal_plf_pci_cfg_read_dword (cyg_uint32 bus,
|
61 |
|
|
cyg_uint32 devfn,
|
62 |
|
|
cyg_uint32 offset);
|
63 |
|
|
extern cyg_uint16 cyg_hal_plf_pci_cfg_read_word (cyg_uint32 bus,
|
64 |
|
|
cyg_uint32 devfn,
|
65 |
|
|
cyg_uint32 offset);
|
66 |
|
|
extern cyg_uint8 cyg_hal_plf_pci_cfg_read_byte (cyg_uint32 bus,
|
67 |
|
|
cyg_uint32 devfn,
|
68 |
|
|
cyg_uint32 offset);
|
69 |
|
|
extern void cyg_hal_plf_pci_cfg_write_dword (cyg_uint32 bus,
|
70 |
|
|
cyg_uint32 devfn,
|
71 |
|
|
cyg_uint32 offset,
|
72 |
|
|
cyg_uint32 val);
|
73 |
|
|
extern void cyg_hal_plf_pci_cfg_write_word (cyg_uint32 bus,
|
74 |
|
|
cyg_uint32 devfn,
|
75 |
|
|
cyg_uint32 offset,
|
76 |
|
|
cyg_uint16 val);
|
77 |
|
|
extern void cyg_hal_plf_pci_cfg_write_byte (cyg_uint32 bus,
|
78 |
|
|
cyg_uint32 devfn,
|
79 |
|
|
cyg_uint32 offset,
|
80 |
|
|
cyg_uint8 val);
|
81 |
|
|
|
82 |
|
|
extern void cyg_hal_plf_pci_io_outb(cyg_uint32 offset, cyg_uint8 value);
|
83 |
|
|
extern void cyg_hal_plf_pci_io_outw(cyg_uint32 offset, cyg_uint16 value);
|
84 |
|
|
extern void cyg_hal_plf_pci_io_outl(cyg_uint32 offset, cyg_uint32 value);
|
85 |
|
|
extern cyg_uint8 cyg_hal_plf_pci_io_inb(cyg_uint32 offset);
|
86 |
|
|
extern cyg_uint16 cyg_hal_plf_pci_io_inw(cyg_uint32 offset);
|
87 |
|
|
extern cyg_uint32 cyg_hal_plf_pci_io_inl(cyg_uint32 offset);
|
88 |
|
|
|
89 |
|
|
extern void cyg_hal_plf_pci_init(void);
|
90 |
|
|
#define HAL_PCI_INIT() cyg_hal_plf_pci_init()
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
// Translate the PCI interrupt requested by the device (INTA#, INTB#,
|
94 |
|
|
// INTC# or INTD#) to the associated CPU interrupt (i.e., HAL vector).
|
95 |
|
|
extern void cyg_hal_plf_pci_translate_interrupt(cyg_uint32 bus, cyg_uint32 devfn,
|
96 |
|
|
CYG_ADDRWORD *vec, cyg_bool *valid);
|
97 |
|
|
#define HAL_PCI_TRANSLATE_INTERRUPT( __bus, __devfn, __vec, __valid)\
|
98 |
|
|
cyg_hal_plf_pci_translate_interrupt(__bus, __devfn, &(__vec), &(__valid))
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
#ifdef CYGPKG_IO_PCI
|
102 |
|
|
|
103 |
|
|
// Read a value from the PCI configuration space of the appropriate
|
104 |
|
|
// size at an address composed from the bus, devfn and offset.
|
105 |
|
|
#define HAL_PCI_CFG_READ_UINT8( __bus, __devfn, __offset, __val ) \
|
106 |
|
|
__val = cyg_hal_plf_pci_cfg_read_byte((__bus), (__devfn), (__offset))
|
107 |
|
|
|
108 |
|
|
#define HAL_PCI_CFG_READ_UINT16( __bus, __devfn, __offset, __val ) \
|
109 |
|
|
__val = cyg_hal_plf_pci_cfg_read_word((__bus), (__devfn), (__offset))
|
110 |
|
|
|
111 |
|
|
#define HAL_PCI_CFG_READ_UINT32( __bus, __devfn, __offset, __val ) \
|
112 |
|
|
__val = cyg_hal_plf_pci_cfg_read_dword((__bus), (__devfn), (__offset))
|
113 |
|
|
|
114 |
|
|
// Write a value to the PCI configuration space of the appropriate
|
115 |
|
|
// size at an address composed from the bus, devfn and offset.
|
116 |
|
|
#define HAL_PCI_CFG_WRITE_UINT8( __bus, __devfn, __offset, __val ) \
|
117 |
|
|
cyg_hal_plf_pci_cfg_write_byte((__bus), (__devfn), (__offset), (__val))
|
118 |
|
|
|
119 |
|
|
#define HAL_PCI_CFG_WRITE_UINT16( __bus, __devfn, __offset, __val ) \
|
120 |
|
|
cyg_hal_plf_pci_cfg_write_word((__bus), (__devfn), (__offset), (__val))
|
121 |
|
|
|
122 |
|
|
#define HAL_PCI_CFG_WRITE_UINT32( __bus, __devfn, __offset, __val ) \
|
123 |
|
|
cyg_hal_plf_pci_cfg_write_dword((__bus), (__devfn), (__offset), (__val))
|
124 |
|
|
#else
|
125 |
|
|
|
126 |
|
|
#define HAL_PCI_CFG_READ_UINT8( __bus, __devfn, __offset, __val )
|
127 |
|
|
#define HAL_PCI_CFG_READ_UINT16( __bus, __devfn, __offset, __val )
|
128 |
|
|
#define HAL_PCI_CFG_READ_UINT32( __bus, __devfn, __offset, __val )
|
129 |
|
|
#define HAL_PCI_CFG_WRITE_UINT8( __bus, __devfn, __offset, __val )
|
130 |
|
|
#define HAL_PCI_CFG_WRITE_UINT16( __bus, __devfn, __offset, __val )
|
131 |
|
|
#define HAL_PCI_CFG_WRITE_UINT32( __bus, __devfn, __offset, __val )
|
132 |
|
|
#endif
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
// Default memory mapping details
|
136 |
|
|
#ifndef CYGARC_PHYSICAL_ADDRESS
|
137 |
|
|
#define CYGARC_PHYSICAL_ADDRESS(x) (x)
|
138 |
|
|
#endif
|
139 |
|
|
|
140 |
|
|
#ifndef CYGARC_UNCACHED_ADDRESS
|
141 |
|
|
#define CYGARC_UNCACHED_ADDRESS(x) \
|
142 |
|
|
((((cyg_uint32)(x)) < 0x10000000) ? (((cyg_uint32)(x))+0x20000000) : (x))
|
143 |
|
|
#endif
|
144 |
|
|
|
145 |
|
|
#ifndef CYGARC_VIRT_TO_BUS
|
146 |
|
|
// direct mapped at uncached address
|
147 |
|
|
#define CYGARC_VIRT_TO_BUS(x) (((cyg_uint32)(x) & 0xfffffff))
|
148 |
|
|
#endif
|
149 |
|
|
|
150 |
|
|
#ifndef CYGARC_BUS_TO_VIRT
|
151 |
|
|
// direct mapped
|
152 |
|
|
#define CYGARC_BUS_TO_VIRT(x) (x)
|
153 |
|
|
#endif
|
154 |
|
|
|
155 |
|
|
#define HAL_PCI_ALLOC_BASE_MEMORY 0x48000000
|
156 |
|
|
#define HAL_PCI_ALLOC_BASE_IO 0
|
157 |
|
|
|
158 |
|
|
#define HAL_PCI_PHYSICAL_MEMORY_BASE 0
|
159 |
|
|
#define HAL_PCI_PHYSICAL_IO_BASE 0
|
160 |
|
|
|
161 |
|
|
//-----------------------------------------------------------------------------
|
162 |
|
|
// HAL IO macros.
|
163 |
|
|
|
164 |
|
|
// Macro used to determine if given address corresponds to PCI IO address
|
165 |
|
|
// space. Evaluates to non-zero if address is for PCI IO.
|
166 |
|
|
#ifdef CYGPKG_IO_PCI
|
167 |
|
|
#define IXDP425_IS_PCI_IO(x) (((cyg_uint32)(x))<0x40000000)
|
168 |
|
|
#else
|
169 |
|
|
#define IXDP425_IS_PCI_IO(x) 0
|
170 |
|
|
#endif
|
171 |
|
|
|
172 |
|
|
//-----------------------------------------------------------------------------
|
173 |
|
|
// BYTE Register access.
|
174 |
|
|
|
175 |
|
|
#define HAL_READ_UINT8( _reg_, _value_ ) \
|
176 |
|
|
CYG_MACRO_START \
|
177 |
|
|
if (IXDP425_IS_PCI_IO(_reg_)) \
|
178 |
|
|
(_value_) = cyg_hal_plf_pci_io_inb((cyg_uint32)(_reg_)); \
|
179 |
|
|
else \
|
180 |
|
|
((_value_) = *((volatile CYG_BYTE *)(_reg_))); \
|
181 |
|
|
CYG_MACRO_END
|
182 |
|
|
|
183 |
|
|
#define HAL_WRITE_UINT8( _reg_, _value_ ) \
|
184 |
|
|
CYG_MACRO_START \
|
185 |
|
|
if (IXDP425_IS_PCI_IO(_reg_)) \
|
186 |
|
|
cyg_hal_plf_pci_io_outb((cyg_uint32)(_reg_), _value_); \
|
187 |
|
|
else \
|
188 |
|
|
(*((volatile CYG_BYTE *)(_reg_)) = (_value_)); \
|
189 |
|
|
CYG_MACRO_END
|
190 |
|
|
|
191 |
|
|
//-----------------------------------------------------------------------------
|
192 |
|
|
// 16 bit access.
|
193 |
|
|
|
194 |
|
|
#define HAL_READ_UINT16( _reg_, _value_ ) \
|
195 |
|
|
CYG_MACRO_START \
|
196 |
|
|
if (IXDP425_IS_PCI_IO(_reg_)) \
|
197 |
|
|
(_value_) = cyg_hal_plf_pci_io_inw((cyg_uint32)(_reg_)); \
|
198 |
|
|
else \
|
199 |
|
|
((_value_) = *((volatile CYG_WORD16 *)(_reg_))); \
|
200 |
|
|
CYG_MACRO_END
|
201 |
|
|
|
202 |
|
|
#define HAL_WRITE_UINT16( _reg_, _value_ ) \
|
203 |
|
|
CYG_MACRO_START \
|
204 |
|
|
if (IXDP425_IS_PCI_IO(_reg_)) \
|
205 |
|
|
cyg_hal_plf_pci_io_outw((cyg_uint32)(_reg_), _value_); \
|
206 |
|
|
else \
|
207 |
|
|
(*((volatile CYG_WORD16 *)(_reg_)) = (_value_)); \
|
208 |
|
|
CYG_MACRO_END
|
209 |
|
|
|
210 |
|
|
//-----------------------------------------------------------------------------
|
211 |
|
|
// 32 bit access.
|
212 |
|
|
|
213 |
|
|
#define HAL_READ_UINT32( _reg_, _value_ ) \
|
214 |
|
|
CYG_MACRO_START \
|
215 |
|
|
if (IXDP425_IS_PCI_IO(_reg_)) \
|
216 |
|
|
(_value_) = cyg_hal_plf_pci_io_inl((cyg_uint32)(_reg_)); \
|
217 |
|
|
else \
|
218 |
|
|
((_value_) = *((volatile CYG_WORD32 *)(_reg_))); \
|
219 |
|
|
CYG_MACRO_END
|
220 |
|
|
|
221 |
|
|
#define HAL_WRITE_UINT32( _reg_, _value_ ) \
|
222 |
|
|
CYG_MACRO_START \
|
223 |
|
|
if (IXDP425_IS_PCI_IO(_reg_)) \
|
224 |
|
|
cyg_hal_plf_pci_io_outl((cyg_uint32)(_reg_), _value_); \
|
225 |
|
|
else \
|
226 |
|
|
(*((volatile CYG_WORD32 *)(_reg_)) = (_value_)); \
|
227 |
|
|
CYG_MACRO_END
|
228 |
|
|
|
229 |
|
|
#define HAL_IO_MACROS_DEFINED
|
230 |
|
|
|
231 |
|
|
//-----------------------------------------------------------------------------
|
232 |
|
|
// HAL flash functions.
|
233 |
|
|
// These perform special operations between RedBoot and the flash driver.
|
234 |
|
|
|
235 |
|
|
externC int hal_flash_read(void *addr, void *data, int len, void **err);
|
236 |
|
|
externC int hal_flash_program(void *addr, void *data, int len, void **err);
|
237 |
|
|
|
238 |
|
|
#endif // CYGONCE_HAL_ARM_IXP425_VAR_IO_H
|
239 |
|
|
// EOF var_io.h
|