1/*	$OpenBSD: pci_machdep.h,v 1.30 2016/05/04 14:30:00 kettenis Exp $	*/
2/*	$NetBSD: pci_machdep.h,v 1.6 1996/11/19 04:49:21 cgd Exp $	*/
3
4/*
5 * Copyright (c) 1996 Carnegie-Mellon University.
6 * All rights reserved.
7 *
8 * Author: Chris G. Demetriou
9 *
10 * Permission to use, copy, modify and distribute this software and
11 * its documentation is hereby granted, provided that both the copyright
12 * notice and this permission notice appear in all copies of the
13 * software, derivative works or modified versions, and any portions
14 * thereof, and that both notices appear in supporting documentation.
15 *
16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 *
20 * Carnegie Mellon requests users of this software to return to
21 *
22 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
23 *  School of Computer Science
24 *  Carnegie Mellon University
25 *  Pittsburgh PA 15213-3890
26 *
27 * any improvements or extensions that they make and grant Carnegie the
28 * rights to redistribute these changes.
29 */
30
31/*
32 * Machine-specific definitions for PCI autoconfiguration.
33 */
34
35/*
36 * Types provided to machine-independent PCI code
37 */
38typedef struct alpha_pci_chipset *pci_chipset_tag_t;
39typedef u_long pcitag_t;
40typedef u_long pci_intr_handle_t;
41
42/*
43 * Forward declarations.
44 */
45struct pci_attach_args;
46
47/*
48 * alpha-specific PCI structure and type definitions.
49 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
50 */
51struct alpha_pci_chipset {
52	void		*pc_conf_v;
53	void		(*pc_attach_hook)(struct device *,
54			    struct device *, struct pcibus_attach_args *);
55	int		(*pc_bus_maxdevs)(void *, int);
56	pcitag_t	(*pc_make_tag)(void *, int, int, int);
57	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
58			    int *, int *);
59	int		(*pc_conf_size)(void *, pcitag_t);
60	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
61	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
62
63	void		*pc_intr_v;
64	int		(*pc_intr_map)(struct pci_attach_args *,
65			    pci_intr_handle_t *);
66	const char	*(*pc_intr_string)(void *, pci_intr_handle_t);
67	int		(*pc_intr_line)(void *, pci_intr_handle_t);
68	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
69			    int, int (*)(void *), void *, const char *);
70	void		(*pc_intr_disestablish)(void *, void *);
71
72        /* alpha-specific */
73        void            *(*pc_pciide_compat_intr_establish)(void *,
74                            struct device *, struct pci_attach_args *, int,
75                            int (*)(void *), void *);
76	void            (*pc_pciide_compat_intr_disestablish)(void *,
77			    void *);
78	char 		*pc_name;	/* PCI chipset name */
79	vaddr_t		pc_mem;		/* PCI memory address */
80	vaddr_t		pc_dense;	/* PCI dense memory address */
81	vaddr_t		pc_ports;	/* PCI port address */
82	long		pc_hae_mask;	/* PCI chipset mask for HAE register */
83	int		pc_bwx;		/* chipset supports BWX */
84};
85
86extern struct alpha_pci_chipset *alpha_pci_chipset;
87int alpha_sysctl_chipset(int *, u_int, char *, size_t *);
88
89/*
90 * Functions provided to machine-independent PCI code.
91 */
92#define	pci_attach_hook(p, s, pba)					\
93    (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
94#define	pci_bus_maxdevs(c, b)						\
95    (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
96#define	pci_make_tag(c, b, d, f)					\
97    (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
98#define	pci_decompose_tag(c, t, bp, dp, fp)				\
99    (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
100#define	pci_conf_size(c, t)						\
101    (*(c)->pc_conf_size)((c)->pc_conf_v, (t))
102#define	pci_conf_read(c, t, r)						\
103    (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
104#define	pci_conf_write(c, t, r, v)					\
105    (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
106#define	pci_intr_map_msi(pa, ihp)	(-1)
107#define	pci_intr_map_msix(pa, vec, ihp)	(-1)
108#define	pci_intr_string(c, ih)						\
109    (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
110#define	pci_intr_line(c, ih)						\
111    (*(c)->pc_intr_line)((c)->pc_intr_v, (ih))
112#define	pci_intr_establish(c, ih, l, h, a, nm)				\
113    (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a), (nm))
114#define	pci_intr_disestablish(c, iv)					\
115    (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
116#define	pci_probe_device_hook(c, a)	(0)
117
118#define	pci_min_powerstate(c, t)	(PCI_PMCSR_STATE_D3)
119#define	pci_set_powerstate_md(c, t, s, p)
120
121/*
122 * alpha-specific PCI functions.
123 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
124 */
125void	pci_display_console(bus_space_tag_t, bus_space_tag_t,
126	    pci_chipset_tag_t, int, int, int);
127#define alpha_pciide_compat_intr_establish(c, d, p, ch, f, a)		\
128    ((c)->pc_pciide_compat_intr_establish == NULL ? NULL :		\
129     (*(c)->pc_pciide_compat_intr_establish)((c)->pc_conf_v, (d), (p),	\
130        (ch), (f), (a)))
131
132#define alpha_pciide_compat_intr_disestablish(c, cookie)		\
133    do { if ((c)->pc_pciide_compat_intr_disestablish != NULL)		\
134	    ((c)->pc_pciide_compat_intr_disestablish)((c)->pc_conf_v,	\
135            (cookie)); } while (0)
136
137#define	pci_dev_postattach(a, b)
138
139#ifdef _KERNEL
140void	pci_display_console(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
141	    int, int, int);
142int	pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
143#endif /* _KERNEL */
144