Lines Matching +full:non +full:- +full:negative
1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2016-2019 HabanaLabs, Ltd.
21 * hl_pci_bars_map() - Map PCI BARs.
24 * @is_wc: Array with flag per BAR whether a write-combined mapping is needed.
28 * Return: 0 on success, non-zero for failure.
33 struct pci_dev *pdev = hdev->pdev; in hl_pci_bars_map()
38 dev_err(hdev->dev, "Cannot obtain PCI resources\n"); in hl_pci_bars_map()
43 bar = i * 2; /* 64-bit BARs */ in hl_pci_bars_map()
44 hdev->pcie_bar[bar] = is_wc[i] ? in hl_pci_bars_map()
47 if (!hdev->pcie_bar[bar]) { in hl_pci_bars_map()
48 dev_err(hdev->dev, "pci_ioremap%s_bar failed for %s\n", in hl_pci_bars_map()
50 rc = -ENODEV; in hl_pci_bars_map()
58 for (i = 2 ; i >= 0 ; i--) { in hl_pci_bars_map()
59 bar = i * 2; /* 64-bit BARs */ in hl_pci_bars_map()
60 if (hdev->pcie_bar[bar]) in hl_pci_bars_map()
61 iounmap(hdev->pcie_bar[bar]); in hl_pci_bars_map()
70 * hl_pci_bars_unmap() - Unmap PCI BARS.
77 struct pci_dev *pdev = hdev->pdev; in hl_pci_bars_unmap()
80 for (i = 2 ; i >= 0 ; i--) { in hl_pci_bars_unmap()
81 bar = i * 2; /* 64-bit BARs */ in hl_pci_bars_unmap()
82 iounmap(hdev->pcie_bar[bar]); in hl_pci_bars_unmap()
89 * hl_pci_elbi_write() - Write through the ELBI interface.
94 * Return: 0 on success, negative value for failure.
98 struct pci_dev *pdev = hdev->pdev; in hl_pci_elbi_write()
103 if (hdev->pldm) in hl_pci_elbi_write()
134 return -EIO; in hl_pci_elbi_write()
137 dev_err(hdev->dev, "ELBI write didn't finish in time\n"); in hl_pci_elbi_write()
138 return -EIO; in hl_pci_elbi_write()
141 dev_err(hdev->dev, "ELBI write has undefined bits in status\n"); in hl_pci_elbi_write()
142 return -EIO; in hl_pci_elbi_write()
146 * hl_pci_iatu_write() - iatu write routine.
151 * Return: 0 on success, negative value for failure.
155 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_pci_iatu_write()
164 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0x00300000); in hl_pci_iatu_write()
166 rc = hl_pci_elbi_write(hdev, prop->pcie_dbi_base_address + dbi_offset, in hl_pci_iatu_write()
170 return -EIO; in hl_pci_iatu_write()
176 * hl_pci_reset_link_through_bridge() - Reset PCI link.
181 struct pci_dev *pdev = hdev->pdev; in hl_pci_reset_link_through_bridge()
185 parent_port = pdev->bus->self; in hl_pci_reset_link_through_bridge()
197 * hl_pci_set_inbound_region() - Configure inbound region
204 * Return: 0 on success, negative value for failure.
209 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_pci_set_inbound_region()
217 if (pci_region->mode == PCI_ADDRESS_MATCH_MODE) { in hl_pci_set_inbound_region()
218 bar_phys_base = hdev->pcie_bar_phys[pci_region->bar]; in hl_pci_set_inbound_region()
219 region_base = bar_phys_base + pci_region->offset_in_bar; in hl_pci_set_inbound_region()
220 region_end_address = region_base + pci_region->size - 1; in hl_pci_set_inbound_region()
232 lower_32_bits(pci_region->addr)); in hl_pci_set_inbound_region()
234 upper_32_bits(pci_region->addr)); in hl_pci_set_inbound_region()
240 pci_region->mode); in hl_pci_set_inbound_region()
243 if (pci_region->mode == PCI_BAR_MATCH_MODE) in hl_pci_set_inbound_region()
245 pci_region->bar); in hl_pci_set_inbound_region()
253 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0); in hl_pci_set_inbound_region()
256 dev_err(hdev->dev, "failed to map bar %u to 0x%08llx\n", in hl_pci_set_inbound_region()
257 pci_region->bar, pci_region->addr); in hl_pci_set_inbound_region()
263 * hl_pci_set_outbound_region() - Configure outbound region 0
269 * Return: 0 on success, negative value for failure.
274 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_pci_set_outbound_region()
280 pci_region->addr + pci_region->size - 1; in hl_pci_set_outbound_region()
282 lower_32_bits(pci_region->addr)); in hl_pci_set_outbound_region()
284 upper_32_bits(pci_region->addr)); in hl_pci_set_outbound_region()
289 if ((hdev->power9_64bit_dma_enable) && (hdev->dma_mask == 64)) in hl_pci_set_outbound_region()
305 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0); in hl_pci_set_outbound_region()
311 * hl_pci_set_dma_mask() - Set DMA masks for the device.
315 * value. If it doesn't succeed, it tries to set it to a fall-back value
317 * Return: 0 on success, non-zero for failure.
321 struct pci_dev *pdev = hdev->pdev; in hl_pci_set_dma_mask()
325 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask)); in hl_pci_set_dma_mask()
327 dev_err(hdev->dev, in hl_pci_set_dma_mask()
329 hdev->dma_mask, rc); in hl_pci_set_dma_mask()
333 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask)); in hl_pci_set_dma_mask()
335 dev_err(hdev->dev, in hl_pci_set_dma_mask()
337 hdev->dma_mask, rc); in hl_pci_set_dma_mask()
345 * hl_pci_init() - PCI initialization code.
354 * Return: 0 on success, non-zero for failure.
359 struct pci_dev *pdev = hdev->pdev; in hl_pci_init()
362 if (hdev->reset_pcilink) in hl_pci_init()
367 dev_err(hdev->dev, "can't enable PCI device\n"); in hl_pci_init()
373 rc = hdev->asic_funcs->pci_bars_map(hdev); in hl_pci_init()
375 dev_err(hdev->dev, "Failed to initialize PCI BARs\n"); in hl_pci_init()
379 rc = hdev->asic_funcs->init_iatu(hdev); in hl_pci_init()
381 dev_err(hdev->dev, "Failed to initialize iATU\n"); in hl_pci_init()
390 * version to determine whether we run with a security-enabled firmware in hl_pci_init()
410 * hl_fw_fini() - PCI finalization code.
419 pci_clear_master(hdev->pdev); in hl_pci_fini()
420 pci_disable_device(hdev->pdev); in hl_pci_fini()