Deleted Added
full compact
isa.c (127146) isa.c (129051)
1/*-
2 * Copyright (c) 1998 Doug Rabson
3 * Copyright (c) 2001 Thomas Moestl <tmm@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * from: FreeBSD: src/sys/alpha/isa/isa.c,v 1.26 2001/07/11
28 *
1/*-
2 * Copyright (c) 1998 Doug Rabson
3 * Copyright (c) 2001 Thomas Moestl <tmm@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * from: FreeBSD: src/sys/alpha/isa/isa.c,v 1.26 2001/07/11
28 *
29 * $FreeBSD: head/sys/sparc64/isa/isa.c 127146 2004-03-17 21:45:55Z jmg $
29 * $FreeBSD: head/sys/sparc64/isa/isa.c 129051 2004-05-08 13:53:47Z marius $
30 */
31
30 */
31
32#include "opt_ofw_pci.h"
33
34#include <sys/param.h>
35#include <sys/systm.h>
32#include <sys/param.h>
33#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/module.h>
38#include <sys/bus.h>
34#include <sys/bus.h>
35
39#include <machine/bus.h>
36#include <machine/bus.h>
40#include <sys/malloc.h>
41#include <sys/proc.h>
37
42#include <sys/rman.h>
38#include <sys/rman.h>
43#include <sys/interrupt.h>
44
45#include <isa/isareg.h>
46#include <isa/isavar.h>
47#include <isa/isa_common.h>
48
39
40#include <isa/isareg.h>
41#include <isa/isavar.h>
42#include <isa/isa_common.h>
43
49#include <dev/pci/pcireg.h>
50#include <dev/pci/pcivar.h>
51
52#include <dev/ofw/ofw_pci.h>
53#include <dev/ofw/openfirm.h>
54
44#include <dev/ofw/openfirm.h>
45
55#include <machine/intr_machdep.h>
56#include <machine/ofw_bus.h>
57#include <machine/resource.h>
58
46#include <machine/resource.h>
47
48#include <dev/pci/pcireg.h>
49#include <dev/pci/pcivar.h>
50
59#include <sparc64/pci/ofw_pci.h>
60#include <sparc64/isa/ofw_isa.h>
61
62/* There can be only one ISA bus, so it is safe to use globals. */
63bus_space_tag_t isa_io_bt = NULL;
64bus_space_handle_t isa_io_hdl;
65bus_space_tag_t isa_mem_bt = NULL;
66bus_space_handle_t isa_mem_hdl;
67
51#include <sparc64/pci/ofw_pci.h>
52#include <sparc64/isa/ofw_isa.h>
53
54/* There can be only one ISA bus, so it is safe to use globals. */
55bus_space_tag_t isa_io_bt = NULL;
56bus_space_handle_t isa_io_hdl;
57bus_space_tag_t isa_mem_bt = NULL;
58bus_space_handle_t isa_mem_hdl;
59
68u_int64_t isa_io_base;
69u_int64_t isa_io_limit;
70u_int64_t isa_mem_base;
71u_int64_t isa_mem_limit;
60static u_int64_t isa_io_base;
61static u_int64_t isa_io_limit;
62static u_int64_t isa_mem_base;
63static u_int64_t isa_mem_limit;
72
73device_t isa_bus_device;
74
75static phandle_t isab_node;
76static ofw_pci_intr_t isa_ino[8];
64
65device_t isa_bus_device;
66
67static phandle_t isab_node;
68static ofw_pci_intr_t isa_ino[8];
77
78#ifdef OFW_NEWPCI
79struct ofw_bus_iinfo isa_iinfo;
69struct ofw_bus_iinfo isa_iinfo;
80#endif
81
82/*
83 * XXX: This is really partly partly PCI-specific, but unfortunately is
84 * differently enough to have to duplicate it here...
85 */
86#define ISAB_RANGE_PHYS(r) \
87 (((u_int64_t)(r)->phys_mid << 32) | (u_int64_t)(r)->phys_lo)
88#define ISAB_RANGE_SPACE(r) (((r)->phys_hi >> 24) & 0x03)

--- 23 unchanged lines hidden (view full) ---

112}
113
114void
115isa_init(device_t dev)
116{
117 device_t bridge;
118 phandle_t node;
119 ofw_isa_intr_t ino;
70
71/*
72 * XXX: This is really partly partly PCI-specific, but unfortunately is
73 * differently enough to have to duplicate it here...
74 */
75#define ISAB_RANGE_PHYS(r) \
76 (((u_int64_t)(r)->phys_mid << 32) | (u_int64_t)(r)->phys_lo)
77#define ISAB_RANGE_SPACE(r) (((r)->phys_hi >> 24) & 0x03)

--- 23 unchanged lines hidden (view full) ---

101}
102
103void
104isa_init(device_t dev)
105{
106 device_t bridge;
107 phandle_t node;
108 ofw_isa_intr_t ino;
120#ifndef OFW_NEWPCI
121 ofw_pci_intr_t rino;
122#endif
123 struct isa_ranges *br;
124 int nbr, i;
125
126 /* The parent of the bus must be a PCI-ISA bridge. */
127 bridge = device_get_parent(dev);
109 struct isa_ranges *br;
110 int nbr, i;
111
112 /* The parent of the bus must be a PCI-ISA bridge. */
113 bridge = device_get_parent(dev);
128#ifdef OFW_NEWPCI
129 isab_node = ofw_pci_get_node(bridge);
114 isab_node = ofw_pci_get_node(bridge);
130#else
131 isab_node = ofw_pci_node(bridge);
132#endif
133 nbr = OF_getprop_alloc(isab_node, "ranges", sizeof(*br), (void **)&br);
134 if (nbr <= 0)
135 panic("isa_init: cannot get bridge range property");
136
115 nbr = OF_getprop_alloc(isab_node, "ranges", sizeof(*br), (void **)&br);
116 if (nbr <= 0)
117 panic("isa_init: cannot get bridge range property");
118
137#ifdef OFW_NEWPCI
138 ofw_bus_setup_iinfo(isab_node, &isa_iinfo, sizeof(ofw_isa_intr_t));
119 ofw_bus_setup_iinfo(isab_node, &isa_iinfo, sizeof(ofw_isa_intr_t));
139#endif
140
141 /*
142 * This is really a bad kludge; however, it is needed to provide
143 * isa_irq_pending(), which is unfortunately still used by some
144 * drivers.
145 */
146 for (i = 0; i < 8; i++)
147 isa_ino[i] = PCI_INVALID_IRQ;
148 for (node = OF_child(isab_node); node != 0; node = OF_peer(node)) {
149 if (OF_getprop(node, "interrupts", &ino, sizeof(ino)) == -1)
150 continue;
151 if (ino > 7)
152 panic("isa_init: XXX: ino too large");
120
121 /*
122 * This is really a bad kludge; however, it is needed to provide
123 * isa_irq_pending(), which is unfortunately still used by some
124 * drivers.
125 */
126 for (i = 0; i < 8; i++)
127 isa_ino[i] = PCI_INVALID_IRQ;
128 for (node = OF_child(isab_node); node != 0; node = OF_peer(node)) {
129 if (OF_getprop(node, "interrupts", &ino, sizeof(ino)) == -1)
130 continue;
131 if (ino > 7)
132 panic("isa_init: XXX: ino too large");
153#ifdef OFW_NEWPCI
154 isa_ino[ino] = ofw_isa_route_intr(bridge, node, &isa_iinfo,
155 ino);
133 isa_ino[ino] = ofw_isa_route_intr(bridge, node, &isa_iinfo,
134 ino);
156#else
157 rino = ofw_bus_route_intr(node, ino, ofw_pci_orb_callback, dev);
158 isa_ino[ino] = rino == ORIR_NOTFOUND ? PCI_INVALID_IRQ : rino;
159#endif
160 }
161
162 for (nbr -= 1; nbr >= 0; nbr--) {
163 switch(ISAB_RANGE_SPACE(br + nbr)) {
164 case ISAR_SPACE_IO:
165 /* This is probably always 0. */
166 isa_io_base = ISAB_RANGE_PHYS(&br[nbr]);
167 isa_io_limit = br[nbr].size;

--- 197 unchanged lines hidden ---
135 }
136
137 for (nbr -= 1; nbr >= 0; nbr--) {
138 switch(ISAB_RANGE_SPACE(br + nbr)) {
139 case ISAR_SPACE_IO:
140 /* This is probably always 0. */
141 isa_io_base = ISAB_RANGE_PHYS(&br[nbr]);
142 isa_io_limit = br[nbr].size;

--- 197 unchanged lines hidden ---