예제 #1
0
static int
musbotg_detach(device_t dev)
{
	struct musbotg_super_softc *sc = device_get_softc(dev);
	int err;

	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) {
		/*
		 * only call musbotg_uninit() after musbotg_init()
		 */
		musbotg_uninit(&sc->sc_otg);

		err = bus_teardown_intr(dev, sc->sc_otg.sc_irq_res,
		    sc->sc_otg.sc_intr_hdl);
		sc->sc_otg.sc_intr_hdl = NULL;
	}

	usb_bus_mem_free_all(&sc->sc_otg.sc_bus, NULL);

	/* Free resources if any */
	if (sc->sc_mem_res[0])
		bus_release_resources(dev, am335x_musbotg_mem_spec,
		    sc->sc_mem_res);

	if (sc->sc_otg.sc_irq_res)
		bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid,
		    sc->sc_otg.sc_irq_res);

	return (0);
}
예제 #2
0
static int
zy7_ehci_detach(device_t dev)
{
	ehci_softc_t *sc = device_get_softc(dev);

	/* during module unload there are lots of children leftover */
	device_delete_children(dev);
	
	sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;

	if (sc->sc_irq_res && sc->sc_intr_hdl)
		/* call ehci_detach() after ehci_init() called after
		 * successful bus_setup_intr().
		 */
		ehci_detach(sc);

	if (sc->sc_irq_res) {
		if (sc->sc_intr_hdl != NULL)
			bus_teardown_intr(dev, sc->sc_irq_res,
					  sc->sc_intr_hdl);
		bus_release_resource(dev, SYS_RES_IRQ,
			     rman_get_rid(sc->sc_irq_res), sc->sc_irq_res);
	}

	if (sc->sc_io_res)
		bus_release_resource(dev, SYS_RES_MEMORY,
			     rman_get_rid(sc->sc_io_res), sc->sc_io_res);
	usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);

	return (0);
}
예제 #3
0
int
ida_detach(device_t dev)
{
	struct ida_softc *ida;
	int error;

	ida = (struct ida_softc *)device_get_softc(dev);

	error = bus_generic_detach(dev);
	if (error)
		return (error);
	error = device_delete_children(dev);
	if (error)
		return (error);

	/*
	 * XXX
	 * before detaching, we must make sure that the system is
	 * quiescent; nothing mounted, no pending activity.
	 */

	/*
	 * XXX
	 * now, how are we supposed to maintain a list of our drives?
	 * iterate over our "child devices"?
	 */

	destroy_dev(ida->ida_dev_t);
	ida_free(ida);
	return (error);
}
예제 #4
0
static int
dotg_fdt_detach(device_t dev)
{
	struct dwc_otg_softc *sc = device_get_softc(dev);
	int err;

	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	if (sc->sc_irq_res && sc->sc_intr_hdl) {
		/*
		 * only call dotg_fdt_uninit() after dotg_fdt_init()
		 */
		dwc_otg_uninit(sc);

		err = bus_teardown_intr(dev, sc->sc_irq_res,
		    sc->sc_intr_hdl);
		sc->sc_intr_hdl = NULL;
	}
	if (sc->sc_irq_res) {
		bus_release_resource(dev, SYS_RES_IRQ, 0,
		    sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}
	if (sc->sc_io_res) {
		bus_release_resource(dev, SYS_RES_MEMORY, 0,
		    sc->sc_io_res);
		sc->sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_bus, NULL);

	return (0);
}
예제 #5
0
static int
mv_ehci_detach(device_t self)
{
    ehci_softc_t *sc = device_get_softc(self);
    device_t bdev;
    int err;

    if (sc->sc_bus.bdev) {
        bdev = sc->sc_bus.bdev;
        device_detach(bdev);
        device_delete_child(self, bdev);
    }
    /* during module unload there are lots of children leftover */
    device_delete_children(self);

    /*
     * disable interrupts that might have been switched on in mv_ehci_attach
     */
    if (sc->sc_io_res) {
        EWRITE4(sc, USB_BRIDGE_INTR_MASK, 0);
    }
    if (sc->sc_irq_res && sc->sc_intr_hdl) {
        /*
         * only call ehci_detach() after ehci_init()
         */
        ehci_detach(sc);

        err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);

        if (err)
            /* XXX or should we panic? */
            device_printf(self, "Could not tear down irq, %d\n",
                          err);
        sc->sc_intr_hdl = NULL;
    }
    if (irq_err && ih_err) {
        err = bus_teardown_intr(self, irq_err, ih_err);

        if (err)
            device_printf(self, "Could not tear down irq, %d\n",
                          err);
        ih_err = NULL;
    }
    if (irq_err) {
        bus_release_resource(self, SYS_RES_IRQ, 0, irq_err);
        irq_err = NULL;
    }
    if (sc->sc_irq_res) {
        bus_release_resource(self, SYS_RES_IRQ, 1, sc->sc_irq_res);
        sc->sc_irq_res = NULL;
    }
    if (sc->sc_io_res) {
        bus_release_resource(self, SYS_RES_MEMORY, 0,
                             sc->sc_io_res);
        sc->sc_io_res = NULL;
    }
    usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);

    return (0);
}
예제 #6
0
static int
at91_udp_detach(device_t dev)
{
	struct at91_udp_softc *sc = device_get_softc(dev);
	device_t bdev;
	int err;

	if (sc->sc_dci.sc_bus.bdev) {
		bdev = sc->sc_dci.sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(dev, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	USB_BUS_LOCK(&sc->sc_dci.sc_bus);
	callout_stop(&sc->sc_vbus);
	USB_BUS_UNLOCK(&sc->sc_dci.sc_bus);

	callout_drain(&sc->sc_vbus);

	/* disable Transceiver */
	AT91_UDP_WRITE_4(&sc->sc_dci, AT91_UDP_TXVC, AT91_UDP_TXVC_DIS);

	/* disable and clear all interrupts */
	AT91_UDP_WRITE_4(&sc->sc_dci, AT91_UDP_IDR, 0xFFFFFFFF);
	AT91_UDP_WRITE_4(&sc->sc_dci, AT91_UDP_ICR, 0xFFFFFFFF);

	if (sc->sc_dci.sc_irq_res && sc->sc_dci.sc_intr_hdl) {
		/*
		 * only call at91_udp_uninit() after at91_udp_init()
		 */
		at91dci_uninit(&sc->sc_dci);

		err = bus_teardown_intr(dev, sc->sc_dci.sc_irq_res,
		    sc->sc_dci.sc_intr_hdl);
		sc->sc_dci.sc_intr_hdl = NULL;
	}
	if (sc->sc_dci.sc_irq_res) {
		bus_release_resource(dev, SYS_RES_IRQ, 0,
		    sc->sc_dci.sc_irq_res);
		sc->sc_dci.sc_irq_res = NULL;
	}
	if (sc->sc_dci.sc_io_res) {
		bus_release_resource(dev, SYS_RES_MEMORY, MEM_RID,
		    sc->sc_dci.sc_io_res);
		sc->sc_dci.sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_dci.sc_bus, NULL);

	/* disable clocks */
	at91_pmc_clock_disable(sc->sc_iclk);
	at91_pmc_clock_disable(sc->sc_fclk);
	at91_pmc_clock_disable(sc->sc_mclk);
	at91_pmc_clock_deref(sc->sc_fclk);
	at91_pmc_clock_deref(sc->sc_iclk);
	at91_pmc_clock_deref(sc->sc_mclk);

	return (0);
}
예제 #7
0
파일: ata-pci.c 프로젝트: coyizumi/cs111
int
ata_pci_detach(device_t dev)
{
    struct ata_pci_controller *ctlr = device_get_softc(dev);

    /* detach & delete all children */
    device_delete_children(dev);

    if (ctlr->r_irq) {
	bus_teardown_intr(dev, ctlr->r_irq, ctlr->handle);
	bus_release_resource(dev, SYS_RES_IRQ, ctlr->r_irq_rid, ctlr->r_irq);
	if (ctlr->r_irq_rid != ATA_IRQ_RID)
	    pci_release_msi(dev);
    }
    if (ctlr->chipdeinit != NULL)
	ctlr->chipdeinit(dev);
    if (ctlr->r_res2) {
#ifdef __sparc64__
	bus_space_unmap(rman_get_bustag(ctlr->r_res2),
	    rman_get_bushandle(ctlr->r_res2), rman_get_size(ctlr->r_res2));
#endif
	bus_release_resource(dev, ctlr->r_type2, ctlr->r_rid2, ctlr->r_res2);
    }
    if (ctlr->r_res1) {
#ifdef __sparc64__
	bus_space_unmap(rman_get_bustag(ctlr->r_res1),
	    rman_get_bushandle(ctlr->r_res1), rman_get_size(ctlr->r_res1));
#endif
	bus_release_resource(dev, ctlr->r_type1, ctlr->r_rid1, ctlr->r_res1);
    }

    return 0;
}
예제 #8
0
static int
octusb_octeon_detach(device_t dev)
{
	struct octusb_octeon_softc *sc = device_get_softc(dev);
	device_t bdev;
	int err;

	if (sc->sc_dci.sc_bus.bdev) {
		bdev = sc->sc_dci.sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(dev, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	if (sc->sc_dci.sc_irq_res && sc->sc_dci.sc_intr_hdl) {
		/*
		 * only call octusb_octeon_uninit() after octusb_octeon_init()
		 */
		octusb_uninit(&sc->sc_dci);

		err = bus_teardown_intr(dev, sc->sc_dci.sc_irq_res,
		    sc->sc_dci.sc_intr_hdl);
		sc->sc_dci.sc_intr_hdl = NULL;
	}
	if (sc->sc_dci.sc_irq_res) {
		bus_release_resource(dev, SYS_RES_IRQ, 0,
		    sc->sc_dci.sc_irq_res);
		sc->sc_dci.sc_irq_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_dci.sc_bus, NULL);

	return (0);
}
예제 #9
0
파일: ehci_imx.c 프로젝트: coyizumi/cs111
static int
imx_ehci_detach(device_t dev)
{
	struct imx_ehci_softc *sc;
	ehci_softc_t *esc;

	sc = device_get_softc(dev);

	esc = &sc->ehci_softc;

	if (esc->sc_bus.bdev != NULL)
		device_delete_child(dev, esc->sc_bus.bdev);
	if (esc->sc_flags & EHCI_SCFLG_DONEINIT)
		ehci_detach(esc);
	if (esc->sc_intr_hdl != NULL)
		bus_teardown_intr(dev, esc->sc_irq_res, 
		    esc->sc_intr_hdl);
	if (sc->ehci_irq_res != NULL)
		bus_release_resource(dev, SYS_RES_IRQ, 0, 
		    sc->ehci_irq_res);
	if (sc->ehci_mem_res != NULL)
		bus_release_resource(dev, SYS_RES_MEMORY, 0,
		    sc->ehci_mem_res);

	usb_bus_mem_free_all(&esc->sc_bus, &ehci_iterate_hw_softc);

	/* During module unload there are lots of children leftover */
	device_delete_children(dev);

	return (0);
}
예제 #10
0
static int
hdspe_detach(device_t dev)
{
    struct sc_info *sc;
    int err;

    sc = device_get_softc(dev);
    if (sc == NULL) {
        device_printf(dev,"Can't detach: softc is null.\n");
        return 0;
    }

    err = device_delete_children(dev);
    if (err)
        return (err);

    hdspe_dmafree(sc);

    if (sc->ih)
        bus_teardown_intr(dev, sc->irq, sc->ih);
    if (sc->dmat)
        bus_dma_tag_destroy(sc->dmat);
    if (sc->irq)
        bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
    if (sc->cs)
        bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(0), sc->cs);
    if (sc->lock)
        snd_mtxfree(sc->lock);

    return 0;
}
예제 #11
0
static int
ad_detach(device_t dev)
{
    struct ad_softc *adp = device_get_ivars(dev);
    struct ata_device *atadev = device_get_softc(dev);

    /* check that we have a valid disk to detach */
    if (!device_get_ivars(dev))
	return ENXIO;
    
    /* destroy the power timeout */
    callout_drain(&atadev->spindown_timer);

    /* detach & delete all children */
    device_delete_children(dev);

    /* destroy disk from the system so we don't get any further requests */
    disk_destroy(adp->disk);

    /* fail requests on the queue and any that's "in flight" for this device */
    ata_fail_requests(dev);

    /* don't leave anything behind */
    device_set_ivars(dev, NULL);
    free(adp, M_AD);
    return 0;
}
예제 #12
0
static int
a10_ehci_detach(device_t self)
{
	ehci_softc_t *sc = device_get_softc(self);
	device_t bdev;
	int err;
	uint32_t reg_value = 0;

	if (sc->sc_bus.bdev) {
		bdev = sc->sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(self, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(self);

	if (sc->sc_irq_res && sc->sc_intr_hdl) {
		/*
		 * only call ehci_detach() after ehci_init()
		 */
		ehci_detach(sc);

		err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);

		if (err)
			/* XXX or should we panic? */
			device_printf(self, "Could not tear down irq, %d\n",
			    err);
		sc->sc_intr_hdl = NULL;
	}

	if (sc->sc_irq_res) {
		bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}
	if (sc->sc_io_res) {
		bus_release_resource(self, SYS_RES_MEMORY, 0,
		    sc->sc_io_res);
		sc->sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);

	/* Disable configure port */
	reg_value = A10_READ_4(sc, SW_SDRAM_REG_HPCR_USB2);
	reg_value &= ~SW_SDRAM_BP_HPCR_ACCESS;
	A10_WRITE_4(sc, SW_SDRAM_REG_HPCR_USB2, reg_value);

	/* Disable passby */
	reg_value = A10_READ_4(sc, SW_USB_PMU_IRQ_ENABLE);
	reg_value &= ~SW_AHB_INCR8; /* AHB INCR8 disable */
	reg_value &= ~SW_AHB_INCR4; /* AHB burst type INCR4 disable */
	reg_value &= ~SW_AHB_INCRX_ALIGN; /* AHB INCRX align disable */
	reg_value &= ~SW_ULPI_BYPASS; /* ULPI bypass disable */
	A10_WRITE_4(sc, SW_USB_PMU_IRQ_ENABLE, reg_value);

	/* Disable clock for USB */
	a10_clk_usb_deactivate();

	return (0);
}
예제 #13
0
static int
exynos_xhci_detach(device_t dev)
{
	struct exynos_xhci_softc *esc = device_get_softc(dev);
	int err;

	/* During module unload there are lots of children leftover */
	device_delete_children(dev);

	xhci_halt_controller(&esc->base);
	
	if (esc->res[2] && esc->base.sc_intr_hdl) {
		err = bus_teardown_intr(dev, esc->res[2],
		    esc->base.sc_intr_hdl);
		if (err) {
			device_printf(dev, "Could not tear down IRQ,"
			    " %d\n", err);
			return (err);
		}
	}

	bus_release_resources(dev, exynos_xhci_spec, esc->res);

	xhci_uninit(&esc->base);
	
	return (0);
}
예제 #14
0
static int
xhci_detach(device_t dev)
{
	struct xhci_softc *sc = device_get_softc(dev);
	int err;

	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	if (sc->sc_irq_res != NULL && sc->sc_intr_hdl != NULL) {
		err = bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intr_hdl);
		if (err != 0)
			device_printf(dev, "Could not tear down irq, %d\n",
			    err);
		sc->sc_intr_hdl = NULL;
	}

	if (sc->sc_irq_res != NULL) {
		bus_release_resource(dev, SYS_RES_IRQ,
		    rman_get_rid(sc->sc_irq_res), sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}

	if (sc->sc_io_res != NULL) {
		bus_release_resource(dev, SYS_RES_MEMORY,
		    rman_get_rid(sc->sc_io_res), sc->sc_io_res);
		sc->sc_io_res = NULL;
	}

	xhci_uninit(sc);

	return (0);
}
예제 #15
0
int
ppc_detach(device_t dev)
{
	struct ppc_data *ppc = DEVTOSOFTC(dev);

	if (ppc->res_irq == 0) {
		return (ENXIO);
	}

	/* detach & delete all children */
	device_delete_children(dev);

	if (ppc->res_irq != 0) {
		bus_teardown_intr(dev, ppc->res_irq, ppc->intr_cookie);
		bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq,
				     ppc->res_irq);
	}
	if (ppc->res_ioport != 0) {
		bus_release_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport,
				     ppc->res_ioport);
	}
	if (ppc->res_drq != 0) {
		bus_release_resource(dev, SYS_RES_DRQ, ppc->rid_drq,
				     ppc->res_drq);
	}

	mtx_destroy(&ppc->ppc_lock);

	return (0);
}
예제 #16
0
static int
atmegadci_detach(device_t dev)
{
	struct atmegadci_super_softc *sc = device_get_softc(dev);
	int err;

	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) {
		/*
		 * only call atmegadci_uninit() after atmegadci_init()
		 */
		atmegadci_uninit(&sc->sc_otg);

		err = bus_teardown_intr(dev, sc->sc_otg.sc_irq_res,
		    sc->sc_otg.sc_intr_hdl);
		sc->sc_otg.sc_intr_hdl = NULL;
	}
	/* free IRQ channel, if any */
	if (sc->sc_otg.sc_irq_res) {
		bus_release_resource(dev, SYS_RES_IRQ, 0,
		    sc->sc_otg.sc_irq_res);
		sc->sc_otg.sc_irq_res = NULL;
	}
	/* free memory resource, if any */
	if (sc->sc_otg.sc_io_res) {
		bus_release_resource(dev, SYS_RES_MEMORY, 0,
		    sc->sc_otg.sc_io_res);
		sc->sc_otg.sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_otg.sc_bus, NULL);

	return (0);
}
예제 #17
0
static int
iicoc_detach(device_t dev)
{
	bus_generic_detach(dev);
	device_delete_children(dev);

	return (0);
}
예제 #18
0
static int
intel_iicbb_detach(device_t idev)
{

	bus_generic_detach(idev);
	device_delete_children(idev);

	return (0);
}
예제 #19
0
파일: at91_ohci.c 프로젝트: 2asoft/freebsd
static int
ohci_atmelarm_detach(device_t dev)
{
	struct at91_ohci_softc *sc = device_get_softc(dev);
	device_t bdev;
	int err;

	if (sc->sc_ohci.sc_bus.bdev) {
		bdev = sc->sc_ohci.sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(dev, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	/*
	 * Put the controller into reset, then disable clocks and do
	 * the MI tear down.  We have to disable the clocks/hardware
	 * after we do the rest of the teardown.  We also disable the
	 * clocks in the opposite order we acquire them, but that
	 * doesn't seem to be absolutely necessary.  We free up the
	 * clocks after we disable them, so the system could, in
	 * theory, reuse them.
	 */
	bus_space_write_4(sc->sc_ohci.sc_io_tag, sc->sc_ohci.sc_io_hdl,
	    OHCI_CONTROL, 0);

	at91_pmc_clock_disable(sc->fclk);
	at91_pmc_clock_disable(sc->iclk);
	at91_pmc_clock_disable(sc->mclk);
	at91_pmc_clock_deref(sc->fclk);
	at91_pmc_clock_deref(sc->iclk);
	at91_pmc_clock_deref(sc->mclk);

	if (sc->sc_ohci.sc_irq_res && sc->sc_ohci.sc_intr_hdl) {
		/*
		 * only call ohci_detach() after ohci_init()
		 */
		ohci_detach(&sc->sc_ohci);

		err = bus_teardown_intr(dev, sc->sc_ohci.sc_irq_res, sc->sc_ohci.sc_intr_hdl);
		sc->sc_ohci.sc_intr_hdl = NULL;
	}
	if (sc->sc_ohci.sc_irq_res) {
		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_ohci.sc_irq_res);
		sc->sc_ohci.sc_irq_res = NULL;
	}
	if (sc->sc_ohci.sc_io_res) {
		bus_release_resource(dev, SYS_RES_MEMORY, MEM_RID,
		    sc->sc_ohci.sc_io_res);
		sc->sc_ohci.sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_ohci.sc_bus, &ohci_iterate_hw_softc);

	return (0);
}
예제 #20
0
static int
radeon_atom_hw_i2c_detach(device_t dev)
{
	/* detach bit-banding code. */
	bus_generic_detach(dev);

	/* delete bit-banding code. */
	device_delete_children(dev);
	return (0);
}
예제 #21
0
static int
iicbus_detach(device_t dev)
{
	struct iicbus_softc *sc = IICBUS_SOFTC(dev);

	iicbus_reset(dev, IIC_FASTEST, 0, NULL);
	bus_generic_detach(dev);
	device_delete_children(dev);
	mtx_destroy(&sc->lock);
	return (0);
}
예제 #22
0
static int
fsl_ehci_detach(device_t self)
{
	struct imx_ehci_softc *sc;
	ehci_softc_t *esc;
	int err, i;

	sc = device_get_softc(self);

	for (i = 0; i < FSL_EHCI_COUNT; i ++) {
		esc = &sc->ehci[i];
		if (esc->sc_flags & EHCI_SCFLG_DONEINIT)
			continue;
		/*
		 * only call ehci_detach() after ehci_init()
		 */
		if (esc->sc_flags & EHCI_SCFLG_DONEINIT) {
			ehci_detach(esc);
			esc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
		}

		/*
		 * Disable interrupts that might have been switched on in
		 * ehci_init.
		 */
		if (esc->sc_io_tag && esc->sc_io_hdl)
			bus_space_write_4(esc->sc_io_tag, esc->sc_io_hdl,
			    EHCI_USBINTR, 0);

		if (esc->sc_irq_res && esc->sc_intr_hdl) {
			err = bus_teardown_intr(self, esc->sc_irq_res,
			    esc->sc_intr_hdl);
			if (err) {
				device_printf(self, "Could not tear down irq,"
				    " %d\n", err);
				return (err);
			}
			esc->sc_intr_hdl = NULL;
		}

		if (esc->sc_bus.bdev) {
			device_delete_child(self, esc->sc_bus.bdev);
			esc->sc_bus.bdev = NULL;
		}
	}

	/* During module unload there are lots of children leftover */
	device_delete_children(self);

	if (sc->sc_res[0])
		bus_release_resources(self, imx_ehci_spec, sc->sc_res);

	return (0);
}
예제 #23
0
static int
vybrid_ehci_detach(device_t dev)
{
	struct vybrid_ehci_softc *esc;
	ehci_softc_t *sc;
	int err;

	esc = device_get_softc(dev);
	sc = &esc->base;

	if (sc->sc_flags & EHCI_SCFLG_DONEINIT)
		return (0);

	/*
	 * only call ehci_detach() after ehci_init()
	 */
	if (sc->sc_flags & EHCI_SCFLG_DONEINIT) {
		ehci_detach(sc);
		sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
	}

	/*
	 * Disable interrupts that might have been switched on in
	 * ehci_init.
	 */
	if (sc->sc_io_tag && sc->sc_io_hdl)
		bus_space_write_4(sc->sc_io_tag, sc->sc_io_hdl,
		    EHCI_USBINTR, 0);

	if (esc->res[5] && sc->sc_intr_hdl) {
		err = bus_teardown_intr(dev, esc->res[5],
		    sc->sc_intr_hdl);
		if (err) {
			device_printf(dev, "Could not tear down irq,"
			    " %d\n", err);
			return (err);
		}
		sc->sc_intr_hdl = NULL;
	}

	if (sc->sc_bus.bdev) {
		device_delete_child(dev, sc->sc_bus.bdev);
		sc->sc_bus.bdev = NULL;
	}

	/* During module unload there are lots of children leftover */
	device_delete_children(dev);

	bus_release_resources(dev, vybrid_ehci_spec, esc->res);

	return (0);
}
예제 #24
0
static int
fsl_ehci_detach(device_t self)
{

	int err;
	ehci_softc_t *sc;

	sc = device_get_softc(self);
	/*
	 * only call ehci_detach() after ehci_init()
	 */
	if (sc->sc_flags & EHCI_SCFLG_DONEINIT) {
		ehci_detach(sc);
		sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
	}

	/* Disable interrupts that might have been switched on in ehci_init */
	if (sc->sc_io_tag && sc->sc_io_hdl)
		bus_space_write_4(sc->sc_io_tag, sc->sc_io_hdl, EHCI_USBINTR, 0);

	if (sc->sc_irq_res && sc->sc_intr_hdl) {
		err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
		if (err) {
			device_printf(self, "Could not tear down irq, %d\n",
			    err);
			return (err);
		}
		sc->sc_intr_hdl = NULL;
	}

	if (sc->sc_bus.bdev) {
		device_delete_child(self, sc->sc_bus.bdev);
		sc->sc_bus.bdev = NULL;
	}

	/* During module unload there are lots of children leftover */
	device_delete_children(self);

	if (sc->sc_irq_res) {
		bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}

	if (sc->sc_io_res) {
		bus_release_resource(self, SYS_RES_MEMORY, 0, sc->sc_io_res);
		sc->sc_io_res = NULL;
		sc->sc_io_tag = 0;
		sc->sc_io_hdl = 0;
	}

	return (0);
}
예제 #25
0
int
uhci_pci_detach(device_t self)
{
	uhci_softc_t *sc = device_get_softc(self);
	device_t bdev;

	if (sc->sc_bus.bdev) {
		bdev = sc->sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(self, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(self);

	/*
	 * disable interrupts that might have been switched on in
	 * uhci_init.
	 */
	if (sc->sc_io_res) {
		USB_BUS_LOCK(&sc->sc_bus);

		/* stop the controller */
		uhci_reset(sc);

		USB_BUS_UNLOCK(&sc->sc_bus);
	}
	pci_disable_busmaster(self);

	if (sc->sc_irq_res && sc->sc_intr_hdl) {
		int err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);

		if (err) {
			/* XXX or should we panic? */
			device_printf(self, "Could not tear down irq, %d\n",
			    err);
		}
		sc->sc_intr_hdl = NULL;
	}
	if (sc->sc_irq_res) {
		bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}
	if (sc->sc_io_res) {
		bus_release_resource(self, SYS_RES_IOPORT, PCI_UHCI_BASE_REG,
		    sc->sc_io_res);
		sc->sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_bus, &uhci_iterate_hw_softc);

	return (0);
}
예제 #26
0
static int
ehci_obio_detach(device_t self)
{
	ehci_softc_t *sc = device_get_softc(self);
	device_t bdev;
	int err;

	if (sc->sc_bus.bdev) {
		bdev = sc->sc_bus.bdev;
		device_detach(bdev);
		device_delete_child(self, bdev);
	}
	/* during module unload there are lots of children leftover */
	device_delete_children(self);

	if (sc->sc_irq_res && sc->sc_intr_hdl) {
		/*
		 * only call ehci_detach() after ehci_init()
		 */
		ehci_detach(sc);

		/* Stop EHCI clock */
		rt305x_sysctl_set(SYSCTL_CLKCFG1, 
		  rt305x_sysctl_get(SYSCTL_CLKCFG1) & 
		  ~(SYSCTL_CLKCFG1_UPHY0_CLK_EN
#ifdef MT7620
		    | SYSCTL_CLKCFG1_UPHY1_CLK_EN
#endif
		));

		err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl);
		if (err)
			device_printf(self, "Could not tear down irq, %d\n",
				err);
		sc->sc_intr_hdl = NULL;
	}
	if (sc->sc_irq_res) {
		bus_release_resource(self, SYS_RES_IRQ, 0,
		    sc->sc_irq_res);
		sc->sc_irq_res = NULL;
	}
	if (sc->sc_io_res) {
		bus_release_resource(self, SYS_RES_MEMORY, 0,
		    sc->sc_io_res);
		sc->sc_io_res = NULL;
	}
	usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);

	return (0);
}
예제 #27
0
static int
musbotg_detach(device_t dev)
{
	struct musbotg_super_softc *sc = device_get_softc(dev);
	device_t bdev;
	int err;
	int i;

	for (i = 0; i < AM335X_USB_PORTS; i++) {
		if (sc->sc_otg[i].sc_bus.bdev) {
			bdev = sc->sc_otg[i].sc_bus.bdev;
			device_detach(bdev);
			device_delete_child(dev, bdev);
		}

		if (sc->sc_otg[i].sc_irq_res && sc->sc_otg[i].sc_intr_hdl) {
			/*
			 * only call musbotg_uninit() after musbotg_init()
			 */
			musbotg_uninit(&sc->sc_otg[i]);

			err = bus_teardown_intr(dev, sc->sc_otg[i].sc_irq_res,
			    sc->sc_otg[i].sc_intr_hdl);
			sc->sc_otg[i].sc_intr_hdl = NULL;
		}

		usb_bus_mem_free_all(&sc->sc_otg[i].sc_bus, NULL);
	}

	if (sc->sc_intr_hdl) {
	 	bus_teardown_intr(dev, sc->sc_irq_res[0],
		    sc->sc_intr_hdl);
		sc->sc_intr_hdl = NULL;
	}


	/* Free resources if any */
	if (sc->sc_mem_res[0])
		bus_release_resources(dev, am335x_musbotg_mem_spec,
		    sc->sc_mem_res);

	if (sc->sc_irq_res[0])
		bus_release_resources(dev, am335x_musbotg_irq_spec,
		    sc->sc_irq_res);

	/* during module unload there are lots of children leftover */
	device_delete_children(dev);

	return (0);
}
예제 #28
0
파일: gpiobus.c 프로젝트: jp629/freebsd
int
gpiobus_detach_bus(device_t dev)
{
	int err;

#ifdef FDT
	ofw_gpiobus_unregister_provider(dev);
#endif
	err = bus_generic_detach(dev);
	if (err != 0)
		return (err);

	return (device_delete_children(dev));
}
예제 #29
0
static int
smbus_detach(device_t dev)
{
	struct smbus_softc *sc = device_get_softc(dev);
	int error;

	error = bus_generic_detach(dev);
	if (error)
		return (error);
	device_delete_children(dev);
	mtx_destroy(&sc->lock);

	return (0);
}
예제 #30
0
파일: cardbus.c 프로젝트: 2asoft/freebsd
static int
cardbus_detach_card(device_t cbdev)
{
	int err = 0;

	err = bus_generic_detach(cbdev);
	if (err)
		return (err);
	err = device_delete_children(cbdev);
	if (err)
		return (err);

	POWER_DISABLE_SOCKET(device_get_parent(cbdev), cbdev);
	return (err);
}