xref: /freebsd/sys/arm64/cavium/thunder_pcie_common.h (revision d943d79a36cf0abfc589a456b1b952365f537a87)
1*d943d79aSZbigniew Bodek /*-
2*d943d79aSZbigniew Bodek  * Copyright (c) 2015 The FreeBSD Foundation
3*d943d79aSZbigniew Bodek  * All rights reserved.
4*d943d79aSZbigniew Bodek  *
5*d943d79aSZbigniew Bodek  * Redistribution and use in source and binary forms, with or without
6*d943d79aSZbigniew Bodek  * modification, are permitted provided that the following conditions
7*d943d79aSZbigniew Bodek  * are met:
8*d943d79aSZbigniew Bodek  * 1. Redistributions of source code must retain the above copyright
9*d943d79aSZbigniew Bodek  * notice, this list of conditions and the following disclaimer.
10*d943d79aSZbigniew Bodek  * 2. Redistributions in binary form must reproduce the above copyright
11*d943d79aSZbigniew Bodek  * notice, this list of conditions and the following disclaimer in the
12*d943d79aSZbigniew Bodek  * documentation and/or other materials provided with the distribution.
13*d943d79aSZbigniew Bodek  *
14*d943d79aSZbigniew Bodek  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*d943d79aSZbigniew Bodek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*d943d79aSZbigniew Bodek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*d943d79aSZbigniew Bodek  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*d943d79aSZbigniew Bodek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*d943d79aSZbigniew Bodek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*d943d79aSZbigniew Bodek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*d943d79aSZbigniew Bodek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*d943d79aSZbigniew Bodek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*d943d79aSZbigniew Bodek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*d943d79aSZbigniew Bodek  * SUCH DAMAGE.
25*d943d79aSZbigniew Bodek  *
26*d943d79aSZbigniew Bodek  * $FreeBSD$
27*d943d79aSZbigniew Bodek  */
28*d943d79aSZbigniew Bodek 
29*d943d79aSZbigniew Bodek #ifndef _CAVIUM_THUNDER_PCIE_COMMON_H_
30*d943d79aSZbigniew Bodek #define	_CAVIUM_THUNDER_PCIE_COMMON_H_
31*d943d79aSZbigniew Bodek 
32*d943d79aSZbigniew Bodek #define	MAX_RANGES_TUPLES	5
33*d943d79aSZbigniew Bodek #define	MIN_RANGES_TUPLES	2
34*d943d79aSZbigniew Bodek 
35*d943d79aSZbigniew Bodek struct pcie_range {
36*d943d79aSZbigniew Bodek 	uint64_t	pci_base;
37*d943d79aSZbigniew Bodek 	uint64_t	phys_base;
38*d943d79aSZbigniew Bodek 	uint64_t	size;
39*d943d79aSZbigniew Bodek 	uint64_t	flags;
40*d943d79aSZbigniew Bodek };
41*d943d79aSZbigniew Bodek 
42*d943d79aSZbigniew Bodek uint32_t range_addr_is_pci(struct pcie_range *, uint64_t, uint64_t);
43*d943d79aSZbigniew Bodek uint32_t range_addr_is_phys(struct pcie_range *, uint64_t, uint64_t);
44*d943d79aSZbigniew Bodek uint64_t range_addr_pci_to_phys(struct pcie_range *, uint64_t);
45*d943d79aSZbigniew Bodek int thunder_common_alloc_msi(device_t, device_t, int, int, int *);
46*d943d79aSZbigniew Bodek int thunder_common_alloc_msix(device_t, device_t, int *);
47*d943d79aSZbigniew Bodek int thunder_common_map_msi(device_t, device_t, int, uint64_t *, uint32_t *);
48*d943d79aSZbigniew Bodek int thunder_common_release_msi(device_t, device_t, int, int *);
49*d943d79aSZbigniew Bodek int thunder_common_release_msix(device_t, device_t, int);
50*d943d79aSZbigniew Bodek 
51*d943d79aSZbigniew Bodek #endif /* _CAVIUM_THUNDER_PCIE_COMMON_H_ */
52