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

Function mtk_pci_read_config

freebsd/mips/mediatek/mtk_pcie.c:616–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614}
615
616static uint32_t
617mtk_pci_read_config(device_t dev, u_int bus, u_int slot, u_int func,
618 u_int reg, int bytes)
619{
620 struct mtk_pci_softc *sc = device_get_softc(dev);
621 uint32_t addr = 0, data = 0;
622
623 /* Return ~0U if slot has no link */
624 if (bus == 0 && mtk_pci_slot_has_link(dev, slot) == 0) {
625 return (~0U);
626 }
627
628 mtx_lock_spin(&mtk_pci_mtx);
629 addr = mtk_pci_make_addr(bus, slot, func, (reg & ~3)) & sc->addr_mask;
630 MT_WRITE32(sc, MTK_PCI_CFGADDR, addr);
631 switch (bytes % 4) {
632 case 0:
633 data = MT_READ32(sc, MTK_PCI_CFGDATA);
634 break;
635 case 1:
636 data = MT_READ8(sc, MTK_PCI_CFGDATA + (reg & 0x3));
637 break;
638 case 2:
639 data = MT_READ16(sc, MTK_PCI_CFGDATA + (reg & 0x3));
640 break;
641 default:
642 panic("%s(): Wrong number of bytes (%d) requested!\n",
643 __FUNCTION__, bytes % 4);
644 }
645 mtx_unlock_spin(&mtk_pci_mtx);
646
647 return (data);
648}
649
650static void
651mtk_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func,

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