summaryrefslogtreecommitdiffstats
path: root/sys/dev/fb
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2007-03-07 21:13:51 +0000
committermarius <marius@FreeBSD.org>2007-03-07 21:13:51 +0000
commit3ee9e586b35a229cddccc22c1dd4ecfecbe90479 (patch)
tree667b76e76345ed2206307e4f857ee9072cec2a6e /sys/dev/fb
parentbe6311d7e9ed6a0c56de419a9feda69db957f6dc (diff)
downloadFreeBSD-src-3ee9e586b35a229cddccc22c1dd4ecfecbe90479.zip
FreeBSD-src-3ee9e586b35a229cddccc22c1dd4ecfecbe90479.tar.gz
Rototill the sparc64 nexus(4) (actually this brings in the code the
sun4v nexus(4) in turn is based on): o Change nexus(4) to manage the resources of its children so the respective device drivers don't need to figure them out of OFW themselves. o Change nexus(4) to provide the ofw_bus KOBJ interface instead of using IVARs for supplying the OFW node and the subset of standard properties of its children. Together with the previous change this also allows to fully take advantage of newbus in that drivers like fhc(4), which attach on multiple parent busses, no longer require different bus front-ends as obtaining the OFW node and properties as well as resource allocation works the same for all supported busses. As such this change also is part 4/4 of allowing creator(4) to work in USIII-based machines as it allows this driver to attach on both nexus(4) and upa(4). On the other hand removing these IVARs breaks API compatibility with the powerpc nexus(4) but which isn't that bad as a) sparc64 currently doesn't share any device driver hanging off of nexus(4) with powerpc and b) they were no longer compatible regarding OFW-related extensions at the pci(4) level since quite some time. o Provide bus_get_dma_tag methods in nexus(4) and its children in order to handle DMA tags in a hierarchical way and get rid of the sparc64_root_dma_tag kludge. Together with the previous two items this changes also allows to completely get rid of the nexus(4) IVAR interface. It also includes: - pushing the constraints previously specified by the nexus_dmatag down into the DMA tags of psycho(4) and sbus(4) as it's their IOMMUs which induce these restrictions (and nothing at the nexus(4) or anything that would warrant specifying them there), - fixing some obviously wrong constraints of the psycho(4) and sbus(4) DMA tags, which happened to not actually be used with the sparc64_root_dma_tag kludge in place and therefore didn't cause problems so far, - replacing magic constants for constraints with macros as far as it is obvious as to where they come from. This doesn't include taking advantage of the newbus way to get the parent DMA tags implemented by this change in order to divorce the IOTSBs of the PCI and SBus IOMMUs or for implementing the workaround for the DMA sync bug in Sabre (and Tomatillo) bridges, yet, though. o Get rid of the notion that nexus(4) (mostly) reflects an UPA bus by replacing ofw_upa.h and with ofw_nexus.h (which was repo-copied from ofw_upa.h) and renaming its content, which actually applies to all of Fireplane/Safari, JBus and UPA (in the host bus case), as appropriate. o Just use M_DEVBUF instead of a separate M_NEXUS malloc type for allocating the device info for the children of nexus(4). This is done in order to not need to export M_NEXUS when deriving drivers for subordinate busses from the nexus(4) class. o Use the DEFINE_CLASS_0() macro to declare the nexus(4) driver so we can derive subclasses from it. o Const'ify the nexus_excl_name and nexus_excl_type arrays as well as add 'associations' and 'rsc', which are pseudo-devices without resources and therefore of no real interest for nexus(4), to the former. o Let the nexus(4) device memory rman manage the entire 64-bit address space instead of just the UPA_MEMSTART to UPA_MEMEND subregion as Fireplane/Safari- and JBus-based machines use multiple ranges, which can't be as easily divided as in the case of UPA (limiting the address space only served for sanity checking anyway). o Use M_WAITOK instead of M_NOWAIT when allocating the device info for children of nexus(4) in order to give one less opportunity for adding devices to nexus(4) to fail. o While adapting the drivers affected by the above nexus(4) changes, change them to take advantage of rman_get_rid() instead of caching the RIDs assigned to allocated resources, now that the RIDs of resources are correctly set. o In iommu(4) and nexus(4) replace hard-coded functions names, which actually became outdated in several places, in panic strings and status massages with __func__. [1] o Use driver_filter_t in prototypes where appropriate. o Add my copyright to creator(4), fhc(4), nexus(4), psycho(4) and sbus(4) as I changed considerable amounts of these drivers as well as added a bunch of new features, workarounds for silicon bugs etc. o Fix some white space nits. Due to lack of access to Exx00 hardware, these changes, i.e. central(4) and fhc(4), couldn't be runtime tested on such a machine. Exx00 are currently reported to panic before trying to attach nexus(4) anyway though. PR: 76052 [1] Approved by: re (kensmith)
Diffstat (limited to 'sys/dev/fb')
-rw-r--r--sys/dev/fb/creator.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/sys/dev/fb/creator.c b/sys/dev/fb/creator.c
index f9f293c..4fa88fa 100644
--- a/sys/dev/fb/creator.c
+++ b/sys/dev/fb/creator.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003 Jake Burkholder.
+ * Copyright (c) 2005 - 2006 Marius Strobl <marius@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,13 +38,12 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/resource.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
#include <machine/bus_private.h>
-#include <machine/nexusvar.h>
#include <machine/ofw_machdep.h>
-#include <machine/ofw_upa.h>
#include <machine/resource.h>
#include <machine/sc_machdep.h>
@@ -63,7 +63,6 @@ struct creator_softc {
struct cdev *sc_si;
- int sc_rid[FFB_NREG];
struct resource *sc_reg[FFB_NREG];
bus_space_tag_t sc_bt[FFB_NREG];
bus_space_handle_t sc_bh[FFB_NREG];
@@ -172,9 +171,7 @@ static devclass_t creator_devclass;
DEFINE_CLASS_0(creator, creator_bus_driver, creator_bus_methods,
sizeof(struct creator_softc));
DRIVER_MODULE(creator, nexus, creator_bus_driver, creator_devclass, 0, 0);
-#if 0
DRIVER_MODULE(creator, upa, creator_bus_driver, creator_devclass, 0, 0);
-#endif
static d_open_t creator_fb_open;
static d_close_t creator_fb_close;
@@ -880,8 +877,8 @@ creator_bus_probe(device_t dev)
phandle_t node;
int type;
- name = nexus_get_name(dev);
- node = nexus_get_node(dev);
+ name = ofw_bus_get_name(dev);
+ node = ofw_bus_get_node(dev);
if (strcmp(name, "SUNW,ffb") == 0) {
if (OF_getprop(node, "board_type", &type, sizeof(type)) == -1)
return (ENXIO);
@@ -906,18 +903,15 @@ static int
creator_bus_attach(device_t dev)
{
struct creator_softc *sc;
- struct upa_regs *reg;
video_adapter_t *adp;
video_switch_t *sw;
phandle_t node;
- bus_addr_t phys;
- bus_size_t size;
int error;
- int nreg;
+ int rid;
int unit;
int i;
- node = nexus_get_node(dev);
+ node = ofw_bus_get_node(dev);
if ((sc = (struct creator_softc *)vid_get_adapter(vid_find_adapter(
CREATOR_DRIVER_NAME, 0))) != NULL && sc->sc_node == node) {
device_printf(dev, "console\n");
@@ -940,20 +934,10 @@ creator_bus_attach(device_t dev)
* allocate more than these two resources and just limit the
* range accessible via creator_fb_mmap() accordingly.
*/
- reg = nexus_get_reg(dev);
- nreg = nexus_get_nreg(dev);
- if (nreg <= FFB_FBC) {
- device_printf(dev, "not enough resources\n");
- error = ENXIO;
- goto fail;
- }
- for (i = 0; i < nreg; i++) {
- phys = UPA_REG_PHYS(reg + i);
- size = UPA_REG_SIZE(reg + i);
- sc->sc_rid[i] = i;
- sc->sc_reg[i] = bus_alloc_resource(dev, SYS_RES_MEMORY,
- &sc->sc_rid[i], phys, phys + size - 1, size,
- RF_ACTIVE);
+ for (i = 0; i < FFB_NREG; i++) {
+ rid = i;
+ sc->sc_reg[i] = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &rid, RF_ACTIVE);
if (sc->sc_reg[i] == NULL) {
if (i <= FFB_FBC) {
device_printf(dev,
@@ -1000,7 +984,7 @@ creator_bus_attach(device_t dev)
for (i = 0; i < devclass_get_maxunit(creator_devclass); i++)
if (vid_find_adapter(CREATOR_DRIVER_NAME, i) < 0)
break;
- if (strcmp(nexus_get_name(dev), "SUNW,afb") == 0)
+ if (strcmp(ofw_bus_get_name(dev), "SUNW,afb") == 0)
sc->sc_flags |= CREATOR_AFB;
if ((error = sw->init(i, adp, 0)) != 0) {
device_printf(dev, "cannot initialize adapter\n");
@@ -1031,8 +1015,8 @@ creator_bus_attach(device_t dev)
fail:
for (i = 0; i < FFB_NREG && sc->sc_reg[i] != NULL; i++)
- bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rid[i],
- sc->sc_reg[i]);
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ rman_get_rid(sc->sc_reg[i]), sc->sc_reg[i]);
return (error);
}
OpenPOWER on IntegriCloud