Lines Matching +full:irqs +full:- +full:map +full:- +full:range
1 /*-
110 * as we want. To support 32-bit cards let's assume
113 * 0x00000000 - 0x000FFFFF IO
114 * 0x00100000 - 0xFFFFFFFF Memory
217 * ARM64TODO Workaround - otherwise an em(4) interface appears to be in thunder_pem_maxslots()
239 *result = sc->id; in thunder_pem_read_ivar()
262 return (pci_domain_activate_bus(sc->id, child, r)); in thunder_pem_activate_resource()
280 return (pci_domain_deactivate_bus(sc->id, child, r)); in thunder_pem_deactivate_resource()
291 struct resource_map_request *argsp, struct resource_map *map) in thunder_pem_map_resource() argument
316 start = range_addr_pci_to_phys(sc->ranges, start); in thunder_pem_map_resource()
317 error = bus_space_map(&memmap_bus, start, length, 0, &map->r_bushandle); in thunder_pem_map_resource()
320 map->r_bustag = &memmap_bus; in thunder_pem_map_resource()
321 map->r_vaddr = (void *)map->r_bushandle; in thunder_pem_map_resource()
322 map->r_size = length; in thunder_pem_map_resource()
328 struct resource_map *map) in thunder_pem_unmap_resource() argument
334 bus_space_unmap(map->r_bustag, map->r_bushandle, map->r_size); in thunder_pem_unmap_resource()
350 return (pci_domain_adjust_bus(sc->id, child, res, start, end)); in thunder_pem_adjust_resource()
367 return (sc->dmat); in thunder_pem_get_dma_tag()
372 int *irqs) in thunder_pem_alloc_msi() argument
378 irqs)); in thunder_pem_alloc_msi()
382 thunder_pem_release_msi(device_t pci, device_t child, int count, int *irqs) in thunder_pem_release_msi() argument
387 return (PCIB_RELEASE_MSI(device_get_parent(bus), child, count, irqs)); in thunder_pem_release_msi()
436 * numbers using hard-coded domain portion for each group. in thunder_pem_get_id()
459 start = rman_get_start(sc->reg); in thunder_pem_identify()
462 sc->node = (start >> SLI_NODE_SHIFT) & SLI_NODE_MASK; in thunder_pem_identify()
463 sc->id = ((start >> SLI_ID_SHIFT) & SLI_ID_MASK) + in thunder_pem_identify()
464 (SLI_PEMS_PER_NODE * sc->node); in thunder_pem_identify()
465 sc->sli = sc->id % SLI_PEMS_PER_GROUP; in thunder_pem_identify()
466 sc->sli_group = (sc->id / SLI_PEMS_PER_GROUP) % SLI_GROUPS_PER_NODE; in thunder_pem_identify()
467 sc->sli_window_base = SLI_BASE | in thunder_pem_identify()
468 (((uint64_t)sc->node) << SLI_NODE_SHIFT) | in thunder_pem_identify()
469 ((uint64_t)sc->sli_group << SLI_GROUP_SHIFT); in thunder_pem_identify()
470 sc->sli_window_base += SLI_WINDOW_SPACING * sc->sli; in thunder_pem_identify()
489 device_printf(sc->dev, "SLI group is not correct\n"); in thunder_pem_slix_s2m_regx_acc_modify()
492 /* Clear lower 32-bits of the SLIx register */ in thunder_pem_slix_s2m_regx_acc_modify()
493 regval = bus_space_read_8(sc->reg_bst, handle, in thunder_pem_slix_s2m_regx_acc_modify()
496 bus_space_write_8(sc->reg_bst, handle, in thunder_pem_slix_s2m_regx_acc_modify()
507 regval = bus_space_read_8(sc->reg_bst, sc->reg_bsh, PEM_ON_REG); in thunder_pem_link_init()
509 device_printf(sc->dev, "PEM%d is not ON\n", sc->id); in thunder_pem_link_init()
513 regval = bus_space_read_8(sc->reg_bst, sc->reg_bsh, PEM_CTL_STATUS); in thunder_pem_link_init()
515 bus_space_write_8(sc->reg_bst, sc->reg_bsh, PEM_CTL_STATUS, regval); in thunder_pem_link_init()
523 device_printf(sc->dev, "PCIe RC: Port %d Link Timeout\n", in thunder_pem_link_init()
524 sc->id); in thunder_pem_link_init()
538 device_printf(sc->dev, "%s failed\n", __func__); in thunder_pem_init()
542 /* To support 32-bit PCIe devices, set S2M_REGx_ACC[BA]=0x0 */ in thunder_pem_init()
544 thunder_pem_slix_s2m_regx_acc_modify(sc, sc->sli_group, i); in thunder_pem_init()
556 bus_space_write_8(sc->reg_bst, sc->reg_bsh, PEM_CFG_RD, in thunder_pem_config_reg_read()
558 bus_space_barrier(sc->reg_bst, sc->reg_bsh, PEM_CFG_RD, 8, in thunder_pem_config_reg_read()
561 data = PEM_CFG_RD_REG_DATA(bus_space_read_8(sc->reg_bst, sc->reg_bsh, in thunder_pem_config_reg_read()
586 t = sc->reg_bst; in thunder_pem_read_config()
587 h = sc->pem_sli_base; in thunder_pem_read_config()
589 bus_space_map(sc->reg_bst, sc->sli_window_base + offset, in thunder_pem_read_config()
607 bus_space_unmap(sc->reg_bst, h, PCIE_REGMAX); in thunder_pem_read_config()
630 t = sc->reg_bst; in thunder_pem_write_config()
631 h = sc->pem_sli_base; in thunder_pem_write_config()
633 bus_space_map(sc->reg_bst, sc->sli_window_base + offset, in thunder_pem_write_config()
650 bus_space_unmap(sc->reg_bst, h, PCIE_REGMAX); in thunder_pem_write_config()
663 return (pci_domain_alloc_bus(sc->id, child, rid, start, end, in thunder_pem_alloc_resource()
680 if (range_addr_is_phys(sc->ranges, start, count)) { in thunder_pem_alloc_resource()
681 start = range_addr_phys_to_pci(sc->ranges, start); in thunder_pem_alloc_resource()
682 end = start + count - 1; in thunder_pem_alloc_resource()
711 return (pci_domain_release_bus(sc->id, child, res)); in thunder_pem_release_resource()
730 return (&sc->io_rman); in thunder_pem_get_rman()
732 return (&sc->mem_rman); in thunder_pem_get_rman()
762 struct resource_map map; in thunder_pem_attach() local
773 sc->dev = dev; in thunder_pem_attach()
783 sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY, in thunder_pem_attach()
785 if (sc->reg == NULL) { in thunder_pem_attach()
791 error = bus_map_resource(dev, SYS_RES_MEMORY, sc->reg, &req, &map); in thunder_pem_attach()
793 device_printf(dev, "could not map memory.\n"); in thunder_pem_attach()
796 rman_set_mapping(sc->reg, &map); in thunder_pem_attach()
798 sc->reg_bst = rman_get_bustag(sc->reg); in thunder_pem_attach()
799 sc->reg_bsh = rman_get_bushandle(sc->reg); in thunder_pem_attach()
812 &sc->dmat); in thunder_pem_attach()
816 /* Map SLI, do it only once */ in thunder_pem_attach()
818 bus_space_map(sc->reg_bst, SLIX_S2M_REGX_ACC, in thunder_pem_attach()
822 bus_space_map(sc->reg_bst, SLIX_S2M_REGX_ACC + in thunder_pem_attach()
829 "bus_space_map failed to map slix_s2m_regx_base\n"); in thunder_pem_attach()
838 sc->mem_rman.rm_type = RMAN_ARRAY; in thunder_pem_attach()
839 sc->mem_rman.rm_descr = "PEM PCIe Memory"; in thunder_pem_attach()
840 error = rman_init(&sc->mem_rman); in thunder_pem_attach()
846 sc->io_rman.rm_type = RMAN_ARRAY; in thunder_pem_attach()
847 sc->io_rman.rm_descr = "PEM PCIe IO"; in thunder_pem_attach()
848 error = rman_init(&sc->io_rman); in thunder_pem_attach()
863 sc->ranges[0].pci_base = PCI_MEMORY_BASE; in thunder_pem_attach()
864 sc->ranges[0].size = PCI_MEMORY_SIZE; in thunder_pem_attach()
865 sc->ranges[0].phys_base = sc->sli_window_base + SLI_PCI_OFFSET + in thunder_pem_attach()
866 sc->ranges[0].pci_base; in thunder_pem_attach()
867 sc->ranges[0].flags = SYS_RES_MEMORY; in thunder_pem_attach()
870 sc->ranges[1].pci_base = PCI_IO_BASE; in thunder_pem_attach()
871 sc->ranges[1].size = PCI_IO_SIZE; in thunder_pem_attach()
872 sc->ranges[1].phys_base = sc->sli_window_base + SLI_PCI_OFFSET + in thunder_pem_attach()
873 sc->ranges[1].pci_base; in thunder_pem_attach()
874 sc->ranges[1].flags = SYS_RES_IOPORT; in thunder_pem_attach()
877 base = sc->ranges[tuple].pci_base; in thunder_pem_attach()
878 size = sc->ranges[tuple].size; in thunder_pem_attach()
880 continue; /* empty range element */ in thunder_pem_attach()
882 rman = thunder_pem_get_rman(dev, sc->ranges[tuple].flags, 0); in thunder_pem_attach()
885 base + size - 1); in thunder_pem_attach()
891 rman_fini(&sc->mem_rman); in thunder_pem_attach()
897 sc->ranges[tuple].pci_base, in thunder_pem_attach()
898 sc->ranges[tuple].phys_base, in thunder_pem_attach()
899 sc->ranges[tuple].size, in thunder_pem_attach()
900 sc->ranges[tuple].flags); in thunder_pem_attach()
914 rman_fini(&sc->io_rman); in thunder_pem_attach()
916 rman_fini(&sc->mem_rman); in thunder_pem_attach()
918 bus_free_resource(dev, SYS_RES_MEMORY, sc->reg); in thunder_pem_attach()
929 rman_fini(&sc->io_rman); in thunder_pem_release_all()
930 rman_fini(&sc->mem_rman); in thunder_pem_release_all()
932 if (sc->reg != NULL) in thunder_pem_release_all()
933 bus_free_resource(dev, SYS_RES_MEMORY, sc->reg); in thunder_pem_release_all()