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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      ixdp425_pci.c
4
//
5
//      HAL PCI board support code for Intel XScale IXDP425
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, 2004 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-12-11
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
#include <cyg/infra/cyg_type.h>         // base types
56
#include <cyg/infra/cyg_trac.h>         // tracing macros
57
#include <cyg/infra/cyg_ass.h>          // assertion macros
58
 
59
#include <cyg/hal/hal_io.h>             // IO macros
60
#include <cyg/hal/hal_if.h>             // calling interface API
61
#include <cyg/hal/hal_arch.h>           // Register state info
62
#include <cyg/hal/hal_diag.h>
63
#include <cyg/hal/hal_intr.h>           // Interrupt names
64
#include <cyg/hal/hal_cache.h>
65
 
66
#ifdef CYGPKG_IO_PCI
67
#include <cyg/io/pci_hw.h>
68
#include <cyg/io/pci.h>
69
 
70
#define IXP425_PCI_MAX_DEV      4
71
#define IXP425_PCI_IRQ_LINES    4
72
 
73
// PCI pin mappings
74
#define PCI_CLK_GPIO     14  // CLK0
75
#define PCI_RESET_GPIO   13
76
#define PCI_INTA_GPIO    11
77
#define PCI_INTB_GPIO    10
78
#define PCI_INTC_GPIO    9
79
#define PCI_INTD_GPIO    8
80
 
81
#define INTA    CYGNUM_HAL_INTERRUPT_GPIO11
82
#define INTB    CYGNUM_HAL_INTERRUPT_GPIO10
83
#define INTC    CYGNUM_HAL_INTERRUPT_GPIO9
84
#define INTD    CYGNUM_HAL_INTERRUPT_GPIO8
85
 
86
static const int pci_irq_table[IXP425_PCI_MAX_DEV][IXP425_PCI_IRQ_LINES] = {
87
    {INTA, INTB, INTC, INTD},
88
    {INTB, INTC, INTD, INTA},
89
    {INTC, INTD, INTA, INTB},
90
    {INTD, INTA, INTB, INTC}
91
};
92
 
93
void
94
cyg_hal_plf_pci_translate_interrupt(cyg_uint32 bus, cyg_uint32 devfn,
95
                                    CYG_ADDRWORD *vec, cyg_bool *valid)
96
{
97
    cyg_uint8 pin;
98
    cyg_uint32 slot = 3 - (CYG_PCI_DEV_GET_DEV(devfn) - 18);
99
 
100
    HAL_PCI_CFG_READ_UINT8(bus, devfn, CYG_PCI_CFG_INT_PIN, pin);
101
    *vec = -1;
102
    *valid = false;
103
 
104
    if (slot < IXP425_PCI_MAX_DEV && pin <= IXP425_PCI_IRQ_LINES) {
105
        *vec = pci_irq_table[slot][pin-1];
106
        *valid = true;
107
    }
108
}
109
 
110
 
111
#define HAL_PCI_CLOCK_ENABLE() \
112
    *IXP425_GPCLKR |= GPCLKR_CLK0_ENABLE;  // GPIO(0) used for PCI clock
113
 
114
#define HAL_PCI_CLOCK_DISABLE() \
115
    *IXP425_GPCLKR &= ~GPCLKR_CLK0_ENABLE;  // GPIO(0) used for PCI clock
116
 
117
#define HAL_PCI_CLOCK_CONFIG() \
118
    *IXP425_GPCLKR |= GPCLKR_CLK0_PCLK2;
119
 
120
#define HAL_PCI_RESET_ASSERT() \
121
    HAL_GPIO_OUTPUT_CLEAR(PCI_RESET_GPIO);
122
 
123
#define HAL_PCI_RESET_DEASSERT() \
124
    HAL_GPIO_OUTPUT_SET(PCI_RESET_GPIO);
125
 
126
void
127
hal_plf_pci_init(void)
128
{
129
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
130
    HAL_PCI_RESET_ASSERT();
131
    HAL_PCI_CLOCK_DISABLE();
132
 
133
    // Set GPIO line direction
134
    HAL_GPIO_OUTPUT_ENABLE(PCI_CLK_GPIO);
135
    HAL_GPIO_OUTPUT_ENABLE(PCI_RESET_GPIO);
136
    HAL_GPIO_OUTPUT_DISABLE(PCI_INTA_GPIO);
137
    HAL_GPIO_OUTPUT_DISABLE(PCI_INTB_GPIO);
138
    HAL_GPIO_OUTPUT_DISABLE(PCI_INTC_GPIO);
139
    HAL_GPIO_OUTPUT_DISABLE(PCI_INTD_GPIO);
140
 
141
    // configure PCI interrupt lines for active low irq
142
    HAL_INTERRUPT_CONFIGURE(INTA, 1, 0);
143
    HAL_INTERRUPT_CONFIGURE(INTB, 1, 0);
144
    HAL_INTERRUPT_CONFIGURE(INTC, 1, 0);
145
    HAL_INTERRUPT_CONFIGURE(INTD, 1, 0);
146
 
147
    // wait 1ms to satisfy "minimum reset assertion time" of the PCI spec.
148
    HAL_DELAY_US(1000);
149
    HAL_PCI_CLOCK_CONFIG();
150
    HAL_PCI_CLOCK_ENABLE();
151
 
152
    // wait 100us to satisfy "minimum reset assertion time from clock stable" 
153
    // requirement of the PCI spec.
154
    HAL_DELAY_US(100);
155
    HAL_PCI_RESET_DEASSERT();
156
#endif
157
}
158
 
159
#endif // CYGPKG_IO_PCI

powered by: WebSVN 2.1.0

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