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