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

Function mtk_pci_write_config

freebsd/mips/mediatek/mtk_pcie.c:650–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648}
649
650static void
651mtk_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func,
652 u_int reg, uint32_t val, int bytes)
653{
654 struct mtk_pci_softc *sc = device_get_softc(dev);
655 uint32_t addr = 0, data = val;
656
657 /* Do not write if slot has no link */
658 if (bus == 0 && mtk_pci_slot_has_link(dev, slot) == 0)
659 return;
660
661 mtx_lock_spin(&mtk_pci_mtx);
662 addr = mtk_pci_make_addr(bus, slot, func, (reg & ~3)) & sc->addr_mask;
663 MT_WRITE32(sc, MTK_PCI_CFGADDR, addr);
664 switch (bytes % 4) {
665 case 0:
666 MT_WRITE32(sc, MTK_PCI_CFGDATA, data);
667 break;
668 case 1:
669 MT_WRITE8(sc, MTK_PCI_CFGDATA + (reg & 0x3), data);
670 break;
671 case 2:
672 MT_WRITE16(sc, MTK_PCI_CFGDATA + (reg & 0x3), data);
673 break;
674 default:
675 panic("%s(): Wrong number of bytes (%d) requested!\n",
676 __FUNCTION__, bytes % 4);
677 }
678 mtx_unlock_spin(&mtk_pci_mtx);
679}
680
681static int
682mtk_pci_route_interrupt(device_t pcib, device_t device, int pin)

Callers 1

mtk_pcie_phy_setup_slotsFunction · 0.85

Calls 4

device_get_softcFunction · 0.85
mtk_pci_slot_has_linkFunction · 0.85
mtk_pci_make_addrFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected