Lines Matching defs:hdev

22  * @hdev: Pointer to hl_device structure.
30 int hl_pci_bars_map(struct hl_device *hdev, const char * const name[3],
33 struct pci_dev *pdev = hdev->pdev;
38 dev_err(hdev->dev, "Cannot obtain PCI resources\n");
44 hdev->pcie_bar[bar] = is_wc[i] ?
47 if (!hdev->pcie_bar[bar]) {
48 dev_err(hdev->dev, "pci_ioremap%s_bar failed for %s\n",
60 if (hdev->pcie_bar[bar])
61 iounmap(hdev->pcie_bar[bar]);
71 * @hdev: Pointer to hl_device structure.
75 static void hl_pci_bars_unmap(struct hl_device *hdev)
77 struct pci_dev *pdev = hdev->pdev;
82 iounmap(hdev->pcie_bar[bar]);
90 * @hdev: Pointer to hl_device structure.
96 static int hl_pci_elbi_write(struct hl_device *hdev, u64 addr, u32 data)
98 struct pci_dev *pdev = hdev->pdev;
103 if (hdev->pldm)
137 dev_err(hdev->dev, "ELBI write didn't finish in time\n");
141 dev_err(hdev->dev, "ELBI write has undefined bits in status\n");
147 * @hdev: Pointer to hl_device structure.
153 int hl_pci_iatu_write(struct hl_device *hdev, u32 addr, u32 data)
155 struct asic_fixed_properties *prop = &hdev->asic_prop;
164 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0x00300000);
166 rc = hl_pci_elbi_write(hdev, prop->pcie_dbi_base_address + dbi_offset,
177 * @hdev: Pointer to hl_device structure.
179 static void hl_pci_reset_link_through_bridge(struct hl_device *hdev)
181 struct pci_dev *pdev = hdev->pdev;
198 * @hdev: Pointer to hl_device structure.
206 int hl_pci_set_inbound_region(struct hl_device *hdev, u8 region,
209 struct asic_fixed_properties *prop = &hdev->asic_prop;
218 bar_phys_base = hdev->pcie_bar_phys[pci_region->bar];
222 rc |= hl_pci_iatu_write(hdev, offset + 0x8,
224 rc |= hl_pci_iatu_write(hdev, offset + 0xC,
226 rc |= hl_pci_iatu_write(hdev, offset + 0x10,
231 rc |= hl_pci_iatu_write(hdev, offset + 0x14,
233 rc |= hl_pci_iatu_write(hdev, offset + 0x18,
235 rc |= hl_pci_iatu_write(hdev, offset + 0x0, 0);
247 rc |= hl_pci_iatu_write(hdev, offset + 0x4, ctrl_reg_val);
253 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0);
256 dev_err(hdev->dev, "failed to map bar %u to 0x%08llx\n",
264 * @hdev: Pointer to hl_device structure.
271 int hl_pci_set_outbound_region(struct hl_device *hdev,
274 struct asic_fixed_properties *prop = &hdev->asic_prop;
281 rc |= hl_pci_iatu_write(hdev, 0x008,
283 rc |= hl_pci_iatu_write(hdev, 0x00C,
285 rc |= hl_pci_iatu_write(hdev, 0x010,
287 rc |= hl_pci_iatu_write(hdev, 0x014, 0);
289 if ((hdev->power9_64bit_dma_enable) && (hdev->dma_mask == 64))
290 rc |= hl_pci_iatu_write(hdev, 0x018, 0x08000000);
292 rc |= hl_pci_iatu_write(hdev, 0x018, 0);
294 rc |= hl_pci_iatu_write(hdev, 0x020,
297 rc |= hl_pci_iatu_write(hdev, 0x000, 0x00002000);
299 rc |= hl_pci_iatu_write(hdev, 0x004, 0x80000000);
305 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0);
312 * @hdev: Pointer to hl_device structure.
319 static int hl_pci_set_dma_mask(struct hl_device *hdev)
321 struct pci_dev *pdev = hdev->pdev;
325 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
327 dev_err(hdev->dev,
329 hdev->dma_mask, rc);
333 rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(hdev->dma_mask));
335 dev_err(hdev->dev,
337 hdev->dma_mask, rc);
346 * @hdev: Pointer to hl_device structure.
356 int hl_pci_init(struct hl_device *hdev, u32 cpu_boot_status_reg,
359 struct pci_dev *pdev = hdev->pdev;
362 if (hdev->reset_pcilink)
363 hl_pci_reset_link_through_bridge(hdev);
367 dev_err(hdev->dev, "can't enable PCI device\n");
373 rc = hdev->asic_funcs->pci_bars_map(hdev);
375 dev_err(hdev->dev, "Failed to initialize PCI BARs\n");
379 rc = hdev->asic_funcs->init_iatu(hdev);
381 dev_err(hdev->dev, "Failed to initialize iATU\n");
385 rc = hl_pci_set_dma_mask(hdev);
393 rc = hl_fw_read_preboot_ver(hdev, cpu_boot_status_reg, boot_err0_reg,
401 hl_pci_bars_unmap(hdev);
411 * @hdev: Pointer to hl_device structure
415 void hl_pci_fini(struct hl_device *hdev)
417 hl_pci_bars_unmap(hdev);
419 pci_clear_master(hdev->pdev);
420 pci_disable_device(hdev->pdev);