2 * Copyright 2006-2007 by Juniper Networks.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <sys/sockio.h>
37 #include <sys/malloc.h>
38 #include <sys/kernel.h>
39 #include <sys/module.h>
40 #include <sys/socket.h>
41 #include <sys/queue.h>
44 #include <sys/endian.h>
49 #include <dev/pci/pcivar.h>
50 #include <dev/pci/pcireg.h>
51 #include <dev/pci/pcib_private.h>
55 #include <machine/resource.h>
56 #include <machine/bus.h>
57 #include <machine/ocpbus.h>
58 #include <machine/spr.h>
60 #include <powerpc/mpc85xx/ocpbus.h>
62 #define REG_CFG_ADDR 0x0000
63 #define CONFIG_ACCESS_ENABLE 0x80000000
65 #define REG_CFG_DATA 0x0004
66 #define REG_INT_ACK 0x0008
68 #define REG_POTAR(n) (0x0c00 + 0x20 * (n))
69 #define REG_POTEAR(n) (0x0c04 + 0x20 * (n))
70 #define REG_POWBAR(n) (0x0c08 + 0x20 * (n))
71 #define REG_POWAR(n) (0x0c10 + 0x20 * (n))
73 #define REG_PITAR(n) (0x0e00 - 0x20 * (n))
74 #define REG_PIWBAR(n) (0x0e08 - 0x20 * (n))
75 #define REG_PIWBEAR(n) (0x0e0c - 0x20 * (n))
76 #define REG_PIWAR(n) (0x0e10 - 0x20 * (n))
78 struct pci_ocp_softc {
82 bus_addr_t sc_iomem_va; /* Virtual mapping. */
83 bus_addr_t sc_iomem_alloc; /* Next allocation. */
84 struct rman sc_ioport;
85 bus_addr_t sc_ioport_va; /* Virtual mapping. */
86 bus_addr_t sc_ioport_alloc; /* Next allocation. */
88 struct resource *sc_res;
89 bus_space_handle_t sc_bsh;
90 bus_space_tag_t sc_bst;
97 static int pci_ocp_attach(device_t);
98 static int pci_ocp_probe(device_t);
100 static struct resource *pci_ocp_alloc_resource(device_t, device_t, int, int *,
101 u_long, u_long, u_long, u_int);
102 static int pci_ocp_read_ivar(device_t, device_t, int, uintptr_t *);
103 static int pci_ocp_release_resource(device_t, device_t, int, int,
105 static int pci_ocp_write_ivar(device_t, device_t, int, uintptr_t);
107 static int pci_ocp_maxslots(device_t);
108 static uint32_t pci_ocp_read_config(device_t, u_int, u_int, u_int, u_int, int);
109 static void pci_ocp_write_config(device_t, u_int, u_int, u_int, u_int,
113 * Bus interface definitions.
115 static device_method_t pci_ocp_methods[] = {
116 /* Device interface */
117 DEVMETHOD(device_probe, pci_ocp_probe),
118 DEVMETHOD(device_attach, pci_ocp_attach),
121 DEVMETHOD(bus_print_child, bus_generic_print_child),
122 DEVMETHOD(bus_read_ivar, pci_ocp_read_ivar),
123 DEVMETHOD(bus_write_ivar, pci_ocp_write_ivar),
124 DEVMETHOD(bus_alloc_resource, pci_ocp_alloc_resource),
125 DEVMETHOD(bus_release_resource, pci_ocp_release_resource),
126 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
127 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
128 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
129 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
132 DEVMETHOD(pcib_maxslots, pci_ocp_maxslots),
133 DEVMETHOD(pcib_read_config, pci_ocp_read_config),
134 DEVMETHOD(pcib_write_config, pci_ocp_write_config),
135 DEVMETHOD(pcib_route_interrupt, pcib_route_interrupt),
140 static driver_t pci_ocp_driver = {
143 sizeof(struct pci_ocp_softc),
146 devclass_t pcib_devclass;
148 DRIVER_MODULE(pcib, ocpbus, pci_ocp_driver, pcib_devclass, 0, 0);
151 pci_ocp_cfgread(struct pci_ocp_softc *sc, u_int bus, u_int slot, u_int func,
152 u_int reg, int bytes)
156 if (bus == sc->sc_busnr)
159 addr = CONFIG_ACCESS_ENABLE;
160 addr |= (bus & 0xff) << 16;
161 addr |= (slot & 0x1f) << 11;
162 addr |= (func & 0x7) << 8;
165 addr |= (reg & 0xf00) << 16;
166 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_CFG_ADDR, addr);
170 data = bus_space_read_1(sc->sc_bst, sc->sc_bsh,
171 REG_CFG_DATA + (reg & 3));
174 data = le16toh(bus_space_read_2(sc->sc_bst, sc->sc_bsh,
175 REG_CFG_DATA + (reg & 2)));
178 data = le32toh(bus_space_read_4(sc->sc_bst, sc->sc_bsh,
189 pci_ocp_cfgwrite(struct pci_ocp_softc *sc, u_int bus, u_int slot, u_int func,
190 u_int reg, uint32_t data, int bytes)
194 if (bus == sc->sc_busnr)
197 addr = CONFIG_ACCESS_ENABLE;
198 addr |= (bus & 0xff) << 16;
199 addr |= (slot & 0x1f) << 11;
200 addr |= (func & 0x7) << 8;
203 addr |= (reg & 0xf00) << 16;
204 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_CFG_ADDR, addr);
208 bus_space_write_1(sc->sc_bst, sc->sc_bsh,
209 REG_CFG_DATA + (reg & 3), data);
212 bus_space_write_2(sc->sc_bst, sc->sc_bsh,
213 REG_CFG_DATA + (reg & 2), htole16(data));
216 bus_space_write_4(sc->sc_bst, sc->sc_bsh,
217 REG_CFG_DATA, htole32(data));
224 dump(struct pci_ocp_softc *sc)
228 #define RD(o) bus_space_read_4(sc->sc_bst, sc->sc_bsh, o)
229 for (i = 0; i < 5; i++) {
230 printf("POTAR%u =0x%08x\n", i, RD(REG_POTAR(i)));
231 printf("POTEAR%u =0x%08x\n", i, RD(REG_POTEAR(i)));
232 printf("POWBAR%u =0x%08x\n", i, RD(REG_POWBAR(i)));
233 printf("POWAR%u =0x%08x\n", i, RD(REG_POWAR(i)));
236 for (i = 1; i < 4; i++) {
237 printf("PITAR%u =0x%08x\n", i, RD(REG_PITAR(i)));
238 printf("PIWBAR%u =0x%08x\n", i, RD(REG_PIWBAR(i)));
239 printf("PIWBEAR%u=0x%08x\n", i, RD(REG_PIWBEAR(i)));
240 printf("PIWAR%u =0x%08x\n", i, RD(REG_PIWAR(i)));
245 for (i = 0; i < 0x48; i += 4) {
246 printf("cfg%02x=0x%08x\n", i, pci_ocp_cfgread(sc, 0, 0, 0,
253 pci_ocp_maxslots(device_t dev)
255 struct pci_ocp_softc *sc = device_get_softc(dev);
257 return ((sc->sc_pcie) ? 0 : 30);
261 pci_ocp_read_config(device_t dev, u_int bus, u_int slot, u_int func,
262 u_int reg, int bytes)
264 struct pci_ocp_softc *sc = device_get_softc(dev);
266 if (bus == sc->sc_busnr && !sc->sc_pcie && slot < 10)
268 return (pci_ocp_cfgread(sc, bus, slot, func, reg, bytes));
272 pci_ocp_write_config(device_t dev, u_int bus, u_int slot, u_int func,
273 u_int reg, uint32_t val, int bytes)
275 struct pci_ocp_softc *sc = device_get_softc(dev);
277 if (bus == sc->sc_busnr && !sc->sc_pcie && slot < 10)
279 pci_ocp_cfgwrite(sc, bus, slot, func, reg, val, bytes);
283 pci_ocp_probe(device_t dev)
286 struct pci_ocp_softc *sc;
287 const char *mpcid, *type;
294 parent = device_get_parent(dev);
295 error = BUS_READ_IVAR(parent, dev, OCPBUS_IVAR_DEVTYPE, &devtype);
298 if (devtype != OCPBUS_DEVTYPE_PCIB)
301 sc = device_get_softc(dev);
304 sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rid,
306 if (sc->sc_res == NULL)
309 sc->sc_bst = rman_get_bustag(sc->sc_res);
310 sc->sc_bsh = rman_get_bushandle(sc->sc_res);
314 cfgreg = pci_ocp_cfgread(sc, 0, 0, 0, PCIR_VENDOR, 2);
315 if (cfgreg != 0x1057 && cfgreg != 0x1957)
317 cfgreg = pci_ocp_cfgread(sc, 0, 0, 0, PCIR_DEVICE, 2);
329 * Documentation from Freescale is incorrect.
330 * Use right values after documentation is corrected.
346 cfgreg = pci_ocp_cfgread(sc, 0, 0, 0, PCIR_CAP_PTR, 1);
347 while (cfgreg != 0) {
348 cfgreg = pci_ocp_cfgread(sc, 0, 0, 0, cfgreg, 2);
349 switch (cfgreg & 0xff) {
350 case PCIY_PCIX: /* PCI-X */
353 case PCIY_EXPRESS: /* PCI Express */
354 type = "PCI Express";
358 cfgreg = (cfgreg >> 8) & 0xff;
361 error = bus_get_resource(dev, SYS_RES_MEMORY, 1, &start, &size);
362 if (error || start == 0 || size == 0)
365 snprintf(buf, sizeof(buf),
366 "Freescale MPC%s %s host controller", mpcid, type);
367 device_set_desc_copy(dev, buf);
368 error = BUS_PROBE_DEFAULT;
371 bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rid, sc->sc_res);
376 pci_ocp_init_bar(struct pci_ocp_softc *sc, int bus, int slot, int func,
380 uint32_t addr, mask, size;
383 reg = PCIR_BAR(barno);
384 pci_ocp_write_config(sc->sc_dev, bus, slot, func, reg, ~0, 4);
385 size = pci_ocp_read_config(sc->sc_dev, bus, slot, func, reg, 4);
388 width = ((size & 7) == 4) ? 2 : 1;
390 if (size & 1) { /* I/O port */
391 allocp = &sc->sc_ioport_alloc;
393 if ((size & 0xffff0000) == 0)
395 } else { /* memory */
396 allocp = &sc->sc_iomem_alloc;
401 /* Sanity check (must be a power of 2). */
405 addr = (*allocp + mask) & ~mask;
406 *allocp = addr + size;
409 printf("PCI %u:%u:%u:%u: reg %x: size=%08x: addr=%08x\n",
410 device_get_unit(sc->sc_dev), bus, slot, func, reg,
413 pci_ocp_write_config(sc->sc_dev, bus, slot, func, reg, addr, 4);
415 pci_ocp_write_config(sc->sc_dev, bus, slot, func, reg + 4,
421 pci_ocp_route_int(struct pci_ocp_softc *sc, u_int bus, u_int slot, u_int func,
427 * Default interrupt routing.
430 intline = intpin - 1;
431 intline += (bus != sc->sc_busnr) ? slot : 0;
432 intline = PIC_IRQ_EXT(intline & 3);
437 printf("PCI %u:%u:%u:%u: intpin %u: intline=%u\n",
438 device_get_unit(sc->sc_dev), bus, slot, func,
445 pci_ocp_init(struct pci_ocp_softc *sc, int bus, int maxslot)
450 uint16_t vendor, device;
451 uint8_t cr8, command, hdrtype, class, subclass;
452 uint8_t intline, intpin;
455 for (slot = 0; slot < maxslot; slot++) {
457 for (func = 0; func <= maxfunc; func++) {
458 hdrtype = pci_ocp_read_config(sc->sc_dev, bus, slot,
459 func, PCIR_HDRTYPE, 1);
460 if ((hdrtype & PCIM_HDRTYPE) > PCI_MAXHDRTYPE)
463 if (func == 0 && (hdrtype & PCIM_MFDEV))
464 maxfunc = PCI_FUNCMAX;
466 command = pci_ocp_read_config(sc->sc_dev, bus, slot,
467 func, PCIR_COMMAND, 1);
468 command &= ~(PCIM_CMD_MEMEN | PCIM_CMD_PORTEN);
469 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
470 PCIR_COMMAND, command, 1);
472 vendor = pci_ocp_read_config(sc->sc_dev, bus, slot,
473 func, PCIR_VENDOR, 2);
474 device = pci_ocp_read_config(sc->sc_dev, bus, slot,
475 func, PCIR_DEVICE, 2);
478 * Make sure the ATA controller on the VIA82C686
479 * South bridge is enabled.
481 if (vendor == 0x1106 && device == 0x0686) {
482 /* Enable the ATA controller. */
483 cr8 = pci_ocp_read_config(sc->sc_dev, bus,
484 slot, func, 0x48, 1);
486 device_printf(sc->sc_dev,
487 "enabling ATA controller\n");
488 pci_ocp_write_config(sc->sc_dev, bus,
489 slot, func, 0x48, cr8 & ~2, 1);
492 if (vendor == 0x1106 && device == 0x0571) {
493 pci_ocp_write_config(sc->sc_dev, bus, slot,
494 func, 0xc4, 0x00, 1);
495 /* Set legacy mode. */
496 pci_ocp_write_config(sc->sc_dev, bus, slot,
497 func, 0x40, 0x08, 1);
498 pci_ocp_write_config(sc->sc_dev, bus, slot,
499 func, PCIR_PROGIF, 0x00, 1);
500 pci_ocp_write_config(sc->sc_dev, bus, slot,
501 func, 0x42, 0x09, 1);
502 pci_ocp_write_config(sc->sc_dev, bus, slot,
503 func, 0x40, 0x0b, 1);
506 /* Program the base address registers. */
507 maxbar = (hdrtype & PCIM_HDRTYPE) ? 1 : 6;
510 bar += pci_ocp_init_bar(sc, bus, slot, func,
513 /* Perform interrupt routing. */
514 intpin = pci_ocp_read_config(sc->sc_dev, bus, slot,
515 func, PCIR_INTPIN, 1);
516 intline = pci_ocp_route_int(sc, bus, slot, func,
518 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
519 PCIR_INTLINE, intline, 1);
521 command |= PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN |
523 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
524 PCIR_COMMAND, command, 1);
527 * Handle PCI-PCI bridges
529 class = pci_ocp_read_config(sc->sc_dev, bus, slot,
530 func, PCIR_CLASS, 1);
531 if (class != PCIC_BRIDGE)
533 subclass = pci_ocp_read_config(sc->sc_dev, bus, slot,
534 func, PCIR_SUBCLASS, 1);
535 if (subclass != PCIS_BRIDGE_PCI)
540 /* Program I/O decoder. */
541 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
542 PCIR_IOBASEL_1, sc->sc_ioport.rm_start >> 8, 1);
543 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
544 PCIR_IOLIMITL_1, sc->sc_ioport.rm_end >> 8, 1);
545 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
546 PCIR_IOBASEH_1, sc->sc_ioport.rm_start >> 16, 2);
547 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
548 PCIR_IOLIMITH_1, sc->sc_ioport.rm_end >> 16, 2);
550 /* Program (non-prefetchable) memory decoder. */
551 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
552 PCIR_MEMBASE_1, sc->sc_iomem.rm_start >> 16, 2);
553 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
554 PCIR_MEMLIMIT_1, sc->sc_iomem.rm_end >> 16, 2);
556 /* Program prefetchable memory decoder. */
557 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
558 PCIR_PMBASEL_1, 0x0010, 2);
559 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
560 PCIR_PMLIMITL_1, 0x000f, 2);
561 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
562 PCIR_PMBASEH_1, 0x00000000, 4);
563 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
564 PCIR_PMLIMITH_1, 0x00000000, 4);
566 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
567 PCIR_PRIBUS_1, bus, 1);
568 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
569 PCIR_SECBUS_1, secbus, 1);
570 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
571 PCIR_SUBBUS_1, 0xff, 1);
573 secbus = pci_ocp_init(sc, secbus,
574 (subclass == PCIS_BRIDGE_PCI) ? 31 : 1);
576 pci_ocp_write_config(sc->sc_dev, bus, slot, func,
577 PCIR_SUBBUS_1, secbus, 1);
585 pci_ocp_inbound(struct pci_ocp_softc *sc, int wnd, int tgt, u_long start,
586 u_long size, u_long pci_start)
588 uint32_t attr, bar, tar;
590 KASSERT(wnd > 0, ("%s: inbound window 0 is invalid", __func__));
593 case OCP85XX_TGTIF_RAM1:
594 attr = 0xa0f55000 | (ffsl(size) - 2);
601 bar = pci_start >> 12;
603 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_PITAR(wnd), tar);
604 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_PIWBEAR(wnd), 0);
605 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_PIWBAR(wnd), bar);
606 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_PIWAR(wnd), attr);
610 pci_ocp_outbound(struct pci_ocp_softc *sc, int wnd, int res, u_long start,
611 u_long size, u_long pci_start)
613 uint32_t attr, bar, tar;
617 attr = 0x80044000 | (ffsl(size) - 2);
620 attr = 0x80088000 | (ffsl(size) - 2);
627 tar = pci_start >> 12;
629 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_POTAR(wnd), tar);
630 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_POTEAR(wnd), 0);
631 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_POWBAR(wnd), bar);
632 bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_POWAR(wnd), attr);
636 pci_ocp_iorange(struct pci_ocp_softc *sc, int type, int wnd)
639 u_long start, end, size, alloc;
640 bus_addr_t pci_start, pci_end;
641 bus_addr_t *vap, *allocp;
644 error = bus_get_resource(sc->sc_dev, type, 1, &start, &size);
648 end = start + size - 1;
656 vap = &sc->sc_ioport_va;
657 allocp = &sc->sc_ioport_alloc;
664 vap = &sc->sc_iomem_va;
665 allocp = &sc->sc_iomem_alloc;
671 rm->rm_type = RMAN_ARRAY;
672 rm->rm_start = pci_start;
673 rm->rm_end = pci_end;
674 error = rman_init(rm);
678 error = rman_manage_region(rm, pci_start, pci_end);
684 *allocp = pci_start + alloc;
685 *vap = (uintptr_t)pmap_mapdev(start, size);
687 pci_ocp_outbound(sc, wnd, type, start, size, pci_start);
692 pci_ocp_attach(device_t dev)
694 struct pci_ocp_softc *sc;
698 sc = device_get_softc(dev);
702 sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rid,
704 if (sc->sc_res == NULL) {
705 device_printf(dev, "could not map I/O memory\n");
708 sc->sc_bst = rman_get_bustag(sc->sc_res);
709 sc->sc_bsh = rman_get_bushandle(sc->sc_res);
711 cfgreg = pci_ocp_cfgread(sc, 0, 0, 0, PCIR_COMMAND, 2);
712 cfgreg |= PCIM_CMD_SERRESPEN | PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN |
714 pci_ocp_cfgwrite(sc, 0, 0, 0, PCIR_COMMAND, cfgreg, 2);
716 pci_ocp_outbound(sc, 0, -1, 0, 0, 0);
717 error = pci_ocp_iorange(sc, SYS_RES_MEMORY, 1);
718 error = pci_ocp_iorange(sc, SYS_RES_IOPORT, 2);
719 pci_ocp_outbound(sc, 3, -1, 0, 0, 0);
720 pci_ocp_outbound(sc, 4, -1, 0, 0, 0);
722 pci_ocp_inbound(sc, 1, -1, 0, 0, 0);
723 pci_ocp_inbound(sc, 2, -1, 0, 0, 0);
724 pci_ocp_inbound(sc, 3, OCP85XX_TGTIF_RAM1, 0, 2U*1024U*1024U*1024U, 0);
726 maxslot = (sc->sc_pcie) ? 1 : 31;
727 pci_ocp_init(sc, sc->sc_busnr, maxslot);
729 device_add_child(dev, "pci", -1);
730 return (bus_generic_attach(dev));
733 static struct resource *
734 pci_ocp_alloc_resource(device_t dev, device_t child, int type, int *rid,
735 u_long start, u_long end, u_long count, u_int flags)
737 struct pci_ocp_softc *sc = device_get_softc(dev);
739 struct resource *res;
745 va = sc->sc_ioport_va;
749 va = sc->sc_iomem_va;
752 /* ISA interrupts are routed to IRQ 0 on the PIC. */
753 if (start < PIC_IRQ_START) {
754 device_printf(dev, "%s requested ISA interrupt %lu\n",
755 device_get_nameunit(child), start);
757 start = PIC_IRQ_EXT(0);
759 return (BUS_ALLOC_RESOURCE(device_get_parent(dev), child,
760 type, rid, start, end, count, flags));
765 res = rman_reserve_resource(rm, start, end, count, flags, child);
769 rman_set_bustag(res, &bs_le_tag);
770 rman_set_bushandle(res, va + rman_get_start(res) - rm->rm_start);
775 pci_ocp_release_resource(device_t dev, device_t child, int type, int rid,
776 struct resource *res)
779 return (rman_release_resource(res));
783 pci_ocp_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
785 struct pci_ocp_softc *sc = device_get_softc(dev);
789 *result = sc->sc_busnr;
791 case PCIB_IVAR_DOMAIN:
792 *result = device_get_unit(dev);
799 pci_ocp_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
801 struct pci_ocp_softc *sc = device_get_softc(dev);
805 sc->sc_busnr = value;