summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/powermac/ata_kauai.c
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2008-10-14 14:54:14 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2008-10-14 14:54:14 +0000
commit0d091e41decf056612b1d6a8280ab6401f861f54 (patch)
treec6f1268aba033a8e59745da49122a0eae51600b2 /sys/powerpc/powermac/ata_kauai.c
parente1d3902c1d1d293d29f200516564bb6a8b9acca9 (diff)
downloadFreeBSD-src-0d091e41decf056612b1d6a8280ab6401f861f54.zip
FreeBSD-src-0d091e41decf056612b1d6a8280ab6401f861f54.tar.gz
Convert PowerPC AIM PCI and nexus busses to standard OFW bus interface. This
simplifies certain device attachments (Kauai ATA, for instance), and makes possible others on new hardware. On G5 systems, there are several otherwise standard PCI devices (Serverworks SATA) that will not allow their interrupt properties to be written, so this information must be supplied directly from Open Firmware. Obtained from: sparc64
Diffstat (limited to 'sys/powerpc/powermac/ata_kauai.c')
-rw-r--r--sys/powerpc/powermac/ata_kauai.c60
1 files changed, 9 insertions, 51 deletions
diff --git a/sys/powerpc/powermac/ata_kauai.c b/sys/powerpc/powermac/ata_kauai.c
index 0582251..53fc676 100644
--- a/sys/powerpc/powermac/ata_kauai.c
+++ b/sys/powerpc/powermac/ata_kauai.c
@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
#include <ata_if.h>
#include <dev/ofw/openfirm.h>
-#include <powerpc/ofw/ofw_pci.h>
+#include <dev/ofw/ofw_bus.h>
#include <machine/intr_machdep.h>
#include <dev/pci/pcivar.h>
@@ -194,11 +194,10 @@ ata_kauai_probe(device_t dev)
{
struct ata_channel *ch;
struct ata_kauai_softc *sc;
- u_long startp, countp;
u_int32_t devid;
phandle_t node;
- char *compatstring = NULL;
- int i, found, rid, status;
+ const char *compatstring = NULL;
+ int i, found, rid;
found = 0;
devid = pci_get_devid(dev);
@@ -212,59 +211,18 @@ ata_kauai_probe(device_t dev)
if (!found)
return (ENXIO);
- node = ofw_pci_find_node(dev);
+ node = ofw_bus_get_node(dev);
sc = device_get_softc(dev);
bzero(sc, sizeof(struct ata_kauai_softc));
ch = &sc->sc_ch.sc_ch;
- OF_getprop_alloc(node, "compatible", 1, (void **)&compatstring);
- if (strcmp(compatstring,"shasta-ata") == 0)
+ compatstring = ofw_bus_get_compat(dev);
+ if (compatstring != NULL && strcmp(compatstring,"shasta-ata") == 0)
sc->shasta = 1;
- free(compatstring, M_OFWPROP);
-
-
- /*
- * This device seems to ignore writes to the interrupt
- * config register, resulting in interrupt resources
- * not being attached. If this is the case, use
- * Open Firmware to determine the irq, and then attach
- * the resource. This allows the ATA common code to
- * allocate the irq.
- */
- status = bus_get_resource(dev, SYS_RES_IRQ, 0, &startp, &countp);
- if (status == ENOENT) {
- int *irq;
- phandle_t iparent;
- int icells, nintr, i;
-
- /*
- * Horrible hack to handle Kauai devices that have their IRQs
- * set up in an utterly wrong way
- */
- if (!sc->shasta)
- bus_set_resource(dev, SYS_RES_IRQ, 0, 39, 1);
-
- /*
- * For the rest of the interrupts, and the main Shasta
- * interrupt, get the IRQs from firmware.
- */
- if (OF_getprop(node, "interrupt-parent", &iparent,
- sizeof(iparent)) == sizeof(iparent)) {
- OF_getprop(iparent, "#interrupt-cells", &icells,
- sizeof(icells)) ;
- }
-
- nintr = OF_getprop_alloc(node, "interrupts", sizeof(*irq),
- (void **)&irq);
-
- for (i = 0; i < nintr; i += icells)
- bus_set_resource(dev, SYS_RES_IRQ,
- i/icells + !sc->shasta, irq[i], 1);
-
- free(irq, M_OFWPROP);
- }
-
+ /* Regular Kauai controllers apparently need this hack */
+ if (!sc->shasta)
+ bus_set_resource(dev, SYS_RES_IRQ, 0, 39, 1);
rid = PCIR_BARS;
sc->sc_memr = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
OpenPOWER on IntegriCloud