CVS commit: src/sys/arch/macppc/pci

2018-04-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Apr 13 22:13:09 UTC 2018

Modified Files:
src/sys/arch/macppc/pci: u3.c

Log Message:
track bus-range for every bus and restrict config space accesses to that
range. Now pcictl pci* list no longer crashes the kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/macppc/pci/u3.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/pci/u3.c
diff -u src/sys/arch/macppc/pci/u3.c:1.8 src/sys/arch/macppc/pci/u3.c:1.9
--- src/sys/arch/macppc/pci/u3.c:1.8	Fri Oct  2 05:22:51 2015
+++ src/sys/arch/macppc/pci/u3.c	Fri Apr 13 22:13:09 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: u3.c,v 1.8 2015/10/02 05:22:51 msaitoh Exp $ */
+/* $NetBSD: u3.c,v 1.9 2018/04/13 22:13:09 macallan Exp $ */
 
 /*
  * Copyright 2006 Kyma Systems LLC.
@@ -54,8 +54,12 @@ struct ibmcpc_softc
 	struct genppc_pci_chipset sc_pc[8];
 	struct powerpc_bus_space sc_iot;
 	struct powerpc_bus_space sc_memt;
+	int sc_ranges[8];	
 };
 
+/* kinda ugly but there can be only one */
+static struct ibmcpc_softc *cpc0 = NULL;
+
 static void ibmcpc_attach(device_t, device_t, void *);
 static int ibmcpc_match(device_t, cfdata_t, void *);
 
@@ -108,6 +112,8 @@ ibmcpc_attach(device_t parent, device_t 
 	reg[1], reg[2]);
 	pc_data = mapiodev(reg[1], reg[2], false);
 
+	cpc0 = sc;
+
 	for (child = OF_child(OF_finddevice("/ht")), i = 1; child;
 	child = OF_peer(child), i++) {
 
@@ -141,6 +147,7 @@ ibmcpc_attach(device_t parent, device_t 
 		macppc_pci_get_chipset_tag(pc);
 		pc->pc_node = child;
 		pc->pc_bus = busrange[0];
+		sc->sc_ranges[pc->pc_bus] = busrange[1];
 		pc->pc_addr = 0x0;
 		pc->pc_data = pc_data;
 		pc->pc_conf_read = ibmcpc_conf_read;
@@ -167,6 +174,7 @@ static pcireg_t
 ibmcpc_conf_read(void *cookie, pcitag_t tag, int reg)
 {
 	pci_chipset_tag_t pc = cookie;
+	struct ibmcpc_softc *sc = cpc0;
 	u_int32_t daddr = (u_int32_t) pc->pc_data;
 	pcireg_t data;
 	u_int32_t bus, dev, func, x, devfn;
@@ -176,6 +184,11 @@ ibmcpc_conf_read(void *cookie, pcitag_t 
 
 	pci_decompose_tag(pc, tag, , , );
 
+	if ((bus < pc->pc_bus) || (bus > sc->sc_ranges[pc->pc_bus])) {
+		data = 0x;
+		goto done;
+	}		 
+
 	devfn = PCI_DEVFN(dev, func);
 
 	if (bus == 0) {
@@ -200,6 +213,7 @@ static void
 ibmcpc_conf_write(void *cookie, pcitag_t tag, int reg, pcireg_t data)
 {
 	pci_chipset_tag_t pc = cookie;
+	struct ibmcpc_softc *sc = cpc0;
 	int32_t *daddr = pc->pc_data;
 	u_int32_t bus, dev, func;
 	u_int32_t x, devfn;
@@ -209,6 +223,9 @@ ibmcpc_conf_write(void *cookie, pcitag_t
 
 	pci_decompose_tag(pc, tag, , , );
 
+	if ((bus < pc->pc_bus) || (bus > sc->sc_ranges[pc->pc_bus]))
+		return;
+
 	devfn = PCI_DEVFN(dev, func);
 
 	if (bus == 0) {



CVS commit: src/sys/arch/macppc/pci

2018-03-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Mar 22 21:30:34 UTC 2018

Modified Files:
src/sys/arch/macppc/pci: uninorth.c

Log Message:
more oea_mapiodev()


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/macppc/pci/uninorth.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/pci/uninorth.c
diff -u src/sys/arch/macppc/pci/uninorth.c:1.19 src/sys/arch/macppc/pci/uninorth.c:1.20
--- src/sys/arch/macppc/pci/uninorth.c:1.19	Fri Mar 16 22:15:07 2018
+++ src/sys/arch/macppc/pci/uninorth.c	Thu Mar 22 21:30:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: uninorth.c,v 1.19 2018/03/16 22:15:07 macallan Exp $	*/
+/*	$NetBSD: uninorth.c,v 1.20 2018/03/22 21:30:34 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uninorth.c,v 1.19 2018/03/16 22:15:07 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uninorth.c,v 1.20 2018/03/22 21:30:34 macallan Exp $");
 
 #include 
 #include 
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: uninorth.c,v
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -161,13 +162,13 @@ uninorth_attach(device_t parent, device_
 	pc->pc_memt = >sc_memt;
 
 	if (ver < 3) {
-		pc->pc_addr = mapiodev(reg[0] + 0x80, 4, false);
-		pc->pc_data = mapiodev(reg[0] + 0xc0, 8, false);
+		pc->pc_addr = oea_mapiodev(reg[0] + 0x80, 4);
+		pc->pc_data = oea_mapiodev(reg[0] + 0xc0, 8);
 		pc->pc_conf_read = uninorth_conf_read;
 		pc->pc_conf_write = uninorth_conf_write;
 	} else {
-		pc->pc_addr = mapiodev(reg[1] + 0x80, 4, false);
-		pc->pc_data = mapiodev(reg[1] + 0xc0, 8, false);
+		pc->pc_addr = oea_mapiodev(reg[1] + 0x80, 4);
+		pc->pc_data = oea_mapiodev(reg[1] + 0xc0, 8);
 		pc->pc_conf_read = uninorth_conf_read_v3;
 		pc->pc_conf_write = uninorth_conf_write_v3;
 	}



CVS commit: src/sys/arch/macppc/pci

2016-07-08 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jul  8 22:21:52 UTC 2016

Modified Files:
src/sys/arch/macppc/pci: bandit.c

Log Message:
first step to make genfb work with /chaos/control - don't do config space
writes on /chaos.
tested by jak


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/macppc/pci/bandit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/pci/bandit.c
diff -u src/sys/arch/macppc/pci/bandit.c:1.31 src/sys/arch/macppc/pci/bandit.c:1.32
--- src/sys/arch/macppc/pci/bandit.c:1.31	Fri Oct  2 05:22:51 2015
+++ src/sys/arch/macppc/pci/bandit.c	Fri Jul  8 22:21:52 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bandit.c,v 1.31 2015/10/02 05:22:51 msaitoh Exp $	*/
+/*	$NetBSD: bandit.c,v 1.32 2016/07/08 22:21:52 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bandit.c,v 1.31 2015/10/02 05:22:51 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bandit.c,v 1.32 2016/07/08 22:21:52 macallan Exp $");
 
 #include 
 #include 
@@ -46,6 +46,7 @@ struct bandit_softc {
 	struct genppc_pci_chipset sc_pc;
 	struct powerpc_bus_space sc_iot;
 	struct powerpc_bus_space sc_memt;
+	boolean_t sc_is_chaos;
 };
 
 static void bandit_attach(device_t, device_t, void *);
@@ -53,6 +54,7 @@ static int bandit_match(device_t, cfdata
 
 static pcireg_t bandit_conf_read(void *, pcitag_t, int);
 static void bandit_conf_write(void *, pcitag_t, int, pcireg_t);
+static void chaos_conf_write(void *, pcitag_t, int, pcireg_t);
 
 static void bandit_init(struct bandit_softc *);
 
@@ -89,6 +91,8 @@ bandit_attach(device_t parent, device_t 
 	aprint_normal("\n");
 	sc->sc_dev = self;
 
+	sc->sc_is_chaos = (strcmp(ca->ca_name, "chaos") == 0);
+
 	/* Bandit address */
 	if (OF_getprop(node, "reg", reg, sizeof(reg)) < 8)
 		return;
@@ -131,7 +135,10 @@ bandit_attach(device_t parent, device_t 
 	pc->pc_data = mapiodev(reg[0] + 0xc0, 8, false);
 	pc->pc_bus = busrange[0];
 	pc->pc_conf_read = bandit_conf_read;
-	pc->pc_conf_write = bandit_conf_write;
+	if (sc->sc_is_chaos) {
+		pc->pc_conf_write = chaos_conf_write;
+	} else
+		pc->pc_conf_write = bandit_conf_write;
 
 	bandit_init(sc);
 
@@ -225,6 +232,15 @@ bandit_conf_write(void *cookie, pcitag_t
 	splx(s);
 }
 
+/*
+ * XXX
+ * /chaos really hates writes to config space, so we just don't do them
+ */
+static void
+chaos_conf_write(void *cookie, pcitag_t tag, int reg, pcireg_t data)
+{
+}
+
 #define	PCI_BANDIT		11
 
 #define	PCI_REG_MODE_SELECT	0x50



CVS commit: src/sys/arch/macppc/pci

2013-05-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed May  1 14:24:49 UTC 2013

Modified Files:
src/sys/arch/macppc/pci: uninorth.c

Log Message:
add G5 support
from Phileas Fogg


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/macppc/pci/uninorth.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/pci/uninorth.c
diff -u src/sys/arch/macppc/pci/uninorth.c:1.16 src/sys/arch/macppc/pci/uninorth.c:1.17
--- src/sys/arch/macppc/pci/uninorth.c:1.16	Wed Oct 26 04:56:23 2011
+++ src/sys/arch/macppc/pci/uninorth.c	Wed May  1 14:24:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: uninorth.c,v 1.16 2011/10/26 04:56:23 macallan Exp $	*/
+/*	$NetBSD: uninorth.c,v 1.17 2013/05/01 14:24:48 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uninorth.c,v 1.16 2011/10/26 04:56:23 macallan Exp $);
+__KERNEL_RCSID(0, $NetBSD: uninorth.c,v 1.17 2013/05/01 14:24:48 macallan Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -52,6 +52,8 @@ static int uninorth_match(device_t, cfda
 
 static pcireg_t uninorth_conf_read(void *, pcitag_t, int);
 static void uninorth_conf_write(void *, pcitag_t, int, pcireg_t);
+static pcireg_t uninorth_conf_read_v3(void *, pcitag_t, int);
+static void uninorth_conf_write_v3(void *, pcitag_t, int, pcireg_t);
 
 CFATTACH_DECL_NEW(uninorth, sizeof(struct uninorth_softc),
 uninorth_match, uninorth_attach, NULL, NULL);
@@ -67,7 +69,9 @@ uninorth_match(device_t parent, cfdata_t
 
 	memset(compat, 0, sizeof(compat));
 	OF_getprop(ca-ca_node, compatible, compat, sizeof(compat));
-	if (strcmp(compat, uni-north) != 0)
+	if (strcmp(compat, uni-north) != 0 
+	strcmp(compat, u3-agp) != 0 
+	strcmp(compat, u4-pcie) != 0)
 		return 0;
 
 	return 1;
@@ -82,6 +86,8 @@ uninorth_attach(device_t parent, device_
 	struct pcibus_attach_args pba;
 	int len, child, node = ca-ca_node;
 	uint32_t reg[2], busrange[2];
+	char compat[32];
+	int ver;
 	struct ranges {
 		uint32_t pci_hi, pci_mid, pci_lo;
 		uint32_t host;
@@ -91,6 +97,15 @@ uninorth_attach(device_t parent, device_
 	printf(\n);
 	sc-sc_dev = self;
 
+	memset(compat, 0, sizeof(compat));
+	OF_getprop(ca-ca_node, compatible, compat, sizeof(compat));
+	if (strcmp(compat, u3-agp) == 0)
+		ver = 3;
+	else if (strcmp(compat, u4-pcie) == 0)
+		ver = 4;
+	else
+		ver = 0;
+
 	/* UniNorth address */
 	if (OF_getprop(node, reg, reg, sizeof(reg))  8)
 		return;
@@ -99,6 +114,8 @@ uninorth_attach(device_t parent, device_
 	if (OF_getprop(node, bus-range, busrange, sizeof(busrange)) != 8)
 		return;
 
+	memset(sc-sc_iot, 0, sizeof(sc-sc_iot));
+
 	/* find i/o tag */
 	len = OF_getprop(node, ranges, ranges, sizeof(ranges));
 	if (len == -1)
@@ -117,7 +134,6 @@ uninorth_attach(device_t parent, device_
 	/* XXX enable gmac ethernet */
 	for (child = OF_child(node); child; child = OF_peer(child)) {
 		volatile int *gmac_gbclock_en = (void *)0xf820;
-		char compat[32];
 
 		memset(compat, 0, sizeof(compat));
 		OF_getprop(child, compatible, compat, sizeof(compat));
@@ -131,6 +147,7 @@ uninorth_attach(device_t parent, device_
 	uninorth io-space) != 0)
 		panic(Can't init uninorth io tag);
 
+	memset(sc-sc_memt, 0, sizeof(sc-sc_memt));
 	sc-sc_memt.pbs_flags = _BUS_SPACE_LITTLE_ENDIAN|_BUS_SPACE_MEM_TYPE;
 	sc-sc_memt.pbs_base = 0x;
 	if (ofwoea_map_space(RANGE_TYPE_PCI, RANGE_MEM, node, sc-sc_memt,
@@ -139,14 +156,22 @@ uninorth_attach(device_t parent, device_
 
 	macppc_pci_get_chipset_tag(pc);
 	pc-pc_node = node;
-	pc-pc_addr = mapiodev(reg[0] + 0x80, 4, false);
-	pc-pc_data = mapiodev(reg[0] + 0xc0, 8, false);
 	pc-pc_bus = busrange[0];
-	pc-pc_conf_read = uninorth_conf_read;
-	pc-pc_conf_write = uninorth_conf_write;
 	pc-pc_iot = sc-sc_iot;
 	pc-pc_memt = sc-sc_memt;
 
+	if (ver  3) {
+		pc-pc_addr = mapiodev(reg[0] + 0x80, 4, false);
+		pc-pc_data = mapiodev(reg[0] + 0xc0, 8, false);
+		pc-pc_conf_read = uninorth_conf_read;
+		pc-pc_conf_write = uninorth_conf_write;
+	} else {
+		pc-pc_addr = mapiodev(reg[1] + 0x80, 4, false);
+		pc-pc_data = mapiodev(reg[1] + 0xc0, 8, false);
+		pc-pc_conf_read = uninorth_conf_read_v3;
+		pc-pc_conf_write = uninorth_conf_write_v3;
+	}
+
 	memset(pba, 0, sizeof(pba));
 	pba.pba_memt = pc-pc_memt;
 	pba.pba_iot = pc-pc_iot;
@@ -237,3 +262,65 @@ uninorth_conf_write(void *cookie, pcitag
 
 	splx(s);
 }
+
+static pcireg_t
+uninorth_conf_read_v3(void *cookie, pcitag_t tag, int reg)
+{
+	pci_chipset_tag_t pc = cookie;
+	int32_t *daddr = pc-pc_data;
+	pcireg_t data;
+	int bus, dev, func, s;
+	uint32_t x;
+
+	/* UniNorth seems to have a 64bit data port */
+	if (reg  0x04)
+		daddr++;
+
+	pci_decompose_tag(pc, tag, bus, dev, func);
+
+	x = (bus  16) | (dev  11) | (func  8) | (reg  0xfc) | 1;
+	/* Set extended register bits */
+	x |= (reg  8)  

CVS commit: src/sys/arch/macppc/pci

2013-04-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Apr 30 10:16:26 UTC 2013

Modified Files:
src/sys/arch/macppc/pci: u3.c

Log Message:
zero sc_iot and sc_memt before using them
from Phileas Fogg
while there, set sc_dev properly


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/macppc/pci/u3.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/pci/u3.c
diff -u src/sys/arch/macppc/pci/u3.c:1.6 src/sys/arch/macppc/pci/u3.c:1.7
--- src/sys/arch/macppc/pci/u3.c:1.6	Sat Oct 27 17:18:01 2012
+++ src/sys/arch/macppc/pci/u3.c	Tue Apr 30 10:16:25 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: u3.c,v 1.6 2012/10/27 17:18:01 chs Exp $ */
+/* $NetBSD: u3.c,v 1.7 2013/04/30 10:16:25 macallan Exp $ */
 
 /*
  * Copyright 2006 Kyma Systems LLC.
@@ -50,6 +50,7 @@
 
 struct ibmcpc_softc
 {
+	device_t sc_dev;
 	struct genppc_pci_chipset sc_pc[8];
 	struct powerpc_bus_space sc_iot;
 	struct powerpc_bus_space sc_memt;
@@ -97,6 +98,7 @@ ibmcpc_attach(device_t parent, device_t 
 	char name[32];
 
 	aprint_normal(\n);
+	sc-sc_dev = self;
 
 	/* u3 address */
 	if (OF_getprop(node, reg, reg, sizeof(reg))  24) {
@@ -120,6 +122,7 @@ ibmcpc_attach(device_t parent, device_t 
 		if (OF_getprop(child, bus-range, busrange, 8)  8)
 			continue;
 
+		memset(sc-sc_iot, 0, sizeof(sc-sc_iot));
 		sc-sc_iot.pbs_flags = _BUS_SPACE_LITTLE_ENDIAN |
 		_BUS_SPACE_IO_TYPE;
 		sc-sc_iot.pbs_base = 0x;
@@ -127,6 +130,7 @@ ibmcpc_attach(device_t parent, device_t 
 		sc-sc_iot, ibmcpc io) != 0)
 			panic(Can't init ibmcpc io tag);
 
+		memset(sc-sc_memt, 0, sizeof(sc-sc_memt));
 		sc-sc_memt.pbs_flags = _BUS_SPACE_LITTLE_ENDIAN |
 		_BUS_SPACE_MEM_TYPE;
 		sc-sc_memt.pbs_base = 0x;



CVS commit: src/sys/arch/macppc/pci

2011-10-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Oct 26 04:56:23 UTC 2011

Modified Files:
src/sys/arch/macppc/pci: bandit.c grackle.c uninorth.c

Log Message:
actually split device and softc


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/macppc/pci/bandit.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/macppc/pci/grackle.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/macppc/pci/uninorth.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/macppc/pci/bandit.c
diff -u src/sys/arch/macppc/pci/bandit.c:1.29 src/sys/arch/macppc/pci/bandit.c:1.30
--- src/sys/arch/macppc/pci/bandit.c:1.29	Thu Jun 30 00:52:58 2011
+++ src/sys/arch/macppc/pci/bandit.c	Wed Oct 26 04:56:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bandit.c,v 1.29 2011/06/30 00:52:58 matt Exp $	*/
+/*	$NetBSD: bandit.c,v 1.30 2011/10/26 04:56:23 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: bandit.c,v 1.29 2011/06/30 00:52:58 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: bandit.c,v 1.30 2011/10/26 04:56:23 macallan Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, $NetBSD: bandit.c,v 1
 #include machine/pio.h
 
 struct bandit_softc {
-	struct device sc_dev;
+	device_t sc_dev;
 	struct genppc_pci_chipset sc_pc;
 	struct powerpc_bus_space sc_iot;
 	struct powerpc_bus_space sc_memt;
@@ -56,7 +56,7 @@ static void bandit_conf_write(void *, pc
 
 static void bandit_init(struct bandit_softc *);
 
-CFATTACH_DECL(bandit, sizeof(struct bandit_softc),
+CFATTACH_DECL_NEW(bandit, sizeof(struct bandit_softc),
 bandit_match, bandit_attach, NULL, NULL);
 
 static int
@@ -87,6 +87,7 @@ bandit_attach(device_t parent, device_t 
 	} ranges[6], *rp = ranges;
 
 	aprint_normal(\n);
+	sc-sc_dev = self;
 
 	/* Bandit address */
 	if (OF_getprop(node, reg, reg, sizeof(reg))  8)

Index: src/sys/arch/macppc/pci/grackle.c
diff -u src/sys/arch/macppc/pci/grackle.c:1.14 src/sys/arch/macppc/pci/grackle.c:1.15
--- src/sys/arch/macppc/pci/grackle.c:1.14	Thu Jun 30 00:52:58 2011
+++ src/sys/arch/macppc/pci/grackle.c	Wed Oct 26 04:56:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: grackle.c,v 1.14 2011/06/30 00:52:58 matt Exp $	*/
+/*	$NetBSD: grackle.c,v 1.15 2011/10/26 04:56:23 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: grackle.c,v 1.14 2011/06/30 00:52:58 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: grackle.c,v 1.15 2011/10/26 04:56:23 macallan Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, $NetBSD: grackle.c,v 
 #include machine/pio.h
 
 struct grackle_softc {
-	struct device sc_dev;
+	device_t sc_dev;
 	struct genppc_pci_chipset sc_pc;
 	struct powerpc_bus_space sc_iot;
 	struct powerpc_bus_space sc_memt;
@@ -53,7 +53,7 @@ static int grackle_match(device_t, cfdat
 static pcireg_t grackle_conf_read(void *, pcitag_t, int);
 static void grackle_conf_write(void *, pcitag_t, int, pcireg_t);
 
-CFATTACH_DECL(grackle, sizeof(struct grackle_softc),
+CFATTACH_DECL_NEW(grackle, sizeof(struct grackle_softc),
 grackle_match, grackle_attach, NULL, NULL);
 
 static int
@@ -92,6 +92,7 @@ grackle_attach(device_t parent, device_t
 	} ranges[6], *rp = ranges;
 
 	aprint_normal(\n);
+	sc-sc_dev = self;
 
 	/* PCI bus number */
 	if (OF_getprop(node, bus-range, busrange, sizeof(busrange)) != 8)

Index: src/sys/arch/macppc/pci/uninorth.c
diff -u src/sys/arch/macppc/pci/uninorth.c:1.15 src/sys/arch/macppc/pci/uninorth.c:1.16
--- src/sys/arch/macppc/pci/uninorth.c:1.15	Thu Jun 30 00:52:58 2011
+++ src/sys/arch/macppc/pci/uninorth.c	Wed Oct 26 04:56:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: uninorth.c,v 1.15 2011/06/30 00:52:58 matt Exp $	*/
+/*	$NetBSD: uninorth.c,v 1.16 2011/10/26 04:56:23 macallan Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: uninorth.c,v 1.15 2011/06/30 00:52:58 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: uninorth.c,v 1.16 2011/10/26 04:56:23 macallan Exp $);
 
 #include sys/param.h
 #include sys/device.h
@@ -41,7 +41,7 @@ __KERNEL_RCSID(0, $NetBSD: uninorth.c,v
 #include machine/pio.h
 
 struct uninorth_softc {
-	struct device sc_dev;
+	device_t sc_dev;
 	struct genppc_pci_chipset sc_pc;
 	struct powerpc_bus_space sc_iot;
 	struct powerpc_bus_space sc_memt;
@@ -53,7 +53,7 @@ static int uninorth_match(device_t, cfda
 static pcireg_t uninorth_conf_read(void *, pcitag_t, int);
 static void uninorth_conf_write(void *, pcitag_t, int, pcireg_t);
 
-CFATTACH_DECL(uninorth, sizeof(struct uninorth_softc),
+CFATTACH_DECL_NEW(uninorth, sizeof(struct uninorth_softc),
 uninorth_match, uninorth_attach, NULL, NULL);
 
 static int
@@ -89,6 +89,7 @@