1/*	$NetBSD: pci_machdep.h,v 1.5 2005/12/11 12:17:06 christos Exp $	*/
2
3/*-
4 * Copyright (c) 2001 Marcus Comstedt
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 *    must display the following acknowledgement:
17 *	This product includes software developed by Marcus Comstedt.
18 * 4. Neither the name of The NetBSD Foundation nor the names of its
19 *    contributors may be used to endorse or promote products derived
20 *    from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/*
36 * Machine-specific definitions for PCI autoconfiguration.
37 */
38
39/*
40 * Types provided to machine-independent PCI code
41 */
42typedef struct dreamcast_pci_chipset *pci_chipset_tag_t;
43typedef u_long  pcitag_t;
44typedef u_long  pci_intr_handle_t;
45
46/*
47 * Forward declarations.
48 */
49struct pci_attach_args;
50
51/*
52 * dreamcast-specific PCI structure and type definitions.
53 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
54 */
55struct dreamcast_pci_chipset {
56        void            *pc_conf_v;
57        void            (*pc_attach_hook)(struct device *,
58                            struct device *, struct pcibus_attach_args *);
59        int             (*pc_bus_maxdevs)(void *, int);
60        pcitag_t        (*pc_make_tag)(void *, int, int, int);
61	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
62			    int *, int *);
63        pcireg_t        (*pc_conf_read)(void *, pcitag_t, int);
64        void            (*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
65
66	void		*pc_intr_v;
67
68  	int		(*pc_intr_map)(struct pci_attach_args *,
69			    pci_intr_handle_t *);
70	const char	*(*pc_intr_string)(void *, pci_intr_handle_t);
71	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
72			    int, int (*)(void *), void *);
73	void		(*pc_intr_disestablish)(void *, void *);
74};
75
76#define pci_attach_hook(p, s, pba)                                      \
77    (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
78#define pci_bus_maxdevs(c, b)                                           \
79    (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
80#define pci_make_tag(c, b, d, f)                                        \
81    (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
82#define	pci_decompose_tag(c, t, bp, dp, fp)				\
83    (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
84#define pci_conf_read(c, t, r)                                          \
85    (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
86#define pci_conf_write(c, t, r, v)                                      \
87    (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
88
89#define	pci_intr_map(pa, ihp)						\
90    (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
91#define	pci_intr_string(c, ih)						\
92    (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
93#define	pci_intr_establish(c, ih, l, h, a)				\
94    (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
95#define	pci_intr_disestablish(c, ih)					\
96    (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (ih))
97