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

Function zy7_devcfg_attach

freebsd/arm/xilinx/zy7_devcfg.c:713–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711static int zy7_devcfg_detach(device_t dev);
712
713static int
714zy7_devcfg_attach(device_t dev)
715{
716 struct zy7_devcfg_softc *sc = device_get_softc(dev);
717 int i;
718 int rid, err;
719
720 /* Allow only one attach. */
721 if (zy7_devcfg_softc_p != NULL)
722 return (ENXIO);
723
724 sc->dev = dev;
725
726 DEVCFG_SC_LOCK_INIT(sc);
727
728 /* Get memory resource. */
729 rid = 0;
730 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
731 RF_ACTIVE);
732 if (sc->mem_res == NULL) {
733 device_printf(dev, "could not allocate memory resources.\n");
734 zy7_devcfg_detach(dev);
735 return (ENOMEM);
736 }
737
738 /* Allocate IRQ. */
739 rid = 0;
740 sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
741 RF_ACTIVE);
742 if (sc->irq_res == NULL) {
743 device_printf(dev, "cannot allocate IRQ\n");
744 zy7_devcfg_detach(dev);
745 return (ENOMEM);
746 }
747
748 /* Activate the interrupt. */
749 err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
750 NULL, zy7_devcfg_intr, sc, &sc->intrhandle);
751 if (err) {
752 device_printf(dev, "cannot setup IRQ\n");
753 zy7_devcfg_detach(dev);
754 return (err);
755 }
756
757 /* Create /dev/devcfg */
758 sc->sc_ctl_dev = make_dev(&zy7_devcfg_cdevsw, 0,
759 UID_ROOT, GID_WHEEL, 0600, "devcfg");
760 if (sc->sc_ctl_dev == NULL) {
761 device_printf(dev, "failed to create /dev/devcfg");
762 zy7_devcfg_detach(dev);
763 return (ENXIO);
764 }
765 sc->sc_ctl_dev->si_drv1 = sc;
766
767 zy7_devcfg_softc_p = sc;
768
769 /* Unlock devcfg registers. */
770 WR4(sc, ZY7_DEVCFG_UNLOCK, ZY7_DEVCFG_UNLOCK_MAGIC);

Callers

nothing calls this directly

Calls 12

device_get_softcFunction · 0.85
bus_alloc_resource_anyFunction · 0.85
device_printfFunction · 0.85
zy7_devcfg_detachFunction · 0.85
bus_setup_intrFunction · 0.85
make_devFunction · 0.85
zy7_pl_fclk_get_sourceFunction · 0.85
zy7_pl_fclk_enabledFunction · 0.85
zy7_pl_fclk_get_freqFunction · 0.85
WR4Function · 0.50
RD4Function · 0.50

Tested by

no test coverage detected