xref: /openbsd/sys/arch/hppa/include/pci_machdep.h (revision 9b7c3dbb)
1 /*	$OpenBSD: pci_machdep.h,v 1.12 2016/05/04 14:30:00 kettenis Exp $	*/
2 
3 /*
4  * Copyright (c) 2003 Michael Shalayeff
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  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  * THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef	_MACHINE_PCI_MACHDEP_H_
30 #define	_MACHINE_PCI_MACHDEP_H_
31 
32 /*
33  * Types provided to machine-independent PCI code
34  */
35 typedef struct hppa_pci_chipset_tag *pci_chipset_tag_t;
36 typedef u_long pcitag_t;
37 typedef u_long pci_intr_handle_t;
38 
39 struct pci_attach_args;
40 
41 struct hppa_pci_chipset_tag {
42 	void		*_cookie;
43 	void		(*pc_attach_hook)(struct device *,
44 			    struct device *, struct pcibus_attach_args *);
45 	int		(*pc_bus_maxdevs)(void *, int);
46 	pcitag_t	(*pc_make_tag)(void *, int, int, int);
47 	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
48 			    int *, int *);
49 	int		(*pc_conf_size)(void *, pcitag_t);
50 	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
51 	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
52 
53 	int		(*pc_intr_map)(struct pci_attach_args *,
54 			    pci_intr_handle_t *);
55 	const char	*(*pc_intr_string)(void *, pci_intr_handle_t);
56 	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
57 			    int, int (*)(void *), void *, const char *);
58 	void		(*pc_intr_disestablish)(void *, void *);
59 
60 	void		*(*pc_alloc_parent)(struct device *,
61 			    struct pci_attach_args *, int);
62 };
63 
64 /*
65  * Functions provided to machine-independent PCI code.
66  */
67 #define	pci_attach_hook(p, s, pba)					\
68     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
69 #define	pci_bus_maxdevs(c, b)						\
70     (*(c)->pc_bus_maxdevs)((c)->_cookie, (b))
71 #define	pci_make_tag(c, b, d, f)					\
72     (*(c)->pc_make_tag)((c)->_cookie, (b), (d), (f))
73 #define	pci_decompose_tag(c, t, bp, dp, fp)				\
74     (*(c)->pc_decompose_tag)((c)->_cookie, (t), (bp), (dp), (fp))
75 #define	pci_conf_size(c, t)						\
76     (*(c)->pc_conf_size)((c)->_cookie, (t))
77 #define	pci_conf_read(c, t, r)						\
78     (*(c)->pc_conf_read)((c)->_cookie, (t), (r))
79 #define	pci_conf_write(c, t, r, v)					\
80     (*(c)->pc_conf_write)((c)->_cookie, (t), (r), (v))
81 #define	pci_intr_map(p, ihp)						\
82     (*(p)->pa_pc->pc_intr_map)((p), (ihp))
83 #define	pci_intr_map_msi(p, ihp)	(-1)
84 #define	pci_intr_map_msix(p, vec, ihp)	(-1)
85 #define	pci_intr_line(c, ih)	(ih)
86 #define	pci_intr_string(c, ih)						\
87     (*(c)->pc_intr_string)((c)->_cookie, (ih))
88 #define	pci_intr_establish(c, ih, l, h, a, nm)				\
89     (*(c)->pc_intr_establish)((c)->_cookie, (ih), (l), (h), (a), (nm))
90 #define	pci_intr_disestablish(c, iv)					\
91     (*(c)->pc_intr_disestablish)((c)->_cookie, (iv))
92 #define	pci_probe_device_hook(c, a)	(0)
93 
94 #define	pci_min_powerstate(c, t)	(PCI_PMCSR_STATE_D3)
95 #define	pci_set_powerstate_md(c, t, s, p)
96 
97 #define	pciide_machdep_compat_intr_establish(a, b, c, d, e)	(NULL)
98 #define	pciide_machdep_compat_intr_disestablish(a, b)	((void)(a), (void)(b))
99 
100 #define	pci_dev_postattach(a, b)
101 
102 #endif /* _MACHINE_PCI_MACHDEP_H_ */
103