1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// prpmc1100_pci.c
|
4 |
|
|
//
|
5 |
|
|
// HAL PCI board support code for Intel XScale PrPMC1100
|
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: 2003-03-27
|
45 |
|
|
// Purpose: HAL PCI board support
|
46 |
|
|
// Description: Implementations of HAL board interfaces
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//========================================================================*/
|
51 |
|
|
#include <pkgconf/hal.h>
|
52 |
|
|
#include <pkgconf/system.h>
|
53 |
|
|
#include CYGBLD_HAL_PLATFORM_H
|
54 |
|
|
|
55 |
|
|
#ifdef CYGPKG_IO_PCI
|
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 |
|
|
|
71 |
|
|
#define IXP425_PCI_MAX_DEV 4
|
72 |
|
|
#define IXP425_PCI_IRQ_LINES 4
|
73 |
|
|
|
74 |
|
|
// PCI pin mappings
|
75 |
|
|
#define PCI_CLK_GPIO 14 // CLK0
|
76 |
|
|
#define PCI_RESET_GPIO 12
|
77 |
|
|
|
78 |
|
|
#define PCI_INTA_GPIO 11
|
79 |
|
|
#define PCI_INTB_GPIO 10
|
80 |
|
|
#define PCI_INTC_GPIO 9
|
81 |
|
|
#define PCI_INTD_GPIO 8
|
82 |
|
|
|
83 |
|
|
#define INTA CYGNUM_HAL_INTERRUPT_GPIO11
|
84 |
|
|
#define INTB CYGNUM_HAL_INTERRUPT_GPIO10
|
85 |
|
|
#define INTC CYGNUM_HAL_INTERRUPT_GPIO9
|
86 |
|
|
#define INTD CYGNUM_HAL_INTERRUPT_GPIO8
|
87 |
|
|
|
88 |
|
|
void
|
89 |
|
|
cyg_hal_plf_pci_translate_interrupt(cyg_uint32 bus, cyg_uint32 devfn,
|
90 |
|
|
CYG_ADDRWORD *vec, cyg_bool *valid)
|
91 |
|
|
{
|
92 |
|
|
*vec = INTA;
|
93 |
|
|
*valid = true;
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
#define HAL_PCI_CLOCK_ENABLE() \
|
98 |
|
|
*IXP425_GPCLKR |= GPCLKR_CLK0_ENABLE; // GPIO(0) used for PCI clock
|
99 |
|
|
|
100 |
|
|
#define HAL_PCI_CLOCK_DISABLE() \
|
101 |
|
|
*IXP425_GPCLKR &= ~GPCLKR_CLK0_ENABLE; // GPIO(0) used for PCI clock
|
102 |
|
|
|
103 |
|
|
#define HAL_PCI_CLOCK_CONFIG() \
|
104 |
|
|
*IXP425_GPCLKR |= GPCLKR_CLK0_PCLK2;
|
105 |
|
|
|
106 |
|
|
#define HAL_PCI_RESET_ASSERT() \
|
107 |
|
|
HAL_GPIO_OUTPUT_CLEAR(PCI_RESET_GPIO);
|
108 |
|
|
|
109 |
|
|
#define HAL_PCI_RESET_DEASSERT() \
|
110 |
|
|
HAL_GPIO_OUTPUT_SET(PCI_RESET_GPIO);
|
111 |
|
|
|
112 |
|
|
void
|
113 |
|
|
hal_plf_pci_init(void)
|
114 |
|
|
{
|
115 |
|
|
cyg_uint8 next_bus;
|
116 |
|
|
int is_host = (*IXP425_PCI_CSR & PCI_CSR_HOST);
|
117 |
|
|
|
118 |
|
|
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
|
119 |
|
|
|
120 |
|
|
if (is_host) {
|
121 |
|
|
// PCI interrupt inputs
|
122 |
|
|
HAL_GPIO_OUTPUT_DISABLE(PCI_INTA_GPIO);
|
123 |
|
|
HAL_GPIO_OUTPUT_DISABLE(PCI_INTB_GPIO);
|
124 |
|
|
HAL_GPIO_OUTPUT_DISABLE(PCI_INTC_GPIO);
|
125 |
|
|
HAL_GPIO_OUTPUT_DISABLE(PCI_INTD_GPIO);
|
126 |
|
|
|
127 |
|
|
// configure PCI interrupt lines for active low irq
|
128 |
|
|
HAL_INTERRUPT_CONFIGURE(INTA, 1, 0);
|
129 |
|
|
HAL_INTERRUPT_CONFIGURE(INTB, 1, 0);
|
130 |
|
|
HAL_INTERRUPT_CONFIGURE(INTC, 1, 0);
|
131 |
|
|
HAL_INTERRUPT_CONFIGURE(INTD, 1, 0);
|
132 |
|
|
|
133 |
|
|
} else {
|
134 |
|
|
// PCI interrupt outputs
|
135 |
|
|
HAL_GPIO_OUTPUT_SET(PCI_INTA_GPIO);
|
136 |
|
|
HAL_GPIO_OUTPUT_ENABLE(PCI_INTA_GPIO);
|
137 |
|
|
HAL_GPIO_OUTPUT_SET(PCI_INTB_GPIO);
|
138 |
|
|
HAL_GPIO_OUTPUT_ENABLE(PCI_INTB_GPIO);
|
139 |
|
|
HAL_GPIO_OUTPUT_SET(PCI_INTC_GPIO);
|
140 |
|
|
HAL_GPIO_OUTPUT_ENABLE(PCI_INTC_GPIO);
|
141 |
|
|
HAL_GPIO_OUTPUT_SET(PCI_INTD_GPIO);
|
142 |
|
|
HAL_GPIO_OUTPUT_ENABLE(PCI_INTD_GPIO);
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
HAL_DELAY_US(100);
|
146 |
|
|
#endif
|
147 |
|
|
|
148 |
|
|
cyg_hal_plf_pci_init();
|
149 |
|
|
|
150 |
|
|
if (is_host) {
|
151 |
|
|
int delay = 200; // Wait up to 20 seconds for EREADY
|
152 |
|
|
while (delay-- > 0)
|
153 |
|
|
if (*PRPMC_CTL_REG & PRPMC_CTL_EREADY)
|
154 |
|
|
break;
|
155 |
|
|
else
|
156 |
|
|
hal_delay_us(100000);
|
157 |
|
|
|
158 |
|
|
next_bus = 1;
|
159 |
|
|
cyg_pci_configure_bus(0, &next_bus);
|
160 |
|
|
} else
|
161 |
|
|
*PRPMC_CTL_REG = PRPMC_CTL_RESETOUT | PRPMC_CTL_INTN_GPIO | PRPMC_CTL_EREADY;
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
#endif // CYGPKG_IO_PCI
|