Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright 2014 IBM Corp.
0004  */
0005 
0006 #ifndef _ASM_PNV_PCI_H
0007 #define _ASM_PNV_PCI_H
0008 
0009 #include <linux/pci.h>
0010 #include <linux/pci_hotplug.h>
0011 #include <linux/irq.h>
0012 #include <linux/of.h>
0013 #include <misc/cxl-base.h>
0014 #include <asm/opal-api.h>
0015 
0016 #define PCI_SLOT_ID_PREFIX  (1UL << 63)
0017 #define PCI_SLOT_ID(phb_id, bdfn)   \
0018     (PCI_SLOT_ID_PREFIX | ((uint64_t)(bdfn) << 16) | (phb_id))
0019 #define PCI_PHB_SLOT_ID(phb_id)     (phb_id)
0020 
0021 extern int pnv_pci_get_slot_id(struct device_node *np, uint64_t *id);
0022 extern int pnv_pci_get_device_tree(uint32_t phandle, void *buf, uint64_t len);
0023 extern int pnv_pci_get_presence_state(uint64_t id, uint8_t *state);
0024 extern int pnv_pci_get_power_state(uint64_t id, uint8_t *state);
0025 extern int pnv_pci_set_power_state(uint64_t id, uint8_t state,
0026                    struct opal_msg *msg);
0027 
0028 extern int pnv_pci_set_tunnel_bar(struct pci_dev *dev, uint64_t addr,
0029                   int enable);
0030 int pnv_phb_to_cxl_mode(struct pci_dev *dev, uint64_t mode);
0031 int pnv_cxl_ioda_msi_setup(struct pci_dev *dev, unsigned int hwirq,
0032                unsigned int virq);
0033 int pnv_cxl_alloc_hwirqs(struct pci_dev *dev, int num);
0034 void pnv_cxl_release_hwirqs(struct pci_dev *dev, int hwirq, int num);
0035 int pnv_cxl_get_irq_count(struct pci_dev *dev);
0036 struct device_node *pnv_pci_get_phb_node(struct pci_dev *dev);
0037 int64_t pnv_opal_pci_msi_eoi(struct irq_data *d);
0038 bool is_pnv_opal_msi(struct irq_chip *chip);
0039 
0040 #ifdef CONFIG_CXL_BASE
0041 int pnv_cxl_alloc_hwirq_ranges(struct cxl_irq_ranges *irqs,
0042                    struct pci_dev *dev, int num);
0043 void pnv_cxl_release_hwirq_ranges(struct cxl_irq_ranges *irqs,
0044                   struct pci_dev *dev);
0045 #endif
0046 
0047 struct pnv_php_slot {
0048     struct hotplug_slot     slot;
0049     uint64_t            id;
0050     char                *name;
0051     int             slot_no;
0052     unsigned int            flags;
0053 #define PNV_PHP_FLAG_BROKEN_PDC     0x1
0054     struct kref         kref;
0055 #define PNV_PHP_STATE_INITIALIZED   0
0056 #define PNV_PHP_STATE_REGISTERED    1
0057 #define PNV_PHP_STATE_POPULATED     2
0058 #define PNV_PHP_STATE_OFFLINE       3
0059     int             state;
0060     int             irq;
0061     struct workqueue_struct     *wq;
0062     struct device_node      *dn;
0063     struct pci_dev          *pdev;
0064     struct pci_bus          *bus;
0065     bool                power_state_check;
0066     u8              attention_state;
0067     void                *fdt;
0068     void                *dt;
0069     struct of_changeset     ocs;
0070     struct pnv_php_slot     *parent;
0071     struct list_head        children;
0072     struct list_head        link;
0073 };
0074 extern struct pnv_php_slot *pnv_php_find_slot(struct device_node *dn);
0075 extern int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
0076                     uint8_t state);
0077 
0078 #endif