2001-11-09 20:21:21 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 Doug Rabson
|
|
|
|
* Copyright (c) 2001 Thomas Moestl <tmm@FreeBSD.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* from: FreeBSD: src/sys/alpha/isa/isa.c,v 1.26 2001/07/11
|
|
|
|
*/
|
|
|
|
|
2004-11-17 14:44:10 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2001-11-09 20:21:21 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/bus.h>
|
2004-05-08 13:53:47 +00:00
|
|
|
|
2001-11-09 20:21:21 +00:00
|
|
|
#include <machine/bus.h>
|
2004-05-08 13:53:47 +00:00
|
|
|
|
2001-11-09 20:21:21 +00:00
|
|
|
#include <sys/rman.h>
|
|
|
|
|
|
|
|
#include <isa/isareg.h>
|
|
|
|
#include <isa/isavar.h>
|
|
|
|
#include <isa/isa_common.h>
|
|
|
|
|
- Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
properties in drivers for devices on Open Firmware supported busses. The
standard properties "reg", "interrupts" und "address" are not covered by
this interface because they are only of interest in the respective bridge
code. There's a remaining standard property "status" which is unclear how
to support properly but which also isn't used in FreeBSD at present.
This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
This in turn allows to simplify and remove code-duplication in drivers for
devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
drivers for their children to use the ofw_bus kobj-interface. The IVAR-
interfaces of the Central, EBus and FHC are entirely replaced by this. The
PCI bus driver used its own kobj-interface and now also uses the ofw_bus
one. The IVARs special to the SBus, e.g. for retrieving the burst size,
remain.
Beware: this causes an ABI-breakage for modules of drivers which used the
IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
recompiled.
The style-inconsistencies introduced in some of the bus drivers will be
fixed by tmm@ in a generic clean-up of the respective drivers later (he
requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
use the ofw_bus kobj-interface. This invloves removing the IVARs related
to the "reg" property which were unused and a leftover from the NetBSD
origini of the code. There's no ABI-breakage caused by this because none
of these driver are currently built as modules.
There are other powerpc bus drivers which can be converted to the ofw_bus
kobj-interface, e.g. the PCI bus driver, which should be done together
with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
advantage of the ofw_bus kobj-interface and simplify them a bit.
Reviewed by: grehan, tmm
Approved by: re (scottl)
Discussed with: tmm
Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
2004-08-12 17:41:33 +00:00
|
|
|
#include <dev/ofw/ofw_bus.h>
|
2003-08-23 00:11:16 +00:00
|
|
|
#include <dev/ofw/openfirm.h>
|
2001-11-09 20:21:21 +00:00
|
|
|
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
2004-05-08 13:53:47 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
|
2001-11-09 20:21:21 +00:00
|
|
|
#include <sparc64/pci/ofw_pci.h>
|
|
|
|
#include <sparc64/isa/ofw_isa.h>
|
|
|
|
|
|
|
|
/* There can be only one ISA bus, so it is safe to use globals. */
|
2004-05-08 13:53:47 +00:00
|
|
|
static u_int64_t isa_io_base;
|
|
|
|
static u_int64_t isa_io_limit;
|
|
|
|
static u_int64_t isa_mem_base;
|
|
|
|
static u_int64_t isa_mem_limit;
|
2001-11-09 20:21:21 +00:00
|
|
|
|
|
|
|
device_t isa_bus_device;
|
|
|
|
|
|
|
|
static phandle_t isab_node;
|
2004-11-17 14:44:10 +00:00
|
|
|
static struct isa_ranges *isab_ranges;
|
|
|
|
static int isab_nrange;
|
|
|
|
static struct ofw_bus_iinfo isa_iinfo;
|
2001-11-09 20:21:21 +00:00
|
|
|
|
|
|
|
/*
|
2004-11-17 14:44:10 +00:00
|
|
|
* XXX: This is really partly PCI-specific, but unfortunately is
|
2001-11-09 20:21:21 +00:00
|
|
|
* differently enough to have to duplicate it here...
|
|
|
|
*/
|
|
|
|
#define ISAB_RANGE_PHYS(r) \
|
|
|
|
(((u_int64_t)(r)->phys_mid << 32) | (u_int64_t)(r)->phys_lo)
|
|
|
|
#define ISAB_RANGE_SPACE(r) (((r)->phys_hi >> 24) & 0x03)
|
|
|
|
|
|
|
|
#define ISAR_SPACE_IO 0x01
|
|
|
|
#define ISAR_SPACE_MEM 0x02
|
|
|
|
|
|
|
|
#define INRANGE(x, start, end) ((x) >= (start) && (x) <= (end))
|
|
|
|
|
2004-11-17 14:44:10 +00:00
|
|
|
static void isa_setup_children(device_t, phandle_t);
|
2001-11-09 20:21:21 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
isa_init(device_t dev)
|
|
|
|
{
|
|
|
|
device_t bridge;
|
2004-11-17 14:44:10 +00:00
|
|
|
int i;
|
2001-11-09 20:21:21 +00:00
|
|
|
|
|
|
|
/* The parent of the bus must be a PCI-ISA bridge. */
|
|
|
|
bridge = device_get_parent(dev);
|
- Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
properties in drivers for devices on Open Firmware supported busses. The
standard properties "reg", "interrupts" und "address" are not covered by
this interface because they are only of interest in the respective bridge
code. There's a remaining standard property "status" which is unclear how
to support properly but which also isn't used in FreeBSD at present.
This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
This in turn allows to simplify and remove code-duplication in drivers for
devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
drivers for their children to use the ofw_bus kobj-interface. The IVAR-
interfaces of the Central, EBus and FHC are entirely replaced by this. The
PCI bus driver used its own kobj-interface and now also uses the ofw_bus
one. The IVARs special to the SBus, e.g. for retrieving the burst size,
remain.
Beware: this causes an ABI-breakage for modules of drivers which used the
IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
recompiled.
The style-inconsistencies introduced in some of the bus drivers will be
fixed by tmm@ in a generic clean-up of the respective drivers later (he
requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
use the ofw_bus kobj-interface. This invloves removing the IVARs related
to the "reg" property which were unused and a leftover from the NetBSD
origini of the code. There's no ABI-breakage caused by this because none
of these driver are currently built as modules.
There are other powerpc bus drivers which can be converted to the ofw_bus
kobj-interface, e.g. the PCI bus driver, which should be done together
with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
advantage of the ofw_bus kobj-interface and simplify them a bit.
Reviewed by: grehan, tmm
Approved by: re (scottl)
Discussed with: tmm
Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
2004-08-12 17:41:33 +00:00
|
|
|
isab_node = ofw_bus_get_node(bridge);
|
2004-11-17 14:44:10 +00:00
|
|
|
isab_nrange = OF_getprop_alloc(isab_node, "ranges",
|
|
|
|
sizeof(*isab_ranges), (void **)&isab_ranges);
|
|
|
|
if (isab_nrange <= 0)
|
2001-11-09 20:21:21 +00:00
|
|
|
panic("isa_init: cannot get bridge range property");
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
|
|
|
|
ofw_bus_setup_iinfo(isab_node, &isa_iinfo, sizeof(ofw_isa_intr_t));
|
|
|
|
|
2004-11-17 14:44:10 +00:00
|
|
|
isa_setup_children(dev, isab_node);
|
|
|
|
|
|
|
|
for (i = isab_nrange - 1; i >= 0; i--) {
|
|
|
|
switch(ISAB_RANGE_SPACE(&isab_ranges[i])) {
|
2001-11-09 20:21:21 +00:00
|
|
|
case ISAR_SPACE_IO:
|
|
|
|
/* This is probably always 0. */
|
2004-11-17 14:44:10 +00:00
|
|
|
isa_io_base = ISAB_RANGE_PHYS(&isab_ranges[i]);
|
|
|
|
isa_io_limit = isab_ranges[i].size;
|
2001-11-09 20:21:21 +00:00
|
|
|
break;
|
|
|
|
case ISAR_SPACE_MEM:
|
|
|
|
/* This is probably always 0. */
|
2004-11-17 14:44:10 +00:00
|
|
|
isa_mem_base = ISAB_RANGE_PHYS(&isab_ranges[i]);
|
|
|
|
isa_mem_limit = isab_ranges[i].size;
|
2001-11-09 20:21:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-05 17:48:54 +00:00
|
|
|
static const struct {
|
2010-04-26 18:49:06 +00:00
|
|
|
const char *const name;
|
2004-11-17 14:44:10 +00:00
|
|
|
uint32_t id;
|
2014-02-23 18:36:45 +00:00
|
|
|
} ofw_isa_pnp_map[] = {
|
2004-11-17 14:44:10 +00:00
|
|
|
{ "SUNW,lomh", 0x0000ae4e }, /* SUN0000 */
|
|
|
|
{ "dma", 0x0002d041 }, /* PNP0200 */
|
|
|
|
{ "floppy", 0x0007d041 }, /* PNP0700 */
|
|
|
|
{ "rtc", 0x000bd041 }, /* PNP0B00 */
|
|
|
|
{ "flashprom", 0x0100ae4e }, /* SUN0001 */
|
|
|
|
{ "parallel", 0x0104d041 }, /* PNP0401 */
|
|
|
|
{ "serial", 0x0105d041 }, /* PNP0501 */
|
2010-04-26 18:49:06 +00:00
|
|
|
{ "su", 0x0105d041 }, /* PNP0501 */
|
2006-06-05 17:48:54 +00:00
|
|
|
{ "i2c", 0x0200ae4e }, /* SUN0002 */
|
|
|
|
{ "rmc-comm", 0x0300ae4e }, /* SUN0003 */
|
2004-11-17 14:44:10 +00:00
|
|
|
{ "kb_ps2", 0x0303d041 }, /* PNP0303 */
|
|
|
|
{ "kdmouse", 0x030fd041 }, /* PNP0F03 */
|
2009-03-19 20:57:59 +00:00
|
|
|
{ "bscbus", 0x0400ae4e }, /* SUN0004 */
|
2004-11-17 14:44:10 +00:00
|
|
|
{ "power", 0x0c0cd041 }, /* PNP0C0C */
|
|
|
|
{ NULL, 0x0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
isa_setup_children(device_t dev, phandle_t parent)
|
2001-11-09 20:21:21 +00:00
|
|
|
{
|
2004-11-17 14:44:10 +00:00
|
|
|
struct isa_regs *regs;
|
2005-05-19 15:47:37 +00:00
|
|
|
struct resource_list *rl;
|
2004-11-17 14:44:10 +00:00
|
|
|
device_t cdev;
|
|
|
|
u_int64_t end, start;
|
|
|
|
ofw_isa_intr_t *intrs, rintr;
|
|
|
|
phandle_t node;
|
|
|
|
uint32_t *drqs, *regidx;
|
2005-05-19 15:47:37 +00:00
|
|
|
int i, ndrq, nintr, nreg, nregidx, rid, rtype;
|
2004-11-17 14:44:10 +00:00
|
|
|
char *name;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop through children and fake up PnP devices for them.
|
|
|
|
* Their resources are added as fully mapped and specified because
|
|
|
|
* adjusting the resources and the resource list entries respectively
|
|
|
|
* in isa_alloc_resource() causes trouble with drivers which use
|
|
|
|
* rman_get_start(), pass-through or allocate and release resources
|
|
|
|
* multiple times, etc. Adjusting the resources might be better off
|
|
|
|
* in a bus_activate_resource method but the common ISA code doesn't
|
|
|
|
* allow for an isa_activate_resource().
|
|
|
|
*/
|
|
|
|
for (node = OF_child(parent); node != 0; node = OF_peer(node)) {
|
|
|
|
if ((OF_getprop_alloc(node, "name", 1, (void **)&name)) == -1)
|
|
|
|
continue;
|
2001-11-09 20:21:21 +00:00
|
|
|
|
2004-11-17 14:44:10 +00:00
|
|
|
/*
|
|
|
|
* Keyboard and mouse controllers hang off of the `8042'
|
|
|
|
* node but we have no real use for the `8042' itself.
|
|
|
|
*/
|
|
|
|
if (strcmp(name, "8042") == 0) {
|
|
|
|
isa_setup_children(dev, node);
|
|
|
|
free(name, M_OFWPROP);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-05-19 15:47:37 +00:00
|
|
|
for (i = 0; ofw_isa_pnp_map[i].name != NULL; i++)
|
|
|
|
if (strcmp(ofw_isa_pnp_map[i].name, name) == 0)
|
2004-11-17 14:44:10 +00:00
|
|
|
break;
|
2005-05-19 15:47:37 +00:00
|
|
|
if (ofw_isa_pnp_map[i].name == NULL) {
|
2007-10-28 22:08:37 +00:00
|
|
|
device_printf(dev, "no PnP map entry for node "
|
2004-11-17 14:44:10 +00:00
|
|
|
"0x%lx: %s\n", (unsigned long)node, name);
|
2006-06-05 17:48:54 +00:00
|
|
|
free(name, M_OFWPROP);
|
2004-11-17 14:44:10 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-12-07 05:30:02 +00:00
|
|
|
if ((cdev = BUS_ADD_CHILD(dev, ISA_ORDER_PNPBIOS, NULL, -1)) ==
|
2004-11-17 14:44:10 +00:00
|
|
|
NULL)
|
|
|
|
panic("isa_setup_children: BUS_ADD_CHILD failed");
|
2005-05-19 15:47:37 +00:00
|
|
|
isa_set_logicalid(cdev, ofw_isa_pnp_map[i].id);
|
|
|
|
isa_set_vendorid(cdev, ofw_isa_pnp_map[i].id);
|
2004-11-17 14:44:10 +00:00
|
|
|
|
2005-05-19 15:47:37 +00:00
|
|
|
rl = BUS_GET_RESOURCE_LIST(dev, cdev);
|
2004-11-17 14:44:10 +00:00
|
|
|
nreg = OF_getprop_alloc(node, "reg", sizeof(*regs),
|
|
|
|
(void **)®s);
|
|
|
|
for (i = 0; i < nreg; i++) {
|
|
|
|
start = ISA_REG_PHYS(®s[i]);
|
|
|
|
end = start + regs[i].size - 1;
|
|
|
|
rtype = ofw_isa_range_map(isab_ranges, isab_nrange,
|
|
|
|
&start, &end, NULL);
|
2005-05-19 15:47:37 +00:00
|
|
|
rid = 0;
|
|
|
|
while (resource_list_find(rl, rtype, rid) != NULL)
|
|
|
|
rid++;
|
|
|
|
bus_set_resource(cdev, rtype, rid, start,
|
2004-11-17 14:44:10 +00:00
|
|
|
end - start + 1);
|
|
|
|
}
|
|
|
|
if (nreg == -1 && parent != isab_node) {
|
|
|
|
/*
|
|
|
|
* The "reg" property still might be an index into
|
|
|
|
* the set of registers of the parent device like
|
|
|
|
* with the nodes hanging off of the `8042' node.
|
|
|
|
*/
|
|
|
|
nregidx = OF_getprop_alloc(node, "reg", sizeof(*regidx),
|
|
|
|
(void **)®idx);
|
|
|
|
if (nregidx > 2)
|
|
|
|
panic("isa_setup_children: impossible number "
|
|
|
|
"of register indices");
|
|
|
|
if (nregidx != -1 && (nreg = OF_getprop_alloc(parent,
|
|
|
|
"reg", sizeof(*regs), (void **)®s)) >= nregidx) {
|
|
|
|
for (i = 0; i < nregidx; i++) {
|
|
|
|
start = ISA_REG_PHYS(®s[regidx[i]]);
|
|
|
|
end = start + regs[regidx[i]].size - 1;
|
|
|
|
rtype = ofw_isa_range_map(isab_ranges,
|
|
|
|
isab_nrange, &start, &end, NULL);
|
2005-05-19 15:47:37 +00:00
|
|
|
rid = 0;
|
|
|
|
while (resource_list_find(rl, rtype,
|
|
|
|
rid) != NULL)
|
|
|
|
rid++;
|
|
|
|
bus_set_resource(cdev, rtype, rid,
|
|
|
|
start, end - start + 1);
|
2004-11-17 14:44:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (regidx != NULL)
|
|
|
|
free(regidx, M_OFWPROP);
|
|
|
|
}
|
|
|
|
if (regs != NULL)
|
|
|
|
free(regs, M_OFWPROP);
|
|
|
|
|
|
|
|
nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intrs),
|
|
|
|
(void **)&intrs);
|
|
|
|
for (i = 0; i < nintr; i++) {
|
|
|
|
if (intrs[i] > 7)
|
|
|
|
panic("isa_setup_children: intr too large");
|
|
|
|
rintr = ofw_isa_route_intr(device_get_parent(dev), node,
|
|
|
|
&isa_iinfo, intrs[i]);
|
2007-10-28 22:08:37 +00:00
|
|
|
if (rintr == PCI_INVALID_IRQ) {
|
|
|
|
device_printf(dev, "could not map ISA "
|
|
|
|
"interrupt %d for node 0x%lx: %s\n",
|
|
|
|
intrs[i], (unsigned long)node, name);
|
|
|
|
continue;
|
|
|
|
}
|
2004-11-17 14:44:10 +00:00
|
|
|
bus_set_resource(cdev, SYS_RES_IRQ, i, rintr, 1);
|
|
|
|
}
|
|
|
|
if (intrs != NULL)
|
|
|
|
free(intrs, M_OFWPROP);
|
|
|
|
|
|
|
|
ndrq = OF_getprop_alloc(node, "dma-channel", sizeof(*drqs),
|
|
|
|
(void **)&drqs);
|
|
|
|
for (i = 0; i < ndrq; i++)
|
|
|
|
bus_set_resource(cdev, SYS_RES_DRQ, i, drqs[i], 1);
|
|
|
|
if (drqs != NULL)
|
|
|
|
free(drqs, M_OFWPROP);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Devices using DMA hang off of the `dma' node instead of
|
|
|
|
* directly from the ISA bridge node.
|
|
|
|
*/
|
|
|
|
if (strcmp(name, "dma") == 0)
|
|
|
|
isa_setup_children(dev, node);
|
|
|
|
|
|
|
|
free(name, M_OFWPROP);
|
2001-11-09 20:21:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct resource *
|
|
|
|
isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
2007-10-28 22:08:37 +00:00
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
2001-11-09 20:21:21 +00:00
|
|
|
{
|
|
|
|
/*
|
2004-03-17 21:45:55 +00:00
|
|
|
* Consider adding a resource definition.
|
2001-11-09 20:21:21 +00:00
|
|
|
*/
|
|
|
|
int passthrough = (device_get_parent(child) != bus);
|
|
|
|
int isdefault = (start == 0UL && end == ~0UL);
|
2005-05-19 15:47:37 +00:00
|
|
|
struct resource_list *rl;
|
2001-11-09 20:21:21 +00:00
|
|
|
struct resource_list_entry *rle;
|
|
|
|
u_long base, limit;
|
|
|
|
|
2005-05-19 15:47:37 +00:00
|
|
|
rl = BUS_GET_RESOURCE_LIST(bus, child);
|
2001-11-09 20:21:21 +00:00
|
|
|
if (!passthrough && !isdefault) {
|
|
|
|
rle = resource_list_find(rl, type, *rid);
|
|
|
|
if (!rle) {
|
|
|
|
if (*rid < 0)
|
2005-05-19 15:47:37 +00:00
|
|
|
return (NULL);
|
2001-11-09 20:21:21 +00:00
|
|
|
switch (type) {
|
|
|
|
case SYS_RES_IRQ:
|
|
|
|
if (*rid >= ISA_NIRQ)
|
2005-05-19 15:47:37 +00:00
|
|
|
return (NULL);
|
2001-11-09 20:21:21 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_DRQ:
|
|
|
|
if (*rid >= ISA_NDRQ)
|
2005-05-19 15:47:37 +00:00
|
|
|
return (NULL);
|
2001-11-09 20:21:21 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_MEMORY:
|
|
|
|
if (*rid >= ISA_NMEM)
|
2005-05-19 15:47:37 +00:00
|
|
|
return (NULL);
|
2001-11-09 20:21:21 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_IOPORT:
|
|
|
|
if (*rid >= ISA_NPORT)
|
2005-05-19 15:47:37 +00:00
|
|
|
return (NULL);
|
2001-11-09 20:21:21 +00:00
|
|
|
break;
|
|
|
|
default:
|
2005-05-19 15:47:37 +00:00
|
|
|
return (NULL);
|
2001-11-09 20:21:21 +00:00
|
|
|
}
|
|
|
|
resource_list_add(rl, type, *rid, start, end, count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2004-11-17 14:44:10 +00:00
|
|
|
* Sanity check if the resource in the respective entry is fully
|
|
|
|
* mapped and specified and its type allocable. A driver could
|
|
|
|
* have added an out of range resource on its own.
|
2001-11-09 20:21:21 +00:00
|
|
|
*/
|
2004-11-17 14:44:10 +00:00
|
|
|
if (!passthrough) {
|
|
|
|
if ((rle = resource_list_find(rl, type, *rid)) == NULL)
|
2001-11-09 20:21:21 +00:00
|
|
|
return (NULL);
|
2004-11-17 14:44:10 +00:00
|
|
|
base = limit = 0;
|
2001-11-09 20:21:21 +00:00
|
|
|
switch (type) {
|
|
|
|
case SYS_RES_MEMORY:
|
2004-11-17 14:44:10 +00:00
|
|
|
base = isa_mem_base;
|
|
|
|
limit = base + isa_mem_limit;
|
|
|
|
break;
|
2001-11-09 20:21:21 +00:00
|
|
|
case SYS_RES_IOPORT:
|
2004-11-17 14:44:10 +00:00
|
|
|
base = isa_io_base;
|
|
|
|
limit = base + isa_io_limit;
|
2001-11-09 20:21:21 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_IRQ:
|
2004-11-17 14:44:10 +00:00
|
|
|
if (rle->start != rle->end || rle->start <= 7)
|
2001-11-09 20:21:21 +00:00
|
|
|
return (NULL);
|
|
|
|
break;
|
2004-11-17 14:44:10 +00:00
|
|
|
case SYS_RES_DRQ:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
if (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT) {
|
|
|
|
if (!INRANGE(rle->start, base, limit) ||
|
|
|
|
!INRANGE(rle->end, base, limit))
|
|
|
|
return (NULL);
|
2001-11-09 20:21:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-17 14:44:10 +00:00
|
|
|
return (resource_list_alloc(rl, bus, child, type, rid, start, end,
|
|
|
|
count, flags));
|
2001-11-09 20:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
isa_release_resource(device_t bus, device_t child, int type, int rid,
|
2007-10-28 22:08:37 +00:00
|
|
|
struct resource *res)
|
2001-11-09 20:21:21 +00:00
|
|
|
{
|
|
|
|
|
2005-05-19 15:47:37 +00:00
|
|
|
return (bus_generic_rl_release_resource(bus, child, type, rid, res));
|
2001-11-09 20:21:21 +00:00
|
|
|
}
|