MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bcm_dma_attach

Function bcm_dma_attach

freebsd/arm/broadcom/bcm2835/bcm2835_dma.c:672–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

670}
671
672static int
673bcm_dma_attach(device_t dev)
674{
675 struct bcm_dma_softc *sc = device_get_softc(dev);
676 phandle_t node;
677 int rid, err = 0;
678 int i;
679
680 sc->sc_dev = dev;
681
682 if (bcm_dma_sc)
683 return (ENXIO);
684
685 for (i = 0; i < BCM_DMA_CH_MAX; i++) {
686 sc->sc_irq[i] = NULL;
687 sc->sc_intrhand[i] = NULL;
688 }
689
690 /* Get DMA channel mask. */
691 node = ofw_bus_get_node(sc->sc_dev);
692 if (OF_getencprop(node, "brcm,dma-channel-mask", &bcm_dma_channel_mask,
693 sizeof(bcm_dma_channel_mask)) == -1 &&
694 OF_getencprop(node, "broadcom,channels", &bcm_dma_channel_mask,
695 sizeof(bcm_dma_channel_mask)) == -1) {
696 device_printf(dev, "could not get channel mask property\n");
697 return (ENXIO);
698 }
699
700 /* Mask out channels used by GPU. */
701 bcm_dma_channel_mask &= ~BCM_DMA_CH_GPU_MASK;
702
703 /* DMA0 - DMA14 */
704 rid = 0;
705 sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
706 if (sc->sc_mem == NULL) {
707 device_printf(dev, "could not allocate memory resource\n");
708 return (ENXIO);
709 }
710
711 /* IRQ DMA0 - DMA11 XXX NOT USE DMA12(spurious?) */
712 for (rid = 0; rid < BCM_DMA_CH_MAX; rid++) {
713 if ((bcm_dma_channel_mask & (1 << rid)) == 0)
714 continue;
715
716 sc->sc_irq[rid] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
717 RF_ACTIVE | RF_SHAREABLE);
718 if (sc->sc_irq[rid] == NULL) {
719 device_printf(dev, "cannot allocate interrupt\n");
720 err = ENXIO;
721 goto fail;
722 }
723 if (bus_setup_intr(dev, sc->sc_irq[rid], INTR_TYPE_MISC | INTR_MPSAFE,
724 NULL, bcm_dma_intr, &sc->sc_dma_ch[rid],
725 &sc->sc_intrhand[rid])) {
726 device_printf(dev, "cannot setup interrupt handler\n");
727 err = ENXIO;
728 goto fail;
729 }

Callers

nothing calls this directly

Calls 8

device_get_softcFunction · 0.85
device_printfFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
bus_setup_intrFunction · 0.85
mtx_initFunction · 0.85
bcm_dma_initFunction · 0.85
bus_release_resourceFunction · 0.85
bus_teardown_intrFunction · 0.85

Tested by

no test coverage detected