[ARM] pxa: Gumstix Verdex PCMCIA support
[linux-2.6/verdex.git] / drivers / pci / pcie / aer / aerdrv.h
blobbd833ea3ba495e77040a754f203ad42f68f709ea
1 /*
2 * Copyright (C) 2006 Intel Corp.
3 * Tom Long Nguyen (tom.l.nguyen@intel.com)
4 * Zhang Yanmin (yanmin.zhang@intel.com)
6 */
8 #ifndef _AERDRV_H_
9 #define _AERDRV_H_
11 #include <linux/workqueue.h>
12 #include <linux/pcieport_if.h>
13 #include <linux/aer.h>
14 #include <linux/interrupt.h>
16 #define AER_NONFATAL 0
17 #define AER_FATAL 1
18 #define AER_CORRECTABLE 2
20 /* Root Error Status Register Bits */
21 #define ROOT_ERR_STATUS_MASKS 0x0f
23 #define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \
24 PCI_EXP_RTCTL_SENFEE| \
25 PCI_EXP_RTCTL_SEFEE)
26 #define ROOT_PORT_INTR_ON_MESG_MASK (PCI_ERR_ROOT_CMD_COR_EN| \
27 PCI_ERR_ROOT_CMD_NONFATAL_EN| \
28 PCI_ERR_ROOT_CMD_FATAL_EN)
29 #define ERR_COR_ID(d) (d & 0xffff)
30 #define ERR_UNCOR_ID(d) (d >> 16)
32 #define AER_ERROR_SOURCES_MAX 100
34 #define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \
35 PCI_ERR_UNC_ECRC| \
36 PCI_ERR_UNC_UNSUP| \
37 PCI_ERR_UNC_COMP_ABORT| \
38 PCI_ERR_UNC_UNX_COMP| \
39 PCI_ERR_UNC_MALF_TLP)
41 struct header_log_regs {
42 unsigned int dw0;
43 unsigned int dw1;
44 unsigned int dw2;
45 unsigned int dw3;
48 #define AER_MAX_MULTI_ERR_DEVICES 5 /* Not likely to have more */
49 struct aer_err_info {
50 struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
51 int error_dev_num;
53 unsigned int id:16;
55 unsigned int severity:2; /* 0:NONFATAL | 1:FATAL | 2:COR */
56 unsigned int __pad1:5;
57 unsigned int multi_error_valid:1;
59 unsigned int first_error:5;
60 unsigned int __pad2:2;
61 unsigned int tlp_header_valid:1;
63 unsigned int status; /* COR/UNCOR Error Status */
64 unsigned int mask; /* COR/UNCOR Error Mask */
65 struct header_log_regs tlp; /* TLP Header */
68 struct aer_err_source {
69 unsigned int status;
70 unsigned int id;
73 struct aer_rpc {
74 struct pcie_device *rpd; /* Root Port device */
75 struct work_struct dpc_handler;
76 struct aer_err_source e_sources[AER_ERROR_SOURCES_MAX];
77 unsigned short prod_idx; /* Error Producer Index */
78 unsigned short cons_idx; /* Error Consumer Index */
79 int isr;
80 spinlock_t e_lock; /*
81 * Lock access to Error Status/ID Regs
82 * and error producer/consumer index
84 struct mutex rpc_mutex; /*
85 * only one thread could do
86 * recovery on the same
87 * root port hierarchy
89 wait_queue_head_t wait_release;
92 struct aer_broadcast_data {
93 enum pci_channel_state state;
94 enum pci_ers_result result;
97 static inline pci_ers_result_t merge_result(enum pci_ers_result orig,
98 enum pci_ers_result new)
100 if (new == PCI_ERS_RESULT_NONE)
101 return orig;
103 switch (orig) {
104 case PCI_ERS_RESULT_CAN_RECOVER:
105 case PCI_ERS_RESULT_RECOVERED:
106 orig = new;
107 break;
108 case PCI_ERS_RESULT_DISCONNECT:
109 if (new == PCI_ERS_RESULT_NEED_RESET)
110 orig = new;
111 break;
112 default:
113 break;
116 return orig;
119 extern struct bus_type pcie_port_bus_type;
120 extern void aer_enable_rootport(struct aer_rpc *rpc);
121 extern void aer_delete_rootport(struct aer_rpc *rpc);
122 extern int aer_init(struct pcie_device *dev);
123 extern void aer_isr(struct work_struct *work);
124 extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
125 extern void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info);
126 extern irqreturn_t aer_irq(int irq, void *context);
128 #ifdef CONFIG_ACPI
129 extern int aer_osc_setup(struct pcie_device *pciedev);
130 #else
131 static inline int aer_osc_setup(struct pcie_device *pciedev)
133 return 0;
135 #endif
137 #endif /* _AERDRV_H_ */