xref: /netbsd-src/sys/arch/alpha/include/pci_machdep.h (revision b7b7574d3bf8eeb51a1fa3977b59142ec6434a55)
1 /* $NetBSD: pci_machdep.h,v 1.18 2014/03/29 19:28:25 christos Exp $ */
2 
3 /*
4  * Copyright (c) 1996 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  *
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  *
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  *
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  */
29 
30 /*
31  * Machine-specific definitions for PCI autoconfiguration.
32  */
33 #define	__HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
34 
35 /*
36  * Types provided to machine-independent PCI code
37  */
38 typedef struct alpha_pci_chipset *pci_chipset_tag_t;
39 typedef u_long pcitag_t;
40 typedef u_long pci_intr_handle_t;
41 
42 /*
43  * Forward declarations.
44  */
45 struct pci_attach_args;
46 
47 /*
48  * alpha-specific PCI structure and type definitions.
49  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
50  */
51 struct alpha_pci_chipset {
52 	void		*pc_conf_v;
53 	void		(*pc_attach_hook)(device_t, device_t,
54 			    struct pcibus_attach_args *);
55 	int		(*pc_bus_maxdevs)(void *, int);
56 	pcitag_t	(*pc_make_tag)(void *, int, int, int);
57 	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
58 			    int *, int *);
59 	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
60 	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
61 
62 	void		*pc_intr_v;
63 	int		(*pc_intr_map)(const struct pci_attach_args *,
64 			    pci_intr_handle_t *);
65 	const char	*(*pc_intr_string)(void *, pci_intr_handle_t,
66 			    char *, size_t);
67 	const struct evcnt *(*pc_intr_evcnt)(void *, pci_intr_handle_t);
68 	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
69 			    int, int (*)(void *), void *);
70 	void		(*pc_intr_disestablish)(void *, void *);
71 
72 	void		*(*pc_pciide_compat_intr_establish)(void *, device_t,
73 			    const struct pci_attach_args *, int,
74 			    int (*)(void *), void *);
75 };
76 
77 /*
78  * Functions provided to machine-independent PCI code.
79  */
80 #define	pci_attach_hook(p, s, pba)					\
81     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
82 #define	pci_bus_maxdevs(c, b)						\
83     (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
84 #define	pci_make_tag(c, b, d, f)					\
85     (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
86 #define	pci_decompose_tag(c, t, bp, dp, fp)				\
87     (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
88 #define	pci_conf_read(c, t, r)						\
89     (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
90 #define	pci_conf_write(c, t, r, v)					\
91     (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
92 #define	pci_intr_map(pa, ihp)						\
93     (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
94 #define	pci_intr_string(c, ih, buf, len)				\
95     (*(c)->pc_intr_string)((c)->pc_intr_v, (ih), (buf), (len))
96 #define	pci_intr_evcnt(c, ih)						\
97     (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
98 #define	pci_intr_establish(c, ih, l, h, a)				\
99     (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
100 #define	pci_intr_disestablish(c, iv)					\
101     (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
102 
103 /*
104  * alpha-specific PCI functions.
105  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
106  */
107 void	pci_display_console(bus_space_tag_t, bus_space_tag_t,
108 	    pci_chipset_tag_t, int, int, int);
109 #define	alpha_pciide_compat_intr_establish(c, d, p, ch, f, a)		\
110     ((c)->pc_pciide_compat_intr_establish == NULL ? NULL :		\
111      (*(c)->pc_pciide_compat_intr_establish)((c)->pc_conf_v, (d), (p),	\
112 	(ch), (f), (a)))
113 void	device_pci_register(device_t, void *);
114