xref: /openbsd-src/sys/arch/loongson/include/pci_machdep.h (revision 058ea91224d14a3d3097d3da93630f63bfdeece5)
1*058ea912Skettenis /*	$OpenBSD: pci_machdep.h,v 1.10 2016/05/04 14:30:01 kettenis Exp $ */
2be674eb1Smiod 
3be674eb1Smiod /*
4be674eb1Smiod  * Copyright (c) 2003-2004 Opsycon AB  (www.opsycon.se / www.opsycon.com)
5be674eb1Smiod  *
6be674eb1Smiod  * Redistribution and use in source and binary forms, with or without
7be674eb1Smiod  * modification, are permitted provided that the following conditions
8be674eb1Smiod  * are met:
9be674eb1Smiod  * 1. Redistributions of source code must retain the above copyright
10be674eb1Smiod  *    notice, this list of conditions and the following disclaimer.
11be674eb1Smiod  * 2. Redistributions in binary form must reproduce the above copyright
12be674eb1Smiod  *    notice, this list of conditions and the following disclaimer in the
13be674eb1Smiod  *    documentation and/or other materials provided with the distribution.
14be674eb1Smiod  *
15be674eb1Smiod  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16be674eb1Smiod  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17be674eb1Smiod  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18be674eb1Smiod  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19be674eb1Smiod  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20be674eb1Smiod  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21be674eb1Smiod  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22be674eb1Smiod  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23be674eb1Smiod  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24be674eb1Smiod  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25be674eb1Smiod  * SUCH DAMAGE.
26be674eb1Smiod  *
27be674eb1Smiod  */
28be674eb1Smiod 
29be674eb1Smiod typedef struct mips_pci_chipset *pci_chipset_tag_t;
30be674eb1Smiod typedef u_long pcitag_t;
31be674eb1Smiod typedef u_long pci_intr_handle_t;
32be674eb1Smiod 
33be674eb1Smiod struct pci_attach_args;
34be674eb1Smiod 
35be674eb1Smiod /*
36be674eb1Smiod  * mips-specific PCI structure and type definitions.
37be674eb1Smiod  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
38be674eb1Smiod  */
39be674eb1Smiod struct mips_pci_chipset {
40be674eb1Smiod     void	*pc_conf_v;
41be674eb1Smiod     void	(*pc_attach_hook)(struct device *,
42be674eb1Smiod 		    struct device *, struct pcibus_attach_args *);
43be674eb1Smiod     int		(*pc_bus_maxdevs)(void *, int);
44be674eb1Smiod     pcitag_t	(*pc_make_tag)(void *, int, int, int);
45be674eb1Smiod     void	(*pc_decompose_tag)(void *, pcitag_t, int *,
46be674eb1Smiod 		    int *, int *);
47b1926db3Smiod     int		(*pc_conf_size)(void *, pcitag_t);
48be674eb1Smiod     pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
49be674eb1Smiod     void	(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
50be674eb1Smiod 
51be674eb1Smiod     void	*pc_intr_v;
52be674eb1Smiod     int		(*pc_intr_map)(struct pci_attach_args *, pci_intr_handle_t *);
53be674eb1Smiod     const char	*(*pc_intr_string)(void *, pci_intr_handle_t);
54be674eb1Smiod     void	*(*pc_intr_establish)(void *, pci_intr_handle_t,
55be674eb1Smiod 		    int, int (*)(void *), void *, char *);
56be674eb1Smiod     void	(*pc_intr_disestablish)(void *, void *);
57be674eb1Smiod };
58be674eb1Smiod 
59be674eb1Smiod /*
60be674eb1Smiod  * Functions provided to machine-independent PCI code.
61be674eb1Smiod  */
62be674eb1Smiod #define	pci_attach_hook(p, s, pba)					\
63be674eb1Smiod     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
64be674eb1Smiod #define	pci_bus_maxdevs(c, b)						\
65be674eb1Smiod     (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
66be674eb1Smiod #define	pci_make_tag(c, b, d, f)					\
67be674eb1Smiod     (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
68be674eb1Smiod #define	pci_decompose_tag(c, t, bp, dp, fp)				\
69be674eb1Smiod     (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
70b1926db3Smiod #define	pci_conf_size(c, t)						\
71b1926db3Smiod     (*(c)->pc_conf_size)((c)->pc_conf_v, (t))
72be674eb1Smiod #define	pci_conf_read(c, t, r)						\
73be674eb1Smiod     (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
74be674eb1Smiod #define	pci_conf_write(c, t, r, v)					\
75be674eb1Smiod     (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
76be674eb1Smiod #define	pci_intr_map(c, ihp)				\
77be674eb1Smiod     (*(c)->pa_pc->pc_intr_map)((c), (ihp))
7842e25420Skettenis #define	pci_intr_map_msi(c, ihp)	(-1)
79*058ea912Skettenis #define	pci_intr_map_msix(c, vec, ihp)	(-1)
80be674eb1Smiod #define	pci_intr_string(c, ih)						\
81be674eb1Smiod     (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
82be674eb1Smiod #define	pci_intr_establish(c, ih, l, h, a, nm)				\
83be674eb1Smiod     (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a), (nm))
84be674eb1Smiod #define	pci_intr_disestablish(c, iv)					\
85be674eb1Smiod     (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
86121a46e8Smiod #define	pci_probe_device_hook(c, a)	(0)
87be674eb1Smiod 
889a8f49f4Skettenis #define	pci_min_powerstate(c, t)	(PCI_PMCSR_STATE_D3)
8925b7ac45Smpi #define	pci_set_powerstate_md(c, t, s, p)
909a8f49f4Skettenis 
91be674eb1Smiod /* PCI view of CPU memory */
92be674eb1Smiod extern paddr_t loongson_dma_base;
93b870770aSmiod 
94b870770aSmiod /*
95b870770aSmiod  * Functions used during early system configuration.
96b870770aSmiod  */
97b870770aSmiod 
9803052511Smiod extern pcitag_t (*pci_make_tag_early)(int, int, int);
9903052511Smiod extern pcireg_t (*pci_conf_read_early)(pcitag_t, int);
100ea14b1d7Sjordan 
101ea14b1d7Sjordan #define	pci_dev_postattach(a, b)
102