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