| 614 | } |
| 615 | |
| 616 | static uint32_t |
| 617 | mtk_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 | |
| 650 | static void |
| 651 | mtk_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func, |
no test coverage detected