// SPDX-License-Identifier: GPL-2.0 /* * Copyright 2016-2019 HabanaLabs, Ltd. * All Rights Reserved. */ #include "../habanalabs.h" #include "../../include/hw_ip/pci/pci_general.h" #include <linux/pci.h> #include <trace/events/habanalabs.h> #define HL_PLDM_PCI_ELBI_TIMEOUT_MSEC … #define IATU_REGION_CTRL_REGION_EN_MASK … #define IATU_REGION_CTRL_MATCH_MODE_MASK … #define IATU_REGION_CTRL_NUM_MATCH_EN_MASK … #define IATU_REGION_CTRL_BAR_NUM_MASK … /** * hl_pci_bars_map() - Map PCI BARs. * @hdev: Pointer to hl_device structure. * @name: Array of BAR names. * @is_wc: Array with flag per BAR whether a write-combined mapping is needed. * * Request PCI regions and map them to kernel virtual addresses. * * Return: 0 on success, non-zero for failure. */ int hl_pci_bars_map(struct hl_device *hdev, const char * const name[3], bool is_wc[3]) { … } /** * hl_pci_bars_unmap() - Unmap PCI BARS. * @hdev: Pointer to hl_device structure. * * Release all PCI BARs and unmap their virtual addresses. */ static void hl_pci_bars_unmap(struct hl_device *hdev) { … } int hl_pci_elbi_read(struct hl_device *hdev, u64 addr, u32 *data) { … } /** * hl_pci_elbi_write() - Write through the ELBI interface. * @hdev: Pointer to hl_device structure. * @addr: Address to write to * @data: Data to write * * Return: 0 on success, negative value for failure. */ static int hl_pci_elbi_write(struct hl_device *hdev, u64 addr, u32 data) { … } /** * hl_pci_iatu_write() - iatu write routine. * @hdev: Pointer to hl_device structure. * @addr: Address to write to * @data: Data to write * * Return: 0 on success, negative value for failure. */ int hl_pci_iatu_write(struct hl_device *hdev, u32 addr, u32 data) { … } /** * hl_pci_set_inbound_region() - Configure inbound region * @hdev: Pointer to hl_device structure. * @region: Inbound region number. * @pci_region: Inbound region parameters. * * Configure the iATU inbound region. * * Return: 0 on success, negative value for failure. */ int hl_pci_set_inbound_region(struct hl_device *hdev, u8 region, struct hl_inbound_pci_region *pci_region) { … } /** * hl_pci_set_outbound_region() - Configure outbound region 0 * @hdev: Pointer to hl_device structure. * @pci_region: Outbound region parameters. * * Configure the iATU outbound region 0. * * Return: 0 on success, negative value for failure. */ int hl_pci_set_outbound_region(struct hl_device *hdev, struct hl_outbound_pci_region *pci_region) { … } /** * hl_get_pci_memory_region() - get PCI region for given address * @hdev: Pointer to hl_device structure. * @addr: device address * * @return region index on success, otherwise PCI_REGION_NUMBER (invalid * region index) */ enum pci_region hl_get_pci_memory_region(struct hl_device *hdev, u64 addr) { … } /** * hl_pci_init() - PCI initialization code. * @hdev: Pointer to hl_device structure. * * Set DMA masks, initialize the PCI controller and map the PCI BARs. * * Return: 0 on success, non-zero for failure. */ int hl_pci_init(struct hl_device *hdev) { … } /** * hl_pci_fini() - PCI finalization code. * @hdev: Pointer to hl_device structure * * Unmap PCI bars and disable PCI device. */ void hl_pci_fini(struct hl_device *hdev) { … }