dm: PTM: Add a few pci utility functions

Add a few pci utility functions to help easy access of pci
    functionalities.
    1. pci_find_capability(): find position of specified pci capability register
    2. pci_find_ext_cap(): find extend capability register position from cap_id
    3. pci_pcie_type(): find pci-e device type
    4. is_root_port(): check whether pdev is a pci root port
    5. is_bridge(): check whether pdev is a bridge

Tracked-On: #5915
Signed-off-by: Rong Liu <rong.l.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Rong Liu
2021-04-28 21:08:59 +00:00
committed by wenlingz
parent 1e033f9d89
commit d3185f8a0c
3 changed files with 124 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2021 Intel Corporation.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#ifndef __PCI_UTIL_H
#define __PCI_UTIL_H
#include <stdbool.h>
#include "pciaccess.h"
int pci_find_cap(struct pci_device *pdev, const int cap_id);
int pci_find_ext_cap(struct pci_device *pdev, int cap_id);
int pci_get_pcie_type(struct pci_device *dev);
bool is_root_port(struct pci_device *pdev);
bool is_bridge(struct pci_device *pdev);
#endif