コード例 #1
0
/*
 * Support for attaching the PCIe-Gen1 MDIO driver to a parent bhndb PCIe
 * bridge device. 
 */
static int
bhndb_mdio_pcie_probe(device_t dev)
{
	struct bhndb_softc	*psc;
	device_t		 parent;

	/* Parent must be a bhndb_pcie instance */
	parent = device_get_parent(dev);
	if (device_get_driver(parent) != &bhndb_pci_driver)
		return (ENXIO);

	/* Parent must have PCIe-Gen1 hostb device */
	psc = device_get_softc(parent);
	if (psc->hostb_dev == NULL)
		return (ENXIO);

	if (bhnd_get_vendor(psc->hostb_dev) != BHND_MFGID_BCM ||
	    bhnd_get_device(psc->hostb_dev) != BHND_COREID_PCIE)
	{
		return (ENXIO);
	}

	device_quiet(dev);
	return (BUS_PROBE_NOWILDCARD);
}
コード例 #2
0
ファイル: nexus.c プロジェクト: MarginC/kame
/*
 * Currently this uses the really grody interface from kern/kern_intr.c
 * (which really doesn't belong in kern/anything.c).  Eventually, all of
 * the code in kern_intr.c and machdep_intr.c should get moved here, since
 * this is going to be the official interface.
 */
static int
nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
		 int flags, void (*ihand)(void *), void *arg, void **cookiep)
{
	driver_t	*driver;
	int		error;

	/* somebody tried to setup an irq that failed to allocate! */
	if (irq == NULL)
		panic("nexus_setup_intr: NULL irq resource!");

	*cookiep = 0;
	if ((irq->r_flags & RF_SHAREABLE) == 0)
		flags |= INTR_EXCL;

	driver = device_get_driver(child);

	/*
	 * We depend here on rman_activate_resource() being idempotent.
	 */
	error = rman_activate_resource(irq);
	if (error)
		return (error);

	error = inthand_add(device_get_nameunit(child), irq->r_start,
	    ihand, arg, flags, cookiep);

	return (error);
}
コード例 #3
0
ファイル: nexus.c プロジェクト: UnitedMarsupials/kame
/*
 * Currently this uses the really grody interface from kern/kern_intr.c
 * (which really doesn't belong in kern/anything.c).  Eventually, all of
 * the code in kern_intr.c and machdep_intr.c should get moved here, since
 * this is going to be the official interface.
 */
static int
nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
		 int flags, void (*ihand)(void *), void *arg, void **cookiep)
{
	intrmask_t	*mask;
	driver_t	*driver;
	int	error, icflags;

	/* somebody tried to setup an irq that failed to allocate! */
	if (irq == NULL)
		panic("nexus_setup_intr: NULL irq resource!");

	*cookiep = 0;
	if (irq->r_flags & RF_SHAREABLE)
		icflags = 0;
	else
		icflags = INTR_EXCL;

	driver = device_get_driver(child);
	switch (flags) {
	case INTR_TYPE_TTY:
		mask = &tty_imask;
		break;
	case (INTR_TYPE_TTY | INTR_TYPE_FAST):
		mask = &tty_imask;
		icflags |= INTR_FAST;
		break;
	case INTR_TYPE_BIO:
		mask = &bio_imask;
		break;
	case INTR_TYPE_NET:
		mask = &net_imask;
		break;
	case INTR_TYPE_CAM:
		mask = &cam_imask;
		break;
	case INTR_TYPE_MISC:
		mask = 0;
		break;
	default:
		panic("still using grody create_intr interface");
	}

	/*
	 * We depend here on rman_activate_resource() being idempotent.
	 */
	error = rman_activate_resource(irq);
	if (error)
		return (error);

	*cookiep = inthand_add(device_get_nameunit(child), irq->r_start,
	    ihand, arg, mask, icflags);
	if (*cookiep == NULL)
		error = EINVAL;	/* XXX ??? */

	return (error);
}