1
2
3
4
5
6#ifndef PCI_IMPL_H
7#define PCI_IMPL_H
8
9#include <linux/types.h>
10#include <linux/spinlock.h>
11#include <linux/pci.h>
12#include <linux/msi.h>
13#include <linux/of_device.h>
14#include <asm/io.h>
15#include <asm/prom.h>
16#include <asm/iommu.h>
17
18
19
20
21
22
23
24
25
26
27
28#define PCI_STC_FLUSHFLAG_INIT(STC) \
29 (*((STC)->strbuf_flushflag) = 0UL)
30#define PCI_STC_FLUSHFLAG_SET(STC) \
31 (*((STC)->strbuf_flushflag) != 0UL)
32
33#ifdef CONFIG_PCI_MSI
34struct pci_pbm_info;
35struct sparc64_msiq_ops {
36 int (*get_head)(struct pci_pbm_info *pbm, unsigned long msiqid,
37 unsigned long *head);
38 int (*dequeue_msi)(struct pci_pbm_info *pbm, unsigned long msiqid,
39 unsigned long *head, unsigned long *msi);
40 int (*set_head)(struct pci_pbm_info *pbm, unsigned long msiqid,
41 unsigned long head);
42 int (*msi_setup)(struct pci_pbm_info *pbm, unsigned long msiqid,
43 unsigned long msi, int is_msi64);
44 int (*msi_teardown)(struct pci_pbm_info *pbm, unsigned long msi);
45 int (*msiq_alloc)(struct pci_pbm_info *pbm);
46 void (*msiq_free)(struct pci_pbm_info *pbm);
47 int (*msiq_build_irq)(struct pci_pbm_info *pbm, unsigned long msiqid,
48 unsigned long devino);
49};
50
51extern void sparc64_pbm_msi_init(struct pci_pbm_info *pbm,
52 const struct sparc64_msiq_ops *ops);
53
54struct sparc64_msiq_cookie {
55 struct pci_pbm_info *pbm;
56 unsigned long msiqid;
57};
58#endif
59
60struct pci_pbm_info {
61 struct pci_pbm_info *next;
62 struct pci_pbm_info *sibling;
63 int index;
64
65
66 unsigned long controller_regs;
67
68
69 unsigned long pbm_regs;
70
71
72 unsigned long sync_reg;
73
74
75 u32 portid;
76
77
78 u32 devhandle;
79
80
81 int chip_type;
82#define PBM_CHIP_TYPE_SABRE 1
83#define PBM_CHIP_TYPE_PSYCHO 2
84#define PBM_CHIP_TYPE_SCHIZO 3
85#define PBM_CHIP_TYPE_SCHIZO_PLUS 4
86#define PBM_CHIP_TYPE_TOMATILLO 5
87 int chip_version;
88 int chip_revision;
89
90
91 const char *name;
92
93
94 struct platform_device *op;
95 u64 ino_bitmap;
96
97
98 struct resource io_space;
99 struct resource mem_space;
100 struct resource busn;
101
102
103 unsigned long config_space;
104
105
106 unsigned long config_space_reg_bits;
107
108 unsigned long pci_afsr;
109 unsigned long pci_afar;
110 unsigned long pci_csr;
111
112
113 int is_66mhz_capable;
114 int all_devs_66mhz;
115
116#ifdef CONFIG_PCI_MSI
117
118 u32 msiq_num;
119 u32 msiq_ent_count;
120 u32 msiq_first;
121 u32 msiq_first_devino;
122 u32 msiq_rotor;
123 struct sparc64_msiq_cookie *msiq_irq_cookies;
124 u32 msi_num;
125 u32 msi_first;
126 u32 msi_data_mask;
127 u32 msix_data_width;
128 u64 msi32_start;
129 u64 msi64_start;
130 u32 msi32_len;
131 u32 msi64_len;
132 void *msi_queues;
133 unsigned long *msi_bitmap;
134 unsigned int *msi_irq_table;
135 int (*setup_msi_irq)(unsigned int *irq_p, struct pci_dev *pdev,
136 struct msi_desc *entry);
137 void (*teardown_msi_irq)(unsigned int irq, struct pci_dev *pdev);
138 const struct sparc64_msiq_ops *msi_ops;
139#endif
140
141
142 struct strbuf stc;
143
144
145 struct iommu *iommu;
146
147
148 unsigned int pci_first_busno;
149 unsigned int pci_last_busno;
150 struct pci_bus *pci_bus;
151 struct pci_ops *pci_ops;
152
153 int numa_node;
154};
155
156extern struct pci_pbm_info *pci_pbm_root;
157
158extern int pci_num_pbms;
159
160
161extern void pci_get_pbm_props(struct pci_pbm_info *pbm);
162extern struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm,
163 struct device *parent);
164extern void pci_determine_mem_io_space(struct pci_pbm_info *pbm);
165
166
167extern void pci_scan_for_target_abort(struct pci_pbm_info *, struct pci_bus *);
168extern void pci_scan_for_master_abort(struct pci_pbm_info *, struct pci_bus *);
169extern void pci_scan_for_parity_error(struct pci_pbm_info *, struct pci_bus *);
170
171
172extern void pci_config_read8(u8 *addr, u8 *ret);
173extern void pci_config_read16(u16 *addr, u16 *ret);
174extern void pci_config_read32(u32 *addr, u32 *ret);
175extern void pci_config_write8(u8 *addr, u8 val);
176extern void pci_config_write16(u16 *addr, u16 val);
177extern void pci_config_write32(u32 *addr, u32 val);
178
179extern struct pci_ops sun4u_pci_ops;
180extern struct pci_ops sun4v_pci_ops;
181
182extern volatile int pci_poke_in_progress;
183extern volatile int pci_poke_cpu;
184extern volatile int pci_poke_faulted;
185
186#endif
187