2 * The file intends to implement the functions needed by EEH, which is
3 * built on IODA compliant chip. Actually, lots of functions related
4 * to EEH would be built based on the OPAL APIs.
6 * Copyright Benjamin Herrenschmidt & Gavin Shan, IBM Corporation 2013.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/bootmem.h>
15 #include <linux/delay.h>
16 #include <linux/init.h>
18 #include <linux/irq.h>
19 #include <linux/kernel.h>
20 #include <linux/msi.h>
21 #include <linux/pci.h>
22 #include <linux/string.h>
25 #include <asm/eeh_event.h>
27 #include <asm/iommu.h>
28 #include <asm/msi_bitmap.h>
30 #include <asm/pci-bridge.h>
31 #include <asm/ppc-pci.h>
38 * ioda_eeh_post_init - Chip dependent post initialization
39 * @hose: PCI controller
41 * The function will be called after eeh PEs and devices
42 * have been built. That means the EEH is ready to supply
43 * service with I/O cache.
45 static int ioda_eeh_post_init(struct pci_controller *hose)
47 struct pnv_phb *phb = hose->private_data;
49 /* FIXME: Enable it for PHB3 later */
50 if (phb->type == PNV_PHB_IODA1)
57 * ioda_eeh_set_option - Set EEH operation or I/O setting
61 * Enable or disable EEH option for the indicated PE. The
62 * function also can be used to enable I/O or DMA for the
65 static int ioda_eeh_set_option(struct eeh_pe *pe, int option)
69 struct pci_controller *hose = pe->phb;
70 struct pnv_phb *phb = hose->private_data;
72 /* Check on PE number */
73 if (pe->addr < 0 || pe->addr >= phb->ioda.total_pe) {
74 pr_err("%s: PE address %x out of range [0, %x] "
76 __func__, pe->addr, phb->ioda.total_pe,
89 case EEH_OPT_THAW_MMIO:
90 ret = opal_pci_eeh_freeze_clear(phb->opal_id, pe_no,
91 OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO);
93 pr_warning("%s: Failed to enable MMIO for "
94 "PHB#%x-PE#%x, err=%lld\n",
95 __func__, hose->global_number, pe_no, ret);
100 case EEH_OPT_THAW_DMA:
101 ret = opal_pci_eeh_freeze_clear(phb->opal_id, pe_no,
102 OPAL_EEH_ACTION_CLEAR_FREEZE_DMA);
104 pr_warning("%s: Failed to enable DMA for "
105 "PHB#%x-PE#%x, err=%lld\n",
106 __func__, hose->global_number, pe_no, ret);
112 pr_warning("%s: Invalid option %d\n", __func__, option);
119 struct pnv_eeh_ops ioda_eeh_ops = {
120 .post_init = ioda_eeh_post_init,
121 .set_option = ioda_eeh_set_option,
125 .configure_bridge = NULL,