pci_machdep.h revision 1.6 1 1.6 rkujawa /* $NetBSD: pci_machdep.h,v 1.6 2012/06/01 09:41:35 rkujawa Exp $ */
2 1.1 rkujawa
3 1.1 rkujawa /*-
4 1.1 rkujawa * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 1.1 rkujawa * All rights reserved.
6 1.1 rkujawa *
7 1.1 rkujawa * This code is derived from software contributed to The NetBSD Foundation
8 1.1 rkujawa * by Radoslaw Kujawa.
9 1.1 rkujawa *
10 1.1 rkujawa * Redistribution and use in source and binary forms, with or without
11 1.1 rkujawa * modification, are permitted provided that the following conditions
12 1.1 rkujawa * are met:
13 1.1 rkujawa * 1. Redistributions of source code must retain the above copyright
14 1.1 rkujawa * notice, this list of conditions and the following disclaimer.
15 1.1 rkujawa * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 rkujawa * notice, this list of conditions and the following disclaimer in the
17 1.1 rkujawa * documentation and/or other materials provided with the distribution.
18 1.1 rkujawa *
19 1.1 rkujawa * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 rkujawa * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 rkujawa * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 rkujawa * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 rkujawa * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 rkujawa * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 rkujawa * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 rkujawa * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 rkujawa * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 rkujawa * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 rkujawa * POSSIBILITY OF SUCH DAMAGE.
30 1.1 rkujawa */
31 1.1 rkujawa
32 1.1 rkujawa #ifndef _AMIGA_PCI_MACHDEP_H_
33 1.1 rkujawa #define _AMIGA_PCI_MACHDEP_H_
34 1.1 rkujawa
35 1.1 rkujawa #include <sys/bus.h>
36 1.1 rkujawa
37 1.1 rkujawa #include <machine/intr.h>
38 1.1 rkujawa
39 1.4 rkujawa /* #define __HAVE_PCI_CONF_HOOK */
40 1.4 rkujawa
41 1.1 rkujawa /*
42 1.1 rkujawa * Forward declarations.
43 1.1 rkujawa */
44 1.1 rkujawa struct pci_attach_args;
45 1.1 rkujawa
46 1.1 rkujawa /*
47 1.1 rkujawa * Types provided to machine-independent PCI code
48 1.1 rkujawa */
49 1.1 rkujawa typedef struct amiga_pci_chipset *pci_chipset_tag_t;
50 1.1 rkujawa typedef u_long pcitag_t;
51 1.1 rkujawa typedef u_long pci_intr_handle_t;
52 1.1 rkujawa
53 1.1 rkujawa /*
54 1.1 rkujawa * amiga-specific PCI structure and type definitions.
55 1.1 rkujawa * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
56 1.1 rkujawa */
57 1.1 rkujawa struct amiga_pci_chipset {
58 1.1 rkujawa void *pc_conf_v;
59 1.1 rkujawa void (*pc_attach_hook)(device_t, device_t,
60 1.1 rkujawa struct pcibus_attach_args *);
61 1.1 rkujawa int (*pc_bus_maxdevs)(pci_chipset_tag_t, int);
62 1.1 rkujawa pcitag_t (*pc_make_tag)(pci_chipset_tag_t, int, int, int);
63 1.1 rkujawa void (*pc_decompose_tag)(pci_chipset_tag_t, pcitag_t, int *,
64 1.1 rkujawa int *, int *);
65 1.1 rkujawa pcireg_t(*pc_conf_read)(pci_chipset_tag_t, pcitag_t,
66 1.1 rkujawa int);
67 1.1 rkujawa void (*pc_conf_write)(pci_chipset_tag_t, pcitag_t, int,
68 1.1 rkujawa pcireg_t);
69 1.2 rkujawa int (*pc_conf_hook)(pci_chipset_tag_t, int, int, int,
70 1.2 rkujawa pcireg_t);
71 1.2 rkujawa void *pc_intr_v;
72 1.1 rkujawa int (*pc_intr_map)(const struct pci_attach_args *,
73 1.1 rkujawa pci_intr_handle_t *);
74 1.1 rkujawa const char *(*pc_intr_string)(pci_chipset_tag_t,
75 1.1 rkujawa pci_intr_handle_t);
76 1.1 rkujawa void *(*pc_intr_establish)(pci_chipset_tag_t,
77 1.1 rkujawa pci_intr_handle_t, int, int (*) (void *), void *);
78 1.1 rkujawa void (*pc_intr_disestablish)(pci_chipset_tag_t, void *);
79 1.1 rkujawa void (*pc_conf_interrupt)(pci_chipset_tag_t, int, int, int,
80 1.1 rkujawa int, int *);
81 1.1 rkujawa
82 1.3 rkujawa /* PCI configuration address register */
83 1.3 rkujawa bus_space_tag_t pci_conf_addresst;
84 1.3 rkujawa bus_space_handle_t pci_conf_addressh;
85 1.3 rkujawa
86 1.3 rkujawa /* PCI configuration data register */
87 1.3 rkujawa bus_space_tag_t pci_conf_datat;
88 1.3 rkujawa bus_space_handle_t pci_conf_datah;
89 1.6 rkujawa
90 1.6 rkujawa void *cookie; /* used in some implementations */
91 1.1 rkujawa };
92 1.1 rkujawa
93 1.1 rkujawa
94 1.1 rkujawa /*
95 1.1 rkujawa * Functions provided to machine-independent PCI code.
96 1.1 rkujawa */
97 1.1 rkujawa #define pci_attach_hook(p, s, pba) \
98 1.1 rkujawa (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
99 1.1 rkujawa #define pci_bus_maxdevs(c, b) \
100 1.1 rkujawa (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
101 1.1 rkujawa #define pci_make_tag(c, b, d, f) \
102 1.1 rkujawa (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
103 1.1 rkujawa #define pci_decompose_tag(c, t, bp, dp, fp) \
104 1.1 rkujawa (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
105 1.1 rkujawa #define pci_conf_read(c, t, r) \
106 1.1 rkujawa (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
107 1.1 rkujawa #define pci_conf_write(c, t, r, v) \
108 1.1 rkujawa (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
109 1.1 rkujawa #define pci_intr_map(pa, ihp) \
110 1.1 rkujawa (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
111 1.1 rkujawa #define pci_intr_string(c, ih) \
112 1.1 rkujawa (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
113 1.1 rkujawa #define pci_intr_evcnt(c, ih) \
114 1.1 rkujawa (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
115 1.1 rkujawa #define pci_intr_establish(c, ih, l, h, a) \
116 1.1 rkujawa (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
117 1.1 rkujawa #define pci_intr_disestablish(c, iv) \
118 1.1 rkujawa (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
119 1.3 rkujawa #define pci_conf_interrupt(c, b, d, f, s, i) \
120 1.3 rkujawa (*(c)->pc_conf_interrupt)((c), (b), (d), (f), (s), (i))
121 1.3 rkujawa #define pci_conf_hook(c, b, d, f, i) \
122 1.3 rkujawa (*(c)->pc_conf_hook)((c), (b), (d), (f), (i))
123 1.1 rkujawa
124 1.1 rkujawa #endif
125 1.3 rkujawa
126 1.3 rkujawa pcitag_t amiga_pci_make_tag(pci_chipset_tag_t pc, int bus, int device,
127 1.3 rkujawa int function);
128 1.3 rkujawa void amiga_pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag,
129 1.3 rkujawa int *bp, int *dp, int *fp);
130 1.3 rkujawa void * amiga_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t
131 1.3 rkujawa ih, int level, int (*ih_fun)(void *), void *ih_arg);
132 1.3 rkujawa void amiga_pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie);
133 1.3 rkujawa const char * amiga_pci_intr_string(pci_chipset_tag_t pc,
134 1.3 rkujawa pci_intr_handle_t ih);
135 1.3 rkujawa int amiga_pci_conf_hook(pci_chipset_tag_t pct, int bus, int dev,
136 1.3 rkujawa int func, pcireg_t id);
137 1.3 rkujawa void amiga_pci_conf_interrupt(pci_chipset_tag_t pc, int bus,
138 1.3 rkujawa int dev, int func, int swiz, int *iline);
139 1.3 rkujawa
140