]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/bhnd/cores/pcie2/bhnd_pcie2_var.h
Merge llvm trunk r351319, resolve conflicts, and update FREEBSD-Xlist.
[FreeBSD/FreeBSD.git] / sys / dev / bhnd / cores / pcie2 / bhnd_pcie2_var.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2015 Landon Fuller <landon@landonf.org>
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  *    without modification.
13  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
14  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
15  *    redistribution must be conditioned upon including a substantially
16  *    similar Disclaimer requirement for further binary redistribution.
17  *
18  * NO WARRANTY
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
22  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
24  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
27  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29  * THE POSSIBILITY OF SUCH DAMAGES.
30  * 
31  * $FreeBSD$
32  */
33
34 #ifndef _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_
35 #define _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_
36
37 #include <sys/param.h>
38 #include <sys/bus.h>
39
40 /*
41  * Shared PCIe-G2 Bridge/Host Bridge definitions.
42  */
43
44 DECLARE_CLASS(bhnd_pcie2_driver);
45 struct bhnd_pcie2_softc;
46
47 int             bhnd_pcie2_generic_probe(device_t dev);
48 int             bhnd_pcie2_generic_attach(device_t dev);
49 int             bhnd_pcie2_generic_detach(device_t dev);
50 int             bhnd_pcie2_generic_suspend(device_t dev);
51 int             bhnd_pcie2_generic_resume(device_t dev);
52
53
54 uint32_t        bhnd_pcie2_read_proto_reg(struct bhnd_pcie2_softc *sc,
55                     uint32_t addr);
56 void            bhnd_pcie2_write_proto_reg(struct bhnd_pcie2_softc *sc,
57                     uint32_t addr, uint32_t val);
58 int             bhnd_pcie2_mdio_read(struct bhnd_pcie2_softc *sc, int phy,
59                     int reg);
60 int             bhnd_pcie2_mdio_write(struct bhnd_pcie2_softc *sc, int phy,
61                     int reg, int val);
62 int             bhnd_pcie2_mdio_read_ext(struct bhnd_pcie2_softc *sc, int phy,
63                     int devaddr, int reg);
64 int             bhnd_pcie2_mdio_write_ext(struct bhnd_pcie2_softc *sc,
65                     int phy, int devaddr, int reg, int val);
66
67 /**
68  * bhnd_pcie2 child device info
69  */
70 struct bhnd_pcie2_devinfo {
71         struct resource_list    resources;
72 };
73
74 /*
75  * Generic PCIe-G2 bridge/end-point driver state.
76  * 
77  * Must be first member of all subclass softc structures.
78  */
79 struct bhnd_pcie2_softc {
80         device_t                 dev;           /**< pci device */
81         uint32_t                 quirks;        /**< quirk flags */
82
83         struct mtx               mtx;           /**< state mutex used to protect
84                                                      interdependent register
85                                                      accesses. */
86
87         struct bhnd_resource    *mem_res;       /**< device register block. */
88         int                      mem_rid;       /**< register block RID */
89 };
90
91
92 #define BHND_PCIE2_LOCK_INIT(sc) \
93         mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
94             "BHND PCIe-G2 driver lock", MTX_DEF)
95 #define BHND_PCIE2_LOCK(sc)                     mtx_lock(&(sc)->mtx)
96 #define BHND_PCIE2_UNLOCK(sc)                   mtx_unlock(&(sc)->mtx)
97 #define BHND_PCIE2_LOCK_ASSERT(sc, what)        mtx_assert(&(sc)->mtx, what)
98 #define BHND_PCIE2_LOCK_DESTROY(sc)             mtx_destroy(&(sc)->mtx)
99
100 #endif /* _BHND_CORES_PCIE2_BHND_PCIE2_VAR_H_ */