Lines Matching +full:device +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0-only
8 #include <linux/device.h>
20 #define VALID_MSIX_IDX(attr, msix_index) ((msix_index) < (attr)->num_irqs)
27 * hinic_msix_attr_set - set message attribute for msix entry
28 * @hwif: the HW interface of a pci function device
36 * Return 0 - Success, negative - Failure
43 u32 msix_ctrl, addr; in hinic_msix_attr_set() local
45 if (!VALID_MSIX_IDX(&hwif->attr, msix_index)) in hinic_msix_attr_set()
46 return -EINVAL; in hinic_msix_attr_set()
54 addr = HINIC_CSR_MSIX_CTRL_ADDR(msix_index); in hinic_msix_attr_set()
56 hinic_hwif_write_reg(hwif, addr, msix_ctrl); in hinic_msix_attr_set()
61 * hinic_msix_attr_cnt_clear - clear message attribute counters for msix entry
62 * @hwif: the HW interface of a pci function device
65 * Return 0 - Success, negative - Failure
69 u32 msix_ctrl, addr; in hinic_msix_attr_cnt_clear() local
71 if (!VALID_MSIX_IDX(&hwif->attr, msix_index)) in hinic_msix_attr_cnt_clear()
72 return -EINVAL; in hinic_msix_attr_cnt_clear()
75 addr = HINIC_CSR_MSIX_CNT_ADDR(msix_index); in hinic_msix_attr_cnt_clear()
77 hinic_hwif_write_reg(hwif, addr, msix_ctrl); in hinic_msix_attr_cnt_clear()
82 * hinic_set_pf_action - set action on pf channel
83 * @hwif: the HW interface of a pci function device
143 mask_bits = readl(hwif->intr_regs_base + offset); in hinic_set_msix_state()
149 writel(mask_bits, hwif->intr_regs_base + offset); in hinic_set_msix_state()
153 * hwif_ready - test if the HW is ready for use
154 * @hwif: the HW interface of a pci function device
156 * Return 0 - Success, negative - Failure
160 u32 addr, attr1; in hwif_ready() local
162 addr = HINIC_CSR_FUNC_ATTR1_ADDR; in hwif_ready()
163 attr1 = hinic_hwif_read_reg(hwif, addr); in hwif_ready()
166 return -EBUSY; in hwif_ready()
170 return -EBUSY; in hwif_ready()
188 dev_err(&hwif->pdev->dev, "Wait for hwif timeout\n"); in wait_hwif_ready()
190 return -EBUSY; in wait_hwif_ready()
194 * set_hwif_attr - set the attributes in the relevant members in hwif
195 * @hwif: the HW interface of a pci function device
203 hwif->attr.func_idx = HINIC_FA0_GET(attr0, FUNC_IDX); in set_hwif_attr()
204 hwif->attr.pf_idx = HINIC_FA0_GET(attr0, PF_IDX); in set_hwif_attr()
205 hwif->attr.pci_intf_idx = HINIC_FA0_GET(attr0, PCI_INTF_IDX); in set_hwif_attr()
206 hwif->attr.func_type = HINIC_FA0_GET(attr0, FUNC_TYPE); in set_hwif_attr()
208 hwif->attr.num_aeqs = BIT(HINIC_FA1_GET(attr1, AEQS_PER_FUNC)); in set_hwif_attr()
209 hwif->attr.num_ceqs = BIT(HINIC_FA1_GET(attr1, CEQS_PER_FUNC)); in set_hwif_attr()
210 hwif->attr.num_irqs = BIT(HINIC_FA1_GET(attr1, IRQS_PER_FUNC)); in set_hwif_attr()
211 hwif->attr.num_dma_attr = BIT(HINIC_FA1_GET(attr1, DMA_ATTR_PER_FUNC)); in set_hwif_attr()
212 hwif->attr.global_vf_id_of_pf = HINIC_FA2_GET(attr2, in set_hwif_attr()
217 * read_hwif_attr - read the attributes and set members in hwif
218 * @hwif: the HW interface of a pci function device
222 u32 addr, attr0, attr1, attr2; in read_hwif_attr() local
224 addr = HINIC_CSR_FUNC_ATTR0_ADDR; in read_hwif_attr()
225 attr0 = hinic_hwif_read_reg(hwif, addr); in read_hwif_attr()
227 addr = HINIC_CSR_FUNC_ATTR1_ADDR; in read_hwif_attr()
228 attr1 = hinic_hwif_read_reg(hwif, addr); in read_hwif_attr()
230 addr = HINIC_CSR_FUNC_ATTR2_ADDR; in read_hwif_attr()
231 attr2 = hinic_hwif_read_reg(hwif, addr); in read_hwif_attr()
237 * set_ppf - try to set hwif as ppf and set the type of hwif in this case
238 * @hwif: the HW interface of a pci function device
242 struct hinic_func_attr *attr = &hwif->attr; in set_ppf()
243 u32 addr, val, ppf_election; in set_ppf() local
246 addr = HINIC_CSR_PPF_ELECTION_ADDR(HINIC_HWIF_PCI_INTF(hwif)); in set_ppf()
248 val = hinic_hwif_read_reg(hwif, addr); in set_ppf()
254 hinic_hwif_write_reg(hwif, addr, val); in set_ppf()
257 val = hinic_hwif_read_reg(hwif, addr); in set_ppf()
259 attr->ppf_idx = HINIC_PPF_ELECTION_GET(val, IDX); in set_ppf()
260 if (attr->ppf_idx == HINIC_HWIF_FUNC_IDX(hwif)) in set_ppf()
261 attr->func_type = HINIC_PPF; in set_ppf()
265 * set_dma_attr - set the dma attributes in the HW
266 * @hwif: the HW interface of a pci function device
279 u32 addr, val, dma_attr_entry; in set_dma_attr() local
282 addr = HINIC_CSR_DMA_ATTR_ADDR(entry_idx); in set_dma_attr()
284 val = hinic_hwif_read_reg(hwif, addr); in set_dma_attr()
298 hinic_hwif_write_reg(hwif, addr, val); in set_dma_attr()
302 * dma_attr_init - initialize the default dma attributes
303 * @hwif: the HW interface of a pci function device
317 return hwif->attr.global_vf_id_of_pf; in hinic_glb_pf_vf_offset()
322 u32 addr, attr0; in hinic_global_func_id_hw() local
324 addr = HINIC_CSR_FUNC_ATTR0_ADDR; in hinic_global_func_id_hw()
325 attr0 = hinic_hwif_read_reg(hwif, addr); in hinic_global_func_id_hw()
332 u32 addr, attr0; in hinic_pf_id_of_vf_hw() local
334 addr = HINIC_CSR_FUNC_ATTR0_ADDR; in hinic_pf_id_of_vf_hw()
335 attr0 = hinic_hwif_read_reg(hwif, addr); in hinic_pf_id_of_vf_hw()
342 u32 addr, attr0, attr1; in __print_selftest_reg() local
344 addr = HINIC_CSR_FUNC_ATTR1_ADDR; in __print_selftest_reg()
345 attr1 = hinic_hwif_read_reg(hwif, addr); in __print_selftest_reg()
348 dev_err(&hwif->pdev->dev, "PCIE is link down\n"); in __print_selftest_reg()
352 addr = HINIC_CSR_FUNC_ATTR0_ADDR; in __print_selftest_reg()
353 attr0 = hinic_hwif_read_reg(hwif, addr); in __print_selftest_reg()
356 dev_err(&hwif->pdev->dev, "Selftest reg: 0x%08x\n", in __print_selftest_reg()
361 * hinic_init_hwif - initialize the hw interface
362 * @hwif: the HW interface of a pci function device
363 * @pdev: the pci device for accessing PCI resources
365 * Return 0 - Success, negative - Failure
371 hwif->pdev = pdev; in hinic_init_hwif()
373 hwif->cfg_regs_bar = pci_ioremap_bar(pdev, HINIC_PCI_CFG_REGS_BAR); in hinic_init_hwif()
374 if (!hwif->cfg_regs_bar) { in hinic_init_hwif()
375 dev_err(&pdev->dev, "Failed to map configuration regs\n"); in hinic_init_hwif()
376 return -ENOMEM; in hinic_init_hwif()
379 hwif->intr_regs_base = pci_ioremap_bar(pdev, HINIC_PCI_INTR_REGS_BAR); in hinic_init_hwif()
380 if (!hwif->intr_regs_base) { in hinic_init_hwif()
381 dev_err(&pdev->dev, "Failed to map configuration regs\n"); in hinic_init_hwif()
382 err = -ENOMEM; in hinic_init_hwif()
388 dev_err(&pdev->dev, "HW interface is not ready\n"); in hinic_init_hwif()
403 iounmap(hwif->intr_regs_base); in hinic_init_hwif()
406 iounmap(hwif->cfg_regs_bar); in hinic_init_hwif()
412 * hinic_free_hwif - free the HW interface
413 * @hwif: the HW interface of a pci function device
417 iounmap(hwif->intr_regs_base); in hinic_free_hwif()
418 iounmap(hwif->cfg_regs_bar); in hinic_free_hwif()