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