- device/softc split
This commit is contained in:
parent
e367a2e837
commit
0d1213e55a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rbus_ppb.c,v 1.24 2008/07/09 16:27:12 joerg Exp $ */
|
||||
/* $NetBSD: rbus_ppb.c,v 1.25 2008/07/09 18:18:56 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||
@ -34,7 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rbus_ppb.c,v 1.24 2008/07/09 16:27:12 joerg Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rbus_ppb.c,v 1.25 2008/07/09 18:18:56 joerg Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -101,12 +101,12 @@ unsigned int rbus_round_up(unsigned int, unsigned int);
|
||||
|
||||
|
||||
struct ppb_cardbus_softc {
|
||||
struct device sc_dev;
|
||||
device_t sc_dev;
|
||||
pcitag_t sc_tag;
|
||||
int foo;
|
||||
};
|
||||
|
||||
CFATTACH_DECL(rbus_ppb, sizeof(struct ppb_cardbus_softc),
|
||||
CFATTACH_DECL_NEW(rbus_ppb, sizeof(struct ppb_cardbus_softc),
|
||||
ppb_cardbus_match, ppb_cardbus_attach, ppb_cardbus_detach, ppb_activate);
|
||||
|
||||
#ifdef CBB_DEBUG
|
||||
@ -267,7 +267,7 @@ rbus_pci_addr_fixup(struct ppb_cardbus_softc *csc,
|
||||
bzero(rct.bussize_memreqs, size);
|
||||
|
||||
printf("%s: sizing buses %d-%d\n",
|
||||
device_xname(&rct.csc->sc_dev),
|
||||
device_xname(rct.csc->sc_dev),
|
||||
minbus, maxbus);
|
||||
|
||||
pci_device_foreach_min(pc, minbus, maxbus,
|
||||
@ -285,7 +285,7 @@ rbus_pci_addr_fixup(struct ppb_cardbus_softc *csc,
|
||||
if(pci_bus_parent[busnum] < minbus ||
|
||||
pci_bus_parent[busnum] >= maxbus) {
|
||||
printf("%s: bus %d has illegal parent %d\n",
|
||||
device_xname(&rct.csc->sc_dev),
|
||||
device_xname(rct.csc->sc_dev),
|
||||
busnum, pci_bus_parent[busnum]);
|
||||
continue;
|
||||
}
|
||||
@ -310,7 +310,7 @@ rbus_pci_addr_fixup(struct ppb_cardbus_softc *csc,
|
||||
rbus_round_up(rct.bussize_memreqs[minbus], 8);
|
||||
|
||||
printf("%s: total needs IO %08lx and MEM %08lx\n",
|
||||
device_xname(&rct.csc->sc_dev),
|
||||
device_xname(rct.csc->sc_dev),
|
||||
rct.bussize_ioreqs[minbus], rct.bussize_memreqs[minbus]);
|
||||
|
||||
if(!caa->ca_rbus_iot) {
|
||||
@ -345,7 +345,7 @@ rbus_pci_addr_fixup(struct ppb_cardbus_softc *csc,
|
||||
&start,
|
||||
&handle) != 0) {
|
||||
panic("%s: can not allocate %ld bytes in MEM bus %d",
|
||||
device_xname(&rct.csc->sc_dev),
|
||||
device_xname(rct.csc->sc_dev),
|
||||
rct.bussize_memreqs[minbus], minbus);
|
||||
}
|
||||
rct.membustags[minbus]=rbus_new(caa->ca_rbus_memt,
|
||||
@ -363,7 +363,7 @@ rbus_pci_addr_fixup(struct ppb_cardbus_softc *csc,
|
||||
busparent = pci_bus_parent[busnum];
|
||||
|
||||
printf("%s: bus %d (parent=%d) needs IO %08lx and MEM %08lx\n",
|
||||
device_xname(&rct.csc->sc_dev),
|
||||
device_xname(rct.csc->sc_dev),
|
||||
busnum,
|
||||
busparent,
|
||||
rct.bussize_ioreqs[busnum],
|
||||
@ -461,7 +461,7 @@ rbus_pci_addr_fixup(struct ppb_cardbus_softc *csc,
|
||||
}
|
||||
|
||||
printf("%s: configuring buses %d-%d\n",
|
||||
device_xname(&rct.csc->sc_dev),
|
||||
device_xname(rct.csc->sc_dev),
|
||||
minbus, maxbus);
|
||||
pci_device_foreach_min(pc, minbus, maxbus,
|
||||
rbus_pci_phys_allocate, &rct);
|
||||
@ -480,7 +480,7 @@ rbus_pci_phys_countspace(pc, tag, context)
|
||||
pci_decompose_tag(pc, tag, &bus, &device, &function);
|
||||
|
||||
printf("%s: configuring device %02x:%02x:%02x\n",
|
||||
device_xname(&rct->csc->sc_dev),
|
||||
device_xname(rct->csc->sc_dev),
|
||||
bus, device, function);
|
||||
|
||||
pciaddr_resource_manage(pc, tag,
|
||||
@ -505,7 +505,7 @@ rbus_do_phys_countspace(pc, tag, mapreg, ctx, type, addr, size)
|
||||
|
||||
if(size > (1<<24)) {
|
||||
printf("%s: skipping huge space request of size=%08x\n",
|
||||
device_xname(&rct->csc->sc_dev), (unsigned int)size);
|
||||
device_xname(rct->csc->sc_dev), (unsigned int)size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -533,7 +533,7 @@ rbus_pci_phys_allocate(pc, tag, context)
|
||||
pci_decompose_tag(pc, tag, &bus, &device, &function);
|
||||
|
||||
printf("%s: configuring device %02x:%02x:%02x\n",
|
||||
device_xname(&rct->csc->sc_dev),
|
||||
device_xname(rct->csc->sc_dev),
|
||||
bus, device, function);
|
||||
|
||||
pciaddr_resource_manage(pc, tag,
|
||||
@ -588,7 +588,7 @@ rbus_do_phys_allocate(pc, tag, mapreg, ctx, type, addr, size)
|
||||
|
||||
if(size > (1<<24)) {
|
||||
printf("%s: skipping huge space request of size=%08x\n",
|
||||
device_xname(&rct->csc->sc_dev), (unsigned int)size);
|
||||
device_xname(rct->csc->sc_dev), (unsigned int)size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -606,7 +606,7 @@ rbus_do_phys_allocate(pc, tag, mapreg, ctx, type, addr, size)
|
||||
mask, size, busflags|flags,
|
||||
addr, &handle)) {
|
||||
printf("%s: no available resources (size=%08x) for bar %2d. fixup failed\n",
|
||||
device_xname(&rct->csc->sc_dev), (unsigned int)size, mapreg);
|
||||
device_xname(rct->csc->sc_dev), (unsigned int)size, mapreg);
|
||||
|
||||
*addr = 0;
|
||||
pci_conf_write(pc, tag, mapreg, *addr);
|
||||
@ -614,7 +614,7 @@ rbus_do_phys_allocate(pc, tag, mapreg, ctx, type, addr, size)
|
||||
}
|
||||
|
||||
printf("%s: alloc %s space of size %08x for %02d:%02d:%02d -> %08x\n",
|
||||
device_xname(&rct->csc->sc_dev),
|
||||
device_xname(rct->csc->sc_dev),
|
||||
bustype,
|
||||
(unsigned int)size,
|
||||
bus, device, function, (unsigned int)*addr);
|
||||
@ -625,7 +625,7 @@ rbus_do_phys_allocate(pc, tag, mapreg, ctx, type, addr, size)
|
||||
/* check */
|
||||
{
|
||||
DPRINTF(("%s: pci_addr_fixup: ",
|
||||
device_xname(&rct->csc->sc_dev)));
|
||||
device_xname(rct->csc->sc_dev)));
|
||||
#ifdef CBB_DEBUG
|
||||
if(rbus_ppb_debug) { pciaddr_print_devid(pc, tag); }
|
||||
#endif
|
||||
@ -635,7 +635,7 @@ rbus_do_phys_allocate(pc, tag, mapreg, ctx, type, addr, size)
|
||||
if (pciaddr_ioaddr(pci_conf_read(pc, tag, mapreg)) != *addr) {
|
||||
pci_conf_write(pc, tag, mapreg, 0); /* clear */
|
||||
printf("%s: fixup failed. (new address=%#x)\n",
|
||||
device_xname(&rct->csc->sc_dev),
|
||||
device_xname(rct->csc->sc_dev),
|
||||
(unsigned)*addr);
|
||||
return (1);
|
||||
}
|
||||
@ -647,7 +647,7 @@ rbus_do_phys_allocate(pc, tag, mapreg, ctx, type, addr, size)
|
||||
}
|
||||
|
||||
static void
|
||||
ppb_cardbus_attach(device_t parent, device_t self, void aux)
|
||||
ppb_cardbus_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct ppb_cardbus_softc *csc = device_private(self);
|
||||
struct cardbus_softc *parent_sc = device_private(parent);
|
||||
@ -663,6 +663,8 @@ ppb_cardbus_attach(device_t parent, device_t self, void aux)
|
||||
u_int16_t pciirq;
|
||||
int minbus, maxbus;
|
||||
|
||||
csc->sc_dev = self;
|
||||
|
||||
mybus = ct->ct_bus;
|
||||
pciirq = 0;
|
||||
rv = 0;
|
||||
@ -798,8 +800,8 @@ int
|
||||
ppb_cardbus_enable(struct ppb_softc * sc)
|
||||
{
|
||||
#if 0
|
||||
struct ppb_cardbus_softc *csc = (struct fxp_cardbus_softc *) sc;
|
||||
struct cardbus_softc *psc = device_private(device_parent(&sc->sc_dev));
|
||||
struct ppb_cardbus_softc *csc = (struct ppb_cardbus_softc *) sc;
|
||||
struct cardbus_softc *psc = device_private(device_parent(sc->sc_dev));
|
||||
cardbus_chipset_tag_t cc = psc->sc_cc;
|
||||
cardbus_function_tag_t cf = psc->sc_cf;
|
||||
|
||||
@ -812,11 +814,11 @@ ppb_cardbus_enable(struct ppb_softc * sc)
|
||||
sc->sc_ih = cardbus_intr_establish(cc, cf, psc->sc_intrline, IPL_NET,
|
||||
fxp_intr, sc);
|
||||
if (NULL == sc->sc_ih) {
|
||||
aprint_error_dev(&sc->sc_dev, "couldn't establish interrupt\n");
|
||||
aprint_error_dev(sc->sc_dev, "couldn't establish interrupt\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("%s: interrupting at %d\n", device_xname(&sc->sc_dev),
|
||||
printf("%s: interrupting at %d\n", device_xname(sc->sc_dev),
|
||||
psc->sc_intrline);
|
||||
|
||||
#endif
|
||||
@ -827,7 +829,7 @@ void
|
||||
ppb_cardbus_disable(struct ppb_softc * sc)
|
||||
{
|
||||
#if 0
|
||||
struct cardbus_softc *psc = device_private(device_parent(&sc->sc_dev));
|
||||
struct cardbus_softc *psc = device_private(device_parent(sc->sc_dev));
|
||||
cardbus_chipset_tag_t cc = psc->sc_cc;
|
||||
cardbus_function_tag_t cf = psc->sc_cf;
|
||||
|
||||
@ -852,7 +854,7 @@ ppb_cardbus_detach(self, flags)
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (ct == NULL)
|
||||
panic("%s: data structure lacks", device_xname(&sc->sc_dev));
|
||||
panic("%s: data structure lacks", device_xname(sc->sc_dev));
|
||||
#endif
|
||||
|
||||
rv = fxp_detach(sc);
|
||||
|
Loading…
Reference in New Issue
Block a user