Lines Matching refs:hdev
32 int hl_pci_bars_map(struct hl_device *hdev, const char * const name[3], in hl_pci_bars_map() argument
35 struct pci_dev *pdev = hdev->pdev; in hl_pci_bars_map()
40 dev_err(hdev->dev, "Cannot obtain PCI resources\n"); in hl_pci_bars_map()
46 hdev->pcie_bar[bar] = is_wc[i] ? in hl_pci_bars_map()
49 if (!hdev->pcie_bar[bar]) { in hl_pci_bars_map()
50 dev_err(hdev->dev, "pci_ioremap%s_bar failed for %s\n", in hl_pci_bars_map()
62 if (hdev->pcie_bar[bar]) in hl_pci_bars_map()
63 iounmap(hdev->pcie_bar[bar]); in hl_pci_bars_map()
77 static void hl_pci_bars_unmap(struct hl_device *hdev) in hl_pci_bars_unmap() argument
79 struct pci_dev *pdev = hdev->pdev; in hl_pci_bars_unmap()
84 iounmap(hdev->pcie_bar[bar]); in hl_pci_bars_unmap()
90 int hl_pci_elbi_read(struct hl_device *hdev, u64 addr, u32 *data) in hl_pci_elbi_read() argument
92 struct pci_dev *pdev = hdev->pdev; in hl_pci_elbi_read()
97 if (hdev->pldm) in hl_pci_elbi_read()
126 trace_habanalabs_elbi_read(&hdev->pdev->dev, (u32) addr, val); in hl_pci_elbi_read()
132 dev_err(hdev->dev, "Error reading from ELBI\n"); in hl_pci_elbi_read()
137 dev_err(hdev->dev, "ELBI read didn't finish in time\n"); in hl_pci_elbi_read()
141 dev_err(hdev->dev, "ELBI read has undefined bits in status\n"); in hl_pci_elbi_read()
153 static int hl_pci_elbi_write(struct hl_device *hdev, u64 addr, u32 data) in hl_pci_elbi_write() argument
155 struct pci_dev *pdev = hdev->pdev; in hl_pci_elbi_write()
160 if (hdev->pldm) in hl_pci_elbi_write()
189 trace_habanalabs_elbi_write(&hdev->pdev->dev, (u32) addr, val); in hl_pci_elbi_write()
197 dev_err(hdev->dev, "ELBI write didn't finish in time\n"); in hl_pci_elbi_write()
201 dev_err(hdev->dev, "ELBI write has undefined bits in status\n"); in hl_pci_elbi_write()
213 int hl_pci_iatu_write(struct hl_device *hdev, u32 addr, u32 data) in hl_pci_iatu_write() argument
215 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_pci_iatu_write()
224 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0x00300000); in hl_pci_iatu_write()
226 rc = hl_pci_elbi_write(hdev, prop->pcie_dbi_base_address + dbi_offset, in hl_pci_iatu_write()
245 int hl_pci_set_inbound_region(struct hl_device *hdev, u8 region, in hl_pci_set_inbound_region() argument
248 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_pci_set_inbound_region()
257 bar_phys_base = hdev->pcie_bar_phys[pci_region->bar]; in hl_pci_set_inbound_region()
261 rc |= hl_pci_iatu_write(hdev, offset + 0x8, in hl_pci_set_inbound_region()
263 rc |= hl_pci_iatu_write(hdev, offset + 0xC, in hl_pci_set_inbound_region()
265 rc |= hl_pci_iatu_write(hdev, offset + 0x10, in hl_pci_set_inbound_region()
270 rc |= hl_pci_iatu_write(hdev, offset + 0x14, lower_32_bits(pci_region->addr)); in hl_pci_set_inbound_region()
271 rc |= hl_pci_iatu_write(hdev, offset + 0x18, upper_32_bits(pci_region->addr)); in hl_pci_set_inbound_region()
274 rc |= hl_pci_iatu_write(hdev, offset + 0x0, 0); in hl_pci_set_inbound_region()
284 rc |= hl_pci_iatu_write(hdev, offset + 0x4, ctrl_reg_val); in hl_pci_set_inbound_region()
290 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0); in hl_pci_set_inbound_region()
293 dev_err(hdev->dev, "failed to map bar %u to 0x%08llx\n", in hl_pci_set_inbound_region()
308 int hl_pci_set_outbound_region(struct hl_device *hdev, in hl_pci_set_outbound_region() argument
311 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_pci_set_outbound_region()
318 rc |= hl_pci_iatu_write(hdev, 0x008, in hl_pci_set_outbound_region()
320 rc |= hl_pci_iatu_write(hdev, 0x00C, in hl_pci_set_outbound_region()
322 rc |= hl_pci_iatu_write(hdev, 0x010, in hl_pci_set_outbound_region()
324 rc |= hl_pci_iatu_write(hdev, 0x014, 0); in hl_pci_set_outbound_region()
326 rc |= hl_pci_iatu_write(hdev, 0x018, 0); in hl_pci_set_outbound_region()
328 rc |= hl_pci_iatu_write(hdev, 0x020, in hl_pci_set_outbound_region()
331 rc |= hl_pci_iatu_write(hdev, 0x000, 0x00002000); in hl_pci_set_outbound_region()
333 rc |= hl_pci_iatu_write(hdev, 0x004, 0x80000000); in hl_pci_set_outbound_region()
339 hl_pci_elbi_write(hdev, prop->pcie_aux_dbi_reg_addr, 0); in hl_pci_set_outbound_region()
352 enum pci_region hl_get_pci_memory_region(struct hl_device *hdev, u64 addr) in hl_get_pci_memory_region() argument
357 struct pci_mem_region *region = &hdev->pci_mem_region[i]; in hl_get_pci_memory_region()
378 int hl_pci_init(struct hl_device *hdev) in hl_pci_init() argument
380 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_pci_init()
381 struct pci_dev *pdev = hdev->pdev; in hl_pci_init()
386 dev_err(hdev->dev, "can't enable PCI device\n"); in hl_pci_init()
392 rc = hdev->asic_funcs->pci_bars_map(hdev); in hl_pci_init()
394 dev_err(hdev->dev, "Failed to map PCI BAR addresses\n"); in hl_pci_init()
398 rc = hdev->asic_funcs->init_iatu(hdev); in hl_pci_init()
400 dev_err(hdev->dev, "PCI controller was not initialized successfully\n"); in hl_pci_init()
405 if (hdev->asic_prop.iatu_done_by_fw) in hl_pci_init()
410 dev_err(hdev->dev, in hl_pci_init()
421 hl_pci_bars_unmap(hdev); in hl_pci_init()
434 void hl_pci_fini(struct hl_device *hdev) in hl_pci_fini() argument
436 hl_pci_bars_unmap(hdev); in hl_pci_fini()
438 pci_disable_device(hdev->pdev); in hl_pci_fini()