LCOV - code coverage report
Current view: top level - include - pci.h (source / functions) Hit Total Coverage
Test: skiboot.info Lines: 0 2 0.0 %
Date: 2024-01-02 21:04:04 Functions: 0 1 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
       2                 :            : /* Copyright 2013-2019 IBM Corp. */
       3                 :            : 
       4                 :            : #ifndef __PCI_H
       5                 :            : #define __PCI_H
       6                 :            : 
       7                 :            : #include <opal.h>
       8                 :            : #include <device.h>
       9                 :            : #include <lock.h>
      10                 :            : #include <bitmap.h>
      11                 :            : #include <ccan/list/list.h>
      12                 :            : 
      13                 :            : #define PCITRACE(_p, _bdfn, fmt, a...) \
      14                 :            :         prlog(PR_TRACE, "PHB#%04x:%02x:%02x.%x " fmt, \
      15                 :            :               (_p)->opal_id,                         \
      16                 :            :               PCI_BUS_NUM(_bdfn),                       \
      17                 :            :               PCI_DEV(_bdfn), PCI_FUNC(_bdfn), ## a)
      18                 :            : #define PCIDBG(_p, _bdfn, fmt, a...) \
      19                 :            :         prlog(PR_DEBUG, "PHB#%04x:%02x:%02x.%x " fmt, \
      20                 :            :               (_p)->opal_id,                         \
      21                 :            :               PCI_BUS_NUM(_bdfn),                       \
      22                 :            :               PCI_DEV(_bdfn), PCI_FUNC(_bdfn), ## a)
      23                 :            : #define PCINOTICE(_p, _bdfn, fmt, a...) \
      24                 :            :         prlog(PR_NOTICE, "PHB#%04x:%02x:%02x.%x " fmt,        \
      25                 :            :               (_p)->opal_id,                         \
      26                 :            :               PCI_BUS_NUM(_bdfn),                       \
      27                 :            :               PCI_DEV(_bdfn), PCI_FUNC(_bdfn), ## a)
      28                 :            : #define PCIERR(_p, _bdfn, fmt, a...) \
      29                 :            :         prlog(PR_ERR, "PHB#%04x:%02x:%02x.%x " fmt,   \
      30                 :            :               (_p)->opal_id,                         \
      31                 :            :               PCI_BUS_NUM(_bdfn),                       \
      32                 :            :               PCI_DEV(_bdfn), PCI_FUNC(_bdfn), ## a)
      33                 :            : 
      34                 :            : struct pci_device;
      35                 :            : struct pci_cfg_reg_filter;
      36                 :            : 
      37                 :            : typedef int64_t (*pci_cfg_reg_func)(void *dev,
      38                 :            :                                     struct pci_cfg_reg_filter *pcrf,
      39                 :            :                                     uint32_t offset, uint32_t len,
      40                 :            :                                     uint32_t *data, bool write);
      41                 :            : typedef void (*pci_cap_free_data_func)(void *data);
      42                 :            : struct pci_cfg_reg_filter {
      43                 :            :         uint32_t                flags;
      44                 :            : #define PCI_REG_FLAG_READ       0x1
      45                 :            : #define PCI_REG_FLAG_WRITE      0x2
      46                 :            : #define PCI_REG_FLAG_MASK       0x3
      47                 :            :         uint32_t                start;
      48                 :            :         uint32_t                len;
      49                 :            :         uint8_t                 *data;
      50                 :            :         pci_cfg_reg_func        func;
      51                 :            :         struct list_node        link;
      52                 :            : };
      53                 :            : 
      54                 :            : /*
      55                 :            :  * While this might not be necessary in the long run, the existing
      56                 :            :  * Linux kernels expect us to provide a device-tree that contains
      57                 :            :  * a representation of all PCI devices below the host bridge. Thus
      58                 :            :  * we need to perform a bus scan. We don't need to assign MMIO/IO
      59                 :            :  * resources, but we do need to assign bus numbers in a way that
      60                 :            :  * is going to be compatible with the HW constraints for PE filtering
      61                 :            :  * that is naturally aligned power of twos for ranges below a bridge.
      62                 :            :  *
      63                 :            :  * Thus the structure pci_device is used for the tracking of the
      64                 :            :  * detected devices and the later generation of the device-tree.
      65                 :            :  *
      66                 :            :  * We do not keep a separate structure for a bus, however a device
      67                 :            :  * can have children in which case a device is a bridge.
      68                 :            :  *
      69                 :            :  * Because this is likely to change, we avoid putting too much
      70                 :            :  * information in that structure nor relying on it for anything
      71                 :            :  * else but the construction of the flat device-tree.
      72                 :            :  */
      73                 :            : struct pci_device {
      74                 :            :         uint16_t                bdfn;
      75                 :            :         bool                    is_bridge;
      76                 :            :         bool                    is_multifunction;
      77                 :            :         bool                    is_vf;
      78                 :            :         uint8_t                 dev_type; /* PCIE */
      79                 :            :         uint8_t                 primary_bus;
      80                 :            :         uint8_t                 secondary_bus;
      81                 :            :         uint8_t                 subordinate_bus;
      82                 :            :         uint32_t                scan_map;
      83                 :            : 
      84                 :            :         uint32_t                vdid;
      85                 :            :         uint32_t                sub_vdid;
      86                 :            : #define PCI_VENDOR_ID(x)        ((x) & 0xFFFF)
      87                 :            : #define PCI_DEVICE_ID(x)        ((x) >> 16)
      88                 :            :         uint32_t                class;
      89                 :            :         uint64_t                cap_list;
      90                 :            :         struct {
      91                 :            :                 uint32_t        pos;
      92                 :            :                 void            *data;
      93                 :            :                 pci_cap_free_data_func free_func;
      94                 :            :         } cap[64];
      95                 :            :         uint32_t                mps;            /* Max payload size capability */
      96                 :            : 
      97                 :            :         uint32_t                pcrf_start;
      98                 :            :         uint32_t                pcrf_end;
      99                 :            :         struct list_head        pcrf;
     100                 :            : 
     101                 :            :         /*
     102                 :            :          * Relaxed ordering is a feature which allows PCIe devices accessing GPU
     103                 :            :          * memory to bypass the normal PCIe ordering rules to increase
     104                 :            :          * performance. It is enabled on a per-PEC basis so every device on a
     105                 :            :          * PEC must support it before we can enable it.
     106                 :            :          */
     107                 :            :         bool                    allow_relaxed_ordering;
     108                 :            : 
     109                 :            :         struct dt_node          *dn;
     110                 :            :         struct pci_slot         *slot;
     111                 :            :         struct pci_device       *parent;
     112                 :            :         struct phb              *phb;
     113                 :            :         struct list_head        children;
     114                 :            :         struct list_node        link;
     115                 :            : };
     116                 :            : 
     117                 :            : static inline void pci_set_cap(struct pci_device *pd, int id, int pos,
     118                 :            :                                void *data, pci_cap_free_data_func free_func,
     119                 :            :                                bool ext)
     120                 :            : {
     121                 :            :         if (!ext) {
     122                 :            :                 pd->cap_list |= (0x1ul << id);
     123                 :            :                 pd->cap[id].pos = pos;
     124                 :            :                 pd->cap[id].data = data;
     125                 :            :                 pd->cap[id].free_func = free_func;
     126                 :            :         } else {
     127                 :            :                 pd->cap_list |= (0x1ul << (id + 32));
     128                 :            :                 pd->cap[id + 32].pos = pos;
     129                 :            :                 pd->cap[id + 32].data = data;
     130                 :            :                 pd->cap[id + 32].free_func = free_func;
     131                 :            :         }
     132                 :            : }
     133                 :            : 
     134                 :            : static inline bool pci_has_cap(struct pci_device *pd,
     135                 :            :                                int id, bool ext)
     136                 :            : {
     137                 :            :         if (!ext)
     138                 :            :                 return !!(pd->cap_list & (0x1ul << id));
     139                 :            :         else
     140                 :            :                 return !!(pd->cap_list & (0x1ul << (id + 32)));
     141                 :            : }
     142                 :            : 
     143                 :            : static inline int pci_cap(struct pci_device *pd,
     144                 :            :                           int id, bool ext)
     145                 :            : {
     146                 :            :         if (!ext)
     147                 :            :                 return pd->cap[id].pos;
     148                 :            :         else
     149                 :            :                 return pd->cap[id + 32].pos;
     150                 :            : }
     151                 :            : 
     152                 :            : static inline void *pci_cap_data(struct pci_device *pd, int id, bool ext)
     153                 :            : {
     154                 :            :         if (!ext)
     155                 :            :                 return pd->cap[id].data;
     156                 :            :         else
     157                 :            :                 return pd->cap[id + 32].data;
     158                 :            : }
     159                 :            : 
     160                 :            : /*
     161                 :            :  * When generating the device-tree, we need to keep track of
     162                 :            :  * the LSI mapping & swizzle it. This state structure is
     163                 :            :  * passed by the PHB to pci_add_nodes() and will be used
     164                 :            :  * internally.
     165                 :            :  *
     166                 :            :  * We assume that the interrupt parent (PIC) #address-cells
     167                 :            :  * is 0 and #interrupt-cells has a max value of 2.
     168                 :            :  */
     169                 :            : struct pci_lsi_state {
     170                 :            : #define MAX_INT_SIZE    2
     171                 :            :         uint32_t int_size;                      /* #cells */
     172                 :            :         uint32_t int_val[4][MAX_INT_SIZE];      /* INTA...INTD */
     173                 :            :         uint32_t int_parent[4];
     174                 :            : };
     175                 :            : 
     176                 :            : /*
     177                 :            :  * NOTE: All PCI functions return negative OPAL error codes
     178                 :            :  *
     179                 :            :  * In addition, some functions may return a positive timeout
     180                 :            :  * value or some other state information, see the description
     181                 :            :  * of individual functions. If nothing is specified, it's
     182                 :            :  * just an error code or 0 (success).
     183                 :            :  *
     184                 :            :  * Functions that operate asynchronously will return a positive
     185                 :            :  * delay value and will require the ->poll() op to be called after
     186                 :            :  * that delay. ->poll() will then return success, a negative error
     187                 :            :  * code, or another delay.
     188                 :            :  *
     189                 :            :  * Note: If an asynchronous function returns 0, it has completed
     190                 :            :  * successfully and does not require a call to ->poll(). Similarly
     191                 :            :  * if ->poll() is called while no operation is in progress, it will
     192                 :            :  * simply return 0 (success)
     193                 :            :  *
     194                 :            :  * Note that all functions except ->lock() itself assume that the
     195                 :            :  * caller is holding the PHB lock.
     196                 :            :  *
     197                 :            :  * TODO: Add more interfaces to control things like link width
     198                 :            :  *       reduction for power savings etc...
     199                 :            :  */
     200                 :            : 
     201                 :            : struct phb;
     202                 :            : extern int last_phb_id;
     203                 :            : 
     204                 :            : struct phb_ops {
     205                 :            :         /*
     206                 :            :          * Config space ops
     207                 :            :          */
     208                 :            :         int64_t (*cfg_read8)(struct phb *phb, uint32_t bdfn,
     209                 :            :                              uint32_t offset, uint8_t *data);
     210                 :            :         int64_t (*cfg_read16)(struct phb *phb, uint32_t bdfn,
     211                 :            :                               uint32_t offset, uint16_t *data);
     212                 :            :         int64_t (*cfg_read32)(struct phb *phb, uint32_t bdfn,
     213                 :            :                               uint32_t offset, uint32_t *data);
     214                 :            :         int64_t (*cfg_write8)(struct phb *phb, uint32_t bdfn,
     215                 :            :                               uint32_t offset, uint8_t data);
     216                 :            :         int64_t (*cfg_write16)(struct phb *phb, uint32_t bdfn,
     217                 :            :                                uint32_t offset, uint16_t data);
     218                 :            :         int64_t (*cfg_write32)(struct phb *phb, uint32_t bdfn,
     219                 :            :                                uint32_t offset, uint32_t data);
     220                 :            : 
     221                 :            :         int64_t (*get_reserved_pe_number)(struct phb *phb);
     222                 :            : 
     223                 :            :         /*
     224                 :            :          * Device init method is called after a device has been detected
     225                 :            :          * and before probing further. It can alter things like scan_map
     226                 :            :          * for bridge ports etc...
     227                 :            :          */
     228                 :            :         int (*device_init)(struct phb *phb, struct pci_device *device,
     229                 :            :                            void *data);
     230                 :            :         void (*device_remove)(struct phb *phb, struct pci_device *pd);
     231                 :            : 
     232                 :            :         /* PHB final fixup is called after PCI probing is completed */
     233                 :            :         void (*phb_final_fixup)(struct phb *phb);
     234                 :            : 
     235                 :            :         /*
     236                 :            :          * EEH methods
     237                 :            :          *
     238                 :            :          * The various arguments are identical to the corresponding
     239                 :            :          * OPAL functions
     240                 :            :          */
     241                 :            :         int64_t (*eeh_freeze_status)(struct phb *phb, uint64_t pe_number,
     242                 :            :                                      uint8_t *freeze_state,
     243                 :            :                                      uint16_t *pci_error_type,
     244                 :            :                                      uint16_t *severity);
     245                 :            :         int64_t (*eeh_freeze_clear)(struct phb *phb, uint64_t pe_number,
     246                 :            :                                     uint64_t eeh_action_token);
     247                 :            :         int64_t (*eeh_freeze_set)(struct phb *phb, uint64_t pe_number,
     248                 :            :                                   uint64_t eeh_action_token);
     249                 :            :         int64_t (*err_inject)(struct phb *phb, uint64_t pe_number,
     250                 :            :                               uint32_t type, uint32_t func, uint64_t addr,
     251                 :            :                               uint64_t mask);
     252                 :            :         int64_t (*get_diag_data2)(struct phb *phb, void *diag_buffer,
     253                 :            :                                   uint64_t diag_buffer_len);
     254                 :            :         int64_t (*next_error)(struct phb *phb, uint64_t *first_frozen_pe,
     255                 :            :                               uint16_t *pci_error_type, uint16_t *severity);
     256                 :            : 
     257                 :            :         /*
     258                 :            :          * Other IODA methods
     259                 :            :          *
     260                 :            :          * The various arguments are identical to the corresponding
     261                 :            :          * OPAL functions
     262                 :            :          */
     263                 :            :         int64_t (*pci_reinit)(struct phb *phb, uint64_t scope, uint64_t data);
     264                 :            :         int64_t (*phb_mmio_enable)(struct phb *phb, uint16_t window_type,
     265                 :            :                                    uint16_t window_num, uint16_t enable);
     266                 :            : 
     267                 :            :         int64_t (*set_phb_mem_window)(struct phb *phb, uint16_t window_type,
     268                 :            :                                       uint16_t window_num, uint64_t addr,
     269                 :            :                                       uint64_t pci_addr, uint64_t size);
     270                 :            : 
     271                 :            :         int64_t (*map_pe_mmio_window)(struct phb *phb, uint64_t pe_number,
     272                 :            :                                       uint16_t window_type, uint16_t window_num,
     273                 :            :                                       uint16_t segment_num);
     274                 :            : 
     275                 :            :         int64_t (*set_pe)(struct phb *phb, uint64_t pe_number,
     276                 :            :                           uint64_t bus_dev_func, uint8_t bus_compare,
     277                 :            :                           uint8_t dev_compare, uint8_t func_compare,
     278                 :            :                           uint8_t pe_action);
     279                 :            : 
     280                 :            :         int64_t (*set_peltv)(struct phb *phb, uint32_t parent_pe,
     281                 :            :                              uint32_t child_pe, uint8_t state);
     282                 :            : 
     283                 :            :         int64_t (*map_pe_dma_window)(struct phb *phb, uint64_t pe_number,
     284                 :            :                                      uint16_t window_id, uint16_t tce_levels,
     285                 :            :                                      uint64_t tce_table_addr,
     286                 :            :                                      uint64_t tce_table_size,
     287                 :            :                                      uint64_t tce_page_size);
     288                 :            : 
     289                 :            :         int64_t (*map_pe_dma_window_real)(struct phb *phb, uint64_t pe_number,
     290                 :            :                                           uint16_t dma_window_number,
     291                 :            :                                           uint64_t pci_start_addr,
     292                 :            :                                           uint64_t pci_mem_size);
     293                 :            : 
     294                 :            :         int64_t (*set_option)(struct phb *phb, enum OpalPhbOption opt,
     295                 :            :                               uint64_t setting);
     296                 :            :         int64_t (*get_option)(struct phb *phb, enum OpalPhbOption opt,
     297                 :            :                               __be64 *setting);
     298                 :            : 
     299                 :            :         int64_t (*set_xive_pe)(struct phb *phb, uint64_t pe_number,
     300                 :            :                                uint32_t xive_num);
     301                 :            : 
     302                 :            :         int64_t (*get_msi_32)(struct phb *phb, uint64_t mve_number,
     303                 :            :                               uint32_t xive_num, uint8_t msi_range,
     304                 :            :                               uint32_t *msi_address, uint32_t *message_data);
     305                 :            : 
     306                 :            :         int64_t (*get_msi_64)(struct phb *phb, uint64_t mve_number,
     307                 :            :                               uint32_t xive_num, uint8_t msi_range,
     308                 :            :                               uint64_t *msi_address, uint32_t *message_data);
     309                 :            : 
     310                 :            :         int64_t (*ioda_reset)(struct phb *phb, bool purge);
     311                 :            : 
     312                 :            :         int64_t (*papr_errinjct_reset)(struct phb *phb);
     313                 :            : 
     314                 :            :         /*
     315                 :            :          * IODA2 PCI interfaces
     316                 :            :          */
     317                 :            :         int64_t (*pci_msi_eoi)(struct phb *phb, uint32_t hwirq);
     318                 :            : 
     319                 :            :         /* TCE Kill abstraction */
     320                 :            :         int64_t (*tce_kill)(struct phb *phb, uint32_t kill_type,
     321                 :            :                             uint64_t pe_number, uint32_t tce_size,
     322                 :            :                             uint64_t dma_addr, uint32_t npages);
     323                 :            : 
     324                 :            :         /* Put phb in capi mode or pcie mode */
     325                 :            :         int64_t (*set_capi_mode)(struct phb *phb, uint64_t mode,
     326                 :            :                                  uint64_t pe_number);
     327                 :            : 
     328                 :            :         int64_t (*set_capp_recovery)(struct phb *phb);
     329                 :            : 
     330                 :            :         /* PCI peer-to-peer setup */
     331                 :            :         void (*set_p2p)(struct phb *phb, uint64_t mode, uint64_t flags,
     332                 :            :                         uint16_t pe_number);
     333                 :            : 
     334                 :            :         /* Get/set PBCQ Tunnel BAR register */
     335                 :            :         void (*get_tunnel_bar)(struct phb *phb, uint64_t *addr);
     336                 :            :         int64_t (*set_tunnel_bar)(struct phb *phb, uint64_t addr);
     337                 :            : };
     338                 :            : 
     339                 :            : enum phb_type {
     340                 :            :         phb_type_pci,
     341                 :            :         phb_type_pcix_v1,
     342                 :            :         phb_type_pcix_v2,
     343                 :            :         phb_type_pcie_v1,
     344                 :            :         phb_type_pcie_v2,
     345                 :            :         phb_type_pcie_v3,
     346                 :            :         phb_type_pcie_v4,
     347                 :            :         phb_type_npu_v2,
     348                 :            :         phb_type_npu_v2_opencapi,
     349                 :            :         phb_type_pau_opencapi,
     350                 :            : };
     351                 :            : 
     352                 :            : /* Generic PCI NVRAM flags */
     353                 :            : extern bool verbose_eeh;
     354                 :            : extern bool pci_tracing;
     355                 :            : 
     356                 :            : void pci_nvram_init(void);
     357                 :            : 
     358                 :            : struct phb {
     359                 :            :         struct dt_node          *dt_node;
     360                 :            :         int                     opal_id;
     361                 :            :         uint32_t                scan_map;
     362                 :            :         enum phb_type           phb_type;
     363                 :            :         struct lock             lock;
     364                 :            :         struct list_head        devices;
     365                 :            :         struct list_head        virt_devices;
     366                 :            :         const struct phb_ops    *ops;
     367                 :            :         struct pci_lsi_state    lstate;
     368                 :            :         uint32_t                mps;
     369                 :            :         bitmap_t                *filter_map;
     370                 :            : 
     371                 :            :         /* PCI-X only slot info, for PCI-E this is in the RC bridge */
     372                 :            :         struct pci_slot         *slot;
     373                 :            : 
     374                 :            :         /* Base location code used to generate the children one */
     375                 :            :         const char              *base_loc_code;
     376                 :            : 
     377                 :            :         /* Additional data the platform might need to attach */
     378                 :            :         void                    *platform_data;
     379                 :            : };
     380                 :            : 
     381                 :            : static inline void phb_lock(struct phb *phb)
     382                 :            : {
     383                 :            :         lock(&phb->lock);
     384                 :            : }
     385                 :            : 
     386                 :            : static inline bool phb_try_lock(struct phb *phb)
     387                 :            : {
     388                 :            :         return try_lock(&phb->lock);
     389                 :            : }
     390                 :            : 
     391                 :            : static inline void phb_unlock(struct phb *phb)
     392                 :            : {
     393                 :            :         unlock(&phb->lock);
     394                 :            : }
     395                 :            : 
     396                 :            : bool pci_check_clear_freeze(struct phb *phb);
     397                 :            : 
     398                 :            : /* Config space ops wrappers */
     399                 :          0 : static inline int64_t pci_cfg_read8(struct phb *phb, uint32_t bdfn,
     400                 :            :                                     uint32_t offset, uint8_t *data)
     401                 :            : {
     402                 :          0 :         return phb->ops->cfg_read8(phb, bdfn, offset, data);
     403                 :            : }
     404                 :            : 
     405                 :            : static inline int64_t pci_cfg_read16(struct phb *phb, uint32_t bdfn,
     406                 :            :                                      uint32_t offset, uint16_t *data)
     407                 :            : {
     408                 :            :         return phb->ops->cfg_read16(phb, bdfn, offset, data);
     409                 :            : }
     410                 :            : 
     411                 :            : static inline int64_t pci_cfg_read32(struct phb *phb, uint32_t bdfn,
     412                 :            :                                      uint32_t offset, uint32_t *data)
     413                 :            : {
     414                 :            :         return phb->ops->cfg_read32(phb, bdfn, offset, data);
     415                 :            : }
     416                 :            : 
     417                 :            : static inline int64_t pci_cfg_write8(struct phb *phb, uint32_t bdfn,
     418                 :            :                                      uint32_t offset, uint8_t data)
     419                 :            : {
     420                 :            :         return phb->ops->cfg_write8(phb, bdfn, offset, data);
     421                 :            : }
     422                 :            : 
     423                 :            : static inline int64_t pci_cfg_write16(struct phb *phb, uint32_t bdfn,
     424                 :            :                                       uint32_t offset, uint16_t data)
     425                 :            : {
     426                 :            :         return phb->ops->cfg_write16(phb, bdfn, offset, data);
     427                 :            : }
     428                 :            : 
     429                 :            : static inline int64_t pci_cfg_write32(struct phb *phb, uint32_t bdfn,
     430                 :            :                                       uint32_t offset, uint32_t data)
     431                 :            : {
     432                 :            :         return phb->ops->cfg_write32(phb, bdfn, offset, data);
     433                 :            : }
     434                 :            : 
     435                 :            : /* Utilities */
     436                 :            : extern void pci_remove_bus(struct phb *phb, struct list_head *list);
     437                 :            : extern uint8_t pci_scan_bus(struct phb *phb, uint8_t bus, uint8_t max_bus,
     438                 :            :                             struct list_head *list, struct pci_device *parent,
     439                 :            :                             bool scan_downstream);
     440                 :            : extern void pci_add_device_nodes(struct phb *phb,
     441                 :            :                                  struct list_head *list,
     442                 :            :                                  struct dt_node *parent_node,
     443                 :            :                                  struct pci_lsi_state *lstate,
     444                 :            :                                  uint8_t swizzle);
     445                 :            : extern int64_t pci_find_cap(struct phb *phb, uint16_t bdfn, uint8_t cap);
     446                 :            : extern int64_t pci_find_ecap(struct phb *phb, uint16_t bdfn, uint16_t cap,
     447                 :            :                              uint8_t *version);
     448                 :            : extern void pci_init_capabilities(struct phb *phb, struct pci_device *pd);
     449                 :            : extern bool pci_wait_crs(struct phb *phb, uint16_t bdfn, uint32_t *out_vdid);
     450                 :            : extern void pci_restore_slot_bus_configs(struct pci_slot *slot);
     451                 :            : extern void pci_device_init(struct phb *phb, struct pci_device *pd);
     452                 :            : extern struct pci_device *pci_walk_dev(struct phb *phb,
     453                 :            :                                        struct pci_device *pd,
     454                 :            :                                        int (*cb)(struct phb *,
     455                 :            :                                                  struct pci_device *,
     456                 :            :                                                  void *),
     457                 :            :                                        void *userdata);
     458                 :            : extern struct pci_device *pci_find_dev(struct phb *phb, uint16_t bdfn);
     459                 :            : extern void pci_restore_bridge_buses(struct phb *phb, struct pci_device *pd);
     460                 :            : extern struct pci_cfg_reg_filter *pci_find_cfg_reg_filter(struct pci_device *pd,
     461                 :            :                                         uint32_t start, uint32_t len);
     462                 :            : extern int64_t pci_handle_cfg_filters(struct phb *phb, uint32_t bdfn,
     463                 :            :                                       uint32_t offset, uint32_t len,
     464                 :            :                                       uint32_t *data, bool write);
     465                 :            : extern struct pci_cfg_reg_filter *pci_add_cfg_reg_filter(struct pci_device *pd,
     466                 :            :                                         uint32_t start, uint32_t len,
     467                 :            :                                         uint32_t flags, pci_cfg_reg_func func);
     468                 :            : 
     469                 :            : /* Manage PHBs */
     470                 :            : #define OPAL_DYNAMIC_PHB_ID (~0)
     471                 :            : extern int64_t pci_register_phb(struct phb *phb, int opal_id);
     472                 :            : extern int64_t pci_unregister_phb(struct phb *phb);
     473                 :            : extern struct phb *pci_get_phb(uint64_t phb_id);
     474                 :            : 
     475                 :            : static inline struct phb *__pci_next_phb_idx(uint64_t *phb_id) {
     476                 :            :         struct phb *phb = NULL;
     477                 :            :         while (phb == NULL && *phb_id <= last_phb_id) {
     478                 :            :                 phb = pci_get_phb((*phb_id)++);
     479                 :            :         }
     480                 :            :         return phb;
     481                 :            : }
     482                 :            : 
     483                 :            : #define for_each_phb(phb)                                       \
     484                 :            :         for (uint64_t __phb_idx = 0;                            \
     485                 :            :              (phb = __pci_next_phb_idx(&__phb_idx)) ; )
     486                 :            : 
     487                 :            : /* Device tree */
     488                 :            : extern void pci_std_swizzle_irq_map(struct dt_node *dt_node,
     489                 :            :                                     struct pci_device *pd,
     490                 :            :                                     struct pci_lsi_state *lstate,
     491                 :            :                                     uint8_t swizzle);
     492                 :            : 
     493                 :            : /* Initialize all PCI slots */
     494                 :            : extern void pci_init_slots(void);
     495                 :            : extern int64_t pci_reset(void);
     496                 :            : 
     497                 :            : extern void opal_pci_eeh_set_evt(uint64_t phb_id);
     498                 :            : extern void opal_pci_eeh_clear_evt(uint64_t phb_id);
     499                 :            : 
     500                 :            : #endif /* __PCI_H */

Generated by: LCOV version 1.14