1 /*
2  * Machine vector for IA-64.
3  *
4  * Copyright (C) 1999 Silicon Graphics, Inc.
5  * Copyright (C) Srinivasa Thirumalachar <sprasad@engr.sgi.com>
6  * Copyright (C) Vijay Chander <vijay@engr.sgi.com>
7  * Copyright (C) 1999-2001 Hewlett-Packard Co.
8  *	David Mosberger-Tang <davidm@hpl.hp.com>
9  */
10 #ifndef _ASM_IA64_MACHVEC_H
11 #define _ASM_IA64_MACHVEC_H
12 
13 #include <linux/config.h>
14 #include <linux/types.h>
15 
16 /* forward declarations: */
17 struct pci_dev;
18 struct pt_regs;
19 struct scatterlist;
20 struct irq_desc;
21 struct page;
22 
23 typedef void ia64_mv_setup_t (char **);
24 typedef void ia64_mv_cpu_init_t(void);
25 typedef void ia64_mv_irq_init_t (void);
26 typedef void ia64_mv_pci_fixup_t (int);
27 typedef unsigned long ia64_mv_map_nr_t (void *);
28 typedef void ia64_mv_mca_init_t (void);
29 typedef void ia64_mv_mca_handler_t (void);
30 typedef void ia64_mv_cmci_handler_t (int, void *, struct pt_regs *);
31 typedef void ia64_mv_log_print_t (void);
32 typedef void ia64_mv_send_ipi_t (int, int, int, int);
33 typedef void ia64_mv_global_tlb_purge_t (unsigned long, unsigned long, unsigned long);
34 typedef struct irq_desc *ia64_mv_irq_desc (unsigned int);
35 typedef u8 ia64_mv_irq_to_vector (u8);
36 typedef unsigned int ia64_mv_local_vector_to_irq (u8 vector);
37 
38 /* PCI-DMA interface: */
39 typedef void ia64_mv_pci_dma_init (void);
40 typedef void *ia64_mv_pci_alloc_consistent (struct pci_dev *, size_t, dma_addr_t *);
41 typedef void ia64_mv_pci_free_consistent (struct pci_dev *, size_t, void *, dma_addr_t);
42 typedef dma_addr_t ia64_mv_pci_map_single (struct pci_dev *, void *, size_t, int);
43 typedef void ia64_mv_pci_unmap_single (struct pci_dev *, dma_addr_t, size_t, int);
44 typedef int ia64_mv_pci_map_sg (struct pci_dev *, struct scatterlist *, int, int);
45 typedef void ia64_mv_pci_unmap_sg (struct pci_dev *, struct scatterlist *, int, int);
46 typedef void ia64_mv_pci_dma_sync_single (struct pci_dev *, dma_addr_t, size_t, int);
47 typedef void ia64_mv_pci_dma_sync_sg (struct pci_dev *, struct scatterlist *, int, int);
48 typedef int ia64_mv_pci_dma_supported (struct pci_dev *, u64);
49 
50 /*
51  * WARNING: The legacy I/O space is _architected_.  Platforms are
52  * expected to follow this architected model (see Section 10.7 in the
53  * IA-64 Architecture Software Developer's Manual).  Unfortunately,
54  * some broken machines do not follow that model, which is why we have
55  * to make the inX/outX operations part of the machine vector.
56  * Platform designers should follow the architected model whenever
57  * possible.
58  */
59 typedef unsigned int ia64_mv_inb_t (unsigned long);
60 typedef unsigned int ia64_mv_inw_t (unsigned long);
61 typedef unsigned int ia64_mv_inl_t (unsigned long);
62 typedef void ia64_mv_outb_t (unsigned char, unsigned long);
63 typedef void ia64_mv_outw_t (unsigned short, unsigned long);
64 typedef void ia64_mv_outl_t (unsigned int, unsigned long);
65 
66 extern void machvec_noop (void);
67 
68 # if defined (CONFIG_IA64_HP_SIM)
69 #  include <asm/machvec_hpsim.h>
70 # elif defined (CONFIG_IA64_DIG)
71 #  include <asm/machvec_dig.h>
72 # elif defined (CONFIG_IA64_HP_ZX1)
73 #  include <asm/machvec_hpzx1.h>
74 # elif defined (CONFIG_IA64_SGI_SN1)
75 #  include <asm/machvec_sn1.h>
76 # elif defined (CONFIG_IA64_SGI_SN2)
77 #  include <asm/machvec_sn2.h>
78 # elif defined (CONFIG_IA64_GENERIC)
79 
80 # ifdef MACHVEC_PLATFORM_HEADER
81 #  include MACHVEC_PLATFORM_HEADER
82 # else
83 #  define platform_name		ia64_mv.name
84 #  define platform_setup	ia64_mv.setup
85 #  define platform_cpu_init	ia64_mv.cpu_init
86 #  define platform_irq_init	ia64_mv.irq_init
87 #  define platform_map_nr	ia64_mv.map_nr
88 #  define platform_mca_init	ia64_mv.mca_init
89 #  define platform_mca_handler	ia64_mv.mca_handler
90 #  define platform_cmci_handler	ia64_mv.cmci_handler
91 #  define platform_log_print	ia64_mv.log_print
92 #  define platform_pci_fixup	ia64_mv.pci_fixup
93 #  define platform_send_ipi		ia64_mv.send_ipi
94 #  define platform_global_tlb_purge	ia64_mv.global_tlb_purge
95 #  define platform_pci_dma_init		ia64_mv.dma_init
96 #  define platform_pci_alloc_consistent	ia64_mv.alloc_consistent
97 #  define platform_pci_free_consistent	ia64_mv.free_consistent
98 #  define platform_pci_map_single	ia64_mv.map_single
99 #  define platform_pci_unmap_single	ia64_mv.unmap_single
100 #  define platform_pci_map_sg		ia64_mv.map_sg
101 #  define platform_pci_unmap_sg		ia64_mv.unmap_sg
102 #  define platform_pci_dma_sync_single	ia64_mv.sync_single
103 #  define platform_pci_dma_sync_sg	ia64_mv.sync_sg
104 #  define platform_pci_dma_supported	ia64_mv.dma_supported
105 #  define platform_irq_desc		ia64_mv.irq_desc
106 #  define platform_irq_to_vector	ia64_mv.irq_to_vector
107 #  define platform_local_vector_to_irq	ia64_mv.local_vector_to_irq
108 #  define platform_inb		ia64_mv.inb
109 #  define platform_inw		ia64_mv.inw
110 #  define platform_inl		ia64_mv.inl
111 #  define platform_outb		ia64_mv.outb
112 #  define platform_outw		ia64_mv.outw
113 #  define platform_outl		ia64_mv.outl
114 # endif
115 
116 struct ia64_machine_vector {
117 	const char *name;
118 	ia64_mv_setup_t *setup;
119 	ia64_mv_cpu_init_t *cpu_init;
120 	ia64_mv_irq_init_t *irq_init;
121 	ia64_mv_pci_fixup_t *pci_fixup;
122 	ia64_mv_map_nr_t *map_nr;
123 	ia64_mv_mca_init_t *mca_init;
124 	ia64_mv_mca_handler_t *mca_handler;
125 	ia64_mv_cmci_handler_t *cmci_handler;
126 	ia64_mv_log_print_t *log_print;
127 	ia64_mv_send_ipi_t *send_ipi;
128 	ia64_mv_global_tlb_purge_t *global_tlb_purge;
129 	ia64_mv_pci_dma_init *dma_init;
130 	ia64_mv_pci_alloc_consistent *alloc_consistent;
131 	ia64_mv_pci_free_consistent *free_consistent;
132 	ia64_mv_pci_map_single *map_single;
133 	ia64_mv_pci_unmap_single *unmap_single;
134 	ia64_mv_pci_map_sg *map_sg;
135 	ia64_mv_pci_unmap_sg *unmap_sg;
136 	ia64_mv_pci_dma_sync_single *sync_single;
137 	ia64_mv_pci_dma_sync_sg *sync_sg;
138 	ia64_mv_pci_dma_supported *dma_supported;
139 	ia64_mv_irq_desc *irq_desc;
140 	ia64_mv_irq_to_vector *irq_to_vector;
141 	ia64_mv_local_vector_to_irq *local_vector_to_irq;
142 	ia64_mv_inb_t *inb;
143 	ia64_mv_inw_t *inw;
144 	ia64_mv_inl_t *inl;
145 	ia64_mv_outb_t *outb;
146 	ia64_mv_outw_t *outw;
147 	ia64_mv_outl_t *outl;
148 };
149 
150 #define MACHVEC_INIT(name)			\
151 {						\
152 	#name,					\
153 	platform_setup,				\
154 	platform_cpu_init,			\
155 	platform_irq_init,			\
156 	platform_pci_fixup,			\
157 	platform_map_nr,			\
158 	platform_mca_init,			\
159 	platform_mca_handler,			\
160 	platform_cmci_handler,			\
161 	platform_log_print,			\
162 	platform_send_ipi,			\
163 	platform_global_tlb_purge,		\
164 	platform_pci_dma_init,			\
165 	platform_pci_alloc_consistent,		\
166 	platform_pci_free_consistent,		\
167 	platform_pci_map_single,		\
168 	platform_pci_unmap_single,		\
169 	platform_pci_map_sg,			\
170 	platform_pci_unmap_sg,			\
171 	platform_pci_dma_sync_single,		\
172 	platform_pci_dma_sync_sg,		\
173 	platform_pci_dma_supported,		\
174 	platform_irq_desc,			\
175 	platform_irq_to_vector,			\
176 	platform_local_vector_to_irq,		\
177 	platform_inb,				\
178 	platform_inw,				\
179 	platform_inl,				\
180 	platform_outb,				\
181 	platform_outw,				\
182 	platform_outl				\
183 }
184 
185 extern struct ia64_machine_vector ia64_mv;
186 extern void machvec_init (const char *name);
187 
188 # else
189 #  error Unknown configuration.  Update asm-ia64/machvec.h.
190 # endif /* CONFIG_IA64_GENERIC */
191 
192 /*
193  * Declare default routines which aren't declared anywhere else:
194  */
195 extern ia64_mv_pci_dma_init swiotlb_init;
196 extern ia64_mv_pci_alloc_consistent swiotlb_alloc_consistent;
197 extern ia64_mv_pci_free_consistent swiotlb_free_consistent;
198 extern ia64_mv_pci_map_single swiotlb_map_single;
199 extern ia64_mv_pci_unmap_single swiotlb_unmap_single;
200 extern ia64_mv_pci_map_sg swiotlb_map_sg;
201 extern ia64_mv_pci_unmap_sg swiotlb_unmap_sg;
202 extern ia64_mv_pci_dma_sync_single swiotlb_sync_single;
203 extern ia64_mv_pci_dma_sync_sg swiotlb_sync_sg;
204 extern ia64_mv_pci_dma_supported swiotlb_pci_dma_supported;
205 
206 /*
207  * Define default versions so we can extend machvec for new platforms without having
208  * to update the machvec files for all existing platforms.
209  */
210 #ifndef platform_setup
211 # define platform_setup		((ia64_mv_setup_t *) machvec_noop)
212 #endif
213 #ifndef platform_cpu_init
214 # define platform_cpu_init	((ia64_mv_cpu_init_t *) machvec_noop)
215 #endif
216 #ifndef platform_irq_init
217 # define platform_irq_init	((ia64_mv_irq_init_t *) machvec_noop)
218 #endif
219 #ifndef platform_mca_init
220 # define platform_mca_init	((ia64_mv_mca_init_t *) machvec_noop)
221 #endif
222 #ifndef platform_mca_handler
223 # define platform_mca_handler	((ia64_mv_mca_handler_t *) machvec_noop)
224 #endif
225 #ifndef platform_cmci_handler
226 # define platform_cmci_handler	((ia64_mv_cmci_handler_t *) machvec_noop)
227 #endif
228 #ifndef platform_log_print
229 # define platform_log_print	((ia64_mv_log_print_t *) machvec_noop)
230 #endif
231 #ifndef platform_pci_fixup
232 # define platform_pci_fixup	((ia64_mv_pci_fixup_t *) machvec_noop)
233 #endif
234 #ifndef platform_send_ipi
235 # define platform_send_ipi	ia64_send_ipi	/* default to architected version */
236 #endif
237 #ifndef platform_global_tlb_purge
238 # define platform_global_tlb_purge	ia64_global_tlb_purge /* default to architected version */
239 #endif
240 #ifndef platform_pci_dma_init
241 # define platform_pci_dma_init		swiotlb_init
242 #endif
243 #ifndef platform_pci_alloc_consistent
244 # define platform_pci_alloc_consistent	swiotlb_alloc_consistent
245 #endif
246 #ifndef platform_pci_free_consistent
247 # define platform_pci_free_consistent	swiotlb_free_consistent
248 #endif
249 #ifndef platform_pci_map_single
250 # define platform_pci_map_single	swiotlb_map_single
251 #endif
252 #ifndef platform_pci_unmap_single
253 # define platform_pci_unmap_single	swiotlb_unmap_single
254 #endif
255 #ifndef platform_pci_map_sg
256 # define platform_pci_map_sg		swiotlb_map_sg
257 #endif
258 #ifndef platform_pci_unmap_sg
259 # define platform_pci_unmap_sg		swiotlb_unmap_sg
260 #endif
261 #ifndef platform_pci_dma_sync_single
262 # define platform_pci_dma_sync_single	swiotlb_sync_single
263 #endif
264 #ifndef platform_pci_dma_sync_sg
265 # define platform_pci_dma_sync_sg	swiotlb_sync_sg
266 #endif
267 #ifndef platform_pci_dma_supported
268 # define  platform_pci_dma_supported	swiotlb_pci_dma_supported
269 #endif
270 #ifndef platform_irq_desc
271 # define platform_irq_desc		__ia64_irq_desc
272 #endif
273 #ifndef platform_irq_to_vector
274 # define platform_irq_to_vector		__ia64_irq_to_vector
275 #endif
276 #ifndef platform_local_vector_to_irq
277 # define platform_local_vector_to_irq	__ia64_local_vector_to_irq
278 #endif
279 #ifndef platform_inb
280 # define platform_inb		__ia64_inb
281 #endif
282 #ifndef platform_inw
283 # define platform_inw		__ia64_inw
284 #endif
285 #ifndef platform_inl
286 # define platform_inl		__ia64_inl
287 #endif
288 #ifndef platform_outb
289 # define platform_outb		__ia64_outb
290 #endif
291 #ifndef platform_outw
292 # define platform_outw		__ia64_outw
293 #endif
294 #ifndef platform_outl
295 # define platform_outl		__ia64_outl
296 #endif
297 
298 #endif /* _ASM_IA64_MACHVEC_H */
299